Guest User

Untitled

a guest
Dec 12th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. mac_to_ipv6 () {
  2. IFS=':'; set $1; unset IFS
  3. ipv6_address="fe80::$(printf %02x $((0x$1 ^ 2)))$2:${3}ff:fe$4:$5$6"
  4. }
  5.  
  6. mac_to_ipv6 () {
  7. mac=$1
  8. ipv6_address=fe80::$(printf %02x $((0x${mac%%:*} ^ 2)))
  9. mac=${mac#*:}
  10. ipv6_address=$ipv6_address${mac%:*:*:*}ff:fe
  11. mac=${mac#*:*:}
  12. ipv6_address=$ipv6_address${mac%:*}${mac##*:}
  13. }
  14.  
  15. mac_to_ipv6 () {
  16. local mac=$1 byte0
  17. printf %02x -v byte0 $((0x${mac:0:2} ^ 2))
  18. ipv6_address="fe80::$byte0${mac:3:5}ff:fe${mac:9:5}${mac:15:2}"
  19. }
  20.  
  21. #!/bin/bash
  22.  
  23. IFS=':'; set $1; unset IFS
  24. printf "fe80::%x%x:%x:%x:%xn" 0x$(( 0x${1} ^ 0x02 )) 0x${2} 0x${3}ff 0xfe${4} 0x${5}${6}
  25.  
  26. $ mac_to_ipv6 00:00:00:00:00:00
  27. fe80::200:00ff:fe00:0000
  28.  
  29. mac_to_ipv6_ll() {
  30. IFS=':'; set $1; unset IFS
  31. echo "fe80::$(printf %02x $((0x$1 ^ 2)))$2:${3}ff:fe$4:$5$6"
  32. }
Add Comment
Please, Sign In to add comment