1 /*
2 * Defines for synchronous PPP/Cisco link level subroutines.
3 *
4 * Copyright (C) 1994 Cronyx Ltd.
5 * Author: Serge Vakulenko, <vak@cronyx.ru>
6 *
7 * Heavily revamped to conform to RFC 1661.
8 * Copyright (C) 1997, Joerg Wunsch.
9 *
10 * This software is distributed with NO WARRANTIES, not even the implied
11 * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 *
13 * Authors grant any other persons or organizations permission to use
14 * or modify this software as long as this message is kept with the software,
15 * all derivative works or modified versions.
16 *
17 * From: Version 2.0, Fri Oct 6 20:39:21 MSK 1995
18 *
19 * From: if_sppp.h,v 1.14 1999/03/30 13:28:26 phk Exp
20 *
21 * $Id: i4b_isppp.h,v 1.1.1.1 2001/01/05 12:49:53 martin Exp $
22 */
23
24 #ifndef _I4B_ISPPP_H_
25 #define _I4B_ISPPP_H_
26
27 #define SPPP_VJ /* use VJ compression */
28
29
30 #ifdef SPPP_VJ
31 #if !(defined (KERNEL) || defined (_KERNEL))
32 #ifdef __FreeBSD__
33 #if 0
34 /*
35 * this is needed on FreeBSD to make /usr/src/usr.bin/kdump and
36 * /usr/src/usr.bin/truss compile.
37 */
38 #include <sys/mbuf.h>
39 #endif
40 #include <netinet/in_systm.h>
41 #include <netinet/ip.h>
42 #include <net/slcompress.h>
43 #endif
44 #endif
45 #endif
46
47 #define IDX_LCP 0 /* idx into state table */
48
49 struct slcp {
50 u_long opts; /* LCP options to send (bitfield) */
51 u_long magic; /* local magic number */
52 u_long mru; /* our max receive unit */
53 u_long their_mru; /* their max receive unit */
54 u_long protos; /* bitmask of protos that are started */
55 u_char echoid; /* id of last keepalive echo request */
56 /* restart max values, see RFC 1661 */
57 int timeout;
58 int max_terminate;
59 int max_configure;
60 int max_failure;
61 };
62
63 #define IDX_IPCP 1 /* idx into state table */
64
65 struct sipcp {
66 u_long opts; /* IPCP options to send (bitfield) */
67 u_int flags;
68 #define IPCP_HISADDR_SEEN 1 /* have seen his address already */
69 #define IPCP_MYADDR_DYN 2 /* my address is dynamically assigned */
70 #define IPCP_MYADDR_SEEN 4 /* have seen his address already */
71 #define IPCP_VJ 8 /* We can use VJ compression */
72 int max_state; /* Max-Slot-Id */
73 int compress_cid; /* Comp-Slot-Id */
74 };
75
76 #define AUTHNAMELEN 32
77 #define AUTHKEYLEN 16
78
79 struct sauth {
80 u_short proto; /* authentication protocol to use */
81 u_short flags;
82 #define AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */
83 /* callouts */
84 #define AUTHFLAG_NORECHALLENGE 2 /* do not re-challenge CHAP */
85 u_char name[AUTHNAMELEN]; /* system identification name */
86 u_char secret[AUTHKEYLEN]; /* secret password */
87 u_char challenge[AUTHKEYLEN]; /* random challenge */
88 };
89
90 #define IDX_PAP 2
91 #define IDX_CHAP 3
92
93 #define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */
94
95 /*
96 * Don't change the order of this. Ordering the phases this way allows
97 * for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to
98 * know whether LCP is up.
99 */
100 enum ppp_phase {
101 PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE,
102 PHASE_AUTHENTICATE, PHASE_NETWORK
103 };
104
105 struct sppp {
106 /* NB: pp_if _must_ be first */
107 struct ifnet pp_if; /* network interface data */
108 struct ifqueue pp_fastq; /* fast output queue */
109 struct ifqueue pp_cpq; /* PPP control protocol queue */
110 struct sppp *pp_next; /* next interface in keepalive list */
111 u_int pp_mode; /* major protocol modes (cisco/ppp/...) */
112 u_int pp_flags; /* sub modes */
113 u_short pp_alivecnt; /* keepalive packets counter */
114 u_short pp_loopcnt; /* loopback detection counter */
115 u_long pp_seq; /* local sequence number */
116 u_long pp_rseq; /* remote sequence number */
117 time_t pp_last_sent;
118 time_t pp_last_recv;
119 enum ppp_phase pp_phase; /* phase we're currently in */
120 int state[IDX_COUNT]; /* state machine */
121 u_char confid[IDX_COUNT]; /* id of last configuration request */
122 int rst_counter[IDX_COUNT]; /* restart counter */
123 int fail_counter[IDX_COUNT]; /* negotiation failure counter */
124 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
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 #endif
128 struct slcp lcp; /* LCP params */
129 struct sipcp ipcp; /* IPCP params */
130 struct sauth myauth; /* auth params, i'm peer */
131 struct sauth hisauth; /* auth params, i'm authenticator */
132 #ifdef SPPP_VJ
133 int enable_vj; /* enable VJ negotiation */
134 struct slcompress pp_comp; /* for VJ compression */
135 #endif
136 /*
137 * These functions are filled in by sppp_attach(), and are
138 * expected to be used by the lower layer (hardware) drivers
139 * in order to communicate the (un)availability of the
140 * communication link. Lower layer drivers that are always
141 * ready to communicate (like hardware HDLC) can shortcut
142 * pp_up from pp_tls, and pp_down from pp_tlf.
143 */
144 void (*pp_up)(struct sppp *sp);
145 void (*pp_down)(struct sppp *sp);
146 /*
147 * These functions need to be filled in by the lower layer
148 * (hardware) drivers if they request notification from the
149 * PPP layer whether the link is actually required. They
150 * correspond to the tls and tlf actions.
151 */
152 void (*pp_tls)(struct sppp *sp);
153 void (*pp_tlf)(struct sppp *sp);
154 /*
155 * These (optional) functions may be filled by the hardware
156 * driver if any notification of established connections
157 * (currently: IPCP up) is desired (pp_con) or any internal
158 * state change of the interface state machine should be
159 * signaled for monitoring purposes (pp_chg).
160 */
161 void (*pp_con)(struct sppp *sp);
162 void (*pp_chg)(struct sppp *sp, int new_state);
163 /* These two fields are for use by the lower layer */
164 void *pp_lowerp;
165 int pp_loweri;
166 };
167
168 #define PP_KEEPALIVE 0x01 /* use keepalive protocol */
169 #define PP_CALLIN 0x08 /* we are being called */
170 #define PP_NEEDAUTH 0x10 /* remote requested authentication */
171
172
173 #define PP_MTU 1500 /* default/minimal MRU */
174 #define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */
175
176 /*
177 * Definitions to pass struct sppp data down into the kernel using the
178 * SIOC[SG]IFGENERIC ioctl interface.
179 *
180 * In order to use this, create a struct spppreq, fill in the cmd
181 * field with SPPPIOGDEFS, and put the address of this structure into
182 * the ifr_data portion of a struct ifreq. Pass this struct to a
183 * SIOCGIFGENERIC ioctl. Then replace the cmd field by SPPPIOCDEFS,
184 * modify the defs field as desired, and pass the struct ifreq now
185 * to a SIOCSIFGENERIC ioctl.
186 */
187
188 #define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp)))
189 #define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp)))
190
191 struct spppreq {
192 u_long cmd;
193 struct sppp defs;
194 };
195
196 #ifndef SIOCSIFGENERIC
197 #define SIOCSIFGENERIC _IOW('i', 57, struct ifreq) /* generic IF set op */
198 #endif
199
200 #ifndef SIOCGIFGENERIC
201 #define SIOCGIFGENERIC _IOWR('i', 58, struct ifreq) /* generic IF get op */
202 #endif
203
204 #if defined(KERNEL) || defined(_KERNEL)
205
206 #ifndef USE_ISPPP
207
208 void sppp_attach (struct ifnet *ifp);
209 void sppp_detach (struct ifnet *ifp);
210 void sppp_input (struct ifnet *ifp, struct mbuf *m);
211
212 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300003
213 int sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
214 #else
215 #ifdef __FreeBSD__
216 int sppp_ioctl (struct ifnet *ifp, int cmd, void *data);
217 #else
218 int sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
219 #endif
220 #endif
221
222 struct mbuf *sppp_dequeue (struct ifnet *ifp);
223 struct mbuf *sppp_pick(struct ifnet *ifp);
224 int sppp_isempty (struct ifnet *ifp);
225 void sppp_flush (struct ifnet *ifp);
226
227 #else /* USE_ISPPP */
228
229 void isppp_attach (struct ifnet *ifp);
230 void isppp_detach (struct ifnet *ifp);
231 void isppp_input (struct ifnet *ifp, struct mbuf *m);
232
233 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300003
234 int isppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
235 #else
236 #ifdef __FreeBSD__
237 int isppp_ioctl (struct ifnet *ifp, int cmd, void *data);
238 #else
239 int isppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
240 #endif
241 #endif
242
243 struct mbuf *isppp_dequeue (struct ifnet *ifp);
244 struct mbuf *isppp_pick(struct ifnet *ifp);
245 int isppp_isempty (struct ifnet *ifp);
246 void isppp_flush (struct ifnet *ifp);
247 #endif /* USE_ISPPP */
248
249 #endif /* KERNEL */
250
251 #endif /* _I4B_ISPPP_H_ */
Cache object: 1a4a1f3dff9de0c5f719a5d50509a7bc
|