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-2023 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.2.2
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 //CodeWarrior or Win32 compiler?
56 #if defined(__CWCC__) || defined(_WIN32)
57  #pragma pack(push, 1)
58 #endif
59 
60 
61 /**
62  * @brief Interface-Identifier option
63  **/
64 
65 typedef __start_packed struct
66 {
67  uint8_t type; //0
68  uint8_t length; //1
71 
72 
73 /**
74  * @brief IPv6-Compression-Protocol option
75  **/
76 
77 typedef __start_packed struct
78 {
79  uint8_t type; //0
80  uint8_t length; //1
81  uint16_t protocol; //2-3
82  uint8_t data[]; //4
84 
85 
86 //CodeWarrior or Win32 compiler?
87 #if defined(__CWCC__) || defined(_WIN32)
88  #pragma pack(pop)
89 #endif
90 
91 //IPV6CP FSM events
92 error_t ipv6cpOpen(PppContext *context);
94 
95 void ipv6cpTick(PppContext *context);
96 
97 void ipv6cpProcessPacket(PppContext *context, const PppPacket *packet, size_t length);
98 
100  const PppConfigurePacket *configureReqPacket);
101 
103  const PppConfigurePacket *configureAckPacket);
104 
106  const PppConfigurePacket *configureNakPacket);
107 
109  const PppConfigurePacket *configureRejPacket);
110 
112  const PppTerminatePacket *terminateReqPacket);
113 
115  const PppTerminatePacket *terminateAckPacket);
116 
118  const PppCodeRejPacket *codeRejPacket);
119 
121  const PppPacket *packet);
122 
123 //IPV6CP FSM callback functions
124 void ipv6cpThisLayerUp(PppContext *context);
125 void ipv6cpThisLayerDown(PppContext *context);
126 void ipv6cpThisLayerStarted(PppContext *context);
127 void ipv6cpThisLayerFinished(PppContext *context);
128 
130 void ipv6cpZeroRestartCount(PppContext *context);
131 
133 
135  const PppConfigurePacket *configureReqPacket);
136 
138  const PppConfigurePacket *configureReqPacket);
139 
141  const PppConfigurePacket *configureReqPacket);
142 
144 
146  const PppTerminatePacket *terminateReqPacket);
147 
148 error_t ipv6cpSendCodeRej(PppContext *context, const PppPacket *packet);
149 
150 //IPV6CP options checking
152  size_t inPacketLen, PppConfigurePacket *outPacket);
153 
155  Ipv6cpInterfaceIdOption *option, PppConfigurePacket *outPacket);
156 
157 //C++ guard
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 #endif
__start_packed struct @1 Eui64
EUI-64 identifier.
__start_packed struct @1 Ipv6cpIpCompProtocolOption
IPv6-Compression-Protocol option.
error_t ipv6cpClose(PppContext *context)
IPV6CP Close event.
Definition: ipv6cp.c:98
uint8_t type
Definition: ipv6cp.h:67
error_t ipv6cpOpen(PppContext *context)
IPV6CP Open event.
Definition: ipv6cp.c:77
#define PppPacket
Definition: ppp.h:37
__start_packed struct @2 PppCodeRejPacket
Code-Reject packet.
void ipv6cpTick(PppContext *context)
IPV6CP timer handler.
Definition: ipv6cp.c:122
error_t ipv6cpParseInterfaceIdOption(PppContext *context, Ipv6cpInterfaceIdOption *option, PppConfigurePacket *outPacket)
Parse Interface-Identifier option.
Definition: ipv6cp.c:969
error_t ipv6cpSendTerminateAck(PppContext *context, const PppTerminatePacket *terminateReqPacket)
Send-Terminate-Ack callback function.
Definition: ipv6cp.c:861
__start_packed struct @6 PppOption
LCP/NCP option.
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
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
#define PppContext
Definition: ppp.h:38
error_t
Error codes.
Definition: error.h:43
uint8_t value[]
Definition: tcp.h:367
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:81
error_t ipv6cpParseOption(PppContext *context, PppOption *option, size_t inPacketLen, PppConfigurePacket *outPacket)
Parse IPV6CP configuration option.
Definition: ipv6cp.c:917
void ipv6cpThisLayerStarted(PppContext *context)
This-Layer-Started callback function.
Definition: ipv6cp.c:642
__start_packed struct _Ipv4Header __end_packed
error_t ipv6cpProcessConfigureReject(PppContext *context, const PppConfigurePacket *configureRejPacket)
Process Configure-Reject packet.
Definition: ipv6cp.c:411
Eui64 interfaceId
Definition: ipv6cp.h:69
__start_packed struct @1 PppTerminatePacket
Terminate-Request and Terminate-Ack packet.
@ 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:82
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:792
@ 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:895
uint8_t length
Definition: ipv6cp.h:68
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:773
error_t ipv6cpSendConfigureRej(PppContext *context, const PppConfigurePacket *configureReqPacket)
Send-Configure-Reject callback function.
Definition: ipv6cp.c:811
error_t ipv6cpSendTerminateReq(PppContext *context)
Send-Terminate-Request callback function.
Definition: ipv6cp.c:829
unsigned int uint_t
Definition: compiler_port.h:50
TCP/IP stack core.
__start_packed struct @0 PppConfigurePacket
Configure-Request, Configure-Ack, Configure-Nak and Configure-Reject packets.
error_t ipv6cpProcessUnknownCode(PppContext *context, const PppPacket *packet)
Process packet with unknown code.
Definition: ipv6cp.c:559
__start_packed struct @0 Ipv6cpInterfaceIdOption
Interface-Identifier option.
Ipv6cpOptionType
IPV6CP option types.
Definition: ipv6cp.h:49
error_t ipv6cpProcessTerminateReq(PppContext *context, const PppTerminatePacket *terminateReqPacket)
Process Terminate-Request packet.
Definition: ipv6cp.c:467