]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/ppp_msg.h
configd-24.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
30 /* local socket path */
31 #define PPP_PATH "/var/run/pppconfd\0"
32
33
34 /* PPP message paquets */
35 struct ppp_msg_hdr {
36 u_int32_t m_type; // type of the message
37 u_int32_t m_result; // error code of notification message
38 u_int32_t m_cookie; // user param
39 u_int32_t m_link; // link for this message
40 u_int32_t m_len; // len of the following data
41 };
42
43 struct ppp_msg {
44 u_int32_t m_type; // type of the message
45 u_int32_t m_result; // error code of notification message
46 u_int32_t m_cookie; // user param, or error num for event
47 u_int32_t m_link; // link for this message
48 u_int32_t m_len; // len of the following data
49 u_char m_data[1]; // msg data sent or received
50 };
51
52
53
54 /* codes for ppp messages */
55 enum {
56 /* API client commands */
57 PPP_VERSION = 1,
58 PPP_STATUS,
59 PPP_CONNECT,
60 PPP_DISCONNECT = 5,
61 PPP_GETOPTION,
62 PPP_SETOPTION,
63 PPP_ENABLE_EVENT,
64 PPP_DISABLE_EVENT,
65 PPP_EVENT,
66 PPP_GETNBLINKS,
67 PPP_GETLINKBYINDEX
68
69 };
70
71 // struct for an option
72 struct ppp_opt_hdr {
73 u_int32_t o_type;
74 };
75
76 struct ppp_opt {
77 u_int32_t o_type;
78 u_char o_data[1];
79 };
80
81
82 /* codes for options management */
83 enum {
84
85 PPP_OPT_DEV_NAME = 1, // string
86 PPP_OPT_DEV_SPEED, // 4 bytes
87 PPP_OPT_DEV_CONNECTSCRIPT, // string
88
89 PPP_OPT_COMM_IDLETIMER, // 4 bytes
90 PPP_OPT_COMM_REMOTEADDR, // string
91
92 PPP_OPT_AUTH_PROTO, // 4 bytes
93 PPP_OPT_AUTH_NAME, // string
94 PPP_OPT_AUTH_PASSWD, // string
95
96 PPP_OPT_LCP_HDRCOMP, // 4 bytes
97 PPP_OPT_LCP_MRU, // 4 bytes
98 PPP_OPT_LCP_MTU, // 4 bytes
99 PPP_OPT_LCP_RCACCM, // 4 bytes
100 PPP_OPT_LCP_TXACCM, // 4 bytes
101
102 PPP_OPT_IPCP_HDRCOMP, // 4 bytes
103 PPP_OPT_IPCP_LOCALADDR, // 4 bytes
104 PPP_OPT_IPCP_REMOTEADDR, // 4 bytes
105
106 PPP_OPT_LOGFILE, // string
107 PPP_OPT_RESERVED, // 4 bytes
108 PPP_OPT_REMINDERTIMER, // 4 bytes (not implemented)
109 PPP_OPT_ALERTENABLE, // 4 bytes (not implemented)
110
111 PPP_OPT_LCP_ECHO, // struct ppp_opt_echo
112
113 PPP_OPT_COMM_CONNECTDELAY, // 4 bytes
114 PPP_OPT_COMM_SESSIONTIMER, // 4 bytes
115 PPP_OPT_COMM_TERMINALMODE, // 4 bytes
116 PPP_OPT_COMM_TERMINALSCRIPT, // string. Additionnal connection script, once modem is connected
117 PPP_OPT_DEV_CAPS, // struct ppp_caps...
118
119 PPP_OPT_IPCP_USESERVERDNS, // 4 bytes
120 PPP_OPT_COMM_CONNECTSPEED, // 4 bytes, actual connection speed
121 PPP_OPT_SERVICEID // string, name of the associated service in the cache
122
123 };
124
125 // options values
126
127 // PPP_LCP_OPT_HDRCOMP -- option ppp addr/ctrl compression
128 enum {
129 PPP_LCP_HDRCOMP_NONE = 0,
130 PPP_LCP_HDRCOMP_ADDR = 1,
131 PPP_LCP_HDRCOMP_PROTO = 2
132 };
133
134 enum {
135 PPP_COMM_TERM_NONE = 0,
136 PPP_COMM_TERM_SCRIPT,
137 PPP_COMM_TERM_WINDOW
138 };
139
140 enum {
141 PPP_IPCP_HDRCOMP_NONE = 0,
142 PPP_IPCP_HDRCOMP_VJ
143 };
144
145 // PPP_LCP_OPT_RCACCM -- option receive control asynchronous character map
146 enum {
147 PPP_LCP_ACCM_NONE = 0,
148 PPP_LCP_ACCM_XONXOFF = 0x000A0000,
149 PPP_LCP_ACCM_ALL = 0xFFFFFFFF
150 };
151
152 // PPP_OPT_AUTH
153 enum {
154 PPP_AUTH_NONE = 0,
155 PPP_AUTH_PAPCHAP,
156 PPP_AUTH_PAP,
157 PPP_AUTH_CHAP
158 };
159
160 // state machine
161 enum {
162 PPP_IDLE = 0,
163 PPP_INITIALIZE,
164 PPP_CONNECTLINK,
165 PPP_STATERESERVED,
166 PPP_ESTABLISH,
167 PPP_AUTHENTICATE,
168 PPP_CALLBACK,
169 PPP_NETWORK,
170 PPP_RUNNING,
171 PPP_TERMINATE,
172 PPP_DISCONNECTLINK
173 };
174
175 // events
176 enum {
177 PPP_EVT_DISCONNECTED = 1,
178 PPP_EVT_CONNSCRIPT_STARTED,
179 PPP_EVT_CONNSCRIPT_FINISHED,
180 PPP_EVT_TERMSCRIPT_STARTED,
181 PPP_EVT_TERMSCRIPT_FINISHED,
182 PPP_EVT_LOWERLAYER_UP,
183 PPP_EVT_LOWERLAYER_DOWN,
184 PPP_EVT_LCP_UP,
185 PPP_EVT_LCP_DOWN,
186 PPP_EVT_IPCP_UP,
187 PPP_EVT_IPCP_DOWN,
188 PPP_EVT_AUTH_STARTED,
189 PPP_EVT_AUTH_FAILED,
190 PPP_EVT_AUTH_SUCCEDED
191 };
192
193 struct ppp_opt_echo { // 0 for the following value will cancel echo option
194 u_int16_t interval; // delay in seconds between echo requests
195 u_int16_t failure; // # of failure before declaring the link down
196 };
197
198 struct ppp_status {
199 // connection stats
200 u_int32_t status;
201 union {
202 struct connected {
203 u_int32_t timeElapsed;
204 u_int32_t timeRemaining;
205 // bytes stats
206 u_int32_t inBytes;
207 u_int32_t inPackets;
208 u_int32_t inErrors;
209 u_int32_t outBytes;
210 u_int32_t outPackets;
211 u_int32_t outErrors;
212 } run;
213 struct disconnected {
214 u_int32_t lastDiscCause;
215 } disc;
216 } s;
217 };
218
219 enum {
220 // from 0 to 255, we use bsd error codes from errno.h
221
222 // ppp speficic error codes
223 PPP_ERR_GEN_ERROR = 256,
224 PPP_ERR_CONNSCRIPTFAILED,
225 PPP_ERR_TERMSCRIPTFAILED,
226 PPP_ERR_LCPFAILED,
227 PPP_ERR_AUTHFAILED,
228 PPP_ERR_IDLETIMEOUT,
229 PPP_ERR_SESSIONTIMEOUT,
230 PPP_ERR_LOOPBACK,
231 PPP_ERR_PEERDEAD,
232 PPP_ERR_DISCSCRIPTFAILED,
233
234 // modem specific error codes
235 PPP_ERR_MOD_NOCARRIER = 512,
236 PPP_ERR_MOD_BUSY,
237 PPP_ERR_MOD_NODIALTONE,
238 PPP_ERR_MOD_ERROR
239 };
240
241 #endif /* _PPP_MSG_H */
242