can_pcb.c revision 1.1.2.4 1 1.1.2.4 bouyer /* $NetBSD: can_pcb.c,v 1.1.2.4 2017/04/23 21:05:09 bouyer Exp $ */
2 1.1.2.1 bouyer
3 1.1.2.1 bouyer /*-
4 1.1.2.1 bouyer * Copyright (c) 2003, 2017 The NetBSD Foundation, Inc.
5 1.1.2.1 bouyer * All rights reserved.
6 1.1.2.1 bouyer *
7 1.1.2.1 bouyer * This code is derived from software contributed to The NetBSD Foundation
8 1.1.2.1 bouyer * by Robert Swindells and Manuel Bouyer
9 1.1.2.1 bouyer *
10 1.1.2.1 bouyer * Redistribution and use in source and binary forms, with or without
11 1.1.2.1 bouyer * modification, are permitted provided that the following conditions
12 1.1.2.1 bouyer * are met:
13 1.1.2.1 bouyer * 1. Redistributions of source code must retain the above copyright
14 1.1.2.1 bouyer * notice, this list of conditions and the following disclaimer.
15 1.1.2.1 bouyer * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.2.1 bouyer * notice, this list of conditions and the following disclaimer in the
17 1.1.2.1 bouyer * documentation and/or other materials provided with the distribution.
18 1.1.2.1 bouyer *
19 1.1.2.1 bouyer * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1.2.1 bouyer * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1.2.1 bouyer * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1.2.1 bouyer * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1.2.1 bouyer * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1.2.1 bouyer * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1.2.1 bouyer * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1.2.1 bouyer * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1.2.1 bouyer * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1.2.1 bouyer * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1.2.1 bouyer * POSSIBILITY OF SUCH DAMAGE.
30 1.1.2.1 bouyer */
31 1.1.2.1 bouyer
32 1.1.2.1 bouyer #include <sys/cdefs.h>
33 1.1.2.4 bouyer __KERNEL_RCSID(0, "$NetBSD: can_pcb.c,v 1.1.2.4 2017/04/23 21:05:09 bouyer Exp $");
34 1.1.2.1 bouyer
35 1.1.2.1 bouyer #include <sys/param.h>
36 1.1.2.1 bouyer #include <sys/systm.h>
37 1.1.2.1 bouyer #include <sys/malloc.h>
38 1.1.2.2 bouyer #include <sys/kmem.h>
39 1.1.2.1 bouyer #include <sys/mbuf.h>
40 1.1.2.1 bouyer #include <sys/protosw.h>
41 1.1.2.1 bouyer #include <sys/socket.h>
42 1.1.2.1 bouyer #include <sys/socketvar.h>
43 1.1.2.1 bouyer #include <sys/ioctl.h>
44 1.1.2.1 bouyer #include <sys/errno.h>
45 1.1.2.1 bouyer #include <sys/time.h>
46 1.1.2.1 bouyer #include <sys/pool.h>
47 1.1.2.1 bouyer #include <sys/proc.h>
48 1.1.2.1 bouyer
49 1.1.2.1 bouyer #include <net/if.h>
50 1.1.2.1 bouyer #include <net/route.h>
51 1.1.2.1 bouyer
52 1.1.2.1 bouyer #include <netcan/can.h>
53 1.1.2.1 bouyer #include <netcan/can_var.h>
54 1.1.2.1 bouyer #include <netcan/can_pcb.h>
55 1.1.2.1 bouyer
56 1.1.2.1 bouyer #define CANPCBHASH_BIND(table, ifindex) \
57 1.1.2.1 bouyer &(table)->canpt_bindhashtbl[ \
58 1.1.2.1 bouyer (ifindex) & (table)->canpt_bindhash]
59 1.1.2.1 bouyer #define CANPCBHASH_CONNECT(table, ifindex) \
60 1.1.2.1 bouyer &(table)->canpt_connecthashtbl[ \
61 1.1.2.1 bouyer (ifindex) & (table)->canpt_bindhash]
62 1.1.2.1 bouyer
63 1.1.2.1 bouyer struct pool canpcb_pool;
64 1.1.2.1 bouyer
65 1.1.2.1 bouyer void
66 1.1.2.1 bouyer can_pcbinit(struct canpcbtable *table, int bindhashsize, int connecthashsize)
67 1.1.2.1 bouyer {
68 1.1.2.1 bouyer static int canpcb_pool_initialized;
69 1.1.2.1 bouyer
70 1.1.2.1 bouyer if (canpcb_pool_initialized == 0) {
71 1.1.2.1 bouyer pool_init(&canpcb_pool, sizeof(struct canpcb), 0, 0, 0,
72 1.1.2.1 bouyer "canpcbpl", NULL, IPL_SOFTNET);
73 1.1.2.1 bouyer canpcb_pool_initialized = 1;
74 1.1.2.1 bouyer }
75 1.1.2.1 bouyer
76 1.1.2.1 bouyer TAILQ_INIT(&table->canpt_queue);
77 1.1.2.1 bouyer table->canpt_bindhashtbl = hashinit(bindhashsize, HASH_LIST, true,
78 1.1.2.1 bouyer &table->canpt_bindhash);
79 1.1.2.1 bouyer table->canpt_connecthashtbl = hashinit(connecthashsize, HASH_LIST,
80 1.1.2.1 bouyer true, &table->canpt_connecthash);
81 1.1.2.1 bouyer }
82 1.1.2.1 bouyer
83 1.1.2.1 bouyer int
84 1.1.2.1 bouyer can_pcballoc(struct socket *so, void *v)
85 1.1.2.1 bouyer {
86 1.1.2.1 bouyer struct canpcbtable *table = v;
87 1.1.2.1 bouyer struct canpcb *canp;
88 1.1.2.2 bouyer struct can_filter *can_init_filter;
89 1.1.2.1 bouyer int s;
90 1.1.2.1 bouyer
91 1.1.2.2 bouyer can_init_filter = kmem_alloc(sizeof(struct can_filter), KM_NOSLEEP);
92 1.1.2.2 bouyer if (can_init_filter == NULL)
93 1.1.2.2 bouyer return (ENOBUFS);
94 1.1.2.2 bouyer can_init_filter->can_id = 0;
95 1.1.2.2 bouyer can_init_filter->can_mask = 0; /* accept all by default */
96 1.1.2.2 bouyer
97 1.1.2.1 bouyer s = splnet();
98 1.1.2.1 bouyer canp = pool_get(&canpcb_pool, PR_NOWAIT);
99 1.1.2.1 bouyer splx(s);
100 1.1.2.2 bouyer if (canp == NULL) {
101 1.1.2.2 bouyer kmem_free(can_init_filter, sizeof(struct can_filter));
102 1.1.2.1 bouyer return (ENOBUFS);
103 1.1.2.2 bouyer }
104 1.1.2.1 bouyer memset(canp, 0, sizeof(*canp));
105 1.1.2.1 bouyer canp->canp_table = table;
106 1.1.2.1 bouyer canp->canp_socket = so;
107 1.1.2.2 bouyer canp->canp_filters = can_init_filter;
108 1.1.2.2 bouyer canp->canp_nfilters = 1;
109 1.1.2.4 bouyer mutex_init(&canp->canp_mtx, MUTEX_DEFAULT, IPL_NET);
110 1.1.2.4 bouyer canp->canp_refcount = 1;
111 1.1.2.1 bouyer
112 1.1.2.1 bouyer so->so_pcb = canp;
113 1.1.2.4 bouyer mutex_enter(&canp->canp_mtx);
114 1.1.2.1 bouyer TAILQ_INSERT_HEAD(&table->canpt_queue, canp, canp_queue);
115 1.1.2.1 bouyer can_pcbstate(canp, CANP_ATTACHED);
116 1.1.2.4 bouyer mutex_exit(&canp->canp_mtx);
117 1.1.2.1 bouyer return (0);
118 1.1.2.1 bouyer }
119 1.1.2.1 bouyer
120 1.1.2.1 bouyer int
121 1.1.2.1 bouyer can_pcbbind(void *v, struct sockaddr_can *scan, struct lwp *l)
122 1.1.2.1 bouyer {
123 1.1.2.1 bouyer struct canpcb *canp = v;
124 1.1.2.1 bouyer
125 1.1.2.1 bouyer if (scan->can_family != AF_CAN)
126 1.1.2.1 bouyer return (EAFNOSUPPORT);
127 1.1.2.4 bouyer mutex_enter(&canp->canp_mtx);
128 1.1.2.1 bouyer if (scan->can_ifindex != 0) {
129 1.1.2.1 bouyer canp->canp_ifp = if_byindex(scan->can_ifindex);
130 1.1.2.1 bouyer if (canp->canp_ifp == NULL)
131 1.1.2.1 bouyer return (EADDRNOTAVAIL);
132 1.1.2.1 bouyer soisconnected(canp->canp_socket);
133 1.1.2.1 bouyer } else {
134 1.1.2.1 bouyer canp->canp_ifp = NULL;
135 1.1.2.1 bouyer canp->canp_socket->so_state &= ~SS_ISCONNECTED; /* XXX */
136 1.1.2.1 bouyer }
137 1.1.2.1 bouyer can_pcbstate(canp, CANP_BOUND);
138 1.1.2.4 bouyer mutex_exit(&canp->canp_mtx);
139 1.1.2.1 bouyer return 0;
140 1.1.2.1 bouyer }
141 1.1.2.1 bouyer
142 1.1.2.1 bouyer /*
143 1.1.2.1 bouyer * Connect from a socket to a specified address.
144 1.1.2.1 bouyer */
145 1.1.2.1 bouyer int
146 1.1.2.1 bouyer can_pcbconnect(void *v, struct sockaddr_can *scan)
147 1.1.2.1 bouyer {
148 1.1.2.1 bouyer #if 0
149 1.1.2.1 bouyer struct canpcb *canp = v;
150 1.1.2.1 bouyer struct sockaddr_can *ifaddr = NULL;
151 1.1.2.1 bouyer int error;
152 1.1.2.1 bouyer #endif
153 1.1.2.1 bouyer
154 1.1.2.1 bouyer if (scan->can_family != AF_CAN)
155 1.1.2.1 bouyer return (EAFNOSUPPORT);
156 1.1.2.1 bouyer #if 0
157 1.1.2.4 bouyer mutex_enter(&canp->canp_mtx);
158 1.1.2.1 bouyer memcpy(&canp->canp_dst, scan, sizeof(struct sockaddr_can));
159 1.1.2.1 bouyer can_pcbstate(canp, CANP_CONNECTED);
160 1.1.2.4 bouyer mutex_exit(&canp->canp_mtx);
161 1.1.2.1 bouyer return 0;
162 1.1.2.1 bouyer #endif
163 1.1.2.1 bouyer return EOPNOTSUPP;
164 1.1.2.1 bouyer }
165 1.1.2.1 bouyer
166 1.1.2.1 bouyer void
167 1.1.2.1 bouyer can_pcbdisconnect(void *v)
168 1.1.2.1 bouyer {
169 1.1.2.1 bouyer struct canpcb *canp = v;
170 1.1.2.1 bouyer
171 1.1.2.4 bouyer mutex_enter(&canp->canp_mtx);
172 1.1.2.4 bouyer can_pcbstate(canp, CANP_DETACHED);
173 1.1.2.4 bouyer mutex_exit(&canp->canp_mtx);
174 1.1.2.1 bouyer if (canp->canp_socket->so_state & SS_NOFDREF)
175 1.1.2.1 bouyer can_pcbdetach(canp);
176 1.1.2.1 bouyer }
177 1.1.2.1 bouyer
178 1.1.2.1 bouyer void
179 1.1.2.1 bouyer can_pcbdetach(void *v)
180 1.1.2.1 bouyer {
181 1.1.2.1 bouyer struct canpcb *canp = v;
182 1.1.2.1 bouyer struct socket *so = canp->canp_socket;
183 1.1.2.1 bouyer
184 1.1.2.1 bouyer KASSERT(mutex_owned(softnet_lock));
185 1.1.2.1 bouyer so->so_pcb = NULL;
186 1.1.2.4 bouyer mutex_enter(&canp->canp_mtx);
187 1.1.2.4 bouyer can_pcbstate(canp, CANP_DETACHED);
188 1.1.2.2 bouyer can_pcbsetfilter(canp, NULL, 0);
189 1.1.2.4 bouyer mutex_exit(&canp->canp_mtx);
190 1.1.2.4 bouyer TAILQ_REMOVE(&canp->canp_table->canpt_queue, canp, canp_queue);
191 1.1.2.4 bouyer sofree(so); /* sofree drops the softnet_lock */
192 1.1.2.4 bouyer canp_unref(canp);
193 1.1.2.1 bouyer mutex_enter(softnet_lock);
194 1.1.2.1 bouyer }
195 1.1.2.1 bouyer
196 1.1.2.1 bouyer void
197 1.1.2.4 bouyer canp_ref(struct canpcb *canp)
198 1.1.2.4 bouyer {
199 1.1.2.4 bouyer KASSERT(mutex_owned(&canp->canp_mtx));
200 1.1.2.4 bouyer canp->canp_refcount++;
201 1.1.2.4 bouyer }
202 1.1.2.4 bouyer
203 1.1.2.4 bouyer void
204 1.1.2.4 bouyer canp_unref(struct canpcb *canp)
205 1.1.2.4 bouyer {
206 1.1.2.4 bouyer mutex_enter(&canp->canp_mtx);
207 1.1.2.4 bouyer canp->canp_refcount--;
208 1.1.2.4 bouyer KASSERT(canp->canp_refcount >= 0);
209 1.1.2.4 bouyer if (canp->canp_refcount > 0) {
210 1.1.2.4 bouyer mutex_exit(&canp->canp_mtx);
211 1.1.2.4 bouyer return;
212 1.1.2.4 bouyer }
213 1.1.2.4 bouyer mutex_exit(&canp->canp_mtx);
214 1.1.2.4 bouyer mutex_destroy(&canp->canp_mtx);
215 1.1.2.4 bouyer pool_put(&canpcb_pool, canp);
216 1.1.2.4 bouyer }
217 1.1.2.4 bouyer
218 1.1.2.4 bouyer void
219 1.1.2.1 bouyer can_setsockaddr(struct canpcb *canp, struct sockaddr_can *scan)
220 1.1.2.1 bouyer {
221 1.1.2.1 bouyer
222 1.1.2.4 bouyer mutex_enter(&canp->canp_mtx);
223 1.1.2.1 bouyer memset(scan, 0, sizeof (*scan));
224 1.1.2.1 bouyer scan->can_family = AF_CAN;
225 1.1.2.1 bouyer scan->can_len = sizeof(*scan);
226 1.1.2.1 bouyer scan->can_ifindex = canp->canp_ifp->if_index;
227 1.1.2.4 bouyer mutex_exit(&canp->canp_mtx);
228 1.1.2.1 bouyer }
229 1.1.2.1 bouyer
230 1.1.2.2 bouyer int
231 1.1.2.2 bouyer can_pcbsetfilter(struct canpcb *canp, struct can_filter *fp, int nfilters)
232 1.1.2.2 bouyer {
233 1.1.2.2 bouyer
234 1.1.2.2 bouyer struct can_filter *newf;
235 1.1.2.4 bouyer KASSERT(mutex_owned(&canp->canp_mtx));
236 1.1.2.2 bouyer
237 1.1.2.2 bouyer if (nfilters > 0) {
238 1.1.2.2 bouyer newf =
239 1.1.2.2 bouyer kmem_alloc(sizeof(struct can_filter) * nfilters, KM_SLEEP);
240 1.1.2.2 bouyer if (newf == NULL)
241 1.1.2.2 bouyer return ENOMEM;
242 1.1.2.2 bouyer memcpy(newf, fp, sizeof(struct can_filter) * nfilters);
243 1.1.2.2 bouyer } else {
244 1.1.2.2 bouyer newf = NULL;
245 1.1.2.2 bouyer }
246 1.1.2.2 bouyer if (canp->canp_filters != NULL) {
247 1.1.2.2 bouyer kmem_free(canp->canp_filters,
248 1.1.2.2 bouyer sizeof(struct can_filter) * canp->canp_nfilters);
249 1.1.2.2 bouyer }
250 1.1.2.2 bouyer canp->canp_filters = newf;
251 1.1.2.2 bouyer canp->canp_nfilters = nfilters;
252 1.1.2.2 bouyer return 0;
253 1.1.2.2 bouyer }
254 1.1.2.2 bouyer
255 1.1.2.2 bouyer
256 1.1.2.2 bouyer
257 1.1.2.1 bouyer #if 0
258 1.1.2.1 bouyer /*
259 1.1.2.1 bouyer * Pass some notification to all connections of a protocol
260 1.1.2.1 bouyer * associated with address dst. The local address and/or port numbers
261 1.1.2.1 bouyer * may be specified to limit the search. The "usual action" will be
262 1.1.2.1 bouyer * taken, depending on the ctlinput cmd. The caller must filter any
263 1.1.2.1 bouyer * cmds that are uninteresting (e.g., no error in the map).
264 1.1.2.1 bouyer * Call the protocol specific routine (if any) to report
265 1.1.2.1 bouyer * any errors for each matching socket.
266 1.1.2.1 bouyer *
267 1.1.2.1 bouyer * Must be called at splsoftnet.
268 1.1.2.1 bouyer */
269 1.1.2.1 bouyer int
270 1.1.2.1 bouyer can_pcbnotify(struct canpcbtable *table, u_int32_t faddr, u_int32_t laddr,
271 1.1.2.1 bouyer int errno, void (*notify)(struct canpcb *, int))
272 1.1.2.1 bouyer {
273 1.1.2.1 bouyer struct canpcbhead *head;
274 1.1.2.1 bouyer struct canpcb *canp, *ncanp;
275 1.1.2.1 bouyer int nmatch;
276 1.1.2.1 bouyer
277 1.1.2.1 bouyer if (faddr == 0 || notify == 0)
278 1.1.2.1 bouyer return (0);
279 1.1.2.1 bouyer
280 1.1.2.1 bouyer nmatch = 0;
281 1.1.2.1 bouyer head = CANPCBHASH_CONNECT(table, faddr, laddr);
282 1.1.2.1 bouyer for (canp = LIST_FIRST(head); canp != NULL; canp = ncanp) {
283 1.1.2.1 bouyer ncanp = LIST_NEXT(canp, canp_hash);
284 1.1.2.1 bouyer if (canp->canp_faddr == faddr &&
285 1.1.2.1 bouyer canp->canp_laddr == laddr) {
286 1.1.2.1 bouyer (*notify)(canp, errno);
287 1.1.2.1 bouyer nmatch++;
288 1.1.2.1 bouyer }
289 1.1.2.1 bouyer }
290 1.1.2.1 bouyer return (nmatch);
291 1.1.2.1 bouyer }
292 1.1.2.1 bouyer
293 1.1.2.1 bouyer void
294 1.1.2.1 bouyer can_pcbnotifyall(struct canpcbtable *table, u_int32_t faddr, int errno,
295 1.1.2.1 bouyer void (*notify)(struct canpcb *, int))
296 1.1.2.1 bouyer {
297 1.1.2.1 bouyer struct canpcb *canp, *ncanp;
298 1.1.2.1 bouyer
299 1.1.2.1 bouyer if (faddr == 0 || notify == 0)
300 1.1.2.1 bouyer return;
301 1.1.2.1 bouyer
302 1.1.2.1 bouyer TAILQ_FOREACH_SAFE(canp, &table->canpt_queue, canp_queue, ncanp) {
303 1.1.2.1 bouyer if (canp->canp_faddr == faddr)
304 1.1.2.1 bouyer (*notify)(canp, errno);
305 1.1.2.1 bouyer }
306 1.1.2.1 bouyer }
307 1.1.2.1 bouyer #endif
308 1.1.2.1 bouyer
309 1.1.2.1 bouyer #if 0
310 1.1.2.1 bouyer void
311 1.1.2.1 bouyer can_pcbpurgeif0(struct canpcbtable *table, struct ifnet *ifp)
312 1.1.2.1 bouyer {
313 1.1.2.1 bouyer struct canpcb *canp, *ncanp;
314 1.1.2.1 bouyer struct ip_moptions *imo;
315 1.1.2.1 bouyer int i, gap;
316 1.1.2.1 bouyer
317 1.1.2.1 bouyer }
318 1.1.2.1 bouyer
319 1.1.2.1 bouyer void
320 1.1.2.1 bouyer can_pcbpurgeif(struct canpcbtable *table, struct ifnet *ifp)
321 1.1.2.1 bouyer {
322 1.1.2.1 bouyer struct canpcb *canp, *ncanp;
323 1.1.2.1 bouyer
324 1.1.2.1 bouyer for (canp = CIRCLEQ_FIRST(&table->canpt_queue);
325 1.1.2.1 bouyer canp != (void *)&table->canpt_queue;
326 1.1.2.1 bouyer canp = ncanp) {
327 1.1.2.1 bouyer ncanp = CIRCLEQ_NEXT(canp, canp_queue);
328 1.1.2.1 bouyer }
329 1.1.2.1 bouyer }
330 1.1.2.1 bouyer #endif
331 1.1.2.1 bouyer
332 1.1.2.1 bouyer
333 1.1.2.1 bouyer
334 1.1.2.1 bouyer void
335 1.1.2.1 bouyer can_pcbstate(struct canpcb *canp, int state)
336 1.1.2.1 bouyer {
337 1.1.2.1 bouyer int ifindex = canp->canp_ifp ? canp->canp_ifp->if_index : 0;
338 1.1.2.4 bouyer KASSERT(mutex_owned(&canp->canp_mtx));
339 1.1.2.1 bouyer
340 1.1.2.1 bouyer if (canp->canp_state > CANP_ATTACHED)
341 1.1.2.1 bouyer LIST_REMOVE(canp, canp_hash);
342 1.1.2.1 bouyer
343 1.1.2.1 bouyer switch (state) {
344 1.1.2.1 bouyer case CANP_BOUND:
345 1.1.2.1 bouyer LIST_INSERT_HEAD(CANPCBHASH_BIND(canp->canp_table,
346 1.1.2.1 bouyer ifindex), canp, canp_hash);
347 1.1.2.1 bouyer break;
348 1.1.2.1 bouyer case CANP_CONNECTED:
349 1.1.2.1 bouyer LIST_INSERT_HEAD(CANPCBHASH_CONNECT(canp->canp_table,
350 1.1.2.1 bouyer ifindex), canp, canp_hash);
351 1.1.2.1 bouyer break;
352 1.1.2.1 bouyer }
353 1.1.2.1 bouyer
354 1.1.2.1 bouyer canp->canp_state = state;
355 1.1.2.1 bouyer }
356 1.1.2.2 bouyer
357 1.1.2.2 bouyer /*
358 1.1.2.2 bouyer * check mbuf against socket accept filter.
359 1.1.2.2 bouyer * returns true if mbuf is accepted, false otherwise
360 1.1.2.2 bouyer */
361 1.1.2.2 bouyer bool
362 1.1.2.2 bouyer can_pcbfilter(struct canpcb *canp, struct mbuf *m)
363 1.1.2.2 bouyer {
364 1.1.2.2 bouyer int i;
365 1.1.2.2 bouyer struct can_frame *fmp;
366 1.1.2.2 bouyer struct can_filter *fip;
367 1.1.2.2 bouyer
368 1.1.2.4 bouyer KASSERT(mutex_owned(&canp->canp_mtx));
369 1.1.2.3 bouyer KASSERT((m->m_flags & M_PKTHDR) != 0);
370 1.1.2.3 bouyer KASSERT(m->m_len == m->m_pkthdr.len);
371 1.1.2.3 bouyer
372 1.1.2.2 bouyer fmp = mtod(m, struct can_frame *);
373 1.1.2.2 bouyer for (i = 0; i < canp->canp_nfilters; i++) {
374 1.1.2.2 bouyer fip = &canp->canp_filters[i];
375 1.1.2.2 bouyer if ((fmp->can_id & fip->can_mask) == fip->can_id)
376 1.1.2.2 bouyer return true;
377 1.1.2.2 bouyer }
378 1.1.2.2 bouyer /* no match */
379 1.1.2.2 bouyer return false;
380 1.1.2.2 bouyer }
381