Skip to content

Instantly share code, notes, and snippets.

@ieaster1
Created February 3, 2020 13:45
Show Gist options
  • Save ieaster1/5755401a3f7fadc9353808e432f066ad to your computer and use it in GitHub Desktop.
Save ieaster1/5755401a3f7fadc9353808e432f066ad to your computer and use it in GitHub Desktop.
Output human readable IGMP Groups from /proc/net/igmp
import re
regex = re.compile(r'[0-9A-F]{8}', flags=re.MULTILINE | re.IGNORECASE)
def readable(s):
addr = ''
for i in range(0, len(s.group()), 2):
chunk = str(int(s.group()[i:i+2], 16))
addr = chunk + '.' + addr
return addr.rstrip('.')
print(re.sub(regex, lambda h: readable(h), open('/proc/net/igmp', 'r').read()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment