diff options
author | volker <volker@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2010-01-15 21:44:04 +0000 |
---|---|---|
committer | volker <volker@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2010-01-15 21:44:04 +0000 |
commit | 69fecdd3d64aac4d19a2fa5777ea2b6c017fe9cf (patch) | |
tree | 67eb5f0c723e5942405bae3f8a4aef62ec1c35df /plugin_netinfo.c | |
parent | ac266e1877dfa2042a00b239ac184ce40e538770 (diff) | |
download | lcd4linux-69fecdd3d64aac4d19a2fa5777ea2b6c017fe9cf.tar.gz |
Ticket 182
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1079 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'plugin_netinfo.c')
-rw-r--r-- | plugin_netinfo.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/plugin_netinfo.c b/plugin_netinfo.c index 57c79b2..08eaee9 100644 --- a/plugin_netinfo.c +++ b/plugin_netinfo.c @@ -143,19 +143,26 @@ static void my_hwaddr(RESULT * result, RESULT * arg1) } strncpy(ifreq.ifr_name, R2S(arg1), sizeof(ifreq.ifr_name)); - // if (ioctl(socknr, SIOCGIFHWADDR, &ifreq) < 0) { - // if (ioctl(socknr, SIOCGIFMAC, &ifreq) < 0) { +#ifndef __MAC_OS_X_VERSION_10_3 + // Linux: get interface MAC address + if (ioctl(socknr, SIOCGIFHWADDR, &ifreq) < 0) { +#else + // MacOS: get interface MAC address if (ioctl(socknr, SIOCGLIFPHYADDR, &ifreq) < 0) { - errcount++; +#endif + errcount++; if (1 == errcount % 1000) { - error("%s: ioctl(IFHWADDR %s) failed: %s", "plugin_netinfo", ifreq.ifr_name, strerror(errno)); + error("%s: ioctl(IF_HARDW_ADDR %s) failed: %s", "plugin_netinfo", ifreq.ifr_name, strerror(errno)); error(" (skip next 1000 errors)"); } SetResult(&result, R_STRING, ""); return; } - // hw = (unsigned char *) ifreq.ifr_hwaddr.sa_data; +#ifndef __MAC_OS_X_VERSION_10_3 + hw = (unsigned char *) ifreq.ifr_hwaddr.sa_data; +#else hw = (unsigned char *) ifreq.ifr_data; +#endif qprintf(value, sizeof(value), "%02x:%02x:%02x:%02x:%02x:%02x", *hw, *(hw + 1), *(hw + 2), *(hw + 3), *(hw + 4), *(hw + 5)); @@ -218,8 +225,11 @@ static void my_netmask(RESULT * result, RESULT * arg1) SetResult(&result, R_STRING, ""); return; } - // sin = (struct sockaddr_in *) &ifreq.ifr_netmask; +#ifndef __MAC_OS_X_VERSION_10_3 + sin = (struct sockaddr_in *) &ifreq.ifr_netmask; +#else sin = (struct sockaddr_in *) &ifreq.ifr_data; +#endif qprintf(value, sizeof(value), "%s", inet_ntoa(sin->sin_addr)); SetResult(&result, R_STRING, value); |