diff --git a/arch/sim/Kconfig b/arch/sim/Kconfig index 5168c7796eb..5bf46951542 100644 --- a/arch/sim/Kconfig +++ b/arch/sim/Kconfig @@ -100,10 +100,19 @@ config SIM_WALLTIME correct for the system timer tick rate. With this definition in the configuration, sleep() behavior is more or less normal. +config SIM_NETDEV + bool "Simulated Network Device" + default y + depends on NET + ---help--- + Build in support for a simulated network device using a TAP device on Linux or + WPCAP on Windows. + if HOST_LINUX choice prompt "Simulation Network Type" default SIM_NET_HOST_ROUTE + depends on SIM_NETDEV config SIM_NET_HOST_ROUTE bool "Use local host route" diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index 540c1c6fc87..5668604ce57 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -119,6 +119,7 @@ ifeq ($(CONFIG_ARCH_ROMGETC),y) CSRCS += up_romgetc.c endif +ifeq ($(CONFIG_SIM_NETDEV),y) ifeq ($(CONFIG_NET_ETHERNET),y) CSRCS += up_netdriver.c HOSTCFLAGS += -DNETDEV_BUFSIZE=$(CONFIG_NET_ETH_MTU) @@ -131,11 +132,12 @@ endif ifeq ($(CONFIG_SIM_NET_HOST_ROUTE),y) HOSTCFLAGS += -DCONFIG_SIM_NET_HOST_ROUTE endif -else +else # HOSTOS != Cygwin HOSTSRCS += up_wpcap.c up_netdev.c DRVLIB = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a -endif -endif +endif # HOSTOS != Cygwin +endif # CONFIG_NET_ETHERNET +endif # CONFIG_SIM_NETDEV ifeq ($(CONFIG_SMP),y) HOSTCFLAGS += -DCONFIG_SMP=1 -DCONFIG_SMP_NCPUS=$(CONFIG_SMP_NCPUS) diff --git a/arch/sim/src/up_idle.c b/arch/sim/src/up_idle.c index 1912bf755cc..05067a7c7ce 100644 --- a/arch/sim/src/up_idle.c +++ b/arch/sim/src/up_idle.c @@ -142,7 +142,7 @@ void up_idle(void) } #endif -#ifdef CONFIG_NET_ETHERNET +#if defined(CONFIG_NET_ETHERNET) && defined(CONFIG_SIM_NETDEV) /* Run the network if enabled */ netdriver_loop(); diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c index ada5bb33ba0..fa8468196e0 100644 --- a/arch/sim/src/up_initialize.c +++ b/arch/sim/src/up_initialize.c @@ -270,7 +270,7 @@ void up_initialize(void) up_registerblockdevice(); /* Our FAT ramdisk at /dev/ram0 */ #endif -#ifdef CONFIG_NET_ETHERNET +#if defined(CONFIG_NET_ETHERNET) && defined(CONFIG_SIM_NETDEV) netdriver_init(); /* Our "real" network driver */ #endif diff --git a/arch/sim/src/up_netdriver.c b/arch/sim/src/up_netdriver.c index d9c12ae3397..bb37ec9fcc7 100644 --- a/arch/sim/src/up_netdriver.c +++ b/arch/sim/src/up_netdriver.c @@ -209,7 +209,7 @@ void netdriver_loop(void) { pkt_input(&g_sim_dev); } -#endif +#endif /* CONFIG_NET_PKT */ /* We only accept IP packets of the configured type and ARP packets */ @@ -253,7 +253,7 @@ void netdriver_loop(void) } } else -#endif +#endif /* CONFIG_NET_IPv4 */ #ifdef CONFIG_NET_IPv6 if (eth->type == HTONS(ETHTYPE_IP6) && is_ours) { @@ -283,7 +283,7 @@ void netdriver_loop(void) { neighbor_out(&g_sim_dev); } -#endif +#endif /* CONFIG_NET_IPv6 */ /* And send the packet */ @@ -291,7 +291,7 @@ void netdriver_loop(void) } } else -#endif +#endif/* CONFIG_NET_IPv6 */ #ifdef CONFIG_NET_ARP if (eth->type == htons(ETHTYPE_ARP)) { @@ -307,7 +307,11 @@ void netdriver_loop(void) netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len); } } + else #endif + { + nwarn("WARNING: Unsupported Ethernet type %u\n", eth->type) + } } } diff --git a/configs/sim/nettest/defconfig b/configs/sim/nettest/defconfig index 14b60be76ef..2c94b1e3a66 100644 --- a/configs/sim/nettest/defconfig +++ b/configs/sim/nettest/defconfig @@ -77,6 +77,7 @@ CONFIG_HOST_X86_64=y CONFIG_SIM_X8664_SYSTEMV=y # CONFIG_SIM_X8664_MICROSOFT is not set # CONFIG_SIM_WALLTIME is not set +CONFIG_SIM_NETDEV=y CONFIG_SIM_NET_HOST_ROUTE=y # CONFIG_SIM_NET_BRIDGE is not set # CONFIG_SIM_FRAMEBUFFER is not set @@ -203,6 +204,8 @@ CONFIG_MAX_TASKS=64 # # CONFIG_PTHREAD_MUTEX_TYPES is not set CONFIG_PTHREAD_MUTEX_ROBUST=y +# CONFIG_PTHREAD_MUTEX_UNSAFE is not set +# CONFIG_PTHREAD_MUTEX_BOTH is not set CONFIG_NPTHREAD_KEYS=4 # CONFIG_PTHREAD_CLEANUP is not set # CONFIG_CANCELLATION_POINTS is not set @@ -368,6 +371,7 @@ CONFIG_SERIAL_CONSOLE=y # CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set +# CONFIG_USBMISC is not set # CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set # CONFIG_DRIVERS_CONTACTLESS is not set @@ -408,10 +412,12 @@ CONFIG_NET_GUARDSIZE=2 CONFIG_NET_ETHERNET=y # CONFIG_NET_LOOPBACK is not set # CONFIG_NET_TUN is not set +# CONFIG_NET_USRSOCK is not set # # Network Device Operations # +# CONFIG_NETDEV_IOCTL is not set # CONFIG_NETDEV_PHY_IOCTL is not set # @@ -442,6 +448,7 @@ CONFIG_NET_SOCKOPTS=y # TCP/IP Networking # CONFIG_NET_TCP=y +# CONFIG_NET_TCP_NO_STACK is not set # CONFIG_NET_TCPURGDATA is not set CONFIG_NET_TCP_CONNS=40 CONFIG_NET_MAX_LISTENPORTS=40 @@ -456,6 +463,7 @@ CONFIG_NET_TCP_RECVDELAY=0 # UDP Networking # # CONFIG_NET_UDP is not set +# CONFIG_NET_UDP_NO_STACK is not set # # ICMP Networking Support @@ -484,6 +492,10 @@ CONFIG_NET_IOB=y CONFIG_IOB_NBUFFERS=24 CONFIG_IOB_BUFSIZE=196 CONFIG_IOB_NCHAINS=8 + +# +# User-space networking stack API +# # CONFIG_NET_ARCH_INCR32 is not set # CONFIG_NET_ARCH_CHKSUM is not set CONFIG_NET_STATISTICS=y @@ -717,7 +729,6 @@ CONFIG_EXAMPLES_NETTEST_IPADDR=0xc0a80080 CONFIG_EXAMPLES_NETTEST_DRIPADDR=0xc0a80001 CONFIG_EXAMPLES_NETTEST_NETMASK=0xffffff00 CONFIG_EXAMPLES_NETTEST_CLIENTIP=0xc0a8006a -# CONFIG_EXAMPLES_NRF24L01TERM is not set # CONFIG_EXAMPLES_NSH is not set # CONFIG_EXAMPLES_NULL is not set # CONFIG_EXAMPLES_NX is not set @@ -748,6 +759,7 @@ CONFIG_EXAMPLES_NETTEST_CLIENTIP=0xc0a8006a # CONFIG_EXAMPLES_WATCHDOG is not set # CONFIG_EXAMPLES_WEBSERVER is not set # CONFIG_EXAMPLES_WGET is not set +# CONFIG_EXAMPLES_XBC_TEST is not set # # File System Utilities diff --git a/configs/sim/udgram/defconfig b/configs/sim/udgram/defconfig index 87e97419c1b..aacb9eb00ef 100644 --- a/configs/sim/udgram/defconfig +++ b/configs/sim/udgram/defconfig @@ -77,6 +77,7 @@ CONFIG_HOST_X86_64=y CONFIG_SIM_X8664_SYSTEMV=y # CONFIG_SIM_X8664_MICROSOFT is not set CONFIG_SIM_WALLTIME=y +CONFIG_SIM_NETDEV=y CONFIG_SIM_NET_HOST_ROUTE=y # CONFIG_SIM_NET_BRIDGE is not set # CONFIG_SIM_FRAMEBUFFER is not set @@ -210,6 +211,8 @@ CONFIG_SCHED_WAITPID=y # # CONFIG_PTHREAD_MUTEX_TYPES is not set CONFIG_PTHREAD_MUTEX_ROBUST=y +# CONFIG_PTHREAD_MUTEX_UNSAFE is not set +# CONFIG_PTHREAD_MUTEX_BOTH is not set CONFIG_NPTHREAD_KEYS=4 # CONFIG_PTHREAD_CLEANUP is not set # CONFIG_CANCELLATION_POINTS is not set @@ -380,6 +383,7 @@ CONFIG_SERIAL_CONSOLE=y # CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set +# CONFIG_USBMISC is not set # CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set # CONFIG_DRIVERS_CONTACTLESS is not set @@ -418,10 +422,12 @@ CONFIG_NET_GUARDSIZE=2 # CONFIG_NET_ETHERNET is not set # CONFIG_NET_LOOPBACK is not set # CONFIG_NET_TUN is not set +# CONFIG_NET_USRSOCK is not set # # Network Device Operations # +# CONFIG_NETDEV_IOCTL is not set # CONFIG_NETDEV_PHY_IOCTL is not set # @@ -453,11 +459,13 @@ CONFIG_NET_LOCAL_DGRAM=y # TCP/IP Networking # # CONFIG_NET_TCP is not set +# CONFIG_NET_TCP_NO_STACK is not set # # UDP Networking # # CONFIG_NET_UDP is not set +# CONFIG_NET_UDP_NO_STACK is not set # # IGMPv2 Client Support @@ -472,6 +480,10 @@ CONFIG_NET_LOCAL_DGRAM=y # Network I/O Buffer Support # # CONFIG_NET_IOB is not set + +# +# User-space networking stack API +# # CONFIG_NET_ARCH_INCR32 is not set # CONFIG_NET_ARCH_CHKSUM is not set # CONFIG_NET_STATISTICS is not set @@ -715,7 +727,6 @@ CONFIG_EXAMPLES_HELLO_STACKSIZE=2048 # CONFIG_EXAMPLES_MM is not set # CONFIG_EXAMPLES_MODBUS is not set # CONFIG_EXAMPLES_MOUNT is not set -# CONFIG_EXAMPLES_NRF24L01TERM is not set CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_NULL is not set # CONFIG_EXAMPLES_NX is not set @@ -760,6 +771,7 @@ CONFIG_EXAMPLES_UDGRAM_CLIENT_PRIORITY=100 # CONFIG_EXAMPLES_USTREAM is not set # CONFIG_EXAMPLES_WATCHDOG is not set # CONFIG_EXAMPLES_WEBSERVER is not set +# CONFIG_EXAMPLES_XBC_TEST is not set # # File System Utilities diff --git a/configs/sim/ustream/defconfig b/configs/sim/ustream/defconfig index 3b4cf6bdd29..43bb73515db 100644 --- a/configs/sim/ustream/defconfig +++ b/configs/sim/ustream/defconfig @@ -77,6 +77,7 @@ CONFIG_HOST_X86_64=y CONFIG_SIM_X8664_SYSTEMV=y # CONFIG_SIM_X8664_MICROSOFT is not set CONFIG_SIM_WALLTIME=y +CONFIG_SIM_NETDEV=y CONFIG_SIM_NET_HOST_ROUTE=y # CONFIG_SIM_NET_BRIDGE is not set # CONFIG_SIM_FRAMEBUFFER is not set @@ -210,6 +211,8 @@ CONFIG_SCHED_WAITPID=y # # CONFIG_PTHREAD_MUTEX_TYPES is not set CONFIG_PTHREAD_MUTEX_ROBUST=y +# CONFIG_PTHREAD_MUTEX_UNSAFE is not set +# CONFIG_PTHREAD_MUTEX_BOTH is not set CONFIG_NPTHREAD_KEYS=4 # CONFIG_PTHREAD_CLEANUP is not set # CONFIG_CANCELLATION_POINTS is not set @@ -380,6 +383,7 @@ CONFIG_SERIAL_CONSOLE=y # CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set +# CONFIG_USBMISC is not set # CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set # CONFIG_DRIVERS_CONTACTLESS is not set @@ -418,10 +422,12 @@ CONFIG_NET_GUARDSIZE=2 # CONFIG_NET_ETHERNET is not set # CONFIG_NET_LOOPBACK is not set # CONFIG_NET_TUN is not set +# CONFIG_NET_USRSOCK is not set # # Network Device Operations # +# CONFIG_NETDEV_IOCTL is not set # CONFIG_NETDEV_PHY_IOCTL is not set # @@ -453,11 +459,13 @@ CONFIG_NET_LOCAL_STREAM=y # TCP/IP Networking # # CONFIG_NET_TCP is not set +# CONFIG_NET_TCP_NO_STACK is not set # # UDP Networking # # CONFIG_NET_UDP is not set +# CONFIG_NET_UDP_NO_STACK is not set # # IGMPv2 Client Support @@ -472,6 +480,10 @@ CONFIG_NET_LOCAL_STREAM=y # Network I/O Buffer Support # # CONFIG_NET_IOB is not set + +# +# User-space networking stack API +# # CONFIG_NET_ARCH_INCR32 is not set # CONFIG_NET_ARCH_CHKSUM is not set # CONFIG_NET_STATISTICS is not set @@ -715,7 +727,6 @@ CONFIG_EXAMPLES_HELLO_STACKSIZE=2048 # CONFIG_EXAMPLES_MM is not set # CONFIG_EXAMPLES_MODBUS is not set # CONFIG_EXAMPLES_MOUNT is not set -# CONFIG_EXAMPLES_NRF24L01TERM is not set CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_NULL is not set # CONFIG_EXAMPLES_NX is not set @@ -755,6 +766,7 @@ CONFIG_EXAMPLES_USTREAM_ADDR="/dev/fifo" # CONFIG_EXAMPLES_USTREAM_USE_POLL is not set # CONFIG_EXAMPLES_WATCHDOG is not set # CONFIG_EXAMPLES_WEBSERVER is not set +# CONFIG_EXAMPLES_XBC_TEST is not set # # File System Utilities diff --git a/include/nuttx/net/netconfig.h b/include/nuttx/net/netconfig.h index b320e0b98f7..9bbd0e9929c 100644 --- a/include/nuttx/net/netconfig.h +++ b/include/nuttx/net/netconfig.h @@ -158,19 +158,19 @@ # endif # ifdef CONFIG_NET_SLIP -# define _MIN_SLIP_MTU MIN(_MIN_LO_MTU,CONFIG_NET_6LOWPAN_MTU) -# define _MAX_SLIP_MTU MAX(_MAX_LO_MTU,CONFIG_NET_6LOWPAN_MTU) +# define _MIN_SLIP_MTU MIN(_MIN_LO_MTU,CONFIG_NET_SLIP_MTU) +# define _MAX_SLIP_MTU MAX(_MAX_LO_MTU,CONFIG_NET_SLIP_MTU) # else # define _MIN_SLIP_MTU _MIN_LO_MTU # define _MAX_SLIP_MTU _MAX_LO_MTU # endif # ifdef CONFIG_NET_6LOWPAN -# define _MIN_6LOWPAN_MTU MIN(_MIN_LO_MTU,CONFIG_NET_SLIP_MTU) -# define _MAX_6LOWPAN_MTU MAX(_MAX_LO_MTU,CONFIG_NET_SLIP_MTU) +# define _MIN_6LOWPAN_MTU MIN(_MIN_SLIP_MTU,CONFIG_NET_6LOWPAN_MTU) +# define _MAX_6LOWPAN_MTU MAX(_MAX_SLIP_MTU,CONFIG_NET_6LOWPAN_MTU) # else -# define _MIN_6LOWPAN_MTU _MIN_LO_MTU -# define _MAX_6LOWPAN_MTU _MAX_LO_MTU +# define _MIN_6LOWPAN_MTU _MIN_SLIP_MTU +# define _MAX_6LOWPAN_MTU _MAX_SLIP_MTU # endif # define MIN_NET_DEV_MTU _MIN_6LOWPAN_MTU diff --git a/libc/netdb/lib_dnscache.c b/libc/netdb/lib_dnscache.c index 5a95dc9b1b5..30cfdcd577f 100644 --- a/libc/netdb/lib_dnscache.c +++ b/libc/netdb/lib_dnscache.c @@ -268,8 +268,8 @@ int dns_find_answer(FAR const char *hostname, FAR struct sockaddr *addr, /* We have a match. Return the resolved host address */ #ifdef CONFIG_NET_IPv4 - if (entry->addr.addr.sa_family == AF_INET) #ifdef CONFIG_NET_IPv6 + if (entry->addr.addr.sa_family == AF_INET) #endif { inlen = sizeof(struct sockaddr_in); @@ -277,8 +277,8 @@ int dns_find_answer(FAR const char *hostname, FAR struct sockaddr *addr, #endif #ifdef CONFIG_NET_IPv6 - else #ifdef CONFIG_NET_IPv4 + else #endif { inlen = sizeof(struct sockaddr_in6); diff --git a/libc/netdb/lib_dnsinit.c b/libc/netdb/lib_dnsinit.c index 04b490a1675..b6e0f8d0e03 100644 --- a/libc/netdb/lib_dnsinit.c +++ b/libc/netdb/lib_dnsinit.c @@ -39,6 +39,7 @@ #include +#include #include #include #include diff --git a/net/sixlowpan/sixlowpan_framelist.c b/net/sixlowpan/sixlowpan_framelist.c index 62582bed1c4..f206a3fe9fd 100644 --- a/net/sixlowpan/sixlowpan_framelist.c +++ b/net/sixlowpan/sixlowpan_framelist.c @@ -370,7 +370,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, /* Add the frame header */ verify = sixlowpan_framecreate(ieee, iob, ieee->i_panid); - DEBUGASSERT(vreify == framer_hdrlen); + DEBUGASSERT(verify == framer_hdrlen); UNUSED(verify); /* Move HC1/HC06/IPv6 header */ @@ -436,7 +436,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, /* Add the frame header to the prealloated IOB. */ verify = sixlowpan_framecreate(ieee, iob, ieee->i_panid); - DEBUGASSERT(vreify == framer_hdrlen); + DEBUGASSERT(verify == framer_hdrlen); UNUSED(verify); /* Copy the payload and queue */ diff --git a/net/sixlowpan/sixlowpan_send.c b/net/sixlowpan/sixlowpan_send.c index f8076449b9e..98cc577f5f5 100644 --- a/net/sixlowpan/sixlowpan_send.c +++ b/net/sixlowpan/sixlowpan_send.c @@ -40,6 +40,7 @@ #include #include +#include #include #include diff --git a/net/tcp/tcp_devpoll.c b/net/tcp/tcp_devpoll.c index 6a7f16c513b..d292d464738 100644 --- a/net/tcp/tcp_devpoll.c +++ b/net/tcp/tcp_devpoll.c @@ -46,6 +46,7 @@ #if defined(CONFIG_NET) && defined(CONFIG_NET_TCP) #include +#include #include #include diff --git a/net/tcp/tcp_timer.c b/net/tcp/tcp_timer.c index eeabb0910c4..245e849ec67 100644 --- a/net/tcp/tcp_timer.c +++ b/net/tcp/tcp_timer.c @@ -46,6 +46,7 @@ #if defined(CONFIG_NET) && defined(CONFIG_NET_TCP) #include +#include #include #include