On the connect-me 9210 when my application starts I see the message:
IAM:AUTOIP IPv4 169.254.43.162 on eth0:0
How can I retrieve this IP address? I want to use it for
multicast DNS.
On the connect-me 9210 when my application starts I see the message:
IAM:AUTOIP IPv4 169.254.43.162 on eth0:0
How can I retrieve this IP address? I want to use it for
multicast DNS.
autoip is laways on interface eth0:0
please check Netos API reference manual. for example:
customizeIamFindInterfaceConfig
Declaration
NaIamParams_t * customizeIamFindInterfaceConfig(char const * ifname, NaIamParamsInfo_t * config);
Arguments
Name Description
ifname A nul-terminated string name of the interface for which to retrieve settings. For example, “eth0” or “eth0:0”. The string is case sensitive.
config Pointer to buffer with IAM configuration.
Return values
Value Description
NULL No configuration for interface was found.
pointer Pointer to interface configuration.
another one: customizeIamGetAutoipConfig
or customizeIamGetIfAddress
I found the code below which seems to work.
I have 2 more questions:
Is there some event which can tell me when the AUTOIP has completed?
If this is the only address I need; what is the best way
to disable the static address set up during project configuration?
theIAMStatus = customizeIamGetIfAddress("eth0:0", AF_INET, &theIAMIPAddress);
if(theIAMStatus != NA_IAM_STATUS_SUCCESS)
{
printf("Unable to retrieve IP address
");
return;
}
myNAStatus = na_ntop(theIAMIPAddress.ipAddress.addr.ipv4.sin_family, &theIAMIPAddress.ipAddress, theIPAddressBuffer, MAX_IP_BUFFER_SIZE);
if(myNAStatus != NASTATUS_SUCCESS)
{
printf("Nothing available
");
}
else
{
printf("IP address found was %s
", theIPAddressBuffer);
}
I believe bsproot.c waits for it by default:
#if ((BSP_WANT_ETHERNET == TRUE) && (BSP_ETH_WIFI_BRIDGE == FALSE))
// No Ethernet IP configuration for the bridge
if ((result) && (customizeIamGetIfAddrInfo(BP_ETH_INTERFACE, &addrInfo) == NA_IAM_STATUS_SUCCESS))
{
result = ((addrInfo.method == NA_IAM_METHOD_AUTOIP) || (addrInfo.method == NA_IAM_METHOD_NONE));
}
#endif
and also
if (NAWaitForIpConfig == TRUE)
{
#if (BSP_WANT_WIRELESS == TRUE) || (BSP_WANT_ETHERNET == TRUE)
WORD32 autoIpDelayTicks = NABspAutoIpDelay * NABspTicksPerSecond;
while (NAGetIPConfigureState() != naIpStateConfigured) /* wait until stack has IP parameters */
{
tx_thread_sleep (1); /* let other tasks run */
}
while ((isOnlyAutoIp()) && (autoIpDelayTicks != 0))
{
autoIpDelayTicks--;
tx_thread_sleep(1);
}
#endif
}
}
I have never tried this but potentially it could work:
naIamDisable(“eth0:3”, NA_IAM_METHOD_STATIC);
returns 1, or NA_IAM_STATUS_SUCCESS
Alternatively define a crazy static IP (perhaps the same one you get on autoip) that would never be used or set up for DHCP if there are no DHCP server available on the network.