mirror of https://github.com/ARMmbed/mbed-os.git
Incorporate review comments from @kjbracey-arm
parent
5168bbdcd0
commit
6905b1b547
|
|
@ -238,7 +238,7 @@ nsapi_error_t LWIP::socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto)
|
||||||
} else if (proto == NSAPI_ICMP) {
|
} else if (proto == NSAPI_ICMP) {
|
||||||
netconntype = NETCONN_RAW;
|
netconntype = NETCONN_RAW;
|
||||||
} else {
|
} else {
|
||||||
return NSAPI_ERROR_PROTO_UNKNOWN;
|
return NSAPI_ERROR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LWIP_IPV6
|
#if LWIP_IPV6
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@
|
||||||
|
|
||||||
#define SYS_LIGHTWEIGHT_PROT 1
|
#define SYS_LIGHTWEIGHT_PROT 1
|
||||||
|
|
||||||
#define LWIP_RAW MBED_CONF_LWIP_RAWIPSOCKET_ENABLED
|
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||||
|
|
||||||
#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT
|
#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT
|
||||||
#define TCPIP_MBOX_SIZE MBED_CONF_LWIP_TCPIP_MBOX_SIZE
|
#define TCPIP_MBOX_SIZE MBED_CONF_LWIP_TCPIP_MBOX_SIZE
|
||||||
|
|
|
||||||
|
|
@ -1,83 +1,125 @@
|
||||||
{
|
{
|
||||||
"name": "lwip",
|
"name": "lwip"
|
||||||
"config": {
|
,
|
||||||
"ipv4-enabled": {
|
"config":
|
||||||
"help": "Enable IPv4",
|
{
|
||||||
"value": true
|
"ipv4-enabled":
|
||||||
|
{
|
||||||
|
"help": "Enable IPv4"
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
true
|
||||||
},
|
},
|
||||||
"ipv6-enabled": {
|
"ipv6-enabled":
|
||||||
"help": "Enable IPv6",
|
{
|
||||||
"value": false
|
"help": "Enable IPv6"
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
false
|
||||||
},
|
},
|
||||||
"ip-ver-pref": {
|
"ip-ver-pref":
|
||||||
"help": "On dual-stack system the preferred stack: 4 for IPv4 and 6 for IPv6",
|
{
|
||||||
|
"help": "On dual-stack system the preferred stack: 4 for IPv4 and 6 for IPv6"
|
||||||
|
,
|
||||||
"value": 4
|
"value": 4
|
||||||
},
|
},
|
||||||
"addr-timeout": {
|
"addr-timeout":
|
||||||
"help": "On dual-stack system how long to additionally wait for other stack's address in seconds",
|
{
|
||||||
|
"help": "On dual-stack system how long to additionally wait for other stack's address in seconds"
|
||||||
|
,
|
||||||
"value": 5
|
"value": 5
|
||||||
},
|
},
|
||||||
"addr-timeout-mode": {
|
"addr-timeout-mode":
|
||||||
"help": "Address timeout mode; true: wait both stack's addresses; false: wait for preferred stack's address",
|
{
|
||||||
"value": true
|
"help": "Address timeout mode; true: wait both stack's addresses; false: wait for preferred stack's address"
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
true
|
||||||
},
|
},
|
||||||
"dhcp-timeout": {
|
"value":
|
||||||
"help": "DHCP timeout value",
|
true
|
||||||
"value": 60
|
|
||||||
},
|
},
|
||||||
"ethernet-enabled": {
|
"l3ip-enabled":
|
||||||
"help": "Enable support for Ethernet interfaces",
|
{
|
||||||
"value": true
|
"help": "Enable support for L3IP interfaces"
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
false
|
||||||
},
|
},
|
||||||
"l3ip-enabled": {
|
"debug-enabled":
|
||||||
"help": "Enable support for L3IP interfaces",
|
{
|
||||||
"value": false
|
"help": "Enable debug trace support"
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
false
|
||||||
},
|
},
|
||||||
"debug-enabled": {
|
"ppp-enabled":
|
||||||
"help": "Enable debug trace support",
|
{
|
||||||
"value": false
|
"help": "Enable support for PPP interfaces (obsolete: use netsocket/ppp configuration instead)"
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
false
|
||||||
},
|
},
|
||||||
"ppp-enabled": {
|
"ppp-ipv4-enabled":
|
||||||
"help": "Enable support for PPP interfaces (obsolete: use netsocket/ppp configuration instead)",
|
{
|
||||||
"value": false
|
"help": "Enable support for ipv4 PPP interface (obsolete: use netsocket/ppp configuration instead)"
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
false
|
||||||
},
|
},
|
||||||
"ppp-ipv4-enabled": {
|
"ppp-ipv6-enabled":
|
||||||
"help": "Enable support for ipv4 PPP interface (obsolete: use netsocket/ppp configuration instead)",
|
{
|
||||||
"value": false
|
"help": "Enable support for ipv6 PPP interface (obsolete: use netsocket/ppp configuration instead)"
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
false
|
||||||
},
|
},
|
||||||
"ppp-ipv6-enabled": {
|
"use-mbed-trace":
|
||||||
"help": "Enable support for ipv6 PPP interface (obsolete: use netsocket/ppp configuration instead)",
|
{
|
||||||
"value": false
|
"help": "Use mbed trace for debug, rather than printf"
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
false
|
||||||
},
|
},
|
||||||
"use-mbed-trace": {
|
"enable-ppp-trace":
|
||||||
"help": "Use mbed trace for debug, rather than printf",
|
{
|
||||||
"value": false
|
"help": "Enable trace support for PPP interfaces (obsolete: use netsocket/ppp configuration instead)"
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
false
|
||||||
},
|
},
|
||||||
"enable-ppp-trace": {
|
"socket-max":
|
||||||
"help": "Enable trace support for PPP interfaces (obsolete: use netsocket/ppp configuration instead)",
|
{
|
||||||
"value": false
|
"help": "Maximum number of open TCPServer, TCPSocket and UDPSocket instances allowed, including one used internally for DNS. Each requires 236 bytes of pre-allocated RAM"
|
||||||
},
|
,
|
||||||
"socket-max": {
|
|
||||||
"help": "Maximum number of open TCPServer, TCPSocket and UDPSocket instances allowed, including one used internally for DNS. Each requires 236 bytes of pre-allocated RAM",
|
|
||||||
"value": 4
|
"value": 4
|
||||||
},
|
},
|
||||||
"tcp-enabled": {
|
"tcp-enabled":
|
||||||
"help": "Enable TCP",
|
{
|
||||||
"value": true
|
"help": "Enable TCP"
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
true
|
||||||
},
|
},
|
||||||
"tcp-server-max": {
|
"tcp-server-max":
|
||||||
"help": "Maximum number of open TCPServer instances allowed. Each requires 72 bytes of pre-allocated RAM",
|
{
|
||||||
|
"help": "Maximum number of open TCPServer instances allowed. Each requires 72 bytes of pre-allocated RAM"
|
||||||
|
,
|
||||||
"value": 4
|
"value": 4
|
||||||
},
|
},
|
||||||
"tcp-socket-max": {
|
"tcp-socket-max":
|
||||||
"help": "Maximum number of open TCPSocket instances allowed. Each requires 196 bytes of pre-allocated RAM",
|
{
|
||||||
|
"help": "Maximum number of open TCPSocket instances allowed. Each requires 196 bytes of pre-allocated RAM"
|
||||||
|
,
|
||||||
"value": 4
|
"value": 4
|
||||||
},
|
},
|
||||||
"udp-socket-max": {
|
"udp-socket-max":
|
||||||
"help": "Maximum number of open UDPSocket instances allowed, including one used internally for DNS. Each requires 84 bytes of pre-allocated RAM",
|
{
|
||||||
|
"help": "Maximum number of open UDPSocket instances allowed, including one used internally for DNS. Each requires 84 bytes of pre-allocated RAM"
|
||||||
|
,
|
||||||
"value": 4
|
"value": 4
|
||||||
},
|
},
|
||||||
"memp-num-tcp-seg": {
|
"memp-num-tcp-seg":
|
||||||
"help": "Number of simultaneously queued TCP segments, see LWIP opt.h for more information. Current default is 16.",
|
"help": "Number of simultaneously queued TCP segments, see LWIP opt.h for more information. Current default is 16.",
|
||||||
"value": 16
|
"value": 16
|
||||||
},
|
},
|
||||||
|
|
@ -85,7 +127,7 @@
|
||||||
"help": "Number of simultaneously queued TCP messages that are received",
|
"help": "Number of simultaneously queued TCP messages that are received",
|
||||||
"value": 8
|
"value": 8
|
||||||
},
|
},
|
||||||
"tcp-mss": {
|
"tcp-mss":
|
||||||
"help": "TCP Maximum segment size, see LWIP opt.h for more information. Current default is 536.",
|
"help": "TCP Maximum segment size, see LWIP opt.h for more information. Current default is 536.",
|
||||||
"value": 536
|
"value": 536
|
||||||
},
|
},
|
||||||
|
|
@ -101,57 +143,87 @@
|
||||||
"help": "mailbox size",
|
"help": "mailbox size",
|
||||||
"value": 8
|
"value": 8
|
||||||
},
|
},
|
||||||
"tcp-snd-buf": {
|
"tcp-snd-buf":
|
||||||
"help": "TCP sender buffer space (bytes), see LWIP's opt.h for more information. Current default is (2 * TCP_MSS).",
|
"help": "TCP sender buffer space (bytes), see LWIP's opt.h for more information. Current default is (2 * TCP_MSS).",
|
||||||
"value": "(2 * TCP_MSS)"
|
"value": "(2 * TCP_MSS)"
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
null
|
||||||
},
|
},
|
||||||
"tcp-wnd": {
|
"tcp-wnd":
|
||||||
"help": "TCP sender buffer space (bytes), see LWIP's opt.h for more information. Current default is (4 * TCP_MSS).",
|
"help": "TCP sender buffer space (bytes), see LWIP's opt.h for more information. Current default is (4 * TCP_MSS).",
|
||||||
"value": "(4 * TCP_MSS)"
|
"value": "(4 * TCP_MSS)"
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
null
|
||||||
},
|
},
|
||||||
"tcp-maxrtx": {
|
"tcp-maxrtx":
|
||||||
"help": "Maximum number of retransmissions of data segments, see LWIP's opt.h for more information. Current default is 6.",
|
"help": "Maximum number of retransmissions of data segments, see LWIP's opt.h for more information. Current default is 6.",
|
||||||
|
"help": "Maximum number of retransmissions of data segments."
|
||||||
|
,
|
||||||
"value": 6
|
"value": 6
|
||||||
},
|
},
|
||||||
"tcp-synmaxrtx": {
|
"tcp-synmaxrtx":
|
||||||
"help": "Maximum number of retransmissions of SYN segments, see LWIP's opt.h for more information. Current default is 6.",
|
"help": "Maximum number of retransmissions of SYN segments, see LWIP's opt.h for more information. Current default is 6.",
|
||||||
"value": 6
|
"value": 6
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
null
|
||||||
},
|
},
|
||||||
"tcp-close-timeout": {
|
"tcp-close-timeout":
|
||||||
"help": "Maximum timeout (ms) for TCP close handshaking timeout",
|
{
|
||||||
|
"help": "Maximum timeout (ms) for TCP close handshaking timeout"
|
||||||
|
,
|
||||||
"value": 1000
|
"value": 1000
|
||||||
},
|
},
|
||||||
"tcpip-thread-priority": {
|
"tcpip-thread-priority":
|
||||||
"help": "Priority of lwip TCPIP thread",
|
{
|
||||||
"value": "osPriorityNormal"
|
"help": "Priority of lwip TCPIP thread"
|
||||||
|
,
|
||||||
|
"value": "osPriorityNormal"
|
||||||
},
|
},
|
||||||
"pbuf-pool-size": {
|
"pbuf-pool-size":
|
||||||
"help": "Number of pbufs in pool - usually used for received packets, so this determines how much data can be buffered between reception and the application reading, see LWIP's opt.h for more information. If a driver uses PBUF_RAM for reception, less pool may be needed. Current default is 5.",
|
"help": "Number of pbufs in pool - usually used for received packets, so this determines how much data can be buffered between reception and the application reading, see LWIP's opt.h for more information. If a driver uses PBUF_RAM for reception, less pool may be needed. Current default is 5.",
|
||||||
"value": 5
|
"value": 5
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
null
|
||||||
},
|
},
|
||||||
"pbuf-pool-bufsize": {
|
"pbuf-pool-bufsize":
|
||||||
"help": "Size of pbufs in pool, see LWIP's opt.h for more information.",
|
"help": "Size of pbufs in pool, see LWIP's opt.h for more information.",
|
||||||
"value": null
|
"help": "Size of pbufs in pool. If set to null, lwIP will base the size on the TCP MSS, which is 536 unless overridden by the target"
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
null
|
||||||
},
|
},
|
||||||
"mem-size": {
|
"mem-size":
|
||||||
"help": "Size of heap (bytes) - used for outgoing packets, and also used by some drivers for reception, see LWIP's opt.h for more information. Current default is 1600.",
|
"help": "Size of heap (bytes) - used for outgoing packets, and also used by some drivers for reception, see LWIP's opt.h for more information. Current default is 1600.",
|
||||||
"value": 1600
|
"value": 1600
|
||||||
|
,
|
||||||
|
"value":
|
||||||
|
null
|
||||||
},
|
},
|
||||||
"tcpip-thread-stacksize": {
|
"tcpip-thread-stacksize":
|
||||||
"help": "Stack size for lwip TCPIP thread",
|
{
|
||||||
|
"help": "Stack size for lwip TCPIP thread"
|
||||||
|
,
|
||||||
"value": 1200
|
"value": 1200
|
||||||
},
|
},
|
||||||
"default-thread-stacksize": {
|
"default-thread-stacksize":
|
||||||
"help": "Stack size for lwip system threads",
|
{
|
||||||
|
"help": "Stack size for lwip system threads"
|
||||||
|
,
|
||||||
"value": 512
|
"value": 512
|
||||||
},
|
},
|
||||||
"ppp-thread-stacksize": {
|
"ppp-thread-stacksize":
|
||||||
"help": "Thread stack size for PPP (obsolete: use netsocket/ppp configuration instead)",
|
{
|
||||||
|
"help": "Thread stack size for PPP (obsolete: use netsocket/ppp configuration instead)"
|
||||||
|
,
|
||||||
"value": 768
|
"value": 768
|
||||||
},
|
},
|
||||||
"rawipsocket-enabled": {
|
"raw-socket-enabled":
|
||||||
"help": "Enable ICMP RAW",
|
{
|
||||||
"value": false
|
"help": "Enable RAW socket"
|
||||||
},
|
},
|
||||||
"num-pbuf": {
|
"num-pbuf": {
|
||||||
"help": "Number of non-pool pbufs, each needs 92 bytes of RAM, see LWIP's opt.h for more information. Current default is 8.",
|
"help": "Number of non-pool pbufs, each needs 92 bytes of RAM, see LWIP's opt.h for more information. Current default is 8.",
|
||||||
|
|
@ -162,71 +234,102 @@
|
||||||
"value": 8
|
"value": 8
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"target_overrides": {
|
"target_overrides":
|
||||||
"REALTEK_RTL8195AM": {
|
{
|
||||||
|
"REALTEK_RTL8195AM":
|
||||||
|
{
|
||||||
"tcpip-thread-stacksize": 1600,
|
"tcpip-thread-stacksize": 1600,
|
||||||
"mem-size": 12800
|
"mem-size": 12800
|
||||||
},
|
},
|
||||||
"UBLOX_EVK_ODIN_W2": {
|
"UBLOX_EVK_ODIN_W2":
|
||||||
|
{
|
||||||
"pbuf-pool-size" : 10
|
"pbuf-pool-size" : 10
|
||||||
},
|
},
|
||||||
"STM": {
|
"STM":
|
||||||
|
{
|
||||||
"mem-size": 2310
|
"mem-size": 2310
|
||||||
},
|
},
|
||||||
"Freescale": {
|
"Freescale":
|
||||||
|
{
|
||||||
"mem-size": 33270
|
"mem-size": 33270
|
||||||
},
|
},
|
||||||
"LPC1768": {
|
"LPC1768":
|
||||||
|
{
|
||||||
"mem-size": 16362
|
"mem-size": 16362
|
||||||
},
|
},
|
||||||
"LPC4088": {
|
"LPC4088":
|
||||||
|
{
|
||||||
"mem-size": 15360
|
"mem-size": 15360
|
||||||
},
|
},
|
||||||
"LPC4088_DM": {
|
"LPC4088_DM":
|
||||||
|
{
|
||||||
"mem-size": 15360
|
"mem-size": 15360
|
||||||
},
|
},
|
||||||
"UBLOX_C027": {
|
"UBLOX_C027":
|
||||||
|
{
|
||||||
"mem-size": 16362
|
"mem-size": 16362
|
||||||
},
|
},
|
||||||
"ARCH_PRO": {
|
"ARCH_PRO":
|
||||||
|
{
|
||||||
"mem-size": 16362
|
"mem-size": 16362
|
||||||
},
|
},
|
||||||
"LPC546XX": {
|
"LPC546XX":
|
||||||
|
{
|
||||||
"mem-size": 36496
|
"mem-size": 36496
|
||||||
},
|
},
|
||||||
"EFM32GG11_STK3701": {
|
"EFM32GG11_STK3701":
|
||||||
|
{
|
||||||
"mem-size": 36560
|
"mem-size": 36560
|
||||||
},
|
},
|
||||||
"RZ_A1_EMAC": {
|
"RZ_A1_EMAC":
|
||||||
|
{
|
||||||
"tcpip-thread-stacksize": 1328,
|
"tcpip-thread-stacksize": 1328,
|
||||||
"default-thread-stacksize": 640,
|
"default-thread-stacksize": 640,
|
||||||
"memp-num-tcp-seg": 32,
|
"memp-num-tcp-seg": 32,
|
||||||
"tcp-mss": 1440,
|
"tcp-mss": 1440,
|
||||||
"tcp-snd-buf": "(8 * TCP_MSS)",
|
"tcp-snd-buf": "(8 * TCP_MSS)"
|
||||||
"tcp-wnd": "(TCP_MSS * 8)",
|
,
|
||||||
|
"tcp-wnd": "(TCP_MSS * 8)"
|
||||||
|
,
|
||||||
"pbuf-pool-size": 16,
|
"pbuf-pool-size": 16,
|
||||||
"mem-size": 51200
|
"mem-size": 51200
|
||||||
},
|
},
|
||||||
"MCU_PSOC6": {
|
"MCU_PSOC6": {
|
||||||
|
{
|
||||||
|
"tcp-wnd": "(TCP_MSS * 6)"
|
||||||
|
,
|
||||||
|
{
|
||||||
"tcpip-thread-stacksize": 8192,
|
"tcpip-thread-stacksize": 8192,
|
||||||
"default-thread-stacksize": 640,
|
"default-thread-stacksize": 640,
|
||||||
"memp-num-tcp-seg": 24,
|
"memp-num-tcp-seg": 24,
|
||||||
"tcp-socket-max": 10,
|
"tcp-socket-max": 10,
|
||||||
"udp-socket-max":10,
|
"udp-socket-max": 10,
|
||||||
"socket-max":18,
|
"socket-max": 18,
|
||||||
"tcp-mss": 1540,
|
"tcp-mss": 1540,
|
||||||
"tcp-snd-buf": "(6 * TCP_MSS)",
|
"tcp-snd-buf": "(6 * TCP_MSS)"
|
||||||
"tcp-wnd": "(TCP_MSS * 6)",
|
,
|
||||||
"pbuf-pool-size": 14,
|
"pbuf-pool-size": 14,
|
||||||
|
,
|
||||||
|
{
|
||||||
|
"tcp-wnd": "(TCP_MSS * 6)"
|
||||||
|
,
|
||||||
"mem-size": 65536
|
"mem-size": 65536
|
||||||
},
|
},
|
||||||
"MIMXRT1050_EVK": {
|
{
|
||||||
|
"tcp-snd-buf": "(6 * TCP_MSS)"
|
||||||
|
,
|
||||||
|
"tcp-wnd": "(TCP_MSS * 6)"
|
||||||
|
,
|
||||||
|
"MIMXRT1050_EVK":
|
||||||
|
{
|
||||||
"mem-size": 36560
|
"mem-size": 36560
|
||||||
},
|
},
|
||||||
"FVP_MPS2_M3": {
|
"FVP_MPS2_M3":
|
||||||
|
{
|
||||||
"mem-size": 36560
|
"mem-size": 36560
|
||||||
},
|
},
|
||||||
"MTS_DRAGONFLY_F411RE": {
|
"MTS_DRAGONFLY_F411RE":
|
||||||
|
{
|
||||||
"tcpip-thread-stacksize": 1600
|
"tcpip-thread-stacksize": 1600
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,6 @@ ICMPSocket::ICMPSocket()
|
||||||
_socket_stats.stats_update_proto(this, NSAPI_ICMP);
|
_socket_stats.stats_update_proto(this, NSAPI_ICMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
ICMPSocket::~ICMPSocket()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
nsapi_protocol_t ICMPSocket::get_proto()
|
nsapi_protocol_t ICMPSocket::get_proto()
|
||||||
{
|
{
|
||||||
return NSAPI_ICMP;
|
return NSAPI_ICMP;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
#define ICMPSOCKET_H
|
#define ICMPSOCKET_H
|
||||||
|
|
||||||
#include "netsocket/InternetSocket.h"
|
#include "netsocket/InternetSocket.h"
|
||||||
#include "netsocket/InternetDatagram.h"
|
#include "netsocket/InternetDatagramSocket.h"
|
||||||
#include "netsocket/NetworkStack.h"
|
#include "netsocket/NetworkStack.h"
|
||||||
#include "netsocket/NetworkInterface.h"
|
#include "netsocket/NetworkInterface.h"
|
||||||
#include "rtos/EventFlags.h"
|
#include "rtos/EventFlags.h"
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
/** ICMP socket implementation.
|
/** ICMP socket implementation.
|
||||||
*/
|
*/
|
||||||
class ICMPSocket : public InternetDatagram {
|
class ICMPSocket : public InternetDatagramSocket {
|
||||||
public:
|
public:
|
||||||
/** Create an uninitialized socket.
|
/** Create an uninitialized socket.
|
||||||
*
|
*
|
||||||
|
|
@ -36,12 +36,6 @@ public:
|
||||||
*/
|
*/
|
||||||
ICMPSocket();
|
ICMPSocket();
|
||||||
|
|
||||||
/** Destroy a socket.
|
|
||||||
*
|
|
||||||
* @note Closes socket if the socket is still open.
|
|
||||||
*/
|
|
||||||
virtual ~ICMPSocket();
|
|
||||||
|
|
||||||
#if !defined(DOXYGEN_ONLY)
|
#if !defined(DOXYGEN_ONLY)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -14,25 +14,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "InternetDatagram.h"
|
#include "InternetDatagramSocket.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "mbed_assert.h"
|
#include "mbed_assert.h"
|
||||||
|
|
||||||
InternetDatagram::InternetDatagram()
|
nsapi_error_t InternetDatagramSocket::connect(const SocketAddress &address)
|
||||||
{
|
|
||||||
_socket_stats.stats_update_proto(this, NSAPI_ICMP);
|
|
||||||
}
|
|
||||||
|
|
||||||
InternetDatagram::~InternetDatagram()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
nsapi_protocol_t InternetDatagram::get_proto()
|
|
||||||
{
|
|
||||||
return NSAPI_PROTO_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsapi_error_t InternetDatagram::connect(const SocketAddress &address)
|
|
||||||
{
|
{
|
||||||
_remote_peer = address;
|
_remote_peer = address;
|
||||||
_socket_stats.stats_update_peer(this, _remote_peer);
|
_socket_stats.stats_update_peer(this, _remote_peer);
|
||||||
|
|
@ -40,7 +26,7 @@ nsapi_error_t InternetDatagram::connect(const SocketAddress &address)
|
||||||
return NSAPI_ERROR_OK;
|
return NSAPI_ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_size_or_error_t InternetDatagram::sendto(const char *host, uint16_t port, const void *data, nsapi_size_t size)
|
nsapi_size_or_error_t InternetDatagramSocket::sendto(const char *host, uint16_t port, const void *data, nsapi_size_t size)
|
||||||
{
|
{
|
||||||
SocketAddress address;
|
SocketAddress address;
|
||||||
nsapi_size_or_error_t err;
|
nsapi_size_or_error_t err;
|
||||||
|
|
@ -61,7 +47,7 @@ nsapi_size_or_error_t InternetDatagram::sendto(const char *host, uint16_t port,
|
||||||
return sendto(address, data, size);
|
return sendto(address, data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_size_or_error_t InternetDatagram::sendto(const SocketAddress &address, const void *data, nsapi_size_t size)
|
nsapi_size_or_error_t InternetDatagramSocket::sendto(const SocketAddress &address, const void *data, nsapi_size_t size)
|
||||||
{
|
{
|
||||||
_lock.lock();
|
_lock.lock();
|
||||||
nsapi_size_or_error_t ret;
|
nsapi_size_or_error_t ret;
|
||||||
|
|
@ -108,7 +94,7 @@ nsapi_size_or_error_t InternetDatagram::sendto(const SocketAddress &address, con
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_size_or_error_t InternetDatagram::send(const void *data, nsapi_size_t size)
|
nsapi_size_or_error_t InternetDatagramSocket::send(const void *data, nsapi_size_t size)
|
||||||
{
|
{
|
||||||
if (!_remote_peer) {
|
if (!_remote_peer) {
|
||||||
return NSAPI_ERROR_NO_ADDRESS;
|
return NSAPI_ERROR_NO_ADDRESS;
|
||||||
|
|
@ -116,7 +102,7 @@ nsapi_size_or_error_t InternetDatagram::send(const void *data, nsapi_size_t size
|
||||||
return sendto(_remote_peer, data, size);
|
return sendto(_remote_peer, data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_size_or_error_t InternetDatagram::recvfrom(SocketAddress *address, void *buffer, nsapi_size_t size)
|
nsapi_size_or_error_t InternetDatagramSocket::recvfrom(SocketAddress *address, void *buffer, nsapi_size_t size)
|
||||||
{
|
{
|
||||||
_lock.lock();
|
_lock.lock();
|
||||||
nsapi_size_or_error_t ret;
|
nsapi_size_or_error_t ret;
|
||||||
|
|
@ -177,12 +163,12 @@ nsapi_size_or_error_t InternetDatagram::recvfrom(SocketAddress *address, void *b
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_size_or_error_t InternetDatagram::recv(void *buffer, nsapi_size_t size)
|
nsapi_size_or_error_t InternetDatagramSocket::recv(void *buffer, nsapi_size_t size)
|
||||||
{
|
{
|
||||||
return recvfrom(NULL, buffer, size);
|
return recvfrom(NULL, buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
Socket *InternetDatagram::accept(nsapi_error_t *error)
|
Socket *InternetDatagramSocket::accept(nsapi_error_t *error)
|
||||||
{
|
{
|
||||||
if (error) {
|
if (error) {
|
||||||
*error = NSAPI_ERROR_UNSUPPORTED;
|
*error = NSAPI_ERROR_UNSUPPORTED;
|
||||||
|
|
@ -190,7 +176,7 @@ Socket *InternetDatagram::accept(nsapi_error_t *error)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_error_t InternetDatagram::listen(int)
|
nsapi_error_t InternetDatagramSocket::listen(int)
|
||||||
{
|
{
|
||||||
return NSAPI_ERROR_UNSUPPORTED;
|
return NSAPI_ERROR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/** \addtogroup netsocket */
|
/** \addtogroup netsocket */
|
||||||
/** @{*/
|
/** @{*/
|
||||||
/* InternetDatagram
|
/* InternetDatagramSocket
|
||||||
* Copyright (c) 2015 ARM Limited
|
* Copyright (c) 2015 ARM Limited
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef InternetDatagram_H
|
#ifndef INTERNETDATAGRAMSOCKET_H
|
||||||
#define InternetDatagram_H
|
#define INTERNETDATAGRAMSOCKET_H
|
||||||
|
|
||||||
#include "netsocket/InternetSocket.h"
|
#include "netsocket/InternetSocket.h"
|
||||||
#include "netsocket/NetworkStack.h"
|
#include "netsocket/NetworkStack.h"
|
||||||
|
|
@ -25,21 +25,10 @@
|
||||||
#include "rtos/EventFlags.h"
|
#include "rtos/EventFlags.h"
|
||||||
|
|
||||||
|
|
||||||
/** InternetDatagram socket implementation.
|
/** InternetDatagramSocket socket implementation.
|
||||||
*/
|
*/
|
||||||
class InternetDatagram : public InternetSocket {
|
class InternetDatagramSocket : public InternetSocket {
|
||||||
public:
|
public:
|
||||||
/** Create an uninitialized socket.
|
|
||||||
*
|
|
||||||
* @note Must call open to initialize the socket on a network stack.
|
|
||||||
*/
|
|
||||||
InternetDatagram();
|
|
||||||
|
|
||||||
/** Destroy a socket.
|
|
||||||
*
|
|
||||||
* @note Closes socket if the socket is still open.
|
|
||||||
*/
|
|
||||||
virtual ~InternetDatagram();
|
|
||||||
|
|
||||||
/** Send data to the specified host and port.
|
/** Send data to the specified host and port.
|
||||||
*
|
*
|
||||||
|
|
@ -135,14 +124,14 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual nsapi_size_or_error_t recv(void *data, nsapi_size_t size);
|
virtual nsapi_size_or_error_t recv(void *data, nsapi_size_t size);
|
||||||
|
|
||||||
/** Not implemented for InternetDatagram.
|
/** Not implemented for InternetDatagramSocket.
|
||||||
*
|
*
|
||||||
* @param error Not used.
|
* @param error Not used.
|
||||||
* @return NSAPI_ERROR_UNSUPPORTED
|
* @return NSAPI_ERROR_UNSUPPORTED
|
||||||
*/
|
*/
|
||||||
virtual Socket *accept(nsapi_error_t *error = NULL);
|
virtual Socket *accept(nsapi_error_t *error = NULL);
|
||||||
|
|
||||||
/** Not implemented for InternetDatagram.
|
/** Not implemented for InternetDatagramSocket.
|
||||||
*
|
*
|
||||||
* @param backlog Not used.
|
* @param backlog Not used.
|
||||||
* @return NSAPI_ERROR_UNSUPPORTED
|
* @return NSAPI_ERROR_UNSUPPORTED
|
||||||
|
|
@ -151,7 +140,12 @@ public:
|
||||||
#if !defined(DOXYGEN_ONLY)
|
#if !defined(DOXYGEN_ONLY)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual nsapi_protocol_t get_proto();
|
|
||||||
|
/** Create an uninitialized socket.
|
||||||
|
*
|
||||||
|
* @note Must call open to initialize the socket on a network stack.
|
||||||
|
*/
|
||||||
|
InternetDatagramSocket() = default;
|
||||||
|
|
||||||
#endif //!defined(DOXYGEN_ONLY)
|
#endif //!defined(DOXYGEN_ONLY)
|
||||||
};
|
};
|
||||||
|
|
@ -183,9 +183,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class InternetSocket;
|
friend class InternetSocket;
|
||||||
friend class InternetDatagram;
|
friend class InternetDatagramSocket;
|
||||||
friend class ICMPSocket;
|
|
||||||
friend class UDPSocket;
|
|
||||||
friend class TCPSocket;
|
friend class TCPSocket;
|
||||||
friend class TCPServer;
|
friend class TCPServer;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,6 @@ UDPSocket::UDPSocket()
|
||||||
_socket_stats.stats_update_proto(this, NSAPI_UDP);
|
_socket_stats.stats_update_proto(this, NSAPI_UDP);
|
||||||
}
|
}
|
||||||
|
|
||||||
UDPSocket::~UDPSocket()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
nsapi_protocol_t UDPSocket::get_proto()
|
nsapi_protocol_t UDPSocket::get_proto()
|
||||||
{
|
{
|
||||||
return NSAPI_UDP;
|
return NSAPI_UDP;
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,14 @@
|
||||||
#include "netsocket/InternetSocket.h"
|
#include "netsocket/InternetSocket.h"
|
||||||
#include "netsocket/NetworkStack.h"
|
#include "netsocket/NetworkStack.h"
|
||||||
#include "netsocket/NetworkInterface.h"
|
#include "netsocket/NetworkInterface.h"
|
||||||
#include "netsocket/InternetDatagram.h"
|
#include "netsocket/InternetDatagramSocket.h"
|
||||||
#include "rtos/EventFlags.h"
|
#include "rtos/EventFlags.h"
|
||||||
#include "ICMPSocket.h"
|
#include "ICMPSocket.h"
|
||||||
|
|
||||||
|
|
||||||
/** UDP socket implementation.
|
/** UDP socket implementation.
|
||||||
*/
|
*/
|
||||||
class UDPSocket : public InternetDatagram {
|
class UDPSocket : public InternetDatagramSocket {
|
||||||
public:
|
public:
|
||||||
/** Create an uninitialized socket.
|
/** Create an uninitialized socket.
|
||||||
*
|
*
|
||||||
|
|
@ -55,12 +55,6 @@ public:
|
||||||
open(stack);
|
open(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Destroy a socket.
|
|
||||||
*
|
|
||||||
* @note Closes socket if the socket is still open.
|
|
||||||
*/
|
|
||||||
virtual ~UDPSocket();
|
|
||||||
|
|
||||||
#if !defined(DOXYGEN_ONLY)
|
#if !defined(DOXYGEN_ONLY)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,6 @@ enum nsapi_error {
|
||||||
NSAPI_ERROR_ADDRESS_IN_USE = -3018, /*!< Address already in use */
|
NSAPI_ERROR_ADDRESS_IN_USE = -3018, /*!< Address already in use */
|
||||||
NSAPI_ERROR_TIMEOUT = -3019, /*!< operation timed out */
|
NSAPI_ERROR_TIMEOUT = -3019, /*!< operation timed out */
|
||||||
NSAPI_ERROR_BUSY = -3020, /*!< device is busy and cannot accept new operation */
|
NSAPI_ERROR_BUSY = -3020, /*!< device is busy and cannot accept new operation */
|
||||||
NSAPI_ERROR_PROTO_UNKNOWN = -3021, /*!< unknown protocol */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -217,7 +216,6 @@ typedef enum nsapi_protocol {
|
||||||
NSAPI_TCP, /*!< Socket is of TCP type */
|
NSAPI_TCP, /*!< Socket is of TCP type */
|
||||||
NSAPI_UDP, /*!< Socket is of UDP type */
|
NSAPI_UDP, /*!< Socket is of UDP type */
|
||||||
NSAPI_ICMP, /*!< Socket is of ICMP type */
|
NSAPI_ICMP, /*!< Socket is of ICMP type */
|
||||||
NSAPI_PROTO_UNKNOWN, /*!< Socket Protocol type UKNOWN */
|
|
||||||
} nsapi_protocol_t;
|
} nsapi_protocol_t;
|
||||||
|
|
||||||
/** Enum of standardized stack option levels
|
/** Enum of standardized stack option levels
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue