Remove extraneous closing brace.
[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.6 2005/06/15 07:15:03 asmodai 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 #ifndef (_KERNEL)
35 #include <netinet/in_systm.h>
36 #include <netinet/ip.h>
37 #include <net/slcompress.h>
38 #endif
39 #endif
40
41 #define IDX_LCP 0               /* idx into state table */
42
43 struct slcp {
44         u_long  opts;           /* LCP options to send (bitfield) */
45         u_long  magic;          /* local magic number */
46         u_long  mru;            /* our max receive unit */
47         u_long  their_mru;      /* their max receive unit */
48         u_long  protos;         /* bitmask of protos that are started */
49         u_char  echoid;         /* id of last keepalive echo request */
50         /* restart max values, see RFC 1661 */
51         int     timeout;
52         int     max_terminate;
53         int     max_configure;
54         int     max_failure;
55 };
56
57 #define IDX_IPCP 1              /* idx into state table */
58
59 struct sipcp {
60         u_long  opts;           /* IPCP options to send (bitfield) */
61         u_int   flags;
62 #define IPCP_HISADDR_SEEN 1     /* have seen his address already */
63 #define IPCP_MYADDR_DYN   2     /* my address is dynamically assigned */
64 #define IPCP_MYADDR_SEEN  4     /* have seen his address already */
65 #define IPCP_VJ           8     /* We can use VJ compression */
66         int     max_state;      /* Max-Slot-Id */
67         int     compress_cid;   /* Comp-Slot-Id */
68 };
69
70 #define AUTHNAMELEN     42
71 #define AUTHKEYLEN      16
72
73 struct sauth {
74         u_short proto;                  /* authentication protocol to use */
75         u_short flags;
76 #define AUTHFLAG_NOCALLOUT      1       /* do not require authentication on */
77                                         /* callouts */
78 #define AUTHFLAG_NORECHALLENGE  2       /* do not re-challenge CHAP */
79         u_char  name[AUTHNAMELEN];      /* system identification name */
80         u_char  secret[AUTHKEYLEN];     /* secret password */
81         u_char  challenge[AUTHKEYLEN];  /* random challenge */
82 };
83
84 #define IDX_PAP         2
85 #define IDX_CHAP        3
86
87 #define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */
88
89 /*
90  * Don't change the order of this.  Ordering the phases this way allows
91  * for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to
92  * know whether LCP is up.
93  */
94 enum ppp_phase {
95         PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE,
96         PHASE_AUTHENTICATE, PHASE_NETWORK
97 };
98
99 struct sppp {
100         /* NB: pp_if _must_ be first */
101         struct  ifnet pp_if;    /* network interface data */
102         struct  ifqueue pp_fastq; /* fast output queue */
103         struct  ifqueue pp_cpq; /* PPP control protocol queue */
104         struct  sppp *pp_next;  /* next interface in keepalive list */
105         u_int   pp_mode;        /* major protocol modes (cisco/ppp/...) */
106         u_int   pp_flags;       /* sub modes */
107         u_short pp_alivecnt;    /* keepalive packets counter */
108         u_short pp_loopcnt;     /* loopback detection counter */
109         u_long  pp_seq;         /* local sequence number */
110         u_long  pp_rseq;        /* remote sequence number */
111         time_t  pp_last_sent;
112         time_t  pp_last_recv;
113         enum ppp_phase pp_phase;        /* phase we're currently in */
114         int     state[IDX_COUNT];       /* state machine */
115         u_char  confid[IDX_COUNT];      /* id of last configuration request */
116         int     rst_counter[IDX_COUNT]; /* restart counter */
117         int     fail_counter[IDX_COUNT]; /* negotiation failure counter */
118         struct callout timeout[IDX_COUNT]; /* per-proto and if callouts */
119         struct callout pap_my_to; /* PAP needs one more... */
120         struct slcp lcp;                /* LCP params */
121         struct sipcp ipcp;              /* IPCP params */
122         struct sauth myauth;            /* auth params, i'm peer */
123         struct sauth hisauth;           /* auth params, i'm authenticator */
124 #ifdef SPPP_VJ
125         int enable_vj;                  /* enable VJ negotiation */
126         struct slcompress pp_comp;      /* for VJ compression */
127 #endif
128         /*
129          * These functions are filled in by sppp_attach(), and are
130          * expected to be used by the lower layer (hardware) drivers
131          * in order to communicate the (un)availability of the
132          * communication link.  Lower layer drivers that are always
133          * ready to communicate (like hardware HDLC) can shortcut
134          * pp_up from pp_tls, and pp_down from pp_tlf.
135          */
136         void    (*pp_up)(struct sppp *sp);
137         void    (*pp_down)(struct sppp *sp);
138         /*
139          * These functions need to be filled in by the lower layer
140          * (hardware) drivers if they request notification from the
141          * PPP layer whether the link is actually required.  They
142          * correspond to the tls and tlf actions.
143          */
144         void    (*pp_tls)(struct sppp *sp);
145         void    (*pp_tlf)(struct sppp *sp);
146         /*
147          * These (optional) functions may be filled by the hardware
148          * driver if any notification of established connections
149          * (currently: IPCP up) is desired (pp_con) or any internal
150          * state change of the interface state machine should be
151          * signaled for monitoring purposes (pp_chg).
152          */
153         void    (*pp_con)(struct sppp *sp);
154         void    (*pp_chg)(struct sppp *sp, int new_state);
155         /* These two fields are for use by the lower layer */
156         void    *pp_lowerp;
157         int     pp_loweri;
158 };
159
160 #define PP_KEEPALIVE    0x01    /* use keepalive protocol */
161 #define PP_CALLIN       0x08    /* we are being called */
162 #define PP_NEEDAUTH     0x10    /* remote requested authentication */
163
164
165 #define PP_MTU          1500    /* default/minimal MRU */
166 #define PP_MAX_MRU      2048    /* maximal MRU we want to negotiate */
167
168 /*
169  * Definitions to pass struct sppp data down into the kernel using the
170  * SIOC[SG]IFGENERIC ioctl interface.
171  *
172  * In order to use this, create a struct spppreq, fill in the cmd
173  * field with SPPPIOGDEFS, and put the address of this structure into
174  * the ifr_data portion of a struct ifreq.  Pass this struct to a
175  * SIOCGIFGENERIC ioctl.  Then replace the cmd field by SPPPIOCDEFS,
176  * modify the defs field as desired, and pass the struct ifreq now
177  * to a SIOCSIFGENERIC ioctl.
178  */
179
180 #define SPPPIOGDEFS  ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp)))
181 #define SPPPIOSDEFS  ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp)))
182
183 struct spppreq {
184         u_long  cmd;
185         struct sppp defs;
186 };
187
188 #ifndef SIOCSIFGENERIC
189 #define SIOCSIFGENERIC   _IOW('i', 57, struct ifreq)    /* generic IF set op */
190 #endif
191
192 #ifndef SIOCGIFGENERIC
193 #define SIOCGIFGENERIC  _IOWR('i', 58, struct ifreq)    /* generic IF get op */
194 #endif
195
196 #if defined(KERNEL) || defined(_KERNEL)
197
198 #ifndef USE_ISPPP
199
200 void sppp_attach (struct ifnet *ifp);
201 void sppp_detach (struct ifnet *ifp);
202 void sppp_input (struct ifnet *ifp, struct mbuf *m);
203
204 int sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
205
206 struct mbuf *sppp_dequeue (struct ifnet *ifp);
207 struct mbuf *sppp_pick(struct ifnet *ifp);
208 int sppp_isempty (struct ifnet *ifp);
209 void sppp_flush (struct ifnet *ifp);
210
211 #else /* USE_ISPPP */
212
213 void isppp_attach (struct ifnet *ifp);
214 void isppp_detach (struct ifnet *ifp);
215 void isppp_input (struct ifnet *ifp, struct mbuf *m);
216
217 int isppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
218
219 struct mbuf *isppp_dequeue (struct ifnet *ifp);
220 struct mbuf *isppp_pick(struct ifnet *ifp);
221 int isppp_isempty (struct ifnet *ifp);
222 void isppp_flush (struct ifnet *ifp);
223 #endif /* USE_ISPPP */
224
225 #endif /* KERNEL */
226
227 #endif /* _I4B_ISPPP_H_ */