|
TinyPPP
PPP networking over any Arduino Stream
|
PPP network interface for RP2040 / RP2350 (arduino-pico): the TinyPPP engine registered as a point-to-point lwIP netif. More...
#include <TinyPPP_RP2040.h>
Public Types | |
| using | StateCallback = void(*)(bool up, void *ref) |
| Callback for link up/down. | |
Public Member Functions | |
| TinyPPP_RP2040 ()=default | |
| TinyPPP_RP2040 (const TinyPPP_RP2040 &)=delete | |
| ~TinyPPP_RP2040 () | |
| bool | begin (Stream &io) |
| bool | config (IPAddress local, IPAddress peer=IPAddress(0, 0, 0, 0), IPAddress dns1=IPAddress(0, 0, 0, 0), IPAddress dns2=IPAddress(0, 0, 0, 0)) |
| bool | connected () const |
| true when the link is up and has an IP address | |
| IPAddress | dnsIP (int n=0) const |
| The DNS server n (0 or 1) received from the peer. | |
| void | end () |
| Terminates the link and removes the interface. | |
| uint32_t | fcsErrors () const |
| Number of received frames with a wrong FCS. | |
| IPAddress | gatewayIP () const |
| The IP address of the peer. | |
| struct netif * | getNetIf () |
| The lwIP netif of the interface. | |
| IPAddress | localIP () const |
| Our IP address. | |
| void | onStateChange (StateCallback cb, void *ref=nullptr) |
| TinyPPP_RP2040 & | operator= (const TinyPPP_RP2040 &)=delete |
| PPPPhase | phase () const |
| Current link phase. | |
| void | setCredentials (const char *user, const char *password) |
| PAP credentials (used only if the peer requires authentication) | |
| void | setDefault (bool flag=true) |
| Make this interface the default route when the link is up (default true) | |
| void | setEchoInterval (uint32_t ms, uint8_t maxFailures=3) |
| LCP echo keep-alive: 0 disables it. | |
| void | setLogger (Print &out) |
| Debug output e.g. setLogger(Serial1) | |
| void | setPassive (bool passive) |
| Passive: do not send LCP requests before the peer starts negotiating. | |
| void | setPollingPeriod (int ms) |
| void | setRequestDNS (bool flag) |
| Request DNS servers from the peer (default true) | |
| const PPPStats & | stats () const |
| Frame and packet counters. | |
| wl_status_t | status () const |
| WL_CONNECTED when the link is up, WL_NO_SHIELD before begin() | |
| IPAddress | subnetMask () const |
| Always 255.255.255.255 (point-to-point link) | |
| bool | waitConnected (uint32_t timeoutMs=30000) |
| Waits until the link is up. | |
Protected Types | |
| enum class | Cmd : uint8_t { None , Start , Stop } |
Protected Member Functions | |
| bool | beginIPv4 () |
| Streaming API for chained buffers (e.g. lwIP pbuf) | |
| ip4_t | dns1 () const |
| First DNS server received from the peer. | |
| ip4_t | dns2 () const |
| Second DNS server received from the peer. | |
| bool | endIPv4 () |
| Sends the packet started with beginIPv4() | |
| void | input (const uint8_t *data, size_t len) |
| bool | isStarted () const |
| true after start() until stop() | |
| bool | isUp () const |
| true when IPCP is open and IPv4 packets can be exchanged | |
| void | logf (const char *fmt,...) |
| uint16_t | mtu () const |
| MTU we may use for sending (peer MRU) | |
| void | onIPv4Packet (const uint8_t *data, size_t len) override |
| Called for each received IPv4 packet. | |
| void | onLinkDown () override |
| Called when the IP link goes down. | |
| void | onLinkUp () override |
| Called when IPCP is opened: addresses are available. | |
| virtual void | onPhase (PPPPhase phase) |
| Called on phase changes. | |
| ip4_t | peerIP () const |
| IP address of the peer. | |
| void | poll () |
| void | process () |
| Reads available input and runs the timers: call frequently. | |
| void | processTimers (uint32_t now) |
| Runs the retransmission and keep-alive timers. | |
| bool | sendIPv4 (const uint8_t *data, size_t len) |
| Sends a complete IPv4 packet. | |
| void | setLocalIP (ip4_t ip) |
| Optional static address configuration. 0 = negotiate with the peer. | |
| void | setLogger (Print *log) |
| Debug output (nullptr to disable) | |
| void | setOfferedDNS (ip4_t dns1, ip4_t dns2=0) |
| DNS servers to offer the peer if it asks for them (server role) | |
| void | setPeerIP (ip4_t ip) |
| Address to assign to the peer if it requests one (server role) | |
| void | start (Stream &io) |
| Starts the PPP negotiation on the indicated stream. | |
| void | stop () |
| Closes the link gracefully (sends LCP Terminate-Request) | |
| void | writeIPv4 (const uint8_t *data, size_t len) |
| Adds data to the packet started with beginIPv4() | |
Static Protected Member Functions | |
| static const char * | ipStr (ip4_t ip, char *buf) |
| static err_t | netifInit (struct netif *netif) |
| static err_t | output4 (struct netif *netif, struct pbuf *p, const ip4_addr_t *addr) |
Protected Attributes | |
| volatile Cmd | _cmd = Cmd::None |
| bool | _default = true |
| Stream * | _io = nullptr |
| struct netif | _netif |
| bool | _netifAdded = false |
| int | _phID = -1 |
| StateCallback | _stateCallback = nullptr |
| void * | _stateRef = nullptr |
| volatile bool | _up = false |
PPP network interface for RP2040 / RP2350 (arduino-pico): the TinyPPP engine registered as a point-to-point lwIP netif.
|
default |
|
delete |
|
inline |
Starts PPP over the indicated stream (e.g. Serial, Serial1). The stream must already be opened (Serial.begin()). Returns immediately: use connected() or waitConnected() to wait for the link.
|
inlineinherited |
Streaming API for chained buffers (e.g. lwIP pbuf)
|
inline |
Optional static configuration. local: our address (otherwise assigned by the peer); peer: address assigned to the peer if it asks for one; dns1 and dns2: DNS servers offered to the peer. Call before begin().
|
inline |
true when the link is up and has an IP address
|
inlineinherited |
First DNS server received from the peer.
|
inlineinherited |
Second DNS server received from the peer.
|
inline |
Terminates the link and removes the interface.
|
inlineinherited |
Sends the packet started with beginIPv4()
|
inline |
Number of received frames with a wrong FCS.
|
inline |
The IP address of the peer.
Feeds raw bytes (alternative to process() when you read the stream yourself)
|
inlineinherited |
true when IPCP is open and IPv4 packets can be exchanged
|
inline |
Our IP address.
|
inlineinherited |
MTU we may use for sending (peer MRU)
Called for each received IPv4 packet.
Reimplemented from PPPEngine.
|
inlineoverrideprotectedvirtual |
Called when the IP link goes down.
Reimplemented from PPPEngine.
|
inlineoverrideprotectedvirtual |
Called when IPCP is opened: addresses are available.
Reimplemented from PPPEngine.
|
inline |
Callback for link up/down (called from the lwIP context); ref is passed to the callback
|
delete |
|
inlinestaticprotected |
|
inlineinherited |
IP address of the peer.
|
inline |
Current link phase.
|
inlineprotected |
|
inlineinherited |
Reads available input and runs the timers: call frequently.
PAP credentials (used only if the peer requires authentication)
Make this interface the default route when the link is up (default true)
LCP echo keep-alive: 0 disables it.
Optional static address configuration. 0 = negotiate with the peer.
DNS servers to offer the peer if it asks for them (server role)
Passive: do not send LCP requests before the peer starts negotiating.
Address to assign to the peer if it requests one (server role)
Poll interval of the lwIP background task in ms (shared by all polled interfaces). Lower values give more throughput.
|
inline |
WL_CONNECTED when the link is up, WL_NO_SHIELD before begin()
|
inlineinherited |
Closes the link gracefully (sends LCP Terminate-Request)
|
inline |
Always 255.255.255.255 (point-to-point link)
Adds data to the packet started with beginIPv4()
|
protected |
|
protected |