-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LwIP: add ICMPv4 Socket support #10978
Conversation
@vmedcy, thank you for your changes. |
features/lwipstack/lwipopts.h
Outdated
@@ -84,7 +84,7 @@ | |||
#define SYS_LIGHTWEIGHT_PROT 1 | |||
|
|||
#ifndef LWIP_RAW | |||
#define LWIP_RAW 0 | |||
#define LWIP_RAW 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be configurable via JSON, like TCP. Enabling raw socket support will increase build size of lwIP, and most people will not need it.
I think it should be off by default, but maybe that could be debated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I agree.
features/netsocket/NetworkStack.h
Outdated
@@ -184,6 +184,7 @@ class NetworkStack: public DNS { | |||
protected: | |||
friend class InternetSocket; | |||
friend class UDPSocket; | |||
friend class RAWSocket; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RawIPSocket
. RAW is not an acronym, and I think we need to distinguish from non-IP cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there some way to create an ICMP Socket by re-using UDPSocket class ( such as InternetDatagram Socket with ICMP protocol it would be nice)
features/netsocket/nsapi_types.h
Outdated
@@ -127,6 +127,7 @@ typedef enum nsapi_security { | |||
NSAPI_SECURITY_CHAP = 0x6, /*!< phrase conforms to PPP authentication context */ | |||
NSAPI_SECURITY_EAP_TLS = 0x7, /*!< phrase conforms to EAP-TLS */ | |||
NSAPI_SECURITY_PEAP = 0x8, /*!< phrase conforms to PEAP */ | |||
NSAPI_SECURITY_WPA2_ENT = 0x9, /*!< phrase conforms to WPA2-AES and WPA-TKIP with enterprise security */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems separate to this PR. Can you make it separate - group it with any other change it applies too.
features/netsocket/nsapi_types.h
Outdated
@@ -266,6 +268,7 @@ typedef enum nsapi_socket_option { | |||
NSAPI_ADD_MEMBERSHIP, /*!< Add membership to multicast address */ | |||
NSAPI_DROP_MEMBERSHIP, /*!< Drop membership to multicast address */ | |||
NSAPI_BIND_TO_DEVICE, /*!< Bind socket network interface name*/ | |||
NSAPI_IP_TOS, /*!< IP TOS */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate out from this PR - if you're adding it, I would want to see at least 1 of lwIP or Nanostack support to illustrate the parameter type.
features/netsocket/RAWSocket.h
Outdated
* | ||
* To be used within accept() function. Close() will clean this up. | ||
*/ | ||
RAWSocket(RAWSocket *parent, nsapi_socket_t socket, SocketAddress address); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was copied from TCPSocket? Not needed for raw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this change by copying from UDPSocket.cpp, yes it is not needed for RAWSocket
features/netsocket/RAWSocket.cpp
Outdated
#include "Timer.h" | ||
#include "mbed_assert.h" | ||
|
||
RAWSocket::RAWSocket() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a big duplication of UDPSocket (another one after CellularNonIPSocket
). In this case it's so similar, because it's NSAPI, that I'm thinking there should be an InternetDatagramSocket
base class to subsume the commonality, that both this and UDPSocket
inherit from.
What do others think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes InternetDatagramSocket can be a base class, if Application needs to create an ICMP socket they can use this class.
@balajicyp @vmedcy - Can you confirm the status of this PR from your side? It is showing changes requested. Is there a clear way forward? |
If this comes to 5.14, it should be updated soon. |
I expect @balajicyp will respond next week after return from vacation. |
If this wants to be in 5.14, it needs to be updated soon as 5.14 code freeze is end of this week. |
I will take up this work this week. The Enabling of the option LWIP_RAW will be done by *overrides in Application json file, so that by default this option will be off. |
I have my changes here at 23b0891 , I try to push to same PR but there is some refs which are mismatched |
I have the new changes pushed here, please review and merge |
@kjbracey-arm @AnttiKauppila please re-review. |
} else if (proto == NSAPI_UDP) { | ||
netconntype = NETCONN_UDP; | ||
} else { | ||
netconntype = NETCONN_RAW; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future-proofing, can you make this error for unknown proto
? I know it didn't before, but it should have,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean the known proto be NASPI_ERROR_PROTO_UNKNOWN and return from function as below.
...
} else if (proto == NSAPI_UDP) {
netconntype = NETCONN_UDP;
} else if { proto == NSAPI_ICMP) {
netconntype = NETCONN_RAW;
} else {
return NSAPI_ERROR_PROTO_UNKNOWN;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed NSAPI_ERROR_PROTO_UNKNOWN
features/netsocket/RAWIPSocket.cpp
Outdated
#include "Timer.h" | ||
#include "mbed_assert.h" | ||
|
||
RAWIPSocket::RAWIPSocket() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In earlier review we agreed this should become ICMPSocket
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I can change it to ICMPSocket.h and ICMPSocket.cpp and change class names accordingly.
features/netsocket/RAWIPSocket.h
Outdated
"The RAWSocket(S *stack) constructor is deprecated" | ||
"It discards the open() call return value." | ||
"Use another constructor and call open() explicitly, instead.") | ||
RAWIPSocket(S *stack) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to include a deprecated constructor in a new class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I will remove RAWIPSocket(S *stack)
features/netsocket/UDPSocket.h
Outdated
|
||
|
||
/** UDP socket implementation. | ||
*/ | ||
class UDPSocket : public InternetSocket { | ||
class UDPSocket : public RAWIPSocket { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code sharing is good, but the class heirarchy is off. This lets you pass a UDPSocket *
to someone expecting a RAWIPSocket *
. Previous discussion suggested inserting an underlying datagram socket base class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kjbracey-arm, Please specify more details what functions Datagram Socket Base class should have? is it all the methods except for the constructor and get_proto()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kjbracey-arm, I have added the InternetDatagram.h/InternetDatagram.cpp as Base Class, Please review.
PR was updated, @kjbracey-arm @tymoteuszblochmobica Please review Note, we are close to the 5.14 code freeze. This needs update asap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nearly there. Just minor tidies and elimination of unneeded bits.
@vmedcy Let us know once answered reviewers comments above. IF this is targeting 5.14, needs to be updated asap to get its approvals otherwise will be moved to the next minor version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kjbracey-arm, I have uploaded the latest changes based on your comments, please review the same.
Test run: FAILEDSummary: 1 of 4 test jobs failed Failed test jobs:
|
One more commit to be added
@vmedcy Please see this response above - it should fix unittests, cherry-pick it to your branch |
@0xc0170 |
CI restarted |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
@vmedcy One missing thing for this one, please add release notes for this addition. |
The basic description and summary needs to be updated too - it's now adding |
On which note, I've very belatedly realised that this implementation is specifically making an ICMPv4 socket ( ICMPv6 is a different protocol, so I guess it logically would be a separate So this is fine. But it should be mentioned in the release notes/docs that this is ICMPv4, and ICMPv6 is not currently supported. |
@balajicyp I updated the release notes and description appropriately. |
Thanks @vmedcy |
Description
Implement ICMPSocket class, make LWIP_RAW option configurable with lwip.raw_socket_enabled, and update socket_open to support nsapi_protocol_t::NSAPI_ICMP.
This allows the application layer to hook into the IP layer itself.
This feature supports only ICMP socket (ICMPv4) and not RAW Socket
Pull request type
Reviewers
@kjbracey-arm @tymoteuszblochmobica
Release Notes
netsocket feature is extended with ICMP socket implementation. This change is only for ICMPv4 and ICMPv6 is not currently supported