Merge from vendor branch HEIMDAL:
[dragonfly.git] / sys / net / i4b / include / i386 / i4b_isppp.h
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.5 2000/07/18 15:05:37 hm Exp $
22  *
23  * $FreeBSD: src/sys/i386/include/i4b_isppp.h,v 1.1.2.2 2001/09/28 07:43:19 gj Exp $
24  * $DragonFly: src/sys/net/i4b/include/i386/i4b_isppp.h,v 1.4 2004/09/16 04:36:32 dillon Exp $
25  */
26
27 #ifndef _I4B_ISPPP_H_
28 #define _I4B_ISPPP_H_
29
30 #define SPPP_VJ                 /* use VJ compression */
31
32
33 #ifdef SPPP_VJ
34 #if !(defined (KERNEL) || defined (_KERNEL))
35 #if defined(__DragonFly__) || defined(__FreeBSD__)
36 #if 0
37 /*
38  * this is needed on FreeBSD to make /usr/src/usr.bin/kdump and
39  * /usr/src/usr.bin/truss compile.
40  */
41 #include <sys/mbuf.h>
42 #endif
43 #include <netinet/in_systm.h>
44 #include <netinet/ip.h>
45 #include <net/slcompress.h>
46 #endif
47 #endif
48 #endif
49
50 #define IDX_LCP 0               /* idx into state table */
51
52 struct slcp {
53         u_long  opts;           /* LCP options to send (bitfield) */
54         u_long  magic;          /* local magic number */
55         u_long  mru;            /* our max receive unit */
56         u_long  their_mru;      /* their max receive unit */
57         u_long  protos;         /* bitmask of protos that are started */
58         u_char  echoid;         /* id of last keepalive echo request */
59         /* restart max values, see RFC 1661 */
60         int     timeout;
61         int     max_terminate;
62         int     max_configure;
63         int     max_failure;
64 };
65
66 #define IDX_IPCP 1              /* idx into state table */
67
68 struct sipcp {
69         u_long  opts;           /* IPCP options to send (bitfield) */
70         u_int   flags;
71 #define IPCP_HISADDR_SEEN 1     /* have seen his address already */
72 #define IPCP_MYADDR_DYN   2     /* my address is dynamically assigned */
73 #define IPCP_MYADDR_SEEN  4     /* have seen his address already */
74 #define IPCP_VJ           8     /* We can use VJ compression */
75         int     max_state;      /* Max-Slot-Id */
76         int     compress_cid;   /* Comp-Slot-Id */
77 };
78
79 #define AUTHNAMELEN     42
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
108 struct sppp {
109         /* NB: pp_if _must_ be first */
110         struct  ifnet pp_if;    /* network interface data */
111         struct  ifqueue pp_fastq; /* fast output queue */
112         struct  ifqueue pp_cpq; /* PPP control protocol queue */
113         struct  sppp *pp_next;  /* next interface in keepalive list */
114         u_int   pp_mode;        /* major protocol modes (cisco/ppp/...) */
115         u_int   pp_flags;       /* sub modes */
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         time_t  pp_last_sent;
121         time_t  pp_last_recv;
122         enum ppp_phase pp_phase;        /* phase we're currently in */
123         int     state[IDX_COUNT];       /* state machine */
124         u_char  confid[IDX_COUNT];      /* id of last configuration request */
125         int     rst_counter[IDX_COUNT]; /* restart counter */
126         int     fail_counter[IDX_COUNT]; /* negotiation failure counter */
127 #if defined(__DragonFly__) || (defined(__FreeBSD__) && __FreeBSD__ >= 3)
128         struct callout timeout[IDX_COUNT]; /* per-proto and if callouts */
129         struct callout pap_my_to; /* PAP needs one more... */
130 #endif
131         struct slcp lcp;                /* LCP params */
132         struct sipcp ipcp;              /* IPCP params */
133         struct sauth myauth;            /* auth params, i'm peer */
134         struct sauth hisauth;           /* auth params, i'm authenticator */
135 #ifdef SPPP_VJ
136         int enable_vj;                  /* enable VJ negotiation */
137         struct slcompress pp_comp;      /* for VJ compression */
138 #endif
139         /*
140          * These functions are filled in by sppp_attach(), and are
141          * expected to be used by the lower layer (hardware) drivers
142          * in order to communicate the (un)availability of the
143          * communication link.  Lower layer drivers that are always
144          * ready to communicate (like hardware HDLC) can shortcut
145          * pp_up from pp_tls, and pp_down from pp_tlf.
146          */
147         void    (*pp_up)(struct sppp *sp);
148         void    (*pp_down)(struct sppp *sp);
149         /*
150          * These functions need to be filled in by the lower layer
151          * (hardware) drivers if they request notification from the
152          * PPP layer whether the link is actually required.  They
153          * correspond to the tls and tlf actions.
154          */
155         void    (*pp_tls)(struct sppp *sp);
156         void    (*pp_tlf)(struct sppp *sp);
157         /*
158          * These (optional) functions may be filled by the hardware
159          * driver if any notification of established connections
160          * (currently: IPCP up) is desired (pp_con) or any internal
161          * state change of the interface state machine should be
162          * signaled for monitoring purposes (pp_chg).
163          */
164         void    (*pp_con)(struct sppp *sp);
165         void    (*pp_chg)(struct sppp *sp, int new_state);
166         /* These two fields are for use by the lower layer */
167         void    *pp_lowerp;
168         int     pp_loweri;
169 };
170
171 #define PP_KEEPALIVE    0x01    /* use keepalive protocol */
172 #define PP_CALLIN       0x08    /* we are being called */
173 #define PP_NEEDAUTH     0x10    /* remote requested authentication */
174
175
176 #define PP_MTU          1500    /* default/minimal MRU */
177 #define PP_MAX_MRU      2048    /* maximal MRU we want to negotiate */
178
179 /*
180  * Definitions to pass struct sppp data down into the kernel using the
181  * SIOC[SG]IFGENERIC ioctl interface.
182  *
183  * In order to use this, create a struct spppreq, fill in the cmd
184  * field with SPPPIOGDEFS, and put the address of this structure into
185  * the ifr_data portion of a struct ifreq.  Pass this struct to a
186  * SIOCGIFGENERIC ioctl.  Then replace the cmd field by SPPPIOCDEFS,
187  * modify the defs field as desired, and pass the struct ifreq now
188  * to a SIOCSIFGENERIC ioctl.
189  */
190
191 #define SPPPIOGDEFS  ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp)))
192 #define SPPPIOSDEFS  ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp)))
193
194 struct spppreq {
195         u_long  cmd;
196         struct sppp defs;
197 };
198
199 #ifndef SIOCSIFGENERIC
200 #define SIOCSIFGENERIC   _IOW('i', 57, struct ifreq)    /* generic IF set op */
201 #endif
202
203 #ifndef SIOCGIFGENERIC
204 #define SIOCGIFGENERIC  _IOWR('i', 58, struct ifreq)    /* generic IF get op */
205 #endif
206
207 #if defined(KERNEL) || defined(_KERNEL)
208
209 #ifndef USE_ISPPP
210
211 void sppp_attach (struct ifnet *ifp);
212 void sppp_detach (struct ifnet *ifp);
213 void sppp_input (struct ifnet *ifp, struct mbuf *m);
214
215 #if defined(__DragonFly__) || (defined(__FreeBSD_version) && __FreeBSD_version >= 300003)
216 int sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
217 #else
218 #if defined(__DragonFly__) || defined(__FreeBSD__)
219 int sppp_ioctl (struct ifnet *ifp, int cmd, void *data);
220 #else
221 int sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
222 #endif
223 #endif
224
225 struct mbuf *sppp_dequeue (struct ifnet *ifp);
226 struct mbuf *sppp_pick(struct ifnet *ifp);
227 int sppp_isempty (struct ifnet *ifp);
228 void sppp_flush (struct ifnet *ifp);
229
230 #else /* USE_ISPPP */
231
232 void isppp_attach (struct ifnet *ifp);
233 void isppp_detach (struct ifnet *ifp);
234 void isppp_input (struct ifnet *ifp, struct mbuf *m);
235
236 #if defined(__DragonFly__) || (defined(__FreeBSD_version) && __FreeBSD_version >= 300003)
237 int isppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
238 #else
239 #if defined(__DragonFly__) || defined(__FreeBSD__)
240 int isppp_ioctl (struct ifnet *ifp, int cmd, void *data);
241 #else
242 int isppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
243 #endif
244 #endif
245
246 struct mbuf *isppp_dequeue (struct ifnet *ifp);
247 struct mbuf *isppp_pick(struct ifnet *ifp);
248 int isppp_isempty (struct ifnet *ifp);
249 void isppp_flush (struct ifnet *ifp);
250 #endif /* USE_ISPPP */
251
252 #endif /* KERNEL */
253
254 #endif /* _I4B_ISPPP_H_ */