Annotation of sys/net/if_sppp.h, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: if_sppp.h,v 1.11 2007/04/17 21:36:58 mpf Exp $ */
2: /* $NetBSD: if_sppp.h,v 1.2.2.1 1999/04/04 06:57:39 explorer Exp $ */
3:
4: /*
5: * Defines for synchronous PPP/Cisco link level subroutines.
6: *
7: * Copyright (C) 1994 Cronyx Ltd.
8: * Author: Serge Vakulenko, <vak@cronyx.ru>
9: *
10: * Heavily revamped to conform to RFC 1661.
11: * Copyright (C) 1997, Joerg Wunsch.
12: *
13: * Redistribution and use in source and binary forms, with or without
14: * modification, are permitted provided that the following conditions are met:
15: * 1. Redistributions of source code must retain the above copyright notice,
16: * this list of conditions and the following disclaimer.
17: * 2. Redistributions in binary form must reproduce the above copyright notice,
18: * this list of conditions and the following disclaimer in the documentation
19: * and/or other materials provided with the distribution.
20: *
21: * THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT ``AS IS'' AND ANY
22: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24: * ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE
25: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31: * POSSIBILITY OF SUCH DAMAGE.
32: *
33: * From: Version 2.0, Fri Oct 6 20:39:21 MSK 1995
34: *
35: * From: if_sppp.h,v 1.8 1997/10/11 11:25:20 joerg Exp
36: *
37: * From: Id: if_sppp.h,v 1.7 1998/12/01 20:20:19 hm Exp
38: */
39:
40: #ifndef _NET_IF_SPPP_H_
41: #define _NET_IF_SPPP_H_
42:
43: #include <sys/timeout.h>
44:
45: #define IDX_LCP 0 /* idx into state table */
46:
47: struct 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:
63: struct 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: #define IPCP_HISADDR_DYN 8 /* his address is dynamically assigned */
70: u_int32_t saved_hisaddr; /* if hisaddr (IPv4) is dynamic, save
71: * original one here, in network byte order */
72: u_int32_t req_hisaddr; /* remote address requested */
73: u_int32_t req_myaddr; /* local address requested */
74: };
75:
76: #define AUTHNAMELEN 64
77: #define AUTHKEYLEN 16
78:
79: struct 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: */
100: enum ppp_phase {
101: PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE,
102: PHASE_AUTHENTICATE, PHASE_NETWORK
103: };
104:
105: struct sppp {
106: /* NB: pp_if _must_ be first */
107: struct ifnet pp_if; /* network interface data */
108: struct ifqueue pp_fastq; /* fast output queue */
109: struct ifqueue pp_cpq; /* PPP control protocol queue */
110: struct sppp *pp_next; /* next interface in keepalive list */
111: u_int pp_flags; /* use Cisco protocol instead of PPP */
112: u_int pp_framebytes; /* number of bytes added by hardware framing */
113: u_short pp_alivecnt; /* keepalive packets counter */
114: u_short pp_loopcnt; /* loopback detection counter */
115: u_int32_t pp_seq; /* local sequence number */
116: u_int32_t pp_rseq; /* remote sequence number */
117: time_t pp_last_receive; /* peer's last "sign of life" */
118: time_t pp_last_activity; /* second of last payload data s/r */
119: enum ppp_phase pp_phase; /* phase we're currently in */
120: int state[IDX_COUNT]; /* state machine */
121: u_char confid[IDX_COUNT]; /* id of last configuration request */
122: int rst_counter[IDX_COUNT]; /* restart counter */
123: int fail_counter[IDX_COUNT]; /* negotiation failure counter */
124: struct timeout ch[IDX_COUNT];
125: struct timeout pap_my_to_ch;
126: struct slcp lcp; /* LCP params */
127: struct sipcp ipcp; /* IPCP params */
128: struct sauth myauth; /* auth params, i'm peer */
129: struct sauth hisauth; /* auth params, i'm authenticator */
130: /*
131: * These functions are filled in by sppp_attach(), and are
132: * expected to be used by the lower layer (hardware) drivers
133: * in order to communicate the (un)availability of the
134: * communication link. Lower layer drivers that are always
135: * ready to communicate (like hardware HDLC) can shortcut
136: * pp_up from pp_tls, and pp_down from pp_tlf.
137: */
138: void (*pp_up)(struct sppp *sp);
139: void (*pp_down)(struct sppp *sp);
140: /*
141: * These functions need to be filled in by the lower layer
142: * (hardware) drivers if they request notification from the
143: * PPP layer whether the link is actually required. They
144: * correspond to the tls and tlf actions.
145: */
146: void (*pp_tls)(struct sppp *sp);
147: void (*pp_tlf)(struct sppp *sp);
148: /*
149: * These (optional) functions may be filled by the hardware
150: * driver if any notification of established connections
151: * (currently: IPCP up) is desired (pp_con) or any internal
152: * state change of the interface state machine should be
153: * signaled for monitoring purposes (pp_chg).
154: */
155: void (*pp_con)(struct sppp *sp);
156: void (*pp_chg)(struct sppp *sp, int new_state);
157: };
158:
159: #define PP_KEEPALIVE 0x01 /* use keepalive protocol */
160: #define PP_CISCO 0x02 /* use Cisco protocol instead of PPP */
161: /* 0x04 was PP_TIMO */
162: #define PP_CALLIN 0x08 /* we are being called */
163: #define PP_NEEDAUTH 0x10 /* remote requested authentication */
164: #define PP_NOFRAMING 0x20 /* do not add/expect encapsulation
165: around PPP frames (i.e. the serial
166: HDLC like encapsulation, RFC1662) */
167:
168: #define PP_MTU 1500 /* default/minimal MRU */
169: #define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */
170:
171: /*
172: * Definitions to pass struct sppp data down into the kernel using the
173: * SIOC[SG]IFGENERIC ioctl interface.
174: *
175: * In order to use this, create a struct spppreq, fill in the cmd
176: * field with SPPPIOGDEFS, and put the address of this structure into
177: * the ifr_data portion of a struct ifreq. Pass this struct to a
178: * SIOCGIFGENERIC ioctl. Then replace the cmd field by SPPPIOCDEFS,
179: * modify the defs field as desired, and pass the struct ifreq now
180: * to a SIOCSIFGENERIC ioctl.
181: */
182:
183: #define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp)))
184: #define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp)))
185:
186: struct spppreq {
187: int cmd;
188: struct sppp defs;
189: };
190:
191: #if defined(_KERNEL)
192: void sppp_attach (struct ifnet *ifp);
193: void sppp_detach (struct ifnet *ifp);
194: void sppp_input (struct ifnet *ifp, struct mbuf *m);
195:
196: /* Workaround */
197: void spppattach (struct ifnet *ifp);
198: int sppp_ioctl(struct ifnet *ifp, u_long cmd, void *data);
199:
200: struct mbuf *sppp_dequeue (struct ifnet *ifp);
201: struct mbuf *sppp_pick(struct ifnet *ifp);
202: int sppp_isempty (struct ifnet *ifp);
203: void sppp_flush (struct ifnet *ifp);
204: #endif
205: #endif /* _NET_IF_SPPP_H_ */
CVSweb