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