On QNX 7.1, vos_getMacAddress is currently not implemented. Below is a possible implementation. It also fixes a warning "control reaches end of non-void function" in vos_getVlanId.
--- src/vos/posix/vos_sock.c (revision 2439)
+++ src/vos/posix/vos_sock.c (working copy)
@@ -80,6 +80,7 @@
# include <net/if.h>
# include <net/if_types.h>
#ifdef __QNXNTO__
+# include <net/if_dl.h>
# include <gulliver.h>
# define bswap_16(x) ENDIAN_RET16(x)
# define bswap_32(x) ENDIAN_RET32(x)
@@ -309,7 +310,37 @@
return found;
#elif defined(__QNXNTO__)
-# warning "no definition for get_mac_address() on this platform!"
+ struct ifaddrs *pIfList;
+ BOOL8 found = FALSE;
+ const char *pName = cDefaultIface;
+
+ if (pIfName != NULL)
+ {
+ pName = pIfName;
+ }
+
+ if (getifaddrs(&pIfList) == 0)
+ {
+ struct ifaddrs *cur;
+
+ for (cur = pIfList; pName != NULL && cur != NULL; cur = cur->ifa_next)
+ {
+ if (cur->ifa_addr &&
+ (cur->ifa_addr->sa_family == AF_LINK) &&
+ (strcmp(cur->ifa_name, pName) == 0))
+ {
+ struct sockaddr_dl *p = (struct sockaddr_dl *)(cur->ifa_addr);
+ memcpy(pMacAddr, LLADDR(p), VOS_MAC_SIZE);
+ found = TRUE;
+ break;
+ }
+ }
+
+ freeifaddrs(pIfList);
+ }
+
+ return found;
+
#else
# error no definition for get_mac_address() on this platform!
#endif
@@ -353,11 +384,13 @@
return vlan_id;
#elif defined(__APPLE__)
-# warning "no definition for get_mac_address() on this platform!"
+# warning "no definition for vos_getVlanId() on this platform!"
+ return 0;
#elif defined(__QNXNTO__)
-# warning "no definition for get_mac_address() on this platform!"
+# warning "no definition for vos_getVlanId() on this platform!"
+ return 0;
#else
-# error no definition for get_mac_address() on this platform!
+# error no definition for vos_getVlanId() on this platform!
#endif
}
Thanks for the fix Renaat !
I'm afraid the "#include <net if_dl.h="">" didn't make it in the commit. Without this line, the code doesn't compile/link on QNX</net>