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