ipv6cp.h
Go to the documentation of this file.
1 /**
2  * @file ipv6cp.h
3  * @brief IPV6CP (PPP IPv6 Control Protocol)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _IPV6CP_H
32 #define _IPV6CP_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "ppp/ppp.h"
37 
38 //C++ guard
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 
44 /**
45  * @brief IPV6CP option types
46  **/
47 
48 typedef enum
49 {
50  IPV6CP_OPTION_INTERFACE_ID = 1, ///<Interface-Identifier
51  IPV6CP_OPTION_IPV6_COMP_PROTOCOL = 2 ///<IPv6-Compression-Protocol
53 
54 
55 //CC-RX, CodeWarrior or Win32 compiler?
56 #if defined(__CCRX__)
57  #pragma pack
58 #elif defined(__CWCC__) || defined(_WIN32)
59  #pragma pack(push, 1)
60 #endif
61 
62 
63 /**
64  * @brief Interface-Identifier option
65  **/
66 
68 {
69  uint8_t type; //0
70  uint8_t length; //1
73 
74 
75 /**
76  * @brief IPv6-Compression-Protocol option
77  **/
78 
79 typedef __packed_struct
80 {
81  uint8_t type; //0
82  uint8_t length; //1
83  uint16_t protocol; //2-3
84  uint8_t data[]; //4
86 
87 
88 //CC-RX, CodeWarrior or Win32 compiler?
89 #if defined(__CCRX__)
90  #pragma unpack
91 #elif defined(__CWCC__) || defined(_WIN32)
92  #pragma pack(pop)
93 #endif
94 
95 //IPV6CP FSM events
96 error_t ipv6cpOpen(PppContext *context);
98 
99 void ipv6cpTick(PppContext *context);
100 
101 void ipv6cpProcessPacket(PppContext *context, const PppPacket *packet, size_t length);
102 
104  const PppConfigurePacket *configureReqPacket);
105 
107  const PppConfigurePacket *configureAckPacket);
108 
110  const PppConfigurePacket *configureNakPacket);
111 
113  const PppConfigurePacket *configureRejPacket);
114 
116  const PppTerminatePacket *terminateReqPacket);
117 
119  const PppTerminatePacket *terminateAckPacket);
120 
122  const PppCodeRejPacket *codeRejPacket);
123 
125  const PppPacket *packet);
126 
127 //IPV6CP FSM callback functions
128 void ipv6cpThisLayerUp(PppContext *context);
129 void ipv6cpThisLayerDown(PppContext *context);
130 void ipv6cpThisLayerStarted(PppContext *context);
131 void ipv6cpThisLayerFinished(PppContext *context);
132 
134 void ipv6cpZeroRestartCount(PppContext *context);
135 
137 
139  const PppConfigurePacket *configureReqPacket);
140 
142  const PppConfigurePacket *configureReqPacket);
143 
145  const PppConfigurePacket *configureReqPacket);
146 
148 
150  const PppTerminatePacket *terminateReqPacket);
151 
152 error_t ipv6cpSendCodeRej(PppContext *context, const PppPacket *packet);
153 
154 //IPV6CP options checking
156  size_t inPacketLen, PppConfigurePacket *outPacket);
157 
159  Ipv6cpInterfaceIdOption *option, PppConfigurePacket *outPacket);
160 
161 //C++ guard
162 #ifdef __cplusplus
163 }
164 #endif
165 
166 #endif
error_t ipv6cpClose(PppContext *context)
IPV6CP Close event.
Definition: ipv6cp.c:98
error_t ipv6cpOpen(PppContext *context)
IPV6CP Open event.
Definition: ipv6cp.c:77
#define PppPacket
Definition: ppp.h:37
Eui64
Definition: ethernet.h:210
void ipv6cpTick(PppContext *context)
IPV6CP timer handler.
Definition: ipv6cp.c:122
typedef __packed_struct
Interface-Identifier option.
Definition: ipv6cp.h:68
error_t ipv6cpParseInterfaceIdOption(PppContext *context, Ipv6cpInterfaceIdOption *option, PppConfigurePacket *outPacket)
Parse Interface-Identifier option.
Definition: ipv6cp.c:970
error_t ipv6cpSendTerminateAck(PppContext *context, const PppTerminatePacket *terminateReqPacket)
Send-Terminate-Ack callback function.
Definition: ipv6cp.c:862
error_t ipv6cpSendConfigureReq(PppContext *context)
Send-Configure-Request callback function.
Definition: ipv6cp.c:703
error_t ipv6cpProcessTerminateAck(PppContext *context, const PppTerminatePacket *terminateAckPacket)
Process Terminate-Ack packet.
Definition: ipv6cp.c:489
PppConfigurePacket
Definition: ppp.h:274
uint8_t type
Definition: coap_common.h:176
void ipv6cpThisLayerFinished(PppContext *context)
This-Layer-Finished callback function.
Definition: ipv6cp.c:654
void ipv6cpThisLayerDown(PppContext *context)
This-Layer-Down callback function.
Definition: ipv6cp.c:615
Ipv6cpIpCompProtocolOption
Definition: ipv6cp.h:85
#define PppContext
Definition: ppp.h:38
PppCodeRejPacket
Definition: ppp.h:300
error_t
Error codes.
Definition: error.h:43
error_t ipv6cpProcessCodeRej(PppContext *context, const PppCodeRejPacket *codeRejPacket)
Process Code-Reject packet.
Definition: ipv6cp.c:512
void ipv6cpThisLayerUp(PppContext *context)
This-Layer-Up callback function.
Definition: ipv6cp.c:579
uint16_t protocol
Definition: ipv6cp.h:83
error_t ipv6cpParseOption(PppContext *context, PppOption *option, size_t inPacketLen, PppConfigurePacket *outPacket)
Parse IPV6CP configuration option.
Definition: ipv6cp.c:918
void ipv6cpThisLayerStarted(PppContext *context)
This-Layer-Started callback function.
Definition: ipv6cp.c:642
error_t ipv6cpProcessConfigureReject(PppContext *context, const PppConfigurePacket *configureRejPacket)
Process Configure-Reject packet.
Definition: ipv6cp.c:411
Eui64 interfaceId
Definition: ipv6cp.h:71
@ IPV6CP_OPTION_INTERFACE_ID
Interface-Identifier.
Definition: ipv6cp.h:50
error_t ipv6cpProcessConfigureNak(PppContext *context, const PppConfigurePacket *configureNakPacket)
Process Configure-Nak packet.
Definition: ipv6cp.c:348
void ipv6cpInitRestartCount(PppContext *context, uint_t value)
Initialize-Restart-Count callback function.
Definition: ipv6cp.c:667
uint8_t data[]
Definition: ipv6cp.h:84
void ipv6cpProcessPacket(PppContext *context, const PppPacket *packet, size_t length)
Process an incoming IPV6CP packet.
Definition: ipv6cp.c:152
error_t ipv6cpProcessConfigureAck(PppContext *context, const PppConfigurePacket *configureAckPacket)
Process Configure-Ack packet.
Definition: ipv6cp.c:322
error_t ipv6cpSendConfigureNak(PppContext *context, const PppConfigurePacket *configureReqPacket)
Send-Configure-Nak callback function.
Definition: ipv6cp.c:793
@ IPV6CP_OPTION_IPV6_COMP_PROTOCOL
IPv6-Compression-Protocol.
Definition: ipv6cp.h:51
error_t ipv6cpSendCodeRej(PppContext *context, const PppPacket *packet)
Send-Code-Reject callback function.
Definition: ipv6cp.c:896
PppTerminatePacket
Definition: ppp.h:287
uint8_t value[]
Definition: tcp.h:369
uint8_t length
Definition: ipv6cp.h:70
void ipv6cpZeroRestartCount(PppContext *context)
Zero-Restart-Count callback function.
Definition: ipv6cp.c:682
error_t ipv6cpProcessConfigureReq(PppContext *context, const PppConfigurePacket *configureReqPacket)
Process Configure-Request packet.
Definition: ipv6cp.c:226
PPP (Point-to-Point Protocol)
error_t ipv6cpSendConfigureAck(PppContext *context, const PppConfigurePacket *configureReqPacket)
Send-Configure-Ack callback function.
Definition: ipv6cp.c:774
error_t ipv6cpSendConfigureRej(PppContext *context, const PppConfigurePacket *configureReqPacket)
Send-Configure-Reject callback function.
Definition: ipv6cp.c:812
error_t ipv6cpSendTerminateReq(PppContext *context)
Send-Terminate-Request callback function.
Definition: ipv6cp.c:830
PppOption
Definition: ppp.h:354
unsigned int uint_t
Definition: compiler_port.h:50
TCP/IP stack core.
error_t ipv6cpProcessUnknownCode(PppContext *context, const PppPacket *packet)
Process packet with unknown code.
Definition: ipv6cp.c:559
Ipv6cpOptionType
IPV6CP option types.
Definition: ipv6cp.h:49
error_t ipv6cpProcessTerminateReq(PppContext *context, const PppTerminatePacket *terminateReqPacket)
Process Terminate-Request packet.
Definition: ipv6cp.c:467
Ipv6cpInterfaceIdOption
Definition: ipv6cp.h:72