android: Fix the get_mac_address() function on Android. For some reason we cannot link against the ether_ntoa function.

This commit is contained in:
Rom Walton 2013-12-03 10:20:44 -05:00
parent d204b77d42
commit 229c1c50be
1 changed files with 10 additions and 1 deletions

View File

@ -261,9 +261,18 @@ int get_mac_address(char* address) {
close(sck); close(sck);
return -1; return -1;
} }
hw_addr=(struct ether_addr *)&(item->lifr_lifru.lifru_enaddr); hw_addr = (struct ether_addr *)&(item->lifr_lifru.lifru_enaddr);
#endif #endif
#ifdef _ANDROID
snprintf(
address, 18, "%02x:%02x:%02x:%02x:%02x:%02x",
hw_addr->ether_addr_octet[0], hw_addr->ether_addr_octet[1],
hw_addr->ether_addr_octet[2], hw_addr->ether_addr_octet[3],
hw_addr->ether_addr_octet[4], hw_addr->ether_addr_octet[5]
);
#else
strcpy(address, ether_ntoa(hw_addr)); strcpy(address, ether_ntoa(hw_addr));
#endif
if (strstr(item->ifr_ifrn.ifrn_name, "eth")) break; if (strstr(item->ifr_ifrn.ifrn_name, "eth")) break;
} }
close(sck); close(sck);