if_sppp.h revision 1.3 1 /*
2 * Defines for synchronous PPP/Cisco link level subroutines.
3 *
4 * Copyright (C) 1994 Cronyx Ltd.
5 * Author: Serge Vakulenko, <vak (at) 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.8 1997/10/11 11:25:20 joerg Exp
20 *
21 * $Id: if_sppp.h,v 1.3 1999/04/04 06:07:56 explorer Exp $
22 */
23
24 #ifndef _NET_IF_HDLC_H_
25 #define _NET_IF_HDLC_H_ 1
26
27 #define IDX_LCP 0 /* idx into state table */
28
29 struct slcp {
30 u_long opts; /* LCP options to send (bitfield) */
31 u_long magic; /* local magic number */
32 u_long mru; /* our max receive unit */
33 u_long their_mru; /* their max receive unit */
34 u_long protos; /* bitmask of protos that are started */
35 u_char echoid; /* id of last keepalive echo request */
36 /* restart max values, see RFC 1661 */
37 int timeout;
38 int max_terminate;
39 int max_configure;
40 int max_failure;
41 };
42
43 #define IDX_IPCP 1 /* idx into state table */
44
45 struct sipcp {
46 u_long opts; /* IPCP options to send (bitfield) */
47 u_int flags;
48 #define IPCP_HISADDR_SEEN 1 /* have seen his address already */
49 #define IPCP_MYADDR_DYN 2 /* my address is dynamically assigned */
50 #define IPCP_MYADDR_SEEN 4 /* have seen his address already */
51 };
52
53 #define AUTHNAMELEN 32
54 #define AUTHKEYLEN 16
55
56 struct sauth {
57 u_short proto; /* authentication protocol to use */
58 u_short flags;
59 #define AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */
60 /* callouts */
61 #define AUTHFLAG_NORECHALLENGE 2 /* do not re-challenge CHAP */
62 u_char name[AUTHNAMELEN]; /* system identification name */
63 u_char secret[AUTHKEYLEN]; /* secret password */
64 u_char challenge[AUTHKEYLEN]; /* random challenge */
65 };
66
67 #define IDX_PAP 2
68 #define IDX_CHAP 3
69
70 #define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */
71
72 /*
73 * Don't change the order of this. Ordering the phases this way allows
74 * for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to
75 * know whether LCP is up.
76 */
77 enum ppp_phase {
78 PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE,
79 PHASE_AUTHENTICATE, PHASE_NETWORK
80 };
81
82 struct sppp {
83 /* NB: pp_if _must_ be first */
84 struct ifnet pp_if; /* network interface data */
85 struct ifqueue pp_fastq; /* fast output queue */
86 struct ifqueue pp_cpq; /* PPP control protocol queue */
87 struct sppp *pp_next; /* next interface in keepalive list */
88 u_int pp_flags; /* use Cisco protocol instead of PPP */
89 u_short pp_alivecnt; /* keepalive packets counter */
90 u_short pp_loopcnt; /* loopback detection counter */
91 u_long pp_seq; /* local sequence number */
92 u_long pp_rseq; /* remote sequence number */
93 enum ppp_phase pp_phase; /* phase we're currently in */
94 int state[IDX_COUNT]; /* state machine */
95 u_char confid[IDX_COUNT]; /* id of last configuration request */
96 int rst_counter[IDX_COUNT]; /* restart counter */
97 int fail_counter[IDX_COUNT]; /* negotiation failure counter */
98 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
99 struct callout_handle ch[IDX_COUNT]; /* per-proto and if callouts */
100 struct callout_handle pap_my_to_ch; /* PAP needs one more... */
101 #endif
102 struct slcp lcp; /* LCP params */
103 struct sipcp ipcp; /* IPCP params */
104 struct sauth myauth; /* auth params, i'm peer */
105 struct sauth hisauth; /* auth params, i'm authenticator */
106 /*
107 * These functions are filled in by sppp_attach(), and are
108 * expected to be used by the lower layer (hardware) drivers
109 * in order to communicate the (un)availability of the
110 * communication link. Lower layer drivers that are always
111 * ready to communicate (like hardware HDLC) can shortcut
112 * pp_up from pp_tls, and pp_down from pp_tlf.
113 */
114 void (*pp_up)(struct sppp *sp);
115 void (*pp_down)(struct sppp *sp);
116 /*
117 * These functions need to be filled in by the lower layer
118 * (hardware) drivers if they request notification from the
119 * PPP layer whether the link is actually required. They
120 * correspond to the tls and tlf actions.
121 */
122 void (*pp_tls)(struct sppp *sp);
123 void (*pp_tlf)(struct sppp *sp);
124 /*
125 * These (optional) functions may be filled by the hardware
126 * driver if any notification of established connections
127 * (currently: IPCP up) is desired (pp_con) or any internal
128 * state change of the interface state machine should be
129 * signaled for monitoring purposes (pp_chg).
130 */
131 void (*pp_con)(struct sppp *sp);
132 void (*pp_chg)(struct sppp *sp, int new_state);
133 };
134
135 #define PP_KEEPALIVE 0x01 /* use keepalive protocol */
136 #define PP_CISCO 0x02 /* use Cisco protocol instead of PPP */
137 /* 0x04 was PP_TIMO */
138 #define PP_CALLIN 0x08 /* we are being called */
139 #define PP_NEEDAUTH 0x10 /* remote requested authentication */
140
141
142 #define PP_MTU 1500 /* default/minimal MRU */
143 #define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */
144
145 /*
146 * Definitions to pass struct sppp data down into the kernel using the
147 * SIOC[SG]IFGENERIC ioctl interface.
148 *
149 * In order to use this, create a struct spppreq, fill in the cmd
150 * field with SPPPIOGDEFS, and put the address of this structure into
151 * the ifr_data portion of a struct ifreq. Pass this struct to a
152 * SIOCGIFGENERIC ioctl. Then replace the cmd field by SPPPIOCDEFS,
153 * modify the defs field as desired, and pass the struct ifreq now
154 * to a SIOCSIFGENERIC ioctl.
155 */
156
157 #define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp)))
158 #define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp)))
159
160 struct spppreq {
161 int cmd;
162 struct sppp defs;
163 };
164
165 #if (defined(__FreeBSD_version) && __FreeBSD_version < 300000) || \
166 (defined(__FreeBSD__) && __FreeBSD__ < 3) || \
167 defined(__NetBSD__) || defined (__OpenBSD__)
168 #define SIOCSIFGENERIC _IOW('i', 57, struct ifreq) /* generic IF set op */
169 #define SIOCGIFGENERIC _IOWR('i', 58, struct ifreq) /* generic IF get op */
170 #endif
171
172 #if defined(KERNEL) || defined(_KERNEL)
173 void sppp_attach (struct ifnet *ifp);
174 void sppp_detach (struct ifnet *ifp);
175 void sppp_input (struct ifnet *ifp, struct mbuf *m);
176 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300003
177 int sppp_ioctl(struct ifnet *ifp, u_long cmd, void *data);
178 #else
179 int sppp_ioctl(struct ifnet *ifp, int cmd, void *data);
180 #endif
181 struct mbuf *sppp_dequeue (struct ifnet *ifp);
182 struct mbuf *sppp_pick(struct ifnet *ifp);
183 int sppp_isempty (struct ifnet *ifp);
184 void sppp_flush (struct ifnet *ifp);
185 #endif
186
187 #endif /* _NET_IF_HDLC_H_ */
188