]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/ppp_msg.h
configd-42.tar.gz
[apple/configd.git] / SystemConfiguration.fproj / ppp_msg.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23
24 #ifndef _PPP_MSG_H
25 #define _PPP_MSG_H
26
27 #include <sys/types.h>
28
29 /* local socket path */
30 #define PPP_PATH "/var/run/pppconfd\0"
31
32
33 /* PPP message paquets */
34 struct ppp_msg_hdr {
35 u_int32_t m_type; // type of the message
36 u_int32_t m_result; // error code of notification message
37 u_int32_t m_cookie; // user param
38 u_int32_t m_link; // link for this message
39 u_int32_t m_len; // len of the following data
40 };
41
42 struct ppp_msg {
43 u_int32_t m_type; // type of the message
44 u_int32_t m_result; // error code of notification message
45 u_int32_t m_cookie; // user param, or error num for event
46 u_int32_t m_link; // link for this message
47 u_int32_t m_len; // len of the following data
48 u_char m_data[1]; // msg data sent or received
49 };
50
51
52
53 /* codes for ppp messages */
54 enum {
55 /* API client commands */
56 PPP_VERSION = 1,
57 PPP_STATUS,
58 PPP_CONNECT,
59 PPP_DISCONNECT = 5,
60 PPP_GETOPTION,
61 PPP_SETOPTION,
62 PPP_ENABLE_EVENT,
63 PPP_DISABLE_EVENT,
64 PPP_EVENT,
65 PPP_GETNBLINKS,
66 PPP_GETLINKBYINDEX
67
68 };
69
70 // struct for an option
71 struct ppp_opt_hdr {
72 u_int32_t o_type;
73 };
74
75 struct ppp_opt {
76 u_int32_t o_type;
77 u_char o_data[1];
78 };
79
80
81 /* codes for options management */
82 enum {
83
84 PPP_OPT_DEV_NAME = 1, // string
85 PPP_OPT_DEV_SPEED, // 4 bytes
86 PPP_OPT_DEV_CONNECTSCRIPT, // string
87
88 PPP_OPT_COMM_IDLETIMER, // 4 bytes
89 PPP_OPT_COMM_REMOTEADDR, // string
90
91 PPP_OPT_AUTH_PROTO, // 4 bytes
92 PPP_OPT_AUTH_NAME, // string
93 PPP_OPT_AUTH_PASSWD, // string
94
95 PPP_OPT_LCP_HDRCOMP, // 4 bytes
96 PPP_OPT_LCP_MRU, // 4 bytes
97 PPP_OPT_LCP_MTU, // 4 bytes
98 PPP_OPT_LCP_RCACCM, // 4 bytes
99 PPP_OPT_LCP_TXACCM, // 4 bytes
100
101 PPP_OPT_IPCP_HDRCOMP, // 4 bytes
102 PPP_OPT_IPCP_LOCALADDR, // 4 bytes
103 PPP_OPT_IPCP_REMOTEADDR, // 4 bytes
104
105 PPP_OPT_LOGFILE, // string
106 PPP_OPT_RESERVED, // 4 bytes
107 PPP_OPT_REMINDERTIMER, // 4 bytes (not implemented)
108 PPP_OPT_ALERTENABLE, // 4 bytes (not implemented)
109
110 PPP_OPT_LCP_ECHO, // struct ppp_opt_echo
111
112 PPP_OPT_COMM_CONNECTDELAY, // 4 bytes
113 PPP_OPT_COMM_SESSIONTIMER, // 4 bytes
114 PPP_OPT_COMM_TERMINALMODE, // 4 bytes
115 PPP_OPT_COMM_TERMINALSCRIPT, // string. Additionnal connection script, once modem is connected
116 PPP_OPT_DEV_CAPS, // struct ppp_caps...
117
118 PPP_OPT_IPCP_USESERVERDNS, // 4 bytes
119 PPP_OPT_COMM_CONNECTSPEED, // 4 bytes, actual connection speed
120 PPP_OPT_SERVICEID // string, name of the associated service in the store
121
122 };
123
124 // options values
125
126 // PPP_LCP_OPT_HDRCOMP -- option ppp addr/ctrl compression
127 enum {
128 PPP_LCP_HDRCOMP_NONE = 0,
129 PPP_LCP_HDRCOMP_ADDR = 1,
130 PPP_LCP_HDRCOMP_PROTO = 2
131 };
132
133 enum {
134 PPP_COMM_TERM_NONE = 0,
135 PPP_COMM_TERM_SCRIPT,
136 PPP_COMM_TERM_WINDOW
137 };
138
139 enum {
140 PPP_IPCP_HDRCOMP_NONE = 0,
141 PPP_IPCP_HDRCOMP_VJ
142 };
143
144 // PPP_LCP_OPT_RCACCM -- option receive control asynchronous character map
145 enum {
146 PPP_LCP_ACCM_NONE = 0,
147 PPP_LCP_ACCM_XONXOFF = 0x000A0000,
148 PPP_LCP_ACCM_ALL = 0xFFFFFFFF
149 };
150
151 // PPP_OPT_AUTH
152 enum {
153 PPP_AUTH_NONE = 0,
154 PPP_AUTH_PAPCHAP,
155 PPP_AUTH_PAP,
156 PPP_AUTH_CHAP
157 };
158
159 // state machine
160 enum {
161 PPP_IDLE = 0,
162 PPP_INITIALIZE,
163 PPP_CONNECTLINK,
164 PPP_STATERESERVED,
165 PPP_ESTABLISH,
166 PPP_AUTHENTICATE,
167 PPP_CALLBACK,
168 PPP_NETWORK,
169 PPP_RUNNING,
170 PPP_TERMINATE,
171 PPP_DISCONNECTLINK
172 };
173
174 // events
175 enum {
176 PPP_EVT_DISCONNECTED = 1,
177 PPP_EVT_CONNSCRIPT_STARTED,
178 PPP_EVT_CONNSCRIPT_FINISHED,
179 PPP_EVT_TERMSCRIPT_STARTED,
180 PPP_EVT_TERMSCRIPT_FINISHED,
181 PPP_EVT_LOWERLAYER_UP,
182 PPP_EVT_LOWERLAYER_DOWN,
183 PPP_EVT_LCP_UP,
184 PPP_EVT_LCP_DOWN,
185 PPP_EVT_IPCP_UP,
186 PPP_EVT_IPCP_DOWN,
187 PPP_EVT_AUTH_STARTED,
188 PPP_EVT_AUTH_FAILED,
189 PPP_EVT_AUTH_SUCCEDED
190 };
191
192 struct ppp_opt_echo { // 0 for the following value will cancel echo option
193 u_int16_t interval; // delay in seconds between echo requests
194 u_int16_t failure; // # of failure before declaring the link down
195 };
196
197 struct ppp_status {
198 // connection stats
199 u_int32_t status;
200 union {
201 struct connected {
202 u_int32_t timeElapsed;
203 u_int32_t timeRemaining;
204 // bytes stats
205 u_int32_t inBytes;
206 u_int32_t inPackets;
207 u_int32_t inErrors;
208 u_int32_t outBytes;
209 u_int32_t outPackets;
210 u_int32_t outErrors;
211 } run;
212 struct disconnected {
213 u_int32_t lastDiscCause;
214 } disc;
215 } s;
216 };
217
218 enum {
219 // from 0 to 255, we use bsd error codes from errno.h
220
221 // ppp speficic error codes
222 PPP_ERR_GEN_ERROR = 256,
223 PPP_ERR_CONNSCRIPTFAILED,
224 PPP_ERR_TERMSCRIPTFAILED,
225 PPP_ERR_LCPFAILED,
226 PPP_ERR_AUTHFAILED,
227 PPP_ERR_IDLETIMEOUT,
228 PPP_ERR_SESSIONTIMEOUT,
229 PPP_ERR_LOOPBACK,
230 PPP_ERR_PEERDEAD,
231 PPP_ERR_DISCSCRIPTFAILED,
232
233 // modem specific error codes
234 PPP_ERR_MOD_NOCARRIER = 512,
235 PPP_ERR_MOD_BUSY,
236 PPP_ERR_MOD_NODIALTONE,
237 PPP_ERR_MOD_ERROR
238 };
239
240 #endif /* _PPP_MSG_H */
241