Skip to content

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

Merged
merged 11 commits into from
Aug 21, 2019
Merged

Created PPP interface and PPP service classes to netsocket #10974

merged 11 commits into from
Aug 21, 2019

Conversation

mikaleppanen
Copy link

@mikaleppanen mikaleppanen commented Jul 5, 2019

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

[ ] Fix
[ ] Refactor
[ ] Target update
[X] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

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,

@mikaleppanen
Copy link
Author

Although not ready for official review, comments appreciated.
@mikter @artokin @kjbracey-arm @AnttiKauppila @kivaisan @AriParkkila

@ciarmcom
Copy link
Member

ciarmcom commented Jul 5, 2019

@mikaleppanen, thank you for your changes.
@ARMmbed/mbed-os-ipcore @ARMmbed/mbed-os-maintainers please review.

@mikaleppanen
Copy link
Author

Rebased to master and updated with latest changes. Pull request is ready for review.

@mikter @artokin @kjbracey-arm @AnttiKauppila @kivaisan @AriParkkila
@ARMmbed/mbed-os-ipcore @ARMmbed/mbed-os-maintainers

if (address_type != PHY_MAC_64BIT) {
return -1;
}
//memcpy(unique_id, address_ptr, 8);
Copy link
Contributor

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?

Copy link
Author

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
Copy link
Contributor

@kivaisan kivaisan Aug 7, 2019

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?

Copy link
Author

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.

* @param uname User name
* @param passwrd Password
*/
virtual void set_uname_password(const char *uname, const char *password) = 0;
Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed.

@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why commented out?

Copy link
Author

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)
{
}
Copy link
Contributor

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.

Copy link
Author

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.

@@ -0,0 +1,193 @@
/*
* Copyright (c) 2018 ARM Limited
Copy link
Contributor

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected


void PPPInterface::set_as_default()
{
#if 0
Copy link
Contributor

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

Copy link
Author

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.

@mikaleppanen
Copy link
Author

Updated pull request with latest changes. Ready for review.

Copy link
Contributor

@kjbracey kjbracey left a 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PPPInterface

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected

*
* Requires that the network is disconnected
*
* @param dhcp False to disable dhcp (defaults to enabled)
Copy link
Contributor

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?

Copy link
Author

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.


mbed::FileHandle *_stream;
nsapi_ip_stack_t _ip_stack;
char _uname[30];
Copy link
Contributor

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?

Copy link
Author

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).

#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
//#include <netdb.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be removed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@mikaleppanen
Copy link
Author

@kivaisan @VeijoPesonen Corrected review defects. Could you check that they are ok.

@mikaleppanen
Copy link
Author

All review comments handled.
Tidied up the commit history by merging corrections found by review and hardware testing to original commits.
Cellular automated greentea hardware tests and manual tests are passing for this PR.
@AriParkkila / @AnttiKauppila is the review ok? If it is, then I think PR should enter testing phase.

@mikaleppanen
Copy link
Author

@ARMmbed/mbed-os-maintainers can this progress?

@artokin
Copy link
Contributor

artokin commented Aug 19, 2019

Changes approved, CI started.

Copy link
Contributor

@0xc0170 0xc0170 left a 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

@mbed-ci
Copy link

mbed-ci commented Aug 19, 2019

Test run: FAILED

Summary: 3 of 4 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-ARM
  • jenkins-ci/mbed-os-ci_build-IAR
  • jenkins-ci/mbed-os-ci_build-GCC_ARM

@mikaleppanen
Copy link
Author

Corrected compilation errors.

@artokin
Copy link
Contributor

artokin commented Aug 19, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Aug 20, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 2
Build artifacts

KariHaapalehto and others added 11 commits August 20, 2019 13:27
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.
@0xc0170
Copy link
Contributor

0xc0170 commented Aug 20, 2019

Recent merges caused the conflict, please rebase and we shall restart CI asap

@artokin
Copy link
Contributor

artokin commented Aug 20, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Aug 20, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 3
Build artifacts

@0xc0170 0xc0170 merged commit 399b517 into ARMmbed:master Aug 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.