diff --git a/Documentation/NuttShell.html b/Documentation/NuttShell.html
index 7414b5bbdf4..36335e873e0 100644
--- a/Documentation/NuttShell.html
+++ b/Documentation/NuttShell.html
@@ -3522,7 +3522,7 @@ nsh>
ping |
CONFIG_NET && CONFIG_NET_ICMP &&
- CONFIG_NET_ICMP_PING && !CONFIG_DISABLE_SIGNALS |
+ CONFIG_NET_ICMP_SOCKET && !CONFIG_DISABLE_SIGNALS
CONFIG_NSH_DISABLE_PING |
diff --git a/TODO b/TODO
index 46c18a49228..4665a9d2445 100644
--- a/TODO
+++ b/TODO
@@ -646,7 +646,7 @@ o Kernel/Protected Build
COMMAND KERNEL INTERFACE(s)
-------- ----------------------------------------------
mkrd ramdisk_register()
- ping icmp_ping()
+ ping6 icmpv6_ping()
mount foreach_mountpoint()
Status: Open
diff --git a/configs/bambino-200e/netnsh/defconfig b/configs/bambino-200e/netnsh/defconfig
index 98369779c20..acd02093269 100644
--- a/configs/bambino-200e/netnsh/defconfig
+++ b/configs/bambino-200e/netnsh/defconfig
@@ -36,7 +36,7 @@ CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_MTU=650
CONFIG_NET_ETH_TCP_RECVWNDO=624
CONFIG_NET_HOSTNAME="Bambino-200E"
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -81,6 +81,7 @@ CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=11
CONFIG_START_MONTH=7
CONFIG_START_YEAR=2012
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART1_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
diff --git a/configs/cloudctrl/nsh/defconfig b/configs/cloudctrl/nsh/defconfig
index 5c7b5cb4b3a..93b89a8470e 100644
--- a/configs/cloudctrl/nsh/defconfig
+++ b/configs/cloudctrl/nsh/defconfig
@@ -23,7 +23,7 @@ CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MMCSD_SPICLOCK=12500000
CONFIG_MMCSD=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -76,6 +76,7 @@ CONFIG_STM32_PWR=y
CONFIG_STM32_SPI1=y
CONFIG_STM32_USART2_REMAP=y
CONFIG_STM32_USART2=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART2_RXBUFSIZE=128
CONFIG_USART2_SERIAL_CONSOLE=y
diff --git a/configs/dk-tm4c129x/README.txt b/configs/dk-tm4c129x/README.txt
index 793f00a4589..b0c0ac557f7 100644
--- a/configs/dk-tm4c129x/README.txt
+++ b/configs/dk-tm4c129x/README.txt
@@ -241,7 +241,7 @@ Networking Support
CONFIG_NET_UDP=y : Enable UDP networking
CONFIG_NET_BROADCAST=y : Needed for DNS name resolution
CONFIG_NET_ICMP=y : Enable ICMP networking
- CONFIG_NET_ICMP_PING=y : Needed for NSH ping command
+ CONFIG_NET_ICMP_SOCKET=y : Needed for NSH ping command
: Defaults should be okay for other options
f Application Configuration -> Network Utilities
CONFIG_NETDB_DNSCLIENT=y : Enable host address resolution
@@ -768,7 +768,7 @@ Where is one of the following:
CONFIG_NET_ARP=y
CONFIG_NET_ARP_SEND=y (optional)
CONFIG_NET_ICMP=y
- CONFIG_NET_ICMP_PING=y
+ CONFIG_NET_ICMP_SOCKET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETUTILS_TELNETD=y
diff --git a/configs/dk-tm4c129x/nsh/defconfig b/configs/dk-tm4c129x/nsh/defconfig
index 47f8e7303b6..5e4e3b67fa4 100644
--- a/configs/dk-tm4c129x/nsh/defconfig
+++ b/configs/dk-tm4c129x/nsh/defconfig
@@ -14,20 +14,18 @@ CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y
CONFIG_BOARD_LOOPSPERMSEC=11401
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_EXAMPLES_NSH=y
CONFIG_HOST_WINDOWS=y
CONFIG_I2CTOOL_MAXBUS=6
CONFIG_I2CTOOL_MINBUS=6
CONFIG_LIBC_FLOATINGPOINT=y
CONFIG_LIBM=y
-CONFIG_SENSORS_LM75=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_NET_ARP_IPIN=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_SOLINGER=y
@@ -60,12 +58,14 @@ CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
+CONFIG_SENSORS_LM75=y
CONFIG_SENSORS=y
CONFIG_START_DAY=24
CONFIG_START_MONTH=3
CONFIG_START_YEAR=2013
CONFIG_SYSTEM_I2CTOOL=y
CONFIG_SYSTEM_LM75=y
+CONFIG_SYSTEM_PING=y
CONFIG_TIVA_BOARDMAC=y
CONFIG_TIVA_ETHERNET=y
CONFIG_TIVA_GPIOP_IRQS=y
diff --git a/configs/eagle100/nsh/defconfig b/configs/eagle100/nsh/defconfig
index 63b8568acbe..ef4b92bbb8a 100644
--- a/configs/eagle100/nsh/defconfig
+++ b/configs/eagle100/nsh/defconfig
@@ -9,7 +9,6 @@ CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_DEVKITARM=y
CONFIG_BOARD_LOOPSPERMSEC=4531
-CONFIG_DISABLE_POLL=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FS_FAT=y
CONFIG_HOST_WINDOWS=y
@@ -18,7 +17,7 @@ CONFIG_MAX_WDOGPARMS=2
CONFIG_MMCSD_SPICLOCK=12500000
CONFIG_MMCSD=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
@@ -52,6 +51,7 @@ CONFIG_SPI=y
CONFIG_START_DAY=13
CONFIG_START_MONTH=2
CONFIG_START_YEAR=2012
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_TIVA_BOARDMAC=y
CONFIG_TIVA_ETHERNET=y
diff --git a/configs/ekk-lm3s9b96/nsh/defconfig b/configs/ekk-lm3s9b96/nsh/defconfig
index 8f911ba9eaa..ed2bd479b1f 100644
--- a/configs/ekk-lm3s9b96/nsh/defconfig
+++ b/configs/ekk-lm3s9b96/nsh/defconfig
@@ -10,14 +10,13 @@ CONFIG_ARCH="arm"
CONFIG_ARMV7M_OABI_TOOLCHAIN=y
CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y
CONFIG_BOARD_LOOPSPERMSEC=4531
-CONFIG_DISABLE_POLL=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FS_FAT=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MMCSD_NSLOTS=0
CONFIG_MMCSD=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
@@ -53,6 +52,7 @@ CONFIG_SPI=y
CONFIG_START_DAY=8
CONFIG_START_MONTH=5
CONFIG_START_YEAR=2010
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_TIVA_ETHERNET=y
CONFIG_TIVA_GPIOA_IRQS=y
diff --git a/configs/ez80f910200zco/nsh/defconfig b/configs/ez80f910200zco/nsh/defconfig
index ba55ba7625d..8bbd7bc6d37 100644
--- a/configs/ez80f910200zco/nsh/defconfig
+++ b/configs/ez80f910200zco/nsh/defconfig
@@ -9,7 +9,6 @@ CONFIG_ARCH_Z80=y
CONFIG_ARCH="z80"
CONFIG_BOARD_LOOPSPERMSEC=1250
CONFIG_DISABLE_MQUEUE=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_AM79C874=y
CONFIG_EXAMPLES_NSH=y
CONFIG_EZ80_EMAC=y
@@ -20,7 +19,7 @@ CONFIG_HOST_WINDOWS=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
@@ -51,6 +50,7 @@ CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=14
CONFIG_START_MONTH=3
CONFIG_START_YEAR=2009
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART0_BAUD=57600
CONFIG_UART0_BITS=0
diff --git a/configs/fire-stm32v2/nsh/defconfig b/configs/fire-stm32v2/nsh/defconfig
index 39acf1d11ca..122c67c5f28 100644
--- a/configs/fire-stm32v2/nsh/defconfig
+++ b/configs/fire-stm32v2/nsh/defconfig
@@ -12,7 +12,6 @@ CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y
CONFIG_BOARD_LOOPSPERMSEC=5483
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_ENC28J60=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FAT_LCNAMES=y
@@ -30,7 +29,7 @@ CONFIG_MAX_WDOGPARMS=2
CONFIG_MMCSD_SDIO=y
CONFIG_MMCSD=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=16
CONFIG_NET_SOCKOPTS=y
@@ -77,6 +76,7 @@ CONFIG_STM32_USART1=y
CONFIG_STM32_USART2=y
CONFIG_STM32_USB=y
CONFIG_SYSTEM_I2CTOOL=y
+CONFIG_SYSTEM_PING=y
CONFIG_SYSTEM_USBMSC=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART1_SERIAL_CONSOLE=y
diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt
index c7c01a494d7..906c8a4a6c9 100644
--- a/configs/freedom-k64f/README.txt
+++ b/configs/freedom-k64f/README.txt
@@ -209,7 +209,7 @@ Networking Support
CONFIG_NET_UDP=y : Enable UDP networking
CONFIG_NET_BROADCAST=y : Needed for DNS name resolution
CONFIG_NET_ICMP=y : Enable ICMP networking
- CONFIG_NET_ICMP_PING=y : Needed for NSH ping command
+ CONFIG_NET_ICMP_SOCKET=y : Needed for NSH ping command
: Defaults should be okay for other options
f Application Configuration -> Network Utilities
CONFIG_NETDB_DNSCLIENT=y : Enable host address resolution
diff --git a/configs/freedom-k64f/netnsh/defconfig b/configs/freedom-k64f/netnsh/defconfig
index 5191429e104..a0e85043822 100644
--- a/configs/freedom-k64f/netnsh/defconfig
+++ b/configs/freedom-k64f/netnsh/defconfig
@@ -9,7 +9,6 @@ CONFIG_BOARD_LOOPSPERMSEC=10016
CONFIG_BUILTIN=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_KSZ8081=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FS_FAT=y
@@ -26,7 +25,7 @@ CONFIG_MOTOROLA_SREC=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_HOSTNAME="Freedom-K64F"
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
@@ -62,6 +61,7 @@ CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=25
CONFIG_START_MONTH=3
CONFIG_START_YEAR=2013
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART3_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
diff --git a/configs/freedom-k66f/README.txt b/configs/freedom-k66f/README.txt
index 9d1d1b0ecb0..b1283e8dc9f 100644
--- a/configs/freedom-k66f/README.txt
+++ b/configs/freedom-k66f/README.txt
@@ -212,7 +212,7 @@ Networking Support
CONFIG_NET_UDP=y : Enable UDP networking
CONFIG_NET_BROADCAST=y : Needed for DNS name resolution
CONFIG_NET_ICMP=y : Enable ICMP networking
- CONFIG_NET_ICMP_PING=y : Needed for NSH ping command
+ CONFIG_NET_ICMP_SOCKET=y : Needed for NSH ping command
: Defaults should be okay for other options
Application Configuration -> Network Utilities
CONFIG_NETDB_DNSCLIENT=y : Enable host address resolution
diff --git a/configs/freedom-k66f/netnsh/defconfig b/configs/freedom-k66f/netnsh/defconfig
index a6bfd92d6a2..8c90e1a4fb5 100644
--- a/configs/freedom-k66f/netnsh/defconfig
+++ b/configs/freedom-k66f/netnsh/defconfig
@@ -15,7 +15,6 @@ CONFIG_BOARDCTL_UNIQUEID=y
CONFIG_BUILTIN=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_KSZ8081=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FS_FAT=y
@@ -35,7 +34,7 @@ CONFIG_MAX_WDOGPARMS=2
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_HOSTNAME="Freedom-K66F"
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
@@ -77,6 +76,7 @@ CONFIG_STACK_COLORATION=y
CONFIG_START_DAY=30
CONFIG_START_MONTH=11
CONFIG_START_YEAR=2016
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=32
CONFIG_UART1_BAUD=57600
CONFIG_UART1_SERIAL_CONSOLE=y
diff --git a/configs/lincoln60/netnsh/defconfig b/configs/lincoln60/netnsh/defconfig
index 5cbb3cfdb85..2b2fdec1368 100644
--- a/configs/lincoln60/netnsh/defconfig
+++ b/configs/lincoln60/netnsh/defconfig
@@ -9,7 +9,6 @@ CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y
CONFIG_BOARD_LOOPSPERMSEC=7982
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_KSZ8041=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FS_FAT=y
@@ -23,7 +22,7 @@ CONFIG_MM_REGIONS=2
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_EMACRAM_SIZE=7296
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_NRXDESC=6
@@ -62,6 +61,7 @@ CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=20
CONFIG_START_MONTH=6
CONFIG_START_YEAR=2010
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
diff --git a/configs/lincoln60/thttpd-binfs/defconfig b/configs/lincoln60/thttpd-binfs/defconfig
index f974e947b8c..d0ee453db68 100644
--- a/configs/lincoln60/thttpd-binfs/defconfig
+++ b/configs/lincoln60/thttpd-binfs/defconfig
@@ -28,7 +28,7 @@ CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=2
CONFIG_NET_ARP_SEND=y
CONFIG_NET_EMACRAM_SIZE=9696
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_NACTIVESOCKETS=12
@@ -58,6 +58,7 @@ CONFIG_START_DAY=6
CONFIG_START_MONTH=6
CONFIG_START_YEAR=2015
CONFIG_SYMTAB_ORDEREDBYNAME=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=1536
CONFIG_THTTPD_CGI_BYTECOUNT=20000
diff --git a/configs/lm3s6432-s2e/nsh/defconfig b/configs/lm3s6432-s2e/nsh/defconfig
index 32a783bcfc8..38b224208bd 100644
--- a/configs/lm3s6432-s2e/nsh/defconfig
+++ b/configs/lm3s6432-s2e/nsh/defconfig
@@ -10,12 +10,11 @@ CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL=y
CONFIG_BOARD_LOOPSPERMSEC=4531
-CONFIG_DISABLE_POLL=y
CONFIG_EXAMPLES_NSH=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
@@ -48,6 +47,7 @@ CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=8
CONFIG_START_MONTH=5
CONFIG_START_YEAR=2010
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_TIVA_BOARDMAC=y
CONFIG_TIVA_ETHERNET=y
diff --git a/configs/lm3s6965-ek/discover/defconfig b/configs/lm3s6965-ek/discover/defconfig
index 417b42f50e7..9bf48a9b415 100644
--- a/configs/lm3s6965-ek/discover/defconfig
+++ b/configs/lm3s6965-ek/discover/defconfig
@@ -10,7 +10,6 @@ CONFIG_ARCH="arm"
CONFIG_ARMV7M_OABI_TOOLCHAIN=y
CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y
CONFIG_BOARD_LOOPSPERMSEC=4531
-CONFIG_DISABLE_POLL=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FS_FAT=y
CONFIG_MAX_TASKS=16
@@ -18,7 +17,7 @@ CONFIG_MAX_WDOGPARMS=2
CONFIG_MMCSD_SPICLOCK=12500000
CONFIG_MMCSD=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
@@ -54,6 +53,7 @@ CONFIG_SPI=y
CONFIG_START_DAY=8
CONFIG_START_MONTH=5
CONFIG_START_YEAR=2010
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_TIVA_ETHERNET=y
CONFIG_TIVA_GPIOA_IRQS=y
diff --git a/configs/lm3s6965-ek/nsh/defconfig b/configs/lm3s6965-ek/nsh/defconfig
index 417b42f50e7..9bf48a9b415 100644
--- a/configs/lm3s6965-ek/nsh/defconfig
+++ b/configs/lm3s6965-ek/nsh/defconfig
@@ -10,7 +10,6 @@ CONFIG_ARCH="arm"
CONFIG_ARMV7M_OABI_TOOLCHAIN=y
CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y
CONFIG_BOARD_LOOPSPERMSEC=4531
-CONFIG_DISABLE_POLL=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FS_FAT=y
CONFIG_MAX_TASKS=16
@@ -18,7 +17,7 @@ CONFIG_MAX_WDOGPARMS=2
CONFIG_MMCSD_SPICLOCK=12500000
CONFIG_MMCSD=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
@@ -54,6 +53,7 @@ CONFIG_SPI=y
CONFIG_START_DAY=8
CONFIG_START_MONTH=5
CONFIG_START_YEAR=2010
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_TIVA_ETHERNET=y
CONFIG_TIVA_GPIOA_IRQS=y
diff --git a/configs/lm3s6965-ek/tcpecho/defconfig b/configs/lm3s6965-ek/tcpecho/defconfig
index 1c79fd0495b..1ba2dbc4ab7 100644
--- a/configs/lm3s6965-ek/tcpecho/defconfig
+++ b/configs/lm3s6965-ek/tcpecho/defconfig
@@ -18,7 +18,7 @@ CONFIG_MAX_WDOGPARMS=2
CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_MTU=650
CONFIG_NET_ETH_TCP_RECVWNDO=624
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
@@ -51,6 +51,7 @@ CONFIG_SCHED_HPWORK=y
CONFIG_START_DAY=8
CONFIG_START_MONTH=5
CONFIG_START_YEAR=2010
+CONFIG_SYSTEM_PING=y
CONFIG_SYSTEM_READLINE=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_TIVA_ETHERNET=y
diff --git a/configs/lm3s8962-ek/nsh/defconfig b/configs/lm3s8962-ek/nsh/defconfig
index 79d79b79393..bc5b390fbdd 100644
--- a/configs/lm3s8962-ek/nsh/defconfig
+++ b/configs/lm3s8962-ek/nsh/defconfig
@@ -9,7 +9,6 @@ CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y
CONFIG_BOARD_LOOPSPERMSEC=4531
-CONFIG_DISABLE_POLL=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FS_FAT=y
CONFIG_HOST_WINDOWS=y
@@ -18,7 +17,7 @@ CONFIG_MAX_WDOGPARMS=2
CONFIG_MMCSD_SPICLOCK=12500000
CONFIG_MMCSD=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
@@ -53,6 +52,7 @@ CONFIG_SPI=y
CONFIG_START_DAY=8
CONFIG_START_MONTH=5
CONFIG_START_YEAR=2010
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_TIVA_ETHERNET=y
CONFIG_TIVA_GPIOA_IRQS=y
diff --git a/configs/lpcxpresso-lpc1768/nsh/defconfig b/configs/lpcxpresso-lpc1768/nsh/defconfig
index da71ea8f200..339716342e0 100644
--- a/configs/lpcxpresso-lpc1768/nsh/defconfig
+++ b/configs/lpcxpresso-lpc1768/nsh/defconfig
@@ -12,7 +12,6 @@ CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_CODEREDL=y
CONFIG_BOARD_LOOPSPERMSEC=8079
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_LAN8720=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FS_FAT=y
@@ -27,7 +26,7 @@ CONFIG_MMCSD=y
CONFIG_MTD=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_EMACRAM_SIZE=7296
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_NRXDESC=6
@@ -65,6 +64,7 @@ CONFIG_SPI=y
CONFIG_START_DAY=12
CONFIG_START_MONTH=4
CONFIG_START_YEAR=2011
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART3_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
diff --git a/configs/misoc/hello/defconfig b/configs/misoc/hello/defconfig
index 0a92468dd81..44cc768f1ff 100644
--- a/configs/misoc/hello/defconfig
+++ b/configs/misoc/hello/defconfig
@@ -41,7 +41,7 @@ CONFIG_NET_ETH_MTU=1400
CONFIG_NET_ETH_TCP_RECVWNDO=742
CONFIG_NET_GUARDSIZE=648
CONFIG_NET_HOSTNAME="nuttx"
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -81,3 +81,4 @@ CONFIG_TASK_NAME_SIZE=0
CONFIG_UART1_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WDOG_INTRESERVE=1
+CONFIG_SYSTEM_PING=y
diff --git a/configs/moxa/nsh/defconfig b/configs/moxa/nsh/defconfig
index f867151e44d..c4e28c4da6b 100644
--- a/configs/moxa/nsh/defconfig
+++ b/configs/moxa/nsh/defconfig
@@ -60,7 +60,7 @@ CONFIG_NET_ARP_SEND=y
CONFIG_NET_ETH_MTU=1500
CONFIG_NET_ETH_TCP_RECVWNDO=1536
CONFIG_NET_FTMAC100=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_ROUTE=y
CONFIG_NET_SOCKOPTS=y
@@ -91,6 +91,7 @@ CONFIG_STANDARD_SERIAL=y
CONFIG_START_DAY=28
CONFIG_START_MONTH=6
CONFIG_START_YEAR=2013
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WDOG_INTRESERVE=0
diff --git a/configs/ntosd-dm320/nsh/defconfig b/configs/ntosd-dm320/nsh/defconfig
index 43e95ced47b..1b09038c09e 100644
--- a/configs/ntosd-dm320/nsh/defconfig
+++ b/configs/ntosd-dm320/nsh/defconfig
@@ -9,7 +9,6 @@ CONFIG_ARM_TOOLCHAIN_CODESOURCERYL=y
CONFIG_BOARD_LOOPSPERMSEC=16945
CONFIG_BOOT_RUNFROMSDRAM=y
CONFIG_DISABLE_MQUEUE=y
-CONFIG_DISABLE_POLL=y
CONFIG_DM9X_BASE=0xd0000300
CONFIG_DM9X_IRQ=27
CONFIG_EXAMPLES_NSH=y
@@ -20,7 +19,7 @@ CONFIG_MAX_TASKS=64
CONFIG_MMCSD=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_DM90x0=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
@@ -49,6 +48,7 @@ CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=12
CONFIG_START_MONTH=9
CONFIG_START_YEAR=2008
+CONFIG_SYSTEM_PING=y
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_USERMAIN_STACKSIZE=4096
diff --git a/configs/olimex-lpc1766stk/ftpc/defconfig b/configs/olimex-lpc1766stk/ftpc/defconfig
index fdd32f5da8e..035e02cb610 100644
--- a/configs/olimex-lpc1766stk/ftpc/defconfig
+++ b/configs/olimex-lpc1766stk/ftpc/defconfig
@@ -29,7 +29,7 @@ CONFIG_MMCSD=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_EMACRAM_SIZE=8512
CONFIG_NET_ETH_TCP_RECVWNDO=550
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_NRXDESC=7
@@ -71,6 +71,7 @@ CONFIG_START_DAY=2
CONFIG_START_MONTH=6
CONFIG_START_YEAR=2011
CONFIG_SYMTAB_ORDEREDBYNAME=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART0_BAUD=57600
CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/configs/olimex-lpc1766stk/hidmouse/defconfig b/configs/olimex-lpc1766stk/hidmouse/defconfig
index 4533a7ee149..6628a1b10c8 100644
--- a/configs/olimex-lpc1766stk/hidmouse/defconfig
+++ b/configs/olimex-lpc1766stk/hidmouse/defconfig
@@ -13,7 +13,6 @@ CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y
CONFIG_BOARD_LOOPSPERMSEC=8111
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_EXAMPLES_NSH=y
CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH="/dev/mouse0"
CONFIG_EXAMPLES_TOUCHSCREEN_MOUSE=y
@@ -29,7 +28,7 @@ CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=2
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
@@ -67,6 +66,7 @@ CONFIG_START_DAY=30
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_SYMTAB_ORDEREDBYNAME=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART0_BAUD=57600
CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/configs/olimex-lpc1766stk/nsh/defconfig b/configs/olimex-lpc1766stk/nsh/defconfig
index db7d415599a..f1fd8616a82 100644
--- a/configs/olimex-lpc1766stk/nsh/defconfig
+++ b/configs/olimex-lpc1766stk/nsh/defconfig
@@ -16,7 +16,6 @@ CONFIG_ARMV7M_OABI_TOOLCHAIN=y
CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y
CONFIG_BOARD_LOOPSPERMSEC=8111
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_KS8721=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FAT_LCNAMES=y
@@ -34,7 +33,7 @@ CONFIG_MMCSD_SPICLOCK=12500000
CONFIG_MMCSD=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_EMACRAM_SIZE=7296
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_NRXDESC=6
@@ -76,6 +75,7 @@ CONFIG_START_DAY=30
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_SYMTAB_ORDEREDBYNAME=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART0_BAUD=57600
CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/configs/olimex-lpc1766stk/zmodem/defconfig b/configs/olimex-lpc1766stk/zmodem/defconfig
index bdbf6efefb5..86becd2f58f 100644
--- a/configs/olimex-lpc1766stk/zmodem/defconfig
+++ b/configs/olimex-lpc1766stk/zmodem/defconfig
@@ -15,7 +15,6 @@ CONFIG_ARMV7M_OABI_TOOLCHAIN=y
CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y
CONFIG_BOARD_LOOPSPERMSEC=8111
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_KS8721=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FAT_LCNAMES=y
@@ -32,7 +31,7 @@ CONFIG_MM_REGIONS=2
CONFIG_MMCSD_SPICLOCK=12500000
CONFIG_MMCSD=y
CONFIG_NET_EMACRAM_SIZE=7296
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_NRXDESC=6
@@ -73,6 +72,7 @@ CONFIG_START_DAY=30
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_SYMTAB_ORDEREDBYNAME=y
+CONFIG_SYSTEM_PING=y
CONFIG_SYSTEM_ZMODEM_DEVNAME="/dev/ttyS1"
CONFIG_SYSTEM_ZMODEM_MOUNTPOINT="/mnt/sdcard"
CONFIG_SYSTEM_ZMODEM_PKTBUFSIZE=1024
diff --git a/configs/olimex-stm32-e407/discover/defconfig b/configs/olimex-stm32-e407/discover/defconfig
index c519314ffc7..a512bc2b2c2 100644
--- a/configs/olimex-stm32-e407/discover/defconfig
+++ b/configs/olimex-stm32-e407/discover/defconfig
@@ -24,7 +24,7 @@ CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=2
CONFIG_NET_ARP_IPIN=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -67,6 +67,7 @@ CONFIG_STM32_PHYSR=31
CONFIG_STM32_PWR=y
CONFIG_STM32_RMII_EXTCLK=y
CONFIG_STM32_USART2=y
+CONFIG_SYSTEM_PING=y
CONFIG_USART2_RXBUFSIZE=128
CONFIG_USART2_SERIAL_CONSOLE=y
CONFIG_USART2_TXBUFSIZE=128
diff --git a/configs/olimex-stm32-e407/netnsh/defconfig b/configs/olimex-stm32-e407/netnsh/defconfig
index ea73fdf4e9d..38336bf89dd 100644
--- a/configs/olimex-stm32-e407/netnsh/defconfig
+++ b/configs/olimex-stm32-e407/netnsh/defconfig
@@ -22,7 +22,7 @@ CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=2
CONFIG_NET_ARP_IPIN=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -73,6 +73,7 @@ CONFIG_STM32_PHYSR=31
CONFIG_STM32_PWR=y
CONFIG_STM32_RMII_EXTCLK=y
CONFIG_STM32_USART2=y
+CONFIG_SYSTEM_PING=y
CONFIG_USART2_RXBUFSIZE=128
CONFIG_USART2_SERIAL_CONSOLE=y
CONFIG_USART2_TXBUFSIZE=128
diff --git a/configs/olimex-stm32-e407/telnetd/defconfig b/configs/olimex-stm32-e407/telnetd/defconfig
index fa001d1c72b..3e601c2eef6 100644
--- a/configs/olimex-stm32-e407/telnetd/defconfig
+++ b/configs/olimex-stm32-e407/telnetd/defconfig
@@ -26,7 +26,7 @@ CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=2
CONFIG_NET_ARP_IPIN=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -73,6 +73,7 @@ CONFIG_STM32_PHYSR=31
CONFIG_STM32_PWR=y
CONFIG_STM32_RMII_EXTCLK=y
CONFIG_STM32_USART2=y
+CONFIG_SYSTEM_PING=y
CONFIG_USART2_RXBUFSIZE=128
CONFIG_USART2_SERIAL_CONSOLE=y
CONFIG_USART2_TXBUFSIZE=128
diff --git a/configs/olimex-stm32-e407/webserver/defconfig b/configs/olimex-stm32-e407/webserver/defconfig
index 81c77faa597..3621a7caf36 100644
--- a/configs/olimex-stm32-e407/webserver/defconfig
+++ b/configs/olimex-stm32-e407/webserver/defconfig
@@ -22,7 +22,7 @@ CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=2
CONFIG_NET_ARP_IPIN=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -69,6 +69,7 @@ CONFIG_STM32_PHYSR=31
CONFIG_STM32_PWR=y
CONFIG_STM32_RMII_EXTCLK=y
CONFIG_STM32_USART2=y
+CONFIG_SYSTEM_PING=y
CONFIG_USART2_RXBUFSIZE=128
CONFIG_USART2_SERIAL_CONSOLE=y
CONFIG_USART2_TXBUFSIZE=128
diff --git a/configs/olimex-stm32-p107/nsh/defconfig b/configs/olimex-stm32-p107/nsh/defconfig
index 5d0898e3874..e8e8b2e151b 100644
--- a/configs/olimex-stm32-p107/nsh/defconfig
+++ b/configs/olimex-stm32-p107/nsh/defconfig
@@ -24,7 +24,7 @@ CONFIG_MMCSD=y
CONFIG_MTD=y
CONFIG_NET_ETH_MTU=650
CONFIG_NET_ETH_TCP_RECVWNDO=624
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -66,6 +66,7 @@ CONFIG_STM32_PHYSR=16
CONFIG_STM32_PWR=y
CONFIG_STM32_USART2_REMAP=y
CONFIG_STM32_USART2=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART2_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
diff --git a/configs/olimex-stm32-p207/nsh/defconfig b/configs/olimex-stm32-p207/nsh/defconfig
index 97927d0ca69..16cec8b2fb8 100644
--- a/configs/olimex-stm32-p207/nsh/defconfig
+++ b/configs/olimex-stm32-p207/nsh/defconfig
@@ -18,7 +18,6 @@ CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BUILTIN=y
CONFIG_CAN_TSEG2=8
CONFIG_DEBUG_SYMBOLS=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_KS8721=y
CONFIG_EXAMPLES_ADC_GROUPSIZE=1
CONFIG_EXAMPLES_ADC=y
@@ -31,7 +30,7 @@ CONFIG_LIB_BOARDCTL=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=2
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
@@ -81,6 +80,7 @@ CONFIG_STM32_RMII_EXTCLK=y
CONFIG_STM32_TIM1_ADC=y
CONFIG_STM32_TIM1=y
CONFIG_STM32_USART3=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART3_SERIAL_CONSOLE=y
CONFIG_USBHOST=y
diff --git a/configs/pic32mx-starterkit/nsh2/defconfig b/configs/pic32mx-starterkit/nsh2/defconfig
index 018ac801d8d..4fd623b657d 100644
--- a/configs/pic32mx-starterkit/nsh2/defconfig
+++ b/configs/pic32mx-starterkit/nsh2/defconfig
@@ -27,7 +27,7 @@ CONFIG_MAX_WDOGPARMS=2
CONFIG_MMCSD=y
CONFIG_MTD=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_NRXDESC=7
@@ -73,6 +73,7 @@ CONFIG_START_DAY=7
CONFIG_START_MONTH=3
CONFIG_START_YEAR=2012
CONFIG_SYMTAB_ORDEREDBYNAME=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WDOG_INTRESERVE=2
diff --git a/configs/pic32mx7mmb/nsh/defconfig b/configs/pic32mx7mmb/nsh/defconfig
index 2b5d45c8511..bc119376fa2 100644
--- a/configs/pic32mx7mmb/nsh/defconfig
+++ b/configs/pic32mx7mmb/nsh/defconfig
@@ -13,7 +13,6 @@ CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH="mips"
CONFIG_BOARD_LOOPSPERMSEC=7245
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_LAN8720=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FAT_LCNAMES=y
@@ -30,7 +29,7 @@ CONFIG_MMCSD_SPICLOCK=12500000
CONFIG_MMCSD=y
CONFIG_MTD=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_NRXDESC=7
@@ -79,6 +78,7 @@ CONFIG_SPI=y
CONFIG_START_MONTH=6
CONFIG_START_YEAR=2012
CONFIG_SYMTAB_ORDEREDBYNAME=y
+CONFIG_SYSTEM_PING=y
CONFIG_SYSTEM_USBMSC=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART1_SERIAL_CONSOLE=y
diff --git a/configs/sam4e-ek/README.txt b/configs/sam4e-ek/README.txt
index aaf19d51c45..90fc5cc0d86 100644
--- a/configs/sam4e-ek/README.txt
+++ b/configs/sam4e-ek/README.txt
@@ -418,7 +418,7 @@ Networking Support
CONFIG_NET_UDP=y : Enable UDP networking
CONFIG_NET_BROADCAST=y : Needed for DNS name resolution
CONFIG_NET_ICMP=y : Enable ICMP networking
- CONFIG_NET_ICMP_PING=y : Needed for NSH ping command
+ CONFIG_NET_ICMP_SOCKET=y : Needed for NSH ping command
: Defaults should be okay for other options
Device drivers -> Network Device/PHY Support
CONFIG_NETDEVICES=y : Enabled PHY selection
diff --git a/configs/sam4e-ek/nsh/defconfig b/configs/sam4e-ek/nsh/defconfig
index ed63eb8c5c4..a42ae0678d1 100644
--- a/configs/sam4e-ek/nsh/defconfig
+++ b/configs/sam4e-ek/nsh/defconfig
@@ -14,7 +14,6 @@ CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL=y
CONFIG_BOARD_LOOPSPERMSEC=11990
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_KSZ8051=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FAT_LCNAMES=y
@@ -28,7 +27,7 @@ CONFIG_MTD_AT25=y
CONFIG_MTD=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=16
CONFIG_NET_SOCKOPTS=y
@@ -79,6 +78,7 @@ CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=10
CONFIG_START_MONTH=3
CONFIG_START_YEAR=2014
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
diff --git a/configs/sam4e-ek/nxwm/defconfig b/configs/sam4e-ek/nxwm/defconfig
index 4547baf9586..9ebf677a6c6 100644
--- a/configs/sam4e-ek/nxwm/defconfig
+++ b/configs/sam4e-ek/nxwm/defconfig
@@ -19,7 +19,6 @@ CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL=y
CONFIG_BOARD_LOOPSPERMSEC=11990
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_KSZ8051=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
@@ -42,7 +41,7 @@ CONFIG_MTD_AT25=y
CONFIG_MTD=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=16
CONFIG_NET_SOCKOPTS=y
@@ -93,7 +92,6 @@ CONFIG_NXWM_HEXCALCULATOR_FONTID=5
CONFIG_NXWM_KEYBOARD_LISTENERSTACK=1024
CONFIG_NXWM_KEYBOARD=y
CONFIG_NXWM_NXTERM_STACKSIZE=1596
-CONFIG_NXWM_STARTWINDOW_MQNAME="nxwm"
CONFIG_NXWM_TASKBAR_HSPACING=4
CONFIG_NXWM_TASKBAR_LEFT=y
CONFIG_NXWM_TASKBAR_VSPACING=4
@@ -136,6 +134,7 @@ CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=10
CONFIG_START_MONTH=3
CONFIG_START_YEAR=2014
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nxwm_main"
diff --git a/configs/sam4e-ek/usbnsh/defconfig b/configs/sam4e-ek/usbnsh/defconfig
index 0c0707ff0b7..7a5be6e6ee4 100644
--- a/configs/sam4e-ek/usbnsh/defconfig
+++ b/configs/sam4e-ek/usbnsh/defconfig
@@ -22,7 +22,6 @@ CONFIG_CDCACM_EPBULKOUT=2
CONFIG_CDCACM_RXBUFSIZE=256
CONFIG_CDCACM_TXBUFSIZE=256
CONFIG_CDCACM=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_KSZ8051=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FAT_LCNAMES=y
@@ -35,7 +34,7 @@ CONFIG_MM_REGIONS=2
CONFIG_MTD_AT25=y
CONFIG_MTD=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=16
CONFIG_NET_SOCKOPTS=y
@@ -88,6 +87,7 @@ CONFIG_START_MONTH=3
CONFIG_START_YEAR=2014
CONFIG_SYSLOG_CHAR=y
CONFIG_SYSLOG_DEVPATH="/dev/ttyS0"
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USBDEV=y
CONFIG_USER_ENTRYPOINT="nsh_main"
diff --git a/configs/sama5d3-xplained/README.txt b/configs/sama5d3-xplained/README.txt
index 3667b73a08a..2e6cb77045a 100644
--- a/configs/sama5d3-xplained/README.txt
+++ b/configs/sama5d3-xplained/README.txt
@@ -820,7 +820,7 @@ Networking
CONFIG_NET_TCP_READAHEAD_BUFSIZE=562 : Read-ahead buffer size
CONFIG_NET_UDP=y : Enable UDP networking
CONFIG_NET_ICMP=y : Enable ICMP networking
- CONFIG_NET_ICMP_PING=y : Needed for NSH ping command
+ CONFIG_NET_ICMP_SOCKET=y : Needed for NSH ping command
: Defaults should be okay for other options
Device drivers -> Network Device/PHY Support
CONFIG_NETDEVICES=y : Enabled PHY selection
diff --git a/configs/sama5d3x-ek/README.txt b/configs/sama5d3x-ek/README.txt
index 5f904171f39..9f6b401f660 100644
--- a/configs/sama5d3x-ek/README.txt
+++ b/configs/sama5d3x-ek/README.txt
@@ -989,7 +989,7 @@ Networking
CONFIG_NET_TCP_READAHEAD_BUFSIZE=562 : Read-ahead buffer size
CONFIG_NET_UDP=y : Enable UDP networking
CONFIG_NET_ICMP=y : Enable ICMP networking
- CONFIG_NET_ICMP_PING=y : Needed for NSH ping command
+ CONFIG_NET_ICMP_SOCKET=y : Needed for NSH ping command
: Defaults should be okay for other options
Device drivers -> Network Device/PHY Support
CONFIG_NETDEVICES=y : Enabled PHY selection
diff --git a/configs/sama5d4-ek/README.txt b/configs/sama5d4-ek/README.txt
index 815fe9474de..8483a0ddc99 100644
--- a/configs/sama5d4-ek/README.txt
+++ b/configs/sama5d4-ek/README.txt
@@ -1356,7 +1356,7 @@ Networking
CONFIG_NET_UDP=y : Enable UDP networking
CONFIG_NET_BROADCAST=y : Support UDP broadcase packets
CONFIG_NET_ICMP=y : Enable ICMP networking
- CONFIG_NET_ICMP_PING=y : Needed for NSH ping command
+ CONFIG_NET_ICMP_SOCKET=y : Needed for NSH ping command
: Defaults should be okay for other options
Device drivers -> Network Device/PHY Support
CONFIG_NETDEVICES=y : Enabled PHY selection
@@ -3959,7 +3959,7 @@ Configurations
CONFIG_NET_ARP=y
CONFIG_NET_ARP_SEND=y (optional)
CONFIG_NET_ICMP=y
- CONFIG_NET_ICMP_PING=y
+ CONFIG_NET_ICMP_SOCKET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETUTILS_TELNETD=y
diff --git a/configs/sama5d4-ek/nsh/defconfig b/configs/sama5d4-ek/nsh/defconfig
index 9c3472a53a0..c0e15dc5b96 100644
--- a/configs/sama5d4-ek/nsh/defconfig
+++ b/configs/sama5d4-ek/nsh/defconfig
@@ -57,7 +57,7 @@ CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_TCP_RECVWNDO=562
CONFIG_NET_HOSTNAME="SAMA5D4-EK"
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
@@ -150,6 +150,7 @@ CONFIG_SDIO_BLOCKSETUP=y
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_I2CTOOL=y
CONFIG_SYSTEM_NXPLAYER=y
+CONFIG_SYSTEM_PING=y
CONFIG_USART3_SERIAL_CONSOLE=y
CONFIG_USBHOST_HIDKBD=y
CONFIG_USBHOST_ISOC_DISABLE=y
diff --git a/configs/sama5d4-ek/nxwm/defconfig b/configs/sama5d4-ek/nxwm/defconfig
index 2d497e2b5ee..2d0d6ca55da 100644
--- a/configs/sama5d4-ek/nxwm/defconfig
+++ b/configs/sama5d4-ek/nxwm/defconfig
@@ -20,7 +20,6 @@ CONFIG_ARCH_LOWVECTORS=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH="arm"
CONFIG_ARMV7A_TOOLCHAIN_CODESOURCERYW=y
-CONFIG_DRIVERS_AUDIO=y
CONFIG_AUDIO_NULL=y
CONFIG_AUDIO_NUM_BUFFERS=4
CONFIG_AUDIO=y
@@ -28,6 +27,7 @@ CONFIG_BOARD_LOOPSPERMSEC=65775
CONFIG_BOOT_RUNFROMSDRAM=y
CONFIG_BUILTIN=y
CONFIG_DEV_ZERO=y
+CONFIG_DRIVERS_AUDIO=y
CONFIG_ETH0_PHY_KSZ8081=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
@@ -57,7 +57,7 @@ CONFIG_MQ_MAXMSGSIZE=64
CONFIG_NET_ARP_IPIN=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_TCP_RECVWNDO=562
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
@@ -121,7 +121,6 @@ CONFIG_NXWM_NXTERM_CUSTOM_FONTID=y
CONFIG_NXWM_NXTERM_FONTID=3
CONFIG_NXWM_NXTERM_STACKSIZE=1596
CONFIG_NXWM_STARTWINDOW_HSPACING=8
-CONFIG_NXWM_STARTWINDOW_MQNAME="nxwm"
CONFIG_NXWM_STARTWINDOW_VSPACING=8
CONFIG_NXWM_TASKBAR_HSPACING=8
CONFIG_NXWM_TASKBAR_LEFT=y
@@ -184,6 +183,7 @@ CONFIG_SDIO_BLOCKSETUP=y
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_I2CTOOL=y
CONFIG_SYSTEM_NXPLAYER=y
+CONFIG_SYSTEM_PING=y
CONFIG_USART3_SERIAL_CONSOLE=y
CONFIG_USBHOST_HIDKBD=y
CONFIG_USBHOST_ISOC_DISABLE=y
diff --git a/configs/same70-xplained/README.txt b/configs/same70-xplained/README.txt
index 2252fc7b942..a237b19e7d9 100644
--- a/configs/same70-xplained/README.txt
+++ b/configs/same70-xplained/README.txt
@@ -401,7 +401,7 @@ Selecting the GMAC peripheral
CONFIG_NET_UDP=y : Enable UDP networking
CONFIG_NET_BROADCAST=y : Support UDP broadcase packets
CONFIG_NET_ICMP=y : Enable ICMP networking
- CONFIG_NET_ICMP_PING=y : Needed for NSH ping command
+ CONFIG_NET_ICMP_SOCKET=y : Needed for NSH ping command
: Defaults should be okay for other options
Device drivers -> Network Device/PHY Support
CONFIG_NETDEVICES=y : Enabled PHY selection
diff --git a/configs/same70-xplained/netnsh/defconfig b/configs/same70-xplained/netnsh/defconfig
index d2a2149b920..89e90c05a70 100644
--- a/configs/same70-xplained/netnsh/defconfig
+++ b/configs/same70-xplained/netnsh/defconfig
@@ -26,7 +26,6 @@ CONFIG_AT24XX_EXTSIZE=160
CONFIG_AT24XX_SIZE=2
CONFIG_BOARD_LOOPSPERMSEC=51262
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_KSZ8081=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FAT_LCNAMES=y
@@ -47,7 +46,7 @@ CONFIG_MTD=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_HOSTNAME="SAME70-Xplained"
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
@@ -102,5 +101,6 @@ CONFIG_START_DAY=10
CONFIG_START_MONTH=3
CONFIG_START_YEAR=2014
CONFIG_SYSTEM_I2CTOOL=y
+CONFIG_SYSTEM_PING=y
CONFIG_USART1_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
diff --git a/configs/samv71-xult/README.txt b/configs/samv71-xult/README.txt
index d1b9837ec44..b9c4f34054d 100644
--- a/configs/samv71-xult/README.txt
+++ b/configs/samv71-xult/README.txt
@@ -717,7 +717,7 @@ Selecting the GMAC peripheral
CONFIG_NET_UDP=y : Enable UDP networking
CONFIG_NET_BROADCAST=y : Support UDP broadcase packets
CONFIG_NET_ICMP=y : Enable ICMP networking
- CONFIG_NET_ICMP_PING=y : Needed for NSH ping command
+ CONFIG_NET_ICMP_SOCKET=y : Needed for NSH ping command
: Defaults should be okay for other options
Device drivers -> Network Device/PHY Support
CONFIG_NETDEVICES=y : Enabled PHY selection
diff --git a/configs/samv71-xult/netnsh/defconfig b/configs/samv71-xult/netnsh/defconfig
index 869f457e5f8..29990c89c0c 100644
--- a/configs/samv71-xult/netnsh/defconfig
+++ b/configs/samv71-xult/netnsh/defconfig
@@ -26,7 +26,6 @@ CONFIG_AT24XX_SIZE=2
CONFIG_BOARD_LOOPSPERMSEC=51262
CONFIG_BUILTIN=y
CONFIG_DEBUG_CUSTOMOPT=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_KSZ8061=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FAT_LCNAMES=y
@@ -46,7 +45,7 @@ CONFIG_MTD=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_HOSTNAME="SAMV71-XULT"
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
@@ -101,5 +100,6 @@ CONFIG_START_DAY=10
CONFIG_START_MONTH=3
CONFIG_START_YEAR=2014
CONFIG_SYSTEM_I2CTOOL=y
+CONFIG_SYSTEM_PING=y
CONFIG_UART3_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
diff --git a/configs/samv71-xult/vnc/defconfig b/configs/samv71-xult/vnc/defconfig
index e9ffc822047..cd95bd33e44 100644
--- a/configs/samv71-xult/vnc/defconfig
+++ b/configs/samv71-xult/vnc/defconfig
@@ -28,7 +28,6 @@ CONFIG_BOARD_LOOPSPERMSEC=51262
CONFIG_BUILTIN=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_KSZ8061=y
CONFIG_EXAMPLES_NSH=y
CONFIG_EXAMPLES_NXIMAGE_BPP=8
@@ -53,7 +52,7 @@ CONFIG_MTD_CONFIG=y
CONFIG_MTD=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_HOSTNAME="SAMV71-XULT"
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
@@ -110,6 +109,7 @@ CONFIG_SDIO_BLOCKSETUP=y
CONFIG_START_DAY=10
CONFIG_START_MONTH=3
CONFIG_START_YEAR=2014
+CONFIG_SYSTEM_PING=y
CONFIG_UART3_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_VNCSERVER_COLORFMT_RGB8=y
diff --git a/configs/samv71-xult/vnxwm/defconfig b/configs/samv71-xult/vnxwm/defconfig
index 5636f11baf0..469e3f8467c 100644
--- a/configs/samv71-xult/vnxwm/defconfig
+++ b/configs/samv71-xult/vnxwm/defconfig
@@ -28,7 +28,6 @@ CONFIG_BOARD_LOOPSPERMSEC=51262
CONFIG_BUILTIN=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_KSZ8061=y
CONFIG_EXPERIMENTAL=y
CONFIG_FAT_LCNAMES=y
@@ -54,7 +53,7 @@ CONFIG_MTD_CONFIG=y
CONFIG_MTD=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_HOSTNAME="SAMV71-XULT"
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
@@ -102,7 +101,6 @@ CONFIG_NXWM_DEFAULT_FONTID=5
CONFIG_NXWM_HEXCALCULATOR_CUSTOM_FONTID=y
CONFIG_NXWM_HEXCALCULATOR_FONTID=5
CONFIG_NXWM_KEYBOARD=y
-CONFIG_NXWM_STARTWINDOW_MQNAME="nxwm"
CONFIG_NXWM_TASKBAR_HSPACING=4
CONFIG_NXWM_TASKBAR_LEFT=y
CONFIG_NXWM_TASKBAR_VSPACING=4
@@ -142,6 +140,7 @@ CONFIG_SDIO_BLOCKSETUP=y
CONFIG_START_DAY=10
CONFIG_START_MONTH=3
CONFIG_START_YEAR=2014
+CONFIG_SYSTEM_PING=y
CONFIG_UART3_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nxwm_main"
CONFIG_USERMAIN_STACKSIZE=1526
diff --git a/configs/shenzhou/nsh/defconfig b/configs/shenzhou/nsh/defconfig
index 9150c3c1996..adceb3ad087 100644
--- a/configs/shenzhou/nsh/defconfig
+++ b/configs/shenzhou/nsh/defconfig
@@ -9,7 +9,6 @@ CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH="arm"
CONFIG_BOARD_LOOPSPERMSEC=5483
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_DM9161=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FAT_LCNAMES=y
@@ -21,7 +20,7 @@ CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MMCSD_SPICLOCK=12500000
CONFIG_MMCSD=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -73,6 +72,7 @@ CONFIG_STM32_PWR=y
CONFIG_STM32_SPI1=y
CONFIG_STM32_USART2_REMAP=y
CONFIG_STM32_USART2=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART2_RXBUFSIZE=128
CONFIG_USART2_SERIAL_CONSOLE=y
diff --git a/configs/shenzhou/nxwm/defconfig b/configs/shenzhou/nxwm/defconfig
index c5007a09c2c..c98dcd58a8b 100644
--- a/configs/shenzhou/nxwm/defconfig
+++ b/configs/shenzhou/nxwm/defconfig
@@ -18,7 +18,6 @@ CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y
CONFIG_BOARD_LOOPSPERMSEC=5483
CONFIG_BOARDCTL_TSCTEST=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_DM9161=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
@@ -33,7 +32,7 @@ CONFIG_LCD=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MQ_MAXMSGSIZE=64
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=16
CONFIG_NET_SOCKOPTS=y
@@ -87,7 +86,6 @@ CONFIG_NXWM_KEYBOARD_LISTENERPRIO=100
CONFIG_NXWM_KEYBOARD_LISTENERSTACK=1024
CONFIG_NXWM_KEYBOARD=y
CONFIG_NXWM_NXTERM_STACKSIZE=1596
-CONFIG_NXWM_STARTWINDOW_MQNAME="nxwm"
CONFIG_NXWM_STARTWINDOW_STACKSIZE=1596
CONFIG_NXWM_TASKBAR_LEFT=y
CONFIG_NXWM_TASKBAR_VSPACING=4
@@ -124,6 +122,7 @@ CONFIG_STM32_SPI3_REMAP=y
CONFIG_STM32_SPI3=y
CONFIG_STM32_USART2_REMAP=y
CONFIG_STM32_USART2=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART2_RXBUFSIZE=128
CONFIG_USART2_SERIAL_CONSOLE=y
diff --git a/configs/shenzhou/thttpd/defconfig b/configs/shenzhou/thttpd/defconfig
index 4713197d0ab..95c1b3fc828 100644
--- a/configs/shenzhou/thttpd/defconfig
+++ b/configs/shenzhou/thttpd/defconfig
@@ -25,7 +25,7 @@ CONFIG_MTD=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_MTU=768
CONFIG_NET_ETH_TCP_RECVWNDO=742
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -80,6 +80,7 @@ CONFIG_STM32_SPI1=y
CONFIG_STM32_USART2_REMAP=y
CONFIG_STM32_USART2=y
CONFIG_SYMTAB_ORDEREDBYNAME=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_THTTPD_CGI_BYTECOUNT=20000
CONFIG_THTTPD_CGI_PRIORITY=50
diff --git a/configs/stm3220g-eval/nsh/defconfig b/configs/stm3220g-eval/nsh/defconfig
index 8d074695c5b..e2331f75efb 100644
--- a/configs/stm3220g-eval/nsh/defconfig
+++ b/configs/stm3220g-eval/nsh/defconfig
@@ -10,7 +10,6 @@ CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH="arm"
CONFIG_BOARD_LOOPSPERMSEC=10926
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_DP83848C=y
CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
CONFIG_EXAMPLES_NSH=y
@@ -28,7 +27,7 @@ CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
CONFIG_MMCSD=y
CONFIG_MTD=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -71,6 +70,7 @@ CONFIG_STM32_PHYSR=16
CONFIG_STM32_PWR=y
CONFIG_STM32_USART3=y
CONFIG_SYMTAB_ORDEREDBYNAME=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART3_RXBUFSIZE=128
CONFIG_USART3_SERIAL_CONSOLE=y
diff --git a/configs/stm3220g-eval/nsh2/defconfig b/configs/stm3220g-eval/nsh2/defconfig
index 524f9891c24..92c0df11e1a 100644
--- a/configs/stm3220g-eval/nsh2/defconfig
+++ b/configs/stm3220g-eval/nsh2/defconfig
@@ -34,7 +34,7 @@ CONFIG_MMCSD_SDIO=y
CONFIG_MMCSD=y
CONFIG_MTD=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -89,6 +89,7 @@ CONFIG_STM32_PWR=y
CONFIG_STM32_SDIO=y
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_I2CTOOL=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WDOG_INTRESERVE=2
diff --git a/configs/stm3220g-eval/nxwm/defconfig b/configs/stm3220g-eval/nxwm/defconfig
index 839d868b91e..abd8d86a484 100644
--- a/configs/stm3220g-eval/nxwm/defconfig
+++ b/configs/stm3220g-eval/nxwm/defconfig
@@ -16,7 +16,6 @@ CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y
CONFIG_BOARD_LOOPSPERMSEC=10926
CONFIG_BOARDCTL_TSCTEST=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_DP83848C=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
@@ -37,7 +36,7 @@ CONFIG_MAX_WDOGPARMS=2
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
CONFIG_MMCSD=y
CONFIG_MQ_MAXMSGSIZE=64
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -88,7 +87,6 @@ CONFIG_NXWM_HEXCALCULATOR_CUSTOM_FONTID=y
CONFIG_NXWM_HEXCALCULATOR_FONTID=5
CONFIG_NXWM_KEYBOARD_LISTENERPRIO=100
CONFIG_NXWM_KEYBOARD=y
-CONFIG_NXWM_STARTWINDOW_MQNAME="nxwm"
CONFIG_NXWM_TASKBAR_LEFT=y
CONFIG_NXWM_TASKBAR_VSPACING=4
CONFIG_NXWM_TOUCHSCREEN_LISTENERPRIO=100
@@ -125,6 +123,7 @@ CONFIG_STMPE811_MULTIPLE=y
CONFIG_STMPE811_THRESHX=39
CONFIG_STMPE811_THRESHY=51
CONFIG_SYMTAB_ORDEREDBYNAME=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART3_RXBUFSIZE=128
CONFIG_USART3_SERIAL_CONSOLE=y
diff --git a/configs/stm3240g-eval/discover/defconfig b/configs/stm3240g-eval/discover/defconfig
index 7e546b2f617..9b1facf1717 100644
--- a/configs/stm3240g-eval/discover/defconfig
+++ b/configs/stm3240g-eval/discover/defconfig
@@ -7,7 +7,6 @@ CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL=y
CONFIG_BOARD_LOOPSPERMSEC=16717
-CONFIG_DISABLE_POLL=y
CONFIG_DISCOVER_DESCR="STM3240G-EVAL"
CONFIG_ETH0_PHY_DP83848C=y
CONFIG_EXAMPLES_DISCOVER_DHCPC=y
@@ -28,7 +27,7 @@ CONFIG_NET_ARP_IPIN=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_MTU=650
CONFIG_NET_ETH_TCP_RECVWNDO=624
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -67,6 +66,7 @@ CONFIG_STM32_PHYSR_SPEED=0x0002
CONFIG_STM32_PHYSR=16
CONFIG_STM32_PWR=y
CONFIG_STM32_USART3=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART3_RXBUFSIZE=128
CONFIG_USART3_SERIAL_CONSOLE=y
diff --git a/configs/stm3240g-eval/nsh/defconfig b/configs/stm3240g-eval/nsh/defconfig
index a219b53c4d3..b599f4e457f 100644
--- a/configs/stm3240g-eval/nsh/defconfig
+++ b/configs/stm3240g-eval/nsh/defconfig
@@ -10,7 +10,6 @@ CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y
CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_DP83848C=y
CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
CONFIG_EXAMPLES_NSH=y
@@ -29,7 +28,7 @@ CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=2
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -79,6 +78,7 @@ CONFIG_STM32_RNG=y
CONFIG_STM32_USART3=y
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_I2CTOOL=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART3_RXBUFSIZE=128
CONFIG_USART3_SERIAL_CONSOLE=y
diff --git a/configs/stm3240g-eval/nsh2/defconfig b/configs/stm3240g-eval/nsh2/defconfig
index f8fece3fbe4..23a3aea1a87 100644
--- a/configs/stm3240g-eval/nsh2/defconfig
+++ b/configs/stm3240g-eval/nsh2/defconfig
@@ -35,7 +35,7 @@ CONFIG_MMCSD_SDIO=y
CONFIG_MMCSD=y
CONFIG_MTD=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -91,6 +91,7 @@ CONFIG_STM32_PWR=y
CONFIG_STM32_SDIO=y
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_I2CTOOL=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WDOG_INTRESERVE=2
diff --git a/configs/stm3240g-eval/nxterm/defconfig b/configs/stm3240g-eval/nxterm/defconfig
index 123601c75d9..55df3d5f112 100644
--- a/configs/stm3240g-eval/nxterm/defconfig
+++ b/configs/stm3240g-eval/nxterm/defconfig
@@ -14,7 +14,6 @@ CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y
CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_DP83848C=y
CONFIG_EXAMPLES_NXTERM=y
CONFIG_HAVE_CXX=y
@@ -30,13 +29,12 @@ CONFIG_INTELHEX_BINARY=y
CONFIG_LCD_MAXCONTRAST=1
CONFIG_LCD_NOGETRUN=y
CONFIG_LCD=y
-CONFIG_LIB_BOARDCTL=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=3
CONFIG_MQ_MAXMSGSIZE=64
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -100,6 +98,7 @@ CONFIG_STM32_PHYSR=16
CONFIG_STM32_PWR=y
CONFIG_STM32_USART3=y
CONFIG_SYSTEM_I2CTOOL=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART3_RXBUFSIZE=128
CONFIG_USART3_SERIAL_CONSOLE=y
diff --git a/configs/stm3240g-eval/nxwm/defconfig b/configs/stm3240g-eval/nxwm/defconfig
index a9cf7f13662..8fcecbd82d5 100644
--- a/configs/stm3240g-eval/nxwm/defconfig
+++ b/configs/stm3240g-eval/nxwm/defconfig
@@ -16,7 +16,6 @@ CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y
CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BOARDCTL_TSCTEST=y
-CONFIG_DISABLE_POLL=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
CONFIG_FS_FAT=y
@@ -35,7 +34,7 @@ CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=2
CONFIG_MQ_MAXMSGSIZE=64
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -86,7 +85,6 @@ CONFIG_NXWIDGETS=y
CONFIG_NXWM_HEXCALCULATOR_CUSTOM_FONTID=y
CONFIG_NXWM_HEXCALCULATOR_FONTID=5
CONFIG_NXWM_KEYBOARD=y
-CONFIG_NXWM_STARTWINDOW_MQNAME="nxwm"
CONFIG_NXWM_TASKBAR_LEFT=y
CONFIG_NXWM_TASKBAR_VSPACING=4
CONFIG_NXWM_UNITTEST=y
@@ -122,6 +120,7 @@ CONFIG_STMPE811_MULTIPLE=y
CONFIG_STMPE811_THRESHX=39
CONFIG_STMPE811_THRESHY=51
CONFIG_SYMTAB_ORDEREDBYNAME=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART3_RXBUFSIZE=128
CONFIG_USART3_SERIAL_CONSOLE=y
diff --git a/configs/stm3240g-eval/webserver/defconfig b/configs/stm3240g-eval/webserver/defconfig
index dc65028da96..f135ed7837b 100644
--- a/configs/stm3240g-eval/webserver/defconfig
+++ b/configs/stm3240g-eval/webserver/defconfig
@@ -12,7 +12,6 @@ CONFIG_ARCH_CHIP_STM32F407IG=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH="arm"
CONFIG_BOARD_LOOPSPERMSEC=16717
-CONFIG_DISABLE_POLL=y
CONFIG_EXAMPLES_NETTEST_NOMAC=y
CONFIG_EXAMPLES_NETTEST=y
CONFIG_EXAMPLES_WEBSERVER=y
@@ -27,7 +26,7 @@ CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=2
CONFIG_MTD=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -73,6 +72,7 @@ CONFIG_STM32_PHYSR=16
CONFIG_STM32_PWR=y
CONFIG_STM32_USART3=y
CONFIG_SYMTAB_ORDEREDBYNAME=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART3_RXBUFSIZE=128
CONFIG_USART3_SERIAL_CONSOLE=y
diff --git a/configs/stm3240g-eval/xmlrpc/defconfig b/configs/stm3240g-eval/xmlrpc/defconfig
index fb3f43310b6..71dd22a63c3 100644
--- a/configs/stm3240g-eval/xmlrpc/defconfig
+++ b/configs/stm3240g-eval/xmlrpc/defconfig
@@ -25,7 +25,7 @@ CONFIG_MM_REGIONS=2
CONFIG_NET_ARP_IPIN=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_MTU=650
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -64,6 +64,7 @@ CONFIG_STM32_PHYSR_SPEED=0x0002
CONFIG_STM32_PHYSR=16
CONFIG_STM32_PWR=y
CONFIG_STM32_USART3=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART3_RXBUFSIZE=128
CONFIG_USART3_SERIAL_CONSOLE=y
diff --git a/configs/stm32butterfly2/nshnet/defconfig b/configs/stm32butterfly2/nshnet/defconfig
index c8b6eb5eca5..1e8dafebc8e 100644
--- a/configs/stm32butterfly2/nshnet/defconfig
+++ b/configs/stm32butterfly2/nshnet/defconfig
@@ -38,7 +38,7 @@ CONFIG_MMCSD=y
CONFIG_NET_ARP_IPIN=y
CONFIG_NET_ETH_MTU=1500
CONFIG_NET_HOSTNAME="butterfly2"
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_LOCAL=y
CONFIG_NET_TCP_SPLIT=y
@@ -86,6 +86,7 @@ CONFIG_STM32_SPI1=y
CONFIG_STM32_USART2_REMAP=y
CONFIG_STM32_USART2=y
CONFIG_SYSLOG_TIMESTAMP=y
+CONFIG_SYSTEM_PING=y
CONFIG_SYSTEM_RAMTEST=y
CONFIG_SYSTEM_VI=y
CONFIG_USART2_SERIAL_CONSOLE=y
diff --git a/configs/stm32f4discovery/README.txt b/configs/stm32f4discovery/README.txt
index e29c20478e0..ccad49bab81 100644
--- a/configs/stm32f4discovery/README.txt
+++ b/configs/stm32f4discovery/README.txt
@@ -1153,7 +1153,7 @@ Where is one of the following:
CONFIG_NET_ARP=y
CONFIG_NET_ARP_SEND=y (optional)
CONFIG_NET_ICMP=y
- CONFIG_NET_ICMP_PING=y
+ CONFIG_NET_ICMP_SOCKET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETUTILS_TELNETD=y
diff --git a/configs/stm32f4discovery/netnsh/defconfig b/configs/stm32f4discovery/netnsh/defconfig
index 6c36909389d..c9e4c765ebe 100644
--- a/configs/stm32f4discovery/netnsh/defconfig
+++ b/configs/stm32f4discovery/netnsh/defconfig
@@ -16,7 +16,6 @@ CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y
CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BOARDCTL_RESET=y
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_LAN8720=y
CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
CONFIG_EXAMPLES_NSH=y
@@ -36,7 +35,7 @@ CONFIG_MMCSD=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_HOSTNAME="STM32F4-Discovery"
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_SOLINGER=y
@@ -93,6 +92,7 @@ CONFIG_STM32_SDIO=y
CONFIG_STM32_SPI1=y
CONFIG_STM32_USART6=y
CONFIG_STM32F4DISBB=y
+CONFIG_SYSTEM_PING=y
CONFIG_USART6_RXBUFSIZE=64
CONFIG_USART6_SERIAL_CONSOLE=y
CONFIG_USART6_TXBUFSIZE=64
diff --git a/configs/stm32f769i-disco/nsh-ethernet/defconfig b/configs/stm32f769i-disco/nsh-ethernet/defconfig
index 7fdba0ec38c..c8d43d09d3f 100644
--- a/configs/stm32f769i-disco/nsh-ethernet/defconfig
+++ b/configs/stm32f769i-disco/nsh-ethernet/defconfig
@@ -1,10 +1,11 @@
-CONFIG_ARCH="arm"
-CONFIG_ARCH_BOARD="stm32f769i-disco"
+# CONFIG_SPI_CALLBACK is not set
CONFIG_ARCH_BOARD_STM32F769I_DISCO=y
+CONFIG_ARCH_BOARD="stm32f769i-disco"
CONFIG_ARCH_BUTTONS=y
-CONFIG_ARCH_CHIP_STM32F769NI=y
CONFIG_ARCH_CHIP_STM32F7=y
+CONFIG_ARCH_CHIP_STM32F769NI=y
CONFIG_ARCH_STACKDUMP=y
+CONFIG_ARCH="arm"
CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
CONFIG_ARMV7M_DCACHE=y
CONFIG_ARMV7M_DTCM=y
@@ -12,26 +13,24 @@ CONFIG_ARMV7M_ICACHE=y
CONFIG_ARMV7M_LAZYFPU=y
CONFIG_BOARD_LOOPSPERMSEC=43103
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_LAN8742A=y
CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FS_PROCFS_REGISTER=y
CONFIG_FS_PROCFS=y
-CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_HAVE_CXX=y
+CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_INTELHEX_BINARY=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
-CONFIG_MMCSD=y
CONFIG_MM_REGIONS=3
+CONFIG_MMCSD=y
CONFIG_NET_ARP_IPIN=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
-CONFIG_NETDB_DNSCLIENT=y
CONFIG_NET_ETH_MTU=1500
CONFIG_NET_HOSTNAME="stntest"
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_SOLINGER=y
@@ -40,6 +39,7 @@ CONFIG_NET_TCP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NET_UDP=y
CONFIG_NET=y
+CONFIG_NETDB_DNSCLIENT=y
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NFILE_STREAMS=8
CONFIG_NSH_BUILTIN_APPS=y
@@ -59,7 +59,6 @@ CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
-# CONFIG_SPI_CALLBACK is not set
CONFIG_SPI=y
CONFIG_START_DAY=14
CONFIG_STM32F7_BKPSRAM=y
@@ -74,16 +73,17 @@ CONFIG_STM32F7_PHYSR_100FD=0x18
CONFIG_STM32F7_PHYSR_100HD=0x8
CONFIG_STM32F7_PHYSR_10FD=0x14
CONFIG_STM32F7_PHYSR_10HD=0x4
-CONFIG_STM32F7_PHYSR=31
CONFIG_STM32F7_PHYSR_ALTCONFIG=y
CONFIG_STM32F7_PHYSR_ALTMODE=0x1C
+CONFIG_STM32F7_PHYSR=31
CONFIG_STM32F7_QUADSPI=y
CONFIG_STM32F7_RNG=y
-CONFIG_STM32F7_SDMMC2=y
CONFIG_STM32F7_SDMMC_DMA=y
+CONFIG_STM32F7_SDMMC2=y
CONFIG_STM32F7_USART1=y
CONFIG_STM32F7_USART6=y
CONFIG_SYSTEM_DHCPC_RENEW=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART1_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
diff --git a/configs/tm4c1294-launchpad/README.txt b/configs/tm4c1294-launchpad/README.txt
index b45511d2cfc..9c3be1b7db4 100644
--- a/configs/tm4c1294-launchpad/README.txt
+++ b/configs/tm4c1294-launchpad/README.txt
@@ -123,7 +123,7 @@ Where is one of the following:
CONFIG_NET_ARP=y
CONFIG_NET_ARP_SEND=y (optional)
CONFIG_NET_ICMP=y
- CONFIG_NET_ICMP_PING=y
+ CONFIG_NET_ICMP_SOCKET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETUTILS_TELNETD=y
diff --git a/configs/tm4c1294-launchpad/nsh/defconfig b/configs/tm4c1294-launchpad/nsh/defconfig
index d2d3c0b97cd..9cdd97e4a59 100644
--- a/configs/tm4c1294-launchpad/nsh/defconfig
+++ b/configs/tm4c1294-launchpad/nsh/defconfig
@@ -11,7 +11,6 @@ CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH="arm"
CONFIG_BOARD_LOOPSPERMSEC=11401
CONFIG_BUILTIN=y
-CONFIG_DISABLE_POLL=y
CONFIG_EXAMPLES_NSH=y
CONFIG_I2C=y
CONFIG_I2CTOOL_MAXBUS=6
@@ -23,7 +22,7 @@ CONFIG_MAX_WDOGPARMS=2
CONFIG_NET_ARP_IPIN=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_SOLINGER=y
@@ -58,6 +57,7 @@ CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_START_YEAR=2015
CONFIG_SYSTEM_I2CTOOL=y
+CONFIG_SYSTEM_PING=y
CONFIG_TIVA_BOARDMAC=y
CONFIG_TIVA_ETHERNET=y
CONFIG_TIVA_I2C0=y
diff --git a/configs/twr-k64f120m/README.txt b/configs/twr-k64f120m/README.txt
index b8f1b423d10..d09425d04a5 100644
--- a/configs/twr-k64f120m/README.txt
+++ b/configs/twr-k64f120m/README.txt
@@ -191,7 +191,7 @@ Networking Support
CONFIG_NET_UDP=y : Enable UDP networking
CONFIG_NET_BROADCAST=y : Needed for DNS name resolution
CONFIG_NET_ICMP=y : Enable ICMP networking
- CONFIG_NET_ICMP_PING=y : Needed for NSH ping command
+ CONFIG_NET_ICMP_SOCKET=y : Needed for NSH ping command
: Defaults should be okay for other options
Application Configuration -> Network Utilities
CONFIG_NETDB_DNSCLIENT=y : Enable host address resolution
diff --git a/configs/twr-k64f120m/netnsh/defconfig b/configs/twr-k64f120m/netnsh/defconfig
index edd3f61e299..6a9fac12955 100644
--- a/configs/twr-k64f120m/netnsh/defconfig
+++ b/configs/twr-k64f120m/netnsh/defconfig
@@ -7,7 +7,6 @@ CONFIG_ARCH_CHIP_MK64FN1M0VMD12=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH="arm"
CONFIG_BOARD_LOOPSPERMSEC=9535
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_KSZ8041=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FAT_LFN=y
@@ -28,7 +27,7 @@ CONFIG_NET_ARP_IPIN=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_HOSTNAME="TWRK64"
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_TCP_WRITE_BUFFERS=y
CONFIG_NET_TCP=y
@@ -53,6 +52,7 @@ CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=23
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=10
CONFIG_TWR_K64F120M_SDHC_AUTOMOUNT=y
CONFIG_UART1_SERIAL_CONSOLE=y
diff --git a/configs/u-blox-c027/nsh/defconfig b/configs/u-blox-c027/nsh/defconfig
index 8479a6f36d2..df3cbb65c51 100644
--- a/configs/u-blox-c027/nsh/defconfig
+++ b/configs/u-blox-c027/nsh/defconfig
@@ -47,7 +47,7 @@ CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_EMACRAM_SIZE=7296
CONFIG_NET_HOSTNAME="c027"
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_NRXDESC=6
@@ -96,6 +96,7 @@ CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=5
CONFIG_START_YEAR=2016
CONFIG_SYSTEM_CLE=y
+CONFIG_SYSTEM_PING=y
CONFIG_SYSTEM_UBLOXMODEM=y
CONFIG_SYSTEM_ZMODEM=y
CONFIG_TASK_NAME_SIZE=0
diff --git a/configs/viewtool-stm32f107/README.txt b/configs/viewtool-stm32f107/README.txt
index facd9837444..09c5248bd40 100644
--- a/configs/viewtool-stm32f107/README.txt
+++ b/configs/viewtool-stm32f107/README.txt
@@ -383,7 +383,7 @@ ViewTool DP83848 Ethernet Module
CONFIG_NET_UDP_CONNS=8
CONFIG_NET_ICMP=y : ICMP support
- CONFIG_NET_ICMP_PING=y
+ CONFIG_NET_ICMP_SOCKET=y
CONFIG_NSH_DRIPADDR=0x0a000001 : Network identity
CONFIG_NSH_IPADDR=0x0a000002
diff --git a/configs/viewtool-stm32f107/netnsh/defconfig b/configs/viewtool-stm32f107/netnsh/defconfig
index 005a04a7ee7..131d3b620b1 100644
--- a/configs/viewtool-stm32f107/netnsh/defconfig
+++ b/configs/viewtool-stm32f107/netnsh/defconfig
@@ -2,8 +2,6 @@
# CONFIG_NSH_CMDOPT_DF_H is not set
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
# CONFIG_NSH_CMDPARMS is not set
-# CONFIG_NSH_DISABLE_IFCONFIG is not set
-# CONFIG_NSH_DISABLE_PS is not set
CONFIG_ARCH_BOARD_VIEWTOOL_STM32F107=y
CONFIG_ARCH_BOARD="viewtool-stm32f107"
CONFIG_ARCH_CHIP_STM32=y
@@ -11,12 +9,11 @@ CONFIG_ARCH_CHIP_STM32F107VC=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH="arm"
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y
-CONFIG_LIB_BOARDCTL=y
CONFIG_BOARD_LOOPSPERMSEC=5483
CONFIG_BUILTIN=y
CONFIG_ETH0_PHY_DP83848C=y
-CONFIG_FS_PROCFS=y
CONFIG_EXAMPLES_NSH=y
+CONFIG_FS_PROCFS=y
CONFIG_HOST_WINDOWS=y
CONFIG_INTELHEX_BINARY=y
CONFIG_IOB_NBUFFERS=24
@@ -26,7 +23,7 @@ CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_MTU=650
CONFIG_NET_ETH_TCP_RECVWNDO=624
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
@@ -72,6 +69,7 @@ CONFIG_STM32_PHYSR=16
CONFIG_STM32_PWR=y
CONFIG_STM32_RMII_EXTCLK=y
CONFIG_STM32_USART1=y
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART1_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
diff --git a/configs/zkit-arm-1769/nsh/defconfig b/configs/zkit-arm-1769/nsh/defconfig
index d60b76e5517..3dcfabe078c 100644
--- a/configs/zkit-arm-1769/nsh/defconfig
+++ b/configs/zkit-arm-1769/nsh/defconfig
@@ -17,7 +17,6 @@ CONFIG_ARCH="arm"
CONFIG_ARMV7M_OABI_TOOLCHAIN=y
CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y
CONFIG_BOARD_LOOPSPERMSEC=8079
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_DP83848C=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FAT_LCNAMES=y
@@ -34,7 +33,7 @@ CONFIG_MMCSD_SPICLOCK=12500000
CONFIG_MMCSD=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_EMACRAM_SIZE=7296
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_NRXDESC=6
@@ -72,6 +71,7 @@ CONFIG_SPI=y
CONFIG_START_DAY=28
CONFIG_START_MONTH=2
CONFIG_START_YEAR=2013
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
diff --git a/configs/zkit-arm-1769/nxhello/defconfig b/configs/zkit-arm-1769/nxhello/defconfig
index 41ca75ba476..2ab4c5a1761 100644
--- a/configs/zkit-arm-1769/nxhello/defconfig
+++ b/configs/zkit-arm-1769/nxhello/defconfig
@@ -19,7 +19,6 @@ CONFIG_ARCH="arm"
CONFIG_ARMV7M_OABI_TOOLCHAIN=y
CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y
CONFIG_BOARD_LOOPSPERMSEC=8079
-CONFIG_DISABLE_POLL=y
CONFIG_ETH0_PHY_DP83848C=y
CONFIG_EXAMPLES_NXHELLO_BGCOLOR=0x00
CONFIG_EXAMPLES_NXHELLO_BPP=1
@@ -40,7 +39,7 @@ CONFIG_MMCSD=y
CONFIG_MQ_MAXMSGSIZE=64
CONFIG_NET_BROADCAST=y
CONFIG_NET_EMACRAM_SIZE=7296
-CONFIG_NET_ICMP_PING=y
+CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_NRXDESC=6
@@ -88,6 +87,7 @@ CONFIG_SPI=y
CONFIG_START_DAY=28
CONFIG_START_MONTH=2
CONFIG_START_YEAR=2013
+CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nxhello_main"
diff --git a/include/nuttx/net/icmp.h b/include/nuttx/net/icmp.h
index 33c38f2cf66..8b54e8290a9 100644
--- a/include/nuttx/net/icmp.h
+++ b/include/nuttx/net/icmp.h
@@ -92,8 +92,8 @@
/* Header sizes */
-#define ICMP_HDRLEN 4 /* Size of ICMP header */
-#define IPICMP_HDRLEN (ICMP_HDRLEN + IPv4_HDRLEN) /* Size of IP + ICMP header */
+#define ICMP_HDRLEN 8 /* Size of ICMP header */
+#define IPICMP_HDRLEN (ICMP_HDRLEN + IPv4_HDRLEN) /* Size of IPv4 + ICMP header */
/****************************************************************************
* Public Type Definitions
@@ -182,36 +182,6 @@ extern "C"
* Public Function Prototypes
****************************************************************************/
-/****************************************************************************
- * Name: imcp_ping
- *
- * Description:
- * Send a ECHO request and wait for the ECHO response
- *
- * Parameters:
- * addr - The IP address of the peer to send the ICMP ECHO request to
- * in network order.
- * id - The ID to use in the ICMP ECHO request. This number should be
- * unique; only ECHO responses with this matching ID will be
- * processed (host order)
- * seqno - The sequence number used in the ICMP ECHO request. NOT used
- * to match responses (host order)
- * dsecs - Wait up to this many deci-seconds for the ECHO response to be
- * returned (host order).
- *
- * Return:
- * seqno of received ICMP ECHO with matching ID (may be different
- * from the seqno argument (may be a delayed response from an earlier
- * ping with the same ID). Or a negated errno on any failure.
- *
- * Assumptions:
- * Called from the user level with interrupts enabled.
- *
- ****************************************************************************/
-
-int icmp_ping(in_addr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen,
- int dsecs);
-
#undef EXTERN
#ifdef __cplusplus
}
diff --git a/include/nuttx/net/net.h b/include/nuttx/net/net.h
index 1a97efb3a04..fb4de5c4737 100644
--- a/include/nuttx/net/net.h
+++ b/include/nuttx/net/net.h
@@ -79,7 +79,7 @@
# define _NX_GETERRNO(r) (-(r))
# define _NX_GETERRVAL(r) (r)
#else
-# define _NX_SEND(s,b,l,f) send(s,b,l,f)
+# define _NX_SEND(s,b,l,f) send(s,b,l,f)
# define _NX_RECV(s,b,l,f) recv(s,b,l,f)
# define _NX_RECVFROM(s,b,l,f,a,n) recvfrom(s,b,l,f,a,n)
# define _NX_GETERRNO(r) errno
diff --git a/include/nuttx/net/netconfig.h b/include/nuttx/net/netconfig.h
index d153a45d788..f290f03986c 100644
--- a/include/nuttx/net/netconfig.h
+++ b/include/nuttx/net/netconfig.h
@@ -226,7 +226,7 @@
/* ICMP configuration options */
#ifndef CONFIG_NET_ICMP
-# undef CONFIG_NET_ICMP_PING
+# undef CONFIG_NET_ICMP_SOCKET
#endif
/* UDP configuration options */
diff --git a/net/devif/devif_poll.c b/net/devif/devif_poll.c
index 0d28f642a39..1ebddbb6f22 100644
--- a/net/devif/devif_poll.c
+++ b/net/devif/devif_poll.c
@@ -282,7 +282,7 @@ static int devif_poll_ieee802154_connections(FAR struct net_driver_s *dev,
*
****************************************************************************/
-#if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING)
+#if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_SOCKET)
static inline int devif_poll_icmp(FAR struct net_driver_s *dev,
devif_poll_callback_t callback)
{
@@ -298,7 +298,7 @@ static inline int devif_poll_icmp(FAR struct net_driver_s *dev,
return callback(dev);
}
-#endif /* CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING */
+#endif /* CONFIG_NET_ICMP && CONFIG_NET_ICMP_SOCKET */
/****************************************************************************
* Name: devif_poll_icmpv6
@@ -601,7 +601,7 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback)
if (!bstop)
#endif
-#if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING)
+#if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_SOCKET)
{
/* Traverse all of the tasks waiting to send an ICMP ECHO request. */
diff --git a/net/icmp/Kconfig b/net/icmp/Kconfig
index 9f38cef29a8..7ed2ecd05b0 100644
--- a/net/icmp/Kconfig
+++ b/net/icmp/Kconfig
@@ -15,18 +15,22 @@ config NET_ICMP
if NET_ICMP
-config NET_ICMP_PING
- bool "ICMP ping interfaces"
+config NET_ICMP_SOCKET
+ bool "IPPROTO_ICMP socket support"
default n
- depends on BUILD_FLAT
---help---
- Provide interfaces to support application level support for
- for sending ECHO (ping) requests and associating ECHO replies.
+ Enable support for IPPROTO_ICMP sockets. These sockets are needed
+ for application level support application for sending ECHO (ping)
+ requests and associated ECHO replies.
- NOTE: Calling these interfaces from application space is a
- violation of the OS/application interface but for historical
- reasons, is permitted in the flat build.
+if NET_ICMP_SOCKET
+config NET_ICMP_NCONNS
+ int "Max ICMP packet sockets"
+ default 4
+ depends on MM_IOB
+
+endif # NET_ICMP_SOCKET
endif # NET_ICMP
endmenu # ICMP Networking Support
endif # NET_IPv4
diff --git a/net/icmp/Make.defs b/net/icmp/Make.defs
index d5a67c2065f..be92772e070 100644
--- a/net/icmp/Make.defs
+++ b/net/icmp/Make.defs
@@ -1,7 +1,7 @@
############################################################################
# net/icmp/Make.defs
#
-# Copyright (C) 2014 Gregory Nutt. All rights reserved.
+# Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt
#
# Redistribution and use in source and binary forms, with or without
@@ -39,8 +39,12 @@ ifeq ($(CONFIG_NET_ICMP),y)
NET_CSRCS += icmp_input.c
-ifeq ($(CONFIG_NET_ICMP_PING),y)
-NET_CSRCS += icmp_ping.c icmp_poll.c icmp_send.c
+ifeq ($(CONFIG_NET_ICMP_SOCKET),y)
+SOCK_CSRCS += icmp_sockif.c icmp_poll.c icmp_conn.c icmp_sendto.c
+SOCK_CSRCS += icmp_recvfrom.c
+ifeq ($(CONFIG_MM_IOB),y)
+SOCK_CSRCS += icmp_netpoll.c
+endif
endif
# Include ICMP build support
diff --git a/net/icmp/icmp.h b/net/icmp/icmp.h
index 9750d88539b..3ea753b9e35 100644
--- a/net/icmp/icmp.h
+++ b/net/icmp/icmp.h
@@ -42,12 +42,62 @@
#include
+#include
+#include
+#include
+
#include
+#include
#include
+#include
#ifdef CONFIG_NET_ICMP
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Allocate/free an ICMP data callback */
+
+#define icmp_callback_alloc(dev) devif_callback_alloc(dev, &(dev)->d_conncb)
+#define icmp_callback_free(dev,cb) devif_dev_callback_free(dev, cb)
+
+/****************************************************************************
+ * Public types
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_ICMP_SOCKET
+/* Representation of a IPPROTO_ICMP socket connection */
+
+struct devif_callback_s; /* Forward reference */
+
+struct icmp_conn_s
+{
+ dq_entry_t node; /* Supports a double linked list */
+ uint16_t id; /* ICMP ECHO request ID */
+ uint8_t nreqs; /* Number of requests with no response received */
+ uint8_t crefs; /* Reference counts on this instance */
+
+ /* The device that the ICMP request was sent on */
+
+ FAR struct net_driver_s *dev; /* Needed to free the callback structure */
+
+#ifdef CONFIG_MM_IOB
+ /* ICMP response read-ahead list. A singly linked list of type struct
+ * iob_qentry_s where the ICMP read-ahead data for the current ID is
+ * retained.
+ */
+
+ struct iob_queue_s readahead; /* Read-ahead buffering */
+#endif
+
+ /* Defines the list of IPPROTO_ICMP callbacks */
+
+ struct devif_callback_s *list;
+};
+#endif
+
/****************************************************************************
* Public Data
****************************************************************************/
@@ -60,25 +110,249 @@ extern "C"
# define EXTERN extern
#endif
+#ifdef CONFIG_NET_ICMP_SOCKET
+/* PF_INET socket address family, IPPROTO_ICMP protocol interface */
+
+EXTERN const struct sock_intf_s g_icmp_sockif;
+#endif
+
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
-/* Defined in icmp_input.c **************************************************/
+struct socket; /* Forward reference */
+struct sockaddr; /* Forward reference */
+struct pollfd; /* Forward reference */
+
+/****************************************************************************
+ * Name: icmp_input
+ *
+ * Description:
+ * Handle incoming ICMP input
+ *
+ * Parameters:
+ * dev - The device driver structure containing the received ICMP
+ * packet
+ *
+ * Return:
+ * None
+ *
+ * Assumptions:
+ * The network is locked.
+ *
+ ****************************************************************************/
void icmp_input(FAR struct net_driver_s *dev);
-/* Defined in icmp_poll.c ***************************************************/
+/****************************************************************************
+ * Name: icmp_sock_initialize
+ *
+ * Description:
+ * Initialize the IPPROTO_ICMP socket connection structures. Called once
+ * and only from the network initialization layer.
+ *
+ ****************************************************************************/
-#ifdef CONFIG_NET_ICMP_PING
+#ifdef CONFIG_NET_ICMP_SOCKET
+void icmp_sock_initialize(void);
+#endif
+
+/****************************************************************************
+ * Name: icmp_alloc
+ *
+ * Description:
+ * Allocate a new, uninitialized IPPROTO_ICMP socket connection structure.
+ * This is normally something done by the implementation of the socket()
+ * interface.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_ICMP_SOCKET
+FAR struct icmp_conn_s *icmp_alloc(void);
+#endif
+
+/****************************************************************************
+ * Name: icmp_free
+ *
+ * Description:
+ * Free a IPPROTO_ICMP socket connection structure that is no longer in
+ * use. This should be done by the implementation of close().
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_ICMP_SOCKET
+void icmp_free(FAR struct icmp_conn_s *conn);
+#endif
+
+/****************************************************************************
+ * Name: icmp_active()
+ *
+ * Description:
+ * Find a connection structure that is the appropriate connection to be
+ * used with the provided ECHO request ID.
+ *
+ * Assumptions:
+ * This function is called from network logic at with the network locked.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_ICMP_SOCKET
+FAR struct icmp_conn_s *icmp_active(uint16_t id);
+#endif
+
+/****************************************************************************
+ * Name: icmp_nextconn
+ *
+ * Description:
+ * Traverse the list of allocated packet connections
+ *
+ * Assumptions:
+ * This function is called from network logic at with the network locked.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_ICMP_SOCKET
+FAR struct icmp_conn_s *icmp_nextconn(FAR struct icmp_conn_s *conn);
+#endif
+
+/****************************************************************************
+ * Name: icmp_findconn
+ *
+ * Description:
+ * Find an ICMP connection structure that is expecting a ICMP ECHO response
+ * with this ID from this device
+ *
+ * Assumptions:
+ * This function is called from network logic at with the network locked.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_ICMP_SOCKET
+FAR struct icmp_conn_s *icmp_findconn(FAR struct net_driver_s *dev, uint8_t id);
+#endif
+
+/****************************************************************************
+ * Name: icmp_poll
+ *
+ * Description:
+ * Poll a device "connection" structure for availability of ICMP TX data
+ *
+ * Parameters:
+ * dev - The device driver structure to use in the send operation
+ *
+ * Return:
+ * None
+ *
+ * Assumptions:
+ * The network is locked.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_ICMP_SOCKET
void icmp_poll(FAR struct net_driver_s *dev);
-#endif /* CONFIG_NET_ICMP_PING */
+#endif
-/* Defined in icmp_send.c ***************************************************/
+/****************************************************************************
+ * Name: icmp_sendto
+ *
+ * Description:
+ * Implements the sendto() operation for the case of the raw packet socket.
+ *
+ * Parameters:
+ * psock A pointer to a NuttX-specific, internal socket structure
+ * buf Data to send
+ * len Length of data to send
+ * flags Send flags
+ * to Address of recipient
+ * tolen The length of the address structure
+ *
+ * Returned Value:
+ * On success, returns the number of characters sent. On error, a negated
+ * errno value is returned (see send_to() for the list of appropriate error
+ * values.
+ *
+ ****************************************************************************/
-#ifdef CONFIG_NET_ICMP_PING
-void icmp_send(FAR struct net_driver_s *dev, FAR in_addr_t *destaddr);
-#endif /* CONFIG_NET_ICMP_PING */
+#ifdef CONFIG_NET_ICMP_SOCKET
+ssize_t icmp_sendto(FAR struct socket *psock, FAR const void *buf, size_t len,
+ int flags, FAR const struct sockaddr *to, socklen_t tolen);
+#endif
+
+/****************************************************************************
+ * Name: icmp_recvfrom
+ *
+ * Description:
+ * Implements the socket recvfrom interface for the case of the AF_INET
+ * data gram socket with the IPPROTO_ICMP protocol. icmp_recvfrom()
+ * receives ICMP ECHO replies for the a socket.
+ *
+ * If 'from' is not NULL, and the underlying protocol provides the source
+ * address, this source address is filled in. The argument 'fromlen' is
+ * initialized to the size of the buffer associated with from, and
+ * modified on return to indicate the actual size of the address stored
+ * there.
+ *
+ * Input Parameters:
+ * psock A pointer to a NuttX-specific, internal socket structure
+ * buf Buffer to receive data
+ * len Length of buffer
+ * flags Receive flags
+ * from Address of source (may be NULL)
+ * fromlen The length of the address structure
+ *
+ * Returned Value:
+ * On success, returns the number of characters received. If no data is
+ * available to be received and the peer has performed an orderly shutdown,
+ * recv() will return 0. Otherwise, on errors, a negated errno value is
+ * returned (see recvfrom() for the list of appropriate error values).
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_ICMP_SOCKET
+ssize_t icmp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
+ int flags, FAR struct sockaddr *from,
+ FAR socklen_t *fromlen);
+#endif
+
+/****************************************************************************
+ * Name: icmp_pollsetup
+ *
+ * Description:
+ * Setup to monitor events on one UDP/IP socket
+ *
+ * Input Parameters:
+ * psock - The UDP/IP socket of interest
+ * fds - The structure describing the events to be monitored, OR NULL if
+ * this is a request to stop monitoring events.
+ *
+ * Returned Value:
+ * 0: Success; Negated errno on failure
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_ICMP_SOCKET
+int icmp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds);
+#endif
+
+/****************************************************************************
+ * Name: icmp_pollteardown
+ *
+ * Description:
+ * Teardown monitoring of events on an UDP/IP socket
+ *
+ * Input Parameters:
+ * psock - The IPPROTO_ICMP socket of interest
+ * fds - The structure describing the events to be monitored, OR NULL if
+ * this is a request to stop monitoring events.
+ *
+ * Returned Value:
+ * 0: Success; Negated errno on failure
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_ICMP_SOCKET
+int icmp_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds);
+#endif
#undef EXTERN
#ifdef __cplusplus
diff --git a/net/icmp/icmp_conn.c b/net/icmp/icmp_conn.c
new file mode 100644
index 00000000000..e360a5a5dc4
--- /dev/null
+++ b/net/icmp/icmp_conn.c
@@ -0,0 +1,286 @@
+/****************************************************************************
+ * net/icmp/icmp_conn.c
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include "devif/devif.h"
+#include "icmp/icmp.h"
+
+#ifdef CONFIG_NET_ICMP_SOCKET
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* The array containing all IPPROTO_ICMP socket connections */
+
+static struct icmp_conn_s g_icmp_connections[CONFIG_NET_ICMP_NCONNS];
+
+/* A list of all free IPPROTO_ICMP socket connections */
+
+static dq_queue_t g_free_icmp_connections;
+static sem_t g_free_sem;
+
+/* A list of all allocated IPPROTO_ICMP socket connections */
+
+static dq_queue_t g_active_icmp_connections;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: icmp_sock_initialize
+ *
+ * Description:
+ * Initialize the IPPROTO_ICMP socket connection structures. Called once
+ * and only from the network initialization layer.
+ *
+ ****************************************************************************/
+
+void icmp_sock_initialize(void)
+{
+ int i;
+
+ /* Initialize the queues */
+
+ dq_init(&g_free_icmp_connections);
+ dq_init(&g_active_icmp_connections);
+ nxsem_init(&g_free_sem, 0, 1);
+
+ for (i = 0; i < CONFIG_NET_ICMP_NCONNS; i++)
+ {
+ /* Move the connection structure to the free list */
+
+ dq_addlast(&g_icmp_connections[i].node, &g_free_icmp_connections);
+ }
+}
+
+/****************************************************************************
+ * Name: icmp_alloc
+ *
+ * Description:
+ * Allocate a new, uninitialized IPPROTO_ICMP socket connection structure.
+ * This is normally something done by the implementation of the socket()
+ * interface.
+ *
+ ****************************************************************************/
+
+FAR struct icmp_conn_s *icmp_alloc(void)
+{
+ FAR struct icmp_conn_s *conn = NULL;
+ int ret;
+
+ /* The free list is only accessed from user, non-interrupt level and
+ * is protected by a semaphore (that behaves like a mutex).
+ */
+
+ ret = net_lockedwait(&g_free_sem);
+ if (ret >= 0)
+ {
+ conn = (FAR struct icmp_conn_s *)dq_remfirst(&g_free_icmp_connections);
+ if (conn != NULL)
+ {
+ /* Clear the connection structure */
+
+ memset(conn, 0, sizeof(struct icmp_conn_s));
+
+ /* Enqueue the connection into the active list */
+
+ dq_addlast(&conn->node, &g_active_icmp_connections);
+ }
+
+ nxsem_post(&g_free_sem);
+ }
+
+ return conn;
+}
+
+/****************************************************************************
+ * Name: icmp_free
+ *
+ * Description:
+ * Free a IPPROTO_ICMP socket connection structure that is no longer in
+ * use. This should be done by the implementation of close().
+ *
+ ****************************************************************************/
+
+void icmp_free(FAR struct icmp_conn_s *conn)
+{
+ int ret;
+
+ /* The free list is only accessed from user, non-interrupt level and
+ * is protected by a semaphore (that behaves like a mutex).
+ */
+
+ DEBUGASSERT(conn->crefs == 0);
+
+ /* Take the semaphore (perhaps waiting) */
+
+ while ((ret = net_lockedwait(&g_free_sem)) < 0)
+ {
+ /* The only case that an error should occur here is if
+ * the wait was awakened by a signal.
+ */
+
+ DEBUGASSERT(ret == -EINTR);
+ }
+
+ UNUSED(ret);
+
+ /* Is this the last reference on the connection? It might not be if the
+ * socket was cloned.
+ */
+
+ if (conn->crefs > 1)
+ {
+ /* No.. just decrement the reference count */
+
+ conn->crefs--;
+ }
+ else
+ {
+ /* Remove the connection from the active list */
+
+ dq_rem(&conn->node, &g_active_icmp_connections);
+
+ /* Free the connection */
+
+ dq_addlast(&conn->node, &g_free_icmp_connections);
+ nxsem_post(&g_free_sem);
+ }
+}
+
+/****************************************************************************
+ * Name: icmp_active()
+ *
+ * Description:
+ * Find a connection structure that is the appropriate connection to be
+ * used with the provided ECHO request ID.
+ *
+ * Assumptions:
+ * This function is called from network logic at with the network locked.
+ *
+ ****************************************************************************/
+
+FAR struct icmp_conn_s *icmp_active(uint16_t id)
+{
+ FAR struct icmp_conn_s *conn =
+ (FAR struct icmp_conn_s *)g_active_icmp_connections.head;
+
+ while (conn != NULL)
+ {
+ /* FIXME lmac in conn should have been set by icmp_bind() */
+
+ if (id == conn->id)
+ {
+ /* Matching connection found.. return a reference to it */
+
+ break;
+ }
+
+ /* Look at the next active connection */
+
+ conn = (FAR struct icmp_conn_s *)conn->node.flink;
+ }
+
+ return conn;
+}
+
+/****************************************************************************
+ * Name: icmp_nextconn
+ *
+ * Description:
+ * Traverse the list of allocated packet connections
+ *
+ * Assumptions:
+ * This function is called from network logic at with the network locked.
+ *
+ ****************************************************************************/
+
+FAR struct icmp_conn_s *icmp_nextconn(FAR struct icmp_conn_s *conn)
+{
+ if (conn == NULL)
+ {
+ return (FAR struct icmp_conn_s *)g_active_icmp_connections.head;
+ }
+ else
+ {
+ return (FAR struct icmp_conn_s *)conn->node.flink;
+ }
+}
+
+/****************************************************************************
+ * Name: icmp_findconn
+ *
+ * Description:
+ * Find an ICMP connection structure that is expecting a ICMP ECHO response
+ * with this ID from this device
+ *
+ * Assumptions:
+ * This function is called from network logic at with the network locked.
+ *
+ ****************************************************************************/
+
+FAR struct icmp_conn_s *icmp_findconn(FAR struct net_driver_s *dev, uint8_t id)
+{
+ FAR struct icmp_conn_s *conn;
+
+ for (conn = icmp_nextconn(NULL); conn != NULL; conn = icmp_nextconn(conn))
+ {
+ if (conn->id == id && conn->dev == dev && conn->nreqs > 0)
+ {
+ return conn;
+ }
+ }
+
+ return conn;
+}
+#endif /* CONFIG_NET_ICMP */
diff --git a/net/icmp/icmp_input.c b/net/icmp/icmp_input.c
index 53758ab53e0..0d993504dd9 100644
--- a/net/icmp/icmp_input.c
+++ b/net/icmp/icmp_input.c
@@ -66,7 +66,134 @@
* Pre-processor Definitions
****************************************************************************/
-#define ICMPBUF ((struct icmp_iphdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
+#define IPv4BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
+#define IPICMPBUF ((FAR struct icmp_iphdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
+#define ICMPBUF ((FAR struct icmp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN])
+#define ICMPSIZE ((dev)->d_len - IPv4_HDRLEN)
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: icmp_datahandler
+ *
+ * Description:
+ * Handle ICMP echo replies that are not accepted by the application.
+ *
+ * Input Parameters:
+ * dev - Device instance only the input packet in d_buf, length = d_len;
+ * conn - A pointer to the ICMP connection structure
+ * buffer - A pointer to the buffer to be copied to the read-ahead
+ * buffers
+ * buflen - The number of bytes to copy to the read-ahead buffer.
+ *
+ * Returned value:
+ * The number of bytes actually buffered is returned. This will be either
+ * zero or equal to buflen; partial packets are not buffered.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_ICMP_SOCKET
+uint16_t icmp_datahandler(FAR struct net_driver_s *dev,
+ FAR struct icmp_conn_s *conn)
+{
+ FAR struct ipv4_hdr_s *ipv4;
+ struct sockaddr_in inaddr;
+ FAR struct iob_s *iob;
+ uint16_t offset;
+ uint16_t buflen;
+ uint8_t addrsize;
+ int ret;
+
+ /* Try to allocate on I/O buffer to start the chain without waiting (and
+ * throttling as necessary). If we would have to wait, then drop the
+ * packet.
+ */
+
+ iob = iob_tryalloc(true);
+ if (iob == NULL)
+ {
+ nerr("ERROR: Failed to create new I/O buffer chain\n");
+ return 0;
+ }
+
+ /* Put the IPv4 address at the beginning of the read-ahead buffer */
+
+ ipv4 = IPv4BUF;
+
+ inaddr.sin_family = AF_INET;
+ inaddr.sin_port = INADDR_ANY;
+
+ net_ipv4addr_copy(inaddr.sin_addr.s_addr,
+ net_ip4addr_conv32(ipv4->srcipaddr));
+
+ /* Copy the src address info into the I/O buffer chain. We will not wait
+ * for an I/O buffer to become available in this context. It there is
+ * any failure to allocated, the entire I/O buffer chain will be discarded.
+ */
+
+ addrsize = sizeof(struct sockaddr_in);
+ ret = iob_trycopyin(iob, &addrsize, sizeof(uint8_t), 0, true);
+ if (ret < 0)
+ {
+ /* On a failure, iob_trycopyin return a negated error value but does
+ * not free any I/O buffers.
+ */
+
+ nerr("ERROR: Failed to length to the I/O buffer chain: %d\n", ret);
+ (void)iob_free_chain(iob);
+ return 0;
+ }
+
+ offset = sizeof(uint8_t);
+
+ ret = iob_trycopyin(iob, (FAR const uint8_t *)&inaddr,
+ sizeof(struct sockaddr_in), offset, true);
+ if (ret < 0)
+ {
+ /* On a failure, iob_trycopyin return a negated error value but does
+ * not free any I/O buffers.
+ */
+
+ nerr("ERROR: Failed to source address to the I/O buffer chain: %d\n", ret);
+ (void)iob_free_chain(iob);
+ return 0;
+ }
+
+ offset += sizeof(struct sockaddr_in);
+
+ /* Copy the new ICMP reply into the I/O buffer chain (without waiting) */
+
+ buflen = ICMPSIZE;
+ ret = iob_trycopyin(iob, (FAR uint8_t *)ICMPBUF, buflen, offset, true);
+ if (ret < 0)
+ {
+ /* On a failure, iob_copyin return a negated error value but does
+ * not free any I/O buffers.
+ */
+
+ nerr("ERROR: Failed to add data to the I/O buffer chain: %d\n", ret);
+ (void)iob_free_chain(iob);
+ return 0;
+ }
+
+ /* Add the new I/O buffer chain to the tail of the read-ahead queue (again
+ * without waiting).
+ */
+
+ ret = iob_tryadd_queue(iob, &conn->readahead);
+ if (ret < 0)
+ {
+ nerr("ERROR: Failed to queue the I/O buffer chain: %d\n", ret);
+ (void)iob_free_chain(iob);
+ return 0;
+ }
+
+ ninfo("Buffered %d bytes\n", buflen + addrsize + 1);
+ return buflen;
+}
+#endif
/****************************************************************************
* Public Functions
@@ -92,7 +219,7 @@
void icmp_input(FAR struct net_driver_s *dev)
{
- FAR struct icmp_iphdr_s *picmp = ICMPBUF;
+ FAR struct icmp_iphdr_s *ipicmp = IPICMPBUF;
#ifdef CONFIG_NET_STATISTICS
g_netstats.icmp.recv++;
@@ -103,45 +230,46 @@ void icmp_input(FAR struct net_driver_s *dev)
* we return the packet.
*/
- if (picmp->type == ICMP_ECHO_REQUEST)
+ if (ipicmp->type == ICMP_ECHO_REQUEST)
{
/* Change the ICMP type */
- picmp->type = ICMP_ECHO_REPLY;
+ ipicmp->type = ICMP_ECHO_REPLY;
/* Swap IP addresses. */
- net_ipv4addr_hdrcopy(picmp->destipaddr, picmp->srcipaddr);
- net_ipv4addr_hdrcopy(picmp->srcipaddr, &dev->d_ipaddr);
+ net_ipv4addr_hdrcopy(ipicmp->destipaddr, ipicmp->srcipaddr);
+ net_ipv4addr_hdrcopy(ipicmp->srcipaddr, &dev->d_ipaddr);
/* Recalculate the ICMP checksum */
#if 0
/* The slow way... sum over the ICMP message */
- picmp->icmpchksum = 0;
- picmp->icmpchksum = ~icmp_chksum(dev, (((uint16_t)picmp->len[0] << 8) | (uint16_t)picmp->len[1]) - IPv4_HDRLEN);
- if (picmp->icmpchksum == 0)
+ ipicmp->icmpchksum = 0;
+ ipicmp->icmpchksum = ~icmp_chksum(dev, (((uint16_t)ipicmp->len[0] << 8) |
+ (uint16_t)ipicmp->len[1]) - IPv4_HDRLEN);
+ if (ipicmp->icmpchksum == 0)
{
- picmp->icmpchksum = 0xffff;
+ ipicmp->icmpchksum = 0xffff;
}
#else
/* The quick way -- Since only the type has changed, just adjust the
* checksum for the change of type
*/
- if (picmp->icmpchksum >= HTONS(0xffff - (ICMP_ECHO_REQUEST << 8)))
+ if (ipicmp->icmpchksum >= HTONS(0xffff - (ICMP_ECHO_REQUEST << 8)))
{
- picmp->icmpchksum += HTONS(ICMP_ECHO_REQUEST << 8) + 1;
+ ipicmp->icmpchksum += HTONS(ICMP_ECHO_REQUEST << 8) + 1;
}
else
{
- picmp->icmpchksum += HTONS(ICMP_ECHO_REQUEST << 8);
+ ipicmp->icmpchksum += HTONS(ICMP_ECHO_REQUEST << 8);
}
#endif
ninfo("Outgoing ICMP packet length: %d (%d)\n",
- dev->d_len, (picmp->len[0] << 8) | picmp->len[1]);
+ dev->d_len, (ipicmp->len[0] << 8) | ipicmp->len[1]);
#ifdef CONFIG_NET_STATISTICS
g_netstats.icmp.sent++;
@@ -149,14 +277,48 @@ void icmp_input(FAR struct net_driver_s *dev)
#endif
}
+#ifdef CONFIG_NET_ICMP_SOCKET
/* If an ICMP echo reply is received then there should also be
* a thread waiting to received the echo response.
*/
-#ifdef CONFIG_NET_ICMP_PING
- else if (picmp->type == ICMP_ECHO_REPLY && dev->d_conncb)
+ else if (ipicmp->type == ICMP_ECHO_REPLY)
{
- (void)devif_conn_event(dev, picmp, ICMP_ECHOREPLY, dev->d_conncb);
+ uint16_t flags;
+
+ flags = devif_conn_event(dev, ipicmp, ICMP_ECHOREPLY, dev->d_conncb);
+ if ((flags & ICMP_ECHOREPLY) != 0)
+ {
+ FAR struct icmp_conn_s *conn;
+ uint16_t nbuffered;
+
+ /* Nothing consumed the ICMP reply. That might because this is
+ * an old, invalid reply or simply because the ping application
+ * has not yet put its poll or recv in place.
+ */
+
+ /* Is there any connection that might expect this reply? */
+
+ conn = icmp_findconn(dev, ipicmp->id);
+ if (conn == NULL)
+ {
+ /* No.. drop the packet */
+
+ goto drop;
+ }
+
+ /* Add the ICMP echo reply to the IPPROTO_ICMP socket read-ahead
+ * buffer.
+ */
+
+ nbuffered = icmp_datahandler(dev, conn);
+ if (nbuffered == 0)
+ {
+ /* Could not buffer the data.. drop the packet */
+
+ goto drop;
+ }
+ }
}
#endif
@@ -164,7 +326,7 @@ void icmp_input(FAR struct net_driver_s *dev)
else
{
- nwarn("WARNING: Unknown ICMP cmd: %d\n", picmp->type);
+ nwarn("WARNING: Unknown ICMP cmd: %d\n", ipicmp->type);
goto typeerr;
}
@@ -173,6 +335,10 @@ void icmp_input(FAR struct net_driver_s *dev)
typeerr:
#ifdef CONFIG_NET_STATISTICS
g_netstats.icmp.typeerr++;
+#endif
+
+drop:
+#ifdef CONFIG_NET_STATISTICS
g_netstats.icmp.drop++;
#endif
dev->d_len = 0;
diff --git a/net/icmp/icmp_netpoll.c b/net/icmp/icmp_netpoll.c
new file mode 100644
index 00000000000..07eb229c8a1
--- /dev/null
+++ b/net/icmp/icmp_netpoll.c
@@ -0,0 +1,311 @@
+/****************************************************************************
+ * net/icmp/icmp_netpoll.c
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+#include "icmp/icmp.h"
+
+#ifdef CONFIG_MM_IOB
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/* This is an allocated container that holds the poll-related information */
+
+struct icmp_poll_s
+{
+ struct pollfd *fds; /* Needed to handle poll events */
+ FAR struct devif_callback_s *cb; /* Needed to teardown the poll */
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: icmp_poll_eventhandler
+ *
+ * Description:
+ * This function is called to perform the actual UDP receive operation
+ * via the device interface layer.
+ *
+ * Parameters:
+ * dev The structure of the network driver that caused the event
+ * conn The connection structure associated with the socket
+ * flags Set of events describing why the callback was invoked
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * This function must be called with the network locked.
+ *
+ ****************************************************************************/
+
+static uint16_t icmp_poll_eventhandler(FAR struct net_driver_s *dev,
+ FAR void *pvconn,
+ FAR void *pvpriv, uint16_t flags)
+{
+ FAR struct icmp_poll_s *info = (FAR struct icmp_poll_s *)pvpriv;
+ FAR struct icmp_conn_s *conn = (FAR struct icmp_conn_s *)pvconn;
+ pollevent_t eventset;
+
+ ninfo("flags: %04x\n", flags);
+
+ DEBUGASSERT(info == NULL || (info->fds != NULL && conn != NULL));
+
+ /* 'priv' might be null in some race conditions (?). Only process the
+ * the event if this poll is from the same device that the request was
+ * sent out on.
+ */
+
+ if (info != NULL && dev == conn->dev)
+ {
+ /* Check for data or connection availability events. */
+
+ eventset = 0;
+ if ((flags & ICMP_ECHOREPLY) != 0)
+ {
+ eventset |= (POLLIN & info->fds->events);
+ }
+
+ /* ICMP_POLL is a sign that we are free to send data. */
+
+ if ((flags & ICMP_POLL) != 0)
+ {
+ eventset |= (POLLOUT & info->fds->events);
+ }
+
+ /* Check for loss of connection events. */
+
+ if ((flags & NETDEV_DOWN) != 0)
+ {
+ eventset |= ((POLLHUP | POLLERR) & info->fds->events);
+ }
+
+ /* Awaken the caller of poll() is requested event occurred. */
+
+ if (eventset)
+ {
+ info->fds->revents |= eventset;
+ nxsem_post(info->fds->sem);
+ }
+ }
+
+ return flags;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: icmp_pollsetup
+ *
+ * Description:
+ * Setup to monitor events on one UDP/IP socket
+ *
+ * Input Parameters:
+ * psock - The UDP/IP socket of interest
+ * fds - The structure describing the events to be monitored, OR NULL if
+ * this is a request to stop monitoring events.
+ *
+ * Returned Value:
+ * 0: Success; Negated errno on failure
+ *
+ ****************************************************************************/
+
+int icmp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
+{
+ FAR struct icmp_conn_s *conn = psock->s_conn;
+ FAR struct icmp_poll_s *info;
+ FAR struct devif_callback_s *cb;
+ int ret;
+
+ DEBUGASSERT(conn != NULL && fds != NULL && conn->dev != NULL);
+
+ /* Allocate a container to hold the poll information */
+
+ info = (FAR struct icmp_poll_s *)kmm_malloc(sizeof(struct icmp_poll_s));
+ if (!info)
+ {
+ return -ENOMEM;
+ }
+
+ /* Some of the following must be atomic */
+
+ net_lock();
+
+ /* Get the device that will provide the provide the NETDEV_DOWN event.
+ * NOTE: in the event that the local socket is bound to INADDR_ANY, the
+ * dev value will be zero and there will be no NETDEV_DOWN notifications.
+ */
+
+ /* Allocate a ICMP callback structure */
+
+ cb = icmp_callback_alloc(conn->dev);
+ if (cb == NULL)
+ {
+ ret = -EBUSY;
+ goto errout_with_lock;
+ }
+
+ /* Initialize the poll info container */
+
+ info->fds = fds;
+ info->cb = cb;
+
+ /* Initialize the callback structure. Save the reference to the info
+ * structure as callback private data so that it will be available during
+ * callback processing.
+ */
+
+ cb->flags = 0;
+ cb->priv = (FAR void *)info;
+ cb->event = icmp_poll_eventhandler;
+
+ if ((info->fds->events & POLLOUT) != 0)
+ {
+ cb->flags |= UDP_POLL;
+ }
+
+ if ((info->fds->events & POLLIN) != 0)
+ {
+ cb->flags |= UDP_NEWDATA;
+ }
+
+ if ((info->fds->events & (POLLHUP | POLLERR)) != 0)
+ {
+ cb->flags |= NETDEV_DOWN;
+ }
+
+ /* Save the reference in the poll info structure as fds private as well
+ * for use during poll teardown as well.
+ */
+
+ fds->priv = (FAR void *)info;
+
+ /* Check for read data availability now */
+
+ if (!IOB_QEMPTY(&conn->readahead))
+ {
+ /* Normal data may be read without blocking. */
+
+ fds->revents |= (POLLRDNORM & fds->events);
+ }
+
+ /* Check if any requested events are already in effect */
+
+ if (fds->revents != 0)
+ {
+ /* Yes.. then signal the poll logic */
+
+ nxsem_post(fds->sem);
+ }
+
+ net_unlock();
+ return OK;
+
+errout_with_lock:
+ kmm_free(info);
+ net_unlock();
+ return ret;
+}
+
+/****************************************************************************
+ * Name: icmp_pollteardown
+ *
+ * Description:
+ * Teardown monitoring of events on an UDP/IP socket
+ *
+ * Input Parameters:
+ * psock - The IPPROTO_ICMP socket of interest
+ * fds - The structure describing the events to be monitored, OR NULL if
+ * this is a request to stop monitoring events.
+ *
+ * Returned Value:
+ * 0: Success; Negated errno on failure
+ *
+ ****************************************************************************/
+
+int icmp_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds)
+{
+ FAR struct icmp_conn_s *conn;
+ FAR struct icmp_poll_s *info;
+
+ DEBUGASSERT(psock != NULL && psock->s_conn != NULL &&
+ fds != NULL && fds->priv != NULL);
+
+ conn = psock->s_conn;
+
+ /* Recover the socket descriptor poll state info from the poll structure */
+
+ info = (FAR struct icmp_poll_s *)fds->priv;
+ DEBUGASSERT(info != NULL && info->fds != NULL && info->cb != NULL);
+
+ if (info != NULL)
+ {
+ /* Release the callback */
+
+ net_lock();
+ icmp_callback_free(conn->dev, info->cb);
+ net_unlock();
+
+ /* Release the poll/select data slot */
+
+ info->fds->priv = NULL;
+
+ /* Then free the poll info container */
+
+ kmm_free(info);
+ }
+
+ return OK;
+}
+
+#endif /* !CONFIG_MM_IOB */
diff --git a/net/icmp/icmp_ping.c b/net/icmp/icmp_ping.c
deleted file mode 100644
index e9d56c5eb8d..00000000000
--- a/net/icmp/icmp_ping.c
+++ /dev/null
@@ -1,427 +0,0 @@
-/****************************************************************************
- * net/icmp/icmp_ping.c
- *
- * Copyright (C) 2008-2012, 2014-2016 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include
-#if defined(CONFIG_NET) && defined(CONFIG_NET_ICMP) && \
- defined(CONFIG_NET_ICMP_PING)
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "netdev/netdev.h"
-#include "devif/devif.h"
-#include "arp/arp.h"
-#include "icmp/icmp.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define ICMPBUF ((struct icmp_iphdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
-#define ICMPDAT (&dev->d_buf[NET_LL_HDRLEN(dev) + sizeof(struct icmp_iphdr_s)])
-
-/* Allocate a new ICMP data callback */
-
-#define icmp_callback_alloc(dev) devif_callback_alloc(dev, &(dev)->d_conncb)
-#define icmp_callback_free(dev,cb) devif_dev_callback_free(dev, cb)
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-struct icmp_ping_s
-{
- FAR struct devif_callback_s *png_cb; /* Reference to callback instance */
-
- sem_t png_sem; /* Use to manage the wait for the response */
- systime_t png_time; /* Start time for determining timeouts */
- systime_t png_ticks; /* System clock ticks to wait */
- int png_result; /* 0: success; <0:negated errno on fail */
- in_addr_t png_addr; /* The peer to be ping'ed */
- uint16_t png_id; /* Used to match requests with replies */
- uint16_t png_seqno; /* IN: seqno to send; OUT: seqno received */
- uint16_t png_datlen; /* The length of data to send in the ECHO request */
- bool png_sent; /* true... the PING request has been sent */
-};
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: ping_timeout
- *
- * Description:
- * Check for send timeout.
- *
- * Parameters:
- * pstate - Ping state structure
- *
- * Returned Value:
- * TRUE:timeout FALSE:no timeout
- *
- * Assumptions:
- * The network is locked
- *
- ****************************************************************************/
-
-static inline int ping_timeout(FAR struct icmp_ping_s *pstate)
-{
- systime_t elapsed = clock_systimer() - pstate->png_time;
- if (elapsed >= pstate->png_ticks)
- {
- return TRUE;
- }
-
- return FALSE;
-}
-
-/****************************************************************************
- * Name: ping_eventhandler
- *
- * Description:
- * This function is called from the interrupt level to perform the actual
- * ECHO request and/or ECHO reply actions when polled by the lower, device
- * interfacing layer.
- *
- * Parameters:
- * dev The structure of the network driver that caused the interrupt
- * conn The received packet, cast to void *
- * pvpriv An instance of struct icmp_ping_s cast to void*
- * flags Set of events describing why the callback was invoked
- *
- * Returned Value:
- * Modified value of the input flags
- *
- * Assumptions:
- * The network is locked.
- *
- ****************************************************************************/
-
-static uint16_t ping_eventhandler(FAR struct net_driver_s *dev,
- FAR void *conn,
- FAR void *pvpriv, uint16_t flags)
-{
- FAR struct icmp_ping_s *pstate = (struct icmp_ping_s *)pvpriv;
- FAR uint8_t *ptr;
- int i;
-
- ninfo("flags: %04x\n", flags);
-
- if (pstate)
- {
- /* Check if the network is still up */
-
- if ((flags & NETDEV_DOWN) != 0)
- {
- nerr("ERROR: Interface is down\n");
- pstate->png_result = -ENETUNREACH;
- goto end_wait;
- }
-
- /* Check if this is a ICMP ECHO reply. If so, return the sequence
- * number to the caller. NOTE: We may not even have sent the
- * requested ECHO request; this could have been the delayed ECHO
- * response from a previous ping.
- */
-
- else if ((flags & ICMP_ECHOREPLY) != 0 && conn != NULL)
- {
- FAR struct icmp_iphdr_s *icmp = (FAR struct icmp_iphdr_s *)conn;
-
- ninfo("ECHO reply: id=%d seqno=%d\n",
- ntohs(icmp->id), ntohs(icmp->seqno));
-
- if (ntohs(icmp->id) == pstate->png_id)
- {
- /* Consume the ECHOREPLY */
-
- flags &= ~ICMP_ECHOREPLY;
- dev->d_len = 0;
-
- /* Return the result to the caller */
-
- pstate->png_result = OK;
- pstate->png_seqno = ntohs(icmp->seqno);
- goto end_wait;
- }
- }
-
- /* Check:
- * If the outgoing packet is available (it may have been claimed
- * by a sendto interrupt serving a different thread)
- * -OR-
- * If the output buffer currently contains unprocessed incoming
- * data.
- * -OR-
- * If we have already sent the ECHO request
- *
- * In the first two cases, we will just have to wait for the next
- * polling cycle.
- */
-
- if (dev->d_sndlen <= 0 && /* Packet available */
- (flags & ICMP_NEWDATA) == 0 && /* No incoming data */
- !pstate->png_sent) /* Request not sent */
- {
- FAR struct icmp_iphdr_s *picmp = ICMPBUF;
-
- /* We can send the ECHO request now.
- *
- * Format the ICMP ECHO request packet
- */
-
- picmp->type = ICMP_ECHO_REQUEST;
- picmp->icode = 0;
- picmp->id = htons(pstate->png_id);
- picmp->seqno = htons(pstate->png_seqno);
-
- /* Add some easily verifiable data */
-
- for (i = 0, ptr = ICMPDAT; i < pstate->png_datlen; i++)
- {
- *ptr++ = i;
- }
-
- /* Send the ICMP echo request. Note that d_sndlen is set to
- * the size of the ICMP payload and does not include the size
- * of the ICMP header.
- */
-
- ninfo("Send ECHO request: seqno=%d\n", pstate->png_seqno);
-
- dev->d_sndlen = pstate->png_datlen + 4;
- icmp_send(dev, &pstate->png_addr);
-
- pstate->png_sent = true;
- return flags;
- }
-
- /* Check if the selected timeout has elapsed */
-
- if (ping_timeout(pstate))
- {
- int failcode;
-
- /* Check if this device is on the same network as the destination
- * device.
- */
-
- if (!net_ipv4addr_maskcmp(pstate->png_addr, dev->d_ipaddr, dev->d_netmask))
- {
- /* Destination address was not on the local network served by this
- * device. If a timeout occurs, then the most likely reason is
- * that the destination address is not reachable.
- */
-
- nerr("ERROR:Not reachable\n");
- failcode = -ENETUNREACH;
- }
- else
- {
- nerr("ERROR:Ping timeout\n");
- failcode = -ETIMEDOUT;
- }
-
- /* Report the failure */
-
- pstate->png_result = failcode;
- goto end_wait;
- }
-
- /* Continue waiting */
- }
-
- return flags;
-
-end_wait:
- ninfo("Resuming\n");
-
- /* Do not allow any further callbacks */
-
- pstate->png_cb->flags = 0;
- pstate->png_cb->priv = NULL;
- pstate->png_cb->event = NULL;
-
- /* Wake up the waiting thread */
-
- nxsem_post(&pstate->png_sem);
- return flags;
-}
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: imcp_ping
- *
- * Description:
- * Send a ECHO request and wait for the ECHO response
- *
- * Parameters:
- * addr - The IP address of the peer to send the ICMP ECHO request to
- * in network order.
- * id - The ID to use in the ICMP ECHO request. This number should be
- * unique; only ECHO responses with this matching ID will be
- * processed (host order)
- * seqno - The sequence number used in the ICMP ECHO request. NOT used
- * to match responses (host order)
- * dsecs - Wait up to this many deci-seconds for the ECHO response to be
- * returned (host order).
- *
- * Return:
- * seqno of received ICMP ECHO with matching ID (may be different
- * from the seqno argument (may be a delayed response from an earlier
- * ping with the same ID). Or a negated errno on any failure.
- *
- * Assumptions:
- * Called from the user level with interrupts enabled.
- *
- ****************************************************************************/
-
-int icmp_ping(in_addr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen,
- int dsecs)
-{
- FAR struct net_driver_s *dev;
- struct icmp_ping_s state;
-#ifdef CONFIG_NET_ARP_SEND
- int ret;
-#endif
-
- /* Get the device that will be used to route this ICMP ECHO request */
-
- dev = netdev_findby_ipv4addr(INADDR_ANY, addr);
- if (dev == 0)
- {
- nerr("ERROR: Not reachable\n");
- return -ENETUNREACH;
- }
-
-#ifdef CONFIG_NET_ARP_SEND
- /* Make sure that the IP address mapping is in the ARP table */
-
- ret = arp_send(addr);
- if (ret < 0)
- {
- nerr("ERROR: Not reachable\n");
- return -ENETUNREACH;
- }
-#endif
-
- /* Initialize the state structure */
-
- /* This semaphore is used for signaling and, hence, should not have
- * priority inheritance enabled.
- */
-
- nxsem_init(&state.png_sem, 0, 0);
- nxsem_setprotocol(&state.png_sem, SEM_PRIO_NONE);
-
- state.png_ticks = DSEC2TICK(dsecs); /* System ticks to wait */
- state.png_result = -ENOMEM; /* Assume allocation failure */
- state.png_addr = addr; /* Address of the peer to be ping'ed */
- state.png_id = id; /* The ID to use in the ECHO request */
- state.png_seqno = seqno; /* The seqno to use in the ECHO request */
- state.png_datlen = datalen; /* The length of data to send in the ECHO request */
- state.png_sent = false; /* ECHO request not yet sent */
-
- net_lock();
- state.png_time = clock_systimer();
-
- /* Set up the callback */
-
- state.png_cb = icmp_callback_alloc(dev);
- if (state.png_cb)
- {
- state.png_cb->flags = (ICMP_POLL | ICMP_ECHOREPLY | NETDEV_DOWN);
- state.png_cb->priv = (FAR void *)&state;
- state.png_cb->event = ping_eventhandler;
- state.png_result = -EINTR; /* Assume sem-wait interrupted by signal */
-
- /* Notify the device driver of the availability of TX data */
-
- netdev_txnotify_dev(dev);
-
- /* Wait for either the full round trip transfer to complete or
- * for timeout to occur. (1) net_lockedwait will also terminate if a
- * signal is received, (2) interrupts may be disabled! They will
- * be re-enabled while the task sleeps and automatically
- * re-enabled when the task restarts.
- */
-
- ninfo("Start time: 0x%08x seqno: %d\n", state.png_time, seqno);
- net_lockedwait(&state.png_sem);
-
- icmp_callback_free(dev, state.png_cb);
- }
-
- net_unlock();
-
- /* Return the negated error number in the event of a failure, or the
- * sequence number of the ECHO reply on success.
- */
-
- if (!state.png_result)
- {
- ninfo("Return seqno=%d\n", state.png_seqno);
- return (int)state.png_seqno;
- }
- else
- {
- nerr("ERROR: Return error=%d\n", -state.png_result);
- return state.png_result;
- }
-}
-
-#endif /* CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING ... */
diff --git a/net/icmp/icmp_poll.c b/net/icmp/icmp_poll.c
index 1075fbbe550..f86e3a6e146 100644
--- a/net/icmp/icmp_poll.c
+++ b/net/icmp/icmp_poll.c
@@ -38,7 +38,7 @@
****************************************************************************/
#include
-#if defined(CONFIG_NET) && defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING)
+#if defined(CONFIG_NET) && defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_SOCKET)
#include
@@ -57,7 +57,7 @@
* Name: icmp_poll
*
* Description:
- * Poll a UDP "connection" structure for availability of TX data
+ * Poll a device "connection" structure for availability of ICMP TX data
*
* Parameters:
* dev - The device driver structure to use in the send operation
@@ -83,4 +83,4 @@ void icmp_poll(FAR struct net_driver_s *dev)
(void)devif_conn_event(dev, NULL, ICMP_POLL, dev->d_conncb);
}
-#endif /* CONFIG_NET && CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING */
+#endif /* CONFIG_NET && CONFIG_NET_ICMP && CONFIG_NET_ICMP_SOCKET */
diff --git a/net/icmp/icmp_recvfrom.c b/net/icmp/icmp_recvfrom.c
new file mode 100644
index 00000000000..381a764d656
--- /dev/null
+++ b/net/icmp/icmp_recvfrom.c
@@ -0,0 +1,552 @@
+/****************************************************************************
+ * net/icmp/icmp_recvfrom.c
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include "devif/devif.h"
+#include "socket/socket.h"
+#include "icmp/icmp.h"
+
+#ifdef CONFIG_NET_ICMP_SOCKET
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define IPv4BUF ((struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
+#define ICMPBUF ((struct icmp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN])
+#define ICMPSIZE ((dev)->d_len - IPv4_HDRLEN)
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct icmp_recvfrom_s
+{
+ FAR struct devif_callback_s *recv_cb; /* Reference to callback instance */
+ FAR struct socket *recv_sock; /* IPPROTO_ICMP socket structure */
+ sem_t recv_sem; /* Use to manage the wait for the response */
+ systime_t recv_time; /* Start time for determining timeouts */
+ in_addr_t recv_from; /* The peer we received the request from */
+ FAR uint8_t *recv_buf; /* Location to return the response */
+ uint16_t recv_buflen; /* Size of the response */
+ int16_t recv_result; /* >=0: receive size on success;
+ * <0:negated errno on fail */
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: recvfrom_timeout
+ *
+ * Description:
+ * Check for send timeout.
+ *
+ * Parameters:
+ * pstate - Reference to instance ot recvfrom state structure
+ *
+ * Returned Value:
+ * true: timeout false: no timeout
+ *
+ * Assumptions:
+ * The network is locked
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_SOCKOPTS
+static inline int recvfrom_timeout(FAR struct icmp_recvfrom_s *pstate)
+{
+ FAR struct socket *psock;
+
+ /* Check for a timeout configured via setsockopts(SO_SNDTIMEO).
+ * If none... we will let the send wait forever.
+ */
+
+ psock = pstate->recv_sock;
+ if (psock != NULL && psock->s_rcvtimeo != 0)
+ {
+ /* Check if the configured timeout has elapsed */
+
+ return net_timeo(pstate->recv_time, psock->s_rcvtimeo);
+ }
+
+ /* No timeout */
+
+ return false;
+}
+#endif /* CONFIG_NET_SOCKOPTS */
+
+/****************************************************************************
+ * Name: recvfrom_eventhandler
+ *
+ * Description:
+ * This function is called from the interrupt level to perform the actual
+ * ECHO request and/or ECHO reply actions when polled by the lower, device
+ * interfacing layer.
+ *
+ * Parameters:
+ * dev The structure of the network driver that caused the interrupt
+ * conn The received packet, cast to void *
+ * pvpriv An instance of struct icmp_recvfrom_s cast to void*
+ * flags Set of events describing why the callback was invoked
+ *
+ * Returned Value:
+ * Modified value of the input flags
+ *
+ * Assumptions:
+ * The network is locked.
+ *
+ ****************************************************************************/
+
+static uint16_t recvfrom_eventhandler(FAR struct net_driver_s *dev,
+ FAR void *pvconn,
+ FAR void *pvpriv, uint16_t flags)
+{
+ FAR struct icmp_recvfrom_s *pstate = (struct icmp_recvfrom_s *)pvpriv;
+ FAR struct socket *psock;
+ FAR struct icmp_conn_s *conn;
+ FAR struct ipv4_hdr_s *ipv4;
+ FAR struct icmp_hdr_s *icmp;
+
+ ninfo("flags: %04x\n", flags);
+
+ if (pstate != NULL)
+ {
+ /* Check if the network is still up */
+
+ if ((flags & NETDEV_DOWN) != 0)
+ {
+ nerr("ERROR: Interface is down\n");
+ pstate->recv_result = -ENETUNREACH;
+ goto end_wait;
+ }
+
+ /* Is this a response on the same device that we sent the request out
+ * on?
+ */
+
+ psock = pstate->recv_sock;
+ DEBUGASSERT(psock != NULL && psock->s_conn != NULL);
+ conn = psock->s_conn;
+ if (dev != conn->dev)
+ {
+ ninfo("Wrong device\n");
+ return flags;
+ }
+
+ /* Check if we have just received a ICMP ECHO reply. */
+
+ if ((flags & ICMP_ECHOREPLY) != 0) /* No incoming data */
+ {
+ unsigned int recvsize;
+
+ /* Check if it is for us */
+
+ icmp = ICMPBUF;
+ if (conn->id != icmp->id)
+ {
+ ninfo("Wrong ID: %u vs %u\n", icmp->id, conn->id);
+ return flags;
+ }
+
+ ninfo("Received ICMP reply\n");
+
+ /* What should we do if the received reply is larger that the
+ * buffer that the caller of sendto provided? Truncate? Error
+ * out?
+ */
+
+ recvsize = ICMPSIZE;
+ if (recvsize > pstate->recv_buflen)
+ {
+ recvsize = pstate->recv_buflen;
+ }
+
+ /* Copy the ICMP ECHO reply to the user provided buffer */
+
+ memcpy(pstate->recv_buf, ICMPBUF, recvsize);
+
+ /* Return the size of the returned data */
+
+ DEBUGASSERT(recvsize > INT16_MAX);
+ pstate->recv_result = recvsize;
+
+ /* Return the IPv4 address of the sender from the IPv4 header */
+
+ ipv4 = IPv4BUF;
+ net_ipv4addr_hdrcopy(&pstate->recv_from, ipv4->srcipaddr);
+
+ /* Decrement the count of oustanding requests. I suppose this
+ * could have already been decremented of there were multiple
+ * threads calling sendto() or recvfrom(). If there finds, we
+ * may have to beef up the design.
+ */
+
+ DEBUGASSERT(conn->nreqs > 0);
+ conn->nreqs--;
+ goto end_wait;
+ }
+
+#ifdef CONFIG_NET_SOCKOPTS
+ /* Check if the selected timeout has elapsed */
+
+ if (recvfrom_timeout(pstate))
+ {
+ nerr("ERROR: recvfrom() timeout\n");
+ pstate->recv_result = -ETIMEDOUT;
+ goto end_wait;
+ }
+#endif
+
+ /* Continue waiting */
+ }
+
+ return flags;
+
+end_wait:
+ ninfo("Resuming\n");
+
+ /* Do not allow any further callbacks */
+
+ pstate->recv_cb->flags = 0;
+ pstate->recv_cb->priv = NULL;
+ pstate->recv_cb->event = NULL;
+
+ /* Wake up the waiting thread */
+
+ nxsem_post(&pstate->recv_sem);
+ return flags;
+}
+
+/****************************************************************************
+ * Name: icmp_readahead
+ *
+ * Description:
+ * Copy the buffered read-ahead data to the user buffer.
+ *
+ * Input Parameters:
+ * conn - IPPROTO_ICMP socket connection structure containing the read-
+ * ahead data.
+ * dev The structure of the network driver that caused the interrupt
+ * pstate recvfrom state structure
+ *
+ * Returned Value:
+ * Nunber of bytes copied to the user buffer
+ *
+ * Assumptions:
+ * The network is locked.
+ *
+ ****************************************************************************/
+
+static inline ssize_t icmp_readahead(FAR struct icmp_conn_s *conn,
+ FAR void *buf, size_t buflen,
+ FAR struct sockaddr_in *from,
+ FAR socklen_t *fromlen)
+{
+ FAR struct sockaddr_in bitbucket;
+ FAR struct iob_s *iob;
+ ssize_t ret = -ENODATA;
+ int recvlen;
+
+ /* Check there is any ICMP replies already buffered in a read-ahead buffer. */
+
+ if ((iob = iob_peek_queue(&conn->readahead)) != NULL)
+ {
+ FAR struct iob_s *tmp;
+ uint16_t offset;
+ uint8_t addrsize;
+
+ DEBUGASSERT(iob->io_pktlen > 0);
+
+ /* Transfer that buffered data from the I/O buffer chain into
+ * the user buffer.
+ */
+
+ /* First get the size of the address */
+
+ recvlen = iob_copyout(&addrsize, iob, sizeof(uint8_t), 0);
+ if (recvlen != sizeof(uint8_t))
+ {
+ ret = -EIO;
+ goto out;
+ }
+
+ offset = sizeof(uint8_t);
+
+ if (addrsize > sizeof(struct sockaddr_in))
+ {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ /* Then get address */
+
+ if (from == NULL)
+ {
+ from = &bitbucket;
+ }
+
+ recvlen = iob_copyout((FAR uint8_t *)from, iob, addrsize, offset);
+ if (recvlen != addrsize)
+ {
+ ret = -EIO;
+ goto out;
+ }
+
+ if (fromlen != NULL)
+ {
+ *fromlen = addrsize;
+ }
+
+ offset += addrsize;
+
+ /* And finally, get the buffered data */
+
+ ret = (ssize_t)iob_copyout(buf, iob, buflen, offset);
+
+ ninfo("Received %ld bytes (of %u)\n", (long)ret, iob->io_pktlen);
+
+out:
+ /* Remove the I/O buffer chain from the head of the read-ahead
+ * buffer queue.
+ */
+
+ tmp = iob_remove_queue(&conn->readahead);
+ DEBUGASSERT(tmp == iob);
+ UNUSED(tmp);
+
+ /* And free the I/O buffer chain */
+
+ (void)iob_free_chain(iob);
+ }
+
+ return ret;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: icmp_recvfrom
+ *
+ * Description:
+ * Implements the socket recvfrom interface for the case of the AF_INET
+ * data gram socket with the IPPROTO_ICMP protocol. icmp_recvfrom()
+ * receives ICMP ECHO replies for the a socket.
+ *
+ * If 'from' is not NULL, and the underlying protocol provides the source
+ * address, this source address is filled in. The argument 'fromlen' is
+ * initialized to the size of the buffer associated with from, and
+ * modified on return to indicate the actual size of the address stored
+ * there.
+ *
+ * Input Parameters:
+ * psock A pointer to a NuttX-specific, internal socket structure
+ * buf Buffer to receive data
+ * len Length of buffer
+ * flags Receive flags
+ * from Address of source (may be NULL)
+ * fromlen The length of the address structure
+ *
+ * Returned Value:
+ * On success, returns the number of characters received. If no data is
+ * available to be received and the peer has performed an orderly shutdown,
+ * recv() will return 0. Otherwise, on errors, a negated errno value is
+ * returned (see recvfrom() for the list of appropriate error values).
+ *
+ ****************************************************************************/
+
+ssize_t icmp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
+ int flags, FAR struct sockaddr *from,
+ FAR socklen_t *fromlen)
+{
+ FAR struct sockaddr_in *inaddr;
+ FAR struct icmp_conn_s *conn;
+ FAR struct net_driver_s *dev;
+ struct icmp_recvfrom_s state;
+ ssize_t ret;
+
+ /* Some sanity checks */
+
+ DEBUGASSERT(psock != NULL && psock->s_conn != NULL && buf != NULL);
+
+ if (len < ICMP_HDRLEN)
+ {
+ return -EINVAL;
+ }
+
+ /* If a 'from' address has been provided, verify that it is large
+ * enough to hold the AF_INET address.
+ */
+
+ if (from != NULL)
+ {
+ if (fromlen == NULL && *fromlen < sizeof(struct sockaddr_in))
+ {
+ return -EINVAL;
+ }
+ }
+
+ /* We cannot receive a response from a device until a request has been
+ * sent to the devivce.
+ */
+
+ conn = psock->s_conn;
+ if (conn->nreqs < 1)
+ {
+ ret = -EPROTO;
+ goto errout;
+ }
+
+ /* Check if there is buffered read-ahead data for this socket. We may have
+ * already received the reponse to previous command.
+ */
+
+ if (!IOB_QEMPTY(&conn->readahead))
+ {
+ return icmp_readahead(conn, buf, len,
+ (FAR struct sockaddr_in *)from, fromlen);
+ }
+
+ /* Initialize the state structure */
+
+ memset(&state, 0, sizeof(struct icmp_recvfrom_s));
+
+ /* This semaphore is used for signaling and, hence, should not have
+ * priority inheritance enabled.
+ */
+
+ nxsem_init(&state.recv_sem, 0, 0);
+ nxsem_setprotocol(&state.recv_sem, SEM_PRIO_NONE);
+
+ state.recv_sock = psock; /* The IPPROTO_ICMP socket instance */
+ state.recv_result = -ENOMEM; /* Assume allocation failure */
+ state.recv_buf = buf; /* Location to return the response */
+ state.recv_buflen = len; /* Size of the response */
+
+ net_lock();
+ state.recv_time = clock_systimer();
+
+ /* Get the device that was used to send the ICMP request. */
+
+ dev = conn->dev;
+ DEBUGASSERT(dev != NULL);
+ if (dev == NULL)
+ {
+ ret = -EPROTO;
+ goto errout;
+ }
+
+ /* Set up the callback */
+
+ state.recv_cb = icmp_callback_alloc(dev);
+ if (state.recv_cb)
+ {
+ state.recv_cb->flags = (ICMP_ECHOREPLY | NETDEV_DOWN);
+ state.recv_cb->priv = (FAR void *)&state;
+ state.recv_cb->event = recvfrom_eventhandler;
+ state.recv_result = -EINTR; /* Assume sem-wait interrupted by signal */
+
+ /* Wait for either the response to be received or for timeout to
+ * occur. (1) net_lockedwait will also terminate if a signal is
+ * received, (2) interrupts may be disabled! They will be re-enabled
+ * while the task sleeps and automatically re-enabled when the task
+ * restarts.
+ */
+
+ ninfo("Start time: 0x%08x\n", state.recv_time);
+ net_lockedwait(&state.recv_sem);
+
+ icmp_callback_free(dev, state.recv_cb);
+ }
+
+ net_unlock();
+
+ /* Return the negated error number in the event of a failure, or the
+ * number of bytes received on success.
+ */
+
+ if (state.recv_result < 0)
+ {
+ nerr("ERROR: Return error=%d\n", state.recv_result);
+ ret = state.recv_result;
+ goto errout;
+ }
+
+ if (from != NULL)
+ {
+ inaddr = (FAR struct sockaddr_in *)from;
+ inaddr->sin_family = AF_INET;
+ inaddr->sin_port = INADDR_ANY;
+
+ net_ipv4addr_copy(inaddr->sin_addr.s_addr, state.recv_from);
+ }
+
+ ret = state.recv_result;
+
+ /* If there a no further outstanding requests, make sure that the request
+ * struct is left pristine.
+ */
+
+errout:
+ if (conn->nreqs < 1)
+ {
+ conn->id = 0;
+ conn->nreqs = 0;
+ conn->dev = NULL;
+
+ iob_free_queue(&conn->readahead);
+ }
+
+ return ret;
+}
+
+#endif /* CONFIG_NET_ICMP_SOCKET */
diff --git a/net/icmp/icmp_send.c b/net/icmp/icmp_send.c
deleted file mode 100644
index 38d737db8af..00000000000
--- a/net/icmp/icmp_send.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/****************************************************************************
- * net/icmp/icmp_send.c
- *
- * Copyright (C) 2008-2010, 2012, 2014 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include
-#if defined(CONFIG_NET) && defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING)
-
-#include
-
-#include
-
-#include
-#include
-#include
-#include
-
-#include "devif/devif.h"
-#include "inet/inet.h"
-#include "utils/utils.h"
-#include "icmp/icmp.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define ICMPBUF ((struct icmp_iphdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: icmp_send
- *
- * Description:
- * Setup to send an ICMP packet
- *
- * Parameters:
- * dev - The device driver structure to use in the send operation
- *
- * Return:
- * None
- *
- * Assumptions:
- * The network is locked.
- *
- ****************************************************************************/
-
-void icmp_send(FAR struct net_driver_s *dev, FAR in_addr_t *destaddr)
-{
- FAR struct icmp_iphdr_s *picmp = ICMPBUF;
-
- if (dev->d_sndlen > 0)
- {
- IFF_SET_IPv4(dev->d_flags);
-
- /* The total length to send is the size of the application data plus
- * the IP and ICMP headers (and, eventually, the Ethernet header)
- */
-
- dev->d_len = dev->d_sndlen + IPICMP_HDRLEN;
-
- /* The total size of the data (for ICMP checksum calculation) includes
- * the size of the ICMP header
- */
-
- dev->d_sndlen += ICMP_HDRLEN;
-
- /* Initialize the IP header. */
-
- picmp->vhl = 0x45;
- picmp->tos = 0;
- picmp->len[0] = (dev->d_len >> 8);
- picmp->len[1] = (dev->d_len & 0xff);
- ++g_ipid;
- picmp->ipid[0] = g_ipid >> 8;
- picmp->ipid[1] = g_ipid & 0xff;
- picmp->ipoffset[0] = IP_FLAG_DONTFRAG >> 8;
- picmp->ipoffset[1] = IP_FLAG_DONTFRAG & 0xff;
- picmp->ttl = IP_TTL;
- picmp->proto = IP_PROTO_ICMP;
-
- net_ipv4addr_hdrcopy(picmp->srcipaddr, &dev->d_ipaddr);
- net_ipv4addr_hdrcopy(picmp->destipaddr, destaddr);
-
- /* Calculate IP checksum. */
-
- picmp->ipchksum = 0;
- picmp->ipchksum = ~(ipv4_chksum(dev));
-
- /* Calculate the ICMP checksum. */
-
- picmp->icmpchksum = 0;
- picmp->icmpchksum = ~(icmp_chksum(dev, dev->d_sndlen));
- if (picmp->icmpchksum == 0)
- {
- picmp->icmpchksum = 0xffff;
- }
-
- ninfo("Outgoing ICMP packet length: %d (%d)\n",
- dev->d_len, (picmp->len[0] << 8) | picmp->len[1]);
-
-#ifdef CONFIG_NET_STATISTICS
- g_netstats.icmp.sent++;
- g_netstats.ipv4.sent++;
-#endif
- }
-}
-
-#endif /* CONFIG_NET && CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING */
diff --git a/net/icmp/icmp_sendto.c b/net/icmp/icmp_sendto.c
new file mode 100644
index 00000000000..11e10b26c10
--- /dev/null
+++ b/net/icmp/icmp_sendto.c
@@ -0,0 +1,514 @@
+/****************************************************************************
+ * net/icmp/icmp_sendto.c
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "utils/utils.h"
+#include "socket/socket.h"
+#include "netdev/netdev.h"
+#include "devif/devif.h"
+#include "inet/inet.h"
+#include "arp/arp.h"
+#include "icmp/icmp.h"
+
+#ifdef CONFIG_NET_ICMP_SOCKET
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define IPv4BUF ((struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
+#define ICMPBUF ((struct icmp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN])
+#define ICMPDAT (&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN + ICMP_DHRLEN])
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct icmp_sendto_s
+{
+ FAR struct devif_callback_s *snd_cb; /* Reference to callback instance */
+ FAR struct socket *snd_sock; /* IPPROTO_ICMP socket structure */
+ sem_t snd_sem; /* Use to manage the wait for send complete */
+ systime_t snd_time; /* Start time for determining timeouts */
+ in_addr_t snd_toaddr; /* The peer to send the request to */
+ FAR const uint8_t *snd_buf; /* ICMP header + data payload */
+ uint16_t snd_buflen; /* Size of the ICMP header + data payload */
+ int16_t snd_result; /* 0: success; <0:negated errno on fail */
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sendto_timeout
+ *
+ * Description:
+ * Check for send timeout.
+ *
+ * Parameters:
+ * pstate - Reference to instance ot sendto state structure
+ *
+ * Returned Value:
+ * true: timeout false: no timeout
+ *
+ * Assumptions:
+ * The network is locked
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_SOCKOPTS
+static inline int sendto_timeout(FAR struct icmp_sendto_s *pstate)
+{
+ FAR struct socket *psock;
+
+ /* Check for a timeout configured via setsockopts(SO_SNDTIMEO).
+ * If none... we will let the send wait forever.
+ */
+
+ psock = pstate->snd_sock;
+ if (psock != NULL && psock->s_sndtimeo != 0)
+ {
+ /* Check if the configured timeout has elapsed */
+
+ return net_timeo(pstate->snd_time, psock->s_sndtimeo);
+ }
+
+ /* No timeout */
+
+ return false;
+}
+#endif /* CONFIG_NET_SOCKOPTS */
+
+/****************************************************************************
+ * Name: sendto_request
+ *
+ * Description:
+ * Setup to send an ICMP request packet
+ *
+ * Parameters:
+ * dev - The device driver structure to use in the send operation
+ * pstate - Reference to an instance of the ICMP sendto state structure
+ *
+ * Return:
+ * None
+ *
+ * Assumptions:
+ * The network is locked.
+ *
+ ****************************************************************************/
+
+static void sendto_request(FAR struct net_driver_s *dev,
+ FAR struct icmp_sendto_s *pstate)
+{
+ FAR struct ipv4_hdr_s *ipv4;
+ FAR struct icmp_hdr_s *icmp;
+
+ IFF_SET_IPv4(dev->d_flags);
+
+ /* The total length to send is the size of the application data plus the
+ * IP and ICMP headers (and, eventually, the Ethernet header)
+ */
+
+ dev->d_len = IPv4_HDRLEN + pstate->snd_buflen;
+
+ /* The total size of the data (including the size of the ICMP header) */
+
+ dev->d_sndlen += pstate->snd_buflen;
+
+ /* Initialize the IP header. */
+
+ ipv4 = IPv4BUF;
+ ipv4->vhl = 0x45;
+ ipv4->tos = 0;
+ ipv4->len[0] = (dev->d_len >> 8);
+ ipv4->len[1] = (dev->d_len & 0xff);
+ ++g_ipid;
+ ipv4->ipid[0] = g_ipid >> 8;
+ ipv4->ipid[1] = g_ipid & 0xff;
+ ipv4->ipoffset[0] = IP_FLAG_DONTFRAG >> 8;
+ ipv4->ipoffset[1] = IP_FLAG_DONTFRAG & 0xff;
+ ipv4->ttl = IP_TTL;
+ ipv4->proto = IP_PROTO_ICMP;
+
+ net_ipv4addr_hdrcopy(ipv4->srcipaddr, &dev->d_ipaddr);
+ net_ipv4addr_hdrcopy(ipv4->destipaddr, &pstate->snd_toaddr);
+
+ /* Copy the ICMP header and payload into place after the IPv4 header */
+
+ icmp = ICMPBUF;
+ memcpy(icmp, pstate->snd_buf, pstate->snd_buflen);
+
+ /* Calculate IP checksum. */
+
+ ipv4->ipchksum = 0;
+ ipv4->ipchksum = ~(ipv4_chksum(dev));
+
+ /* Calculate the ICMP checksum. */
+
+ icmp->icmpchksum = 0;
+ icmp->icmpchksum = ~(icmp_chksum(dev, pstate->snd_buflen));
+ if (icmp->icmpchksum == 0)
+ {
+ icmp->icmpchksum = 0xffff;
+ }
+
+ ninfo("Outgoing ICMP packet length: %d (%d)\n",
+ dev->d_len, (ipv4->len[0] << 8) | ipv4->len[1]);
+
+#ifdef CONFIG_NET_STATISTICS
+ g_netstats.icmp.sent++;
+ g_netstats.ipv4.sent++;
+#endif
+}
+
+/****************************************************************************
+ * Name: sendto_eventhandler
+ *
+ * Description:
+ * This function is called from the interrupt level to perform the actual
+ * ECHO request and/or ECHO reply actions when polled by the lower, device
+ * interfacing layer.
+ *
+ * Parameters:
+ * dev The structure of the network driver that caused the interrupt
+ * conn The received packet, cast to void *
+ * pvpriv An instance of struct icmp_sendto_s cast to void*
+ * flags Set of events describing why the callback was invoked
+ *
+ * Returned Value:
+ * Modified value of the input flags
+ *
+ * Assumptions:
+ * The network is locked.
+ *
+ ****************************************************************************/
+
+static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev,
+ FAR void *conn,
+ FAR void *pvpriv, uint16_t flags)
+{
+ FAR struct icmp_sendto_s *pstate = (struct icmp_sendto_s *)pvpriv;
+
+ ninfo("flags: %04x\n", flags);
+
+ if (pstate != NULL)
+ {
+ /* Check if the network is still up */
+
+ if ((flags & NETDEV_DOWN) != 0)
+ {
+ nerr("ERROR: Interface is down\n");
+ pstate->snd_result = -ENETUNREACH;
+ goto end_wait;
+ }
+
+ /* Check:
+ * If the outgoing packet is available (it may have been claimed
+ * by a sendto interrupt serving a different thread)
+ * -OR-
+ * If the output buffer currently contains unprocessed incoming
+ * data.
+ * -OR-
+ * If we have already sent the ECHO request
+ *
+ * In the first two cases, we will just have to wait for the next
+ * polling cycle.
+ */
+
+ if (dev->d_sndlen <= 0 && /* Packet available */
+ (flags & ICMP_NEWDATA) == 0) /* No incoming data */
+ {
+ /* Send the ICMP echo request. */
+
+ ninfo("Send ICMP request\n");
+
+ sendto_request(dev, pstate);
+ pstate->snd_result = OK;
+ goto end_wait;
+ }
+
+#ifdef CONFIG_NET_SOCKOPTS
+ /* Check if the selected timeout has elapsed */
+
+ if (sendto_timeout(pstate))
+ {
+ int failcode;
+
+ /* Check if this device is on the same network as the destination
+ * device.
+ */
+
+ if (!net_ipv4addr_maskcmp(pstate->snd_toaddr, dev->d_ipaddr, dev->d_netmask))
+ {
+ /* Destination address was not on the local network served by this
+ * device. If a timeout occurs, then the most likely reason is
+ * that the destination address is not reachable.
+ */
+
+ nerr("ERROR: Not reachable\n");
+ failcode = -ENETUNREACH;
+ }
+ else
+ {
+ nerr("ERROR: sendto() timeout\n");
+ failcode = -ETIMEDOUT;
+ }
+
+ /* Report the failure */
+
+ pstate->snd_result = failcode;
+ goto end_wait;
+ }
+#endif
+
+ /* Continue waiting */
+ }
+
+ return flags;
+
+end_wait:
+ ninfo("Resuming\n");
+
+ /* Do not allow any further callbacks */
+
+ pstate->snd_cb->flags = 0;
+ pstate->snd_cb->priv = NULL;
+ pstate->snd_cb->event = NULL;
+
+ /* Wake up the waiting thread */
+
+ nxsem_post(&pstate->snd_sem);
+ return flags;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: icmp_sendto
+ *
+ * Description:
+ * Implements the sendto() operation for the case of the raw packet socket.
+ * The 'buf' parameter points to a block of memory that includes an ICMP
+ * request header, followed by any payload that accompanies the request.
+ * The 'len' parameter includes both the size of the ICMP header and the
+ * followign payload.
+ *
+ * Parameters:
+ * psock A pointer to a NuttX-specific, internal socket structure
+ * buf Data to send
+ * len Length of data to send
+ * flags Send flags
+ * to Address of recipient
+ * tolen The length of the address structure
+ *
+ * Returned Value:
+ * On success, returns the number of characters sent. On error, a negated
+ * errno value is returned (see send_to() for the list of appropriate error
+ * values.
+ *
+ ****************************************************************************/
+
+ssize_t icmp_sendto(FAR struct socket *psock, FAR const void *buf, size_t len,
+ int flags, FAR const struct sockaddr *to, socklen_t tolen)
+{
+ FAR const struct sockaddr_in *inaddr;
+ FAR struct net_driver_s *dev;
+ FAR struct icmp_conn_s *conn;
+ FAR struct icmp_hdr_s *icmp;
+ struct icmp_sendto_s state;
+ int ret;
+
+ /* Some sanity checks */
+
+ DEBUGASSERT(psock != NULL && psock->s_conn != NULL &&
+ buf != NULL && to != NULL);
+
+ if (len < ICMP_HDRLEN || tolen < sizeof(struct sockaddr_in))
+ {
+ return -EINVAL;
+ }
+
+ conn = psock->s_conn;
+ inaddr = (FAR const struct sockaddr_in *)to;
+
+ /* Get the device that will be used to route this ICMP ECHO request */
+
+ dev = netdev_findby_ipv4addr(INADDR_ANY, inaddr->sin_addr.s_addr);
+ if (dev == NULL)
+ {
+ nerr("ERROR: Not reachable\n");
+ ret = -ENETUNREACH;
+ goto errout;
+ }
+
+ /* If we are no longer processing the same ping ID, then flush any pending
+ * packets from the read-ahead buffer.
+ *
+ * REVISIT: How to we free up any lingering reponses if there are no
+ * futher pings?
+ */
+
+ icmp = (FAR struct icmp_hdr_s *)buf;
+ if (icmp->type != ICMP_ECHO_REQUEST || icmp->id != conn->id ||
+ dev != conn->dev)
+ {
+ conn->id = 0;
+ conn->nreqs = 0;
+ conn->dev = NULL;
+
+ iob_free_queue(&conn->readahead);
+ }
+
+#ifdef CONFIG_NET_ARP_SEND
+ /* Make sure that the IP address mapping is in the ARP table */
+
+ ret = arp_send(inaddr->sin_addr.s_addr);
+ if (ret < 0)
+ {
+ nerr("ERROR: Not reachable\n");
+ ret = -ENETUNREACH;
+ goto errout;
+ }
+#endif
+
+ /* Initialize the state structure */
+
+ /* This semaphore is used for signaling and, hence, should not have
+ * priority inheritance enabled.
+ */
+
+ nxsem_init(&state.snd_sem, 0, 0);
+ nxsem_setprotocol(&state.snd_sem, SEM_PRIO_NONE);
+
+ state.snd_sock = psock; /* The IPPROTO_ICMP socket instance */
+ state.snd_result = -ENOMEM; /* Assume allocation failure */
+ state.snd_toaddr = inaddr->sin_addr.s_addr; /* Address of the peer to send the request */
+ state.snd_buf = buf; /* ICMP header + data payload */
+ state.snd_buflen = len; /* Size of the ICMP header + data payload */
+
+ net_lock();
+ state.snd_time = clock_systimer();
+
+ /* Set up the callback */
+
+ state.snd_cb = icmp_callback_alloc(dev);
+ if (state.snd_cb)
+ {
+ state.snd_cb->flags = (ICMP_POLL | NETDEV_DOWN);
+ state.snd_cb->priv = (FAR void *)&state;
+ state.snd_cb->event = sendto_eventhandler;
+ state.snd_result = -EINTR; /* Assume sem-wait interrupted by signal */
+
+ /* Setup to receive ICMP ECHO replies */
+
+ if (icmp->type == ICMP_ECHO_REQUEST)
+ {
+ conn->id = icmp->id;
+ conn->nreqs = 1;
+ }
+
+ conn->dev = dev;
+
+ /* Notify the device driver of the availability of TX data */
+
+ netdev_txnotify_dev(dev);
+
+ /* Wait for either the send to complete or for timeout to occur. (1)
+ * net_lockedwait will also terminate if a signal is received, (2)
+ * interrupts may be disabled! They will be re-enabled while the
+ * task sleeps and automatically re-enabled when the task restarts.
+ */
+
+ ninfo("Start time: 0x%08x\n", state.snd_time);
+ net_lockedwait(&state.snd_sem);
+
+ icmp_callback_free(dev, state.snd_cb);
+ }
+
+ net_unlock();
+
+ /* Return the negated error number in the event of a failure, or the
+ * number of bytes sent on success.
+ */
+
+ if (state.snd_result < 0)
+ {
+ nerr("ERROR: Return error=%d\n", state.snd_result);
+ ret = state.snd_result;
+ goto errout;
+ }
+
+ return len;
+
+errout:
+ conn->id = 0;
+ conn->nreqs = 0;
+ conn->dev = NULL;
+
+ iob_free_queue(&conn->readahead);
+ return ret;
+}
+
+#endif /* CONFIG_NET_ICMP_SOCKET */
diff --git a/net/icmp/icmp_sockif.c b/net/icmp/icmp_sockif.c
new file mode 100644
index 00000000000..7182eb4d45b
--- /dev/null
+++ b/net/icmp/icmp_sockif.c
@@ -0,0 +1,519 @@
+/****************************************************************************
+ * net/socket/icmp_sockif.c
+ *
+ * Copyright (C) 2017 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include "icmp/icmp.h"
+
+#ifdef CONFIG_NET_ICMP_SOCKET
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int icmp_setup(FAR struct socket *psock, int protocol);
+static sockcaps_t icmp_sockcaps(FAR struct socket *psock);
+static void icmp_addref(FAR struct socket *psock);
+static int icmp_bind(FAR struct socket *psock,
+ FAR const struct sockaddr *addr, socklen_t addrlen);
+static int icmp_getsockname(FAR struct socket *psock,
+ FAR struct sockaddr *addr, FAR socklen_t *addrlen);
+static int icmp_listen(FAR struct socket *psock, int backlog);
+static int icmp_connect(FAR struct socket *psock,
+ FAR const struct sockaddr *addr, socklen_t addrlen);
+static int icmp_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
+ FAR socklen_t *addrlen, FAR struct socket *newsock);
+#ifndef CONFIG_DISABLE_POLL
+static int icmp_netpoll(FAR struct socket *psock,
+ FAR struct pollfd *fds, bool setup);
+#endif
+static ssize_t icmp_send(FAR struct socket *psock, FAR const void *buf,
+ size_t len, int flags);
+static int icmp_close(FAR struct socket *psock);
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+const struct sock_intf_s g_icmp_sockif =
+{
+ icmp_setup, /* si_setup */
+ icmp_sockcaps, /* si_sockcaps */
+ icmp_addref, /* si_addref */
+ icmp_bind, /* si_bind */
+ icmp_getsockname, /* si_getsockname */
+ icmp_listen, /* si_listen */
+ icmp_connect, /* si_connect */
+ icmp_accept, /* si_accept */
+#ifndef CONFIG_DISABLE_POLL
+ icmp_netpoll, /* si_poll */
+#endif
+ icmp_send, /* si_send */
+ icmp_sendto, /* si_sendto */
+#ifdef CONFIG_NET_SENDFILE
+ NULL, /* si_sendfile */
+#endif
+ icmp_recvfrom, /* si_recvfrom */
+ icmp_close /* si_close */
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: icmp_setup
+ *
+ * Description:
+ * Called for socket() to verify that the provided socket type and
+ * protocol are usable by this address family. Perform any family-
+ * specific socket fields.
+ *
+ * Parameters:
+ * psock A pointer to a user allocated socket structure to be
+ * initialized.
+ * protocol (see sys/socket.h)
+ *
+ * Returned Value:
+ * Zero (OK) is returned on success. Otherwise, a negater errno value is
+ * returned.
+ *
+ ****************************************************************************/
+
+static int icmp_setup(FAR struct socket *psock, int protocol)
+{
+ /* Only SOCK_DGRAM and IPPROTO_ICMP are supported */
+
+ if (psock->s_type == SOCK_DGRAM && protocol == IPPROTO_ICMP)
+ {
+ /* Allocate the IPPROTO_ICMP socket connection structure and save in\
+ * the new socket instance.
+ */
+
+ FAR struct icmp_conn_s *conn = icmp_alloc();
+ if (conn == NULL)
+ {
+ /* Failed to reserve a connection structure */
+
+ return -ENOMEM;
+ }
+
+ /* Set the reference count on the connection structure.
+ * This reference count will be incremented only if the socket is
+ * dup'ed
+ */
+
+ DEBUGASSERT(conn->crefs == 0);
+ conn->crefs = 1;
+
+ /* Save the pre-allocated connection in the socket structure */
+
+ psock->s_conn = conn;
+ return OK;
+ }
+ else
+ {
+ return -EPROTONOSUPPORT;
+ }
+}
+
+/****************************************************************************
+ * Name: icmp_sockcaps
+ *
+ * Description:
+ * Return the bit encoded capabilities of this socket.
+ *
+ * Parameters:
+ * psock - Socket structure of the socket whose capabilities are being
+ * queried.
+ *
+ * Returned Value:
+ * The set of socket cababilities is returned.
+ *
+ ****************************************************************************/
+
+static sockcaps_t icmp_sockcaps(FAR struct socket *psock)
+{
+ return 0;
+}
+
+/****************************************************************************
+ * Name: icmp_addref
+ *
+ * Description:
+ * Increment the refernce count on the underlying connection structure.
+ *
+ * Parameters:
+ * psock - Socket structure of the socket whose reference count will be
+ * incremented.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void icmp_addref(FAR struct socket *psock)
+{
+ FAR struct icmp_conn_s *conn;
+
+ DEBUGASSERT(psock != NULL && psock->s_conn != NULL);
+
+ conn = psock->s_conn;
+ DEBUGASSERT(conn->crefs > 0 && conn->crefs < 255);
+ conn->crefs++;
+}
+
+/****************************************************************************
+ * Name: icmp_connect
+ *
+ * Description:
+ * icmp_connect() connects the local socket referred to by the structure
+ * 'psock' to the address specified by 'addr'. The addrlen argument
+ * specifies the size of 'addr'. The format of the address in 'addr' is
+ * determined by the address space of the socket 'psock'.
+ *
+ * If the socket 'psock' is of type SOCK_DGRAM then 'addr' is the address
+ * to which datagrams are sent by default, and the only address from which
+ * datagrams are received. If the socket is of type SOCK_STREAM or
+ * SOCK_SEQPACKET, this call attempts to make a connection to the socket
+ * that is bound to the address specified by 'addr'.
+ *
+ * Generally, connection-based protocol sockets may successfully
+ * icmp_connect() only once; connectionless protocol sockets may use
+ * icmp_connect() multiple times to change their association.
+ * Connectionless sockets may dissolve the association by connecting to
+ * an address with the sa_family member of sockaddr set to AF_UNSPEC.
+ *
+ * Parameters:
+ * psock Pointer to a socket structure initialized by psock_socket()
+ * addr Server address (form depends on type of socket)
+ * addrlen Length of actual 'addr'
+ *
+ * Returned Value:
+ * 0 on success; a negated errno value on failue. See connect() for the
+ * list of appropriate errno values to be returned.
+ *
+ ****************************************************************************/
+
+static int icmp_connect(FAR struct socket *psock,
+ FAR const struct sockaddr *addr, socklen_t addrlen)
+{
+ return -EAFNOSUPPORT;
+}
+
+/****************************************************************************
+ * Name: icmp_accept
+ *
+ * Description:
+ * The icmp_accept function is used with connection-based socket types
+ * (SOCK_STREAM, SOCK_SEQPACKET and SOCK_RDM). It extracts the first
+ * connection request on the queue of pending connections, creates a new
+ * connected socket with mostly the same properties as 'sockfd', and
+ * allocates a new socket descriptor for the socket, which is returned. The
+ * newly created socket is no longer in the listening state. The original
+ * socket 'sockfd' is unaffected by this call. Per file descriptor flags
+ * are not inherited across an icmp_accept.
+ *
+ * The 'sockfd' argument is a socket descriptor that has been created with
+ * socket(), bound to a local address with bind(), and is listening for
+ * connections after a call to listen().
+ *
+ * On return, the 'addr' structure is filled in with the address of the
+ * connecting entity. The 'addrlen' argument initially contains the size
+ * of the structure pointed to by 'addr'; on return it will contain the
+ * actual length of the address returned.
+ *
+ * If no pending connections are present on the queue, and the socket is
+ * not marked as non-blocking, icmp_accept blocks the caller until a
+ * connection is present. If the socket is marked non-blocking and no
+ * pending connections are present on the queue, icmp_accept returns
+ * EAGAIN.
+ *
+ * Parameters:
+ * psock Reference to the listening socket structure
+ * addr Receives the address of the connecting client
+ * addrlen Input: allocated size of 'addr', Return: returned size of 'addr'
+ * newsock Location to return the accepted socket information.
+ *
+ * Returned Value:
+ * Returns 0 (OK) on success. On failure, it returns a negated errno
+ * value. See accept() for a desrciption of the approriate error value.
+ *
+ * Assumptions:
+ * The network is locked.
+ *
+ ****************************************************************************/
+
+static int icmp_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
+ FAR socklen_t *addrlen, FAR struct socket *newsock)
+{
+ return -EAFNOSUPPORT;
+}
+
+/****************************************************************************
+ * Name: icmp_bind
+ *
+ * Description:
+ * icmp_bind() gives the socket 'psock' the local address 'addr'. 'addr'
+ * is 'addrlen' bytes long. Traditionally, this is called "assigning a
+ * name to a socket." When a socket is created with socket(), it exists
+ * in a name space (address family) but has no name assigned.
+ *
+ * Parameters:
+ * psock Socket structure of the socket to bind
+ * addr Socket local address
+ * addrlen Length of 'addr'
+ *
+ * Returned Value:
+ * 0 on success; A negated errno value is returned on failure. See
+ * bind() for a list a appropriate error values.
+ *
+ ****************************************************************************/
+
+static int icmp_bind(FAR struct socket *psock, FAR const struct sockaddr *addr,
+ socklen_t addrlen)
+{
+ /* An ICMP socket cannot be bound to a local address */
+
+ return -EBADF;
+}
+
+/****************************************************************************
+ * Name: icmp_getsockname
+ *
+ * Description:
+ * The icmp_getsockname() function retrieves the locally-bound name of the
+ * specified packet socket, stores this address in the sockaddr structure
+ * pointed to by the 'addr' argument, and stores the length of this
+ * address in the object pointed to by the 'addrlen' argument.
+ *
+ * If the actual length of the address is greater than the length of the
+ * supplied sockaddr structure, the stored address will be truncated.
+ *
+ * If the socket has not been bound to a local name, the value stored in
+ * the object pointed to by address is unspecified.
+ *
+ * Parameters:
+ * psock Socket structure of the socket to be queried
+ * addr sockaddr structure to receive data [out]
+ * addrlen Length of sockaddr structure [in/out]
+ *
+ * Returned Value:
+ * On success, 0 is returned, the 'addr' argument points to the address
+ * of the socket, and the 'addrlen' argument points to the length of the
+ * address. Otherwise, a negated errno value is returned. See
+ * getsockname() for the list of appropriate error numbers.
+ *
+ ****************************************************************************/
+
+static int icmp_getsockname(FAR struct socket *psock,
+ FAR struct sockaddr *addr, FAR socklen_t *addrlen)
+{
+ return -EAFNOSUPPORT;
+}
+
+/****************************************************************************
+ * Name: icmp_listen
+ *
+ * Description:
+ * To accept connections, a socket is first created with psock_socket(), a
+ * willingness to accept incoming connections and a queue limit for
+ * incoming connections are specified with psock_listen(), and then the
+ * connections are accepted with psock_accept(). For the case of raw
+ * packet sockets, psock_listen() calls this function. The psock_listen()
+ * call applies only to sockets of type SOCK_STREAM or SOCK_SEQPACKET.
+ *
+ * Parameters:
+ * psock Reference to an internal, boound socket structure.
+ * backlog The maximum length the queue of pending connections may grow.
+ * If a connection request arrives with the queue full, the client
+ * may receive an error with an indication of ECONNREFUSED or,
+ * if the underlying protocol supports retransmission, the request
+ * may be ignored so that retries succeed.
+ *
+ * Returned Value:
+ * On success, zero is returned. On error, a negated errno value is
+ * returned. See list() for the set of appropriate error values.
+ *
+ ****************************************************************************/
+
+int icmp_listen(FAR struct socket *psock, int backlog)
+{
+ return -EOPNOTSUPP;
+}
+
+/****************************************************************************
+ * Name: icmp_netpoll
+ *
+ * Description:
+ * The standard poll() operation redirects operations on socket descriptors
+ * to net_poll which, indiectly, calls to function.
+ *
+ * Input Parameters:
+ * psock - An instance of the internal socket structure.
+ * fds - The structure describing the events to be monitored, OR NULL if
+ * this is a request to stop monitoring events.
+ * setup - true: Setup up the poll; false: Teardown the poll
+ *
+ * Returned Value:
+ * 0: Success; Negated errno on failure
+ *
+ ****************************************************************************/
+
+#ifndef CONFIG_DISABLE_POLL
+static int icmp_netpoll(FAR struct socket *psock, FAR struct pollfd *fds,
+ bool setup)
+{
+#ifdef CONFIG_MM_IOB
+ /* Check if we are setting up or tearing down the poll */
+
+ if (setup)
+ {
+ /* Perform the ICMP poll() setup */
+
+ return icmp_pollsetup(psock, fds);
+ }
+ else
+ {
+ /* Perform the ICMP poll() teardown */
+
+ return icmp_pollteardown(psock, fds);
+ }
+#else
+ return -ENOSYS;
+#endif /* CONFIG_MM_IOB */
+}
+#endif /* !CONFIG_DISABLE_POLL */
+
+/****************************************************************************
+ * Name: icmp_send
+ *
+ * Description:
+ * Socket send() method for the raw packet socket.
+ *
+ * Parameters:
+ * psock An instance of the internal socket structure.
+ * buf Data to send
+ * len Length of data to send
+ * flags Send flags
+ *
+ * Returned Value:
+ * On success, returns the number of characters sent. On error, a negated
+ * errno value is returned (see send() for the list of appropriate error
+ * values.
+ *
+ ****************************************************************************/
+
+static ssize_t icmp_send(FAR struct socket *psock, FAR const void *buf,
+ size_t len, int flags)
+{
+ /* ICMP sockets cannot be bound and, hence, cannot support any connection-
+ * oriented data transfer.
+ */
+
+ return -EDESTADDRREQ;
+}
+
+/****************************************************************************
+ * Name: icmp_close
+ *
+ * Description:
+ * Performs the close operation on a raw packet socket instance
+ *
+ * Parameters:
+ * psock Socket instance
+ *
+ * Returned Value:
+ * 0 on success; a negated errno value is returned on any failure.
+ *
+ * Assumptions:
+ *
+ ****************************************************************************/
+
+static int icmp_close(FAR struct socket *psock)
+{
+ FAR struct icmp_conn_s *conn;
+
+ DEBUGASSERT(psock != NULL && psock->s_conn != NULL);
+ conn = psock->s_conn;
+
+ /* Is this the last reference to the connection structure (there could be\
+ * more if the socket was dup'ed).
+ */
+
+ DEBUGASSERT(conn->crefs > 0);
+
+ if (conn->crefs <= 1)
+ {
+ /* Yes... free an read-ahead data */
+
+ iob_free_queue(&conn->readahead);
+
+ /* Then free the connection structure */
+
+ conn->crefs = 0; /* No more references on the connection */
+ icmp_free(psock->s_conn); /* Free network resources */
+ }
+ else
+ {
+ /* No.. Just decrement the reference count */
+
+ conn->crefs--;
+ }
+
+ return OK;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#endif /* CONFIG_NET_ICMP_SOCKET */
diff --git a/net/inet/inet.h b/net/inet/inet.h
index fb16b4e9435..e225a63f00f 100644
--- a/net/inet/inet.h
+++ b/net/inet/inet.h
@@ -101,12 +101,6 @@ EXTERN const net_ipv6addr_t g_ipv6_llnetmask; /* Netmask for local link addres
#endif
#endif /* CONFIG_NET_IPv6 */
-/* PF_INET/PF_INET6 socket address family interface */
-
-#ifdef HAVE_INET_SOCKETS
-EXTERN const struct sock_intf_s g_inet_sockif;
-#endif
-
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
@@ -128,6 +122,26 @@ struct socket; /* Forward reference */
void inet_setipid(uint16_t id);
+/****************************************************************************
+ * Name: inet_sockif
+ *
+ * Description:
+ * Return the socket interface associated with the inet address family.
+ *
+ * Input Parameters:
+ * family - Socket address family
+ * type - Socket type
+ * protocol - Socket protocol
+ *
+ * Returned Value:
+ * On success, a non-NULL instance of struct sock_intf_s is returned. NULL
+ * is returned only if the address family is not supported.
+ *
+ ****************************************************************************/
+
+FAR const struct sock_intf_s *
+ inet_sockif(sa_family_t family, int type, int protocol);
+
/****************************************************************************
* Name: ipv4_getsockname and ipv6_sockname
*
diff --git a/net/inet/inet_recvfrom.c b/net/inet/inet_recvfrom.c
index b42c971a3e9..a69013dfbfb 100644
--- a/net/inet/inet_recvfrom.c
+++ b/net/inet/inet_recvfrom.c
@@ -296,13 +296,12 @@ static inline void inet_udp_newdata(FAR struct net_driver_s *dev,
#endif /* NET_UDP_HAVE_STACK */
/****************************************************************************
- * Name: inet_tcp_readahead
+ * Name: inet_tcp_readahead and inet_udp_readahead
*
* Description:
- * Copy the read data from the packet
+ * Copy the read-ahead data from the packet
*
* Parameters:
- * dev The structure of the network driver that caused the interrupt
* pstate recvfrom state structure
*
* Returned Value:
@@ -1501,7 +1500,7 @@ static ssize_t inet_tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t
* modified on return to indicate the actual size of the address stored
* there.
*
- * Parameters:
+ * Input Parameters:
* psock A pointer to a NuttX-specific, internal socket structure
* buf Buffer to receive data
* len Length of buffer
diff --git a/net/inet/inet_sockif.c b/net/inet/inet_sockif.c
index 4ccedad5f91..0aa96e70b2a 100644
--- a/net/inet/inet_sockif.c
+++ b/net/inet/inet_sockif.c
@@ -50,6 +50,7 @@
#include "tcp/tcp.h"
#include "udp/udp.h"
+#include "icmp/icmp.h"
#include "sixlowpan/sixlowpan.h"
#include "socket/socket.h"
#include "inet/inet.h"
@@ -88,10 +89,10 @@ static ssize_t inet_sendfile(FAR struct socket *psock, FAR struct file *infil
#endif
/****************************************************************************
- * Public Data
+ * Private Data
****************************************************************************/
-const struct sock_intf_s g_inet_sockif =
+static const struct sock_intf_s g_inet_sockif =
{
inet_setup, /* si_setup */
inet_sockcaps, /* si_sockcaps */
@@ -1206,16 +1207,39 @@ static ssize_t inet_sendfile(FAR struct socket *psock,
****************************************************************************/
/****************************************************************************
- * Name:
+ * Name: inet_sockif
*
* Description:
+ * Return the socket interface associated with the inet address family.
*
- * Parameters:
+ * Input Parameters:
+ * family - Socket address family
+ * type - Socket type
+ * protocol - Socket protocol
*
* Returned Value:
- *
- * Assumptions:
+ * On success, a non-NULL instance of struct sock_intf_s is returned. NULL
+ * is returned only if the address family is not supported.
*
****************************************************************************/
+FAR const struct sock_intf_s *
+ inet_sockif(sa_family_t family, int type, int protocol)
+{
+ DEBUGASSERT(family == PF_INET || family == PF_INET6);
+
+#if defined(HAVE_PFINET_SOCKETS) && defined(CONFIG_NET_ICMP_SOCKET)
+ /* PF_INET, ICMP data gram sockets are a special case of raw sockets */
+
+ if (family == PF_INET && type == SOCK_DGRAM && protocol == IPPROTO_ICMP)
+ {
+ return &g_icmp_sockif;
+ }
+ else
+#endif
+ {
+ return &g_inet_sockif;
+ }
+}
+
#endif /* HAVE_INET_SOCKETS */
diff --git a/net/net_initialize.c b/net/net_initialize.c
index 9899e09d0f8..7ed6f0b6a58 100644
--- a/net/net_initialize.c
+++ b/net/net_initialize.c
@@ -51,6 +51,7 @@
#include "arp/arp.h"
#include "sixlowpan/sixlowpan.h"
#include "neighbor/neighbor.h"
+#include "icmp/icmp.h"
#include "tcp/tcp.h"
#include "udp/udp.h"
#include "pkt/pkt.h"
@@ -126,6 +127,12 @@ void net_setup(void)
pkt_initialize();
#endif
+#ifdef CONFIG_NET_ICMP_SOCKET
+ /* Initialize IPPPROTO_ICMP socket support */
+
+ icmp_sock_initialize();
+#endif
+
#ifdef CONFIG_NET_IEEE802154
/* Initialize IEEE 802.15.4 socket support */
diff --git a/net/pkt/pkt_conn.c b/net/pkt/pkt_conn.c
index 7300fe04256..95b08235f97 100644
--- a/net/pkt/pkt_conn.c
+++ b/net/pkt/pkt_conn.c
@@ -116,7 +116,7 @@ static inline void _pkt_semtake(sem_t *sem)
*
* Description:
* Initialize the packet socket connection structures. Called once and
- * only from the UIP layer.
+ * only from the network initialization layer.
*
****************************************************************************/
@@ -206,15 +206,15 @@ void pkt_free(FAR struct pkt_conn_s *conn)
* Name: pkt_active()
*
* Description:
- * Find a connection structure that is the appropriate
- * connection to be used with the provided Ethernet header
+ * Find a connection structure that is the appropriate connection to be
+ * used with the provided Ethernet header
*
* Assumptions:
- * This function is called from network logic at interrupt level
+ * This function is called from network logic at with the network locked.
*
****************************************************************************/
-FAR struct pkt_conn_s *pkt_active(struct eth_hdr_s *buf)
+FAR struct pkt_conn_s *pkt_active(FAR struct eth_hdr_s *buf)
{
#define eth_addr_cmp(addr1, addr2) \
((addr1[0] == addr2[0]) && (addr1[1] == addr2[1]) && \
@@ -250,8 +250,7 @@ FAR struct pkt_conn_s *pkt_active(struct eth_hdr_s *buf)
* Traverse the list of allocated packet connections
*
* Assumptions:
- * This function is called from network logic at interrupt level (or with
- * interrupts disabled).
+ * This function is called from network logic at with the network locked.
*
****************************************************************************/
diff --git a/net/pkt/pkt_sockif.c b/net/pkt/pkt_sockif.c
index e765adfb41e..571495e15f3 100644
--- a/net/pkt/pkt_sockif.c
+++ b/net/pkt/pkt_sockif.c
@@ -614,17 +614,4 @@ static int pkt_close(FAR struct socket *psock)
* Public Functions
****************************************************************************/
-/****************************************************************************
- * Name:
- *
- * Description:
- *
- * Parameters:
- *
- * Returned Value:
- *
- * Assumptions:
- *
- ****************************************************************************/
-
#endif /* CONFIG_NET_PKT */
diff --git a/net/socket/net_sockif.c b/net/socket/net_sockif.c
index 07e496cbbbb..cd029b3fe1d 100644
--- a/net/socket/net_sockif.c
+++ b/net/socket/net_sockif.c
@@ -61,8 +61,10 @@
* Description:
* Return the socket interface associated with this address family.
*
- * Parameters:
- * family - Address family
+ * Input Parameters:
+ * family - Socket address family
+ * type - Socket type
+ * protocol - Socket protocol
*
* Returned Value:
* On success, a non-NULL instance of struct sock_intf_s is returned. NULL
@@ -70,7 +72,8 @@
*
****************************************************************************/
-FAR const struct sock_intf_s *net_sockif(sa_family_t family)
+FAR const struct sock_intf_s *
+ net_sockif(sa_family_t family, int type, int protocol)
{
FAR const struct sock_intf_s *sockif = NULL;
@@ -85,7 +88,7 @@ FAR const struct sock_intf_s *net_sockif(sa_family_t family)
#ifdef HAVE_PFINET6_SOCKETS
case PF_INET6:
#endif
- sockif = &g_inet_sockif;
+ sockif = inet_sockif(family, type, protocol);
break;
#endif
diff --git a/net/socket/socket.c b/net/socket/socket.c
index d231a4dae97..6f9d64272e1 100644
--- a/net/socket/socket.c
+++ b/net/socket/socket.c
@@ -60,7 +60,7 @@
* socket() creates an endpoint for communication and returns a socket
* structure.
*
- * Parameters:
+ * Input Parameters:
* domain (see sys/socket.h)
* type (see sys/socket.h)
* protocol (see sys/socket.h)
@@ -134,7 +134,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
/* Get the socket interface */
- sockif = net_sockif(domain);
+ sockif = net_sockif(domain, type, protocol);
if (sockif == NULL)
{
nerr("ERROR: socket address family unsupported: %d\n", domain);
diff --git a/net/socket/socket.h b/net/socket/socket.h
index b03d0ccbf46..0557709c08b 100644
--- a/net/socket/socket.h
+++ b/net/socket/socket.h
@@ -220,8 +220,10 @@ FAR struct socket *sockfd_socket(int sockfd);
* Description:
* Return the socket interface associated with this address family.
*
- * Parameters:
- * family - Address family
+ * Input Parameters:
+ * family - Socket address family
+ * type - Socket type
+ * protocol - Socket protocol
*
* Returned Value:
* On success, a non-NULL instance of struct sock_intf_s is returned. NULL
@@ -229,7 +231,8 @@ FAR struct socket *sockfd_socket(int sockfd);
*
****************************************************************************/
-FAR const struct sock_intf_s *net_sockif(sa_family_t family);
+FAR const struct sock_intf_s *
+ net_sockif(sa_family_t family, int type, int protocol);
/****************************************************************************
* Name: net_timeo
diff --git a/net/udp/udp_netpoll.c b/net/udp/udp_netpoll.c
index 19631b47ba4..0145c3303ea 100644
--- a/net/udp/udp_netpoll.c
+++ b/net/udp/udp_netpoll.c
@@ -200,7 +200,7 @@ int udp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
goto errout_with_lock;
}
- /* Allocate a TCP/IP callback structure */
+ /* Allocate a UDP callback structure */
cb = udp_callback_alloc(info->dev, conn);
if (cb == NULL)
@@ -278,7 +278,7 @@ errout_with_lock:
* Teardown monitoring of events on an UDP/IP socket
*
* Input Parameters:
- * psock - The TCP/IP socket of interest
+ * psock - The UDP socket of interest
* fds - The structure describing the events to be monitored, OR NULL if
* this is a request to stop monitoring events.
*
diff --git a/net/utils/net_icmpchksum.c b/net/utils/net_icmpchksum.c
index c9d24148bd9..12b20c50122 100644
--- a/net/utils/net_icmpchksum.c
+++ b/net/utils/net_icmpchksum.c
@@ -68,13 +68,13 @@
*
****************************************************************************/
-#if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING)
+#if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_SOCKET)
uint16_t icmp_chksum(FAR struct net_driver_s *dev, int len)
{
FAR struct icmp_iphdr_s *icmp = ICMPBUF;
return net_chksum((FAR uint16_t *)&icmp->type, len);
}
-#endif /* CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING */
+#endif /* CONFIG_NET_ICMP && CONFIG_NET_ICMP_SOCKET */
/****************************************************************************
* Name: icmpv6_chksum
diff --git a/net/utils/utils.h b/net/utils/utils.h
index 0b14be5585b..fc72447084e 100644
--- a/net/utils/utils.h
+++ b/net/utils/utils.h
@@ -352,7 +352,7 @@ uint16_t udp_ipv6_chksum(FAR struct net_driver_s *dev);
*
****************************************************************************/
-#if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING)
+#if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_SOCKET)
uint16_t icmp_chksum(FAR struct net_driver_s *dev, int len);
#endif