Skip to content

Instantly share code, notes, and snippets.

@austinschwartz
Last active January 19, 2017 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save austinschwartz/e2ce308f639995caf3688eead1991d25 to your computer and use it in GitHub Desktop.
Save austinschwartz/e2ce308f639995caf3688eead1991d25 to your computer and use it in GitHub Desktop.
link-local unicast
mac = "98:4f:ee:00:0c:3a"
x = mac.split(':')
x.insert(3, 'ff')
x.insert(4, 'fe')
x[0] = (x[0].to_i(16) ^ 0b00000010).to_s(16)
x.insert(0, 'fe')
x.insert(1, '80')
x = x.each_slice(2).map{|x|x.join('')}.join(':')
x.insert(4, ":")
print(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment