From 472ee315f0a6ac88af38cc284237eade707f0e86 Mon Sep 17 00:00:00 2001 From: Martine Lenders <mlenders@inf.fu-berlin.de> Date: Fri, 7 Aug 2015 07:39:02 +0200 Subject: [PATCH] ethernet/ethertype: remove ng_ prefix --- cpu/native/include/dev_eth_tap.h | 2 +- cpu/native/ng_net/dev_eth_tap.c | 8 +-- sys/include/dev_eth_autoinit.h | 2 +- sys/include/net/dev_eth.h | 4 +- sys/include/net/{ng_ethernet.h => ethernet.h} | 26 ++++----- .../net/{ng_ethernet => ethernet}/hdr.h | 20 +++---- .../net/{ng_ethertype.h => ethertype.h} | 18 +++--- sys/include/net/ng_netdev_eth.h | 2 +- sys/include/net/ng_nettype.h | 10 ++-- .../link_layer/ng_netdev_eth/ng_netdev_eth.c | 58 +++++++++---------- 10 files changed, 74 insertions(+), 76 deletions(-) rename sys/include/net/{ng_ethernet.h => ethernet.h} (67%) rename sys/include/net/{ng_ethernet => ethernet}/hdr.h (63%) rename sys/include/net/{ng_ethertype.h => ethertype.h} (65%) diff --git a/cpu/native/include/dev_eth_tap.h b/cpu/native/include/dev_eth_tap.h index 055da3e24c..224fe1d076 100644 --- a/cpu/native/include/dev_eth_tap.h +++ b/cpu/native/include/dev_eth_tap.h @@ -36,7 +36,7 @@ typedef struct dev_eth_tap { dev_eth_t ethdev; /**< dev_eth internal member */ char tap_name[IFNAMSIZ]; /**< host dev file name */ int tap_fd; /**< host file descriptor for the TAP */ - uint8_t addr[NG_ETHERNET_ADDR_LEN]; /**< The MAC address of the TAP */ + uint8_t addr[ETHERNET_ADDR_LEN]; /**< The MAC address of the TAP */ uint8_t promiscous; /**< Flag for promiscous mode */ } dev_eth_tap_t; diff --git a/cpu/native/ng_net/dev_eth_tap.c b/cpu/native/ng_net/dev_eth_tap.c index be819279a4..77345df079 100644 --- a/cpu/native/ng_net/dev_eth_tap.c +++ b/cpu/native/ng_net/dev_eth_tap.c @@ -63,7 +63,7 @@ static int _recv(dev_eth_t *ethdev, char* buf, int n); static inline void _get_mac_addr(dev_eth_t *ethdev, uint8_t *dst) { dev_eth_tap_t *dev = (dev_eth_tap_t*)ethdev; - memcpy(dst, dev->addr, NG_ETHERNET_ADDR_LEN); + memcpy(dst, dev->addr, ETHERNET_ADDR_LEN); } static inline int _get_promiscous(dev_eth_t *ethdev) { @@ -112,10 +112,10 @@ static int _recv(dev_eth_t *dev_eth, char *buf, int len) { DEBUG("ng_tapnet: read %d bytes\n", nread); if (nread > 0) { - ng_ethernet_hdr_t *hdr = (ng_ethernet_hdr_t *)buf; + ethernet_hdr_t *hdr = (ethernet_hdr_t *)buf; if (!(dev->promiscous) && !_is_addr_multicast(hdr->dst) && !_is_addr_broadcast(hdr->dst) && - (memcmp(hdr->dst, dev->addr, NG_ETHERNET_ADDR_LEN) != 0)) { + (memcmp(hdr->dst, dev->addr, ETHERNET_ADDR_LEN) != 0)) { DEBUG("ng_eth_dev: received for %02x:%02x:%02x:%02x:%02x:%02x\n" "That's not me => Dropped\n", hdr->dst[0], hdr->dst[1], hdr->dst[2], @@ -250,7 +250,7 @@ static int _init(dev_eth_t *ethdev) } real_exit(EXIT_FAILURE); } - memcpy(dev->addr, ifr.ifr_hwaddr.sa_data, NG_ETHERNET_ADDR_LEN); + memcpy(dev->addr, ifr.ifr_hwaddr.sa_data, ETHERNET_ADDR_LEN); /* change mac addr so it differs from what the host is using */ dev->addr[5]++; diff --git a/sys/include/dev_eth_autoinit.h b/sys/include/dev_eth_autoinit.h index 3058e8aeaf..715225b2bf 100644 --- a/sys/include/dev_eth_autoinit.h +++ b/sys/include/dev_eth_autoinit.h @@ -8,7 +8,7 @@ /** * @defgroup sys_net_dev_eth dev_eth auto setup - * @ingroup net_ng_ethernet + * @ingroup net_ethernet * @file * @brief Automatically setup available ethernet devices * @{ diff --git a/sys/include/net/dev_eth.h b/sys/include/net/dev_eth.h index 78c8c10ec0..69718b01d8 100644 --- a/sys/include/net/dev_eth.h +++ b/sys/include/net/dev_eth.h @@ -9,7 +9,7 @@ /** * @defgroup net_dev_eth_ll Low-Level Driver Inteface - * @ingroup net_ng_ethernet + * @ingroup net_ethernet * @file * @brief Low-level ethernet driver interface * @{ @@ -58,7 +58,7 @@ extern "C" { #endif #include <stdint.h> -#include "ng_ethernet/hdr.h" +#include "ethernet/hdr.h" /** * @brief Structure to hold driver state diff --git a/sys/include/net/ng_ethernet.h b/sys/include/net/ethernet.h similarity index 67% rename from sys/include/net/ng_ethernet.h rename to sys/include/net/ethernet.h index 3d6ab91d69..b8513c947b 100644 --- a/sys/include/net/ng_ethernet.h +++ b/sys/include/net/ethernet.h @@ -7,7 +7,7 @@ */ /** - * @defgroup net_ng_ethernet Ethernet + * @defgroup net_ethernet Ethernet * @ingroup net * @brief Ethernet implementation * @{ @@ -19,35 +19,33 @@ */ -#ifndef NG_ETHERNET_H_ -#define NG_ETHERNET_H_ +#ifndef ETHERNET_H_ +#define ETHERNET_H_ #include <stdint.h> -#include "net/ng_ethernet/hdr.h" +#include "net/ethernet/hdr.h" #include "net/eui64.h" #ifdef __cplusplus extern "C" { #endif -#define NG_ETHERNET_DATA_LEN (1500) /**< maximum number of bytes in payload */ -#define NG_ETHERNET_FCS_LEN (4) /**< number of bytes in the FCS +#define ETHERNET_DATA_LEN (1500) /**< maximum number of bytes in payload */ +#define ETHERNET_FCS_LEN (4) /**< number of bytes in the FCS * (frame check sequence) */ /** * @brief maximum number of bytes in an ethernet frame (without FCS) */ -#define NG_ETHERNET_FRAME_LEN (NG_ETHERNET_DATA_LEN + \ - sizeof(ng_ethernet_hdr_t)) -#define NG_ETHERNET_MIN_LEN (64) /**< minimum number of bytes in an +#define ETHERNET_FRAME_LEN (ETHERNET_DATA_LEN + sizeof(ethernet_hdr_t)) +#define ETHERNET_MIN_LEN (64) /**< minimum number of bytes in an * ethernet frame (with FCF) */ /** * @brief maximum number of bytes in an ethernet frame (with FCF) */ -#define NG_ETHERNET_MAX_LEN (NG_ETHERNET_FRAME_LEN + \ - NG_ETHERNET_FCS_LEN) +#define ETHERNET_MAX_LEN (ETHERNET_FRAME_LEN + ETHERNET_FCS_LEN) /** * @brief Generates an IPv6 interface identifier from a 48-bit MAC address. @@ -58,9 +56,9 @@ extern "C" { * * @param[out] eui64 The resulting EUI-64. * @param[in] mac A 48-bit MAC address. Is expected to be at least - * @ref NG_ETHERNET_ADDR_LEN long. + * @ref ETHERNET_ADDR_LEN long. */ -static inline void ng_ethernet_get_iid(eui64_t *eui64, uint8_t *mac) +static inline void ethernet_get_iid(eui64_t *eui64, uint8_t *mac) { eui64->uint8[0] = mac[0] ^ 0x02; eui64->uint8[1] = mac[1]; @@ -76,7 +74,7 @@ static inline void ng_ethernet_get_iid(eui64_t *eui64, uint8_t *mac) } #endif -#endif /* NG_ETHERNET_H_ */ +#endif /* ETHERNET_H_ */ /** * @} */ diff --git a/sys/include/net/ng_ethernet/hdr.h b/sys/include/net/ethernet/hdr.h similarity index 63% rename from sys/include/net/ng_ethernet/hdr.h rename to sys/include/net/ethernet/hdr.h index 275dc5d84f..6860afcfe4 100644 --- a/sys/include/net/ng_ethernet/hdr.h +++ b/sys/include/net/ethernet/hdr.h @@ -7,8 +7,8 @@ */ /** - * @defgroup net_ng_ethernet_hdr Ethernet header - * @ingroup net_ng_ethernet + * @defgroup net_ethernet_hdr Ethernet header + * @ingroup net_ethernet * @brief Ethernet header * @{ * @@ -19,8 +19,8 @@ */ -#ifndef NG_ETHERNET_HDR_H_ -#define NG_ETHERNET_HDR_H_ +#ifndef ETHERNET_HDR_H_ +#define ETHERNET_HDR_H_ #include <inttypes.h> @@ -30,22 +30,22 @@ extern "C" { #endif -#define NG_ETHERNET_ADDR_LEN (6) /**< Length of an Ethernet address */ +#define ETHERNET_ADDR_LEN (6) /**< Length of an Ethernet address */ /** * @brief Ethernet header */ typedef struct __attribute__((packed)) { - uint8_t dst[NG_ETHERNET_ADDR_LEN]; /**< destination address */ - uint8_t src[NG_ETHERNET_ADDR_LEN]; /**< source address */ - network_uint16_t type; /**< ether type (see @ref net_ng_ethertype) */ -} ng_ethernet_hdr_t; + uint8_t dst[ETHERNET_ADDR_LEN]; /**< destination address */ + uint8_t src[ETHERNET_ADDR_LEN]; /**< source address */ + network_uint16_t type; /**< ether type (see @ref net_ethertype) */ +} ethernet_hdr_t; #ifdef __cplusplus } #endif -#endif /* NG_ETHERNET_HDR_H_ */ +#endif /* ETHERNET_HDR_H_ */ /** * @} */ diff --git a/sys/include/net/ng_ethertype.h b/sys/include/net/ethertype.h similarity index 65% rename from sys/include/net/ng_ethertype.h rename to sys/include/net/ethertype.h index 3f026fc84c..8ca3f408ad 100644 --- a/sys/include/net/ng_ethertype.h +++ b/sys/include/net/ethertype.h @@ -7,7 +7,7 @@ */ /** - * @defgroup net_ng_ethertype Ether types + * @defgroup net_ethertype Ether types * @ingroup net * @brief Ether types * @see <a href="http://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml#ieee-802-numbers-1"> @@ -23,25 +23,25 @@ */ -#ifndef NG_ETHERTYPE_H_ -#define NG_ETHERTYPE_H_ +#ifndef ETHERTYPE_H_ +#define ETHERTYPE_H_ #ifdef __cplusplus extern "C" { #endif /* expand at will ;-) */ -#define NG_ETHERTYPE_RESERVED (0x0000) /**< Reserved */ -#define NG_ETHERTYPE_IPV4 (0x0800) /**< Internet protocol version 4 */ -#define NG_ETHERTYPE_ARP (0x0806) /**< Address resolution protocol */ -#define NG_ETHERTYPE_IPV6 (0x86dd) /**< Internet protocol version 6 */ -#define NG_ETHERTYPE_UNKNOWN (0xffff) /**< Reserved (no protocol specified) */ +#define ETHERTYPE_RESERVED (0x0000) /**< Reserved */ +#define ETHERTYPE_IPV4 (0x0800) /**< Internet protocol version 4 */ +#define ETHERTYPE_ARP (0x0806) /**< Address resolution protocol */ +#define ETHERTYPE_IPV6 (0x86dd) /**< Internet protocol version 6 */ +#define ETHERTYPE_UNKNOWN (0xffff) /**< Reserved (no protocol specified) */ #ifdef __cplusplus } #endif -#endif /* NG_ETHERTYPE_H_ */ +#endif /* ETHERTYPE_H_ */ /** * @} */ diff --git a/sys/include/net/ng_netdev_eth.h b/sys/include/net/ng_netdev_eth.h index 8f8dad2ced..e755a7428c 100644 --- a/sys/include/net/ng_netdev_eth.h +++ b/sys/include/net/ng_netdev_eth.h @@ -31,7 +31,7 @@ #include "kernel_types.h" #include "net/ng_netdev.h" -#include "net/ng_ethernet/hdr.h" +#include "net/ethernet/hdr.h" #include "net/dev_eth.h" #ifdef __cplusplus diff --git a/sys/include/net/ng_nettype.h b/sys/include/net/ng_nettype.h index 9251d5ca9e..fa79b070b0 100644 --- a/sys/include/net/ng_nettype.h +++ b/sys/include/net/ng_nettype.h @@ -24,7 +24,7 @@ #include <inttypes.h> -#include "net/ng_ethertype.h" +#include "net/ethertype.h" #include "net/protnum.h" #ifdef __cplusplus @@ -103,7 +103,7 @@ static inline ng_nettype_t ng_nettype_from_ethertype(uint16_t type) { switch (type) { #ifdef MODULE_NG_IPV6 - case NG_ETHERTYPE_IPV6: + case ETHERTYPE_IPV6: return NG_NETTYPE_IPV6; #endif default: @@ -120,17 +120,17 @@ static inline ng_nettype_t ng_nettype_from_ethertype(uint16_t type) * @param[in] type A protocol type * * @return The corresponding Ether Type number to @p type. - * @return @ref NG_ETHERTYPE_RESERVED if @p type not translatable. + * @return @ref ETHERTYPE_RESERVED if @p type not translatable. */ static inline uint16_t ng_nettype_to_ethertype(ng_nettype_t type) { switch (type) { #ifdef MODULE_NG_IPV6 case NG_NETTYPE_IPV6: - return NG_ETHERTYPE_IPV6; + return ETHERTYPE_IPV6; #endif default: - return NG_ETHERTYPE_UNKNOWN; + return ETHERTYPE_UNKNOWN; } } diff --git a/sys/net/link_layer/ng_netdev_eth/ng_netdev_eth.c b/sys/net/link_layer/ng_netdev_eth/ng_netdev_eth.c index 84baa8ff88..8c19de3902 100644 --- a/sys/net/link_layer/ng_netdev_eth/ng_netdev_eth.c +++ b/sys/net/link_layer/ng_netdev_eth/ng_netdev_eth.c @@ -30,8 +30,8 @@ #include "byteorder.h" #include "net/eui64.h" -#include "net/ng_ethernet.h" -#include "net/ng_ethertype.h" +#include "net/ethernet.h" +#include "net/ethertype.h" #include "net/ng_netdev.h" #include "net/ng_netif/hdr.h" #include "net/ng_pkt.h" @@ -47,8 +47,8 @@ ng_netdev_eth_t ng_netdev_eth; -static uint8_t send_buffer[NG_ETHERNET_MAX_LEN]; -static uint8_t recv_buffer[NG_ETHERNET_MAX_LEN]; +static uint8_t send_buffer[ETHERNET_MAX_LEN]; +static uint8_t recv_buffer[ETHERNET_MAX_LEN]; #define _ISR_EVENT_RX (1U) @@ -177,7 +177,7 @@ static int _rem_event_callback(ng_netdev_t *dev, ng_netdev_event_cb_t cb) /* individual option getters to be called by _get() */ static inline int _get_addr(ng_netdev_eth_t *netdev, uint8_t *value, size_t max_len) { - if (max_len < NG_ETHERNET_ADDR_LEN) { + if (max_len < ETHERNET_ADDR_LEN) { /* value buffer not big enough */ return -EOVERFLOW; } @@ -185,7 +185,7 @@ static inline int _get_addr(ng_netdev_eth_t *netdev, uint8_t *value, size_t max_ dev_eth_t *dev = netdev->ethdev; dev->driver->get_mac_addr(dev, value); - return NG_ETHERNET_ADDR_LEN; + return ETHERNET_ADDR_LEN; } static inline int _get_addr_len(uint16_t *value, size_t max_len) @@ -195,7 +195,7 @@ static inline int _get_addr_len(uint16_t *value, size_t max_len) return -EOVERFLOW; } - *value = NG_ETHERNET_ADDR_LEN; + *value = ETHERNET_ADDR_LEN; return sizeof(uint16_t); } @@ -208,9 +208,9 @@ static inline int _get_iid(ng_netdev_eth_t *netdev, eui64_t *value, size_t max_l } dev_eth_t *dev = netdev->ethdev; - uint8_t addr[NG_ETHERNET_ADDR_LEN]; + uint8_t addr[ETHERNET_ADDR_LEN]; dev->driver->get_mac_addr(dev, addr); - ng_ethernet_get_iid(value, addr); + ethernet_get_iid(value, addr); return sizeof(eui64_t); } @@ -222,7 +222,7 @@ static inline int _get_max_pkt_sz(uint16_t *value, size_t max_len) return -EOVERFLOW; } - *value = NG_ETHERNET_MAX_LEN; + *value = ETHERNET_MAX_LEN; return sizeof(uint16_t); } @@ -351,7 +351,7 @@ static void _isr_event(ng_netdev_t *dev, uint32_t event_type) static inline void _addr_set_broadcast(uint8_t *dst) { - memset(dst, 0xff, NG_ETHERNET_ADDR_LEN); + memset(dst, 0xff, ETHERNET_ADDR_LEN); } #define _IPV6_DST_OFFSET (36) /* sizeof(ipv6_hdr_t) - 4 */ @@ -378,7 +378,7 @@ static inline void _addr_set_multicast(uint8_t *dst, ng_pktsnip_t *payload) static int _marshall_ethernet(ng_netdev_eth_t *dev, uint8_t *buffer, ng_pktsnip_t *pkt) { int data_len = 0; - ng_ethernet_hdr_t *hdr = (ng_ethernet_hdr_t *)buffer; + ethernet_hdr_t *hdr = (ethernet_hdr_t *)buffer; ng_netif_hdr_t *netif_hdr; ng_pktsnip_t *payload; @@ -398,13 +398,13 @@ static int _marshall_ethernet(ng_netdev_eth_t *dev, uint8_t *buffer, ng_pktsnip_ hdr->type = byteorder_htons(ng_nettype_to_ethertype(payload->type)); } else { - hdr->type = byteorder_htons(NG_ETHERTYPE_UNKNOWN); + hdr->type = byteorder_htons(ETHERTYPE_UNKNOWN); } netif_hdr = pkt->data; /* set ethernet header */ - if (netif_hdr->src_l2addr_len == NG_ETHERNET_ADDR_LEN) { + if (netif_hdr->src_l2addr_len == ETHERNET_ADDR_LEN) { memcpy(hdr->dst, ng_netif_hdr_get_src_addr(netif_hdr), netif_hdr->src_l2addr_len); } @@ -419,9 +419,9 @@ static int _marshall_ethernet(ng_netdev_eth_t *dev, uint8_t *buffer, ng_pktsnip_ else if (netif_hdr->flags & NG_NETIF_HDR_FLAGS_MULTICAST) { _addr_set_multicast(hdr->dst, payload); } - else if (netif_hdr->dst_l2addr_len == NG_ETHERNET_ADDR_LEN) { + else if (netif_hdr->dst_l2addr_len == ETHERNET_ADDR_LEN) { memcpy(hdr->dst, ng_netif_hdr_get_dst_addr(netif_hdr), - NG_ETHERNET_ADDR_LEN); + ETHERNET_ADDR_LEN); } else { DEBUG("ng_netdev_eth: destination address had unexpected format\n"); @@ -432,10 +432,10 @@ static int _marshall_ethernet(ng_netdev_eth_t *dev, uint8_t *buffer, ng_pktsnip_ hdr->dst[0], hdr->dst[1], hdr->dst[2], hdr->dst[3], hdr->dst[4], hdr->dst[5]); - data_len += sizeof(ng_ethernet_hdr_t); + data_len += sizeof(ethernet_hdr_t); while (payload != NULL) { - if ((data_len + payload->size) > NG_ETHERNET_MAX_LEN) { + if ((data_len + payload->size) > ETHERNET_MAX_LEN) { DEBUG("ng_netdev_eth: Packet too big for ethernet frame\n"); return -ENOBUFS; } @@ -449,10 +449,10 @@ static int _marshall_ethernet(ng_netdev_eth_t *dev, uint8_t *buffer, ng_pktsnip_ /* Pad to minimum payload size. * Linux does this on its own, but it doesn't hurt to do it here. * As of now only tuntaposx needs this. */ - if (data_len < (NG_ETHERNET_MIN_LEN)) { + if (data_len < (ETHERNET_MIN_LEN)) { DEBUG("ng_netdev_eth: padding data! (%d -> ", data_len); - memset(send_buffer + data_len, 0, NG_ETHERNET_MIN_LEN - data_len); - data_len = NG_ETHERNET_MIN_LEN; + memset(send_buffer + data_len, 0, ETHERNET_MIN_LEN - data_len); + data_len = ETHERNET_MIN_LEN; DEBUG("%d)\n", data_len); } @@ -491,20 +491,20 @@ void dev_eth_linkstate_handler(dev_eth_t *dev, int newstate) static void _rx_event(ng_netdev_eth_t *netdev) { dev_eth_t *dev = netdev->ethdev; - int nread = dev->driver->recv(dev, (char*)recv_buffer, NG_ETHERNET_MAX_LEN); + int nread = dev->driver->recv(dev, (char*)recv_buffer, ETHERNET_MAX_LEN); DEBUG("ng_netdev_eth: read %d bytes\n", nread); if (nread > 0) { - ng_ethernet_hdr_t *hdr = (ng_ethernet_hdr_t *)recv_buffer; + ethernet_hdr_t *hdr = (ethernet_hdr_t *)recv_buffer; ng_pktsnip_t *netif_hdr, *pkt; ng_nettype_t receive_type = NG_NETTYPE_UNDEF; - size_t data_len = (nread - sizeof(ng_ethernet_hdr_t)); + size_t data_len = (nread - sizeof(ethernet_hdr_t)); /* TODO: implement multicast groups? */ netif_hdr = ng_pktbuf_add(NULL, NULL, - sizeof(ng_netif_hdr_t) + (2 * NG_ETHERNET_ADDR_LEN), + sizeof(ng_netif_hdr_t) + (2 * ETHERNET_ADDR_LEN), NG_NETTYPE_NETIF); if (netif_hdr == NULL) { @@ -512,9 +512,9 @@ static void _rx_event(ng_netdev_eth_t *netdev) return; } - ng_netif_hdr_init(netif_hdr->data, NG_ETHERNET_ADDR_LEN, NG_ETHERNET_ADDR_LEN); - ng_netif_hdr_set_src_addr(netif_hdr->data, hdr->src, NG_ETHERNET_ADDR_LEN); - ng_netif_hdr_set_dst_addr(netif_hdr->data, hdr->dst, NG_ETHERNET_ADDR_LEN); + ng_netif_hdr_init(netif_hdr->data, ETHERNET_ADDR_LEN, ETHERNET_ADDR_LEN); + ng_netif_hdr_set_src_addr(netif_hdr->data, hdr->src, ETHERNET_ADDR_LEN); + ng_netif_hdr_set_dst_addr(netif_hdr->data, hdr->dst, ETHERNET_ADDR_LEN); ((ng_netif_hdr_t *)netif_hdr->data)->if_pid = thread_getpid(); receive_type = ng_nettype_from_ethertype(byteorder_ntohs(hdr->type)); @@ -528,7 +528,7 @@ static void _rx_event(ng_netdev_eth_t *netdev) #endif /* Mark netif header and payload for next layer */ - if ((pkt = ng_pktbuf_add(netif_hdr, recv_buffer + sizeof(ng_ethernet_hdr_t), + if ((pkt = ng_pktbuf_add(netif_hdr, recv_buffer + sizeof(ethernet_hdr_t), data_len, receive_type)) == NULL) { ng_pktbuf_release(netif_hdr); DEBUG("ng_netdev_eth: no space left in packet buffer\n"); -- GitLab