net: Add CONFIG_NET_NATIVE option for selecting native IP

Allow user to disable native IP stack and use offloaded IP
stack instead. It is also possible to enable both at the same
time if needed.

Fixes #18105

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2019-08-09 14:49:35 +03:00
parent ac7f81314e
commit 6cf1da486d
26 changed files with 560 additions and 188 deletions

View file

@ -1,5 +1,8 @@
# SPDX-License-Identifier: Apache-2.0
zephyr_sources_ifdef(CONFIG_SLIP slip.c)
zephyr_sources_ifdef(CONFIG_NET_LOOPBACK loopback.c)
if(CONFIG_NET_NATIVE)
zephyr_sources_ifdef(CONFIG_SLIP slip.c)
zephyr_sources_ifdef(CONFIG_NET_PPP ppp.c)
endif()

View file

@ -7,6 +7,7 @@
menuconfig NET_PPP
bool "Point-to-point (PPP) UART based driver"
depends on NET_L2_PPP
depends on NET_NATIVE
select UART_PIPE
select UART_INTERRUPT_DRIVEN
@ -73,6 +74,7 @@ endif # NET_PPP
menuconfig SLIP
bool "SLIP driver"
depends on (!QEMU_TARGET || NET_QEMU_SLIP)
depends on NET_NATIVE
select UART_PIPE
select UART_INTERRUPT_DRIVEN

View file

