source: rtems/cpukit/libnetworking/netinet/udp_usrreq.c @ 751c513

4.104.114.84.95
Last change on this file since 751c513 was 751c513, checked in by Ralf Corsepius <ralf.corsepius@…>, on 12/03/04 at 05:07:56

2004-12-03 Ralf Corsepius <ralf.corsepius@…>

  • libnetworking/net/if_ethersubr.c, libnetworking/net/radix.h, libnetworking/netinet/if_ether.h, libnetworking/netinet/igmp_var.h, libnetworking/netinet/in_var.h, libnetworking/netinet/tcp_timer.h, libnetworking/netinet/udp_usrreq.c, libnetworking/rtems/rtems_glue.c: Misc. updates from FreeBSD and bugfixes tripped by GCC-4.0.0.
  • Property mode set to 100644
File size: 17.2 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 <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 __P((struct inpcb *));
90static  int udp_output __P((struct inpcb *, struct mbuf *, struct mbuf *,
91                            struct mbuf *));
92static  void udp_notify __P((struct inpcb *, int));
93
94void
95udp_init()
96{
97        LIST_INIT(&udb);
98        udbinfo.listhead = &udb;
99        udbinfo.hashbase = hashinit(UDBHASHSIZE, M_PCB, &udbinfo.hashmask);
100}
101
102void
103udp_input(m, iphlen)
104        register struct mbuf *m;
105        int iphlen;
106{
107        register struct ip *ip;
108        register struct udphdr *uh;
109        register struct inpcb *inp;
110        struct mbuf *opts = 0;
111        int len;
112        struct ip save_ip;
113
114        udpstat.udps_ipackets++;
115
116        /*
117         * Strip IP options, if any; should skip this,
118         * make available to user, and use on returned packets,
119         * but we don't yet have a way to check the checksum
120         * with options still present.
121         */
122        if (iphlen > sizeof (struct ip)) {
123                ip_stripoptions(m, (struct mbuf *)0);
124                iphlen = sizeof(struct ip);
125        }
126
127        /*
128         * Get IP and UDP header together in first mbuf.
129         */
130        ip = mtod(m, struct ip *);
131        if (m->m_len < iphlen + sizeof(struct udphdr)) {
132                if ((m = m_pullup(m, iphlen + sizeof(struct udphdr))) == 0) {
133                        udpstat.udps_hdrops++;
134                        return;
135                }
136                ip = mtod(m, struct ip *);
137        }
138        uh = (struct udphdr *)((caddr_t)ip + iphlen);
139
140        /*
141         * Make mbuf data length reflect UDP length.
142         * If not enough data to reflect UDP length, drop.
143         */
144        len = ntohs((u_short)uh->uh_ulen);
145        if (ip->ip_len != len) {
146                if (len > ip->ip_len || len < sizeof(struct udphdr)) {
147                        udpstat.udps_badlen++;
148                        goto bad;
149                }
150                m_adj(m, len - ip->ip_len);
151                /* ip->ip_len = len; */
152        }
153        /*
154         * Save a copy of the IP header in case we want restore it
155         * for sending an ICMP error message in response.
156         */
157        save_ip = *ip;
158
159        /*
160         * Checksum extended UDP header and data.
161         */
162        if (uh->uh_sum) {
163                ((struct ipovly *)ip)->ih_next = 0;
164                ((struct ipovly *)ip)->ih_prev = 0;
165                ((struct ipovly *)ip)->ih_x1 = 0;
166                ((struct ipovly *)ip)->ih_len = uh->uh_ulen;
167                uh->uh_sum = in_cksum(m, len + sizeof (struct ip));
168                if (uh->uh_sum) {
169                        udpstat.udps_badsum++;
170                        m_freem(m);
171                        return;
172                }
173        }
174
175        if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) ||
176            in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif)) {
177                struct inpcb *last;
178                /*
179                 * Deliver a multicast or broadcast datagram to *all* sockets
180                 * for which the local and remote addresses and ports match
181                 * those of the incoming datagram.  This allows more than
182                 * one process to receive multi/broadcasts on the same port.
183                 * (This really ought to be done for unicast datagrams as
184                 * well, but that would cause problems with existing
185                 * applications that open both address-specific sockets and
186                 * a wildcard socket listening to the same port -- they would
187                 * end up receiving duplicates of every unicast datagram.
188                 * Those applications open the multiple sockets to overcome an
189                 * inadequacy of the UDP socket interface, but for backwards
190                 * compatibility we avoid the problem here rather than
191                 * fixing the interface.  Maybe 4.5BSD will remedy this?)
192                 */
193
194                /*
195                 * Construct sockaddr format source address.
196                 */
197                udp_in.sin_port = uh->uh_sport;
198                udp_in.sin_addr = ip->ip_src;
199                m->m_len -= sizeof (struct udpiphdr);
200                m->m_data += sizeof (struct udpiphdr);
201                /*
202                 * Locate pcb(s) for datagram.
203                 * (Algorithm copied from raw_intr().)
204                 */
205                last = NULL;
206                for (inp = udb.lh_first; inp != NULL; inp = inp->inp_list.le_next) {
207                        if (inp->inp_lport != uh->uh_dport)
208                                continue;
209                        if (inp->inp_laddr.s_addr != INADDR_ANY) {
210                                if (inp->inp_laddr.s_addr !=
211                                    ip->ip_dst.s_addr)
212                                        continue;
213                        }
214                        if (inp->inp_faddr.s_addr != INADDR_ANY) {
215                                if (inp->inp_faddr.s_addr !=
216                                    ip->ip_src.s_addr ||
217                                    inp->inp_fport != uh->uh_sport)
218                                        continue;
219                        }
220
221                        if (last != NULL) {
222                                struct mbuf *n;
223
224                                if ((n = m_copy(m, 0, M_COPYALL)) != NULL) {
225                                        if (last->inp_flags & INP_CONTROLOPTS
226                                            || last->inp_socket->so_options & SO_TIMESTAMP)
227                                                ip_savecontrol(last, &opts, ip, n);
228                                        if (sbappendaddr(&last->inp_socket->so_rcv,
229                                                (struct sockaddr *)&udp_in,
230                                                n, opts) == 0) {
231                                                m_freem(n);
232                                                if (opts)
233                                                    m_freem(opts);
234                                                udpstat.udps_fullsock++;
235                                        } else
236                                                sorwakeup(last->inp_socket);
237                                        opts = 0;
238                                }
239                        }
240                        last = inp;
241                        /*
242                         * Don't look for additional matches if this one does
243                         * not have either the SO_REUSEPORT or SO_REUSEADDR
244                         * socket options set.  This heuristic avoids searching
245                         * through all pcbs in the common case of a non-shared
246                         * port.  It * assumes that an application will never
247                         * clear these options after setting them.
248                         */
249                        if (((last->inp_socket->so_options&(SO_REUSEPORT|SO_REUSEADDR)) == 0))
250                                break;
251                }
252
253                if (last == NULL) {
254                        /*
255                         * No matching pcb found; discard datagram.
256                         * (No need to send an ICMP Port Unreachable
257                         * for a broadcast or multicast datgram.)
258                         */
259                        udpstat.udps_noportbcast++;
260                        goto bad;
261                }
262                if (last->inp_flags & INP_CONTROLOPTS
263                    || last->inp_socket->so_options & SO_TIMESTAMP)
264                        ip_savecontrol(last, &opts, ip, m);
265                if (sbappendaddr(&last->inp_socket->so_rcv,
266                     (struct sockaddr *)&udp_in,
267                     m, opts) == 0) {
268                        udpstat.udps_fullsock++;
269                        goto bad;
270                }
271                sorwakeup(last->inp_socket);
272                return;
273        }
274        /*
275         * Locate pcb for datagram.
276         */
277        inp = in_pcblookuphash(&udbinfo, ip->ip_src, uh->uh_sport,
278            ip->ip_dst, uh->uh_dport, 1);
279        if (inp == NULL) {
280                if (log_in_vain) {
281                        char buf[4*sizeof "123"];
282
283                        strcpy(buf, inet_ntoa(ip->ip_dst));
284                        log(LOG_INFO, "Connection attempt to UDP %s:%d"
285                            " from %s:%d\n",
286                                buf, ntohs(uh->uh_dport),
287                                inet_ntoa(ip->ip_src), ntohs(uh->uh_sport));
288                }
289                udpstat.udps_noport++;
290                if (m->m_flags & (M_BCAST | M_MCAST)) {
291                        udpstat.udps_noportbcast++;
292                        goto bad;
293                }
294                *ip = save_ip;
295                icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0);
296                return;
297        }
298
299        /*
300         * Construct sockaddr format source address.
301         * Stuff source address and datagram in user buffer.
302         */
303        udp_in.sin_port = uh->uh_sport;
304        udp_in.sin_addr = ip->ip_src;
305        if (inp->inp_flags & INP_CONTROLOPTS
306            || inp->inp_socket->so_options & SO_TIMESTAMP)
307                ip_savecontrol(inp, &opts, ip, m);
308        iphlen += sizeof(struct udphdr);
309        m->m_len -= iphlen;
310        m->m_pkthdr.len -= iphlen;
311        m->m_data += iphlen;
312        if (sbappendaddr(&inp->inp_socket->so_rcv, (struct sockaddr *)&udp_in,
313            m, opts) == 0) {
314                udpstat.udps_fullsock++;
315                goto bad;
316        }
317        sorwakeup(inp->inp_socket);
318        return;
319bad:
320        m_freem(m);
321        if (opts)
322                m_freem(opts);
323}
324
325/*
326 * Notify a udp user of an asynchronous error;
327 * just wake up so that he can collect error status.
328 */
329static void
330udp_notify(inp, errnum)
331        register struct inpcb *inp;
332        int errnum;
333{
334        inp->inp_socket->so_error = errnum;
335        sorwakeup(inp->inp_socket);
336        sowwakeup(inp->inp_socket);
337}
338
339void
340udp_ctlinput(cmd, sa, vip)
341        int cmd;
342        struct sockaddr *sa;
343        void *vip;
344{
345        register struct ip *ip = vip;
346        register struct udphdr *uh;
347
348        if (!PRC_IS_REDIRECT(cmd) &&
349            ((unsigned)cmd >= PRC_NCMDS || inetctlerrmap[cmd] == 0))
350                return;
351        if (ip) {
352                uh = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2));
353                in_pcbnotify(&udb, sa, uh->uh_dport, ip->ip_src, uh->uh_sport,
354                        cmd, udp_notify);
355        } else
356                in_pcbnotify(&udb, sa, 0, zeroin_addr, 0, cmd, udp_notify);
357}
358
359static int
360udp_output(inp, m, addr, control)
361        register struct inpcb *inp;
362        register struct mbuf *m;
363        struct mbuf *addr, *control;
364{
365        register struct udpiphdr *ui;
366        register int len = m->m_pkthdr.len;
367        struct in_addr laddr;
368        int s = 0, error = 0;
369
370        if (control)
371                m_freem(control);               /* XXX */
372
373        if (len + sizeof(struct udpiphdr) > IP_MAXPACKET) {
374                error = EMSGSIZE;
375                goto release;
376        }
377
378        if (addr) {
379                laddr = inp->inp_laddr;
380                if (inp->inp_faddr.s_addr != INADDR_ANY) {
381                        error = EISCONN;
382                        goto release;
383                }
384                /*
385                 * Must block input while temporarily connected.
386                 */
387                s = splnet();
388                error = in_pcbconnect(inp, addr);
389                if (error) {
390                        splx(s);
391                        goto release;
392                }
393        } else {
394                if (inp->inp_faddr.s_addr == INADDR_ANY) {
395                        error = ENOTCONN;
396                        goto release;
397                }
398        }
399        /*
400         * Calculate data length and get a mbuf
401         * for UDP and IP headers.
402         */
403        M_PREPEND(m, sizeof(struct udpiphdr), M_DONTWAIT);
404        if (m == 0) {
405                error = ENOBUFS;
406                if (addr)
407                        splx(s);
408                goto release;
409        }
410
411        /*
412         * Fill in mbuf with extended UDP header
413         * and addresses and length put into network format.
414         */
415        ui = mtod(m, struct udpiphdr *);
416        ui->ui_next = ui->ui_prev = 0;
417        ui->ui_x1 = 0;
418        ui->ui_pr = IPPROTO_UDP;
419        ui->ui_len = htons((u_short)len + sizeof (struct udphdr));
420        ui->ui_src = inp->inp_laddr;
421        ui->ui_dst = inp->inp_faddr;
422        ui->ui_sport = inp->inp_lport;
423        ui->ui_dport = inp->inp_fport;
424        ui->ui_ulen = ui->ui_len;
425
426        /*
427         * Stuff checksum and output datagram.
428         */
429        ui->ui_sum = 0;
430        if (udpcksum) {
431            if ((ui->ui_sum = in_cksum(m, sizeof (struct udpiphdr) + len)) == 0)
432                ui->ui_sum = 0xffff;
433        }
434        ((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len;
435        ((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl;    /* XXX */
436        ((struct ip *)ui)->ip_tos = inp->inp_ip_tos;    /* XXX */
437        udpstat.udps_opackets++;
438        error = ip_output(m, inp->inp_options, &inp->inp_route,
439            inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST),
440            inp->inp_moptions);
441
442        if (addr) {
443                in_pcbdisconnect(inp);
444                inp->inp_laddr = laddr;
445                splx(s);
446        }
447        return (error);
448
449release:
450        m_freem(m);
451        return (error);
452}
453
454#ifdef __rtems__
455#define INP_INFO_RLOCK(a)
456#define INP_INFO_RUNLOCK(a)
457#define INP_LOCK(a)
458#define INP_UNLOCK(a)
459#endif
460
461static int
462udp_pcblist(SYSCTL_HANDLER_ARGS)
463{
464        int error, i, n, s;
465        struct inpcb *inp, **inp_list;
466        inp_gen_t gencnt;
467        struct xinpgen xig;
468
469        /*
470         * The process of preparing the TCB list is too time-consuming and
471         * resource-intensive to repeat twice on every request.
472         */
473        if (req->oldptr == 0) {
474                n = udbinfo.ipi_count;
475                req->oldidx = 2 * (sizeof xig)
476                        + (n + n/8) * sizeof(struct xinpcb);
477                return 0;
478        }
479
480        if (req->newptr != 0)
481                return EPERM;
482
483        /*
484         * OK, now we're committed to doing something.
485         */
486        s = splnet();
487        gencnt = udbinfo.ipi_gencnt;
488        n = udbinfo.ipi_count;
489        splx(s);
490
491        sysctl_wire_old_buffer(req, 2 * (sizeof xig)
492                + n * sizeof(struct xinpcb));
493
494        xig.xig_len = sizeof xig;
495        xig.xig_count = n;
496        xig.xig_gen = gencnt;
497#if 0
498        xig.xig_sogen = so_gencnt;
499#endif
500        error = SYSCTL_OUT(req, &xig, sizeof xig);
501        if (error)
502                return error;
503
504  /* ccj add the exit if count is 0 */
505  if (!n)
506    return error;
507 
508        inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK);
509        if (inp_list == 0)
510                return ENOMEM;
511       
512        s = splnet();
513        INP_INFO_RLOCK(&udbinfo);
514        for (inp = LIST_FIRST(udbinfo.listhead), i = 0; inp && i < n;
515             inp = LIST_NEXT(inp, inp_list)) {
516                INP_LOCK(inp);
517                if (inp->inp_gencnt <= gencnt)
518#if 0
519      &&
520                    cr_canseesocket(req->td->td_ucred, inp->inp_socket) == 0)
521#endif
522                        inp_list[i++] = inp;
523                INP_UNLOCK(inp);
524        }
525        INP_INFO_RUNLOCK(&udbinfo);
526        splx(s);
527        n = i;
528
529        error = 0;
530        for (i = 0; i < n; i++) {
531                inp = inp_list[i];
532                INP_LOCK(inp);
533                if (inp->inp_gencnt <= gencnt) {
534                        struct xinpcb xi;
535                        xi.xi_len = sizeof xi;
536                        /* XXX should avoid extra copy */
537                        bcopy(inp, &xi.xi_inp, sizeof *inp);
538#if 0
539                        if (inp->inp_socket)
540                                sotoxsocket(inp->inp_socket, &xi.xi_socket);
541#endif
542                        error = SYSCTL_OUT(req, &xi, sizeof xi);
543                }
544                INP_UNLOCK(inp);
545        }
546        if (!error) {
547                /*
548                 * Give the user an updated idea of our state.
549                 * If the generation differs from what we told
550                 * her before, she knows that something happened
551                 * while we were processing this request, and it
552                 * might be necessary to retry.
553                 */
554                s = splnet();
555                INP_INFO_RLOCK(&udbinfo);
556                xig.xig_gen = udbinfo.ipi_gencnt;
557#if 0
558                xig.xig_sogen = so_gencnt;
559#endif
560                xig.xig_count = udbinfo.ipi_count;
561                INP_INFO_RUNLOCK(&udbinfo);
562                splx(s);
563                error = SYSCTL_OUT(req, &xig, sizeof xig);
564        }
565        free(inp_list, M_TEMP);
566        return error;
567}
568
569SYSCTL_PROC(_net_inet_udp, UDPCTL_PCBLIST, pcblist, CTLFLAG_RD, 0, 0,
570            udp_pcblist, "S,xinpcb", "List of active UDP sockets");
571
572static u_long   udp_sendspace = 9216;           /* really max datagram size */
573                                        /* 40 1K datagrams */
574SYSCTL_INT(_net_inet_udp, UDPCTL_MAXDGRAM, maxdgram, CTLFLAG_RW,
575        &udp_sendspace, 0, "");
576
577static u_long   udp_recvspace = 40 * (1024 + sizeof(struct sockaddr_in));
578SYSCTL_INT(_net_inet_udp, UDPCTL_RECVSPACE, recvspace, CTLFLAG_RW,
579        &udp_recvspace, 0, "");
580
581/*ARGSUSED*/
582int
583udp_usrreq(so, req, m, addr, control)
584        struct socket *so;
585        int req;
586        struct mbuf *m, *addr, *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(inp)
721        struct inpcb *inp;
722{
723        int s = splnet();
724
725        in_pcbdetach(inp);
726        splx(s);
727}
Note: See TracBrowser for help on using the repository browser.