]> git.saurik.com Git - apple/xnu.git/blame - bsd/net/if_sppp.h
xnu-344.23.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 *
de355530
A
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.
1c79356b 11 *
de355530
A
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
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
de355530
A
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.
1c79356b
A
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
9bccf70c
A
44#include <sys/appleapiopts.h>
45
46#ifndef DONT_WARN_OBSOLETE
47#warning if_sppp.h is not used by the darwin kernel
48#endif
1c79356b
A
49
50#define IDX_LCP 0 /* idx into state table */
51
52struct slcp {
53 u_long opts; /* LCP options to send (bitfield) */
54 u_long magic; /* local magic number */
55 u_long mru; /* our max receive unit */
56 u_long their_mru; /* their max receive unit */
57 u_long protos; /* bitmask of protos that are started */
58 u_char echoid; /* id of last keepalive echo request */
59 /* restart max values, see RFC 1661 */
60 int timeout;
61 int max_terminate;
62 int max_configure;
63 int max_failure;
64};
65
66#define IDX_IPCP 1 /* idx into state table */
67
68struct sipcp {
69 u_long opts; /* IPCP options to send (bitfield) */
70 u_int flags;
71#define IPCP_HISADDR_SEEN 1 /* have seen his address already */
72#define IPCP_MYADDR_DYN 2 /* my address is dynamically assigned */
73#define IPCP_MYADDR_SEEN 4 /* have seen his address already */
74};
75
76#define AUTHNAMELEN 32
77#define AUTHKEYLEN 16
78
79struct sauth {
80 u_short proto; /* authentication protocol to use */
81 u_short flags;
82#define AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */
83 /* callouts */
84#define AUTHFLAG_NORECHALLENGE 2 /* do not re-challenge CHAP */
85 u_char name[AUTHNAMELEN]; /* system identification name */
86 u_char secret[AUTHKEYLEN]; /* secret password */
87 u_char challenge[AUTHKEYLEN]; /* random challenge */
88};
89
90#define IDX_PAP 2
91#define IDX_CHAP 3
92
93#define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */
94
95/*
96 * Don't change the order of this. Ordering the phases this way allows
97 * for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to
98 * know whether LCP is up.
99 */
100enum ppp_phase {
101 PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE,
102 PHASE_AUTHENTICATE, PHASE_NETWORK
103};
104
9bccf70c 105#ifdef __APPLE_API_PRIVATE
1c79356b
A
106struct sppp {
107 /* NB: pp_if _must_ be first */
108 struct ifnet pp_if; /* network interface data */
109 struct ifqueue pp_fastq; /* fast output queue */
110 struct ifqueue pp_cpq; /* PPP control protocol queue */
111 struct sppp *pp_next; /* next interface in keepalive list */
112 u_int pp_flags; /* use Cisco protocol instead of PPP */
113 u_short pp_alivecnt; /* keepalive packets counter */
114 u_short pp_loopcnt; /* loopback detection counter */
115 u_long pp_seq; /* local sequence number */
116 u_long pp_rseq; /* remote sequence number */
117 enum ppp_phase pp_phase; /* phase we're currently in */
118 int state[IDX_COUNT]; /* state machine */
119 u_char confid[IDX_COUNT]; /* id of last configuration request */
120 int rst_counter[IDX_COUNT]; /* restart counter */
121 int fail_counter[IDX_COUNT]; /* negotiation failure counter */
122 struct callout_handle ch[IDX_COUNT]; /* per-proto and if callouts */
123 struct callout_handle pap_my_to_ch; /* PAP needs one more... */
124 struct slcp lcp; /* LCP params */
125 struct sipcp ipcp; /* IPCP params */
126 struct sauth myauth; /* auth params, i'm peer */
127 struct sauth hisauth; /* auth params, i'm authenticator */
128 /*
129 * These functions are filled in by sppp_attach(), and are
130 * expected to be used by the lower layer (hardware) drivers
131 * in order to communicate the (un)availability of the
132 * communication link. Lower layer drivers that are always
133 * ready to communicate (like hardware HDLC) can shortcut
134 * pp_up from pp_tls, and pp_down from pp_tlf.
135 */
136 void (*pp_up)(struct sppp *sp);
137 void (*pp_down)(struct sppp *sp);
138 /*
139 * These functions need to be filled in by the lower layer
140 * (hardware) drivers if they request notification from the
141 * PPP layer whether the link is actually required. They
142 * correspond to the tls and tlf actions.
143 */
144 void (*pp_tls)(struct sppp *sp);
145 void (*pp_tlf)(struct sppp *sp);
146 /*
147 * These (optional) functions may be filled by the hardware
148 * driver if any notification of established connections
149 * (currently: IPCP up) is desired (pp_con) or any internal
150 * state change of the interface state machine should be
151 * signaled for monitoring purposes (pp_chg).
152 */
153 void (*pp_con)(struct sppp *sp);
154 void (*pp_chg)(struct sppp *sp, int new_state);
155 /* These two fields are for use by the lower layer */
156 void *pp_lowerp;
157 int pp_loweri;
158};
159
9bccf70c
A
160#endif /* __APPLE_API_PRIVATE */
161
1c79356b
A
162#define PP_KEEPALIVE 0x01 /* use keepalive protocol */
163#define PP_CISCO 0x02 /* use Cisco protocol instead of PPP */
164 /* 0x04 was PP_TIMO */
165#define PP_CALLIN 0x08 /* we are being called */
166#define PP_NEEDAUTH 0x10 /* remote requested authentication */
167
168
169#define PP_MTU 1500 /* default/minimal MRU */
170#define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */
171
172/*
173 * Definitions to pass struct sppp data down into the kernel using the
174 * SIOC[SG]IFGENERIC ioctl interface.
175 *
176 * In order to use this, create a struct spppreq, fill in the cmd
177 * field with SPPPIOGDEFS, and put the address of this structure into
178 * the ifr_data portion of a struct ifreq. Pass this struct to a
179 * SIOCGIFGENERIC ioctl. Then replace the cmd field by SPPPIOCDEFS,
180 * modify the defs field as desired, and pass the struct ifreq now
181 * to a SIOCSIFGENERIC ioctl.
182 */
183
184#define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp)))
185#define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp)))
186
187struct spppreq {
188 int cmd;
189 struct sppp defs;
190};
191
192#ifdef KERNEL
9bccf70c 193#ifdef __APPLE_API_PRIVATE
1c79356b
A
194void sppp_attach (struct ifnet *ifp);
195void sppp_detach (struct ifnet *ifp);
196void sppp_input (struct ifnet *ifp, struct mbuf *m);
197int sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
198struct mbuf *sppp_dequeue (struct ifnet *ifp);
199struct mbuf *sppp_pick(struct ifnet *ifp);
200int sppp_isempty (struct ifnet *ifp);
201void sppp_flush (struct ifnet *ifp);
9bccf70c 202#endif /* __APPLE_API_PRIVATE */
1c79356b
A
203#endif
204
205#endif /* _NET_IF_SPPP_H_ */