autosreqop.blogg.se

Linux C how to get MAC address
Linux C how to get MAC address









KernResult = IOServiceGetMatchingServices(kIOMasterPortDefault, MatchingDict = IOServiceMatching(kIOEthernetInterfaceClass) ĬFDictionar圜reateMutable(kCFAllocatorDefault, 0,ĬFSTR(kIOPrimaryInterface), kCFBooleanTrue) ĬFSTR(kIOPropertyMatchKey), propertyMatchDict) Static kern_return_t FindEthernetInterfaces(io_iterator_t *matchingServices)ĬFMutableDictionaryRef propertyMatchDict If(UuidCreateSequential(&uuid) = RPC_S_UUID_NO_ADDRESS) return -1 If(GetAdaptersInfo(AdapterInfo, &dwBufLen) = ERROR_SUCCESS) IP_ADAPTER_INFO AdapterInfo // Allocate informationĭWORD dwBufLen = sizeof(AdapterInfo) // Save memory size of buffer Inline long MACAddressUtility::GetMACAddressMSW(unsigned char * result) If platform is not supported then return error code Call appropriate function for each platform Long MACAddressUtility::GetMACAddress(unsigned char * result)

linux C how to get MAC address

Static long GetMACAddressLinux(unsigned char * result) Static long GetMACAddressMAC(unsigned char * result) Static long GetMACAddressMSW(unsigned char * result) Static long GetMACAddress(unsigned char * result) So, I decided to write a small class which allows obtainig MAC address for Windows, Linux, Mac OS and Windows Mobile.

linux C how to get MAC address

But what was a surprise that wxWidgets does not have API which allows obtaining MAC address in cross-platform way. In one of my current projects I had to implement client-server communication and protection by MAC address when client machine can’t connect to server if its MAC address is not allowed, regardless of network or broadband connection.











Linux C how to get MAC address