badprop.blogg.se

Convert mac address from integer to string representation
Convert mac address from integer to string representation






I can leave out the formatting characters ( : ) in the config file to make it a little simpler, but the config has to contain a human readable MAC address. That way I can do the conversion once when I load the config and then just compare for each packet simply If parse(input) is called with a number, it is interpreted as a 48-bit integer representing the MAC address. What I would like to do, and can't seem to get right, is convert that char* that I'm getting from the config file to something that I can directly compare to arpheader->sha. As typically represented, MAC addresses are recognizable as six groups of two hexadecimal digits, separated by hyphens, colons, or without a separator.

convert mac address from integer to string representation

What I'm doing now, that works, is looping through the arpheader->sha elements and creating a char* in the same format that I get from the config file, then comparing those. I want to compare that to a char* representation of a given MAC address from a config file "xx:xx:xx:xx:xx:xx" I'm storing packet headers in a struct* "arpheader" that has a u_char* "sha" with a length 6 that is the source hardware address from an ARP packet. I'm using libpcap to capture ARP response packets.








Convert mac address from integer to string representation