if_sppp.h revision 1.34 1 /* $NetBSD: if_sppp.h,v 1.34 2021/05/11 01:27:45 yamaguchi Exp $ */
2
3 /*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Martin Husemann <martin (at) NetBSD.org>.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef _NET_IF_SPPP_H_
33 #define _NET_IF_SPPP_H_
34
35 /* ioctls used by the if_spppsubr.c driver */
36
37 #include <sys/ioccom.h>
38
39
40 #define SPPP_AUTHPROTO_NONE 0
41 #define SPPP_AUTHPROTO_PAP 1
42 #define SPPP_AUTHPROTO_CHAP 2
43
44 #define SPPP_AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */
45 /* callouts */
46 #define SPPP_AUTHFLAG_NORECHALLENGE 2 /* do not re-challenge CHAP */
47 #define SPPP_AUTHFLAG_PASSIVEAUTHPROTO 4 /* use authproto proposed by peer */
48
49 struct spppauthcfg {
50 char ifname[IFNAMSIZ]; /* pppoe interface name */
51 u_int hisauth; /* one of SPPP_AUTHPROTO_* above */
52 u_int myauth; /* one of SPPP_AUTHPROTO_* above */
53 u_int myname_length; /* includes terminating 0 */
54 u_int mysecret_length; /* includes terminating 0 */
55 u_int hisname_length; /* includes terminating 0 */
56 u_int hissecret_length; /* includes terminating 0 */
57 u_int myauthflags;
58 u_int hisauthflags;
59 char *myname;
60 char *mysecret;
61 char *hisname;
62 char *hissecret;
63 };
64
65 #define SPPPGETAUTHCFG _IOWR('i', 120, struct spppauthcfg)
66 #define SPPPSETAUTHCFG _IOW('i', 121, struct spppauthcfg)
67
68 struct sppplcpcfg {
69 char ifname[IFNAMSIZ]; /* pppoe interface name */
70 int lcp_timeout; /* LCP timeout, in ticks */
71 };
72
73 #define SPPPGETLCPCFG _IOWR('i', 122, struct sppplcpcfg)
74 #define SPPPSETLCPCFG _IOW('i', 123, struct sppplcpcfg)
75
76 /*
77 * Don't change the order of this. Ordering the phases this way allows
78 * for a comparison of ``pp_phase >= PHASE_AUTHENTICATE'' in order to
79 * know whether LCP is up.
80 */
81 #define SPPP_PHASE_DEAD 0
82 #define SPPP_PHASE_ESTABLISH 1
83 #define SPPP_PHASE_TERMINATE 2
84 #define SPPP_PHASE_AUTHENTICATE 3
85 #define SPPP_PHASE_NETWORK 4
86
87 struct spppstatus {
88 char ifname[IFNAMSIZ]; /* pppoe interface name */
89 int phase; /* one of SPPP_PHASE_* above */
90 };
91
92 #define SPPPGETSTATUS _IOWR('i', 124, struct spppstatus)
93
94 struct spppstatusncp {
95 char ifname[IFNAMSIZ]; /* pppoe interface name */
96 int phase; /* one of SPPP_PHASE_* above */
97 int ncpup; /* != 0 if at least on NCP is up */
98 };
99
100 #define SPPPGETSTATUSNCP _IOWR('i', 134, struct spppstatusncp)
101
102 struct spppidletimeout {
103 char ifname[IFNAMSIZ]; /* pppoe interface name */
104 time_t idle_seconds; /* number of seconds idle before
105 * disconnect, 0 to disable idle-timeout */
106 };
107
108 struct spppidletimeout50 {
109 char ifname[IFNAMSIZ]; /* pppoe interface name */
110 uint32_t idle_seconds; /* number of seconds idle before
111 * disconnect, 0 to disable idle-timeout */
112 };
113
114 #define SPPPGETIDLETO _IOWR('i', 125, struct spppidletimeout)
115 #define SPPPSETIDLETO _IOW('i', 126, struct spppidletimeout)
116 #define __SPPPGETIDLETO50 _IOWR('i', 125, struct spppidletimeout50)
117 #define __SPPPSETIDLETO50 _IOW('i', 126, struct spppidletimeout50)
118
119 struct spppauthfailurestats {
120 char ifname[IFNAMSIZ]; /* pppoe interface name */
121 int auth_failures; /* number of LCP failures since last successful TLU */
122 int max_failures; /* max. allowed authorization failures */
123 };
124
125 #define SPPPGETAUTHFAILURES _IOWR('i', 127, struct spppauthfailurestats)
126
127 struct spppauthfailuresettings {
128 char ifname[IFNAMSIZ]; /* pppoe interface name */
129 int max_failures; /* max. allowed authorization failures */
130 };
131 #define SPPPSETAUTHFAILURE _IOW('i', 128, struct spppauthfailuresettings)
132
133 /* set the DNS options we would like to query during PPP negotiation */
134 struct spppdnssettings {
135 char ifname[IFNAMSIZ]; /* pppoe interface name */
136 int query_dns; /* bitmask (bits 0 and 1) for DNS options to query in IPCP */
137 };
138 #define SPPPSETDNSOPTS _IOW('i', 129, struct spppdnssettings)
139 #define SPPPGETDNSOPTS _IOWR('i', 130, struct spppdnssettings)
140
141 /* get the DNS addresses we received from the peer */
142 struct spppdnsaddrs {
143 char ifname[IFNAMSIZ]; /* pppoe interface name */
144 uint32_t dns[2]; /* IP addresses */
145 };
146
147 #define SPPPGETDNSADDRS _IOWR('i', 131, struct spppdnsaddrs)
148
149 /* set LCP keepalive/timeout options */
150 struct spppkeepalivesettings {
151 char ifname[IFNAMSIZ]; /* pppoe interface name */
152 u_int maxalive; /* number of LCP echo req. w/o reply */
153 time_t max_noreceive; /* (sec.) grace period before we start
154 sending LCP echo requests. */
155 };
156 struct spppkeepalivesettings50 {
157 char ifname[IFNAMSIZ]; /* pppoe interface name */
158 u_int maxalive; /* number of LCP echo req. w/o reply */
159 uint32_t max_noreceive; /* (sec.) grace period before we start
160 sending LCP echo requests. */
161 };
162 #define SPPPSETKEEPALIVE _IOW('i', 132, struct spppkeepalivesettings)
163 #define SPPPGETKEEPALIVE _IOWR('i', 133, struct spppkeepalivesettings)
164 #define __SPPPSETKEEPALIVE50 _IOW('i', 132, struct spppkeepalivesettings50)
165 #define __SPPPGETKEEPALIVE50 _IOWR('i', 133, struct spppkeepalivesettings50)
166
167 /* 134 already used! */
168
169 /* states are named and numbered according to RFC 1661 */
170 #define SPPP_STATE_INITIAL 0
171 #define SPPP_STATE_STARTING 1
172 #define SPPP_STATE_CLOSED 2
173 #define SPPP_STATE_STOPPED 3
174 #define SPPP_STATE_CLOSING 4
175 #define SPPP_STATE_STOPPING 5
176 #define SPPP_STATE_REQ_SENT 6
177 #define SPPP_STATE_ACK_RCVD 7
178 #define SPPP_STATE_ACK_SENT 8
179 #define SPPP_STATE_OPENED 9
180
181 #define SPPP_LCP_OPT_MRU __BIT(1)
182 #define SPPP_LCP_OPT_ASYNC_MAP __BIT(2)
183 #define SPPP_LCP_OPT_AUTH_PROTO __BIT(3)
184 #define SPPP_LCP_OPT_QUAL_PROTO __BIT(4)
185 #define SPPP_LCP_OPT_MAGIC __BIT(5)
186 #define SPPP_LCP_OPT_RESERVED __BIT(6)
187 #define SPPP_LCP_OPT_PROTO_COMP __BIT(7)
188 #define SPPP_LCP_OPT_ADDR_COMP __BIT(8)
189 #define SPPP_LCP_OPT_FCS_ALTS __BIT(9)
190 #define SPPP_LCP_OPT_SELF_DESC_PAD __BIT(10)
191 #define SPPP_LCP_OPT_CALL_BACK __BIT(13)
192 #define SPPP_LCP_OPT_COMPOUND_FRMS __BIT(15)
193 #define SPPP_LCP_OPT_MP_MRRU __BIT(17)
194 #define SPPP_LCP_OPT_MP_SSNHF __BIT(18)
195 #define SPPP_LCP_OPT_MP_EID __BIT(19)
196
197 /* #define SPPP_OPT_ADDRESSES __BIT(0) */
198 #define SPPP_IPCP_OPT_COMPRESSION __BIT(1)
199 #define SPPP_IPCP_OPT_ADDRESS __BIT(2)
200 #define SPPP_IPCP_OPT_PRIMDNS __BIT(3)
201 #define SPPP_IPCP_OPT_SECDNS __BIT(4)
202
203 #define SPPP_IPV6CP_OPT_IFID __BIT(1)
204 #define SPPP_IPV6CP_OPT_COMPRESSION __BIT(2)
205
206 struct sppplcpstatus {
207 char ifname[IFNAMSIZ];
208 int state;
209 int timeout;
210 u_long opts;
211 u_long magic;
212 u_long mru;
213 };
214
215 #define SPPPGETLCPSTATUS _IOWR('i', 135, struct sppplcpstatus)
216
217 struct spppipcpstatus {
218 char ifname[IFNAMSIZ];
219 int state;
220 u_long opts;
221 u_int32_t myaddr;
222 };
223
224 #define SPPPGETIPCPSTATUS _IOWR('i', 136, struct spppipcpstatus)
225
226 struct spppipv6cpstatus {
227 char ifname[IFNAMSIZ];
228 int state;
229 u_long opts;
230 u_int8_t my_ifid[8];
231 u_int8_t his_ifid[8];
232 };
233
234 #define SPPPGETIPV6CPSTATUS _IOWR('i', 137, struct spppipv6cpstatus)
235
236 #define SPPP_NCP_IPCP __BIT(0)
237 #define SPPP_NCP_IPV6CP __BIT(1)
238 struct spppncpcfg {
239 char ifname[IFNAMSIZ];
240 u_int ncp_flags;
241 };
242
243 #define SPPPGETNCPCFG _IOWR('i', 138, struct spppncpcfg)
244 #define SPPPSETNCPCFG _IOW('i', 139, struct spppncpcfg)
245
246 #endif /* !_NET_IF_SPPP_H_ */
247
248