2 * Defines for synchronous PPP/Cisco link level subroutines.
4 * Copyright (C) 1994 Cronyx Ltd.
5 * Author: Serge Vakulenko, <vak@cronyx.ru>
7 * Heavily revamped to conform to RFC 1661.
8 * Copyright (C) 1997, Joerg Wunsch.
10 * This software is distributed with NO WARRANTIES, not even the implied
11 * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
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.
17 * From: Version 2.0, Fri Oct 6 20:39:21 MSK 1995
19 * From: if_sppp.h,v 1.14 1999/03/30 13:28:26 phk Exp
21 * $Id: i4b_isppp.h,v 1.5 2000/07/18 15:05:37 hm Exp $
23 * $FreeBSD: src/sys/i386/include/i4b_isppp.h,v 1.1.2.2 2001/09/28 07:43:19 gj Exp $
29 #define SPPP_VJ /* use VJ compression */
33 #if !(defined (KERNEL) || defined (_KERNEL))
37 * this is needed on FreeBSD to make /usr/src/usr.bin/kdump and
38 * /usr/src/usr.bin/truss compile.
42 #include <netinet/in_systm.h>
43 #include <netinet/ip.h>
44 #include <net/slcompress.h>
49 #define IDX_LCP 0 /* idx into state table */
52 u_long opts; /* LCP options to send (bitfield) */
53 u_long magic; /* local magic number */
54 u_long mru; /* our max receive unit */
55 u_long their_mru; /* their max receive unit */
56 u_long protos; /* bitmask of protos that are started */
57 u_char echoid; /* id of last keepalive echo request */
58 /* restart max values, see RFC 1661 */
65 #define IDX_IPCP 1 /* idx into state table */
68 u_long opts; /* IPCP options to send (bitfield) */
70 #define IPCP_HISADDR_SEEN 1 /* have seen his address already */
71 #define IPCP_MYADDR_DYN 2 /* my address is dynamically assigned */
72 #define IPCP_MYADDR_SEEN 4 /* have seen his address already */
73 #define IPCP_VJ 8 /* We can use VJ compression */
74 int max_state; /* Max-Slot-Id */
75 int compress_cid; /* Comp-Slot-Id */
78 #define AUTHNAMELEN 42
82 u_short proto; /* authentication protocol to use */
84 #define AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */
86 #define AUTHFLAG_NORECHALLENGE 2 /* do not re-challenge CHAP */
87 u_char name[AUTHNAMELEN]; /* system identification name */
88 u_char secret[AUTHKEYLEN]; /* secret password */
89 u_char challenge[AUTHKEYLEN]; /* random challenge */
95 #define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */
98 * Don't change the order of this. Ordering the phases this way allows
99 * for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to
100 * know whether LCP is up.
103 PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE,
104 PHASE_AUTHENTICATE, PHASE_NETWORK
108 /* NB: pp_if _must_ be first */
109 struct ifnet pp_if; /* network interface data */
110 struct ifqueue pp_fastq; /* fast output queue */
111 struct ifqueue pp_cpq; /* PPP control protocol queue */
112 struct sppp *pp_next; /* next interface in keepalive list */
113 u_int pp_mode; /* major protocol modes (cisco/ppp/...) */
114 u_int pp_flags; /* sub modes */
115 u_short pp_alivecnt; /* keepalive packets counter */
116 u_short pp_loopcnt; /* loopback detection counter */
117 u_long pp_seq; /* local sequence number */
118 u_long pp_rseq; /* remote sequence number */
121 enum ppp_phase pp_phase; /* phase we're currently in */
122 int state[IDX_COUNT]; /* state machine */
123 u_char confid[IDX_COUNT]; /* id of last configuration request */
124 int rst_counter[IDX_COUNT]; /* restart counter */
125 int fail_counter[IDX_COUNT]; /* negotiation failure counter */
126 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
127 struct callout_handle ch[IDX_COUNT]; /* per-proto and if callouts */
128 struct callout_handle pap_my_to_ch; /* PAP needs one more... */
130 struct slcp lcp; /* LCP params */
131 struct sipcp ipcp; /* IPCP params */
132 struct sauth myauth; /* auth params, i'm peer */
133 struct sauth hisauth; /* auth params, i'm authenticator */
135 int enable_vj; /* enable VJ negotiation */
136 struct slcompress pp_comp; /* for VJ compression */
139 * These functions are filled in by sppp_attach(), and are
140 * expected to be used by the lower layer (hardware) drivers
141 * in order to communicate the (un)availability of the
142 * communication link. Lower layer drivers that are always
143 * ready to communicate (like hardware HDLC) can shortcut
144 * pp_up from pp_tls, and pp_down from pp_tlf.
146 void (*pp_up)(struct sppp *sp);
147 void (*pp_down)(struct sppp *sp);
149 * These functions need to be filled in by the lower layer
150 * (hardware) drivers if they request notification from the
151 * PPP layer whether the link is actually required. They
152 * correspond to the tls and tlf actions.
154 void (*pp_tls)(struct sppp *sp);
155 void (*pp_tlf)(struct sppp *sp);
157 * These (optional) functions may be filled by the hardware
158 * driver if any notification of established connections
159 * (currently: IPCP up) is desired (pp_con) or any internal
160 * state change of the interface state machine should be
161 * signaled for monitoring purposes (pp_chg).
163 void (*pp_con)(struct sppp *sp);
164 void (*pp_chg)(struct sppp *sp, int new_state);
165 /* These two fields are for use by the lower layer */
170 #define PP_KEEPALIVE 0x01 /* use keepalive protocol */
171 #define PP_CALLIN 0x08 /* we are being called */
172 #define PP_NEEDAUTH 0x10 /* remote requested authentication */
175 #define PP_MTU 1500 /* default/minimal MRU */
176 #define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */
179 * Definitions to pass struct sppp data down into the kernel using the
180 * SIOC[SG]IFGENERIC ioctl interface.
182 * In order to use this, create a struct spppreq, fill in the cmd
183 * field with SPPPIOGDEFS, and put the address of this structure into
184 * the ifr_data portion of a struct ifreq. Pass this struct to a
185 * SIOCGIFGENERIC ioctl. Then replace the cmd field by SPPPIOCDEFS,
186 * modify the defs field as desired, and pass the struct ifreq now
187 * to a SIOCSIFGENERIC ioctl.
190 #define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp)))
191 #define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp)))
198 #ifndef SIOCSIFGENERIC
199 #define SIOCSIFGENERIC _IOW('i', 57, struct ifreq) /* generic IF set op */
202 #ifndef SIOCGIFGENERIC
203 #define SIOCGIFGENERIC _IOWR('i', 58, struct ifreq) /* generic IF get op */
206 #if defined(KERNEL) || defined(_KERNEL)
210 void sppp_attach (struct ifnet *ifp);
211 void sppp_detach (struct ifnet *ifp);
212 void sppp_input (struct ifnet *ifp, struct mbuf *m);
214 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300003
215 int sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
218 int sppp_ioctl (struct ifnet *ifp, int cmd, void *data);
220 int sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
224 struct mbuf *sppp_dequeue (struct ifnet *ifp);
225 struct mbuf *sppp_pick(struct ifnet *ifp);
226 int sppp_isempty (struct ifnet *ifp);
227 void sppp_flush (struct ifnet *ifp);
229 #else /* USE_ISPPP */
231 void isppp_attach (struct ifnet *ifp);
232 void isppp_detach (struct ifnet *ifp);
233 void isppp_input (struct ifnet *ifp, struct mbuf *m);
235 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300003
236 int isppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
239 int isppp_ioctl (struct ifnet *ifp, int cmd, void *data);
241 int isppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
245 struct mbuf *isppp_dequeue (struct ifnet *ifp);
246 struct mbuf *isppp_pick(struct ifnet *ifp);
247 int isppp_isempty (struct ifnet *ifp);
248 void isppp_flush (struct ifnet *ifp);
249 #endif /* USE_ISPPP */
253 #endif /* _I4B_ISPPP_H_ */