diff options
author | Michael Brown <mcb30@ipxe.org> | 2013-08-30 19:05:03 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2013-09-03 01:24:15 +0100 |
commit | 0b65c8cad6ed1b03ce1870856b3496c7be1f8bf1 (patch) | |
tree | 7735c595a01cf81212490caa99e7ad7cfffb81f5 /src/net/ethernet.c | |
parent | d5f69e93887cb9ad505b7ed6394891652f393885 (diff) | |
download | ipxe-0b65c8cad6ed1b03ce1870856b3496c7be1f8bf1.tar.gz |
[netdevice] Add method for generating EUI-64 address from link-layer address
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/ethernet.c')
-rw-r--r-- | src/net/ethernet.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/net/ethernet.c b/src/net/ethernet.c index 4fd2ab6e5..013b2d762 100644 --- a/src/net/ethernet.c +++ b/src/net/ethernet.c @@ -165,6 +165,21 @@ int eth_eth_addr ( const void *ll_addr, void *eth_addr ) { return 0; } +/** + * Generate EUI-64 address + * + * @v ll_addr Link-layer address + * @v eui64 EUI-64 address to fill in + * @ret rc Return status code + */ +int eth_eui64 ( const void *ll_addr, void *eui64 ) { + + memcpy ( ( eui64 + 0 ), ( ll_addr + 0 ), 3 ); + memcpy ( ( eui64 + 5 ), ( ll_addr + 3 ), 3 ); + *( ( uint16_t * ) ( eui64 + 3 ) ) = htons ( 0xfffe ); + return 0; +} + /** Ethernet protocol */ struct ll_protocol ethernet_protocol __ll_protocol = { .name = "Ethernet", @@ -178,6 +193,7 @@ struct ll_protocol ethernet_protocol __ll_protocol = { .ntoa = eth_ntoa, .mc_hash = eth_mc_hash, .eth_addr = eth_eth_addr, + .eui64 = eth_eui64, }; /** |