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-2020 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 1.9.8
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 
92 //IPV6CP FSM events
93 error_t ipv6cpOpen(PppContext *context);
95 
96 void ipv6cpTick(PppContext *context);
97 
98 void ipv6cpProcessPacket(PppContext *context, const PppPacket *packet, size_t length);
99 
101  const PppConfigurePacket *configureReqPacket);
102 
104  const PppConfigurePacket *configureAckPacket);
105 
107  const PppConfigurePacket *configureNakPacket);
108 
110  const PppConfigurePacket *configureRejPacket);
111 
113  const PppTerminatePacket *terminateReqPacket);
114 
116  const PppTerminatePacket *terminateAckPacket);
117 
119  const PppCodeRejPacket *codeRejPacket);
120 
122  const PppPacket *packet);
123 
124 //IPV6CP FSM callback functions
125 void ipv6cpThisLayerUp(PppContext *context);
126 void ipv6cpThisLayerDown(PppContext *context);
127 void ipv6cpThisLayerStarted(PppContext *context);
128 void ipv6cpThisLayerFinished(PppContext *context);
129 
131 void ipv6cpZeroRestartCount(PppContext *context);
132 
134 
136  const PppConfigurePacket *configureReqPacket);
137 
139  const PppConfigurePacket *configureReqPacket);
140 
142  const PppConfigurePacket *configureReqPacket);
143 
145 
147  const PppTerminatePacket *terminateReqPacket);
148 
149 error_t ipv6cpSendCodeRej(PppContext *context, const PppPacket *packet);
150 
151 //IPV6CP options checking
153  size_t inPacketLen, PppConfigurePacket *outPacket);
154 
156  Ipv6cpInterfaceIdOption *option, PppConfigurePacket *outPacket);
157 
158 //C++ guard
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif
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
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:981
error_t ipv6cpSendTerminateAck(PppContext *context, const PppTerminatePacket *terminateReqPacket)
Send-Terminate-Ack callback function.
Definition: ipv6cp.c:873
error_t ipv6cpSendConfigureReq(PppContext *context)
Send-Configure-Request callback function.
Definition: ipv6cp.c:715
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:666
__start_packed struct @6 Eui64
EUI-64 identifier.
void ipv6cpThisLayerDown(PppContext *context)
This-Layer-Down callback function.
Definition: ipv6cp.c:627
#define PppContext
Definition: ppp.h:38
__start_packed struct @172 Ipv6cpIpCompProtocolOption
IPv6-Compression-Protocol option.
error_t
Error codes.
Definition: error.h:42
uint8_t value[]
Definition: tcp.h:332
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
__start_packed struct @185 PppCodeRejPacket
Code-Reject packet.
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:929
__start_packed struct @171 Ipv6cpInterfaceIdOption
Interface-Identifier option.
void ipv6cpThisLayerStarted(PppContext *context)
This-Layer-Started callback function.
Definition: ipv6cp.c:654
__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
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:679
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:804
IPv6-Compression-Protocol.
Definition: ipv6cp.h:51
error_t ipv6cpSendCodeRej(PppContext *context, const PppPacket *packet)
Send-Code-Reject callback function.
Definition: ipv6cp.c:907
uint8_t length
Definition: ipv6cp.h:68
void ipv6cpZeroRestartCount(PppContext *context)
Zero-Restart-Count callback function.
Definition: ipv6cp.c:694
error_t ipv6cpProcessConfigureReq(PppContext *context, const PppConfigurePacket *configureReqPacket)
Process Configure-Request packet.
Definition: ipv6cp.c:226
PPP (Point-to-Point Protocol)
__start_packed struct @184 PppTerminatePacket
Terminate-Request and Terminate-Ack packet.
error_t ipv6cpSendConfigureAck(PppContext *context, const PppConfigurePacket *configureReqPacket)
Send-Configure-Ack callback function.
Definition: ipv6cp.c:785
error_t ipv6cpSendConfigureRej(PppContext *context, const PppConfigurePacket *configureReqPacket)
Send-Configure-Reject callback function.
Definition: ipv6cp.c:823
error_t ipv6cpSendTerminateReq(PppContext *context)
Send-Terminate-Request callback function.
Definition: ipv6cp.c:841
unsigned int uint_t
Definition: compiler_port.h:45
TCP/IP stack core.
__start_packed struct @189 PppOption
LCP/NCP option.
error_t ipv6cpProcessUnknownCode(PppContext *context, const PppPacket *packet)
Process packet with unknown code.
Definition: ipv6cp.c:559
__start_packed struct @183 PppConfigurePacket
Configure-Request, Configure-Ack, Configure-Nak and Configure-Reject packets.
Ipv6cpOptionType
IPV6CP option types.
Definition: ipv6cp.h:48
error_t ipv6cpProcessTerminateReq(PppContext *context, const PppTerminatePacket *terminateReqPacket)
Process Terminate-Request packet.
Definition: ipv6cp.c:467