mikroSDK Reference Manual
ipcp.h
Go to the documentation of this file.
1
31#ifndef _IPCP_H
32#define _IPCP_H
33
34//Dependencies
35#include "core/net.h"
36#include "ppp/ppp.h"
37
38//Subnet mask
39#define IPCP_DEFAULT_SUBNET_MASK IPV4_ADDR(255, 255, 255, 255)
40
41//C++ guard
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46
61
62
63//CodeWarrior or Win32 compiler?
64#if defined(__CWCC__) || defined(_WIN32)
65 #pragma pack(push, 1)
66#endif
67
68
74{
75 uint8_t type; //0
76 uint8_t length; //1
77 Ipv4Addr srcIpAddr; //2-5
78 Ipv4Addr destIpAddr; //6-9
79} IpcpIpAddressesOption;
80
81
86typedef __packed_struct
87{
88 uint8_t type; //0
89 uint8_t length; //1
90 uint16_t protocol; //2-3
91 uint8_t data[]; //4
92} IpcpIpCompProtocolOption;
93
94
99typedef __packed_struct
100{
101 uint8_t type; //0
102 uint8_t length; //1
103 Ipv4Addr ipAddr; //2-5
104} IpcpIpAddressOption;
105
106
111typedef __packed_struct
112{
113 uint8_t type; //0
114 uint8_t length; //1
115 Ipv4Addr ipAddr; //2-5
116} IpcpPrimaryDnsOption;
117
118
123typedef __packed_struct
124{
125 uint8_t type; //0
126 uint8_t length; //1
127 Ipv4Addr ipAddr; //2-5
128} IpcpPrimaryNbnsOption;
129
130
135typedef __packed_struct
136{
137 uint8_t type; //0
138 uint8_t length; //1
139 Ipv4Addr ipAddr; //2-5
140} IpcpSecondaryDnsOption;
141
142
147typedef __packed_struct
148{
149 uint8_t type; //0
150 uint8_t length; //1
151 Ipv4Addr ipAddr; //2-5
152} IpcpSecondaryNbnsOption;
153
154
155//CodeWarrior or Win32 compiler?
156#if defined(__CWCC__) || defined(_WIN32)
157 #pragma pack(pop)
158#endif
159
160//IPCP FSM events
161error_t ipcpOpen(PppContext *context);
162error_t ipcpClose(PppContext *context);
163
164void ipcpTick(PppContext *context);
165
166void ipcpProcessPacket(PppContext *context, const PppPacket *packet, size_t length);
167
168error_t ipcpProcessConfigureReq(PppContext *context,
169 const PppConfigurePacket *configureReqPacket);
170
171error_t ipcpProcessConfigureAck(PppContext *context,
172 const PppConfigurePacket *configureAckPacket);
173
174error_t ipcpProcessConfigureNak(PppContext *context,
175 const PppConfigurePacket *configureNakPacket);
176
177error_t ipcpProcessConfigureReject(PppContext *context,
178 const PppConfigurePacket *configureRejPacket);
179
180error_t ipcpProcessTerminateReq(PppContext *context,
181 const PppTerminatePacket *terminateReqPacket);
182
183error_t ipcpProcessTerminateAck(PppContext *context,
184 const PppTerminatePacket *terminateAckPacket);
185
186error_t ipcpProcessCodeRej(PppContext *context,
187 const PppCodeRejPacket *codeRejPacket);
188
189error_t ipcpProcessUnknownCode(PppContext *context,
190 const PppPacket *packet);
191
192//IPCP FSM callback functions
193void ipcpThisLayerUp(PppContext *context);
194void ipcpThisLayerDown(PppContext *context);
195void ipcpThisLayerStarted(PppContext *context);
196void ipcpThisLayerFinished(PppContext *context);
197
198void ipcpInitRestartCount(PppContext *context, uint_t value);
199void ipcpZeroRestartCount(PppContext *context);
200
201error_t ipcpSendConfigureReq(PppContext *context);
202
203error_t ipcpSendConfigureAck(PppContext *context,
204 const PppConfigurePacket *configureReqPacket);
205
206error_t ipcpSendConfigureNak(PppContext *context,
207 const PppConfigurePacket *configureReqPacket);
208
209error_t ipcpSendConfigureRej(PppContext *context,
210 const PppConfigurePacket *configureReqPacket);
211
212error_t ipcpSendTerminateReq(PppContext *context);
213
214error_t ipcpSendTerminateAck(PppContext *context,
215 const PppTerminatePacket *terminateReqPacket);
216
217error_t ipcpSendCodeRej(PppContext *context, const PppPacket *packet);
218
219//IPCP options checking
220error_t ipcpParseOption(PppContext *context, PppOption *option,
221 size_t inPacketLen, PppConfigurePacket *outPacket);
222
223error_t ipcpParseIpAddressOption(PppContext *context,
224 IpcpIpAddressOption *option, PppConfigurePacket *outPacket);
225
226//C++ guard
227#ifdef __cplusplus
228}
229#endif
230
231#endif
error_t
Error codes.
Definition error.h:43
IpcpOptionType
IPCP option types.
Definition ipcp.h:52
@ IPCP_OPTION_IP_ADDRESS
IP-Address.
Definition ipcp.h:55
@ IPCP_OPTION_PRIMARY_NBNS
Primary-NBNS-Server-Address.
Definition ipcp.h:57
@ IPCP_OPTION_IP_ADDRESSES
IP-Addresses.
Definition ipcp.h:53
@ IPCP_OPTION_IP_COMP_PROTOCOL
IP-Compression-Protocol.
Definition ipcp.h:54
@ IPCP_OPTION_SECONDARY_NBNS
Secondary-NBNS-Server-Address.
Definition ipcp.h:59
@ IPCP_OPTION_SECONDARY_DNS
Secondary-DNS-Server-Address.
Definition ipcp.h:58
@ IPCP_OPTION_PRIMARY_DNS
Primary-DNS-Server-Address.
Definition ipcp.h:56
typedef __packed_struct
IP-Addresses option.
Definition ipcp.h:74
uint32_t Ipv4Addr
IPv4 network address.
Definition ipv4.h:267
TCP/IP stack core.
PPP (Point-to-Point Protocol)