diff --git a/Documentation b/Documentation index ce750c0899c..cae6e67e053 160000 --- a/Documentation +++ b/Documentation @@ -1 +1 @@ -Subproject commit ce750c0899c2138b37b52a48d020a3eceb92fd04 +Subproject commit cae6e67e0534485cd42119346a2e0121d6652965 diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 32c87c7e0c7..370b35cc5d3 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -5,12 +5,21 @@ comment "General Ethernet MAC Driver Options" -config NETDEV_MULTINIC - bool "Multiple network interface support" +config NETDEV_LOOPBACK + bool "Local loopback support" default n + ---help--- + Add support for the local network loopback device, lo. + +config NETDEV_MULTINIC + bool "Multiple network interface support" + default n if !NETDEV_LOOPBACK + default y if NETDEV_LOOPBACK ---help--- Select this option if you board and/or MCU are capable of supporting - multiple Ethernet MAC drivers. + multiple link layer drivers. NOTE that the local loopback device + is considered to be a a link layer driver so if local loopback + support is used you probably need to select this option. config NETDEV_LATEINIT bool "Late driver initialization" diff --git a/include/nuttx/net/net.h b/include/nuttx/net/net.h index 77c7fd807ab..b10787f171e 100644 --- a/include/nuttx/net/net.h +++ b/include/nuttx/net/net.h @@ -76,6 +76,7 @@ enum net_lltype_e { NET_LL_ETHERNET = 0, /* Ethernet */ + NET_LL_LOOPBACK, /* Local loopback */ NET_LL_SLIP, /* Serial Line Internet Protocol (SLIP) */ NET_LL_PPP, /* Point-to-Point Protocol (PPP) */ NET_LL_TUN, /* TUN Virtual Network Device */ diff --git a/include/nuttx/net/netconfig.h b/include/nuttx/net/netconfig.h index aeea16b4e17..8825c50981c 100644 --- a/include/nuttx/net/netconfig.h +++ b/include/nuttx/net/netconfig.h @@ -157,7 +157,7 @@ # define MAX_NET_DEV_MTU CONFIG_NET_ETH_MTU #else - /* Perhaps only Unix domain sockets */ + /* Perhaps only Unix domain sockets of the loopback device */ # define NET_LL_HDRLEN(d) 0 # define NET_DEV_MTU(d) 0 @@ -166,6 +166,10 @@ #endif /* MULTILINK or SLIP or ETHERNET */ +/* For the loopback device, we will use the largest representable MTU */ + +#define NET_LO_MTU UINT16_MAX + /* Layer 3/4 Configuration Options ******************************************/ /* IP configuration options */ @@ -346,6 +350,7 @@ */ #define TCP_MSS(d,h) (NET_DEV_MTU(d) - NET_LL_HDRLEN(d) - TCP_HDRLEN - (h)) +#define LO_TCP_MSS(h) (NET_LO_MTU - (h)) /* If Ethernet is supported, then it will have the smaller MSS */ @@ -402,15 +407,17 @@ * See the note above regarding the TCP MSS and CONFIG_NET_MULTILINK. */ +#define NET_LO_TCP_RECVWNDO LO_TCP_MSS(0) + #ifdef CONFIG_NET_SLIP # ifndef CONFIG_NET_SLIP_TCP_RECVWNDO -# define CONFIG_NET_SLIP_TCP_RECVWNDO SLIP_TCP_MSS +# define CONFIG_NET_SLIP_TCP_RECVWNDO SLIP_TCP_MSS(0) # endif #endif #ifdef CONFIG_NET_ETHERNET # ifndef CONFIG_NET_ETH_TCP_RECVWNDO -# define CONFIG_NET_ETH_TCP_RECVWNDO ETH_TCP_MSS +# define CONFIG_NET_ETH_TCP_RECVWNDO ETH_TCP_MSS(0) # endif #endif diff --git a/net/netdev/netdev_register.c b/net/netdev/netdev_register.c index 524f6cb2d4b..e46ce2afc96 100644 --- a/net/netdev/netdev_register.c +++ b/net/netdev/netdev_register.c @@ -61,8 +61,9 @@ * Pre-processor Definitions ****************************************************************************/ -#define NETDEV_SLIP_FORMAT "sl%d" #define NETDEV_ETH_FORMAT "eth%d" +#define NETDEV_LO_FORMAT "lo" +#define NETDEV_SLIP_FORMAT "sl%d" #define NETDEV_TUN_FORMAT "tun%d" #if defined(CONFIG_NET_SLIP) @@ -190,6 +191,17 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype) switch (lltype) { +#ifdef CONFIG_NETDEV_LOOPBACK + case NET_LL_LOOPBACK: /* Local loopback */ + dev->d_llhdrlen = 0; + dev->d_mtu = NET_LO_MTU; +#ifdef CONFIG_NET_TCP + dev->d_recvwndo = NET_LO_TCP_RECVWNDO; +#endif + devfmt = NETDEV_LO_FORMAT; + break; +#endif + #ifdef CONFIG_NET_ETHERNET case NET_LL_ETHERNET: /* Ethernet */ dev->d_llhdrlen = ETH_HDRLEN;