TinyPPP
PPP networking over any Arduino Stream
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions | Variables
tinyppp Namespace Reference

TinyPPP internals: PPP engine, HDLC framing and the IP stack. More...

Classes

class  Checksum
 Internet checksum (RFC 1071) over several (possibly odd sized) pieces. More...
 
class  HDLCDecoder
 HDLC frame decoder (RFC 1662). More...
 
class  HDLCEncoder
 HDLC frame encoder (RFC 1662). More...
 
class  IPStack
 Minimal IPv4 stack (ICMP echo, UDP, TCP, DNS resolver) for platforms without lwIP. More...
 
class  PPPClient
 TCP client over PPP: used like WiFiClient or EthernetClient. More...
 
class  PPPEngine
 Portable PPP engine: LCP, PAP client and IPCP over an Arduino Stream. More...
 
class  PPPServer
 TCP server over PPP: used like WiFiServer or EthernetServer. More...
 
struct  PPPStats
 Frame and packet counters of a PPPEngine. More...
 
class  PPPUDP
 UDP socket over PPP: used like WiFiUDP or EthernetUDP. More...
 
class  RingBuffer
 Byte ring buffer with a fixed capacity of N bytes. More...
 
class  TinyPPP_ESP32
 PPP network interface for ESP32 (arduino-esp32 3.x): ESP-IDF lwIP PPP via esp_netif, integrated as a NetworkInterface. More...
 
class  TinyPPP_Generic
 PPP network interface for platforms without lwIP: the PPP engine combined with the TinyPPP IPStack (TCP, UDP, ICMP echo and DNS). More...
 
class  TinyPPP_RP2040
 PPP network interface for RP2040 / RP2350 (arduino-pico): the TinyPPP engine registered as a point-to-point lwIP netif. More...
 

Typedefs

using ip4_t = uint32_t
 IPv4 address in network byte order as stored in memory.
 
using PPPClient = NetworkClient
 Portable aliases for the network classes that work over PPP.
 
using PPPServer = NetworkServer
 
using PPPUDP = NetworkUDP
 
using TinyPPP = TinyPPP_ESP32
 The PPP network interface of this platform.
 

Enumerations

enum  CPCode : uint8_t {
  CONF_REQ = 1 , CONF_ACK = 2 , CONF_NAK = 3 , CONF_REJ = 4 ,
  TERM_REQ = 5 , TERM_ACK = 6 , CODE_REJ = 7 , PROT_REJ = 8 ,
  ECHO_REQ = 9 , ECHO_REP = 10 , DISCARD_REQ = 11
}
 Control protocol (LCP, IPCP) packet codes. More...
 
enum class  CPState : uint8_t {
  Initial , Stopped , Closing , ReqSent ,
  AckRcvd , AckSent , Opened
}
 Simplified RFC 1661 automaton states. More...
 
enum  IPCPOption : uint8_t { IPCP_COMPRESSION = 2 , IPCP_ADDRESS = 3 , IPCP_DNS1 = 129 , IPCP_DNS2 = 131 }
 IPCP configuration options. More...
 
enum  LCPOption : uint8_t {
  LCP_MRU = 1 , LCP_ACCM = 2 , LCP_AUTH = 3 , LCP_MAGIC = 5 ,
  LCP_PFC = 7 , LCP_ACFC = 8
}
 LCP configuration options. More...
 
enum class  PPPPhase : uint8_t {
  Dead , Establish , Authenticate , Network ,
  Running , Terminate
}
 Overall link phase. More...
 
enum class  TCPState : uint8_t {
  Closed , SynSent , SynRcvd , Established ,
  FinWait1 , FinWait2 , CloseWait , Closing ,
  LastAck , TimeWait
}
 TCP connection states (RFC 793) More...
 

Functions

uint16_t fcs16 (const uint8_t *data, size_t len, uint16_t fcs=FCS16_INIT)
 FCS-16 over a buffer (continues from fcs)
 
uint16_t fcs16Update (uint16_t fcs, uint8_t b)
 Incremental FCS-16 (RFC 1662, reflected CRC-CCITT) using a nibble table.
 
ip4_t fromIPAddress (const IPAddress &ip)
 Converts an Arduino IPAddress to an engine address (0 if not set)
 
ip4_t toIp4 (uint8_t a, uint8_t b, uint8_t c, uint8_t d)
 Builds an address from its 4 bytes (a.b.c.d)
 
IPAddress toIPAddress (ip4_t ip)
 Converts an engine address to an Arduino IPAddress.
 
const char * toStr (PPPPhase p)
 Name of a phase (for logging)
 

Variables

static constexpr uint16_t FCS16_GOOD = 0xF0B8
 
static constexpr uint16_t FCS16_INIT = 0xFFFF
 
static constexpr uint8_t HDLC_ALL_STATIONS = 0xFF
 
static constexpr uint8_t HDLC_ESCAPE = 0x7D
 
static constexpr uint8_t HDLC_FLAG = 0x7E
 
static constexpr uint8_t HDLC_UI = 0x03
 
static constexpr uint8_t HDLC_XOR = 0x20
 
static constexpr uint16_t PPP_IP = 0x0021
 PPP protocol numbers.
 
