From ce3a2dc0d4237a1f09c9819bf749ce16232e666c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 24 Aug 2015 13:59:52 -0600 Subject: [PATCH] NSH changes to work with the network local loopback device --- nshlib/nsh.h | 3 ++- nshlib/nsh_netcmds.c | 9 +++++++++ nshlib/nsh_netinit.c | 17 ++++++++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/nshlib/nsh.h b/nshlib/nsh.h index e87177eb4..895b1e228 100644 --- a/nshlib/nsh.h +++ b/nshlib/nsh.h @@ -155,7 +155,8 @@ * domain sockets were enable. */ -#if !defined(CONFIG_NET_ETHERNET) && !defined(CONFIG_NET_SLIP) && !defined(CONFIG_NET_TUN) +#if !defined(CONFIG_NET_ETHERNET) && !defined(CONFIG_NET_LOOPBACK) && \ + !defined(CONFIG_NET_SLIP) && !defined(CONFIG_NET_TUN) /* No link layer protocol is a good indication that there is no network * device. */ diff --git a/nshlib/nsh_netcmds.c b/nshlib/nsh_netcmds.c index 39be39e65..ce4c6a42e 100644 --- a/nshlib/nsh_netcmds.c +++ b/nshlib/nsh_netcmds.c @@ -515,6 +515,12 @@ static int ifconfig_callback(FAR struct net_driver_s *dev, void *arg) break; # endif +# if defined(CONFIG_NET_LOOPBACK) + case NET_LL_LOOPBACK: + nsh_output(vtbl, "%s\tLink encap:Local Loopback\n", dev->d_ifname); + break; +# endif + # if defined(CONFIG_NET_SLIP) case NET_LL_SLIP: nsh_output(vtbl, "%s\tLink encap:SLIP", dev->d_ifname); @@ -543,6 +549,9 @@ static int ifconfig_callback(FAR struct net_driver_s *dev, void *arg) nsh_output(vtbl, "%s\tLink encap:Ethernet HWaddr %s at %s\n", dev->d_ifname, ether_ntoa(&dev->d_mac), status); +#elif defined(CONFIG_NET_LOOPBACK) + nsh_output(vtbl, "%s\tLink encap:Local Loopback\n", dev->d_ifname); + #elif defined(CONFIG_NET_SLIP) nsh_output(vtbl, "%s\tLink encap:SLIP at %s\n", dev->d_ifname, status); diff --git a/nshlib/nsh_netinit.c b/nshlib/nsh_netinit.c index 393997e33..38e20aeb2 100644 --- a/nshlib/nsh_netinit.c +++ b/nshlib/nsh_netinit.c @@ -103,19 +103,32 @@ #if defined(CONFIG_NET_ETHERNET) # define NET_DEVNAME "eth0" +# define NSH_HAVE_NETDEV #elif defined(CONFIG_NET_SLIP) # define NET_DEVNAME "sl0" # ifndef CONFIG_NSH_NOMAC # error "CONFIG_NSH_NOMAC must be defined for SLIP" # endif +# define NSH_HAVE_NETDEV #elif defined(CONFIG_NET_TUN) # define NET_DEVNAME "tun0" +# define NSH_HAVE_NETDEV #elif defined(CONFIG_NET_LOCAL) # define NET_DEVNAME "lo" -#else +# define NSH_HAVE_NETDEV +#elif !defined(CONFIG_NET_LOOPBACK) # error ERROR: No link layer protocol defined #endif +/* If we have no network device (only only the local loopback device), then we + * cannot support the network monitor. + */ + +#ifndef NSH_HAVE_NETDEV +# undef CONFIG_NSH_NETINIT_MONITOR +#endif + + /* We need a valid IP domain (any domain) to create a socket that we can use * to comunicate with the network device. */ @@ -208,6 +221,7 @@ static const uint16_t g_ipv6_netmask[8] = static void nsh_netinit_configure(void) { +#ifdef NSH_HAVE_NETDEV #ifdef CONFIG_NET_IPv4 struct in_addr addr; #endif @@ -328,6 +342,7 @@ static void nsh_netinit_configure(void) dhcpc_close(handle); } #endif +#endif /* NSH_HAVE_NETDEV */ nvdbg("Exit\n"); }