-
Notifications
You must be signed in to change notification settings - Fork 3k
Created PPP interface and PPP service classes to netsocket #10974
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
Conversation
Although not ready for official review, comments appreciated. |
@mikaleppanen, thank you for your changes. |
Rebased to master and updated with latest changes. Pull request is ready for review. @mikter @artokin @kjbracey-arm @AnttiKauppila @kivaisan @AriParkkila |
if (address_type != PHY_MAC_64BIT) { | ||
return -1; | ||
} | ||
//memcpy(unique_id, address_ptr, 8); |
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.
Are these commented codes needed?
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 the write function since not valid for ppp.
phy.PHY_MAC = iid64; | ||
phy.address_write = ppp_phy_address_write; | ||
phy.driver_description = const_cast<char *>("PPP"); | ||
phy.link_type = static_cast<phy_link_type_e>(5); // PHY_LINK_PPP To compile without nanostack changes |
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.
Is there some bigger reason not to define PHY_LINK_PPP
in phy_link_type_e
?
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.
Added the constant to phy_link_type_e.
features/netsocket/PPP.h
Outdated
* @param uname User name | ||
* @param passwrd Password | ||
*/ | ||
virtual void set_uname_password(const char *uname, const char *password) = 0; |
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.
Cellular has used set_credentials
name for these.
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.
Renamed.
features/netsocket/ppp/ppp.c
Outdated
@@ -927,8 +905,8 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) { | |||
*/ | |||
for (i = 0; (protp = protocols[i]) != NULL; ++i) { | |||
if (protp->protocol == protocol) { | |||
pb = pbuf_coalesce(pb, PBUF_RAW); | |||
(*protp->input)(pcb, (u8_t*)pb->payload, pb->len); | |||
///////// pb = pbuf_coalesce(pb, PBUF_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.
Why commented out?
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 as not needed (always a single buffer on this stage).
|
||
void PPPPhy::get_mac_address(uint8_t *mac) | ||
{ | ||
} |
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.
Are get_mac_address and set_mac_address left intentionally empty? If so then comment would be nice.
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.
Refactored nanostack phy classes so that mac address get/set are no longer part of the base class.
features/netsocket/PPPInterface.cpp
Outdated
@@ -0,0 +1,193 @@ | |||
/* | |||
* Copyright (c) 2018 ARM Limited |
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.
Please update copyrigth year in all new files
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.
Corrected
features/netsocket/PPPInterface.cpp
Outdated
|
||
void PPPInterface::set_as_default() | ||
{ | ||
#if 0 |
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.
Please add comment why PPPINterface can't be set as default interface
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 the "if 0" and casting to lwip stack.
Updated pull request with latest changes. Ready for review. |
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.
Architecturally, I'm extremely impressed. This pulls together a whole bunch of Mbed OS concepts that have been partially formed since 5.7 and 5.9, and extends them very elegantly to cover this generic PPP engine,
The whole set-up looks fantastic now, and OnboardNetworkStack
is beautiful.
My only real concern is the forking out of the PPP core from lwip, and what the plan is to track any upstream lwIP PPP changes in future. Do we have the tooling to do that elegantly? I guess git subtree squash might still manage to handle the file renamings - it's just a merge, ultimately, and that can sometimes...?
@@ -338,6 +339,14 @@ class NetworkInterface: public DNS { | |||
return 0; | |||
} | |||
|
|||
/** Return pointer to a MeshInterface. |
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.
PPPInterface
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.
Corrected
features/netsocket/PPPInterface.h
Outdated
* | ||
* Requires that the network is disconnected | ||
* | ||
* @param dhcp False to disable dhcp (defaults to enabled) |
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.
Does this actually have a default argument?
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 whole function from PPP interface since dhcp is not valid for ppp. It is set false on stack bring up.
features/netsocket/PPPInterface.h
Outdated
|
||
mbed::FileHandle *_stream; | ||
nsapi_ip_stack_t _ip_stack; | ||
char _uname[30]; |
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.
Should a define be used instead?
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.
Chained user name and password to pointers inside ppp interface class (similar to cellular interface).
features/netsocket/ppp/source/auth.c
Outdated
#include <netdb.h> | ||
#include <netinet/in.h> | ||
#include <arpa/inet.h> | ||
//#include <netdb.h> |
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.
Should be removed?
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.
@kivaisan @VeijoPesonen Corrected review defects. Could you check that they are ok. |
All review comments handled. |
@ARMmbed/mbed-os-maintainers can this progress? |
Changes approved, CI started. |
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.
[x] Functionality change
Please add release notes section describing this in detail for users
Test run: FAILEDSummary: 3 of 4 test jobs failed Failed test jobs:
|
Corrected compilation errors. |
CI started |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Moved PPP and renamed files and constants.
Created PPP service class that encapsulates the PPP protocol. Class is similar to EMAC and L3IP classes with additional methods to read IP and DNS server addresses negotiation using PPP and to set PPP specific parameters (file handle for modem access etc.). PPP service can use on its own thread or in run in mbed os event Queue thread. Added ppp_nsapi.cpp module that implements the nsapi_ppp.h services. Added ppp_nsapi.cpp module that implements the nsapi_ppp.h services.
PPP service encapsulates the PPP protocol. PPP interface can be used as helper class to bind PPP protocol with network stack (similar to EMAC and L3IP interface). Added PPP interface to onboard network stack class.
Created (a new) PPP interface for PPP service. Removed lwip dependencies to PPP (memory allocations etc.). Moved PPP configuration options away from lwIP mbed_lib.json to new PPP service. For backwards compatibility, using the old options is also currently supported.
Created PPP interface for PPP service. Re-used the ethernet tasklet and PHY driver structure for PPP.
If PPP interface is the lwIP default interface, adds the PPP DNS servers to default DNS server storage. If PPP is not default interface, then adds DNS servers to interface specific storage.
Increased stack size from 768 to 816.
Corrected PPP thread stack size for RZ_A1_EMAC, CYW943012P6EVB_01, CY8CPROTO_062_4343W, CY8CKIT_062_WIFI_BT and CY8CKIT_062S2_43012 that have special configuration for PPP thread size. Removed pppInterface() helper call from network interface. It causes binary compatibility break with precompiled network interface classes. Call is helper function to check network interface type in case it is unknown, and is not mandatory or used with PPP.
Recent merges caused the conflict, please rebase and we shall restart CI asap |
CI started |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Description
Created PPP interface and PPP service classes to netsocket. This allows that both lwip and nanostack can use a common PPP service for cellular connectivity. Lwip PPP protocol is separated from lwip and moved under netsocket as an independent entity. PPP offers much similar interface for (onboard) network stack as the EMAC and L3IP. PPPInterface class has been created as similar helper class as the EMACInterface and L3IPInterface are.
The "nsapi_ppp.h" interface is kept same, and the implementation for it is in ppp service file "ppp_nsapi.cpp". Cellular classes using the "nsapi_ppp.h" interface should not need updates. Existing ppp configuration under lwip mbed_lib.json is still supported, although configuration under ppp service should be used instead.
Most major changes to internal structure of PPP were, to replace its interface to lwip netif with new one and to make PPP to use network stack's memory manager for memory allocations, instead of direct access to lwip memory buffers.
Pull request type
Reviewers
Release Notes
Add Cellular PPP connection support to Nanostack. Support is made by creating a common PPP service class that both lwIP and Nanostack can use for cellular connectivity.
Affected components are lwIP and Nanostack on board IP stacks, new netsocket PPP interface and PPP service class. Cellular network interface, cellular classes and "nsapi_ppp.h" interface are not modified. No changes are required from the users of the Cellular network interface to continue using the lwIP as the default IP stack.
To use the Nanostack IP stack with the Cellular network interface instead of the lwIP stack, cellular application configuration must be modified in following way:
Set the default stack to nanostack
"nsapi.default-stack": "NANOSTACK"
Configure PPP to IPv6 only mode (Nanostack does not support IPv4)
"ppp.ipv4-enabled": false, "ppp.ipv6-enabled": true,