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  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneTCP Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _IPV6CP_H
30 #define _IPV6CP_H
31 
32 //Dependencies
33 #include "core/net.h"
34 #include "ppp/ppp.h"
35 
36 //C++ guard
37 #ifdef __cplusplus
38  extern "C" {
39 #endif
40 
41 
42 /**
43  * @brief IPV6CP option types
44  **/
45 
46 typedef enum
47 {
48  IPV6CP_OPTION_INTERFACE_ID = 1, ///<Interface-Identifier
49  IPV6CP_OPTION_IPV6_COMP_PROTOCOL = 2 ///<IPv6-Compression-Protocol
51 
52 
53 //CodeWarrior or Win32 compiler?
54 #if defined(__CWCC__) || defined(_WIN32)
55  #pragma pack(push, 1)
56 #endif
57 
58 
59 /**
60  * @brief Interface-Identifier option
61  **/
62 
63 typedef __start_packed struct
64 {
65  uint8_t type; //0
66  uint8_t length; //1
69 
70 
71 /**
72  * @brief IPv6-Compression-Protocol option
73  **/
74 
75 typedef __start_packed struct
76 {
77  uint8_t type; //0
78  uint8_t length; //1
79  uint16_t protocol; //2-3
80  uint8_t data[]; //4
82 
83 
84 //CodeWarrior or Win32 compiler?
85 #if defined(__CWCC__) || defined(_WIN32)
86  #pragma pack(pop)
87 #endif
88 
89 
90 //IPV6CP FSM events
91 error_t ipv6cpOpen(PppContext *context);
93 
94 void ipv6cpTick(PppContext *context);
95 
96 void ipv6cpProcessPacket(PppContext *context, const PppPacket *packet, size_t length);
97 
99  const PppConfigurePacket *configureReqPacket);
100 
102  const PppConfigurePacket *configureAckPacket);
103 
105  const PppConfigurePacket *configureNakPacket);
106 
108  const PppConfigurePacket *configureRejPacket);
109 
111  const PppTerminatePacket *terminateReqPacket);
112 
114  const PppTerminatePacket *terminateAckPacket);
115 
117  const PppCodeRejPacket *codeRejPacket);
118 
120  const PppPacket *packet);
121 
122 //IPV6CP FSM callback functions
123 void ipv6cpThisLayerUp(PppContext *context);
124 void ipv6cpThisLayerDown(PppContext *context);
125 void ipv6cpThisLayerStarted(PppContext *context);
126 void ipv6cpThisLayerFinished(PppContext *context);
127 
129 void ipv6cpZeroRestartCount(PppContext *context);
130 
132 
134  const PppConfigurePacket *configureReqPacket);
135 
137  const PppConfigurePacket *configureReqPacket);
138 
140  const PppConfigurePacket *configureReqPacket);
141 
143 
145  const PppTerminatePacket *terminateReqPacket);
146 
147 error_t ipv6cpSendCodeRej(PppContext *context, const PppPacket *packet);
148 
149 //IPV6CP options checking
151  size_t inPacketLen, PppConfigurePacket *outPacket);
152 
154  Ipv6cpInterfaceIdOption *option, PppConfigurePacket *outPacket);
155 
156 //C++ guard
157 #ifdef __cplusplus
158  }
159 #endif
160 
161 #endif
__start_packed struct @289 PppTerminatePacket
Terminate-Request and Terminate-Ack packet.
PPP (Point-to-Point Protocol)
void ipv6cpThisLayerStarted(PppContext *context)
This-Layer-Started callback function.
Definition: ipv6cp.c:652
void ipv6cpThisLayerFinished(PppContext *context)
This-Layer-Finished callback function.
Definition: ipv6cp.c:664
error_t ipv6cpOpen(PppContext *context)
IPV6CP Open event.
Definition: ipv6cp.c:75
error_t ipv6cpProcessUnknownCode(PppContext *context, const PppPacket *packet)
Process packet with unknown code.
Definition: ipv6cp.c:557
TCP/IP stack core.
error_t ipv6cpSendTerminateAck(PppContext *context, const PppTerminatePacket *terminateReqPacket)
Send-Terminate-Ack callback function.
Definition: ipv6cp.c:871
IPv6-Compression-Protocol.
Definition: ipv6cp.h:49
void ipv6cpProcessPacket(PppContext *context, const PppPacket *packet, size_t length)
Process an incoming IPV6CP packet.
Definition: ipv6cp.c:150
error_t ipv6cpSendTerminateReq(PppContext *context)
Send-Terminate-Request callback function.
Definition: ipv6cp.c:839
__start_packed struct @290 PppCodeRejPacket
Code-Reject packet.
void ipv6cpThisLayerUp(PppContext *context)
This-Layer-Up callback function.
Definition: ipv6cp.c:577
Ipv6cpOptionType
IPV6CP option types.
Definition: ipv6cp.h:46
void ipv6cpZeroRestartCount(PppContext *context)
Zero-Restart-Count callback function.
Definition: ipv6cp.c:692
Interface-Identifier.
Definition: ipv6cp.h:48
error_t ipv6cpParseInterfaceIdOption(PppContext *context, Ipv6cpInterfaceIdOption *option, PppConfigurePacket *outPacket)
Parse Interface-Identifier option.
Definition: ipv6cp.c:979
uint8_t type
Definition: ipv6cp.h:65
#define PppPacket
Definition: ppp.h:35
error_t ipv6cpSendConfigureReq(PppContext *context)
Send-Configure-Request callback function.
Definition: ipv6cp.c:713
__start_packed struct @276 Ipv6cpInterfaceIdOption
Interface-Identifier option.
void ipv6cpInitRestartCount(PppContext *context, uint_t value)
Initialize-Restart-Count callback function.
Definition: ipv6cp.c:677
uint8_t data[]
Definition: ipv6cp.h:80
__start_packed struct @294 PppOption
LCP/NCP option.
__start_packed struct @113 Eui64
EUI-64 identifier.
error_t ipv6cpProcessConfigureNak(PppContext *context, const PppConfigurePacket *configureNakPacket)
Process Configure-Nak packet.
Definition: ipv6cp.c:346
uint16_t protocol
Definition: ipv6cp.h:79
error_t ipv6cpProcessTerminateAck(PppContext *context, const PppTerminatePacket *terminateAckPacket)
Process Terminate-Ack packet.
Definition: ipv6cp.c:487
error_t ipv6cpParseOption(PppContext *context, PppOption *option, size_t inPacketLen, PppConfigurePacket *outPacket)
Parse IPV6CP configuration option.
Definition: ipv6cp.c:927
void ipv6cpThisLayerDown(PppContext *context)
This-Layer-Down callback function.
Definition: ipv6cp.c:625
Eui64 interfaceId
Definition: ipv6cp.h:67
error_t ipv6cpSendCodeRej(PppContext *context, const PppPacket *packet)
Send-Code-Reject callback function.
Definition: ipv6cp.c:905
__start_packed struct @277 Ipv6cpIpCompProtocolOption
IPv6-Compression-Protocol option.
#define PppContext
Definition: ppp.h:36
__start_packed struct _Ipv4Header __end_packed
error_t
Error codes.
Definition: error.h:40
unsigned int uint_t
Definition: compiler_port.h:43
error_t ipv6cpSendConfigureNak(PppContext *context, const PppConfigurePacket *configureReqPacket)
Send-Configure-Nak callback function.
Definition: ipv6cp.c:802
error_t ipv6cpProcessConfigureAck(PppContext *context, const PppConfigurePacket *configureAckPacket)
Process Configure-Ack packet.
Definition: ipv6cp.c:320
uint8_t value[]
Definition: dtls_misc.h:141
error_t ipv6cpProcessConfigureReject(PppContext *context, const PppConfigurePacket *configureRejPacket)
Process Configure-Reject packet.
Definition: ipv6cp.c:409
uint8_t length
Definition: ipv6cp.h:66
void ipv6cpTick(PppContext *context)
IPV6CP timer handler.
Definition: ipv6cp.c:120
error_t ipv6cpSendConfigureRej(PppContext *context, const PppConfigurePacket *configureReqPacket)
Send-Configure-Reject callback function.
Definition: ipv6cp.c:821
error_t ipv6cpProcessTerminateReq(PppContext *context, const PppTerminatePacket *terminateReqPacket)
Process Terminate-Request packet.
Definition: ipv6cp.c:465
__start_packed struct @288 PppConfigurePacket
Configure-Request, Configure-Ack, Configure-Nak and Configure-Reject packets.
error_t ipv6cpProcessConfigureReq(PppContext *context, const PppConfigurePacket *configureReqPacket)
Process Configure-Request packet.
Definition: ipv6cp.c:224
error_t ipv6cpProcessCodeRej(PppContext *context, const PppCodeRejPacket *codeRejPacket)
Process Code-Reject packet.
Definition: ipv6cp.c:510
error_t ipv6cpClose(PppContext *context)
IPV6CP Close event.
Definition: ipv6cp.c:96
error_t ipv6cpSendConfigureAck(PppContext *context, const PppConfigurePacket *configureReqPacket)
Send-Configure-Ack callback function.
Definition: ipv6cp.c:783