1 /*	$NetBSD: if_pppvar.h,v 1.28 2016/04/28 00:16:56 ozaki-r Exp $	*/
2 /*	Id: if_pppvar.h,v 1.3 1996/07/01 01:04:37 paulus Exp	 */
3 
4 /*
5  * if_pppvar.h - private structures and declarations for PPP.
6  *
7  * Copyright (c) 1989-2002 Paul Mackerras. All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in
18  *    the documentation and/or other materials provided with the
19  *    distribution.
20  *
21  * 3. The name(s) of the authors of this software must not be used to
22  *    endorse or promote products derived from this software without
23  *    prior written permission.
24  *
25  * 4. Redistributions of any form whatsoever must retain the following
26  *    acknowledgment:
27  *    "This product includes software developed by Paul Mackerras
28  *     <paulus@samba.org>".
29  *
30  * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
31  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
32  * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
33  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
34  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
35  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
36  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
37  *
38  * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
39  *
40  * Redistribution and use in source and binary forms, with or without
41  * modification, are permitted provided that the following conditions
42  * are met:
43  *
44  * 1. Redistributions of source code must retain the above copyright
45  *    notice, this list of conditions and the following disclaimer.
46  *
47  * 2. Redistributions in binary form must reproduce the above copyright
48  *    notice, this list of conditions and the following disclaimer in
49  *    the documentation and/or other materials provided with the
50  *    distribution.
51  *
52  * 3. The name "Carnegie Mellon University" must not be used to
53  *    endorse or promote products derived from this software without
54  *    prior written permission. For permission or any legal
55  *    details, please contact
56  *      Office of Technology Transfer
57  *      Carnegie Mellon University
58  *      5000 Forbes Avenue
59  *      Pittsburgh, PA  15213-3890
60  *      (412) 268-4387, fax: (412) 268-7395
61  *      tech-transfer@andrew.cmu.edu
62  *
63  * 4. Redistributions of any form whatsoever must retain the following
64  *    acknowledgment:
65  *    "This product includes software developed by Computing Services
66  *     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
67  *
68  * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
69  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
70  * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
71  * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
72  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
73  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
74  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
75  */
76 
77 #ifndef _NET_IF_PPPVAR_H_
78 #define _NET_IF_PPPVAR_H_
79 
80 #include <sys/callout.h>
81 
82 /*
83  * Supported network protocols.  These values are used for
84  * indexing sc_npmode.
85  */
86 #define NP_IP	0		/* Internet Protocol */
87 #define NP_IPV6	1		/* Internet Protocol version 6 */
88 #define NUM_NP	2		/* Number of NPs. */
89 
90 /*
91  * Structure describing each ppp unit.
92  */
93 struct ppp_softc {
94 	struct	ifnet sc_if;		/* network-visible interface */
95 	int	sc_unit;		/* XXX unit number */
96 	u_int	sc_flags;		/* control/status bits; see if_ppp.h */
97 	void	*sc_devp;		/* pointer to device-dep structure */
98 	void	(*sc_start)(struct ppp_softc *);	/* start output proc */
99 	void	(*sc_ctlp)(struct ppp_softc *); /* rcvd control pkt */
100 	void	(*sc_relinq)(struct ppp_softc *); /* relinquish ifunit */
101 	struct	callout sc_timo_ch;	/* timeout callout */
102 	uint16_t sc_mru;		/* max receive unit */
103 	pid_t	sc_xfer;		/* used in transferring unit */
104 	struct	ifqueue sc_rawq;	/* received packets */
105 	struct	ifqueue sc_inq;		/* queue of input packets for daemon */
106 	struct	ifqueue sc_fastq;	/* interactive output packet q */
107 	struct	mbuf *sc_togo;		/* output packet ready to go */
108 	struct	mbuf *sc_npqueue;	/* output packets not to be sent yet */
109 	struct	mbuf **sc_npqtail;	/* ptr to last next ptr in npqueue */
110 	struct	pppstat sc_stats;	/* count of bytes/pkts sent/rcvd */
111 	enum	NPmode sc_npmode[NUM_NP]; /* what to do with each NP */
112 	struct	compressor *sc_xcomp;	/* transmit compressor */
113 	void	*sc_xc_state;		/* transmit compressor state */
114 	struct	compressor *sc_rcomp;	/* receive decompressor */
115 	void	*sc_rc_state;		/* receive decompressor state */
116 	time_t	sc_last_sent;		/* time (secs) last NP pkt sent */
117 	time_t	sc_last_recv;		/* time (secs) last NP pkt rcvd */
118 	void	*sc_si;			/* software interrupt handle */
119 #ifdef PPP_FILTER
120 	/* Filter for packets to pass. */
121 	struct	bpf_program sc_pass_filt_in;
122 	struct	bpf_program sc_pass_filt_out;
123 
124 	/* Filter for "non-idle" packets. */
125 	struct	bpf_program sc_active_filt_in;
126 	struct	bpf_program sc_active_filt_out;
127 #endif /* PPP_FILTER */
128 #ifdef	VJC
129 	struct	slcompress *sc_comp; 	/* vjc control buffer */
130 #endif
131 
132 	/* Device-dependent part for async lines. */
133 	ext_accm sc_asyncmap;		/* async control character map */
134 	uint32_t sc_rasyncmap;		/* receive async control char map */
135 	struct	mbuf *sc_outm;		/* mbuf chain currently being output */
136 	struct	mbuf *sc_m;		/* pointer to input mbuf chain */
137 	struct	mbuf *sc_mc;		/* pointer to current input mbuf */
138 	char	*sc_mp;			/* ptr to next char in input mbuf */
139 	uint16_t sc_ilen;		/* length of input packet so far */
140 	uint16_t sc_fcs;		/* FCS so far (input) */
141 	uint16_t sc_outfcs;		/* FCS so far for output packet */
142 	uint16_t sc_maxfastq;		/* Maximum number of packets that
143 					 * can be received back-to-back in
144 					 * the high priority queue */
145 	uint8_t sc_nfastq;		/* Number of packets received
146 					 * back-to-back in the high priority
147 					 * queue */
148 	u_char sc_rawin_start;		/* current char start */
149 	struct ppp_rawin sc_rawin;	/* chars as received */
150 	LIST_ENTRY(ppp_softc) sc_iflist;
151 };
152 
153 #ifdef _KERNEL
154 
155 struct	ppp_softc *pppalloc(pid_t);
156 void	pppdealloc(struct ppp_softc *);
157 int	pppioctl(struct ppp_softc *, u_long, void *, int, struct lwp *);
158 void	ppp_restart(struct ppp_softc *);
159 void	ppppktin(struct ppp_softc *, struct mbuf *, int);
160 struct	mbuf *ppp_dequeue(struct ppp_softc *);
161 int	pppoutput(struct ifnet *, struct mbuf *, const struct sockaddr *,
162 	    const struct rtentry *);
163 #endif /* _KERNEL */
164 
165 #endif /* !_NET_IF_PPPVAR_H_ */
166