1 | /* |
---|
2 | * if_pppvar.h - private structures and declarations for PPP. |
---|
3 | * |
---|
4 | * Copyright (c) 1994 The Australian National University. |
---|
5 | * All rights reserved. |
---|
6 | * |
---|
7 | * Permission to use, copy, modify, and distribute this software and its |
---|
8 | * documentation is hereby granted, provided that the above copyright |
---|
9 | * notice appears in all copies. This software is provided without any |
---|
10 | * warranty, express or implied. The Australian National University |
---|
11 | * makes no representations about the suitability of this software for |
---|
12 | * any purpose. |
---|
13 | * |
---|
14 | * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY |
---|
15 | * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
---|
16 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF |
---|
17 | * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY |
---|
18 | * OF SUCH DAMAGE. |
---|
19 | * |
---|
20 | * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, |
---|
21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
---|
22 | * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
---|
23 | * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO |
---|
24 | * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, |
---|
25 | * OR MODIFICATIONS. |
---|
26 | * |
---|
27 | * Copyright (c) 1989 Carnegie Mellon University. |
---|
28 | * All rights reserved. |
---|
29 | * |
---|
30 | * Redistribution and use in source and binary forms are permitted |
---|
31 | * provided that the above copyright notice and this paragraph are |
---|
32 | * duplicated in all such forms and that any documentation, |
---|
33 | * advertising materials, and other materials related to such |
---|
34 | * distribution and use acknowledge that the software was developed |
---|
35 | * by Carnegie Mellon University. The name of the |
---|
36 | * University may not be used to endorse or promote products derived |
---|
37 | * from this software without specific prior written permission. |
---|
38 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
---|
39 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
---|
40 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
---|
41 | * |
---|
42 | * $FreeBSD: src/sys/net/if_pppvar.h,v 1.26 2006/12/05 18:54:21 ume Exp $ |
---|
43 | */ |
---|
44 | |
---|
45 | |
---|
46 | #ifndef _NET_IF_PPPVAR_H_ |
---|
47 | #define _NET_IF_PPPVAR_H_ |
---|
48 | |
---|
49 | #include <net/if_var.h> /* struct ifnet */ |
---|
50 | #include <net/ppp_defs.h> /* struct pppstat */ |
---|
51 | #include <rtems/rtems/types.h> /* rtems_id */ |
---|
52 | |
---|
53 | #ifdef __cplusplus |
---|
54 | extern "C" { |
---|
55 | #endif |
---|
56 | |
---|
57 | struct proc; |
---|
58 | |
---|
59 | /* |
---|
60 | * Supported network protocols. These values are used for |
---|
61 | * indexing sc_npmode. |
---|
62 | */ |
---|
63 | #define NP_IP 0 /* Internet Protocol */ |
---|
64 | #define NUM_NP 1 /* Number of NPs. */ |
---|
65 | #define NUM_MBUFQ 64 |
---|
66 | |
---|
67 | |
---|
68 | /* |
---|
69 | * Structure describing each ppp unit. |
---|
70 | */ |
---|
71 | struct ppp_softc { |
---|
72 | device_t sc_dev; |
---|
73 | struct mtx sc_mtx; |
---|
74 | struct ifnet *sc_ifp; /* network-visible interface */ |
---|
75 | u_int sc_flags; /* control/status bits; see if_ppp.h */ |
---|
76 | void *sc_devp; /* pointer to device-dep structure */ |
---|
77 | void (*sc_start)(struct ppp_softc *); /* start output proc */ |
---|
78 | void (*sc_ctlp)(struct ppp_softc *); /* rcvd control pkt */ |
---|
79 | void (*sc_relinq)(struct ppp_softc *); /* relinquish ifunit */ |
---|
80 | short sc_mru; /* max receive unit */ |
---|
81 | pid_t sc_xfer; /* used in transferring unit */ |
---|
82 | struct ifqueue sc_rawq; /* received packets */ |
---|
83 | struct ifqueue sc_inq; /* queue of input packets for daemon */ |
---|
84 | struct ifaltq sc_fastq; /* interactive output packet q */ |
---|
85 | struct mbuf *sc_npqueue; /* output packets not to be sent yet */ |
---|
86 | struct mbuf **sc_npqtail; /* ptr to last next ptr in npqueue */ |
---|
87 | struct pppstat sc_stats; /* count of bytes/pkts sent/rcvd */ |
---|
88 | caddr_t sc_bpf; /* hook for BPF */ |
---|
89 | enum NPmode sc_npmode[NUM_NP]; /* what to do with each NP */ |
---|
90 | struct compressor *sc_xcomp; /* transmit compressor */ |
---|
91 | void *sc_xc_state; /* transmit compressor state */ |
---|
92 | struct compressor *sc_rcomp; /* receive decompressor */ |
---|
93 | void *sc_rc_state; /* receive decompressor state */ |
---|
94 | time_t sc_last_sent; /* time (secs) last NP pkt sent */ |
---|
95 | time_t sc_last_recv; /* time (secs) last NP pkt rcvd */ |
---|
96 | #ifdef PPP_FILTER |
---|
97 | struct bpf_program sc_pass_filt; /* filter for packets to pass */ |
---|
98 | struct bpf_program sc_active_filt; /* filter for "non-idle" packets */ |
---|
99 | #endif /* PPP_FILTER */ |
---|
100 | #ifdef VJC |
---|
101 | struct vjcompress *sc_comp; /* vjc control buffer */ |
---|
102 | #endif |
---|
103 | |
---|
104 | /* Device-dependent part for async lines. */ |
---|
105 | ext_accm sc_asyncmap; /* async control character map */ |
---|
106 | u_long sc_rasyncmap; /* receive async control char map */ |
---|
107 | struct mbuf *sc_outm; /* mbuf chain currently being output */ |
---|
108 | struct mbuf *sc_outmc; /* mbuf currently being output */ |
---|
109 | struct mbuf *sc_m; /* pointer to input mbuf chain */ |
---|
110 | struct mbuf *sc_mc; /* pointer to current input mbuf */ |
---|
111 | char *sc_mp; /* ptr to next char in input mbuf */ |
---|
112 | short sc_ilen; /* length of input packet so far */ |
---|
113 | u_short sc_fcs; /* FCS so far (input) */ |
---|
114 | u_short sc_outfcs; /* FCS so far for output packet */ |
---|
115 | u_char sc_rawin[16]; /* chars as received */ |
---|
116 | int sc_rawin_count; /* # in sc_rawin */ |
---|
117 | |
---|
118 | struct ifqueue sc_freeq; /* free packets */ |
---|
119 | short sc_outoff; /* output packet byte offset */ |
---|
120 | bool sc_outoff_update; /* outoff needs update in pppstart */ |
---|
121 | short sc_outflag; /* output status flag */ |
---|
122 | short sc_outlen; /* length of output packet */ |
---|
123 | short sc_outfcslen; /* length of output fcs data */ |
---|
124 | u_char sc_outfcsbuf[8]; /* output packet fcs buffer */ |
---|
125 | u_char *sc_outbuf; /* pointer to output data */ |
---|
126 | u_char sc_outchar; |
---|
127 | |
---|
128 | rtems_id sc_rxtask; |
---|
129 | rtems_id sc_txtask; |
---|
130 | rtems_id sc_pppdtask; |
---|
131 | }; |
---|
132 | |
---|
133 | struct ppp_softc *pppalloc(pid_t pid); |
---|
134 | void pppdealloc(struct ppp_softc *sc); |
---|
135 | int pppoutput(struct ifnet *, struct mbuf *, const struct sockaddr *, |
---|
136 | struct route *); |
---|
137 | int pppioctl(struct ppp_softc *sc, ioctl_command_t cmd, caddr_t data, |
---|
138 | int flag, struct proc *p); |
---|
139 | struct mbuf *ppp_dequeue(struct ppp_softc *sc); |
---|
140 | u_short pppfcs(u_short fcs, u_char *cp, int len); |
---|
141 | void pppallocmbuf(struct ppp_softc *sc, struct mbuf **mp); |
---|
142 | |
---|
143 | |
---|
144 | /* define event values */ |
---|
145 | #define RX_PACKET RTEMS_EVENT_1 |
---|
146 | #define RX_MBUF RTEMS_EVENT_2 |
---|
147 | #define RX_EMPTY RTEMS_EVENT_3 |
---|
148 | #define TX_PACKET RTEMS_EVENT_1 |
---|
149 | #define TX_TRANSMIT RTEMS_EVENT_2 |
---|
150 | #define PPPD_EVENT RTEMS_EVENT_31 |
---|
151 | |
---|
152 | /* define out flag values */ |
---|
153 | #define SC_TX_BUSY 0x0001 |
---|
154 | #define SC_TX_FCS 0x0002 |
---|
155 | #define SC_TX_ESCAPE 0x0004 |
---|
156 | #define SC_TX_LASTCHAR 0x0008 |
---|
157 | #define SC_TX_PENDING 0x0010 |
---|
158 | |
---|
159 | /* |
---|
160 | * Special interface queue functions to exchange mbufs between task and |
---|
161 | * interrupt context via pppinput() and pppstart(). |
---|
162 | */ |
---|
163 | |
---|
164 | static inline void |
---|
165 | if_ppp_enqueue(struct ifqueue *ifq, struct mbuf *m) |
---|
166 | { |
---|
167 | rtems_interrupt_level level; |
---|
168 | |
---|
169 | rtems_interrupt_disable(level); |
---|
170 | _IF_ENQUEUE(ifq, m); |
---|
171 | rtems_interrupt_enable(level); |
---|
172 | } |
---|
173 | |
---|
174 | static inline struct mbuf * |
---|
175 | if_ppp_dequeue(struct ifqueue *ifq) |
---|
176 | { |
---|
177 | struct mbuf *m; |
---|
178 | rtems_interrupt_level level; |
---|
179 | |
---|
180 | rtems_interrupt_disable(level); |
---|
181 | _IF_DEQUEUE(ifq, m); |
---|
182 | rtems_interrupt_enable(level); |
---|
183 | |
---|
184 | return m; |
---|
185 | } |
---|
186 | |
---|
187 | #ifdef __cplusplus |
---|
188 | } |
---|
189 | #endif |
---|
190 | |
---|
191 | #endif /* _NET_IF_PPPVAR_H_ */ |
---|
192 | |
---|