Skip to content
Permalink
Browse files

net/ethernet: Cleanup a bit on the usage of ifdefs

ARP, LLDP and GPTP functions have dummies in case of being disabled so
let's use IS_ENABLED() accordingly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
  • Loading branch information...
tbursztyka authored and jukkar committed May 28, 2019
1 parent 5994506 commit 845f070c1edb0608dcaf2c855084772739cdba94
Showing with 13 additions and 13 deletions.
  1. +1 −1 subsys/net/ip/ipv4_autoconf_internal.h
  2. +12 −12 subsys/net/l2/ethernet/ethernet.c
@@ -87,7 +87,7 @@ void net_ipv4_autoconf_reset(struct net_if *iface);
enum net_verdict net_ipv4_autoconf_input(struct net_if *iface,
struct net_pkt *pkt);
#else
#define net_ipv4_autoconf_input(...)
#define net_ipv4_autoconf_input(...) NET_CONTINUE
#endif

#endif /* __IPV4_AUTOCONF_INTERNAL_H */
@@ -268,26 +268,24 @@ static enum net_verdict ethernet_recv(struct net_if *iface,

ethernet_update_rx_stats(iface, pkt, net_pkt_get_len(pkt) + hdr_len);

#ifdef CONFIG_NET_ARP
if (family == AF_INET && type == NET_ETH_PTYPE_ARP) {
if (IS_ENABLED(CONFIG_NET_ARP) &&
family == AF_INET && type == NET_ETH_PTYPE_ARP) {
NET_DBG("ARP packet from %s received",
log_strdup(net_sprint_ll_addr(
(u8_t *)hdr->src.addr,
sizeof(struct net_eth_addr))));
#ifdef CONFIG_NET_IPV4_AUTO
if (net_ipv4_autoconf_input(iface, pkt) == NET_DROP) {

if (IS_ENABLED(CONFIG_NET_IPV4_AUTO) &&
net_ipv4_autoconf_input(iface, pkt) == NET_DROP) {
return NET_DROP;
}
#endif

return net_arp_input(pkt, hdr);
}
#endif

#if defined(CONFIG_NET_GPTP)
if (type == NET_ETH_PTYPE_PTP) {
if (IS_ENABLED(CONFIG_NET_GPTP) && type == NET_ETH_PTYPE_PTP) {
return net_gptp_recv(iface, pkt);
}
#endif

ethernet_update_length(iface, pkt);

@@ -531,6 +529,8 @@ static void ethernet_update_tx_stats(struct net_if *iface, struct net_pkt *pkt)
eth_stats_update_broadcast_tx(iface);
}
}
#else
#define ethernet_update_tx_stats(...)
#endif /* CONFIG_NET_STATISTICS_ETHERNET */

static void ethernet_remove_l2_header(struct net_pkt *pkt)
@@ -634,9 +634,9 @@ static int ethernet_send(struct net_if *iface, struct net_pkt *pkt)
ethernet_remove_l2_header(pkt);
goto error;
}
#if defined(CONFIG_NET_STATISTICS_ETHERNET)

ethernet_update_tx_stats(iface, pkt);
#endif

ret = net_pkt_get_len(pkt);
ethernet_remove_l2_header(pkt);

@@ -911,7 +911,7 @@ int net_eth_vlan_disable(struct net_if *iface, u16_t tag)

return 0;
}
#endif
#endif /* CONFIG_NET_VLAN */

NET_L2_INIT(ETHERNET_L2, ethernet_recv, ethernet_send, ethernet_enable,
ethernet_flags);

0 comments on commit 845f070

Please sign in to comment.
You can’t perform that action at this time.