source: rtems/cpukit/libnetworking/netinet/udp_usrreq.c @ dd967330

4.104.114.95
Last change on this file since dd967330 was dd967330, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/01/08 at 06:36:17

Stop using old-style function definitions.

  • Property mode set to 100644
File size: 17.4 KB
Line 
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
3 *      The Regents of the University of California.  All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 *    may be used to endorse or promote products derived from this software
15 *    without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 *      @(#)udp_usrreq.c        8.6 (Berkeley) 5/23/95
30 * $FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.170 2004/11/08 14:44:53 phk Exp $
31 */
32
33#include <sys/param.h>
34#include <rtems/bsd/sys/queue.h>
35#include <sys/systm.h>
36#include <sys/malloc.h>
37#include <sys/mbuf.h>
38#include <sys/protosw.h>
39#include <sys/socket.h>
40#include <sys/socketvar.h>
41#include <sys/errno.h>
42#include <sys/stat.h>
43#include <sys/kernel.h>
44#include <sys/sysctl.h>
45#include <sys/syslog.h>
46
47#include <net/if.h>
48#include <net/route.h>
49
50#include <netinet/in.h>
51#include <netinet/in_systm.h>
52#include <netinet/ip.h>
53#include <netinet/in_pcb.h>
54#include <netinet/in_var.h>
55#include <netinet/ip_var.h>
56#include <netinet/ip_icmp.h>
57#include <netinet/udp.h>
58#include <netinet/udp_var.h>
59
60/*
61 * UDP protocol implementation.
62 * Per RFC 768, August, 1980.
63 */
64#ifndef COMPAT_42
65static int      udpcksum = 1;
66#else
67static int      udpcksum = 0;           /* XXX */
68#endif
69SYSCTL_INT(_net_inet_udp, UDPCTL_CHECKSUM, checksum, CTLFLAG_RW,
70                &udpcksum, 0, "");
71
72static int log_in_vain = 0;
73SYSCTL_INT(_net_inet_udp, OID_AUTO, log_in_vain, CTLFLAG_RW,
74        &log_in_vain, 0, "");
75
76struct  inpcbhead udb;          /* from udp_var.h */
77struct  inpcbinfo udbinfo;
78
79#ifndef UDBHASHSIZE
80#define UDBHASHSIZE 64
81#endif
82
83       struct   udpstat udpstat;        /* from udp_var.h */
84SYSCTL_STRUCT(_net_inet_udp, UDPCTL_STATS, stats, CTLFLAG_RD,
85        &udpstat, udpstat, "");
86
87static struct   sockaddr_in udp_in = { sizeof(udp_in), AF_INET };
88
89static  void udp_detach(struct inpcb *);
90static  int udp_output(struct inpcb *, struct mbuf *, struct mbuf *,
91                            struct mbuf *);
92static  void udp_notify(struct inpcb *, int);
93
94void
95udp_init(void)
96{
97        LIST_INIT(&udb);
98        udbinfo.listhead = &udb;
99        udbinfo.hashbase = hashinit(UDBHASHSIZE, M_PCB, &udbinfo.hashmask);
100}
101
102void
103udp_input(struct mbuf *m, int iphlen)
104{
105        register struct ip *ip;
106        register struct udphdr *uh;
107        register struct inpcb *inp;
108        struct mbuf *opts = 0;
109        int len;
110        struct ip save_ip;
111
112        udpstat.udps_ipackets++;
113
114        /*
115         * Strip IP options, if any; should skip this,
116         * make available to user, and use on returned packets,
117         * but we don't yet have a way to check the checksum
118         * with options still present.
119         */
120        if (iphlen > sizeof (struct ip)) {
121                ip_stripoptions(m, (struct mbuf *)0);
122                iphlen = sizeof(struct ip);
123        }
124
125        /*
126         * Get IP and UDP header together in first mbuf.
127         */
128        ip = mtod(m, struct ip *);
129        if (m->m_len < iphlen + sizeof(struct udphdr)) {
130                if ((m = m_pullup(m, iphlen + sizeof(struct udphdr))) == 0) {
131                        udpstat.udps_hdrops++;
132                        return;
133                }
134                ip = mtod(m, struct ip *);
135        }
136        uh = (struct udphdr *)((caddr_t)ip + iphlen);
137
138        /*
139         * Make mbuf data length reflect UDP length.
140         * If not enough data to reflect UDP length, drop.
141         */
142        len = ntohs((u_short)uh->uh_ulen);
143        if (ip->ip_len != len) {
144                if (len > ip->ip_len || len < sizeof(struct udphdr)) {
145                        udpstat.udps_badlen++;
146                        goto bad;
147                }
148                m_adj(m, len - ip->ip_len);
149                /* ip->ip_len = len; */
150        }
151        /*
152         * Save a copy of the IP header in case we want restore it
153         * for sending an ICMP error message in response.
154         */
155        save_ip = *ip;
156
157        /*
158         * Checksum extended UDP header and data.
159         */
160        if (uh->uh_sum) {
161                ((struct ipovly *)ip)->ih_next = 0;
162                ((struct ipovly *)ip)->ih_prev = 0;
163                ((struct ipovly *)ip)->ih_x1 = 0;
164                ((struct ipovly *)ip)->ih_len = uh->uh_ulen;
165                uh->uh_sum = in_cksum(m, len + sizeof (struct ip));
166                if (uh->uh_sum) {
167                        udpstat.udps_badsum++;
168                        m_freem(m);
169                        return;
170                }
171        }
172
173        if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) ||
174            in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif)) {
175                struct inpcb *last;
176                /*
177                 * Deliver a multicast or broadcast datagram to *all* sockets
178                 * for which the local and remote addresses and ports match
179                 * those of the incoming datagram.  This allows more than
180                 * one process to receive multi/broadcasts on the same port.
181                 * (This really ought to be done for unicast datagrams as
182                 * well, but that would cause problems with existing
183                 * applications that open both address-specific sockets and
184                 * a wildcard socket listening to the same port -- they would
185                 * end up receiving duplicates of every unicast datagram.
186                 * Those applications open the multiple sockets to overcome an
187                 * inadequacy of the UDP socket interface, but for backwards
188                 * compatibility we avoid the problem here rather than
189                 * fixing the interface.  Maybe 4.5BSD will remedy this?)
190                 */
191
192                /*
193                 * Construct sockaddr format source address.
194                 */
195                udp_in.sin_port = uh->uh_sport;
196                udp_in.sin_addr = ip->ip_src;
197                m->m_len -= sizeof (struct udpiphdr);
198                m->m_data += sizeof (struct udpiphdr);
199                /*
200                 * Locate pcb(s) for datagram.
201                 * (Algorithm copied from raw_intr().)
202                 */
203                last = NULL;
204                for (inp = udb.lh_first; inp != NULL; inp = inp->inp_list.le_next) {
205                        if (inp->inp_lport != uh->uh_dport)
206                                continue;
207                        if (inp->inp_laddr.s_addr != INADDR_ANY) {
208                                if (inp->inp_laddr.s_addr !=
209                                    ip->ip_dst.s_addr)
210                                        continue;
211                        }
212                        if (inp->inp_faddr.s_addr != INADDR_ANY) {
213                                if (inp->inp_faddr.s_addr !=
214                                    ip->ip_src.s_addr ||
215                                    inp->inp_fport != uh->uh_sport)
216                                        continue;
217                        }
218
219                        if (last != NULL) {
220                                struct mbuf *n;
221
222                                if ((n = m_copy(m, 0, M_COPYALL)) != NULL) {
223                                        if (last->inp_flags & INP_CONTROLOPTS
224                                            || last->inp_socket->so_options & SO_TIMESTAMP)
225                                                ip_savecontrol(last, &opts, ip, n);
226                                        if (sbappendaddr(&last->inp_socket->so_rcv,
227                                                (struct sockaddr *)&udp_in,
228                                                n, opts) == 0) {
229                                                m_freem(n);
230                                                if (opts)
231                                                    m_freem(opts);
232                                                udpstat.udps_fullsock++;
233                                        } else
234                                                sorwakeup(last->inp_socket);
235                                        opts = 0;
236                                }
237                        }
238                        last = inp;
239                        /*
240                         * Don't look for additional matches if this one does
241                         * not have either the SO_REUSEPORT or SO_REUSEADDR
242                         * socket options set.  This heuristic avoids searching
243                         * through all pcbs in the common case of a non-shared
244                         * port.  It * assumes that an application will never
245                         * clear these options after setting them.
246                         */
247                        if (((last->inp_socket->so_options&(SO_REUSEPORT|SO_REUSEADDR)) == 0))
248                                break;
249                }
250
251                if (last == NULL) {
252                        /*
253                         * No matching pcb found; discard datagram.
254                         * (No need to send an ICMP Port Unreachable
255                         * for a broadcast or multicast datgram.)
256                         */
257                        udpstat.udps_noportbcast++;
258                        goto bad;
259                }
260                if (last->inp_flags & INP_CONTROLOPTS
261                    || last->inp_socket->so_options & SO_TIMESTAMP)
262                        ip_savecontrol(last, &opts, ip, m);
263                if (sbappendaddr(&last->inp_socket->so_rcv,
264                     (struct sockaddr *)&udp_in,
265                     m, opts) == 0) {
266                        udpstat.udps_fullsock++;
267                        goto bad;
268                }
269                sorwakeup(last->inp_socket);
270                return;
271        }
272        /*
273         * Locate pcb for datagram.
274         */
275        inp = in_pcblookuphash(&udbinfo, ip->ip_src, uh->uh_sport,
276            ip->ip_dst, uh->uh_dport, 1);
277        if (inp == NULL) {
278                if (log_in_vain) {
279                        char buf[4*sizeof "123"];
280
281                        strcpy(buf, inet_ntoa(ip->ip_dst));
282                        log(LOG_INFO, "Connection attempt to UDP %s:%d"
283                            " from %s:%d\n",
284                                buf, ntohs(uh->uh_dport),
285                                inet_ntoa(ip->ip_src), ntohs(uh->uh_sport));
286                }
287                udpstat.udps_noport++;
288                if (m->m_flags & (M_BCAST | M_MCAST)) {
289                        udpstat.udps_noportbcast++;
290                        goto bad;
291                }
292                *ip = save_ip;
293                icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0);
294                return;
295        }
296
297        /*
298         * Construct sockaddr format source address.
299         * Stuff source address and datagram in user buffer.
300         */
301        udp_in.sin_port = uh->uh_sport;
302        udp_in.sin_addr = ip->ip_src;
303        if (inp->inp_flags & INP_CONTROLOPTS
304            || inp->inp_socket->so_options & SO_TIMESTAMP)
305                ip_savecontrol(inp, &opts, ip, m);
306        iphlen += sizeof(struct udphdr);
307        m->m_len -= iphlen;
308        m->m_pkthdr.len -= iphlen;
309        m->m_data += iphlen;
310        if (sbappendaddr(&inp->inp_socket->so_rcv, (struct sockaddr *)&udp_in,
311            m, opts) == 0) {
312                udpstat.udps_fullsock++;
313                goto bad;
314        }
315        sorwakeup(inp->inp_socket);
316        return;
317bad:
318        m_freem(m);
319        if (opts)
320                m_freem(opts);
321}
322
323/*
324 * Notify a udp user of an asynchronous error;
325 * just wake up so that he can collect error status.
326 */
327static void
328udp_notify(struct inpcb *inp, int errnum)
329{
330        inp->inp_socket->so_error = errnum;
331        sorwakeup(inp->inp_socket);
332        sowwakeup(inp->inp_socket);
333}
334
335void
336udp_ctlinput(int cmd, struct sockaddr *sa, void *vip)
337{
338        register struct ip *ip = vip;
339        register struct udphdr *uh;
340
341        if (!PRC_IS_REDIRECT(cmd) &&
342            ((unsigned)cmd >= PRC_NCMDS || inetctlerrmap[cmd] == 0))
343                return;
344        if (ip) {
345                uh = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2));
346                in_pcbnotify(&udb, sa, uh->uh_dport, ip->ip_src, uh->uh_sport,
347                        cmd, udp_notify);
348        } else
349                in_pcbnotify(&udb, sa, 0, zeroin_addr, 0, cmd, udp_notify);
350}
351
352static int
353udp_output(struct inpcb *inp, struct mbuf *m, struct mbuf *addr,
354    struct mbuf *control)
355{
356        register struct udpiphdr *ui;
357        register int len = m->m_pkthdr.len;
358        struct in_addr laddr;
359        int s = 0, error = 0;
360
361        laddr.s_addr = 0;
362        if (control)
363                m_freem(control);               /* XXX */
364
365        if (len + sizeof(struct udpiphdr) > IP_MAXPACKET) {
366                error = EMSGSIZE;
367                goto release;
368        }
369
370        if (addr) {
371                laddr = inp->inp_laddr;
372                if (inp->inp_faddr.s_addr != INADDR_ANY) {
373                        error = EISCONN;
374                        goto release;
375                }
376                /*
377                 * Must block input while temporarily connected.
378                 */
379                s = splnet();
380                error = in_pcbconnect(inp, addr);
381                if (error) {
382                        splx(s);
383                        goto release;
384                }
385        } else {
386                if (inp->inp_faddr.s_addr == INADDR_ANY) {
387                        error = ENOTCONN;
388                        goto release;
389                }
390        }
391        /*
392         * Calculate data length and get a mbuf
393         * for UDP and IP headers.
394         */
395        M_PREPEND(m, sizeof(struct udpiphdr), M_DONTWAIT);
396        if (m == 0) {
397                error = ENOBUFS;
398                if (addr)
399                        splx(s);
400                goto release;
401        }
402
403        /*
404         * Fill in mbuf with extended UDP header
405         * and addresses and length put into network format.
406         */
407        ui = mtod(m, struct udpiphdr *);
408        ui->ui_next = ui->ui_prev = 0;
409        ui->ui_x1 = 0;
410        ui->ui_pr = IPPROTO_UDP;
411        ui->ui_len = htons((u_short)len + sizeof (struct udphdr));
412        ui->ui_src = inp->inp_laddr;
413        ui->ui_dst = inp->inp_faddr;
414        ui->ui_sport = inp->inp_lport;
415        ui->ui_dport = inp->inp_fport;
416        ui->ui_ulen = ui->ui_len;
417
418        /*
419         * Stuff checksum and output datagram.
420         */
421        ui->ui_sum = 0;
422        if (udpcksum) {
423            if ((ui->ui_sum = in_cksum(m, sizeof (struct udpiphdr) + len)) == 0)
424                ui->ui_sum = 0xffff;
425        }
426        ((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len;
427        ((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl;    /* XXX */
428        ((struct ip *)ui)->ip_tos = inp->inp_ip_tos;    /* XXX */
429        udpstat.udps_opackets++;
430        error = ip_output(m, inp->inp_options, &inp->inp_route,
431            inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST),
432            inp->inp_moptions);
433
434        if (addr) {
435                in_pcbdisconnect(inp);
436                inp->inp_laddr = laddr;
437                splx(s);
438        }
439        return (error);
440
441release:
442        m_freem(m);
443        return (error);
444}
445
446#ifdef __rtems__
447#define INP_INFO_RLOCK(a)
448#define INP_INFO_RUNLOCK(a)
449#define INP_LOCK(a)
450#define INP_UNLOCK(a)
451#endif
452
453static int
454udp_pcblist(SYSCTL_HANDLER_ARGS)
455{
456        int error, i, n, s;
457        struct inpcb *inp, **inp_list;
458        inp_gen_t gencnt;
459        struct xinpgen xig;
460
461        /*
462         * The process of preparing the TCB list is too time-consuming and
463         * resource-intensive to repeat twice on every request.
464         */
465        if (req->oldptr == 0) {
466                n = udbinfo.ipi_count;
467                req->oldidx = 2 * (sizeof xig)
468                        + (n + n/8) * sizeof(struct xinpcb);
469                return 0;
470        }
471
472        if (req->newptr != 0)
473                return EPERM;
474
475        /*
476         * OK, now we're committed to doing something.
477         */
478        s = splnet();
479        gencnt = udbinfo.ipi_gencnt;
480        n = udbinfo.ipi_count;
481        splx(s);
482
483        sysctl_wire_old_buffer(req, 2 * (sizeof xig)
484                + n * sizeof(struct xinpcb));
485
486        xig.xig_len = sizeof xig;
487        xig.xig_count = n;
488        xig.xig_gen = gencnt;
489#if 0
490        xig.xig_sogen = so_gencnt;
491#endif
492        error = SYSCTL_OUT(req, &xig, sizeof xig);
493        if (error)
494                return error;
495
496  /* ccj add the exit if count is 0 */
497  if (!n)
498    return error;
499 
500        inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK);
501        if (inp_list == 0)
502                return ENOMEM;
503       
504        s = splnet();
505        INP_INFO_RLOCK(&udbinfo);
506        for (inp = LIST_FIRST(udbinfo.listhead), i = 0; inp && i < n;
507             inp = LIST_NEXT(inp, inp_list)) {
508                INP_LOCK(inp);
509                if (inp->inp_gencnt <= gencnt)
510#if 0
511      &&
512                    cr_canseesocket(req->td->td_ucred, inp->inp_socket) == 0)
513#endif
514                        inp_list[i++] = inp;
515                INP_UNLOCK(inp);
516        }
517        INP_INFO_RUNLOCK(&udbinfo);
518        splx(s);
519        n = i;
520
521        error = 0;
522        for (i = 0; i < n; i++) {
523                inp = inp_list[i];
524                INP_LOCK(inp);
525                if (inp->inp_gencnt <= gencnt) {
526                        struct xinpcb xi;
527                        xi.xi_len = sizeof xi;
528                        /* XXX should avoid extra copy */
529                        bcopy(inp, &xi.xi_inp, sizeof *inp);
530#if 0
531                        if (inp->inp_socket)
532                                sotoxsocket(inp->inp_socket, &xi.xi_socket);
533#endif
534                        error = SYSCTL_OUT(req, &xi, sizeof xi);
535                }
536                INP_UNLOCK(inp);
537        }
538        if (!error) {
539                /*
540                 * Give the user an updated idea of our state.
541                 * If the generation differs from what we told
542                 * her before, she knows that something happened
543                 * while we were processing this request, and it
544                 * might be necessary to retry.
545                 */
546                s = splnet();
547                INP_INFO_RLOCK(&udbinfo);
548                xig.xig_gen = udbinfo.ipi_gencnt;
549#if 0
550                xig.xig_sogen = so_gencnt;
551#endif
552                xig.xig_count = udbinfo.ipi_count;
553                INP_INFO_RUNLOCK(&udbinfo);
554                splx(s);
555                error = SYSCTL_OUT(req, &xig, sizeof xig);
556        }
557        free(inp_list, M_TEMP);
558        return error;
559}
560
561SYSCTL_PROC(_net_inet_udp, UDPCTL_PCBLIST, pcblist, CTLFLAG_RD, 0, 0,
562            udp_pcblist, "S,xinpcb", "List of active UDP sockets");
563
564static u_long   udp_sendspace = 9216;           /* really max datagram size */
565                                        /* 40 1K datagrams */
566SYSCTL_INT(_net_inet_udp, UDPCTL_MAXDGRAM, maxdgram, CTLFLAG_RW,
567        &udp_sendspace, 0, "");
568
569static u_long   udp_recvspace = 40 * (1024 + sizeof(struct sockaddr_in));
570SYSCTL_INT(_net_inet_udp, UDPCTL_RECVSPACE, recvspace, CTLFLAG_RW,
571        &udp_recvspace, 0, "");
572
573#if defined(__rtems__)
574void rtems_set_udp_buffer_sizes(u_long sendspace, u_long recvspace)
575{
576    if ( sendspace != 0 )
577      udp_sendspace = sendspace;
578    if ( recvspace != 0 )
579      udp_recvspace = recvspace;
580}
581#endif
582
583/*ARGSUSED*/
584int
585udp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr,
586    struct mbuf *control)
587{
588        struct inpcb *inp = sotoinpcb(so);
589        int error = 0;
590        int s;
591
592        if (req == PRU_CONTROL)
593                return (in_control(so, (u_long)m, (caddr_t)addr,
594                        (struct ifnet *)control));
595        if (inp == NULL && req != PRU_ATTACH) {
596                error = EINVAL;
597                goto release;
598        }
599        /*
600         * Note: need to block udp_input while changing
601         * the udp pcb queue and/or pcb addresses.
602         */
603        switch (req) {
604
605        case PRU_ATTACH:
606                if (inp != NULL) {
607                        error = EINVAL;
608                        break;
609                }
610                s = splnet();
611                error = in_pcballoc(so, &udbinfo);
612                splx(s);
613                if (error)
614                        break;
615                error = soreserve(so, udp_sendspace, udp_recvspace);
616                if (error)
617                        break;
618                ((struct inpcb *) so->so_pcb)->inp_ip_ttl = ip_defttl;
619                break;
620
621        case PRU_DETACH:
622                udp_detach(inp);
623                break;
624
625        case PRU_BIND:
626                s = splnet();
627                error = in_pcbbind(inp, addr);
628                splx(s);
629                break;
630
631        case PRU_LISTEN:
632                error = EOPNOTSUPP;
633                break;
634
635        case PRU_CONNECT:
636                if (inp->inp_faddr.s_addr != INADDR_ANY) {
637                        error = EISCONN;
638                        break;
639                }
640                s = splnet();
641                error = in_pcbconnect(inp, addr);
642                splx(s);
643                if (error == 0)
644                        soisconnected(so);
645                break;
646
647        case PRU_CONNECT2:
648                error = EOPNOTSUPP;
649                break;
650
651        case PRU_ACCEPT:
652                error = EOPNOTSUPP;
653                break;
654
655        case PRU_DISCONNECT:
656                if (inp->inp_faddr.s_addr == INADDR_ANY) {
657                        error = ENOTCONN;
658                        break;
659                }
660                s = splnet();
661                in_pcbdisconnect(inp);
662                inp->inp_laddr.s_addr = INADDR_ANY;
663                splx(s);
664                so->so_state &= ~SS_ISCONNECTED;                /* XXX */
665                break;
666
667        case PRU_SHUTDOWN:
668                socantsendmore(so);
669                break;
670
671        case PRU_SEND:
672                return (udp_output(inp, m, addr, control));
673
674        case PRU_ABORT:
675                soisdisconnected(so);
676                udp_detach(inp);
677                break;
678
679        case PRU_SOCKADDR:
680                in_setsockaddr(inp, addr);
681                break;
682
683        case PRU_PEERADDR:
684                in_setpeeraddr(inp, addr);
685                break;
686
687        case PRU_SENSE:
688                /*
689                 * stat: don't bother with a blocksize.
690                 */
691                return (0);
692
693        case PRU_SENDOOB:
694        case PRU_FASTTIMO:
695        case PRU_SLOWTIMO:
696        case PRU_PROTORCV:
697        case PRU_PROTOSEND:
698                error =  EOPNOTSUPP;
699                break;
700
701        case PRU_RCVD:
702        case PRU_RCVOOB:
703                return (EOPNOTSUPP);    /* do not free mbuf's */
704
705        default:
706                panic("udp_usrreq");
707        }
708
709release:
710        if (control) {
711                printf("udp control data unexpectedly retained\n");
712                m_freem(control);
713        }
714        if (m)
715                m_freem(m);
716        return (error);
717}
718
719static void
720udp_detach(struct inpcb *inp)
721{
722        int s = splnet();
723
724        in_pcbdetach(inp);
725        splx(s);
726}
Note: See TracBrowser for help on using the repository browser.