From d5d3bbcd4442ad193de175499cffb6b535885f4f Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Wed, 5 Feb 2014 09:46:52 +0100 Subject: [PATCH] add EUI-64 support for nativenet --- cpu/native/include/nativenet.h | 17 +++++++++++++++++ cpu/native/include/nativenet_internal.h | 1 + cpu/native/net/interface.c | 15 +++++++++++++++ cpu/native/net/tap.c | 11 +++++++++++ 4 files changed, 44 insertions(+) diff --git a/cpu/native/include/nativenet.h b/cpu/native/include/nativenet.h index 0251b68a0e..79dc1e3a13 100644 --- a/cpu/native/include/nativenet.h +++ b/cpu/native/include/nativenet.h @@ -84,6 +84,23 @@ radio_address_t nativenet_set_address(radio_address_t address); */ radio_address_t nativenet_get_address(); +/** + * @brief Sets the IEEE long address of the nativenet transceiver. + * + * @param[in] addr The desired address. + * + * @return The set address after calling. + */ +uint64_t nativenet_set_address_long(uint64_t addr); + +/** + * @brief Gets the current IEEE long address of the nativenet + * transceiver. + * + * @return The current IEEE long address. + */ +uint64_t nativenet_get_address_long(void); + /** * Set transceiver channel * diff --git a/cpu/native/include/nativenet_internal.h b/cpu/native/include/nativenet_internal.h index 58a2f2d7c1..954f4bdcd3 100644 --- a/cpu/native/include/nativenet_internal.h +++ b/cpu/native/include/nativenet_internal.h @@ -38,6 +38,7 @@ struct rx_buffer_s { }; extern struct rx_buffer_s _nativenet_rx_buffer[RX_BUF_SIZE]; +extern uint64_t _native_net_addr_long; void _nativenet_handle_packet(radio_packet_t *packet); int8_t send_buf(radio_packet_t *packet); diff --git a/cpu/native/net/interface.c b/cpu/native/net/interface.c index 59998dbea0..1d97548f6c 100644 --- a/cpu/native/net/interface.c +++ b/cpu/native/net/interface.c @@ -47,6 +47,7 @@ uint16_t _native_net_pan; uint8_t _native_net_monitor; static int _native_net_tpid; radio_address_t _native_net_addr; +uint64_t _native_net_addr_long; /************************************************************************/ /* nativenet.h **********************************************************/ @@ -108,6 +109,20 @@ radio_address_t nativenet_get_address() return _native_net_addr; } +uint64_t nativenet_get_address_long(void) +{ + DEBUG("nativenet_get_address_long -> address = %"PRIx64"\n", _native_net_addr_long); + return _native_net_addr_long; +} + +uint64_t nativenet_set_address_long(uint64_t address) +{ + DEBUG("nativenet_set_address_long(address=%"PRIx64")\n", address); + warnx("nativenet_set_address_long: this does not actually change the interfaces address"); + _native_net_addr_long = address; + return _native_net_addr_long; +} + int8_t nativenet_send(radio_packet_t *packet) { packet->src = _native_net_addr; diff --git a/cpu/native/net/tap.c b/cpu/native/net/tap.c index e378b53cae..957519602e 100644 --- a/cpu/native/net/tap.c +++ b/cpu/native/net/tap.c @@ -284,6 +284,17 @@ int tap_init(char *name) } memcpy(_native_tap_mac, ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN); #endif + DEBUG("_native_tap_mac: %02x:%02x:%02x:%02x:%02x:%02x\n", _native_tap_mac[0], _native_tap_mac[1], _native_tap_mac[2], _native_tap_mac[3], _native_tap_mac[4], _native_tap_mac[5]); + + unsigned char *eui_64 = (unsigned char*)&_native_net_addr_long; + eui_64[0] = _native_tap_mac[0]; + eui_64[1] = _native_tap_mac[1]; + eui_64[2] = _native_tap_mac[2]; + eui_64[3] = 0xff; + eui_64[4] = 0xfe; + eui_64[5] = _native_tap_mac[3]; + eui_64[6] = _native_tap_mac[4]; + eui_64[7] = _native_tap_mac[5]; /* configure signal handler for fds */ register_interrupt(SIGIO, _native_handle_tap_input);