FreeBSD/Linux Kernel Cross Reference
sys/net/if_sppp.h
1 /* $OpenBSD: if_sppp.h,v 1.30 2021/11/17 18:00:24 bket Exp $ */
2 /* $NetBSD: if_sppp.h,v 1.2.2.1 1999/04/04 06:57:39 explorer Exp $ */
3
4 /*
5 * Defines for synchronous PPP link level subroutines.
6 *
7 * Copyright (C) 1994 Cronyx Ltd.
8 * Author: Serge Vakulenko, <vak@cronyx.ru>
9 *
10 * Heavily revamped to conform to RFC 1661.
11 * Copyright (C) 1997, Joerg Wunsch.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT ``AS IS'' AND ANY
22 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 *
33 * From: Version 2.0, Fri Oct 6 20:39:21 MSK 1995
34 *
35 * From: if_sppp.h,v 1.8 1997/10/11 11:25:20 joerg Exp
36 *
37 * From: Id: if_sppp.h,v 1.7 1998/12/01 20:20:19 hm Exp
38 */
39
40 #ifndef _NET_IF_SPPP_H_
41 #define _NET_IF_SPPP_H_
42
43 #define AUTHFLAG_NOCALLOUT 1 /* don't require authentication on callouts */
44 #define AUTHFLAG_NORECHALLENGE 2 /* don't re-challenge CHAP */
45
46 /*
47 * Don't change the order of this. Ordering the phases this way allows
48 * for a comparison of ``pp_phase >= PHASE_AUTHENTICATE'' in order to
49 * know whether LCP is up.
50 */
51 enum ppp_phase {
52 PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE,
53 PHASE_AUTHENTICATE, PHASE_NETWORK
54 };
55
56
57 #define AUTHMAXLEN 256 /* including terminating '\0' */
58 #define AUTHCHALEN 16 /* length of the challenge we send */
59
60 /*
61 * Definitions to pass struct sppp data down into the kernel using the
62 * SIOC[SG]IFGENERIC ioctl interface.
63 *
64 * In order to use this, create a struct spppreq, fill in the cmd
65 * field with SPPPIOGDEFS, and put the address of this structure into
66 * the ifr_data portion of a struct ifreq. Pass this struct to a
67 * SIOCGIFGENERIC ioctl. Then replace the cmd field by SPPPIOSDEFS,
68 * modify the defs field as desired, and pass the struct ifreq now
69 * to a SIOCSIFGENERIC ioctl.
70 */
71
72 struct sauthreq {
73 int cmd;
74 u_short proto; /* authentication protocol to use */
75 u_short flags;
76 u_char name[AUTHMAXLEN]; /* system identification name */
77 u_char secret[AUTHMAXLEN]; /* secret password */
78 };
79
80 struct spppreq {
81 int cmd;
82 enum ppp_phase phase; /* phase we're currently in */
83 };
84
85 #include <netinet/in.h>
86
87 #define IPCP_MAX_DNSSRV 2
88 struct sdnsreq {
89 int cmd;
90 struct in_addr dns[IPCP_MAX_DNSSRV];
91 };
92
93 #define SPPPIOGDEFS ((int)(('S' << 24) + (1 << 16) + sizeof(struct spppreq)))
94 #define SPPPIOSDEFS ((int)(('S' << 24) + (2 << 16) + sizeof(struct spppreq)))
95 #define SPPPIOGMAUTH ((int)(('S' << 24) + (3 << 16) + sizeof(struct sauthreq)))
96 #define SPPPIOSMAUTH ((int)(('S' << 24) + (4 << 16) + sizeof(struct sauthreq)))
97 #define SPPPIOGHAUTH ((int)(('S' << 24) + (5 << 16) + sizeof(struct sauthreq)))
98 #define SPPPIOSHAUTH ((int)(('S' << 24) + (6 << 16) + sizeof(struct sauthreq)))
99 #define SPPPIOGDNS ((int)(('S' << 24) + (7 << 16) + sizeof(struct sdnsreq)))
100
101
102 #ifdef _KERNEL
103
104 #include <sys/timeout.h>
105 #include <sys/task.h>
106
107 #ifdef INET6
108 #include <netinet6/in6_var.h>
109 #endif
110
111 #define IDX_LCP 0 /* idx into state table */
112
113 struct slcp {
114 u_long opts; /* LCP options to send (bitfield) */
115 u_long magic; /* local magic number */
116 u_long mru; /* our max receive unit */
117 u_long their_mru; /* their max receive unit */
118 u_long protos; /* bitmask of protos that are started */
119 u_char echoid; /* id of last keepalive echo request */
120 /* restart max values, see RFC 1661 */
121 int timeout; /* seconds */
122 int max_terminate;
123 int max_configure;
124 int max_failure;
125 };
126
127 #define IDX_IPCP 1 /* idx into state table */
128 #define IDX_IPV6CP 2
129
130 struct sipcp {
131 u_long opts; /* IPCP options to send (bitfield) */
132 u_int flags;
133 #define IPCP_HISADDR_SEEN 1 /* have seen his address already */
134 #define IPCP_MYADDR_DYN 2 /* my address is dynamically assigned */
135 #define IPCP_MYADDR_SEEN 4 /* have seen my address already */
136 #define IPCP_HISADDR_DYN 8 /* his address is dynamically assigned */
137 #define IPV6CP_MYIFID_DYN 1 /* my ifid is dynamically assigned */
138 #define IPV6CP_MYIFID_SEEN 2 /* have seen my suggested ifid */
139 u_int32_t saved_hisaddr; /* if hisaddr (IPv4) is dynamic, save
140 * original one here, in network byte order */
141 u_int32_t req_hisaddr; /* remote address requested (IPv4) */
142 u_int32_t req_myaddr; /* local address requested (IPv4) */
143 struct in_addr dns[IPCP_MAX_DNSSRV]; /* IPv4 DNS servers (RFC 1877) */
144 #ifdef INET6
145 struct in6_aliasreq req_ifid; /* local ifid requested (IPv6) */
146 #endif
147 struct task set_addr_task; /* set address from process context */
148 struct task clear_addr_task; /* clear address from process context */
149 };
150
151 struct sauth {
152 u_short proto; /* authentication protocol to use */
153 u_short flags;
154 u_char *name; /* system identification name */
155 u_char *secret; /* secret password */
156 };
157
158 #define IDX_PAP 3
159 #define IDX_CHAP 4
160
161 #define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */
162
163 struct sppp {
164 /* NB: pp_if _must_ be first */
165 struct ifnet pp_if; /* network interface data */
166 struct mbuf_queue pp_cpq; /* PPP control protocol queue */
167 struct sppp *pp_next; /* next interface in keepalive list */
168 u_int pp_flags;
169 u_int pp_framebytes; /* number of bytes added by hardware framing */
170 u_short pp_alivecnt; /* keepalive packets counter */
171 u_short pp_loopcnt; /* loopback detection counter */
172 u_int32_t pp_seq; /* local sequence number */
173 u_int32_t pp_rseq; /* remote sequence number */
174 time_t pp_last_receive; /* peer's last "sign of life" */
175 time_t pp_last_activity; /* second of last payload data s/r */
176 enum ppp_phase pp_phase; /* phase we're currently in */
177 int state[IDX_COUNT]; /* state machine */
178 u_char confid[IDX_COUNT]; /* id of last configuration request */
179 int rst_counter[IDX_COUNT]; /* restart counter */
180 int fail_counter[IDX_COUNT]; /* negotiation failure counter */
181 struct timeout ch[IDX_COUNT];
182 struct timeout pap_my_to_ch;
183 struct slcp lcp; /* LCP params */
184 struct sipcp ipcp; /* IPCP params */
185 struct sipcp ipv6cp; /* IPV6CP params */
186 struct sauth myauth; /* auth params, i'm peer */
187 struct sauth hisauth; /* auth params, i'm authenticator */
188 u_char chap_challenge[AUTHCHALEN]; /* random challenge used by CHAP */
189
190 /*
191 * These functions are filled in by sppp_attach(), and are
192 * expected to be used by the lower layer (hardware) drivers
193 * in order to communicate the (un)availability of the
194 * communication link. Lower layer drivers that are always
195 * ready to communicate (like hardware HDLC) can shortcut
196 * pp_up from pp_tls, and pp_down from pp_tlf.
197 */
198 void (*pp_up)(struct sppp *sp);
199 void (*pp_down)(struct sppp *sp);
200 /*
201 * These functions need to be filled in by the lower layer
202 * (hardware) drivers if they request notification from the
203 * PPP layer whether the link is actually required. They
204 * correspond to the tls and tlf actions.
205 */
206 void (*pp_tls)(struct sppp *sp);
207 void (*pp_tlf)(struct sppp *sp);
208 /*
209 * These (optional) functions may be filled by the hardware
210 * driver if any notification of established connections
211 * (currently: IPCP up) is desired (pp_con) or any internal
212 * state change of the interface state machine should be
213 * signaled for monitoring purposes (pp_chg).
214 */
215 void (*pp_con)(struct sppp *sp);
216 void (*pp_chg)(struct sppp *sp, int new_state);
217 };
218
219 #define PP_KEEPALIVE 0x01 /* use keepalive protocol */
220 /* 0x02 was PP_CISCO */
221 /* 0x04 was PP_TIMO */
222 #define PP_CALLIN 0x08 /* we are being called */
223 #define PP_NEEDAUTH 0x10 /* remote requested authentication */
224 #define PP_NOFRAMING 0x20 /* do not add/expect encapsulation
225 around PPP frames (i.e. the serial
226 HDLC like encapsulation, RFC1662) */
227
228 #define PP_MIN_MRU IP_MSS /* minimal MRU */
229 #define PP_MTU 1500 /* default MTU */
230 #define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */
231
232 void sppp_attach (struct ifnet *ifp);
233 void sppp_detach (struct ifnet *ifp);
234 void sppp_input (struct ifnet *ifp, struct mbuf *m);
235
236 /* Workaround */
237 void spppattach (struct ifnet *ifp);
238 int sppp_ioctl(struct ifnet *ifp, u_long cmd, void *data);
239
240 struct mbuf *sppp_dequeue (struct ifnet *ifp);
241 int sppp_isempty (struct ifnet *ifp);
242 void sppp_flush (struct ifnet *ifp);
243 #endif /* _KERNEL */
244 #endif /* _NET_IF_SPPP_H_ */
Cache object: 92149022691587203d690d1501f15d29
|