diff --git a/features/lwipstack/LWIPStack.cpp b/features/lwipstack/LWIPStack.cpp index 36dea27dfd..34345dc0c9 100644 --- a/features/lwipstack/LWIPStack.cpp +++ b/features/lwipstack/LWIPStack.cpp @@ -238,7 +238,7 @@ nsapi_error_t LWIP::socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto) } else if (proto == NSAPI_ICMP) { netconntype = NETCONN_RAW; } else { - return NSAPI_ERROR_PROTO_UNKNOWN; + return NSAPI_ERROR_UNSUPPORTED; } #if LWIP_IPV6 diff --git a/features/lwipstack/lwipopts.h b/features/lwipstack/lwipopts.h index e38aae6da7..0a866f391b 100644 --- a/features/lwipstack/lwipopts.h +++ b/features/lwipstack/lwipopts.h @@ -81,7 +81,7 @@ #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 TCPIP_MBOX_SIZE MBED_CONF_LWIP_TCPIP_MBOX_SIZE diff --git a/features/lwipstack/mbed_lib.json b/features/lwipstack/mbed_lib.json index a5bab31072..6c42dc113f 100644 --- a/features/lwipstack/mbed_lib.json +++ b/features/lwipstack/mbed_lib.json @@ -1,83 +1,125 @@ { - "name": "lwip", - "config": { - "ipv4-enabled": { - "help": "Enable IPv4", - "value": true +"name": "lwip" + , +"config": + { +"ipv4-enabled": + { +"help": "Enable IPv4" + , +"value": + true }, - "ipv6-enabled": { - "help": "Enable IPv6", - "value": false +"ipv6-enabled": + { +"help": "Enable IPv6" + , +"value": + false }, - "ip-ver-pref": { - "help": "On dual-stack system the preferred stack: 4 for IPv4 and 6 for IPv6", +"ip-ver-pref": + { +"help": "On dual-stack system the preferred stack: 4 for IPv4 and 6 for IPv6" + , "value": 4 }, - "addr-timeout": { - "help": "On dual-stack system how long to additionally wait for other stack's address in seconds", +"addr-timeout": + { +"help": "On dual-stack system how long to additionally wait for other stack's address in seconds" + , "value": 5 }, - "addr-timeout-mode": { - "help": "Address timeout mode; true: wait both stack's addresses; false: wait for preferred stack's address", - "value": true +"addr-timeout-mode": + { +"help": "Address timeout mode; true: wait both stack's addresses; false: wait for preferred stack's address" + , +"value": + true }, - "dhcp-timeout": { - "help": "DHCP timeout value", - "value": 60 +"value": + true }, - "ethernet-enabled": { - "help": "Enable support for Ethernet interfaces", - "value": true +"l3ip-enabled": + { +"help": "Enable support for L3IP interfaces" + , +"value": + false }, - "l3ip-enabled": { - "help": "Enable support for L3IP interfaces", - "value": false +"debug-enabled": + { +"help": "Enable debug trace support" + , +"value": + false }, - "debug-enabled": { - "help": "Enable debug trace support", - "value": false +"ppp-enabled": + { +"help": "Enable support for PPP interfaces (obsolete: use netsocket/ppp configuration instead)" + , +"value": + false }, - "ppp-enabled": { - "help": "Enable support for PPP interfaces (obsolete: use netsocket/ppp configuration instead)", - "value": false +"ppp-ipv4-enabled": + { +"help": "Enable support for ipv4 PPP interface (obsolete: use netsocket/ppp configuration instead)" + , +"value": + false }, - "ppp-ipv4-enabled": { - "help": "Enable support for ipv4 PPP interface (obsolete: use netsocket/ppp configuration instead)", - "value": false +"ppp-ipv6-enabled": + { +"help": "Enable support for ipv6 PPP interface (obsolete: use netsocket/ppp configuration instead)" + , +"value": + false }, - "ppp-ipv6-enabled": { - "help": "Enable support for ipv6 PPP interface (obsolete: use netsocket/ppp configuration instead)", - "value": false +"use-mbed-trace": + { +"help": "Use mbed trace for debug, rather than printf" + , +"value": + false }, - "use-mbed-trace": { - "help": "Use mbed trace for debug, rather than printf", - "value": false +"enable-ppp-trace": + { +"help": "Enable trace support for PPP interfaces (obsolete: use netsocket/ppp configuration instead)" + , +"value": + false }, - "enable-ppp-trace": { - "help": "Enable trace support for PPP interfaces (obsolete: use netsocket/ppp configuration instead)", - "value": false - }, - "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", +"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 }, - "tcp-enabled": { - "help": "Enable TCP", - "value": true +"tcp-enabled": + { +"help": "Enable TCP" + , +"value": + true }, - "tcp-server-max": { - "help": "Maximum number of open TCPServer instances allowed. Each requires 72 bytes of pre-allocated RAM", +"tcp-server-max": + { +"help": "Maximum number of open TCPServer instances allowed. Each requires 72 bytes of pre-allocated RAM" + , "value": 4 }, - "tcp-socket-max": { - "help": "Maximum number of open TCPSocket instances allowed. Each requires 196 bytes of pre-allocated RAM", +"tcp-socket-max": + { +"help": "Maximum number of open TCPSocket instances allowed. Each requires 196 bytes of pre-allocated RAM" + , "value": 4 }, - "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", +"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" + , "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.", "value": 16 }, @@ -85,7 +127,7 @@ "help": "Number of simultaneously queued TCP messages that are received", "value": 8 }, - "tcp-mss": { +"tcp-mss": "help": "TCP Maximum segment size, see LWIP opt.h for more information. Current default is 536.", "value": 536 }, @@ -101,57 +143,87 @@ "help": "mailbox size", "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).", "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).", "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." + , "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.", "value": 6 + , +"value": + null }, - "tcp-close-timeout": { - "help": "Maximum timeout (ms) for TCP close handshaking timeout", +"tcp-close-timeout": + { +"help": "Maximum timeout (ms) for TCP close handshaking timeout" + , "value": 1000 }, - "tcpip-thread-priority": { - "help": "Priority of lwip TCPIP thread", - "value": "osPriorityNormal" +"tcpip-thread-priority": + { +"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.", "value": 5 + , +"value": + null }, - "pbuf-pool-bufsize": { +"pbuf-pool-bufsize": "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.", "value": 1600 + , +"value": + null }, - "tcpip-thread-stacksize": { - "help": "Stack size for lwip TCPIP thread", +"tcpip-thread-stacksize": + { +"help": "Stack size for lwip TCPIP thread" + , "value": 1200 }, - "default-thread-stacksize": { - "help": "Stack size for lwip system threads", +"default-thread-stacksize": + { +"help": "Stack size for lwip system threads" + , "value": 512 }, - "ppp-thread-stacksize": { - "help": "Thread stack size for PPP (obsolete: use netsocket/ppp configuration instead)", +"ppp-thread-stacksize": + { +"help": "Thread stack size for PPP (obsolete: use netsocket/ppp configuration instead)" + , "value": 768 }, - "rawipsocket-enabled": { - "help": "Enable ICMP RAW", - "value": false +"raw-socket-enabled": + { +"help": "Enable RAW socket" }, "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.", @@ -162,71 +234,102 @@ "value": 8 } }, - "target_overrides": { - "REALTEK_RTL8195AM": { +"target_overrides": + { +"REALTEK_RTL8195AM": + { "tcpip-thread-stacksize": 1600, "mem-size": 12800 }, - "UBLOX_EVK_ODIN_W2": { +"UBLOX_EVK_ODIN_W2": + { "pbuf-pool-size" : 10 }, - "STM": { +"STM": + { "mem-size": 2310 }, - "Freescale": { +"Freescale": + { "mem-size": 33270 }, - "LPC1768": { +"LPC1768": + { "mem-size": 16362 }, - "LPC4088": { +"LPC4088": + { "mem-size": 15360 }, - "LPC4088_DM": { +"LPC4088_DM": + { "mem-size": 15360 }, - "UBLOX_C027": { +"UBLOX_C027": + { "mem-size": 16362 }, - "ARCH_PRO": { +"ARCH_PRO": + { "mem-size": 16362 }, - "LPC546XX": { +"LPC546XX": + { "mem-size": 36496 }, - "EFM32GG11_STK3701": { +"EFM32GG11_STK3701": + { "mem-size": 36560 }, - "RZ_A1_EMAC": { +"RZ_A1_EMAC": + { "tcpip-thread-stacksize": 1328, "default-thread-stacksize": 640, "memp-num-tcp-seg": 32, "tcp-mss": 1440, - "tcp-snd-buf": "(8 * TCP_MSS)", - "tcp-wnd": "(TCP_MSS * 8)", +"tcp-snd-buf": "(8 * TCP_MSS)" + , +"tcp-wnd": "(TCP_MSS * 8)" + , "pbuf-pool-size": 16, "mem-size": 51200 }, "MCU_PSOC6": { + { +"tcp-wnd": "(TCP_MSS * 6)" + , + { "tcpip-thread-stacksize": 8192, "default-thread-stacksize": 640, "memp-num-tcp-seg": 24, "tcp-socket-max": 10, - "udp-socket-max":10, - "socket-max":18, + "udp-socket-max": 10, + "socket-max": 18, "tcp-mss": 1540, - "tcp-snd-buf": "(6 * TCP_MSS)", - "tcp-wnd": "(TCP_MSS * 6)", +"tcp-snd-buf": "(6 * TCP_MSS)" + , "pbuf-pool-size": 14, + , + { +"tcp-wnd": "(TCP_MSS * 6)" + , "mem-size": 65536 }, - "MIMXRT1050_EVK": { + { +"tcp-snd-buf": "(6 * TCP_MSS)" + , +"tcp-wnd": "(TCP_MSS * 6)" + , +"MIMXRT1050_EVK": + { "mem-size": 36560 }, - "FVP_MPS2_M3": { +"FVP_MPS2_M3": + { "mem-size": 36560 }, - "MTS_DRAGONFLY_F411RE": { +"MTS_DRAGONFLY_F411RE": + { "tcpip-thread-stacksize": 1600 } } diff --git a/features/netsocket/ICMPSocket.cpp b/features/netsocket/ICMPSocket.cpp index 32e69cfb3e..6e564bea38 100644 --- a/features/netsocket/ICMPSocket.cpp +++ b/features/netsocket/ICMPSocket.cpp @@ -23,10 +23,6 @@ ICMPSocket::ICMPSocket() _socket_stats.stats_update_proto(this, NSAPI_ICMP); } -ICMPSocket::~ICMPSocket() -{ -} - nsapi_protocol_t ICMPSocket::get_proto() { return NSAPI_ICMP; diff --git a/features/netsocket/ICMPSocket.h b/features/netsocket/ICMPSocket.h index 26778daa06..6d3223d407 100644 --- a/features/netsocket/ICMPSocket.h +++ b/features/netsocket/ICMPSocket.h @@ -20,7 +20,7 @@ #define ICMPSOCKET_H #include "netsocket/InternetSocket.h" -#include "netsocket/InternetDatagram.h" +#include "netsocket/InternetDatagramSocket.h" #include "netsocket/NetworkStack.h" #include "netsocket/NetworkInterface.h" #include "rtos/EventFlags.h" @@ -28,7 +28,7 @@ /** ICMP socket implementation. */ -class ICMPSocket : public InternetDatagram { +class ICMPSocket : public InternetDatagramSocket { public: /** Create an uninitialized socket. * @@ -36,12 +36,6 @@ public: */ ICMPSocket(); - /** Destroy a socket. - * - * @note Closes socket if the socket is still open. - */ - virtual ~ICMPSocket(); - #if !defined(DOXYGEN_ONLY) protected: diff --git a/features/netsocket/InternetDatagram.cpp b/features/netsocket/InternetDatagramSocket.cpp similarity index 82% rename from features/netsocket/InternetDatagram.cpp rename to features/netsocket/InternetDatagramSocket.cpp index 23131b739d..7526a5e86c 100644 --- a/features/netsocket/InternetDatagram.cpp +++ b/features/netsocket/InternetDatagramSocket.cpp @@ -14,25 +14,11 @@ * limitations under the License. */ -#include "InternetDatagram.h" +#include "InternetDatagramSocket.h" #include "Timer.h" #include "mbed_assert.h" -InternetDatagram::InternetDatagram() -{ - _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) +nsapi_error_t InternetDatagramSocket::connect(const SocketAddress &address) { _remote_peer = address; _socket_stats.stats_update_peer(this, _remote_peer); @@ -40,7 +26,7 @@ nsapi_error_t InternetDatagram::connect(const SocketAddress &address) 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; 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); } -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(); nsapi_size_or_error_t ret; @@ -108,7 +94,7 @@ nsapi_size_or_error_t InternetDatagram::sendto(const SocketAddress &address, con 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) { 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); } -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(); nsapi_size_or_error_t ret; @@ -177,12 +163,12 @@ nsapi_size_or_error_t InternetDatagram::recvfrom(SocketAddress *address, void *b 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); } -Socket *InternetDatagram::accept(nsapi_error_t *error) +Socket *InternetDatagramSocket::accept(nsapi_error_t *error) { if (error) { *error = NSAPI_ERROR_UNSUPPORTED; @@ -190,7 +176,7 @@ Socket *InternetDatagram::accept(nsapi_error_t *error) return NULL; } -nsapi_error_t InternetDatagram::listen(int) +nsapi_error_t InternetDatagramSocket::listen(int) { return NSAPI_ERROR_UNSUPPORTED; } diff --git a/features/netsocket/InternetDatagram.h b/features/netsocket/InternetDatagramSocket.h similarity index 92% rename from features/netsocket/InternetDatagram.h rename to features/netsocket/InternetDatagramSocket.h index 17f79e655f..75c1223ba8 100644 --- a/features/netsocket/InternetDatagram.h +++ b/features/netsocket/InternetDatagramSocket.h @@ -1,6 +1,6 @@ /** \addtogroup netsocket */ /** @{*/ -/* InternetDatagram +/* InternetDatagramSocket * Copyright (c) 2015 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,8 +16,8 @@ * limitations under the License. */ -#ifndef InternetDatagram_H -#define InternetDatagram_H +#ifndef INTERNETDATAGRAMSOCKET_H +#define INTERNETDATAGRAMSOCKET_H #include "netsocket/InternetSocket.h" #include "netsocket/NetworkStack.h" @@ -25,21 +25,10 @@ #include "rtos/EventFlags.h" -/** InternetDatagram socket implementation. +/** InternetDatagramSocket socket implementation. */ -class InternetDatagram : public InternetSocket { +class InternetDatagramSocket : public InternetSocket { 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. * @@ -135,14 +124,14 @@ public: */ 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. * @return NSAPI_ERROR_UNSUPPORTED */ virtual Socket *accept(nsapi_error_t *error = NULL); - /** Not implemented for InternetDatagram. + /** Not implemented for InternetDatagramSocket. * * @param backlog Not used. * @return NSAPI_ERROR_UNSUPPORTED @@ -151,7 +140,12 @@ public: #if !defined(DOXYGEN_ONLY) 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) }; diff --git a/features/netsocket/NetworkStack.h b/features/netsocket/NetworkStack.h index 560da81e95..a8cf469760 100644 --- a/features/netsocket/NetworkStack.h +++ b/features/netsocket/NetworkStack.h @@ -183,9 +183,7 @@ public: protected: friend class InternetSocket; - friend class InternetDatagram; - friend class ICMPSocket; - friend class UDPSocket; + friend class InternetDatagramSocket; friend class TCPSocket; friend class TCPServer; diff --git a/features/netsocket/UDPSocket.cpp b/features/netsocket/UDPSocket.cpp index 6f37685567..a21d099cfe 100644 --- a/features/netsocket/UDPSocket.cpp +++ b/features/netsocket/UDPSocket.cpp @@ -23,10 +23,6 @@ UDPSocket::UDPSocket() _socket_stats.stats_update_proto(this, NSAPI_UDP); } -UDPSocket::~UDPSocket() -{ -} - nsapi_protocol_t UDPSocket::get_proto() { return NSAPI_UDP; diff --git a/features/netsocket/UDPSocket.h b/features/netsocket/UDPSocket.h index 783ca6a197..bde85b987a 100644 --- a/features/netsocket/UDPSocket.h +++ b/features/netsocket/UDPSocket.h @@ -23,14 +23,14 @@ #include "netsocket/InternetSocket.h" #include "netsocket/NetworkStack.h" #include "netsocket/NetworkInterface.h" -#include "netsocket/InternetDatagram.h" +#include "netsocket/InternetDatagramSocket.h" #include "rtos/EventFlags.h" #include "ICMPSocket.h" /** UDP socket implementation. */ -class UDPSocket : public InternetDatagram { +class UDPSocket : public InternetDatagramSocket { public: /** Create an uninitialized socket. * @@ -55,12 +55,6 @@ public: open(stack); } - /** Destroy a socket. - * - * @note Closes socket if the socket is still open. - */ - virtual ~UDPSocket(); - #if !defined(DOXYGEN_ONLY) protected: diff --git a/features/netsocket/nsapi_types.h b/features/netsocket/nsapi_types.h index e2180abf1c..fa0ef691da 100644 --- a/features/netsocket/nsapi_types.h +++ b/features/netsocket/nsapi_types.h @@ -56,7 +56,6 @@ enum nsapi_error { NSAPI_ERROR_ADDRESS_IN_USE = -3018, /*!< Address already in use */ NSAPI_ERROR_TIMEOUT = -3019, /*!< operation timed out */ 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_UDP, /*!< Socket is of UDP type */ NSAPI_ICMP, /*!< Socket is of ICMP type */ - NSAPI_PROTO_UNKNOWN, /*!< Socket Protocol type UKNOWN */ } nsapi_protocol_t; /** Enum of standardized stack option levels