mikroSDK Reference Manual
lcp.h
Go to the documentation of this file.
1
31#ifndef _LCP_H
32#define _LCP_H
33
34//Dependencies
35#include "core/net.h"
36#include "ppp/ppp.h"
37
38//C++ guard
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43
58
59
60//CodeWarrior or Win32 compiler?
61#if defined(__CWCC__) || defined(_WIN32)
62 #pragma pack(push, 1)
63#endif
64
65
71{
72 uint8_t type; //0
73 uint8_t length; //1
74 uint16_t mru; //2-3
75} LcpMruOption;
76
77
82typedef __packed_struct
83{
84 uint8_t type; //0
85 uint8_t length; //1
86 uint32_t accm; //2-5
87} LcpAccmOption;
88
89
94typedef __packed_struct
95{
96 uint8_t type; //0
97 uint8_t length; //1
98 uint16_t protocol; //2-3
99 uint8_t data[]; //4
100} LcpAuthProtocolOption;
101
102
107typedef __packed_struct
108{
109 uint8_t type; //0
110 uint8_t length; //1
111 uint16_t protocol; //2-3
112 uint8_t data[]; //4
113} LcpQualityProtocolOption;
114
115
120typedef __packed_struct
121{
122 uint8_t type; //0
123 uint8_t length; //1
124 uint32_t magicNumber; //2-5
125} LcpMagicNumberOption;
126
127
132typedef __packed_struct
133{
134 uint8_t type; //0
135 uint8_t length; //1
136} LcpPfcOption;
137
138
143typedef __packed_struct
144{
145 uint8_t type; //0
146 uint8_t length; //1
147} LcpAcfcOption;
148
149
150//CodeWarrior or Win32 compiler?
151#if defined(__CWCC__) || defined(_WIN32)
152 #pragma pack(pop)
153#endif
154
155//LCP FSM events
156error_t lcpOpen(PppContext *context);
157error_t lcpClose(PppContext *context);
158
159void lcpTick(PppContext *context);
160
161void lcpProcessPacket(PppContext *context, const PppPacket *packet, size_t length);
162
163error_t lcpProcessConfigureReq(PppContext *context,
164 const PppConfigurePacket *configureReqPacket);
165
166error_t lcpProcessConfigureAck(PppContext *context,
167 const PppConfigurePacket *configureAckPacket);
168
169error_t lcpProcessConfigureNak(PppContext *context,
170 const PppConfigurePacket *configureNakPacket);
171
172error_t lcpProcessConfigureReject(PppContext *context,
173 const PppConfigurePacket *configureRejPacket);
174
175error_t lcpProcessTerminateReq(PppContext *context,
176 const PppTerminatePacket *terminateReqPacket);
177
178error_t lcpProcessTerminateAck(PppContext *context,
179 const PppTerminatePacket *terminateAckPacket);
180
181error_t lcpProcessCodeRej(PppContext *context,
182 const PppCodeRejPacket *codeRejPacket);
183
184error_t lcpProcessProtocolRej(PppContext *context,
185 const PppProtocolRejPacket *protocolRejPacket);
186
187error_t lcpProcessEchoReq(PppContext *context,
188 const PppEchoPacket *echoReqPacket);
189
190error_t lcpProcessEchoRep(PppContext *context,
191 const PppEchoPacket *echoRepPacket);
192
193error_t lcpProcessDiscardReq(PppContext *context,
194 const PppDiscardReqPacket *discardReqPacket);
195
196error_t lcpProcessUnknownCode(PppContext *context,
197 const PppPacket *packet);
198
199error_t lcpProcessUnknownProtocol(PppContext *context,
200 uint16_t protocol, const uint8_t *information, size_t length);
201
202//LCP FSM callback functions
203void lcpThisLayerUp(PppContext *context);
204void lcpThisLayerDown(PppContext *context);
205void lcpThisLayerStarted(PppContext *context);
206void lcpThisLayerFinished(PppContext *context);
207
208void lcpInitRestartCount(PppContext *context, uint_t value);
209void lcpZeroRestartCount(PppContext *context);
210
211error_t lcpSendConfigureReq(PppContext *context);
212
213error_t lcpSendConfigureAck(PppContext *context,
214 const PppConfigurePacket *configureReqPacket);
215
216error_t lcpSendConfigureNak(PppContext *context,
217 const PppConfigurePacket *configureReqPacket);
218
219error_t lcpSendConfigureRej(PppContext *context,
220 const PppConfigurePacket *configureReqPacket);
221
222error_t lcpSendTerminateReq(PppContext *context);
223
224error_t lcpSendTerminateAck(PppContext *context,
225 const PppTerminatePacket *terminateReqPacket);
226
227error_t lcpSendCodeRej(PppContext *context, const PppPacket *packet);
228error_t lcpSendEchoRep(PppContext *context, const PppEchoPacket *echoReqPacket);
229
230//LCP options checking
231error_t lcpParseOption(PppContext *context, PppOption *option,
232 size_t inPacketLen, PppConfigurePacket *outPacket);
233
234error_t lcpParseMruOption(PppContext *context,
235 LcpMruOption *option, PppConfigurePacket *outPacket);
236
237error_t lcpParseAccmOption(PppContext *context,
238 LcpAccmOption *option, PppConfigurePacket *outPacket);
239
240error_t lcpParseAuthProtocolOption(PppContext *context,
241 LcpAuthProtocolOption *option, PppConfigurePacket *outPacket);
242
243error_t lcpParseMagicNumberOption(PppContext *context,
244 LcpMagicNumberOption *option, PppConfigurePacket *outPacket);
245
246error_t lcpParsePfcOption(PppContext *context,
247 LcpPfcOption *option, PppConfigurePacket *outPacket);
248
249error_t lcpParseAcfcOption(PppContext *context,
250 LcpAcfcOption *option, PppConfigurePacket *outPacket);
251
252//C++ guard
253#ifdef __cplusplus
254}
255#endif
256
257#endif
error_t
Error codes.
Definition error.h:43
LcpOptionType
LCP option types.
Definition lcp.h:49
@ LCP_OPTION_PFC
Protocol-Field-Compression.
Definition lcp.h:55
@ LCP_OPTION_MAGIC_NUMBER
Magic-Number.
Definition lcp.h:54
@ LCP_OPTION_AUTH_PROTOCOL
Authentication-Protocol.
Definition lcp.h:52
@ LCP_OPTION_QUALITY_PROTOCOL
Quality-Protocol.
Definition lcp.h:53
@ LCP_OPTION_ACCM
Async-Control-Character-Map.
Definition lcp.h:51
@ LCP_OPTION_MRU
Maximum-Receive-Unit.
Definition lcp.h:50
@ LCP_OPTION_ACFC
Address-and-Control-Field-Compression.
Definition lcp.h:56
typedef __packed_struct
Maximum-Receive-Unit option.
Definition lcp.h:71
TCP/IP stack core.
PPP (Point-to-Point Protocol)