]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[netdevice] Add method for generating EUI-64 address from link-layer address
authorMichael Brown <mcb30@ipxe.org>
Fri, 30 Aug 2013 18:05:03 +0000 (19:05 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 3 Sep 2013 00:24:15 +0000 (01:24 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/net/ipoib.c
src/include/ipxe/ethernet.h
src/include/ipxe/netdevice.h
src/net/80211/net80211.c
src/net/ethernet.c

index c1b8cad9a6ca58f4eb3ec96e2019e7d2cb95e264..1b53917769637994dc5d9576656a28fefc8e3bb3 100644 (file)
@@ -265,6 +265,7 @@ struct ll_protocol ipoib_protocol __ll_protocol = {
        .ntoa           = eth_ntoa,
        .mc_hash        = eth_mc_hash,
        .eth_addr       = eth_eth_addr,
+       .eui64          = eth_eui64,
        .flags          = LL_NAME_ONLY,
 };
 
index 1794ff67ee37e58f118e91c97064e6d9c63b9983..5ffc45b738ffb1de8dcdf9899a05ef393daf6637 100644 (file)
@@ -91,6 +91,7 @@ extern const char * eth_ntoa ( const void *ll_addr );
 extern int eth_mc_hash ( unsigned int af, const void *net_addr,
                         void *ll_addr );
 extern int eth_eth_addr ( const void *ll_addr, void *eth_addr );
+extern int eth_eui64 ( const void *ll_addr, void *eui64 );
 extern struct net_device * alloc_etherdev ( size_t priv_size );
 
 #endif /* _IPXE_ETHERNET_H */
index 7288ad86dc554aa5b00c9a416c29180185aea548..7f819d9ab84afd4e5b1d8ef531e79d1724b0de20 100644 (file)
@@ -175,8 +175,17 @@ struct ll_protocol {
         *
         * @v ll_addr           Link-layer address
         * @v eth_addr          Ethernet-compatible address to fill in
+        * @ret rc              Return status code
         */
        int ( * eth_addr ) ( const void *ll_addr, void *eth_addr );
+       /**
+        * Generate EUI-64 address
+        *
+        * @v ll_addr           Link-layer address
+        * @v eui64             EUI-64 address to fill in
+        * @ret rc              Return status code
+        */
+       int ( * eui64 ) ( const void *ll_addr, void *eui64 );
        /** Link-layer protocol
         *
         * This is an ARPHRD_XXX constant, in network byte order.
index 54df79056d867188baa88f53aadad992949f3bb1..3893f652c90b25eade2fa632943149bb5690704a 100644 (file)
@@ -599,6 +599,7 @@ static struct ll_protocol net80211_ll_protocol __ll_protocol = {
        .ntoa = eth_ntoa,
        .mc_hash = eth_mc_hash,
        .eth_addr = eth_eth_addr,
+       .eui64 = eth_eui64,
        .ll_proto = htons ( ARPHRD_ETHER ),     /* "encapsulated Ethernet" */
        .hw_addr_len = ETH_ALEN,
        .ll_addr_len = ETH_ALEN,
index 4fd2ab6e538f8d674565ff8993571f7d89379943..013b2d76299013fa43526b8dbafd25a53f727fdf 100644 (file)
@@ -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,
 };
 
 /**