sco_socket.c revision 1.35 1 1.35 rtr /* $NetBSD: sco_socket.c,v 1.35 2015/04/24 22:32:37 rtr Exp $ */
2 1.1 gdamore
3 1.1 gdamore /*-
4 1.1 gdamore * Copyright (c) 2006 Itronix Inc.
5 1.1 gdamore * All rights reserved.
6 1.1 gdamore *
7 1.1 gdamore * Redistribution and use in source and binary forms, with or without
8 1.1 gdamore * modification, are permitted provided that the following conditions
9 1.1 gdamore * are met:
10 1.1 gdamore * 1. Redistributions of source code must retain the above copyright
11 1.1 gdamore * notice, this list of conditions and the following disclaimer.
12 1.1 gdamore * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 gdamore * notice, this list of conditions and the following disclaimer in the
14 1.1 gdamore * documentation and/or other materials provided with the distribution.
15 1.1 gdamore * 3. The name of Itronix Inc. may not be used to endorse
16 1.1 gdamore * or promote products derived from this software without specific
17 1.1 gdamore * prior written permission.
18 1.1 gdamore *
19 1.1 gdamore * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
20 1.1 gdamore * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 gdamore * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 gdamore * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
23 1.1 gdamore * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 1.1 gdamore * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 1.1 gdamore * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 1.1 gdamore * ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 gdamore * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 gdamore * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 gdamore * POSSIBILITY OF SUCH DAMAGE.
30 1.1 gdamore */
31 1.1 gdamore
32 1.1 gdamore #include <sys/cdefs.h>
33 1.35 rtr __KERNEL_RCSID(0, "$NetBSD: sco_socket.c,v 1.35 2015/04/24 22:32:37 rtr Exp $");
34 1.8 plunky
35 1.8 plunky /* load symbolic names */
36 1.8 plunky #ifdef BLUETOOTH_DEBUG
37 1.8 plunky #define PRUREQUESTS
38 1.8 plunky #define PRCOREQUESTS
39 1.8 plunky #endif
40 1.1 gdamore
41 1.1 gdamore #include <sys/param.h>
42 1.1 gdamore #include <sys/domain.h>
43 1.1 gdamore #include <sys/kernel.h>
44 1.1 gdamore #include <sys/mbuf.h>
45 1.1 gdamore #include <sys/proc.h>
46 1.1 gdamore #include <sys/protosw.h>
47 1.1 gdamore #include <sys/socket.h>
48 1.1 gdamore #include <sys/socketvar.h>
49 1.1 gdamore #include <sys/systm.h>
50 1.1 gdamore
51 1.1 gdamore #include <netbt/bluetooth.h>
52 1.1 gdamore #include <netbt/hci.h>
53 1.1 gdamore #include <netbt/sco.h>
54 1.1 gdamore
55 1.1 gdamore /*******************************************************************************
56 1.1 gdamore *
57 1.1 gdamore * SCO SOCK_SEQPACKET sockets - low latency audio data
58 1.1 gdamore */
59 1.1 gdamore
60 1.1 gdamore static void sco_connecting(void *);
61 1.1 gdamore static void sco_connected(void *);
62 1.1 gdamore static void sco_disconnected(void *, int);
63 1.1 gdamore static void *sco_newconn(void *, struct sockaddr_bt *, struct sockaddr_bt *);
64 1.1 gdamore static void sco_complete(void *, int);
65 1.9 plunky static void sco_linkmode(void *, int);
66 1.1 gdamore static void sco_input(void *, struct mbuf *);
67 1.1 gdamore
68 1.1 gdamore static const struct btproto sco_proto = {
69 1.1 gdamore sco_connecting,
70 1.1 gdamore sco_connected,
71 1.1 gdamore sco_disconnected,
72 1.1 gdamore sco_newconn,
73 1.1 gdamore sco_complete,
74 1.9 plunky sco_linkmode,
75 1.1 gdamore sco_input,
76 1.1 gdamore };
77 1.1 gdamore
78 1.1 gdamore int sco_sendspace = 4096;
79 1.1 gdamore int sco_recvspace = 4096;
80 1.1 gdamore
81 1.14 rmind static int
82 1.16 rmind sco_attach(struct socket *so, int proto)
83 1.14 rmind {
84 1.14 rmind int error;
85 1.14 rmind
86 1.14 rmind KASSERT(so->so_pcb == NULL);
87 1.14 rmind
88 1.14 rmind if (so->so_lock == NULL) {
89 1.14 rmind mutex_obj_hold(bt_lock);
90 1.14 rmind so->so_lock = bt_lock;
91 1.14 rmind solock(so);
92 1.14 rmind }
93 1.14 rmind KASSERT(solocked(so));
94 1.14 rmind
95 1.14 rmind error = soreserve(so, sco_sendspace, sco_recvspace);
96 1.14 rmind if (error) {
97 1.14 rmind return error;
98 1.14 rmind }
99 1.16 rmind return sco_attach_pcb((struct sco_pcb **)&so->so_pcb, &sco_proto, so);
100 1.14 rmind }
101 1.14 rmind
102 1.14 rmind static void
103 1.16 rmind sco_detach(struct socket *so)
104 1.14 rmind {
105 1.15 martin KASSERT(so->so_pcb != NULL);
106 1.16 rmind sco_detach_pcb((struct sco_pcb **)&so->so_pcb);
107 1.14 rmind KASSERT(so->so_pcb == NULL);
108 1.14 rmind }
109 1.14 rmind
110 1.18 rtr static int
111 1.35 rtr sco_accept(struct socket *so, struct sockaddr *nam)
112 1.25 rtr {
113 1.25 rtr struct sco_pcb *pcb = so->so_pcb;
114 1.25 rtr
115 1.25 rtr KASSERT(solocked(so));
116 1.25 rtr KASSERT(nam != NULL);
117 1.25 rtr
118 1.25 rtr if (pcb == NULL)
119 1.25 rtr return EINVAL;
120 1.25 rtr
121 1.35 rtr return sco_peeraddr_pcb(pcb, (struct sockaddr_bt *)nam);
122 1.25 rtr }
123 1.25 rtr
124 1.25 rtr static int
125 1.34 rtr sco_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
126 1.27 rtr {
127 1.27 rtr struct sco_pcb *pcb = so->so_pcb;
128 1.34 rtr struct sockaddr_bt *sa = (struct sockaddr_bt *)nam;
129 1.27 rtr
130 1.27 rtr KASSERT(solocked(so));
131 1.27 rtr KASSERT(nam != NULL);
132 1.27 rtr
133 1.27 rtr if (pcb == NULL)
134 1.27 rtr return EINVAL;
135 1.27 rtr
136 1.27 rtr if (sa->bt_len != sizeof(struct sockaddr_bt))
137 1.27 rtr return EINVAL;
138 1.27 rtr
139 1.27 rtr if (sa->bt_family != AF_BLUETOOTH)
140 1.27 rtr return EAFNOSUPPORT;
141 1.27 rtr
142 1.27 rtr return sco_bind_pcb(pcb, sa);
143 1.27 rtr }
144 1.27 rtr
145 1.27 rtr static int
146 1.30 rtr sco_listen(struct socket *so, struct lwp *l)
147 1.27 rtr {
148 1.27 rtr struct sco_pcb *pcb = so->so_pcb;
149 1.27 rtr
150 1.27 rtr KASSERT(solocked(so));
151 1.27 rtr
152 1.27 rtr if (pcb == NULL)
153 1.27 rtr return EINVAL;
154 1.27 rtr
155 1.27 rtr return sco_listen_pcb(pcb);
156 1.27 rtr }
157 1.27 rtr
158 1.27 rtr static int
159 1.30 rtr sco_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
160 1.28 rtr {
161 1.28 rtr struct sco_pcb *pcb = so->so_pcb;
162 1.28 rtr struct sockaddr_bt *sa;
163 1.28 rtr
164 1.28 rtr KASSERT(solocked(so));
165 1.28 rtr KASSERT(nam != NULL);
166 1.28 rtr
167 1.28 rtr if (pcb == NULL)
168 1.28 rtr return EINVAL;
169 1.28 rtr
170 1.28 rtr sa = mtod(nam, struct sockaddr_bt *);
171 1.28 rtr if (sa->bt_len != sizeof(struct sockaddr_bt))
172 1.28 rtr return EINVAL;
173 1.28 rtr
174 1.28 rtr if (sa->bt_family != AF_BLUETOOTH)
175 1.28 rtr return EAFNOSUPPORT;
176 1.28 rtr
177 1.28 rtr soisconnecting(so);
178 1.28 rtr return sco_connect_pcb(pcb, sa);
179 1.28 rtr }
180 1.28 rtr
181 1.28 rtr static int
182 1.33 rtr sco_connect2(struct socket *so, struct socket *so2)
183 1.33 rtr {
184 1.33 rtr struct sco_pcb *pcb = so->so_pcb;
185 1.33 rtr
186 1.33 rtr KASSERT(solocked(so));
187 1.33 rtr
188 1.33 rtr if (pcb == NULL)
189 1.33 rtr return EINVAL;
190 1.33 rtr
191 1.33 rtr return EOPNOTSUPP;
192 1.33 rtr }
193 1.33 rtr
194 1.33 rtr static int
195 1.29 rtr sco_disconnect(struct socket *so)
196 1.29 rtr {
197 1.29 rtr struct sco_pcb *pcb = so->so_pcb;
198 1.29 rtr
199 1.29 rtr KASSERT(solocked(so));
200 1.29 rtr
201 1.29 rtr if (pcb == NULL)
202 1.29 rtr return EINVAL;
203 1.29 rtr
204 1.29 rtr soisdisconnecting(so);
205 1.29 rtr return sco_disconnect_pcb(pcb, so->so_linger);
206 1.29 rtr }
207 1.29 rtr
208 1.29 rtr static int
209 1.29 rtr sco_shutdown(struct socket *so)
210 1.29 rtr {
211 1.29 rtr KASSERT(solocked(so));
212 1.29 rtr
213 1.29 rtr socantsendmore(so);
214 1.29 rtr return 0;
215 1.29 rtr }
216 1.29 rtr
217 1.29 rtr static int
218 1.29 rtr sco_abort(struct socket *so)
219 1.29 rtr {
220 1.29 rtr struct sco_pcb *pcb = so->so_pcb;
221 1.29 rtr
222 1.29 rtr KASSERT(solocked(so));
223 1.29 rtr
224 1.29 rtr if (pcb == NULL)
225 1.29 rtr return EINVAL;
226 1.29 rtr
227 1.29 rtr sco_disconnect_pcb(pcb, 0);
228 1.29 rtr soisdisconnected(so);
229 1.29 rtr sco_detach(so);
230 1.29 rtr return 0;
231 1.29 rtr }
232 1.29 rtr
233 1.29 rtr static int
234 1.23 rtr sco_ioctl(struct socket *so, u_long cmd, void *nam, struct ifnet *ifp)
235 1.18 rtr {
236 1.18 rtr return EOPNOTSUPP;
237 1.18 rtr }
238 1.18 rtr
239 1.20 rtr static int
240 1.20 rtr sco_stat(struct socket *so, struct stat *ub)
241 1.20 rtr {
242 1.23 rtr KASSERT(solocked(so));
243 1.23 rtr
244 1.22 rtr return 0;
245 1.20 rtr }
246 1.20 rtr
247 1.24 rtr static int
248 1.35 rtr sco_peeraddr(struct socket *so, struct sockaddr *nam)
249 1.24 rtr {
250 1.24 rtr struct sco_pcb *pcb = (struct sco_pcb *)so->so_pcb;
251 1.24 rtr
252 1.24 rtr KASSERT(solocked(so));
253 1.24 rtr KASSERT(pcb != NULL);
254 1.24 rtr KASSERT(nam != NULL);
255 1.24 rtr
256 1.35 rtr return sco_peeraddr_pcb(pcb, (struct sockaddr_bt *)nam);
257 1.24 rtr }
258 1.24 rtr
259 1.24 rtr static int
260 1.35 rtr sco_sockaddr(struct socket *so, struct sockaddr *nam)
261 1.24 rtr {
262 1.24 rtr struct sco_pcb *pcb = (struct sco_pcb *)so->so_pcb;
263 1.24 rtr
264 1.24 rtr KASSERT(solocked(so));
265 1.24 rtr KASSERT(pcb != NULL);
266 1.24 rtr KASSERT(nam != NULL);
267 1.24 rtr
268 1.35 rtr return sco_sockaddr_pcb(pcb, (struct sockaddr_bt *)nam);
269 1.24 rtr }
270 1.24 rtr
271 1.26 rtr static int
272 1.32 rtr sco_rcvd(struct socket *so, int flags, struct lwp *l)
273 1.32 rtr {
274 1.32 rtr KASSERT(solocked(so));
275 1.32 rtr
276 1.32 rtr return EOPNOTSUPP;
277 1.32 rtr }
278 1.32 rtr
279 1.32 rtr static int
280 1.26 rtr sco_recvoob(struct socket *so, struct mbuf *m, int flags)
281 1.26 rtr {
282 1.26 rtr KASSERT(solocked(so));
283 1.26 rtr
284 1.26 rtr return EOPNOTSUPP;
285 1.26 rtr }
286 1.26 rtr
287 1.26 rtr static int
288 1.31 rtr sco_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
289 1.31 rtr struct mbuf *control, struct lwp *l)
290 1.31 rtr {
291 1.31 rtr struct sco_pcb *pcb = so->so_pcb;
292 1.31 rtr int err = 0;
293 1.31 rtr struct mbuf *m0;
294 1.31 rtr
295 1.31 rtr KASSERT(solocked(so));
296 1.31 rtr KASSERT(m != NULL);
297 1.31 rtr
298 1.31 rtr if (control) /* no use for that */
299 1.31 rtr m_freem(control);
300 1.31 rtr
301 1.31 rtr if (pcb == NULL) {
302 1.31 rtr err = EINVAL;
303 1.31 rtr goto release;
304 1.31 rtr }
305 1.31 rtr
306 1.31 rtr if (m->m_pkthdr.len == 0)
307 1.31 rtr goto release;
308 1.31 rtr
309 1.31 rtr if (m->m_pkthdr.len > pcb->sp_mtu) {
310 1.31 rtr err = EMSGSIZE;
311 1.31 rtr goto release;
312 1.31 rtr }
313 1.31 rtr
314 1.31 rtr m0 = m_copypacket(m, M_DONTWAIT);
315 1.31 rtr if (m0 == NULL) {
316 1.31 rtr err = ENOMEM;
317 1.31 rtr goto release;
318 1.31 rtr }
319 1.31 rtr
320 1.31 rtr sbappendrecord(&so->so_snd, m);
321 1.31 rtr return sco_send_pcb(pcb, m0);
322 1.31 rtr
323 1.31 rtr release:
324 1.31 rtr m_freem(m);
325 1.31 rtr return err;
326 1.31 rtr }
327 1.31 rtr
328 1.31 rtr static int
329 1.26 rtr sco_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
330 1.26 rtr {
331 1.26 rtr KASSERT(solocked(so));
332 1.26 rtr
333 1.26 rtr if (m)
334 1.26 rtr m_freem(m);
335 1.26 rtr if (control)
336 1.26 rtr m_freem(control);
337 1.26 rtr
338 1.26 rtr return EOPNOTSUPP;
339 1.26 rtr }
340 1.26 rtr
341 1.33 rtr static int
342 1.33 rtr sco_purgeif(struct socket *so, struct ifnet *ifp)
343 1.33 rtr {
344 1.33 rtr
345 1.33 rtr return EOPNOTSUPP;
346 1.33 rtr }
347 1.33 rtr
348 1.1 gdamore /*
349 1.1 gdamore * User Request.
350 1.1 gdamore * up is socket
351 1.18 rtr * m is optional mbuf chain containing message
352 1.18 rtr * nam is optional mbuf chain containing an address
353 1.1 gdamore * ctl is optional mbuf chain containing socket options
354 1.1 gdamore * l is pointer to process requesting action (if any)
355 1.1 gdamore *
356 1.1 gdamore * we are responsible for disposing of m and ctl if
357 1.1 gdamore * they are mbuf chains
358 1.1 gdamore */
359 1.13 rmind static int
360 1.1 gdamore sco_usrreq(struct socket *up, int req, struct mbuf *m,
361 1.5 christos struct mbuf *nam, struct mbuf *ctl, struct lwp *l)
362 1.1 gdamore {
363 1.33 rtr struct sco_pcb *pcb = up->so_pcb;
364 1.1 gdamore int err = 0;
365 1.1 gdamore
366 1.1 gdamore DPRINTFN(2, "%s\n", prurequests[req]);
367 1.14 rmind KASSERT(req != PRU_ATTACH);
368 1.14 rmind KASSERT(req != PRU_DETACH);
369 1.25 rtr KASSERT(req != PRU_ACCEPT);
370 1.27 rtr KASSERT(req != PRU_BIND);
371 1.27 rtr KASSERT(req != PRU_LISTEN);
372 1.28 rtr KASSERT(req != PRU_CONNECT);
373 1.33 rtr KASSERT(req != PRU_CONNECT2);
374 1.29 rtr KASSERT(req != PRU_DISCONNECT);
375 1.29 rtr KASSERT(req != PRU_SHUTDOWN);
376 1.29 rtr KASSERT(req != PRU_ABORT);
377 1.18 rtr KASSERT(req != PRU_CONTROL);
378 1.20 rtr KASSERT(req != PRU_SENSE);
379 1.24 rtr KASSERT(req != PRU_PEERADDR);
380 1.24 rtr KASSERT(req != PRU_SOCKADDR);
381 1.32 rtr KASSERT(req != PRU_RCVD);
382 1.26 rtr KASSERT(req != PRU_RCVOOB);
383 1.31 rtr KASSERT(req != PRU_SEND);
384 1.26 rtr KASSERT(req != PRU_SENDOOB);
385 1.33 rtr KASSERT(req != PRU_PURGEIF);
386 1.1 gdamore
387 1.1 gdamore /* anything after here *requires* a pcb */
388 1.1 gdamore if (pcb == NULL) {
389 1.1 gdamore err = EINVAL;
390 1.1 gdamore goto release;
391 1.1 gdamore }
392 1.1 gdamore
393 1.1 gdamore switch(req) {
394 1.1 gdamore case PRU_FASTTIMO:
395 1.1 gdamore case PRU_SLOWTIMO:
396 1.1 gdamore case PRU_PROTORCV:
397 1.1 gdamore case PRU_PROTOSEND:
398 1.1 gdamore err = EOPNOTSUPP;
399 1.1 gdamore break;
400 1.1 gdamore
401 1.1 gdamore default:
402 1.1 gdamore UNKNOWN(req);
403 1.1 gdamore err = EOPNOTSUPP;
404 1.1 gdamore break;
405 1.1 gdamore }
406 1.1 gdamore
407 1.1 gdamore release:
408 1.1 gdamore if (m) m_freem(m);
409 1.1 gdamore if (ctl) m_freem(ctl);
410 1.1 gdamore return err;
411 1.1 gdamore }
412 1.1 gdamore
413 1.1 gdamore /*
414 1.1 gdamore * get/set socket options
415 1.1 gdamore */
416 1.1 gdamore int
417 1.11 plunky sco_ctloutput(int req, struct socket *so, struct sockopt *sopt)
418 1.1 gdamore {
419 1.1 gdamore struct sco_pcb *pcb = (struct sco_pcb *)so->so_pcb;
420 1.1 gdamore int err = 0;
421 1.1 gdamore
422 1.1 gdamore DPRINTFN(2, "req %s\n", prcorequests[req]);
423 1.1 gdamore
424 1.1 gdamore if (pcb == NULL)
425 1.1 gdamore return EINVAL;
426 1.1 gdamore
427 1.11 plunky if (sopt->sopt_level != BTPROTO_SCO)
428 1.6 plunky return ENOPROTOOPT;
429 1.1 gdamore
430 1.1 gdamore switch(req) {
431 1.1 gdamore case PRCO_GETOPT:
432 1.11 plunky err = sco_getopt(pcb, sopt);
433 1.1 gdamore break;
434 1.1 gdamore
435 1.1 gdamore case PRCO_SETOPT:
436 1.11 plunky err = sco_setopt(pcb, sopt);
437 1.1 gdamore break;
438 1.1 gdamore
439 1.1 gdamore default:
440 1.6 plunky err = ENOPROTOOPT;
441 1.1 gdamore break;
442 1.1 gdamore }
443 1.1 gdamore
444 1.1 gdamore return err;
445 1.1 gdamore }
446 1.1 gdamore
447 1.1 gdamore /*****************************************************************************
448 1.1 gdamore *
449 1.1 gdamore * SCO Protocol socket callbacks
450 1.1 gdamore *
451 1.1 gdamore */
452 1.1 gdamore static void
453 1.1 gdamore sco_connecting(void *arg)
454 1.1 gdamore {
455 1.1 gdamore struct socket *so = arg;
456 1.1 gdamore
457 1.1 gdamore DPRINTF("Connecting\n");
458 1.1 gdamore soisconnecting(so);
459 1.1 gdamore }
460 1.1 gdamore
461 1.1 gdamore static void
462 1.1 gdamore sco_connected(void *arg)
463 1.1 gdamore {
464 1.1 gdamore struct socket *so = arg;
465 1.1 gdamore
466 1.1 gdamore DPRINTF("Connected\n");
467 1.1 gdamore soisconnected(so);
468 1.1 gdamore }
469 1.1 gdamore
470 1.1 gdamore static void
471 1.1 gdamore sco_disconnected(void *arg, int err)
472 1.1 gdamore {
473 1.1 gdamore struct socket *so = arg;
474 1.1 gdamore
475 1.1 gdamore DPRINTF("Disconnected (%d)\n", err);
476 1.1 gdamore
477 1.1 gdamore so->so_error = err;
478 1.1 gdamore soisdisconnected(so);
479 1.1 gdamore }
480 1.1 gdamore
481 1.1 gdamore static void *
482 1.5 christos sco_newconn(void *arg, struct sockaddr_bt *laddr,
483 1.5 christos struct sockaddr_bt *raddr)
484 1.1 gdamore {
485 1.2 tron struct socket *so = arg;
486 1.1 gdamore
487 1.3 plunky DPRINTF("New Connection\n");
488 1.12 rmind so = sonewconn(so, false);
489 1.2 tron if (so == NULL)
490 1.2 tron return NULL;
491 1.2 tron
492 1.2 tron soisconnecting(so);
493 1.2 tron return so->so_pcb;
494 1.1 gdamore }
495 1.1 gdamore
496 1.1 gdamore static void
497 1.1 gdamore sco_complete(void *arg, int num)
498 1.1 gdamore {
499 1.1 gdamore struct socket *so = arg;
500 1.1 gdamore
501 1.1 gdamore while (num-- > 0)
502 1.1 gdamore sbdroprecord(&so->so_snd);
503 1.1 gdamore
504 1.1 gdamore sowwakeup(so);
505 1.1 gdamore }
506 1.1 gdamore
507 1.1 gdamore static void
508 1.9 plunky sco_linkmode(void *arg, int mode)
509 1.9 plunky {
510 1.9 plunky }
511 1.9 plunky
512 1.9 plunky static void
513 1.1 gdamore sco_input(void *arg, struct mbuf *m)
514 1.1 gdamore {
515 1.1 gdamore struct socket *so = arg;
516 1.1 gdamore
517 1.1 gdamore /*
518 1.1 gdamore * since this data is time sensitive, if the buffer
519 1.1 gdamore * is full we just dump data until the latest one
520 1.1 gdamore * will fit.
521 1.1 gdamore */
522 1.1 gdamore
523 1.1 gdamore while (m->m_pkthdr.len > sbspace(&so->so_rcv))
524 1.1 gdamore sbdroprecord(&so->so_rcv);
525 1.1 gdamore
526 1.1 gdamore DPRINTFN(10, "received %d bytes\n", m->m_pkthdr.len);
527 1.1 gdamore
528 1.1 gdamore sbappendrecord(&so->so_rcv, m);
529 1.1 gdamore sorwakeup(so);
530 1.1 gdamore }
531 1.13 rmind
532 1.17 rmind PR_WRAP_USRREQS(sco)
533 1.13 rmind
534 1.17 rmind #define sco_attach sco_attach_wrapper
535 1.17 rmind #define sco_detach sco_detach_wrapper
536 1.25 rtr #define sco_accept sco_accept_wrapper
537 1.27 rtr #define sco_bind sco_bind_wrapper
538 1.27 rtr #define sco_listen sco_listen_wrapper
539 1.28 rtr #define sco_connect sco_connect_wrapper
540 1.33 rtr #define sco_connect2 sco_connect2_wrapper
541 1.29 rtr #define sco_disconnect sco_disconnect_wrapper
542 1.29 rtr #define sco_shutdown sco_shutdown_wrapper
543 1.29 rtr #define sco_abort sco_abort_wrapper
544 1.18 rtr #define sco_ioctl sco_ioctl_wrapper
545 1.20 rtr #define sco_stat sco_stat_wrapper
546 1.24 rtr #define sco_peeraddr sco_peeraddr_wrapper
547 1.24 rtr #define sco_sockaddr sco_sockaddr_wrapper
548 1.32 rtr #define sco_rcvd sco_rcvd_wrapper
549 1.26 rtr #define sco_recvoob sco_recvoob_wrapper
550 1.31 rtr #define sco_send sco_send_wrapper
551 1.26 rtr #define sco_sendoob sco_sendoob_wrapper
552 1.33 rtr #define sco_purgeif sco_purgeif_wrapper
553 1.13 rmind #define sco_usrreq sco_usrreq_wrapper
554 1.13 rmind
555 1.13 rmind const struct pr_usrreqs sco_usrreqs = {
556 1.16 rmind .pr_attach = sco_attach,
557 1.16 rmind .pr_detach = sco_detach,
558 1.25 rtr .pr_accept = sco_accept,
559 1.27 rtr .pr_bind = sco_bind,
560 1.27 rtr .pr_listen = sco_listen,
561 1.28 rtr .pr_connect = sco_connect,
562 1.33 rtr .pr_connect2 = sco_connect2,
563 1.29 rtr .pr_disconnect = sco_disconnect,
564 1.29 rtr .pr_shutdown = sco_shutdown,
565 1.29 rtr .pr_abort = sco_abort,
566 1.18 rtr .pr_ioctl = sco_ioctl,
567 1.20 rtr .pr_stat = sco_stat,
568 1.24 rtr .pr_peeraddr = sco_peeraddr,
569 1.24 rtr .pr_sockaddr = sco_sockaddr,
570 1.32 rtr .pr_rcvd = sco_rcvd,
571 1.26 rtr .pr_recvoob = sco_recvoob,
572 1.31 rtr .pr_send = sco_send,
573 1.26 rtr .pr_sendoob = sco_sendoob,
574 1.33 rtr .pr_purgeif = sco_purgeif,
575 1.13 rmind .pr_generic = sco_usrreq,
576 1.13 rmind };
577