Skip to content

Commit ab88335

Browse files
committed
Incorporate review comments from @kjbracey-arm
1 parent 90e188b commit ab88335

File tree

6 files changed

+27
-41
lines changed

6 files changed

+27
-41
lines changed

features/lwipstack/LWIPStack.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,10 @@ nsapi_error_t LWIP::socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto)
235235
netconntype = NETCONN_TCP;
236236
} else if (proto == NSAPI_UDP) {
237237
netconntype = NETCONN_UDP;
238-
} else {
238+
} else if (proto == NSAPI_ICMP) {
239239
netconntype = NETCONN_RAW;
240+
} else {
241+
return NSAPI_ERROR_PROTO_UNKNOWN;
240242
}
241243

242244
#if LWIP_IPV6

features/netsocket/RAWIPSocket.cpp renamed to features/netsocket/ICMPSocket.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,33 @@
1414
* limitations under the License.
1515
*/
1616

17-
#include "RAWIPSocket.h"
17+
#include "ICMPSocket.h"
1818
#include "Timer.h"
1919
#include "mbed_assert.h"
2020

21-
RAWIPSocket::RAWIPSocket()
21+
ICMPSocket::ICMPSocket()
2222
{
2323
_socket_stats.stats_update_proto(this, NSAPI_ICMP);
2424
}
2525

26-
RAWIPSocket::~RAWIPSocket()
26+
ICMPSocket::~ICMPSocket()
2727
{
2828
}
2929

30-
nsapi_protocol_t RAWIPSocket::get_proto()
30+
nsapi_protocol_t ICMPSocket::get_proto()
3131
{
3232
return NSAPI_ICMP;
3333
}
3434

35-
nsapi_error_t RAWIPSocket::connect(const SocketAddress &address)
35+
nsapi_error_t ICMPSocket::connect(const SocketAddress &address)
3636
{
3737
_remote_peer = address;
3838
_socket_stats.stats_update_peer(this, _remote_peer);
3939
_socket_stats.stats_update_socket_state(this, SOCK_CONNECTED);
4040
return NSAPI_ERROR_OK;
4141
}
4242

