1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #5171 from jia200x/PPP_hdr

[GNRC PPP] PPP header definition and helpers
This commit is contained in:
Martine Lenders 2016-11-02 17:00:31 +01:00 committed by GitHub
commit a6f3db49e5
2 changed files with 117 additions and 0 deletions

67
sys/include/net/ppp/hdr.h Normal file
View File

@ -0,0 +1,67 @@
/*
* Copyright (C) 2016 José Ignacio Alamos <jialamos@uc.cl>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup net_ppp Header
* @ingroup net_ppp_hdr
* @brief PPP header abstraction type and helper functions
* @{
*
* @file
* @brief General definitions for PPP header and their helper functions
*
* @author José Ignacio Alamos
*/
#ifndef PPP_HDR_H_
#define PPP_HDR_H_
#include <inttypes.h>
#include "byteorder.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Header of a PPP packet
* @details A PPP packet is transmited as a payload of an HDLC packet. PPP packets only carry information about control protocol
* of a PPP stack (Link Control Protocol, IP Control Protocol, etc). IP packets encapsulated in HDLC frame are not
* considered PPP packet.
*
* The format of PPP header plus payload is:
*
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Code | Identifier | Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Payload ...
* +-+-+-+-+
*
*
* @see <a href="https://tools.ietf.org/html/rfc1661#section-5">
* RFC 1661, section 5
* </a>
*/
/* PPP pkt header struct */
typedef struct __attribute__((packed)){
uint8_t code; /**< Code of PPP packet*/
uint8_t id; /**< Identifier PPP of packet*/
network_uint16_t length; /**< Length of PPP packet including payload*/
} ppp_hdr_t;
#ifdef __cplusplus
}
#endif
#endif /* PPP_HDR_H_ */
/** @} */

50
sys/include/net/ppptype.h Normal file
View File

@ -0,0 +1,50 @@
/*
* Copyright (C) 2016 José Ignacio Alamos
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License v2.1. See the file LICENSE in the top level directory for
* more details.
*/
/**
* @defgroup net_ppptypes PPP types
* @ingroup net
* @brief PPP types
* @note Last Updated: 2016-02-04
* @{
*
* @file
* @brief PPP type definitions
*
* @author José Ignacio Alamos <jialamos@uc.cl>
* @see <a href="http://www.iana.org/assignments/ppp-numbers/ppp-numbers.xhtml#ppp-numbers-2">
* IANA, PPP NUMBERS
* </a>
*/
#ifndef PPPTYPE_H_
#define PPPTYPE_H_
#ifdef __cplusplus
extern "C" {
#endif
#define PPPTYPE_IPV6 (0x0057) /**< IPv6 packet in PPP*/
#define PPPTYPE_IPV4 (0x0021) /**< IPv4 packet in PPP */
#define PPPTYPE_NCP_IPV6 (0x8057) /**< NCP packet for IPV6*/
#define PPPTYPE_NCP_IPV4 (0x8021) /**< NCP packet for IPv4*/
#define PPPTYPE_LCP (0xC021) /**< LCP packet */
#define PPPTYPE_PAP (0xC023) /**< PAP packet */
#define PPPTYPE_UNKNOWN (0x8001) /**<Unknown packet (Unused protocol number according to IANA) */
#ifdef __cplusplus
}
#endif
#endif /* PPPTYPE_H_ */
/**
* @}
*/