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