]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
d7e50217 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
d7e50217 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
d7e50217 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * Defines for synchronous PPP/Cisco link level subroutines. | |
27 | * | |
28 | * Copyright (C) 1994 Cronyx Ltd. | |
29 | * Author: Serge Vakulenko, <vak@cronyx.ru> | |
30 | * | |
31 | * Heavily revamped to conform to RFC 1661. | |
32 | * Copyright (C) 1997, Joerg Wunsch. | |
33 | * | |
34 | * This software is distributed with NO WARRANTIES, not even the implied | |
35 | * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
36 | * | |
37 | * Authors grant any other persons or organizations permission to use | |
38 | * or modify this software as long as this message is kept with the software, | |
39 | * all derivative works or modified versions. | |
40 | * | |
41 | * From: Version 2.0, Fri Oct 6 20:39:21 MSK 1995 | |
42 | * | |
43 | */ | |
44 | ||
45 | #ifndef _NET_IF_SPPP_H_ | |
46 | #define _NET_IF_SPPP_H_ 1 | |
9bccf70c A |
47 | #include <sys/appleapiopts.h> |
48 | ||
49 | #ifndef DONT_WARN_OBSOLETE | |
50 | #warning if_sppp.h is not used by the darwin kernel | |
51 | #endif | |
1c79356b A |
52 | |
53 | #define IDX_LCP 0 /* idx into state table */ | |
54 | ||
55 | struct slcp { | |
56 | u_long opts; /* LCP options to send (bitfield) */ | |
57 | u_long magic; /* local magic number */ | |
58 | u_long mru; /* our max receive unit */ | |
59 | u_long their_mru; /* their max receive unit */ | |
60 | u_long protos; /* bitmask of protos that are started */ | |
61 | u_char echoid; /* id of last keepalive echo request */ | |
62 | /* restart max values, see RFC 1661 */ | |
63 | int timeout; | |
64 | int max_terminate; | |
65 | int max_configure; | |
66 | int max_failure; | |
67 | }; | |
68 | ||
69 | #define IDX_IPCP 1 /* idx into state table */ | |
70 | ||
71 | struct sipcp { | |
72 | u_long opts; /* IPCP options to send (bitfield) */ | |
73 | u_int flags; | |
74 | #define IPCP_HISADDR_SEEN 1 /* have seen his address already */ | |
75 | #define IPCP_MYADDR_DYN 2 /* my address is dynamically assigned */ | |
76 | #define IPCP_MYADDR_SEEN 4 /* have seen his address already */ | |
77 | }; | |
78 | ||
79 | #define AUTHNAMELEN 32 | |
80 | #define AUTHKEYLEN 16 | |
81 | ||
82 | struct sauth { | |
83 | u_short proto; /* authentication protocol to use */ | |
84 | u_short flags; | |
85 | #define AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */ | |
86 | /* callouts */ | |
87 | #define AUTHFLAG_NORECHALLENGE 2 /* do not re-challenge CHAP */ | |
88 | u_char name[AUTHNAMELEN]; /* system identification name */ | |
89 | u_char secret[AUTHKEYLEN]; /* secret password */ | |
90 | u_char challenge[AUTHKEYLEN]; /* random challenge */ | |
91 | }; | |
92 | ||
93 | #define IDX_PAP 2 | |
94 | #define IDX_CHAP 3 | |
95 | ||
96 | #define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */ | |
97 | ||
98 | /* | |
99 | * Don't change the order of this. Ordering the phases this way allows | |
100 | * for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to | |
101 | * know whether LCP is up. | |
102 | */ | |
103 | enum ppp_phase { | |
104 | PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE, | |
105 | PHASE_AUTHENTICATE, PHASE_NETWORK | |
106 | }; | |
107 | ||
9bccf70c | 108 | #ifdef __APPLE_API_PRIVATE |
1c79356b A |
109 | struct sppp { |
110 | /* NB: pp_if _must_ be first */ | |
111 | struct ifnet pp_if; /* network interface data */ | |
112 | struct ifqueue pp_fastq; /* fast output queue */ | |
113 | struct ifqueue pp_cpq; /* PPP control protocol queue */ | |
114 | struct sppp *pp_next; /* next interface in keepalive list */ | |
115 | u_int pp_flags; /* use Cisco protocol instead of PPP */ | |
116 | u_short pp_alivecnt; /* keepalive packets counter */ | |
117 | u_short pp_loopcnt; /* loopback detection counter */ | |
118 | u_long pp_seq; /* local sequence number */ | |
119 | u_long pp_rseq; /* remote sequence number */ | |
120 | enum ppp_phase pp_phase; /* phase we're currently in */ | |
121 | int state[IDX_COUNT]; /* state machine */ | |
122 | u_char confid[IDX_COUNT]; /* id of last configuration request */ | |
123 | int rst_counter[IDX_COUNT]; /* restart counter */ | |
124 | int fail_counter[IDX_COUNT]; /* negotiation failure counter */ | |
125 | struct callout_handle ch[IDX_COUNT]; /* per-proto and if callouts */ | |
126 | struct callout_handle pap_my_to_ch; /* PAP needs one more... */ | |
127 | struct slcp lcp; /* LCP params */ | |
128 | struct sipcp ipcp; /* IPCP params */ | |
129 | struct sauth myauth; /* auth params, i'm peer */ | |
130 | struct sauth hisauth; /* auth params, i'm authenticator */ | |
131 | /* | |
132 | * These functions are filled in by sppp_attach(), and are | |
133 | * expected to be used by the lower layer (hardware) drivers | |
134 | * in order to communicate the (un)availability of the | |
135 | * communication link. Lower layer drivers that are always | |
136 | * ready to communicate (like hardware HDLC) can shortcut | |
137 | * pp_up from pp_tls, and pp_down from pp_tlf. | |
138 | */ | |
139 | void (*pp_up)(struct sppp *sp); | |
140 | void (*pp_down)(struct sppp *sp); | |
141 | /* | |
142 | * These functions need to be filled in by the lower layer | |
143 | * (hardware) drivers if they request notification from the | |
144 | * PPP layer whether the link is actually required. They | |
145 | * correspond to the tls and tlf actions. | |
146 | */ | |
147 | void (*pp_tls)(struct sppp *sp); | |
148 | void (*pp_tlf)(struct sppp *sp); | |
149 | /* | |
150 | * These (optional) functions may be filled by the hardware | |
151 | * driver if any notification of established connections | |
152 | * (currently: IPCP up) is desired (pp_con) or any internal | |
153 | * state change of the interface state machine should be | |
154 | * signaled for monitoring purposes (pp_chg). | |
155 | */ | |
156 | void (*pp_con)(struct sppp *sp); | |
157 | void (*pp_chg)(struct sppp *sp, int new_state); | |
158 | /* These two fields are for use by the lower layer */ | |
159 | void *pp_lowerp; | |
160 | int pp_loweri; | |
161 | }; | |
162 | ||
9bccf70c A |
163 | #endif /* __APPLE_API_PRIVATE */ |
164 | ||
1c79356b A |
165 | #define PP_KEEPALIVE 0x01 /* use keepalive protocol */ |
166 | #define PP_CISCO 0x02 /* use Cisco protocol instead of PPP */ | |
167 | /* 0x04 was PP_TIMO */ | |
168 | #define PP_CALLIN 0x08 /* we are being called */ | |
169 | #define PP_NEEDAUTH 0x10 /* remote requested authentication */ | |
170 | ||
171 | ||
172 | #define PP_MTU 1500 /* default/minimal MRU */ | |
173 | #define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */ | |
174 | ||
175 | /* | |
176 | * Definitions to pass struct sppp data down into the kernel using the | |
177 | * SIOC[SG]IFGENERIC ioctl interface. | |
178 | * | |
179 | * In order to use this, create a struct spppreq, fill in the cmd | |
180 | * field with SPPPIOGDEFS, and put the address of this structure into | |
181 | * the ifr_data portion of a struct ifreq. Pass this struct to a | |
182 | * SIOCGIFGENERIC ioctl. Then replace the cmd field by SPPPIOCDEFS, | |
183 | * modify the defs field as desired, and pass the struct ifreq now | |
184 | * to a SIOCSIFGENERIC ioctl. | |
185 | */ | |
186 | ||
187 | #define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp))) | |
188 | #define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp))) | |
189 | ||
190 | struct spppreq { | |
191 | int cmd; | |
192 | struct sppp defs; | |
193 | }; | |
194 | ||
195 | #ifdef KERNEL | |
9bccf70c | 196 | #ifdef __APPLE_API_PRIVATE |
1c79356b A |
197 | void sppp_attach (struct ifnet *ifp); |
198 | void sppp_detach (struct ifnet *ifp); | |
199 | void sppp_input (struct ifnet *ifp, struct mbuf *m); | |
200 | int sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data); | |
201 | struct mbuf *sppp_dequeue (struct ifnet *ifp); | |
202 | struct mbuf *sppp_pick(struct ifnet *ifp); | |
203 | int sppp_isempty (struct ifnet *ifp); | |
204 | void sppp_flush (struct ifnet *ifp); | |
9bccf70c | 205 | #endif /* __APPLE_API_PRIVATE */ |
1c79356b A |
206 | #endif |
207 | ||
208 | #endif /* _NET_IF_SPPP_H_ */ |