ppp.c File Reference

PPP (Point-to-Point Protocol) More...

#include "core/net.h"
#include "ppp/ppp.h"
#include "ppp/ppp_hdlc.h"
#include "ppp/ppp_debug.h"
#include "ppp/lcp.h"
#include "ppp/ipcp.h"
#include "ppp/ipv6cp.h"
#include "ppp/pap.h"
#include "ppp/chap.h"
#include "mibs/mib2_module.h"
#include "mibs/if_mib_module.h"
#include "str.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   PPP_TRACE_LEVEL
 

Functions

void pppGetDefaultSettings (PppSettings *settings)
 Initialize settings with default values. More...
 
error_t pppInit (PppContext *context, const PppSettings *settings)
 PPP initialization. More...
 
error_t pppSetTimeout (NetInterface *interface, systime_t timeout)
 Set timeout value for blocking operations. More...
 
error_t pppSetAuthInfo (NetInterface *interface, const char_t *username, const char_t *password)
 Set PPP authentication information. More...
 
bool_t pppCheckPassword (NetInterface *interface, const char_t *password)
 Password verification. More...
 
error_t pppSendAtCommand (NetInterface *interface, const char_t *data)
 Send AT command. More...
 
error_t pppReceiveAtCommand (NetInterface *interface, char_t *data, size_t size)
 Wait for an incoming AT command. More...
 
error_t pppConnect (NetInterface *interface)
 Establish a PPP connection. More...
 
error_t pppClose (NetInterface *interface)
 Close a PPP connection. More...
 
void pppTick (NetInterface *interface)
 PPP timer handler. More...
 
void pppProcessFrame (NetInterface *interface, uint8_t *frame, size_t length, NetRxAncillary *ancillary)
 Process an incoming PPP frame. More...
 
error_t pppSendFrame (NetInterface *interface, NetBuffer *buffer, size_t offset, uint16_t protocol)
 Send a PPP frame. More...
 
size_t pppParseFrameHeader (const uint8_t *frame, size_t length, uint16_t *protocol)
 Parse PPP frame header. More...
 
uint16_t pppCalcFcs (const uint8_t *data, size_t length)
 FCS calculation. More...
 
uint16_t pppCalcFcsEx (const NetBuffer *buffer, size_t offset, size_t length)
 Calculate FCS over a multi-part buffer. More...
 
NetBufferpppAllocBuffer (size_t length, size_t *offset)
 Allocate a buffer to hold a PPP frame. More...
 

Variables

systime_t pppTickCounter
 

Detailed Description

PPP (Point-to-Point Protocol)

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.4

Definition in file ppp.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   PPP_TRACE_LEVEL

Definition at line 32 of file ppp.c.

Function Documentation

◆ pppAllocBuffer()

NetBuffer* pppAllocBuffer ( size_t  length,
size_t *  offset 
)

Allocate a buffer to hold a PPP frame.

Parameters
[in]lengthDesired payload length
[out]offsetOffset to the first byte of the payload
Returns
The function returns a pointer to the newly allocated buffer. If the system is out of resources, NULL is returned

Definition at line 1305 of file ppp.c.

◆ pppCalcFcs()

uint16_t pppCalcFcs ( const uint8_t *  data,
size_t  length 
)

FCS calculation.

Parameters
[in]dataPointer to the data over which to calculate the FCS
[in]lengthNumber of bytes to process
Returns
Resulting FCS value

Definition at line 1220 of file ppp.c.

◆ pppCalcFcsEx()

uint16_t pppCalcFcsEx ( const NetBuffer buffer,
size_t  offset,
size_t  length 
)

Calculate FCS over a multi-part buffer.

Parameters
[in]bufferPointer to the multi-part buffer
[in]offsetOffset from the beginning of the buffer
[in]lengthNumber of bytes to process
Returns
Resulting FCS value

Definition at line 1248 of file ppp.c.

◆ pppCheckPassword()

bool_t pppCheckPassword ( NetInterface interface,
const char_t password 
)

Password verification.

