Need some help converting a MAC address to binary data for use in an ethernet frame
Posted
by Ron
on Stack Overflow
See other posts from Stack Overflow
or by Ron
Published on 2010-06-07T01:56:06Z
Indexed on
2010/06/07
2:02 UTC
Read the original article
Hit count: 279
I've been looking over various internet postings and a lot of the code I've seen looks similar to this:
def mactobinar(mac):
addr = ''
temp = mac.replace(':', '')
for i in range(0, len(temp), 2):
addr = ''.join([addr, struct.pack('B', int(temp[i: i + 2], 16)))])
return addr
Can someone explain how this code works?
© Stack Overflow or respective owner