@ -30,10 +30,10 @@
#include <net/net_stats.h>
#include <net/net_timeout.h>
#if defined(CONFIG_NET_DHCPV4)
#if defined(CONFIG_NET_DHCPV4) && defined(CONFIG_NET_NATIVE_IPV4)
#include <net/dhcpv4.h>
#endif
#if defined(CONFIG_NET_IPV4_AUTO)
#if defined(CONFIG_NET_IPV4_AUTO) && defined(CONFIG_NET_NATIVE_IPV4)
#include <net/ipv4_autoconf.h>
#endif
@ -50,11 +50,11 @@ struct net_if_addr {
/** IP address */
struct net_addr address;
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
struct net_timeout lifetime;
#endif
#if defined(CONFIG_NET_IPV6_DAD)
#if defined(CONFIG_NET_IPV6_DAD) && defined(CONFIG_NET_NATIVE_IPV6)
/** Duplicate address detection (DAD) timer */
sys_snode_t dad_node;
u32_t dad_start;
@ -65,7 +65,7 @@ struct net_if_addr {
/** What is the current state of the address */
enum net_addr_state addr_state;
#if defined(CONFIG_NET_IPV6_DAD)
#if defined(CONFIG_NET_IPV6_DAD) && defined(CONFIG_NET_NATIVE_IPV6)
/** How many times we have done DAD */
u8_t dad_count;
#endif
@ -205,7 +205,7 @@ struct net_offload;
#endif /* CONFIG_NET_OFFLOAD */
/** @cond INTERNAL_HIDDEN */
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
#define NET_IF_MAX_IPV6_ADDR CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT
#define NET_IF_MAX_IPV6_MADDR CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT
#define NET_IF_MAX_IPV6_PREFIX CONFIG_NET_IF_IPV6_PREFIX_COUNT
@ -234,7 +234,7 @@ struct net_if_ipv6 {
/** Retransmit timer (RFC 4861, page 52) */
u32_t retrans_timer;
#if defined(CONFIG_NET_IPV6_ND)
#if defined(CONFIG_NET_IPV6_ND) && defined(CONFIG_NET_NATIVE_IPV6)
/** Router solicitation timer node */
sys_snode_t rs_node;
@ -250,7 +250,7 @@ struct net_if_ipv6 {
};
/** @cond INTERNAL_HIDDEN */
#if defined(CONFIG_NET_IPV4)
#if defined(CONFIG_NET_NATIVE_IPV4)
#define NET_IF_MAX_IPV4_ADDR CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT
#define NET_IF_MAX_IPV4_MADDR CONFIG_NET_IF_MCAST_IPV4_ADDR_COUNT
#else
@ -276,7 +276,7 @@ struct net_if_ipv4 {
u8_t ttl;
};
#if defined(CONFIG_NET_DHCPV4)
#if defined(CONFIG_NET_DHCPV4) && defined(CONFIG_NET_NATIVE_IPV4)
struct net_if_dhcpv4 {
/** Used for timer lists */
sys_snode_t node;
@ -315,7 +315,7 @@ struct net_if_dhcpv4 {
};
#endif /* CONFIG_NET_DHCPV4 */
#if defined(CONFIG_NET_IPV4_AUTO)
#if defined(CONFIG_NET_IPV4_AUTO) && defined(CONFIG_NET_NATIVE_IPV4)
struct net_if_ipv4_autoconf {
/** Used for timer lists */
sys_snode_t node;
@ -359,11 +359,11 @@ struct net_if_ipv4_autoconf {
* @brief Network interface IP address configuration.
*/
struct net_if_ip {
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
struct net_if_ipv6 *ipv6;
#endif /* CONFIG_NET_IPV6 */
#if defined(CONFIG_NET_IPV4)
#if defined(CONFIG_NET_NATIVE_IPV4)
struct net_if_ipv4 *ipv4;
#endif /* CONFIG_NET_IPV4 */
};
@ -375,11 +375,11 @@ struct net_if_config {
/** IP address configuration setting */
struct net_if_ip ip;
#if defined(CONFIG_NET_DHCPV4)
#if defined(CONFIG_NET_DHCPV4) && defined(CONFIG_NET_NATIVE_IPV4)
struct net_if_dhcpv4 dhcpv4;
#endif /* CONFIG_NET_DHCPV4 */
#if defined(CONFIG_NET_IPV4_AUTO)
#if defined(CONFIG_NET_IPV4_AUTO) && defined(CONFIG_NET_NATIVE_IPV4)
struct net_if_ipv4_autoconf ipv4auto;
#endif /* CONFIG_NET_IPV4_AUTO */
};
@ -653,7 +653,7 @@ static inline struct net_if_config *net_if_get_config(struct net_if *iface)
*
* @param iface Pointer to a network interface structure
*/
#if defined(CONFIG_NET_IPV6_DAD)
#if defined(CONFIG_NET_IPV6_DAD) && defined(CONFIG_NET_NATIVE_IPV6)
void net_if_start_dad(struct net_if *iface);
#else
static inline void net_if_start_dad(struct net_if *iface)
@ -675,7 +675,7 @@ void net_if_start_rs(struct net_if *iface);
*
* @param iface Pointer to a network interface structure
*/
#if defined(CONFIG_NET_IPV6_ND)
#if defined(CONFIG_NET_IPV6_ND) && defined(CONFIG_NET_NATIVE_IPV6)
void net_if_stop_rs(struct net_if *iface);
#else
static inline void net_if_stop_rs(struct net_if *iface)
@ -1166,7 +1166,7 @@ bool net_if_ipv6_addr_onlink(struct net_if **iface, struct in6_addr *addr);
*
* @return pointer to the IPv6 address, or NULL if none
*/
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
static inline struct in6_addr *net_if_router_ipv6(struct net_if_router *router)
{
return &router->address.in6_addr;
@ -1247,7 +1247,7 @@ bool net_if_ipv6_router_rm(struct net_if_router *router);
*/
static inline u8_t net_if_ipv6_get_hop_limit(struct net_if *iface)
{
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
if (!iface->config.ip.ipv6) {
return 0;
}
@ -1267,7 +1267,7 @@ static inline u8_t net_if_ipv6_get_hop_limit(struct net_if *iface)
static inline void net_ipv6_set_hop_limit(struct net_if *iface,
u8_t hop_limit)
{
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
if (!iface->config.ip.ipv6) {
return;
}
@ -1285,7 +1285,7 @@ static inline void net_ipv6_set_hop_limit(struct net_if *iface,
static inline void net_if_ipv6_set_base_reachable_time(struct net_if *iface,
u32_t reachable_time)
{
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
if (!iface->config.ip.ipv6) {
return;
}
@ -1303,7 +1303,7 @@ static inline void net_if_ipv6_set_base_reachable_time(struct net_if *iface,
*/
static inline u32_t net_if_ipv6_get_reachable_time(struct net_if *iface)
{
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
if (!iface->config.ip.ipv6) {
return 0;
}
@ -1331,7 +1331,7 @@ u32_t net_if_ipv6_calc_reachable_time(struct net_if_ipv6 *ipv6);
*/
static inline void net_if_ipv6_set_reachable_time(struct net_if_ipv6 *ipv6)
{
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
ipv6->reachable_time = net_if_ipv6_calc_reachable_time(ipv6);
#endif
}
@ -1345,7 +1345,7 @@ static inline void net_if_ipv6_set_reachable_time(struct net_if_ipv6 *ipv6)
static inline void net_if_ipv6_set_retrans_timer(struct net_if *iface,
u32_t retrans_timer)
{
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
if (!iface->config.ip.ipv6) {
return;
}
@ -1363,7 +1363,7 @@ static inline void net_if_ipv6_set_retrans_timer(struct net_if *iface,
*/
static inline u32_t net_if_ipv6_get_retrans_timer(struct net_if *iface)
{
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
if (!iface->config.ip.ipv6) {
return 0;
}
@ -1385,8 +1385,19 @@ static inline u32_t net_if_ipv6_get_retrans_timer(struct net_if *iface)
* @return Pointer to IPv6 address to use, NULL if no IPv6 address
* could be found.
*/
#if defined(CONFIG_NET_NATIVE_IPV6)
const struct in6_addr *net_if_ipv6_select_src_addr(struct net_if *iface,
const struct in6_addr *dst);
#else
static inline const struct in6_addr *net_if_ipv6_select_src_addr(
struct net_if *iface, const struct in6_addr *dst)
{
ARG_UNUSED(iface);
ARG_UNUSED(dst);
return NULL;
}
#endif
/**
* @brief Get a network interface that should be used when sending
@ -1397,7 +1408,17 @@ const struct in6_addr *net_if_ipv6_select_src_addr(struct net_if *iface,
* @return Pointer to network interface to use, NULL if no suitable interface
* could be found.
*/
#if defined(CONFIG_NET_NATIVE_IPV6)
struct net_if *net_if_ipv6_select_src_iface(const struct in6_addr *dst);
#else
static inline struct net_if *net_if_ipv6_select_src_iface(
const struct in6_addr *dst)
{
ARG_UNUSED(dst);
return NULL;
}
#endif
/**
* @brief Get a IPv6 link local address in a given state.
@ -1477,7 +1498,7 @@ int net_if_config_ipv4_put(struct net_if *iface);
*/
static inline u8_t net_if_ipv4_get_ttl(struct net_if *iface)
{
#if defined(CONFIG_NET_IPV4)
#if defined(CONFIG_NET_NATIVE_IPV4)
if (!iface->config.ip.ipv4) {
return 0;
}
@ -1600,7 +1621,7 @@ struct net_if_mcast_addr *net_if_ipv4_maddr_lookup(const struct in_addr *addr,
*
* @return pointer to the IPv4 address, or NULL if none
*/
#if defined(CONFIG_NET_IPV4)
#if defined(CONFIG_NET_NATIVE_IPV4)
static inline struct in_addr *net_if_router_ipv4(struct net_if_router *router)
{
return &router->address.in_addr;
@ -1694,7 +1715,17 @@ bool net_if_ipv4_is_addr_bcast(struct net_if *iface,
* @return Pointer to network interface to use, NULL if no suitable interface
* could be found.
*/
#if defined(CONFIG_NET_NATIVE_IPV4)
struct net_if *net_if_ipv4_select_src_iface(const struct in_addr *dst);
#else
static inline struct net_if *net_if_ipv4_select_src_iface(
const struct in_addr *dst)
{
ARG_UNUSED(dst);
return NULL;
}
#endif
/**
* @brief Get a IPv4 source address that should be used when sending
@ -1707,8 +1738,19 @@ struct net_if *net_if_ipv4_select_src_iface(const struct in_addr *dst);
* @return Pointer to IPv4 address to use, NULL if no IPv4 address
* could be found.
*/
#if defined(CONFIG_NET_NATIVE_IPV4)
const struct in_addr *net_if_ipv4_select_src_addr(struct net_if *iface,
const struct in_addr *dst);
#else
static inline const struct in_addr *net_if_ipv4_select_src_addr(
struct net_if *iface, const struct in_addr *dst)
{
ARG_UNUSED(iface);
ARG_UNUSED(dst);
return NULL;
}
#endif
/**
* @brief Get a IPv4 link local address in a given state.
@ -1931,7 +1973,7 @@ static inline bool net_if_is_up(struct net_if *iface)
*/
int net_if_down(struct net_if *iface);
#if defined(CONFIG_NET_PKT_TIMESTAMP)
#if defined(CONFIG_NET_PKT_TIMESTAMP) && defined(CONFIG_NET_NATIVE)
/**
* @typedef net_if_timestamp_callback_t
* @brief Define callback that is called after a network packet
@ -2037,7 +2079,7 @@ struct net_if_api {
void (*init)(struct net_if *iface);
};
#if defined(CONFIG_NET_DHCPV4)
#if defined(CONFIG_NET_DHCPV4) && defined(CONFIG_NET_NATIVE_IPV4)
#define NET_IF_DHCPV4_INIT .dhcpv4.state = NET_DHCPV4_DISABLED,
#else
#define NET_IF_DHCPV4_INIT

View file

@ -800,6 +800,7 @@ extern bool net_if_ipv4_is_addr_bcast(struct net_if *iface,
*
* @return True if address is a broadcast address, false otherwise.
*/
#if defined(CONFIG_NET_NATIVE_IPV4)
static inline bool net_ipv4_is_addr_bcast(struct net_if *iface,
const struct in_addr *addr)
{
@ -809,6 +810,16 @@ static inline bool net_ipv4_is_addr_bcast(struct net_if *iface,
return net_if_ipv4_is_addr_bcast(iface, addr);
}
#else
static inline bool net_ipv4_is_addr_bcast(struct net_if *iface,
const struct in_addr *addr)
{
ARG_UNUSED(iface);
ARG_UNUSED(addr);
return false;
}
#endif
extern struct net_if_addr *net_if_ipv4_addr_lookup(const struct in_addr *addr,
struct net_if **iface);

View file

@ -7,33 +7,43 @@ zephyr_library_compile_definitions_ifdef(
)
zephyr_library_sources(
net_context.c
net_core.c
net_if.c
net_pkt.c
net_tc.c
utils.c
)
if(CONFIG_NET_OFFLOAD)
zephyr_library_sources(net_context.c net_pkt.c net_tc.c)
endif()
zephyr_library_sources_ifdef(CONFIG_NET_MGMT_EVENT net_mgmt.c)
if(CONFIG_NET_NATIVE)
zephyr_library_sources(net_context.c)
zephyr_library_sources(net_pkt.c)
zephyr_library_sources(net_tc.c)
zephyr_library_sources_ifdef(CONFIG_NET_6LO 6lo.c)
zephyr_library_sources_ifdef(CONFIG_NET_DHCPV4 dhcpv4.c)
zephyr_library_sources_ifdef(CONFIG_NET_IPV4_AUTO ipv4_autoconf.c)
zephyr_library_sources_ifdef(CONFIG_NET_IPV4 icmpv4.c ipv4.c)
zephyr_library_sources_ifdef(CONFIG_NET_IPV6 icmpv6.c nbr.c ipv6.c ipv6_nbr.c)
zephyr_library_sources_ifdef(CONFIG_NET_IPV6 icmpv6.c nbr.c
ipv6.c ipv6_nbr.c)
zephyr_library_sources_ifdef(CONFIG_NET_IPV6_MLD ipv6_mld.c)
zephyr_library_sources_ifdef(CONFIG_NET_IPV6_FRAGMENT ipv6_fragment.c)
zephyr_library_sources_ifdef(CONFIG_NET_MGMT_EVENT net_mgmt.c)
zephyr_library_sources_ifdef(CONFIG_NET_ROUTE route.c)
zephyr_library_sources_ifdef(CONFIG_NET_SHELL net_shell.c)
zephyr_library_sources_ifdef(CONFIG_NET_STATISTICS net_stats.c)
zephyr_library_sources_ifdef(CONFIG_NET_TCP connection.c tcp.c)
zephyr_library_sources_ifdef(CONFIG_NET_TRICKLE trickle.c)
zephyr_library_sources_ifdef(CONFIG_NET_UDP connection.c udp.c)
zephyr_library_sources_ifdef(CONFIG_NET_SOCKETS_PACKET connection.c packet_socket.c)
zephyr_library_sources_ifdef(CONFIG_NET_SOCKETS_CAN connection.c canbus_socket.c)
zephyr_library_sources_ifdef(CONFIG_NET_SOCKETS_PACKET connection.c
packet_socket.c)
zephyr_library_sources_ifdef(CONFIG_NET_SOCKETS_CAN connection.c
canbus_socket.c)
zephyr_library_sources_ifdef(CONFIG_NET_PROMISCUOUS_MODE promiscuous.c)
endif()
if(CONFIG_NET_SHELL)
zephyr_library_sources(net_shell.c)
zephyr_library_include_directories(. ${ZEPHYR_BASE}/subsys/net/l2)
zephyr_library_link_libraries_ifdef(CONFIG_MBEDTLS mbedTLS)
endif()

View file

@ -8,6 +8,50 @@
menu "IP stack"
config NET_NATIVE
bool "Enable native IP stack"
default y
help
Enables Zephyr native IP stack. If you disable this, then
you need to enable the offloading support if you want to
have IP connectivity.
# Hidden options for enabling native IPv6/IPv4. Using these options
# avoids having "defined(CONFIG_NET_IPV6) && defined(CONFIG_NET_NATIVE)"
# in the code as we can have "defined(CONFIG_NET_NATIVE_IPV6)" instead.
config NET_NATIVE_IPV6
bool
depends on NET_NATIVE
default y if NET_IPV6
config NET_NATIVE_IPV4
bool
depends on NET_NATIVE
default y if NET_IPV4
config NET_NATIVE_TCP
bool
depends on NET_NATIVE
default y if NET_TCP
config NET_NATIVE_UDP
bool
depends on NET_NATIVE
default y if NET_UDP
config NET_OFFLOAD
bool "Offload IP stack [EXPERIMENTAL]"
help
Enables TCP/IP stack to be offload to a co-processor.
if NET_OFFLOAD
module = NET_OFFLOAD
module-dep = NET_LOG
module-str = Log level for offload layer
module-help = Enables offload layer to output debug messages.
source "subsys/net/Kconfig.template.log_config.net"
endif # NET_OFFLOAD
# Hidden option
config NET_RAW_MODE
bool
@ -399,6 +443,7 @@ config NET_TEST
config NET_SLIP_TAP
bool "TAP SLIP driver"
depends on NET_QEMU_SLIP
depends on NET_NATIVE
select SLIP
select UART_PIPE
select UART_INTERRUPT_DRIVEN
@ -615,19 +660,6 @@ source "subsys/net/ip/Kconfig.mgmt"
source "subsys/net/ip/Kconfig.stats"
config NET_OFFLOAD
bool "Offload IP stack [EXPERIMENTAL]"
help
Enables TCP/IP stack to be offload to a co-processor.
if NET_OFFLOAD
module = NET_OFFLOAD
module-dep = NET_LOG
module-str = Log level for offload layer
module-help = Enables offload layer to output debug messages.
source "subsys/net/Kconfig.template.log_config.net"
endif # NET_OFFLOAD
source "subsys/net/ip/Kconfig.debug"
endmenu

View file

@ -88,6 +88,7 @@ struct net_conn {
*
* @return Return 0 if the registration succeed, <0 otherwise.
*/
#if defined(CONFIG_NET_NATIVE)
int net_conn_register(u16_t proto, u8_t family,
const struct sockaddr *remote_addr,
const struct sockaddr *local_addr,
@ -96,6 +97,29 @@ int net_conn_register(u16_t proto, u8_t family,
net_conn_cb_t cb,
void *user_data,
struct net_conn_handle **handle);
#else
static inline int net_conn_register(u16_t proto, u8_t family,
const struct sockaddr *remote_addr,
const struct sockaddr *local_addr,
u16_t remote_port,
u16_t local_port,
net_conn_cb_t cb,
void *user_data,
struct net_conn_handle **handle)
{
ARG_UNUSED(proto);
ARG_UNUSED(family);
ARG_UNUSED(remote_addr);
ARG_UNUSED(local_addr);
ARG_UNUSED(remote_port);
ARG_UNUSED(local_port);
ARG_UNUSED(cb);
ARG_UNUSED(user_data);
ARG_UNUSED(handle);
return -ENOTSUP;
}
#endif
/**
* @brief Unregister connection handler.
@ -104,7 +128,16 @@ int net_conn_register(u16_t proto, u8_t family,
*
* @return Return 0 if the unregistration succeed, <0 otherwise.
*/
#if defined(CONFIG_NET_NATIVE)
int net_conn_unregister(struct net_conn_handle *handle);
#else
static inline int net_conn_unregister(struct net_conn_handle *handle)
{
ARG_UNUSED(handle);
return -ENOTSUP;
}
#endif
/**
* @brief Change the callback and user_data for a registered connection
@ -165,7 +198,11 @@ typedef void (*net_conn_foreach_cb_t)(struct net_conn *conn, void *user_data);
*/
void net_conn_foreach(net_conn_foreach_cb_t cb, void *user_data);
#if defined(CONFIG_NET_NATIVE)
void net_conn_init(void);
#else
#define net_conn_init(...)
#endif
#ifdef __cplusplus
}

View file

@ -68,13 +68,33 @@ int net_icmpv4_send_error(struct net_pkt *pkt, u8_t type, u8_t code);
*
* @return Return 0 if the sending succeed, <0 otherwise.
*/
#if defined(CONFIG_NET_NATIVE_IPV4)
int net_icmpv4_send_echo_request(struct net_if *iface,
struct in_addr *dst,
u16_t identifier,
u16_t sequence,
const void *data,
size_t data_size);
#else
static inline int net_icmpv4_send_echo_request(struct net_if *iface,
struct in_addr *dst,
u16_t identifier,
u16_t sequence,
const void *data,
size_t data_size)
{
ARG_UNUSED(iface);
ARG_UNUSED(dst);
ARG_UNUSED(identifier);
ARG_UNUSED(sequence);
ARG_UNUSED(data);
ARG_UNUSED(data_size);
return -ENOTSUP;
}
#endif
#if defined(CONFIG_NET_NATIVE_IPV4)
void net_icmpv4_register_handler(struct net_icmpv4_handler *handler);
void net_icmpv4_unregister_handler(struct net_icmpv4_handler *handler);
@ -84,10 +104,11 @@ enum net_verdict net_icmpv4_input(struct net_pkt *pkt,
int net_icmpv4_finalize(struct net_pkt *pkt);
#if defined(CONFIG_NET_IPV4)
void net_icmpv4_init(void);
#else
#define net_icmpv4_init(...)
#define net_icmpv4_register_handler(...)
#define net_icmpv4_unregister_handler(...)
#endif
#endif /* __ICMPV4_H */

View file

@ -184,13 +184,33 @@ int net_icmpv6_send_error(struct net_pkt *pkt, u8_t type, u8_t code,
*
* @return Return 0 if the sending succeed, <0 otherwise.
*/
#if defined(CONFIG_NET_NATIVE_IPV6)
int net_icmpv6_send_echo_request(struct net_if *iface,
struct in6_addr *dst,
u16_t identifier,
u16_t sequence,
const void *data,
size_t data_size);
#else
static inline int net_icmpv6_send_echo_request(struct net_if *iface,
struct in6_addr *dst,
u16_t identifier,
u16_t sequence,
const void *data,
size_t data_size)
{
ARG_UNUSED(iface);
ARG_UNUSED(dst);
ARG_UNUSED(identifier);
ARG_UNUSED(sequence);
ARG_UNUSED(data);
ARG_UNUSED(data_size);
return -ENOTSUP;
}
#endif
#if defined(CONFIG_NET_NATIVE_IPV6)
void net_icmpv6_register_handler(struct net_icmpv6_handler *handler);
void net_icmpv6_unregister_handler(struct net_icmpv6_handler *handler);
enum net_verdict net_icmpv6_input(struct net_pkt *pkt,
@ -199,10 +219,11 @@ enum net_verdict net_icmpv6_input(struct net_pkt *pkt,
int net_icmpv6_create(struct net_pkt *pkt, u8_t icmp_type, u8_t icmp_code);
int net_icmpv6_finalize(struct net_pkt *pkt);
#if defined(CONFIG_NET_IPV6)
void net_icmpv6_init(void);
#else
#define net_icmpv6_init(...)
#define net_icmpv6_register_handler(...)
#define net_icmpv6_unregister_handler(...)
#endif
#endif /* __ICMPV6_H */

View file

@ -97,20 +97,6 @@ int net_ipv4_finalize(struct net_pkt *pkt, u8_t next_header_proto)
return 0;
}
const struct in_addr *net_ipv4_unspecified_address(void)
{
static const struct in_addr addr;
return &addr;
}
const struct in_addr *net_ipv4_broadcast_address(void)
{
static const struct in_addr addr = { { { 255, 255, 255, 255 } } };
return &addr;
}
enum net_verdict net_ipv4_input(struct net_pkt *pkt)
{
NET_PKT_DATA_ACCESS_CONTIGUOUS_DEFINE(ipv4_access, struct net_ipv4_hdr);

View file

@ -31,9 +31,22 @@
*
* @return 0 on success, negative errno otherwise.
*/
#if defined(CONFIG_NET_NATIVE_IPV4)
int net_ipv4_create(struct net_pkt *pkt,
const struct in_addr *src,
const struct in_addr *dst);
#else
static inline int net_ipv4_create(struct net_pkt *pkt,
const struct in_addr *src,
const struct in_addr *dst)
{
ARG_UNUSED(pkt);
ARG_UNUSED(src);
ARG_UNUSED(dst);
return -ENOTSUP;
}
#endif
/**
* @brief Finalize IPv4 packet. It should be called right before
@ -46,6 +59,17 @@ int net_ipv4_create(struct net_pkt *pkt,
*
* @return 0 on success, negative errno otherwise.
*/
#if defined(CONFIG_NET_NATIVE_IPV4)
int net_ipv4_finalize(struct net_pkt *pkt, u8_t next_header_proto);
#else
static inline int net_ipv4_finalize(struct net_pkt *pkt,
u8_t next_header_proto)
{
ARG_UNUSED(pkt);
ARG_UNUSED(next_header_proto);
return -ENOTSUP;
}
#endif
#endif /* __IPV4_H */

View file

@ -47,15 +47,6 @@ LOG_MODULE_REGISTER(net_ipv6, CONFIG_NET_IPV6_LOG_LEVEL);
*/
#define MAX_REACHABLE_TIME 3600000
/* IPv6 wildcard and loopback address defined by RFC2553 */
const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
const struct in6_addr *net_ipv6_unspecified_address(void)
{
return &in6addr_any;
}
int net_ipv6_create(struct net_pkt *pkt,
const struct in6_addr *src,
const struct in6_addr *dst)

View file

@ -151,9 +151,22 @@ static inline bool net_ipv6_is_nexthdr_upper_layer(u8_t nexthdr)
*
* @return 0 on success, negative errno otherwise.
*/
#if defined(CONFIG_NET_NATIVE_IPV6)
int net_ipv6_create(struct net_pkt *pkt,
const struct in6_addr *src,
const struct in6_addr *dst);
#else
static inline int net_ipv6_create(struct net_pkt *pkt,
const struct in6_addr *src,
const struct in6_addr *dst)
{
ARG_UNUSED(pkt);
ARG_UNUSED(src);
ARG_UNUSED(dst);
return -ENOTSUP;
}
#endif
/**
* @brief Finalize IPv6 packet. It should be called right before
@ -166,8 +179,18 @@ int net_ipv6_create(struct net_pkt *pkt,
*
* @return 0 on success, negative errno otherwise.
*/
#if defined(CONFIG_NET_NATIVE_IPV6)
int net_ipv6_finalize(struct net_pkt *pkt, u8_t next_header_proto);
#else
static inline int net_ipv6_finalize(struct net_pkt *pkt,
u8_t next_header_proto)
{
ARG_UNUSED(pkt);
ARG_UNUSED(next_header_proto);
return -ENOTSUP;
}
#endif
/**
* @brief Join a given multicast group.
@ -218,7 +241,7 @@ typedef void (*net_nbr_cb_t)(struct net_nbr *nbr, void *user_data);
*
* @return Return a verdict.
*/
#if defined(CONFIG_NET_IPV6_NBR_CACHE)
#if defined(CONFIG_NET_IPV6_NBR_CACHE) && defined(CONFIG_NET_NATIVE_IPV6)
enum net_verdict net_ipv6_prepare_for_send(struct net_pkt *pkt);
#else
static inline enum net_verdict net_ipv6_prepare_for_send(struct net_pkt *pkt)
@ -235,7 +258,7 @@ static inline enum net_verdict net_ipv6_prepare_for_send(struct net_pkt *pkt)
*
* @return A valid pointer on a neighbor on success, NULL otherwise
*/
#if defined(CONFIG_NET_IPV6_NBR_CACHE)
#if defined(CONFIG_NET_IPV6_NBR_CACHE) && defined(CONFIG_NET_NATIVE_IPV6)
struct net_nbr *net_ipv6_nbr_lookup(struct net_if *iface,
struct in6_addr *addr);
#else
@ -266,7 +289,7 @@ struct net_nbr *net_ipv6_get_nbr(struct net_if *iface, u8_t idx);
*
* @return A valid pointer on a neighbor on success, NULL otherwise
*/
#if defined(CONFIG_NET_IPV6_NBR_CACHE)
#if defined(CONFIG_NET_IPV6_NBR_CACHE) && defined(CONFIG_NET_NATIVE_IPV6)
struct in6_addr *net_ipv6_nbr_lookup_by_index(struct net_if *iface,
u8_t idx);
#else
@ -293,7 +316,7 @@ struct in6_addr *net_ipv6_nbr_lookup_by_index(struct net_if *iface,
*
* @return A valid pointer on a neighbor on success, NULL otherwise
*/
#if defined(CONFIG_NET_IPV6_NBR_CACHE)
#if defined(CONFIG_NET_IPV6_NBR_CACHE) && defined(CONFIG_NET_NATIVE_IPV6)
struct net_nbr *net_ipv6_nbr_add(struct net_if *iface,
struct in6_addr *addr,
struct net_linkaddr *lladdr,
@ -318,7 +341,7 @@ static inline struct net_nbr *net_ipv6_nbr_add(struct net_if *iface,
*
* @return True if neighbor could be removed, False otherwise
*/
#if defined(CONFIG_NET_IPV6_NBR_CACHE)
#if defined(CONFIG_NET_IPV6_NBR_CACHE) && defined(CONFIG_NET_NATIVE_IPV6)
bool net_ipv6_nbr_rm(struct net_if *iface, struct in6_addr *addr);
#else
static inline bool net_ipv6_nbr_rm(struct net_if *iface, struct in6_addr *addr)
@ -333,7 +356,7 @@ static inline bool net_ipv6_nbr_rm(struct net_if *iface, struct in6_addr *addr)
* @param cb User supplied callback function to call.
* @param user_data User specified data.
*/
#if defined(CONFIG_NET_IPV6_NBR_CACHE)
#if defined(CONFIG_NET_IPV6_NBR_CACHE) && defined(CONFIG_NET_NATIVE_IPV6)
void net_ipv6_nbr_foreach(net_nbr_cb_t cb, void *user_data);
#else /* CONFIG_NET_IPV6_NBR_CACHE */
static inline void net_ipv6_nbr_foreach(net_nbr_cb_t cb, void *user_data)
@ -348,7 +371,7 @@ static inline void net_ipv6_nbr_foreach(net_nbr_cb_t cb, void *user_data)
* @param iface A valid pointer on a network interface
* @param nbr Neighbor struct pointer
*/
#if defined(CONFIG_NET_IPV6_ND)
#if defined(CONFIG_NET_IPV6_ND) && defined(CONFIG_NET_NATIVE_IPV6)
void net_ipv6_nbr_set_reachable_timer(struct net_if *iface,
struct net_nbr *nbr);
@ -429,7 +452,7 @@ int net_ipv6_find_last_ext_hdr(struct net_pkt *pkt, u16_t *next_hdr_off,
*
* @return Return verdict about the packet
*/
#if defined(CONFIG_NET_IPV6_FRAGMENT)
#if defined(CONFIG_NET_IPV6_FRAGMENT) && defined(CONFIG_NET_NATIVE_IPV6)
enum net_verdict net_ipv6_handle_fragment_hdr(struct net_pkt *pkt,
struct net_ipv6_hdr *hdr,
u8_t nexthdr);
@ -447,7 +470,7 @@ enum net_verdict net_ipv6_handle_fragment_hdr(struct net_pkt *pkt,
}
#endif /* CONFIG_NET_IPV6_FRAGMENT */
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
void net_ipv6_init(void);
void net_ipv6_nbr_init(void);
#if defined(CONFIG_NET_IPV6_MLD)

View file

@ -193,7 +193,16 @@ int net_nbr_unlink(struct net_nbr *nbr, struct net_linkaddr *lladdr);
* @param idx Link layer address index in ll table.
* @return Pointer to link layer address storage, NULL if not found
*/
#if defined(CONFIG_NET_NATIVE)
struct net_linkaddr_storage *net_nbr_get_lladdr(u8_t idx);
#else
static inline struct net_linkaddr_storage *net_nbr_get_lladdr(u8_t idx)
{
ARG_UNUSED(idx);
return NULL;
}
#endif
/**
* @brief Clear table from all neighbors. After this the linking between

View file

@ -42,13 +42,13 @@ extern struct net_if __net_if_end[];
extern struct net_if_dev __net_if_dev_start[];
extern struct net_if_dev __net_if_dev_end[];
#if defined(CONFIG_NET_IPV4) || defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV4) || defined(CONFIG_NET_NATIVE_IPV6)
static struct net_if_router routers[CONFIG_NET_MAX_ROUTERS];
static struct k_delayed_work router_timer;
static sys_slist_t active_router_timers;
#endif
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
/* Timer that triggers network address renewal */
static struct k_delayed_work address_lifetime_timer;
@ -78,7 +78,7 @@ static struct {
} ipv6_addresses[CONFIG_NET_IF_MAX_IPV6_COUNT];
#endif /* CONFIG_NET_IPV6 */
#if defined(CONFIG_NET_IPV4)
#if defined(CONFIG_NET_NATIVE_IPV4)
static struct {
struct net_if_ipv4 ipv4;
struct net_if *iface;
@ -89,7 +89,7 @@ static struct {
*/
static sys_slist_t link_callbacks;
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
/* Multicast join/leave tracking.
*/
static sys_slist_t mcast_monitor_callbacks;
@ -438,7 +438,7 @@ static enum net_l2_flags l2_flags_get(struct net_if *iface)
return flags;
}
#if defined(CONFIG_NET_IPV4) || defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV4) || defined(CONFIG_NET_NATIVE_IPV6)
/* Return how many bits are shared between two IP addresses */
static u8_t get_ipaddr_diff(const u8_t *src, const u8_t *dst, int addr_len)
{
@ -687,7 +687,7 @@ static void iface_router_init(void)
#define iface_router_init(...)
#endif
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
int net_if_config_ipv6_get(struct net_if *iface, struct net_if_ipv6 **ipv6)
{
int i;
@ -2402,9 +2402,36 @@ static void iface_ipv6_init(int if_count)
#define join_mcast_nodes(...)
#define iface_ipv6_start(...)
#define iface_ipv6_init(...)
struct net_if_mcast_addr *net_if_ipv6_maddr_lookup(const struct in6_addr *addr,
struct net_if **iface)
{
ARG_UNUSED(addr);
ARG_UNUSED(iface);
return NULL;
}
struct net_if_addr *net_if_ipv6_addr_lookup(const struct in6_addr *addr,
struct net_if **ret)
{
ARG_UNUSED(addr);
ARG_UNUSED(ret);
return NULL;
}
struct in6_addr *net_if_ipv6_get_global_addr(enum net_addr_state state,
struct net_if **iface)
{
ARG_UNUSED(state);
ARG_UNUSED(iface);
return NULL;
}
#endif /* CONFIG_NET_IPV6 */
#if defined(CONFIG_NET_IPV4)
#if defined(CONFIG_NET_NATIVE_IPV4)
int net_if_config_ipv4_get(struct net_if *iface, struct net_if_ipv4 **ipv4)
{
int i;
@ -3170,6 +3197,33 @@ static void iface_ipv4_init(int if_count)
#else
#define iface_ipv4_init(...)
struct net_if_mcast_addr *net_if_ipv4_maddr_lookup(const struct in_addr *addr,
struct net_if **iface)
{
ARG_UNUSED(addr);
ARG_UNUSED(iface);
return NULL;
}
struct net_if_addr *net_if_ipv4_addr_lookup(const struct in_addr *addr,
struct net_if **ret)
{
ARG_UNUSED(addr);
ARG_UNUSED(ret);
return NULL;
}
struct in_addr *net_if_ipv4_get_global_addr(struct net_if *iface,
enum net_addr_state addr_state)
{
ARG_UNUSED(addr_state);
ARG_UNUSED(iface);
return NULL;
}
#endif /* CONFIG_NET_IPV4 */
struct net_if *net_if_select_src_iface(const struct sockaddr *dst)

View file

@ -38,15 +38,42 @@
#include "connection.h"
extern void net_pkt_init(void);
extern void net_if_init(void);
extern void net_if_post_init(void);
extern void net_if_carrier_down(struct net_if *iface);
#if defined(CONFIG_NET_NATIVE) || defined(CONFIG_NET_OFFLOAD)
extern void net_context_init(void);
enum net_verdict net_ipv4_input(struct net_pkt *pkt);
enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback);
extern void net_pkt_init(void);
extern void net_tc_tx_init(void);
extern void net_tc_rx_init(void);
#else
static inline void net_context_init(void) { }
static inline void net_pkt_init(void) { }
static inline void net_tc_tx_init(void) { }
static inline void net_tc_rx_init(void) { }
#endif
#if defined(CONFIG_NET_NATIVE)
enum net_verdict net_ipv4_input(struct net_pkt *pkt);
enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback);
#else
static inline enum net_verdict net_ipv4_input(struct net_pkt *pkt)
{
ARG_UNUSED(pkt);
return NET_CONTINUE;
}
static inline enum net_verdict net_ipv6_input(struct net_pkt *pkt,
bool is_loopback)
{
ARG_UNUSED(pkt);
ARG_UNUSED(is_loopback);
return NET_CONTINUE;
}
#endif
extern void net_tc_submit_to_tx_queue(u8_t tc, struct net_pkt *pkt);
extern void net_tc_submit_to_rx_queue(u8_t tc, struct net_pkt *pkt);
extern enum net_verdict net_promisc_mode_input(struct net_pkt *pkt);

View file

@ -224,7 +224,7 @@ static const char *iface2str(struct net_if *iface, const char **extra)
return "<unknown type>";
}
#if defined(CONFIG_NET_L2_ETHERNET)
#if defined(CONFIG_NET_L2_ETHERNET) && defined(CONFIG_NET_NATIVE)
struct ethernet_capabilities {
enum ethernet_hw_caps capability;
const char * const description;
@ -265,6 +265,7 @@ static void print_supported_ethernet_capabilities(
static void iface_cb(struct net_if *iface, void *user_data)
{
#if defined(CONFIG_NET_NATIVE)
struct net_shell_user_data *data = user_data;
const struct shell *shell = data->shell;
@ -547,9 +548,15 @@ static void iface_cb(struct net_if *iface, void *user_data)
PR("DHCPv4 attempts : %d\n",
iface->config.dhcpv4.attempts);
#endif /* CONFIG_NET_DHCPV4 */
#else
ARG_UNUSED(iface);
ARG_UNUSED(user_data);
#endif /* CONFIG_NET_NATIVE */
}
#if defined(CONFIG_NET_ROUTE)
#if defined(CONFIG_NET_ROUTE) && defined(CONFIG_NET_NATIVE)
static void route_cb(struct net_route_entry *entry, void *user_data)
{
struct net_shell_user_data *data = user_data;
@ -609,7 +616,7 @@ static void iface_per_route_cb(struct net_if *iface, void *user_data)
}
#endif /* CONFIG_NET_ROUTE */
#if defined(CONFIG_NET_ROUTE_MCAST)
#if defined(CONFIG_NET_ROUTE_MCAST) && defined(CONFIG_NET_NATIVE)
static void route_mcast_cb(struct net_route_entry_mcast *entry,
void *user_data)
{
@ -715,6 +722,10 @@ static void print_ppp_stats(struct net_if *iface, struct net_stats_ppp *data,
}
#endif /* CONFIG_NET_STATISTICS_PPP && CONFIG_NET_STATISTICS_USER_API */
#if !defined(CONFIG_NET_NATIVE)
#define GET_STAT(a, b) 0
#endif
static void print_tc_tx_stats(const struct shell *shell, struct net_if *iface)
{
#if NET_TC_TX_COUNT > 1
@ -799,7 +810,7 @@ static void net_shell_print_statistics(struct net_if *iface, void *user_data)
PR("=================\n");
}
#if defined(CONFIG_NET_STATISTICS_IPV6)
#if defined(CONFIG_NET_STATISTICS_IPV6) && defined(CONFIG_NET_NATIVE_IPV6)
PR("IPv6 recv %d\tsent\t%d\tdrop\t%d\tforwarded\t%d\n",
GET_STAT(iface, ipv6.recv),
GET_STAT(iface, ipv6.sent),
@ -819,7 +830,7 @@ static void net_shell_print_statistics(struct net_if *iface, void *user_data)
#endif /* CONFIG_NET_STATISTICS_MLD */
#endif /* CONFIG_NET_STATISTICS_IPV6 */
#if defined(CONFIG_NET_STATISTICS_IPV4)
#if defined(CONFIG_NET_STATISTICS_IPV4) && defined(CONFIG_NET_NATIVE_IPV4)
PR("IPv4 recv %d\tsent\t%d\tdrop\t%d\tforwarded\t%d\n",
GET_STAT(iface, ipv4.recv),
GET_STAT(iface, ipv4.sent),
@ -836,7 +847,7 @@ static void net_shell_print_statistics(struct net_if *iface, void *user_data)
GET_STAT(iface, ip_errors.chkerr),
GET_STAT(iface, ip_errors.protoerr));
#if defined(CONFIG_NET_STATISTICS_ICMP)
#if defined(CONFIG_NET_STATISTICS_ICMP) && defined(CONFIG_NET_NATIVE_IPV4)
PR("ICMP recv %d\tsent\t%d\tdrop\t%d\n",
GET_STAT(iface, icmp.recv),
GET_STAT(iface, icmp.sent),
@ -846,7 +857,7 @@ static void net_shell_print_statistics(struct net_if *iface, void *user_data)
GET_STAT(iface, icmp.chkerr));
#endif
#if defined(CONFIG_NET_STATISTICS_UDP)
#if defined(CONFIG_NET_STATISTICS_UDP) && defined(CONFIG_NET_NATIVE_UDP)
PR("UDP recv %d\tsent\t%d\tdrop\t%d\n",
GET_STAT(iface, udp.recv),
GET_STAT(iface, udp.sent),
@ -855,7 +866,7 @@ static void net_shell_print_statistics(struct net_if *iface, void *user_data)
GET_STAT(iface, udp.chkerr));
#endif
#if defined(CONFIG_NET_STATISTICS_TCP)
#if defined(CONFIG_NET_STATISTICS_TCP) && defined(CONFIG_NET_NATIVE_TCP)
PR("TCP bytes recv %u\tsent\t%d\n",
GET_STAT(iface, tcp.bytes.received),
GET_STAT(iface, tcp.bytes.sent));
@ -876,7 +887,7 @@ static void net_shell_print_statistics(struct net_if *iface, void *user_data)
GET_STAT(iface, tcp.connrst));
#endif
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP)
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP) && defined(CONFIG_NET_NATIVE)
if (GET_STAT(iface, tx_time.time_count) > 0) {
PR("Network pkt TX time %lu us\n",
(u32_t)(GET_STAT(iface, tx_time.time_sum) /
@ -921,6 +932,7 @@ static void net_shell_print_statistics(struct net_if *iface, void *user_data)
}
#endif /* CONFIG_NET_STATISTICS */
#if defined(CONFIG_NET_OFFLOAD) || defined(CONFIG_NET_NATIVE)
static void get_addresses(struct net_context *context,
char addr_local[], int local_len,
char addr_remote[], int remote_len)
@ -994,6 +1006,7 @@ static void context_cb(struct net_context *context, void *user_data)
(*count)++;
}
#endif /* CONFIG_NET_OFFLOAD || CONFIG_NET_NATIVE */
#if CONFIG_NET_CONN_LOG_LEVEL >= LOG_LEVEL_DBG
static void conn_handler_cb(struct net_conn *conn, void *user_data)
@ -1057,7 +1070,8 @@ static void conn_handler_cb(struct net_conn *conn, void *user_data)
}
#endif /* CONFIG_NET_CONN_LOG_LEVEL >= LOG_LEVEL_DBG */
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_TCP) && \
(defined(CONFIG_NET_OFFLOAD) || defined(CONFIG_NET_NATIVE))
static void tcp_cb(struct net_tcp *tcp, void *user_data)
{
struct net_shell_user_data *data = user_data;
@ -1262,7 +1276,7 @@ static int cmd_net_allocs(const struct shell *shell, size_t argc, char *argv[])
return 0;
}
#if defined(CONFIG_NET_ARP)
#if defined(CONFIG_NET_ARP) && defined(CONFIG_NET_NATIVE)
static void arp_cb(struct arp_entry *entry, void *user_data)
{
struct net_shell_user_data *data = user_data;
@ -1284,8 +1298,8 @@ static void arp_cb(struct arp_entry *entry, void *user_data)
#if !defined(CONFIG_NET_ARP)
static void print_arp_error(const struct shell *shell)
{
PR_INFO("Enable CONFIG_NET_ARP, CONFIG_NET_IPV4 and "
"CONFIG_NET_L2_ETHERNET to see ARP information.\n");
PR_INFO("Enable CONFIG_NET_NATIVE, CONFIG_NET_ARP, CONFIG_NET_IPV4 and"
" CONFIG_NET_L2_ETHERNET to see ARP information.\n");
}
#endif
@ -1335,12 +1349,13 @@ static int cmd_net_arp_flush(const struct shell *shell, size_t argc,
static int cmd_net_conn(const struct shell *shell, size_t argc, char *argv[])
{
struct net_shell_user_data user_data;
int count = 0;
ARG_UNUSED(argc);
ARG_UNUSED(argv);
#if defined(CONFIG_NET_OFFLOAD) || defined(CONFIG_NET_NATIVE)
struct net_shell_user_data user_data;
int count = 0;
PR(" Context \tIface Flags Local \tRemote\n");
user_data.shell = shell;
@ -1396,6 +1411,12 @@ static int cmd_net_conn(const struct shell *shell, size_t argc, char *argv[])
/* Do not print anything if no fragments are pending atm */
#endif
#else
PR("Enable CONFIG_NET_OFFLOAD or CONFIG_NET_NATIVE to see "
"connection information.");
#endif /* CONFIG_NET_OFFLOAD || CONFIG_NET_NATIVE */
return 0;
}
@ -2305,7 +2326,7 @@ static int cmd_net_iface_down(const struct shell *shell, size_t argc,
return 0;
}
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
static u32_t time_diff(u32_t time1, u32_t time2)
{
return (u32_t)abs((s32_t)time1 - (s32_t)time2);
@ -2374,11 +2395,11 @@ static void address_lifetime_cb(struct net_if *iface, void *user_data)
prefix_len);
}
}
#endif /* CONFIG_NET_IPV6 */
#endif /* CONFIG_NET_NATIVE_IPV6 */
static int cmd_net_ipv6(const struct shell *shell, size_t argc, char *argv[])
{
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
struct net_shell_user_data user_data;
#endif
@ -2389,7 +2410,7 @@ static int cmd_net_ipv6(const struct shell *shell, size_t argc, char *argv[])
return -ENOEXEC;
}
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
PR("IPv6 fragmentation support : %s\n",
IS_ENABLED(CONFIG_NET_IPV6_FRAGMENT) ? "enabled" :
"disabled");
@ -2480,6 +2501,7 @@ struct ctx_info {
struct net_buf_pool *data_pools[CONFIG_NET_MAX_CONTEXTS];
};
#if defined(CONFIG_NET_OFFLOAD) || defined(CONFIG_NET_NATIVE)
#if defined(CONFIG_NET_CONTEXT_NET_PKT_POOL)
static bool slab_pool_found_already(struct ctx_info *info,
struct k_mem_slab *slab,
@ -2554,15 +2576,17 @@ static void context_info(struct net_context *context, void *user_data)
info->pos++;
#endif /* CONFIG_NET_CONTEXT_NET_PKT_POOL */
}
#endif /* CONFIG_NET_OFFLOAD || CONFIG_NET_NATIVE */
static int cmd_net_mem(const struct shell *shell, size_t argc, char *argv[])
{
struct k_mem_slab *rx, *tx;
struct net_buf_pool *rx_data, *tx_data;
ARG_UNUSED(argc);
ARG_UNUSED(argv);
#if defined(CONFIG_NET_OFFLOAD) || defined(CONFIG_NET_NATIVE)
struct k_mem_slab *rx, *tx;
struct net_buf_pool *rx_data, *tx_data;
net_pkt_get_info(&rx, &tx, &rx_data, &tx_data);
PR("Fragment length %d bytes\n", CONFIG_NET_BUF_DATA_SIZE);
@ -2610,6 +2634,10 @@ static int cmd_net_mem(const struct shell *shell, size_t argc, char *argv[])
PR("No external memory pools found.\n");
}
}
#else
PR("Enable CONFIG_NET_OFFLOAD or CONFIG_NET_NATIVE to see "
"memory usage.");
#endif /* CONFIG_NET_OFFLOAD || CONFIG_NET_NATIVE */
return 0;
}
@ -2744,7 +2772,7 @@ static int cmd_net_nbr(const struct shell *shell, size_t argc, char *argv[])
K_SEM_DEFINE(ping_timeout, 0, 1);
static const struct shell *shell_for_ping;
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
static enum net_verdict handle_ipv6_echo_reply(struct net_pkt *pkt,
struct net_ipv6_hdr *ip_hdr,
@ -2871,7 +2899,7 @@ static int ping_ipv6(const struct shell *shell,
#define remove_ipv6_ping_handler()
#endif /* CONFIG_NET_IPV6 */
#if defined(CONFIG_NET_IPV4)
#if defined(CONFIG_NET_NATIVE_IPV4)
static enum net_verdict handle_ipv4_echo_reply(struct net_pkt *pkt,
struct net_ipv4_hdr *ip_hdr,
@ -3193,13 +3221,14 @@ static int cmd_net_ppp_status(const struct shell *shell, size_t argc,
static int cmd_net_route(const struct shell *shell, size_t argc, char *argv[])
{
ARG_UNUSED(argc);
ARG_UNUSED(argv);
#if defined(CONFIG_NET_NATIVE)
#if defined(CONFIG_NET_ROUTE) || defined(CONFIG_NET_ROUTE_MCAST)
struct net_shell_user_data user_data;
#endif
ARG_UNUSED(argc);
ARG_UNUSED(argv);
#if defined(CONFIG_NET_ROUTE) || defined(CONFIG_NET_ROUTE_MCAST)
user_data.shell = shell;
#endif
@ -3214,7 +3243,7 @@ static int cmd_net_route(const struct shell *shell, size_t argc, char *argv[])
#if defined(CONFIG_NET_ROUTE_MCAST)
net_if_foreach(iface_per_mcast_route_cb, &user_data);
#endif
#endif
return 0;
}
@ -3391,7 +3420,7 @@ static int cmd_net_stats(const struct shell *shell, size_t argc, char *argv[])
return 0;
}
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
static struct net_context *tcp_ctx;
static const struct shell *tcp_shell;
@ -3431,7 +3460,7 @@ static void get_my_ipv6_addr(struct net_if *iface,
static void get_my_ipv4_addr(struct net_if *iface,
struct sockaddr *myaddr)
{
#if defined(CONFIG_NET_IPV4)
#if defined(CONFIG_NET_NATIVE_IPV4)
/* Just take the first IPv4 address of an interface. */
memcpy(&net_sin(myaddr)->sin_addr,
&iface->config.ip.ipv4->unicast[0].address.in_addr,
@ -3594,16 +3623,14 @@ static void tcp_sent_cb(struct net_context *context,
static int cmd_net_tcp_connect(const struct shell *shell, size_t argc,
char *argv[])
{
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int arg = 0;
/* tcp connect <ip> port */
char *endptr;
char *ip;
u16_t port;
#endif
#if defined(CONFIG_NET_TCP)
/* tcp connect <ip> port */
if (tcp_ctx && net_context_is_used(tcp_ctx)) {
PR("Already connected\n");
@ -3630,8 +3657,9 @@ static int cmd_net_tcp_connect(const struct shell *shell, size_t argc,
tcp_connect(shell, ip, port, &tcp_ctx);
#else
PR_INFO("TCP not enabled. Set CONFIG_NET_TCP to enable it.\n");
#endif /* CONFIG_NET_TCP */
PR_INFO("Native TCP not enabled. Set CONFIG_NET_TCP and "
"CONFIG_NET_NATIVE to enable TCP support.\n");
#endif /* CONFIG_NET_NATIVE_TCP */
return 0;
}
@ -3639,7 +3667,7 @@ static int cmd_net_tcp_connect(const struct shell *shell, size_t argc,
static int cmd_net_tcp_send(const struct shell *shell, size_t argc,
char *argv[])
{
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int arg = 0;
int ret;
struct net_shell_user_data user_data;
@ -3666,8 +3694,9 @@ static int cmd_net_tcp_send(const struct shell *shell, size_t argc,
}
#else
PR_INFO("TCP not enabled. Set CONFIG_NET_TCP to enable it.\n");
#endif /* CONFIG_NET_TCP */
PR_INFO("Native TCP not enabled. Set CONFIG_NET_TCP and "
"CONFIG_NET_NATIVE to enable TCP support.\n");
#endif /* CONFIG_NET_NATIVE_TCP */
return 0;
}
@ -3675,11 +3704,9 @@ static int cmd_net_tcp_send(const struct shell *shell, size_t argc,
static int cmd_net_tcp_close(const struct shell *shell, size_t argc,
char *argv[])
{
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int ret;
#endif
#if defined(CONFIG_NET_TCP)
/* tcp close */
if (!tcp_ctx || !net_context_is_used(tcp_ctx)) {
PR_WARNING("Not connected\n");
@ -3695,7 +3722,8 @@ static int cmd_net_tcp_close(const struct shell *shell, size_t argc,
PR("Connection closed.\n");
tcp_ctx = NULL;
#else
PR_INFO("TCP not enabled. Set CONFIG_NET_TCP to enable it.\n");
PR_INFO("Native TCP not enabled. Set CONFIG_NET_TCP and "
"CONFIG_NET_NATIVE to enable TCP support.\n");
#endif /* CONFIG_NET_TCP */
return 0;

View file

@ -7,7 +7,7 @@
#ifndef __NET_STATS_H__
#define __NET_STATS_H__
#if defined(CONFIG_NET_STATISTICS)
#if defined(CONFIG_NET_STATISTICS) && defined(CONFIG_NET_NATIVE)
#include <stdlib.h>
@ -67,7 +67,7 @@ static inline void net_stats_update_bytes_sent(struct net_if *iface,
#define net_stats_update_bytes_sent(iface, bytes)
#endif /* CONFIG_NET_STATISTICS */
#if defined(CONFIG_NET_STATISTICS_IPV6)
#if defined(CONFIG_NET_STATISTICS_IPV6) && defined(CONFIG_NET_NATIVE_IPV6)
/* IPv6 stats */
static inline void net_stats_update_ipv6_sent(struct net_if *iface)
@ -90,7 +90,7 @@ static inline void net_stats_update_ipv6_drop(struct net_if *iface)
#define net_stats_update_ipv6_recv(iface)
#endif /* CONFIG_NET_STATISTICS_IPV6 */
#if defined(CONFIG_NET_STATISTICS_IPV6_ND)
#if defined(CONFIG_NET_STATISTICS_IPV6_ND) && defined(CONFIG_NET_NATIVE_IPV6)
/* IPv6 Neighbor Discovery stats*/
static inline void net_stats_update_ipv6_nd_sent(struct net_if *iface)
@ -113,7 +113,7 @@ static inline void net_stats_update_ipv6_nd_drop(struct net_if *iface)
#define net_stats_update_ipv6_nd_drop(iface)
#endif /* CONFIG_NET_STATISTICS_IPV6_ND */
#if defined(CONFIG_NET_STATISTICS_IPV4)
#if defined(CONFIG_NET_STATISTICS_IPV4) && defined(CONFIG_NET_NATIVE_IPV4)
/* IPv4 stats */
static inline void net_stats_update_ipv4_drop(struct net_if *iface)
@ -136,7 +136,7 @@ static inline void net_stats_update_ipv4_recv(struct net_if *iface)
#define net_stats_update_ipv4_recv(iface)
#endif /* CONFIG_NET_STATISTICS_IPV4 */
#if defined(CONFIG_NET_STATISTICS_ICMP)
#if defined(CONFIG_NET_STATISTICS_ICMP) && defined(CONFIG_NET_NATIVE_IPV4)
/* Common ICMPv4/ICMPv6 stats */
static inline void net_stats_update_icmp_sent(struct net_if *iface)
{
@ -158,7 +158,7 @@ static inline void net_stats_update_icmp_drop(struct net_if *iface)
#define net_stats_update_icmp_drop(iface)
#endif /* CONFIG_NET_STATISTICS_ICMP */
#if defined(CONFIG_NET_STATISTICS_UDP)
#if defined(CONFIG_NET_STATISTICS_UDP) && defined(CONFIG_NET_NATIVE_UDP)
/* UDP stats */
static inline void net_stats_update_udp_sent(struct net_if *iface)
{
@ -186,7 +186,7 @@ static inline void net_stats_update_udp_chkerr(struct net_if *iface)
#define net_stats_update_udp_chkerr(iface)
#endif /* CONFIG_NET_STATISTICS_UDP */
#if defined(CONFIG_NET_STATISTICS_TCP)
#if defined(CONFIG_NET_STATISTICS_TCP) && defined(CONFIG_NET_NATIVE_TCP)
/* TCP stats */
static inline void net_stats_update_tcp_sent(struct net_if *iface, u32_t bytes)
{
@ -272,6 +272,10 @@ static inline void net_stats_update_tcp_seg_rexmit(struct net_if *iface)
static inline void net_stats_update_per_proto_recv(struct net_if *iface,
enum net_ip_protocol proto)
{
if (!IS_ENABLED(CONFIG_NET_NATIVE)) {
return;
}
if (IS_ENABLED(CONFIG_NET_UDP) && proto == IPPROTO_UDP) {
net_stats_update_udp_recv(iface);
} else if (IS_ENABLED(CONFIG_NET_TCP) && proto == IPPROTO_TCP) {
@ -282,6 +286,10 @@ static inline void net_stats_update_per_proto_recv(struct net_if *iface,
static inline void net_stats_update_per_proto_drop(struct net_if *iface,
enum net_ip_protocol proto)
{
if (!IS_ENABLED(CONFIG_NET_NATIVE)) {
return;
}
if (IS_ENABLED(CONFIG_NET_UDP) && proto == IPPROTO_UDP) {
net_stats_update_udp_drop(iface);
} else if (IS_ENABLED(CONFIG_NET_TCP) && proto == IPPROTO_TCP) {
@ -289,7 +297,7 @@ static inline void net_stats_update_per_proto_drop(struct net_if *iface,
}
}
#if defined(CONFIG_NET_STATISTICS_MLD)
#if defined(CONFIG_NET_STATISTICS_MLD) && defined(CONFIG_NET_NATIVE)
static inline void net_stats_update_ipv6_mld_recv(struct net_if *iface)
{
UPDATE_STAT(iface, stats.ipv6_mld.recv++);
@ -332,7 +340,8 @@ static inline void net_stats_update_tx_time(struct net_if *iface,
}
#endif /* CONFIG_NET_CONTEXT_TIMESTAMP && STATISTICS */
#if (NET_TC_COUNT > 1) && defined(CONFIG_NET_STATISTICS)
#if (NET_TC_COUNT > 1) && defined(CONFIG_NET_STATISTICS) \
&& defined(CONFIG_NET_NATIVE)
static inline void net_stats_update_tc_sent_pkt(struct net_if *iface, u8_t tc)
{
UPDATE_STAT(iface, stats.tc.sent[tc].pkts++);
@ -350,7 +359,8 @@ static inline void net_stats_update_tc_sent_priority(struct net_if *iface,
UPDATE_STAT(iface, stats.tc.sent[tc].priority = priority);
}
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP) && defined(CONFIG_NET_STATISTICS)
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP) && defined(CONFIG_NET_STATISTICS) \
&& defined(CONFIG_NET_NATIVE)
static inline void net_stats_update_tc_tx_time(struct net_if *iface,
u8_t tc,
u32_t start_time,
@ -401,7 +411,8 @@ static inline void net_stats_update_tc_recv_priority(struct net_if *iface,
#define net_stats_update_tc_recv_bytes(iface, tc, bytes)
#define net_stats_update_tc_recv_priority(iface, tc, priority)
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP) && defined(CONFIG_NET_STATISTICS)
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP) && defined(CONFIG_NET_STATISTICS) \
&& defined(CONFIG_NET_NATIVE)
static inline void net_stats_update_tc_tx_time(struct net_if *iface,
u8_t pkt_priority,
u32_t start_time,
@ -425,7 +436,8 @@ static inline void net_stats_update_tc_tx_time(struct net_if *iface,
#endif /* CONFIG_NET_CONTEXT_TIMESTAMP && CONFIG_NET_STATISTICS */
#endif /* NET_TC_COUNT > 1 */
#if defined(CONFIG_NET_STATISTICS_PERIODIC_OUTPUT)
#if defined(CONFIG_NET_STATISTICS_PERIODIC_OUTPUT) \
&& defined(CONFIG_NET_NATIVE)
/* A simple periodic statistic printer, used only in net core */
void net_print_statistics_all(void);
void net_print_statistics_iface(struct net_if *iface);

View file

@ -70,8 +70,19 @@ struct net_route_entry {
* @return Return route entry related to a given destination address, NULL
* if not found.
*/
#if defined(CONFIG_NET_NATIVE)
struct net_route_entry *net_route_lookup(struct net_if *iface,
struct in6_addr *dst);
#else
static inline struct net_route_entry *net_route_lookup(struct net_if *iface,
struct in6_addr *dst)
{
ARG_UNUSED(iface);
ARG_UNUSED(dst);
return NULL;
}
#endif
/**
* @brief Add a route to routing table.
@ -251,7 +262,7 @@ bool net_route_get_info(struct net_if *iface,
*/
int net_route_packet(struct net_pkt *pkt, struct in6_addr *nexthop);
#if defined(CONFIG_NET_ROUTE)
#if defined(CONFIG_NET_ROUTE) && defined(CONFIG_NET_NATIVE)
void net_route_init(void);
#else
#define net_route_init(...)

View file

@ -238,7 +238,7 @@ static inline u32_t tcp_init_isn(void)
const char *net_tcp_state_str(enum net_tcp_state state);
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
void net_tcp_change_state(struct net_tcp *tcp, enum net_tcp_state new_state);
#else
#define net_tcp_change_state(...)
@ -253,7 +253,7 @@ void net_tcp_change_state(struct net_tcp *tcp, enum net_tcp_state new_state);
* @return Pointer TCP connection context. NULL if no available
* context can be found.
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
struct net_tcp *net_tcp_alloc(struct net_context *context);
#else
static inline struct net_tcp *net_tcp_alloc(struct net_context *context)
@ -270,7 +270,7 @@ static inline struct net_tcp *net_tcp_alloc(struct net_context *context)
*
* @return 0 if ok, < 0 if error
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_release(struct net_tcp *tcp);
#else
static inline int net_tcp_release(struct net_tcp *tcp)
@ -296,7 +296,7 @@ static inline int net_tcp_release(struct net_tcp *tcp)
*
* @return 0 if ok, < 0 if error
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_prepare_segment(struct net_tcp *tcp, u8_t flags,
void *options, size_t optlen,
const struct sockaddr_ptr *local,
@ -329,7 +329,7 @@ static inline int net_tcp_prepare_segment(struct net_tcp *tcp, u8_t flags,
*
* @return 0 if ok, < 0 if error
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_prepare_ack(struct net_tcp *tcp, const struct sockaddr *remote,
struct net_pkt **pkt);
#else
@ -354,7 +354,7 @@ static inline int net_tcp_prepare_ack(struct net_tcp *tcp,
*
* @return 0 if ok, < 0 if error
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_prepare_reset(struct net_tcp *tcp,
const struct sockaddr *local,
const struct sockaddr *remote,
@ -378,7 +378,7 @@ static inline int net_tcp_prepare_reset(struct net_tcp *tcp,
* @param cb User supplied callback function to call.
* @param user_data User specified data.
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
void net_tcp_foreach(net_tcp_cb_t cb, void *user_data);
#else
static inline void net_tcp_foreach(net_tcp_cb_t cb, void *user_data)
@ -397,7 +397,7 @@ static inline void net_tcp_foreach(net_tcp_cb_t cb, void *user_data)
*
* @return 0 if ok, < 0 if error
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_send_data(struct net_context *context, net_context_send_cb_t cb,
void *user_data);
#else
@ -421,7 +421,7 @@ static inline int net_tcp_send_data(struct net_context *context,
*
* @return 0 if ok, < 0 if error
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_queue_data(struct net_context *context, struct net_pkt *pkt);
#else
static inline int net_tcp_queue_data(struct net_context *context,
@ -439,7 +439,7 @@ static inline int net_tcp_queue_data(struct net_context *context,
*
* @param pkt Packet
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_send_pkt(struct net_pkt *pkt);
#else
static inline int net_tcp_send_pkt(struct net_pkt *pkt)
@ -456,7 +456,7 @@ static inline int net_tcp_send_pkt(struct net_pkt *pkt)
* @param seq Received ACK sequence number
* @return False if ACK sequence number is invalid, true otherwise
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
bool net_tcp_ack_received(struct net_context *ctx, u32_t ack);
#else
static inline bool net_tcp_ack_received(struct net_context *ctx, u32_t ack)
@ -474,7 +474,7 @@ static inline bool net_tcp_ack_received(struct net_context *ctx, u32_t ack)
*
* @return Maximum Segment Size
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
u16_t net_tcp_get_recv_mss(const struct net_tcp *tcp);
#else
static inline u16_t net_tcp_get_recv_mss(const struct net_tcp *tcp)
@ -491,7 +491,7 @@ static inline u16_t net_tcp_get_recv_mss(const struct net_tcp *tcp)
*
* @return Current TCP receive window
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
u32_t net_tcp_get_recv_wnd(const struct net_tcp *tcp);
#else
static inline u32_t net_tcp_get_recv_wnd(const struct net_tcp *tcp)
@ -506,7 +506,7 @@ static inline u32_t net_tcp_get_recv_wnd(const struct net_tcp *tcp)
*
* @param tcp TCP context
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
static inline enum net_tcp_state net_tcp_get_state(const struct net_tcp *tcp)
{
return (enum net_tcp_state)tcp->state;
@ -527,7 +527,7 @@ static inline enum net_tcp_state net_tcp_get_state(const struct net_tcp *tcp)
*
* @return true if network packet sequence number is valid, false otherwise
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
bool net_tcp_validate_seq(struct net_tcp *tcp, struct net_tcp_hdr *tcp_hdr);
#else
static inline bool net_tcp_validate_seq(struct net_tcp *tcp,
@ -546,7 +546,7 @@ static inline bool net_tcp_validate_seq(struct net_tcp *tcp,
*
* @return 0 on success, negative errno otherwise.
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_finalize(struct net_pkt *pkt);
#else
static inline int net_tcp_finalize(struct net_pkt *pkt)
@ -582,7 +582,7 @@ int net_tcp_parse_opts(struct net_pkt *pkt, int opt_totlen,
*
* @return 0 if no erro, < 0 in case of error
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_recv(struct net_context *context, net_context_recv_cb_t cb,
void *user_data);
#else
@ -607,7 +607,7 @@ static inline int net_tcp_recv(struct net_context *context,
* in case it was not a TCP socket or -EPROTONOSUPPORT if TCP is not
* supported
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_put(struct net_context *context);
#else
static inline int net_tcp_put(struct net_context *context)
@ -626,7 +626,7 @@ static inline int net_tcp_put(struct net_context *context)
* @return 0 if successful, -EOPNOTSUPP if the context was not for TCP,
* -EPROTONOSUPPORT if TCP is not supported
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_listen(struct net_context *context);
#else
static inline int net_tcp_listen(struct net_context *context)
@ -647,7 +647,7 @@ static inline int net_tcp_listen(struct net_context *context)
* if the receive window delta is out of bounds, -EPROTONOSUPPORT
* if TCP is not supported
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_update_recv_wnd(struct net_context *context, s32_t delta);
#else
static inline int net_tcp_update_recv_wnd(struct net_context *context,
@ -667,7 +667,7 @@ static inline int net_tcp_update_recv_wnd(struct net_context *context,
*
* @return 0 if successful, < 0 on error
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_get(struct net_context *context);
#else
static inline int net_tcp_get(struct net_context *context)
@ -685,7 +685,7 @@ static inline int net_tcp_get(struct net_context *context)
*
* @return 0 if successful, < 0 on error
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_unref(struct net_context *context);
#else
static inline int net_tcp_unref(struct net_context *context)
@ -705,7 +705,7 @@ static inline int net_tcp_unref(struct net_context *context)
*
* @return 0 on success, < 0 on error
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_accept(struct net_context *context, net_tcp_accept_cb_t cb,
void *user_data);
#else
@ -734,7 +734,7 @@ static inline int net_tcp_accept(struct net_context *context,
*
* @return 0 on success, < 0 on error
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
int net_tcp_connect(struct net_context *context,
const struct sockaddr *addr,
struct sockaddr *laddr,
@ -770,7 +770,7 @@ static inline int net_tcp_connect(struct net_context *context,
*
* @return TCP header on success, NULL on error
*/
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
struct net_tcp_hdr *net_tcp_input(struct net_pkt *pkt,
struct net_pkt_data_access *tcp_access);
#else
@ -785,7 +785,7 @@ struct net_tcp_hdr *net_tcp_input(struct net_pkt *pkt,
}
#endif
#if defined(CONFIG_NET_TCP)
#if defined(CONFIG_NET_NATIVE_TCP)
void net_tcp_init(void);
#else
#define net_tcp_init(...)

View file

@ -39,7 +39,7 @@ extern "C" {
*
* @return 0 on success, negative errno otherwise.
*/
#if defined(CONFIG_NET_UDP)
#if defined(CONFIG_NET_NATIVE_UDP)
int net_udp_create(struct net_pkt *pkt, u16_t src_port, u16_t dst_port);
#else
static inline int net_udp_create(struct net_pkt *pkt,
@ -62,7 +62,7 @@ static inline int net_udp_create(struct net_pkt *pkt,
*
* @return 0 on success, negative errno otherwise.
*/
#if defined(CONFIG_NET_UDP)
#if defined(CONFIG_NET_NATIVE_UDP)
int net_udp_finalize(struct net_pkt *pkt);
#else
static inline int net_udp_finalize(struct net_pkt *pkt)
@ -81,7 +81,7 @@ static inline int net_udp_finalize(struct net_pkt *pkt)
*
* @return UDP header on success, NULL on error
*/
#if defined(CONFIG_NET_UDP)
#if defined(CONFIG_NET_NATIVE_UDP)
struct net_udp_hdr *net_udp_input(struct net_pkt *pkt,
struct net_pkt_data_access *udp_access);
#else

View file

@ -881,3 +881,26 @@ const char *net_family2str(sa_family_t family)
return NULL;
}
const struct in_addr *net_ipv4_unspecified_address(void)
{
static const struct in_addr addr;
return &addr;
}
const struct in_addr *net_ipv4_broadcast_address(void)
{
static const struct in_addr addr = { { { 255, 255, 255, 255 } } };
return &addr;
}
/* IPv6 wildcard and loopback address defined by RFC2553 */
const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
const struct in6_addr *net_ipv6_unspecified_address(void)
{
return &in6addr_any;
}

View file

@ -6,9 +6,11 @@ zephyr_library_compile_definitions_ifdef(
CONFIG_NEWLIB_LIBC __LINUX_ERRNO_EXTENSIONS__
)
zephyr_library_sources_ifdef(CONFIG_NET_ARP arp.c)
zephyr_library_sources_ifdef(CONFIG_NET_L2_ETHERNET ethernet.c)
zephyr_library_sources_ifdef(CONFIG_NET_L2_ETHERNET_MGMT ethernet_mgmt.c)
if(CONFIG_NET_NATIVE)
zephyr_library_sources_ifdef(CONFIG_NET_ARP arp.c)
zephyr_library_sources_ifdef(CONFIG_NET_STATISTICS_ETHERNET ethernet_stats.c)
if(CONFIG_NET_GPTP)
@ -18,3 +20,5 @@ endif()
if(CONFIG_NET_LLDP)
add_subdirectory(lldp)
endif()
endif()

View file

@ -7,7 +7,7 @@
#ifndef __ARP_H
#define __ARP_H
#if defined(CONFIG_NET_ARP)
#if defined(CONFIG_NET_ARP) && defined(CONFIG_NET_NATIVE)
#include <sys/slist.h>
#include <net/ethernet.h>
@ -79,6 +79,7 @@ void net_arp_init(void);
#define net_arp_prepare(_kt, _u1, _u2) _kt
#define net_arp_input(...) NET_OK
#define net_arp_clear_cache(...)
#define net_arp_foreach(...) 0
#define net_arp_init(...)
#endif /* CONFIG_NET_ARP */

View file

@ -33,7 +33,7 @@ extern const struct log_backend *log_backend_net_get(void);
static K_SEM_DEFINE(waiter, 0, 1);
static struct k_sem counter;
#if defined(CONFIG_NET_DHCPV4)
#if defined(CONFIG_NET_DHCPV4) && defined(CONFIG_NET_NATIVE_IPV4)
static struct net_mgmt_event_callback mgmt4_cb;
static void ipv4_addr_add_handler(struct net_mgmt_event_callback *cb,
@ -95,12 +95,12 @@ static void setup_dhcpv4(struct net_if *iface)
#define setup_dhcpv4(...)
#endif /* CONFIG_NET_DHCPV4 */
#if defined(CONFIG_NET_IPV4) && !defined(CONFIG_NET_DHCPV4) && \
!defined(CONFIG_NET_CONFIG_MY_IPV4_ADDR)
#if defined(CONFIG_NET_NATIVE_IPV4) && !defined(CONFIG_NET_DHCPV4) && \
!defined(CONFIG_NET_CONFIG_MY_IPV4_ADDR)
#error "You need to define an IPv4 address or enable DHCPv4!"
#endif
#if defined(CONFIG_NET_IPV4) && defined(CONFIG_NET_CONFIG_MY_IPV4_ADDR)
#if defined(CONFIG_NET_NATIVE_IPV4) && defined(CONFIG_NET_CONFIG_MY_IPV4_ADDR)
static void setup_ipv4(struct net_if *iface)
{
@ -171,7 +171,7 @@ static void setup_ipv4(struct net_if *iface)
#define setup_ipv4(...)
#endif /* CONFIG_NET_IPV4 && !CONFIG_NET_DHCPV4 */
#if defined(CONFIG_NET_IPV6)
#if defined(CONFIG_NET_NATIVE_IPV6)
#if !defined(CONFIG_NET_CONFIG_MY_IPV6_ADDR)
#error "You need to define an IPv6 address!"
#endif

View file

@ -126,7 +126,7 @@ static void conn_mgr_initial_state(struct net_if *iface)
iface_states[idx] = NET_STATE_IFACE_UP;
}
if (IS_ENABLED(CONFIG_NET_IPV6)) {
if (IS_ENABLED(CONFIG_NET_NATIVE_IPV6)) {
if (net_if_ipv6_get_global_addr(NET_ADDR_PREFERRED, &iface)) {
NET_DBG("IPv6 addr set");
iface_states[idx] |= NET_STATE_IPV6_ADDR_SET |
@ -137,7 +137,7 @@ static void conn_mgr_initial_state(struct net_if *iface)
}
}
if (IS_ENABLED(CONFIG_NET_IPV4)) {
if (IS_ENABLED(CONFIG_NET_NATIVE_IPV4)) {
if (net_if_ipv4_get_global_addr(iface, NET_ADDR_PREFERRED)) {
NET_DBG("IPv4 addr set");
iface_states[idx] |= NET_STATE_IPV4_ADDR_SET;