static constexpr uint16_t PPP_IPCP = 0x8021
 
static constexpr uint16_t PPP_IPV6 = 0x0057
 
static constexpr uint16_t PPP_LCP = 0xC021
 
static constexpr uint16_t PPP_PAP = 0xC023
 

Detailed Description

TinyPPP internals: PPP engine, HDLC framing and the IP stack.

HDLC-like framing for PPP (RFC 1662): FCS-16, byte stuffing and frame reassembly. Platform independent: only depends on the Arduino Print API.

Generic implementation for platforms without lwIP: SAMD and mbed based WiFiNINA boards (Nano 33 IoT, MKR WiFi 1010, Nano RP2040 Connect), the desktop (Arduino-Emulator) and other cores.

The PPP engine is combined with the small TinyPPP IPStack, so PPPClient, PPPServer and PPPUDP work over the link. Received IPv4 packets that are not handled by the stack can be processed with onReceive(), and raw packets can be sent with send().

There is no background task: the link is processed by all socket methods and by loop(). Call loop() regularly when the sketch does not use a socket for a while.

Typedef Documentation

◆ ip4_t

IPv4 address in network byte order as stored in memory.

IPv4 address in network byte order as stored in memory (same as lwIP)

◆ PPPClient

Portable aliases for the network classes that work over PPP.

◆ PPPServer

◆ PPPUDP

◆ TinyPPP

The PPP network interface of this platform.

Enumeration Type Documentation

◆ CPCode

Control protocol (LCP, IPCP) packet codes.

Enumerator
CONF_REQ 
CONF_ACK 
CONF_NAK 
CONF_REJ 
TERM_REQ 
TERM_ACK 
CODE_REJ 
PROT_REJ 
ECHO_REQ 
ECHO_REP 
DISCARD_REQ 

◆ CPState

Simplified RFC 1661 automaton states.

Enumerator
Initial 
Stopped 
Closing 
ReqSent 
AckRcvd 
AckSent 
Opened 

◆ IPCPOption

IPCP configuration options.

Enumerator
IPCP_COMPRESSION 
IPCP_ADDRESS 
IPCP_DNS1 
IPCP_DNS2 

◆ LCPOption

LCP configuration options.

Enumerator
LCP_MRU 
LCP_ACCM 
LCP_AUTH 
LCP_MAGIC 
LCP_PFC 
LCP_ACFC 

◆ PPPPhase

Overall link phase.

Enumerator
Dead 
Establish 
Authenticate 
Network 
Running 
Terminate 

◆ TCPState

TCP connection states (RFC 793)

Enumerator
Closed 
SynSent 
SynRcvd 
Established 
FinWait1 
FinWait2 
CloseWait 
Closing 
LastAck 
TimeWait 

Function Documentation

◆ fcs16()

uint16_t fcs16 ( const uint8_t *  data,
size_t  len,
uint16_t  fcs = FCS16_INIT 
)
inline

FCS-16 over a buffer (continues from fcs)

◆ fcs16Update()

uint16_t fcs16Update ( uint16_t  fcs,
uint8_t  b 
)
inline

Incremental FCS-16 (RFC 1662, reflected CRC-CCITT) using a nibble table.

◆ fromIPAddress()

ip4_t fromIPAddress ( const IPAddress &  ip)
inline

Converts an Arduino IPAddress to an engine address (0 if not set)

◆ toIp4()

ip4_t toIp4 ( uint8_t  a,
uint8_t  b,
uint8_t  c,
uint8_t  d 
)
inline

Builds an address from its 4 bytes (a.b.c.d)

◆ toIPAddress()

IPAddress toIPAddress ( ip4_t  ip)
inline

Converts an engine address to an Arduino IPAddress.

◆ toStr()

const char * toStr ( PPPPhase  p)
inline

Name of a phase (for logging)

Variable Documentation

◆ FCS16_GOOD

constexpr uint16_t FCS16_GOOD = 0xF0B8
staticconstexpr

◆ FCS16_INIT

constexpr uint16_t FCS16_INIT = 0xFFFF
staticconstexpr

◆ HDLC_ALL_STATIONS

constexpr uint8_t HDLC_ALL_STATIONS = 0xFF
staticconstexpr

◆ HDLC_ESCAPE

constexpr uint8_t HDLC_ESCAPE = 0x7D
staticconstexpr

◆ HDLC_FLAG

constexpr uint8_t HDLC_FLAG = 0x7E
staticconstexpr

◆ HDLC_UI

constexpr uint8_t HDLC_UI = 0x03
staticconstexpr

◆ HDLC_XOR

constexpr uint8_t HDLC_XOR = 0x20
staticconstexpr

◆ PPP_IP

constexpr uint16_t PPP_IP = 0x0021
staticconstexpr

PPP protocol numbers.

◆ PPP_IPCP

constexpr uint16_t PPP_IPCP = 0x8021
staticconstexpr

◆ PPP_IPV6

constexpr uint16_t PPP_IPV6 = 0x0057
staticconstexpr

◆ PPP_LCP

constexpr uint16_t PPP_LCP = 0xC021
staticconstexpr

◆ PPP_PAP

constexpr uint16_t PPP_PAP = 0xC023
staticconstexpr