diff --git a/include/zephyr/net/net_if.h b/include/zephyr/net/net_if.h index 4e08aa50ba564b..0e0e619a831587 100644 --- a/include/zephyr/net/net_if.h +++ b/include/zephyr/net/net_if.h @@ -1827,7 +1827,16 @@ bool net_if_ipv6_router_rm(struct net_if_router *router); * * @return Hop limit */ +#if defined(CONFIG_NET_NATIVE_IPV6) uint8_t net_if_ipv6_get_hop_limit(struct net_if *iface); +#else +static inline uint8_t net_if_ipv6_get_hop_limit(struct net_if *iface) +{ + ARG_UNUSED(iface); + + return 0; +} +#endif /* CONFIG_NET_NATIVE_IPV6 */ /** * @brief Set the default IPv6 hop limit of a given interface. @@ -1835,7 +1844,16 @@ uint8_t net_if_ipv6_get_hop_limit(struct net_if *iface); * @param iface Network interface * @param hop_limit New hop limit */ +#if defined(CONFIG_NET_NATIVE_IPV6) void net_if_ipv6_set_hop_limit(struct net_if *iface, uint8_t hop_limit); +#else +static inline void net_if_ipv6_set_hop_limit(struct net_if *iface, + uint8_t hop_limit) +{ + ARG_UNUSED(iface); + ARG_UNUSED(hop_limit); +} +#endif /* CONFIG_NET_NATIVE_IPV6 */ /** @cond INTERNAL_HIDDEN */ @@ -1860,7 +1878,16 @@ static inline void net_ipv6_set_hop_limit(struct net_if *iface, * * @return Hop limit */ +#if defined(CONFIG_NET_NATIVE_IPV6) uint8_t net_if_ipv6_get_mcast_hop_limit(struct net_if *iface); +#else +static inline uint8_t net_if_ipv6_get_mcast_hop_limit(struct net_if *iface) +{ + ARG_UNUSED(iface); + + return 0; +} +#endif /* CONFIG_NET_NATIVE_IPV6 */ /** * @brief Set the default IPv6 multicast hop limit of a given interface. @@ -1868,7 +1895,16 @@ uint8_t net_if_ipv6_get_mcast_hop_limit(struct net_if *iface); * @param iface Network interface * @param hop_limit New hop limit */ +#if defined(CONFIG_NET_NATIVE_IPV6) void net_if_ipv6_set_mcast_hop_limit(struct net_if *iface, uint8_t hop_limit); +#else +static inline void net_if_ipv6_set_mcast_hop_limit(struct net_if *iface, + uint8_t hop_limit) +{ + ARG_UNUSED(iface); + ARG_UNUSED(hop_limit); +} +#endif /* CONFIG_NET_NATIVE_IPV6 */ /** * @brief Set IPv6 reachable time for a given interface diff --git a/subsys/net/ip/net_context.c b/subsys/net/ip/net_context.c index af434e950f17a5..e6a13874bdef4c 100644 --- a/subsys/net/ip/net_context.c +++ b/subsys/net/ip/net_context.c @@ -2456,7 +2456,7 @@ enum net_verdict net_context_packet_received(struct net_conn *conn, return verdict; } -#if defined(CONFIG_NET_UDP) +#if defined(CONFIG_NET_NATIVE_UDP) static int recv_udp(struct net_context *context, net_context_recv_cb_t cb, k_timeout_t timeout, @@ -2538,7 +2538,7 @@ static int recv_udp(struct net_context *context, } #else #define recv_udp(...) 0 -#endif /* CONFIG_NET_UDP */ +#endif /* CONFIG_NET_NATIVE_UDP */ static enum net_verdict net_context_raw_packet_received( struct net_conn *conn, diff --git a/subsys/net/ip/net_core.c b/subsys/net/ip/net_core.c index 8ab2fb93a3c850..5259f9c6e6d70e 100644 --- a/subsys/net/ip/net_core.c +++ b/subsys/net/ip/net_core.c @@ -60,6 +60,7 @@ LOG_MODULE_REGISTER(net_core, CONFIG_NET_CORE_LOG_LEVEL); #include "net_stats.h" +#if defined(CONFIG_NET_NATIVE) static inline enum net_verdict process_data(struct net_pkt *pkt, bool is_loopback) { @@ -188,22 +189,6 @@ static void net_post_init(void) #endif } -static void init_rx_queues(void) -{ - /* Starting TX side. The ordering is important here and the TX - * can only be started when RX side is ready to receive packets. - */ - net_if_init(); - - net_tc_rx_init(); - - /* This will take the interface up and start everything. */ - net_if_post_init(); - - /* Things to init after network interface is working */ - net_post_init(); -} - static inline void copy_ll_addr(struct net_pkt *pkt) { memcpy(net_pkt_lladdr_src(pkt), net_pkt_lladdr_if(pkt), @@ -571,6 +556,39 @@ static inline void l3_init(void) NET_DBG("Network L3 init done"); } +#else /* CONFIG_NET_NATIVE */ +#define l3_init(...) +#define net_post_init(...) +int net_send_data(struct net_pkt *pkt) +{ + ARG_UNUSED(pkt); + + return -ENOTSUP; +} +int net_recv_data(struct net_if *iface, struct net_pkt *pkt) +{ + ARG_UNUSED(iface); + ARG_UNUSED(pkt); + + return -ENOTSUP; +} +#endif /* CONFIG_NET_NATIVE */ + +static void init_rx_queues(void) +{ + /* Starting TX side. The ordering is important here and the TX + * can only be started when RX side is ready to receive packets. + */ + net_if_init(); + + net_tc_rx_init(); + + /* This will take the interface up and start everything. */ + net_if_post_init(); + + /* Things to init after network interface is working */ + net_post_init(); +} static inline int services_init(void) { diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index 0d0248158f7587..20f0c4e4994f17 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -174,6 +174,7 @@ struct net_if *z_vrfy_net_if_get_by_index(int index) #include #endif +#if defined(CONFIG_NET_NATIVE) static inline void net_context_send_cb(struct net_context *context, int status) { @@ -382,6 +383,7 @@ void net_if_queue_tx(struct net_if *iface, struct net_pkt *pkt) ; } } +#endif /* CONFIG_NET_NATIVE */ void net_if_stats_reset(struct net_if *iface) { @@ -445,6 +447,7 @@ static inline void init_iface(struct net_if *iface) net_ipv6_pe_init(iface); } +#if defined(CONFIG_NET_NATIVE) enum net_verdict net_if_send_data(struct net_if *iface, struct net_pkt *pkt) { const struct net_l2 *l2; @@ -551,6 +554,7 @@ enum net_verdict net_if_send_data(struct net_if *iface, struct net_pkt *pkt) return verdict; } +#endif /* CONFIG_NET_NATIVE */ int net_if_set_link_addr_locked(struct net_if *iface, uint8_t *addr, uint8_t len, diff --git a/subsys/net/ip/utils.c b/subsys/net/ip/utils.c index e8b6b99b073b2b..f130a184bcb27b 100644 --- a/subsys/net/ip/utils.c +++ b/subsys/net/ip/utils.c @@ -634,7 +634,7 @@ static inline uint16_t pkt_calc_chksum(struct net_pkt *pkt, uint16_t sum) return sum; } -#if defined(CONFIG_NET_IP) +#if defined(CONFIG_NET_NATIVE_IP) uint16_t net_calc_chksum(struct net_pkt *pkt, uint8_t proto) { size_t len = 0U; @@ -684,7 +684,7 @@ uint16_t net_calc_chksum(struct net_pkt *pkt, uint8_t proto) } #endif -#if defined(CONFIG_NET_IPV4) +#if defined(CONFIG_NET_NATIVE_IPV4) uint16_t net_calc_chksum_ipv4(struct net_pkt *pkt) { uint16_t sum; @@ -697,7 +697,7 @@ uint16_t net_calc_chksum_ipv4(struct net_pkt *pkt) return ~sum; } -#endif /* CONFIG_NET_IPV4 */ +#endif /* CONFIG_NET_NATIVE_IPV4 */ #if defined(CONFIG_NET_IPV4_IGMP) uint16_t net_calc_chksum_igmp(struct net_pkt *pkt)