43-
nsapi_size_or_error_t RAWIPSocket::sendto(const char *host, uint16_t port, const void *data, nsapi_size_t size)
43+
nsapi_size_or_error_t ICMPSocket::sendto(const char *host, uint16_t port, const void *data, nsapi_size_t size)
4444
{
4545
SocketAddress address;
4646
nsapi_size_or_error_t err;
@@ -61,7 +61,7 @@ nsapi_size_or_error_t RAWIPSocket::sendto(const char *host, uint16_t port, const
6161
return sendto(address, data, size);
6262
}
6363

64-
nsapi_size_or_error_t RAWIPSocket::sendto(const SocketAddress &address, const void *data, nsapi_size_t size)
64+
nsapi_size_or_error_t ICMPSocket::sendto(const SocketAddress &address, const void *data, nsapi_size_t size)
6565
{
6666
_lock.lock();
6767
nsapi_size_or_error_t ret;
@@ -108,15 +108,15 @@ nsapi_size_or_error_t RAWIPSocket::sendto(const SocketAddress &address, const vo
108108
return ret;
109109
}
110110

111-
nsapi_size_or_error_t RAWIPSocket::send(const void *data, nsapi_size_t size)
111+
nsapi_size_or_error_t ICMPSocket::send(const void *data, nsapi_size_t size)
112112
{
113113
if (!_remote_peer) {
114114
return NSAPI_ERROR_NO_ADDRESS;
115115
}
116116
return sendto(_remote_peer, data, size);
117117
}
118118

119-
nsapi_size_or_error_t RAWIPSocket::recvfrom(SocketAddress *address, void *buffer, nsapi_size_t size)
119+
nsapi_size_or_error_t ICMPSocket::recvfrom(SocketAddress *address, void *buffer, nsapi_size_t size)
120120
{
121121
_lock.lock();
122122
nsapi_size_or_error_t ret;
@@ -177,20 +177,20 @@ nsapi_size_or_error_t RAWIPSocket::recvfrom(SocketAddress *address, void *buffer
177177
return ret;
178178
}
179179

180-
nsapi_size_or_error_t RAWIPSocket::recv(void *buffer, nsapi_size_t size)
180+
nsapi_size_or_error_t ICMPSocket::recv(void *buffer, nsapi_size_t size)
181181
{
182182
return recvfrom(NULL, buffer, size);
183183
}
184184

185-
Socket *RAWIPSocket::accept(nsapi_error_t *error)
185+
Socket *ICMPSocket::accept(nsapi_error_t *error)
186186
{
187187
if (error) {
188188
*error = NSAPI_ERROR_UNSUPPORTED;
189189
}
190190
return NULL;
191191
}
192192

193-
nsapi_error_t RAWIPSocket::listen(int)
193+
nsapi_error_t ICMPSocket::listen(int)
194194
{
195195
return NSAPI_ERROR_UNSUPPORTED;
196196
}

features/netsocket/RAWIPSocket.h renamed to features/netsocket/ICMPSocket.h

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** \addtogroup netsocket */
22
/** @{*/
3-
/* RAWIPSocket
3+
/* ICMPSocket
44
* Copyright (c) 2015 ARM Limited
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,8 +16,8 @@
1616
* limitations under the License.
1717
*/
1818

19-
#ifndef RAWIPSOCKET_H
20-
#define RAWIPSOCKET_H
19+
#ifndef ICMPSOCKET_H
20+
#define ICMPSOCKET_H
2121

2222
#include "netsocket/InternetSocket.h"
2323
#include "netsocket/NetworkStack.h"
@@ -27,36 +27,19 @@
2727

2828
/** RAW socket implementation.
2929
*/
30-
class RAWIPSocket : public InternetSocket {
30+
class ICMPSocket : public InternetSocket {
3131
public:
3232
/** Create an uninitialized socket.
3333
*
3434
* @note Must call open to initialize the socket on a network stack.
3535
*/
36-
RAWIPSocket();
37-
38-
/** Create and open a socket on the network stack of the given
39-
* network interface.
40-
*
41-
* @tparam S Type of the Network stack.
42-
* @param stack Network stack as target for socket.
43-
* @deprecated since mbed-os-5.11
44-
*/
45-
template <typename S>
46-
MBED_DEPRECATED_SINCE("mbed-os-5.11",
47-
"The RAWSocket(S *stack) constructor is deprecated"
48-
"It discards the open() call return value."
49-
"Use another constructor and call open() explicitly, instead.")
50-
RAWIPSocket(S *stack)
51-
{
52-
open(stack);
53-
}
36+
ICMPSocket();
5437

5538
/** Destroy a socket.
5639
*
5740
* @note Closes socket if the socket is still open.
5841
*/
59-
virtual ~RAWIPSocket();
42+
virtual ~ICMPSocket();
6043

6144
/** Send data to the specified host and port.
6245
*
@@ -152,14 +135,14 @@ class RAWIPSocket : public InternetSocket {
152135
*/
153136
virtual nsapi_size_or_error_t recv(void *data, nsapi_size_t size);
154137

155-
/** Not implemented for RAWIPSocket.
138+
/** Not implemented for ICMPSocket.
156139
*
157140
* @param error Not used.
158141
* @return NSAPI_ERROR_UNSUPPORTED
159142
*/
160143
virtual Socket *accept(nsapi_error_t *error = NULL);
161144

162-
/** Not implemented for RAWIPSocket.
145+
/** Not implemented for ICMPSocket.
163146
*
164147
* @param backlog Not used.
165148
* @return NSAPI_ERROR_UNSUPPORTED

features/netsocket/NetworkStack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class NetworkStack: public DNS {
183183

184184
protected:
185185
friend class InternetSocket;
186-
friend class RAWIPSocket;
186+
friend class ICMPSocket;
187187
friend class UDPSocket;
188188
friend class TCPSocket;
189189
friend class TCPServer;

features/netsocket/UDPSocket.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
#include "netsocket/NetworkStack.h"
2525
#include "netsocket/NetworkInterface.h"
2626
#include "rtos/EventFlags.h"
27-
#include "RAWIPSocket.h"
27+
#include "ICMPSocket.h"
2828

2929

3030
/** UDP socket implementation.
3131
*/
32-
class UDPSocket : public RAWIPSocket {
32+
class UDPSocket : public ICMPSocket {
3333
public:
3434
/** Create an uninitialized socket.
3535
*

features/netsocket/nsapi_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ enum nsapi_error {
5656
NSAPI_ERROR_ADDRESS_IN_USE = -3018, /*!< Address already in use */
5757
NSAPI_ERROR_TIMEOUT = -3019, /*!< operation timed out */
5858
NSAPI_ERROR_BUSY = -3020, /*!< device is busy and cannot accept new operation */
59+
NSAPI_ERROR_PROTO_UNKNOWN = -3021, /*!< unknown protocol */
5960
};
6061

6162

0 commit comments

Comments
 (0)