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
45 #define IDX_LCP 0 /* idx into state table */
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 */
61 #define IDX_IPCP 1 /* idx into state table */
64 u_long opts
; /* IPCP options to send (bitfield) */
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 */
71 #define AUTHNAMELEN 32
75 u_short proto
; /* authentication protocol to use */
77 #define AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */
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 */
88 #define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */
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.
96 PHASE_DEAD
, PHASE_ESTABLISH
, PHASE_TERMINATE
,
97 PHASE_AUTHENTICATE
, PHASE_NETWORK
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 */
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.
130 void (*pp_up
)(struct sppp
*sp
);
131 void (*pp_down
)(struct sppp
*sp
);
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.
138 void (*pp_tls
)(struct sppp
*sp
);
139 void (*pp_tlf
)(struct sppp
*sp
);
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).
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 */
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 */
161 #define PP_MTU 1500 /* default/minimal MRU */
162 #define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */
165 * Definitions to pass struct sppp data down into the kernel using the
166 * SIOC[SG]IFGENERIC ioctl interface.
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.
176 #define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp)))
177 #define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp)))
185 void sppp_attach (struct ifnet
*ifp
);
186 void sppp_detach (struct ifnet
*ifp
);
187 void sppp_input (struct ifnet
*ifp
, struct mbuf
*m
);
188 int sppp_ioctl (struct ifnet
*ifp
, u_long cmd
, void *data
);
189 struct mbuf
*sppp_dequeue (struct ifnet
*ifp
);
190 struct mbuf
*sppp_pick(struct ifnet
*ifp
);
191 int sppp_isempty (struct ifnet
*ifp
);
192 void sppp_flush (struct ifnet
*ifp
);
195 #endif /* _NET_IF_SPPP_H_ */