25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
511 B

def getSrcMacFromPkt(packet):
if len(packet) < 16:
return None
return packet[10:16]
def getDstMacFromPkt(packet):
if len(packet) < 10:
return None
return packet[4:10]
def binToHexStr(binmac):
return "".join(["%02x" % ord(i) for i in binmac])
# checks if packet is a broadcast packet
def isBroadcast(packet):
binmac = getDstMacFromPkt(packet)
# normal broadcast
if binmac == '\xff\xff\xff\xff\xff\xff':
return True
# v6 multicast
if binmac.startswith('\x33\x33'):
return True
return False