Parameters
[in]interfaceUnderlying network interface
[in]passwordNULL-terminated string containing the password to be checked
Returns
TRUE if the password is valid, else FALSE

Definition at line 283 of file ppp.c.

◆ pppClose()

error_t pppClose ( NetInterface interface)

Close a PPP connection.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 744 of file ppp.c.

◆ pppConnect()

error_t pppConnect ( NetInterface interface)

Establish a PPP connection.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 475 of file ppp.c.

◆ pppGetDefaultSettings()

void pppGetDefaultSettings ( PppSettings settings)

Initialize settings with default values.

Parameters
[out]settingsStructure that contains PPP settings

Definition at line 98 of file ppp.c.

◆ pppInit()

error_t pppInit ( PppContext context,
const PppSettings settings 
)

PPP initialization.

Parameters
[in]contextPointer to the PPP context
[in]settingsPPP specific settings
Returns
Error code

Definition at line 124 of file ppp.c.

◆ pppParseFrameHeader()

size_t pppParseFrameHeader ( const uint8_t *  frame,
size_t  length,
uint16_t *  protocol 
)

Parse PPP frame header.

Parameters
[in]framePointer to the PPP frame
[in]lengthLength of the frame, in bytes
[out]protocolValue of the Protocol field
Returns
If the PPP header was successfully parsed, the function returns the size of the PPP header, in bytes. If a parsing error occurred, zero is returned

Definition at line 1148 of file ppp.c.

◆ pppProcessFrame()

void pppProcessFrame ( NetInterface interface,
uint8_t *  frame,
size_t  length,
NetRxAncillary ancillary 
)

Process an incoming PPP frame.

Parameters
[in]interfaceUnderlying network interface
[in]frameIncoming PPP frame to process
[in]lengthTotal frame length
[in]ancillaryAdditional options passed to the stack along with the packet

Definition at line 909 of file ppp.c.

◆ pppReceiveAtCommand()

error_t pppReceiveAtCommand ( NetInterface interface,
char_t data,
size_t  size 
)

Wait for an incoming AT command.

Parameters
[in]interfaceUnderlying network interface
[out]dataBuffer where to store the incoming AT command
[in]sizeSize of the buffer, in bytes
Returns
Error code

Definition at line 394 of file ppp.c.

◆ pppSendAtCommand()

error_t pppSendAtCommand ( NetInterface interface,
const char_t data 
)

Send AT command.

Parameters
[in]interfaceUnderlying network interface
[in]dataNULL-terminated string that contains the AT command to be sent
Returns
Error code

Definition at line 330 of file ppp.c.

◆ pppSendFrame()

error_t pppSendFrame ( NetInterface interface,
NetBuffer buffer,
size_t  offset,
uint16_t  protocol 
)

Send a PPP frame.

Parameters
[in]interfaceUnderlying network interface
[in]bufferMulti-part buffer containing the data
[in]offsetOffset to the first data byte
[in]protocolProtocol field value
Returns
Error code

Definition at line 1035 of file ppp.c.

◆ pppSetAuthInfo()

error_t pppSetAuthInfo ( NetInterface interface,
const char_t username,
const char_t password 
)

Set PPP authentication information.

Parameters
[in]interfaceUnderlying network interface
[in]usernameNULL-terminated string containing the user name to be used
[in]passwordNULL-terminated string containing the password to be used
Returns
Error code

Definition at line 236 of file ppp.c.

◆ pppSetTimeout()

error_t pppSetTimeout ( NetInterface interface,
systime_t  timeout 
)

Set timeout value for blocking operations.

Parameters
[in]interfaceUnderlying network interface
[in]timeoutMaximum time to wait
Returns
Error code

Definition at line 199 of file ppp.c.

◆ pppTick()

void pppTick ( NetInterface interface)

PPP timer handler.

This routine must be periodically called by the TCP/IP stack to manage retransmissions

Parameters
[in]interfaceUnderlying network interface

Definition at line 864 of file ppp.c.

Variable Documentation

◆ pppTickCounter

systime_t pppTickCounter

Definition at line 53 of file ppp.c.