X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fipv6cp.c;h=dbdc5ef8b38c21b217a9bd769ad49b9c540f87e1;hb=0f9bd9807d92d624782fa3bc3d2abfb305edf7ee;hp=dec6cfea7568f75e808077f937633ea730f87ed7;hpb=d732b2bbc1920fd6eddc39e4abe8fcd7e0ca4683;p=ppp.git diff --git a/pppd/ipv6cp.c b/pppd/ipv6cp.c index dec6cfe..dbdc5ef 100644 --- a/pppd/ipv6cp.c +++ b/pppd/ipv6cp.c @@ -1055,6 +1055,46 @@ endswitch: } +/* + * ether_to_eui64 - Convert 48-bit Ethernet address into 64-bit EUI + * + * walks the list of valid ethernet interfaces, and convert the first + * found 48-bit MAC address into EUI 64. caller also assumes that + * the system has a properly configured Ethernet interface for this + * function to return non-zero. + */ +static int +ether_to_eui64(eui64_t *p_eui64) +{ + u_char addr[6]; + char *if_name; + + if ((if_name = get_first_ethernet()) == NULL) { + error("no persistent id can be found"); + return 0; + } + + if (get_if_hwaddr(addr, if_name) < 0) { + error("could not obtain hardware address for %s", if_name); + return 0; + } + + /* + * And convert the EUI-48 into EUI-64, per RFC 2472 [sec 4.1] + */ + p_eui64->e8[0] = addr[0] | 0x02; + p_eui64->e8[1] = addr[1]; + p_eui64->e8[2] = addr[2]; + p_eui64->e8[3] = 0xFF; + p_eui64->e8[4] = 0xFE; + p_eui64->e8[5] = addr[3]; + p_eui64->e8[6] = addr[4]; + p_eui64->e8[7] = addr[5]; + + return 1; +} + + /* * ipv6_check_options - check that any IP-related options are OK, * and assign appropriate defaults.