annotate network/PPP.h @ 107:56d09a0969b5 avr-http

Import uIP and the PPP implementation from https://code.google.com/p/avrusbmodem/
author Matt Johnston <matt@ucc.asn.au>
date Fri, 07 Sep 2012 23:53:53 +0800
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
107
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 /*
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 LUFA Powered Wireless 3G Modem Host
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 Copyright (C) Mike Alexander, 2010.
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 Copyright (C) Dean Camera, 2010.
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 */
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 /*
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 Copyright 2010 Mike Alexander (mike [at] mikealex [dot] com)
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 Permission to use, copy, modify, distribute, and sell this
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 software and its documentation for any purpose is hereby granted
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 without fee, provided that the above copyright notice appear in
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 all copies and that both that the copyright notice and this
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 permission notice and warranty disclaimer appear in supporting
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17 documentation, and that the name of the author not be used in
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 advertising or publicity pertaining to distribution of the
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 software without specific, written prior permission.
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21 The author disclaim all warranties with regard to this
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22 software, including all implied warranties of merchantability
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 and fitness. In no event shall the author be liable for any
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24 special, indirect or consequential damages or any damages
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
25 whatsoever resulting from loss of use, data or profits, whether
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
26 in an action of contract, negligence or other tortious action,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
27 arising out of or in connection with the use or performance of
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
28 this software.
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
29 */
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
30
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
31 #ifndef _PPP_H_
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
32 #define _PPP_H_
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
33
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
34 /* Includes: */
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
35 #include <util/crc16.h>
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
36 #include <stdbool.h>
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
37 #include <stdint.h>
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
38
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
39 #include "LinkManagement.h"
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
40 #include "Lib/RingBuff.h"
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
41 #include "Lib/Debug.h"
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
42
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
43 /* Enums: */
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
44
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
45 typedef enum
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
46 {
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
47 PPP_LAYER_Physical,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
48 PPP_LAYER_Authentication,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
49 PPP_LAYER_Network,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
50 } PPP_Layers_t;
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
51
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
52 typedef enum
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
53 {
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
54 PPP_PHASE_Dead,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
55 PPP_PHASE_Establish,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
56 PPP_PHASE_Authenticate,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
57 PPP_PHASE_Network,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
58 PPP_PHASE_Terminate
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
59 } PPP_Phases_t;
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
60
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
61 typedef enum
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
62 {
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
63 PPP_STATE_Initial,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
64 PPP_STATE_Starting,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
65 PPP_STATE_Closed,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
66 PPP_STATE_Stopped,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
67 PPP_STATE_Closing,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
68 PPP_STATE_Stopping,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
69 PPP_STATE_Req_Sent,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
70 PPP_STATE_Ack_Rcvd,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
71 PPP_STATE_Ack_Sent,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
72 PPP_STATE_Opened
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
73 } PPP_States_t;
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
74
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
75 typedef enum
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
76 {
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
77 PPP_EVENT_Up,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
78 PPP_EVENT_Down,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
79 PPP_EVENT_Open,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
80 PPP_EVENT_Close,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
81 PPP_EVENT_TOPlus,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
82 PPP_EVENT_TOMinus,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
83 PPP_EVENT_RCRPlus,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
84 PPP_EVENT_RCRMinus,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
85 PPP_EVENT_RCA,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
86 PPP_EVENT_RCN,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
87 PPP_EVENT_RTR,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
88 PPP_EVENT_RTA,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
89 PPP_EVENT_RUC,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
90 PPP_EVENT_RXJPlus,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
91 PPP_EVENT_RXJMinus,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
92 PPP_EVENT_RXR
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
93 } PPP_Events_t;
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
94
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
95 /* Type Defines: */
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
96 typedef struct
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
97 {
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
98 uint8_t Type;
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
99 uint8_t Length;
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
100 uint8_t Data[];
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
101 } PPP_Option_t;
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
102
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
103 typedef struct
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
104 {
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
105 uint8_t Code;
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
106 uint8_t PacketID;
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
107 uint16_t Length;
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
108 PPP_Option_t Options[];
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
109 } PPP_Packet_t;
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
110
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
111 /* Macros: */
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
112 #define CALC_CRC16(crcvalue, c) _crc_ccitt_update(crcvalue, c);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
113
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
114 // Defines for LCP Negotiation Codes
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
115 #define REQ 1 // Request options list for PPP negotiations
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
116 #define ACK 2 // Acknowledge options list for PPP negotiations
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
117 #define NAK 3 // Not acknowledged options list for PPP negotiations
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
118 #define REJ 4 // Reject options list for PPP negotiations
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
119 #define TERMREQ 5 // Termination request for LCP to close connection
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
120 #define TERMREPLY 6 // Termination reply
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
121 #define CODEREJ 7 // Code reject
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
122 #define PROTREJ 8 // Protocol reject
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
123 #define ECHOREQ 9 // Echo Request
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
124 #define ECHOREPLY 10 // Echo Reply
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
125 #define DISC 11 // Discard request
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
126
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
127 // Packet Types (Protocols)
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
128 #define IP 0x0021 // Internet Protocol packet
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
129 #define IPCP 0x8021 // Internet Protocol Configure Protocol packet
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
130 #define LCP 0xC021 // Link Configure Protocol packet
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
131 #define PAP 0xC023 // Password Authentication Protocol packet
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
132 #define CHAP 0xC223 // Challenge Handshake Authentication Protocol packet
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
133 #define NONE 0x0000
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
134
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
135 #define LCP_OPTION_Maximum_Receive_Unit 0x1 // LCP Option 1
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
136 #define LCP_OPTION_Async_Control_Character_Map 0x2 // LCP Option 2
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
137 #define LCP_OPTION_Authentication_Protocol 0x3 // LCP Option 3
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
138 #define LCP_OPTION_Quality_Protocol 0x4 // LCP Option 4
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
139 #define LCP_OPTION_Magic_Number 0x5 // LCP Option 5
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
140 #define LCP_OPTION_Reserved 0x6 // LCP Option 6
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
141 #define LCP_OPTION_Protocol_Field_Compression 0x7 // LCP Option 7
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
142 #define LCP_OPTION_Address_and_Control_Field_Compression 0x8 // LCP Option 8
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
143 #define LCP_OPTION_Callback 0xd // LCP Option D
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
144
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
145 #define IPCP_OPTION_IP_Compression_Protocol 0x2 // IPCP Option 2
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
146 #define IPCP_OPTION_IP_address 0x3 // IPCP Option 3
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
147 #define IPCP_OPTION_Primary_DNS 0x81 // IPCP Option 81
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
148 #define IPCP_OPTION_Secondary_DNS 0x83 // IPCP Option 83
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
149
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
150 #define MAX_RESTARTS 5
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
151 #define OUTGOING_PACKET_BUFFER_SIZE 48
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
152
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
153 /* External Variables: */
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
154 extern uint8_t ConnectedState;
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
155
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
156 /* Function Prototypes: */
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
157 void PPP_ManageLink(void);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
158 void PPP_InitPPP(void);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
159 void PPP_LinkTimer(void);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
160 void PPP_LinkUp(void);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
161 void PPP_LinkOpen(void);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
162 void PPP_StartLink(void);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
163
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
164 #if defined(INCLUDE_FROM_PPP_C)
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
165 static PPP_Option_t* PPP_GetNextOption(const PPP_Packet_t* const ThisPacket,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
166 const PPP_Option_t* const CurrentOption);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
167 static void PPP_RemoveOption(PPP_Packet_t* const ThisPacket,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
168 const uint8_t Type);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
169 static void PPP_AddOption(const PPP_Option_t*);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
170 static bool PPP_CheckForOption(const PPP_Option_t*);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
171 static void PPP_ChangeOption(PPP_Packet_t* const ThisPacket,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
172 const PPP_Option_t* const Option);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
173 static void PPP_ProcessNAK(void);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
174 static void PPP_ProcessREJ(void);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
175 static bool PPP_TestForNAK(const PPP_Option_t* const Option);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
176 static bool PPP_TestForREJ(const uint8_t Options[],
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
177 const uint8_t NumOptions);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
178 static void PPP_ManageState(const PPP_Events_t Event,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
179 PPP_States_t* const State,
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
180 PPP_Layers_t const Layer);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
181 static void Send_Configure_Request(void);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
182 static void Send_Configure_Ack(void);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
183 static void Send_Configure_Nak_Rej(void);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
184 static void Send_Terminate_Request(void);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
185 static void Send_Terminate_Ack(void);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
186 static void Send_Code_Reject(void);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
187 static void Send_Echo_Reply(void);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
188 static void This_Layer_Up(PPP_Layers_t Layer);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
189 static void This_Layer_Down(PPP_Layers_t Layer);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
190 static void This_Layer_Started(PPP_Layers_t Layer);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
191 static void This_Layer_Finished(PPP_Layers_t Layer);
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
192 #endif
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
193
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
194 #endif
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
195
56d09a0969b5 Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
196