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