2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 * Defines for synchronous PPP/Cisco link level subroutines.
25 * Copyright (C) 1994 Cronyx Ltd.
26 * Author: Serge Vakulenko, <vak@cronyx.ru>
28 * Heavily revamped to conform to RFC 1661.
29 * Copyright (C) 1997, Joerg Wunsch.
31 * This software is distributed with NO WARRANTIES, not even the implied
32 * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
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.
38 * From: Version 2.0, Fri Oct 6 20:39:21 MSK 1995
42 #ifndef _NET_IF_SPPP_H_
43 #define _NET_IF_SPPP_H_ 1
44 #include <sys/appleapiopts.h>
46 #ifndef DONT_WARN_OBSOLETE
47 #warning if_sppp.h is not used by the darwin kernel
50 #define IDX_LCP 0 /* idx into state table */
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 */
66 #define IDX_IPCP 1 /* idx into state table */
69 u_long opts
; /* IPCP options to send (bitfield) */
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 */
76 #define AUTHNAMELEN 32
80 u_short proto
; /* authentication protocol to use */
82 #define AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */
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 */
93 #define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */
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.
101 PHASE_DEAD
, PHASE_ESTABLISH
, PHASE_TERMINATE
,
102 PHASE_AUTHENTICATE
, PHASE_NETWORK
105 #ifdef __APPLE_API_PRIVATE
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 */
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.
136 void (*pp_up
)(struct sppp
*sp
);
137 void (*pp_down
)(struct sppp
*sp
);
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.
144 void (*pp_tls
)(struct sppp
*sp
);
145 void (*pp_tlf
)(struct sppp
*sp
);
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).
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 */
160 #endif /* __APPLE_API_PRIVATE */
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 */
169 #define PP_MTU 1500 /* default/minimal MRU */
170 #define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */
173 * Definitions to pass struct sppp data down into the kernel using the
174 * SIOC[SG]IFGENERIC ioctl interface.
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.
184 #define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp)))
185 #define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp)))
193 #ifdef __APPLE_API_PRIVATE
194 void sppp_attach (struct ifnet
*ifp
);
195 void sppp_detach (struct ifnet
*ifp
);
196 void sppp_input (struct ifnet
*ifp
, struct mbuf
*m
);
197 int sppp_ioctl (struct ifnet
*ifp
, u_long cmd
, void *data
);
198 struct mbuf
*sppp_dequeue (struct ifnet
*ifp
);
199 struct mbuf
*sppp_pick(struct ifnet
*ifp
);
200 int sppp_isempty (struct ifnet
*ifp
);
201 void sppp_flush (struct ifnet
*ifp
);
202 #endif /* __APPLE_API_PRIVATE */
205 #endif /* _NET_IF_SPPP_H_ */