Annotation of src/sys/netinet/udp_usrreq.c, Revision 1.116.2.3
1.116.2.3! tron 1: /* $NetBSD$ */
1.48 itojun 2:
3: /*
4: * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5: * All rights reserved.
1.94 itojun 6: *
1.48 itojun 7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. Redistributions in binary form must reproduce the above copyright
13: * notice, this list of conditions and the following disclaimer in the
14: * documentation and/or other materials provided with the distribution.
15: * 3. Neither the name of the project nor the names of its contributors
16: * may be used to endorse or promote products derived from this software
17: * without specific prior written permission.
1.94 itojun 18: *
1.48 itojun 19: * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22: * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29: * SUCH DAMAGE.
30: */
1.14 cgd 31:
1.1 cgd 32: /*
1.44 thorpej 33: * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
1.13 mycroft 34: * The Regents of the University of California. All rights reserved.
1.1 cgd 35: *
36: * Redistribution and use in source and binary forms, with or without
37: * modification, are permitted provided that the following conditions
38: * are met:
39: * 1. Redistributions of source code must retain the above copyright
40: * notice, this list of conditions and the following disclaimer.
41: * 2. Redistributions in binary form must reproduce the above copyright
42: * notice, this list of conditions and the following disclaimer in the
43: * documentation and/or other materials provided with the distribution.
1.104 agc 44: * 3. Neither the name of the University nor the names of its contributors
1.1 cgd 45: * may be used to endorse or promote products derived from this software
46: * without specific prior written permission.
47: *
48: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58: * SUCH DAMAGE.
59: *
1.44 thorpej 60: * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
1.1 cgd 61: */
1.91 lukem 62:
63: #include <sys/cdefs.h>
1.116.2.3! tron 64: __KERNEL_RCSID(0, "$NetBSD$");
1.50 thorpej 65:
1.77 soda 66: #include "opt_inet.h"
1.50 thorpej 67: #include "opt_ipsec.h"
1.78 thorpej 68: #include "opt_inet_csum.h"
1.64 ws 69: #include "opt_ipkdb.h"
1.101 martin 70: #include "opt_mbuftrace.h"
1.1 cgd 71:
1.5 mycroft 72: #include <sys/param.h>
73: #include <sys/malloc.h>
74: #include <sys/mbuf.h>
75: #include <sys/protosw.h>
76: #include <sys/socket.h>
77: #include <sys/socketvar.h>
1.13 mycroft 78: #include <sys/errno.h>
1.5 mycroft 79: #include <sys/stat.h>
1.27 christos 80: #include <sys/systm.h>
81: #include <sys/proc.h>
1.53 itojun 82: #include <sys/domain.h>
1.27 christos 83: #include <sys/sysctl.h>
1.1 cgd 84:
1.5 mycroft 85: #include <net/if.h>
86: #include <net/route.h>
1.1 cgd 87:
1.5 mycroft 88: #include <netinet/in.h>
89: #include <netinet/in_systm.h>
1.15 cgd 90: #include <netinet/in_var.h>
1.5 mycroft 91: #include <netinet/ip.h>
92: #include <netinet/in_pcb.h>
93: #include <netinet/ip_var.h>
94: #include <netinet/ip_icmp.h>
95: #include <netinet/udp.h>
96: #include <netinet/udp_var.h>
1.1 cgd 97:
1.53 itojun 98: #ifdef INET6
99: #include <netinet/ip6.h>
100: #include <netinet/icmp6.h>
101: #include <netinet6/ip6_var.h>
102: #include <netinet6/in6_pcb.h>
103: #include <netinet6/udp6_var.h>
104: #endif
105:
106: #ifndef INET6
107: /* always need ip6.h for IP6_EXTHDR_GET */
108: #include <netinet/ip6.h>
109: #endif
110:
1.76 itojun 111: #include "faith.h"
112: #if defined(NFAITH) && NFAITH > 0
113: #include <net/if_faith.h>
114: #endif
115:
1.27 christos 116: #include <machine/stdarg.h>
117:
1.105 jonathan 118: #ifdef FAST_IPSEC
119: #include <netipsec/ipsec.h>
1.116.2.3! tron 120: #include <netipsec/ipsec_var.h> /* XXX ipsecstat namespace */
1.105 jonathan 121: #ifdef INET6
122: #include <netipsec/ipsec6.h>
123: #endif
124: #endif /* FAST_IPSEC*/
125:
1.48 itojun 126: #ifdef IPSEC
127: #include <netinet6/ipsec.h>
128: #include <netkey/key.h>
129: #endif /*IPSEC*/
130:
1.64 ws 131: #ifdef IPKDB
132: #include <ipkdb/ipkdb.h>
133: #endif
134:
1.8 mycroft 135: /*
136: * UDP protocol implementation.
137: * Per RFC 768, August, 1980.
138: */
139: #ifndef COMPAT_42
140: int udpcksum = 1;
141: #else
142: int udpcksum = 0; /* XXX */
143: #endif
1.93 matt 144:
145: struct inpcbtable udbtable;
146: struct udpstat udpstat;
1.8 mycroft 147:
1.72 itojun 148: #ifdef INET
1.53 itojun 149: static void udp4_sendup __P((struct mbuf *, int, struct sockaddr *,
150: struct socket *));
151: static int udp4_realinput __P((struct sockaddr_in *, struct sockaddr_in *,
152: struct mbuf *, int));
1.72 itojun 153: #endif
1.53 itojun 154: #ifdef INET6
155: static void udp6_sendup __P((struct mbuf *, int, struct sockaddr *,
156: struct socket *));
157: static int udp6_realinput __P((int, struct sockaddr_in6 *,
158: struct sockaddr_in6 *, struct mbuf *, int));
159: #endif
1.72 itojun 160: #ifdef INET
1.13 mycroft 161: static void udp_notify __P((struct inpcb *, int));
1.72 itojun 162: #endif
1.7 mycroft 163:
1.26 mycroft 164: #ifndef UDBHASHSIZE
165: #define UDBHASHSIZE 128
166: #endif
167: int udbhashsize = UDBHASHSIZE;
168:
1.98 matt 169: #ifdef MBUFTRACE
170: struct mowner udp_mowner = { "udp" };
171: struct mowner udp_rx_mowner = { "udp", "rx" };
172: struct mowner udp_tx_mowner = { "udp", "tx" };
173: #endif
174:
1.78 thorpej 175: #ifdef UDP_CSUM_COUNTERS
176: #include <sys/device.h>
177:
178: struct evcnt udp_hwcsum_bad = EVCNT_INITIALIZER(EVCNT_TYPE_MISC,
179: NULL, "udp", "hwcsum bad");
180: struct evcnt udp_hwcsum_ok = EVCNT_INITIALIZER(EVCNT_TYPE_MISC,
181: NULL, "udp", "hwcsum ok");
182: struct evcnt udp_hwcsum_data = EVCNT_INITIALIZER(EVCNT_TYPE_MISC,
183: NULL, "udp", "hwcsum data");
184: struct evcnt udp_swcsum = EVCNT_INITIALIZER(EVCNT_TYPE_MISC,
185: NULL, "udp", "swcsum");
186:
187: #define UDP_CSUM_COUNTER_INCR(ev) (ev)->ev_count++
188:
189: #else
190:
191: #define UDP_CSUM_COUNTER_INCR(ev) /* nothing */
192:
193: #endif /* UDP_CSUM_COUNTERS */
194:
1.7 mycroft 195: void
1.1 cgd 196: udp_init()
197: {
1.18 mycroft 198:
1.35 mycroft 199: in_pcbinit(&udbtable, udbhashsize, udbhashsize);
1.78 thorpej 200:
201: #ifdef UDP_CSUM_COUNTERS
202: evcnt_attach_static(&udp_hwcsum_bad);
203: evcnt_attach_static(&udp_hwcsum_ok);
204: evcnt_attach_static(&udp_hwcsum_data);
205: evcnt_attach_static(&udp_swcsum);
206: #endif /* UDP_CSUM_COUNTERS */
1.98 matt 207:
208: MOWNER_ATTACH(&udp_tx_mowner);
209: MOWNER_ATTACH(&udp_rx_mowner);
210: MOWNER_ATTACH(&udp_mowner);
1.1 cgd 211: }
212:
1.72 itojun 213: #ifdef INET
1.7 mycroft 214: void
1.27 christos 215: #if __STDC__
216: udp_input(struct mbuf *m, ...)
217: #else
218: udp_input(m, va_alist)
219: struct mbuf *m;
220: va_dcl
221: #endif
1.1 cgd 222: {
1.53 itojun 223: va_list ap;
224: struct sockaddr_in src, dst;
225: struct ip *ip;
226: struct udphdr *uh;
1.97 simonb 227: int iphlen;
1.53 itojun 228: int len;
229: int n;
1.96 itojun 230: u_int16_t ip_len;
1.53 itojun 231:
232: va_start(ap, m);
233: iphlen = va_arg(ap, int);
1.97 simonb 234: (void)va_arg(ap, int); /* ignore value, advance ap */
1.53 itojun 235: va_end(ap);
236:
1.98 matt 237: MCLAIM(m, &udp_rx_mowner);
1.53 itojun 238: udpstat.udps_ipackets++;
239:
240: /*
241: * Get IP and UDP header together in first mbuf.
242: */
243: ip = mtod(m, struct ip *);
244: IP6_EXTHDR_GET(uh, struct udphdr *, m, iphlen, sizeof(struct udphdr));
245: if (uh == NULL) {
246: udpstat.udps_hdrops++;
247: return;
248: }
1.95 thorpej 249: KASSERT(UDP_HDR_ALIGNED_P(uh));
1.53 itojun 250:
1.57 itojun 251: /* destination port of 0 is illegal, based on RFC768. */
252: if (uh->uh_dport == 0)
253: goto bad;
254:
1.53 itojun 255: /*
256: * Make mbuf data length reflect UDP length.
257: * If not enough data to reflect UDP length, drop.
258: */
1.96 itojun 259: ip_len = ntohs(ip->ip_len);
1.53 itojun 260: len = ntohs((u_int16_t)uh->uh_ulen);
1.96 itojun 261: if (ip_len != iphlen + len) {
262: if (ip_len < iphlen + len || len < sizeof(struct udphdr)) {
1.53 itojun 263: udpstat.udps_badlen++;
264: goto bad;
265: }
1.96 itojun 266: m_adj(m, iphlen + len - ip_len);
1.53 itojun 267: }
268:
269: /*
270: * Checksum extended UDP header and data.
271: */
272: if (uh->uh_sum) {
1.78 thorpej 273: switch (m->m_pkthdr.csum_flags &
1.112 enami 274: ((m->m_pkthdr.rcvif->if_csum_flags_rx & M_CSUM_UDPv4) |
275: M_CSUM_TCP_UDP_BAD | M_CSUM_DATA)) {
1.78 thorpej 276: case M_CSUM_UDPv4|M_CSUM_TCP_UDP_BAD:
277: UDP_CSUM_COUNTER_INCR(&udp_hwcsum_bad);
278: goto badcsum;
279:
1.106 jonathan 280: case M_CSUM_UDPv4|M_CSUM_DATA: {
281: u_int32_t hw_csum = m->m_pkthdr.csum_data;
1.78 thorpej 282: UDP_CSUM_COUNTER_INCR(&udp_hwcsum_data);
1.106 jonathan 283: if (m->m_pkthdr.csum_flags & M_CSUM_NO_PSEUDOHDR)
1.112 enami 284: hw_csum = in_cksum_phdr(ip->ip_src.s_addr,
285: ip->ip_dst.s_addr,
1.115 drochner 286: htons(hw_csum + len + IPPROTO_UDP));
1.106 jonathan 287: if ((hw_csum ^ 0xffff) != 0)
1.78 thorpej 288: goto badcsum;
289: break;
1.106 jonathan 290: }
1.78 thorpej 291:
292: case M_CSUM_UDPv4:
293: /* Checksum was okay. */
294: UDP_CSUM_COUNTER_INCR(&udp_hwcsum_ok);
295: break;
296:
297: default:
298: /* Need to compute it ourselves. */
299: UDP_CSUM_COUNTER_INCR(&udp_swcsum);
300: if (in4_cksum(m, IPPROTO_UDP, iphlen, len) != 0)
301: goto badcsum;
302: break;
1.53 itojun 303: }
304: }
305:
306: /* construct source and dst sockaddrs. */
307: bzero(&src, sizeof(src));
308: src.sin_family = AF_INET;
309: src.sin_len = sizeof(struct sockaddr_in);
310: bcopy(&ip->ip_src, &src.sin_addr, sizeof(src.sin_addr));
311: src.sin_port = uh->uh_sport;
312: bzero(&dst, sizeof(dst));
313: dst.sin_family = AF_INET;
314: dst.sin_len = sizeof(struct sockaddr_in);
315: bcopy(&ip->ip_dst, &dst.sin_addr, sizeof(dst.sin_addr));
316: dst.sin_port = uh->uh_dport;
317:
318: n = udp4_realinput(&src, &dst, m, iphlen);
319: #ifdef INET6
320: if (IN_MULTICAST(ip->ip_dst.s_addr) || n == 0) {
321: struct sockaddr_in6 src6, dst6;
322:
323: bzero(&src6, sizeof(src6));
324: src6.sin6_family = AF_INET6;
325: src6.sin6_len = sizeof(struct sockaddr_in6);
326: src6.sin6_addr.s6_addr[10] = src6.sin6_addr.s6_addr[11] = 0xff;
327: bcopy(&ip->ip_src, &src6.sin6_addr.s6_addr[12],
328: sizeof(ip->ip_src));
329: src6.sin6_port = uh->uh_sport;
330: bzero(&dst6, sizeof(dst6));
331: dst6.sin6_family = AF_INET6;
332: dst6.sin6_len = sizeof(struct sockaddr_in6);
333: dst6.sin6_addr.s6_addr[10] = dst6.sin6_addr.s6_addr[11] = 0xff;
334: bcopy(&ip->ip_dst, &dst6.sin6_addr.s6_addr[12],
335: sizeof(ip->ip_dst));
336: dst6.sin6_port = uh->uh_dport;
337:
338: n += udp6_realinput(AF_INET, &src6, &dst6, m, iphlen);
339: }
340: #endif
341:
342: if (n == 0) {
343: if (m->m_flags & (M_BCAST | M_MCAST)) {
344: udpstat.udps_noportbcast++;
345: goto bad;
346: }
1.61 itojun 347: udpstat.udps_noport++;
1.64 ws 348: #ifdef IPKDB
1.53 itojun 349: if (checkipkdb(&ip->ip_src, uh->uh_sport, uh->uh_dport,
350: m, iphlen + sizeof(struct udphdr),
351: m->m_pkthdr.len - iphlen - sizeof(struct udphdr))) {
352: /*
353: * It was a debugger connect packet,
354: * just drop it now
355: */
356: goto bad;
357: }
358: #endif
359: icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0);
360: m = NULL;
361: }
362:
363: bad:
364: if (m)
365: m_freem(m);
1.78 thorpej 366: return;
367:
368: badcsum:
369: m_freem(m);
370: udpstat.udps_badsum++;
1.53 itojun 371: }
1.72 itojun 372: #endif
1.53 itojun 373:
374: #ifdef INET6
375: int
376: udp6_input(mp, offp, proto)
377: struct mbuf **mp;
378: int *offp, proto;
379: {
380: struct mbuf *m = *mp;
381: int off = *offp;
382: struct sockaddr_in6 src, dst;
383: struct ip6_hdr *ip6;
384: struct udphdr *uh;
385: u_int32_t plen, ulen;
386:
1.76 itojun 387: ip6 = mtod(m, struct ip6_hdr *);
388:
1.53 itojun 389: #if defined(NFAITH) && 0 < NFAITH
1.76 itojun 390: if (faithprefix(&ip6->ip6_dst)) {
391: /* send icmp6 host unreach? */
392: m_freem(m);
393: return IPPROTO_DONE;
1.53 itojun 394: }
395: #endif
396:
397: udp6stat.udp6s_ipackets++;
398:
399: /* check for jumbogram is done in ip6_input. we can trust pkthdr.len */
400: plen = m->m_pkthdr.len - off;
401: IP6_EXTHDR_GET(uh, struct udphdr *, m, off, sizeof(struct udphdr));
402: if (uh == NULL) {
403: ip6stat.ip6s_tooshort++;
404: return IPPROTO_DONE;
405: }
1.95 thorpej 406: KASSERT(UDP_HDR_ALIGNED_P(uh));
1.53 itojun 407: ulen = ntohs((u_short)uh->uh_ulen);
1.69 itojun 408: /*
409: * RFC2675 section 4: jumbograms will have 0 in the UDP header field,
410: * iff payload length > 0xffff.
411: */
1.53 itojun 412: if (ulen == 0 && plen > 0xffff)
413: ulen = plen;
414:
415: if (plen != ulen) {
416: udp6stat.udp6s_badlen++;
1.54 itojun 417: goto bad;
418: }
419:
1.57 itojun 420: /* destination port of 0 is illegal, based on RFC768. */
421: if (uh->uh_dport == 0)
422: goto bad;
423:
1.54 itojun 424: /* Be proactive about malicious use of IPv4 mapped address */
425: if (IN6_IS_ADDR_V4MAPPED(&ip6->ip6_src) ||
426: IN6_IS_ADDR_V4MAPPED(&ip6->ip6_dst)) {
427: /* XXX stat */
1.53 itojun 428: goto bad;
429: }
430:
431: /*
432: * Checksum extended UDP header and data.
433: */
1.116.2.1 tron 434: if (uh->uh_sum == 0) {
1.53 itojun 435: udp6stat.udp6s_nosum++;
1.116.2.1 tron 436: goto bad;
1.116.2.2 tron 437: }
438: if (in6_cksum(m, IPPROTO_UDP, off, ulen) != 0) {
1.53 itojun 439: udp6stat.udp6s_badsum++;
440: goto bad;
441: }
442:
443: /*
444: * Construct source and dst sockaddrs.
445: * Note that ifindex (s6_addr16[1]) is already filled.
446: */
447: bzero(&src, sizeof(src));
448: src.sin6_family = AF_INET6;
449: src.sin6_len = sizeof(struct sockaddr_in6);
1.69 itojun 450: /* KAME hack: recover scopeid */
451: (void)in6_recoverscope(&src, &ip6->ip6_src, m->m_pkthdr.rcvif);
1.53 itojun 452: src.sin6_port = uh->uh_sport;
453: bzero(&dst, sizeof(dst));
454: dst.sin6_family = AF_INET6;
455: dst.sin6_len = sizeof(struct sockaddr_in6);
1.69 itojun 456: /* KAME hack: recover scopeid */
457: (void)in6_recoverscope(&dst, &ip6->ip6_dst, m->m_pkthdr.rcvif);
1.53 itojun 458: dst.sin6_port = uh->uh_dport;
459:
460: if (udp6_realinput(AF_INET6, &src, &dst, m, off) == 0) {
461: if (m->m_flags & M_MCAST) {
462: udp6stat.udp6s_noportmcast++;
463: goto bad;
464: }
1.61 itojun 465: udp6stat.udp6s_noport++;
1.53 itojun 466: icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
467: m = NULL;
468: }
469:
470: bad:
471: if (m)
472: m_freem(m);
473: return IPPROTO_DONE;
474: }
475: #endif
476:
1.72 itojun 477: #ifdef INET
1.53 itojun 478: static void
479: udp4_sendup(m, off, src, so)
480: struct mbuf *m;
481: int off; /* offset of data portion */
482: struct sockaddr *src;
483: struct socket *so;
484: {
485: struct mbuf *opts = NULL;
486: struct mbuf *n;
487: struct inpcb *inp = NULL;
488:
489: if (!so)
490: return;
491: switch (so->so_proto->pr_domain->dom_family) {
492: case AF_INET:
493: inp = sotoinpcb(so);
494: break;
495: #ifdef INET6
496: case AF_INET6:
497: break;
498: #endif
499: default:
500: return;
501: }
502:
1.105 jonathan 503: #if defined(IPSEC) || defined(FAST_IPSEC)
1.53 itojun 504: /* check AH/ESP integrity. */
505: if (so != NULL && ipsec4_in_reject_so(m, so)) {
506: ipsecstat.in_polvio++;
1.110 itojun 507: if ((n = m_copy(m, 0, M_COPYALL)) != NULL)
508: icmp_error(n, ICMP_UNREACH, ICMP_UNREACH_ADMIN_PROHIBIT,
509: 0, 0);
1.53 itojun 510: return;
511: }
512: #endif /*IPSEC*/
513:
514: if ((n = m_copy(m, 0, M_COPYALL)) != NULL) {
515: if (inp && (inp->inp_flags & INP_CONTROLOPTS
516: || so->so_options & SO_TIMESTAMP)) {
517: struct ip *ip = mtod(n, struct ip *);
518: ip_savecontrol(inp, &opts, ip, n);
519: }
520:
521: m_adj(n, off);
522: if (sbappendaddr(&so->so_rcv, src, n,
523: opts) == 0) {
524: m_freem(n);
525: if (opts)
526: m_freem(opts);
1.81 enami 527: udpstat.udps_fullsock++;
1.53 itojun 528: } else
529: sorwakeup(so);
530: }
531: }
1.72 itojun 532: #endif
1.53 itojun 533:
534: #ifdef INET6
535: static void
536: udp6_sendup(m, off, src, so)
537: struct mbuf *m;
538: int off; /* offset of data portion */
539: struct sockaddr *src;
540: struct socket *so;
541: {
542: struct mbuf *opts = NULL;
543: struct mbuf *n;
544: struct in6pcb *in6p = NULL;
545:
546: if (!so)
547: return;
548: if (so->so_proto->pr_domain->dom_family != AF_INET6)
549: return;
550: in6p = sotoin6pcb(so);
551:
1.105 jonathan 552: #if defined(IPSEC) || defined(FAST_IPSEC)
1.53 itojun 553: /* check AH/ESP integrity. */
554: if (so != NULL && ipsec6_in_reject_so(m, so)) {
555: ipsec6stat.in_polvio++;
1.111 mycroft 556: if ((n = m_copy(m, 0, M_COPYALL)) != NULL)
1.110 itojun 557: icmp6_error(n, ICMP6_DST_UNREACH,
558: ICMP6_DST_UNREACH_ADMIN, 0);
1.53 itojun 559: return;
560: }
561: #endif /*IPSEC*/
562:
563: if ((n = m_copy(m, 0, M_COPYALL)) != NULL) {
564: if (in6p && (in6p->in6p_flags & IN6P_CONTROLOPTS
565: || in6p->in6p_socket->so_options & SO_TIMESTAMP)) {
566: struct ip6_hdr *ip6 = mtod(n, struct ip6_hdr *);
567: ip6_savecontrol(in6p, &opts, ip6, n);
568: }
569:
570: m_adj(n, off);
571: if (sbappendaddr(&so->so_rcv, src, n, opts) == 0) {
572: m_freem(n);
573: if (opts)
574: m_freem(opts);
575: udp6stat.udp6s_fullsock++;
576: } else
577: sorwakeup(so);
578: }
579: }
580: #endif
581:
1.72 itojun 582: #ifdef INET
1.53 itojun 583: static int
584: udp4_realinput(src, dst, m, off)
585: struct sockaddr_in *src;
586: struct sockaddr_in *dst;
587: struct mbuf *m;
588: int off; /* offset of udphdr */
589: {
590: u_int16_t *sport, *dport;
591: int rcvcnt;
592: struct in_addr *src4, *dst4;
1.109 itojun 593: struct inpcb_hdr *inph;
1.53 itojun 594: struct inpcb *inp;
595:
596: rcvcnt = 0;
597: off += sizeof(struct udphdr); /* now, offset of payload */
598:
599: if (src->sin_family != AF_INET || dst->sin_family != AF_INET)
600: goto bad;
601:
602: src4 = &src->sin_addr;
603: sport = &src->sin_port;
604: dst4 = &dst->sin_addr;
605: dport = &dst->sin_port;
606:
1.73 itojun 607: if (IN_MULTICAST(dst4->s_addr) ||
1.53 itojun 608: in_broadcast(*dst4, m->m_pkthdr.rcvif)) {
609: /*
610: * Deliver a multicast or broadcast datagram to *all* sockets
611: * for which the local and remote addresses and ports match
612: * those of the incoming datagram. This allows more than
613: * one process to receive multi/broadcasts on the same port.
614: * (This really ought to be done for unicast datagrams as
615: * well, but that would cause problems with existing
616: * applications that open both address-specific sockets and
617: * a wildcard socket listening to the same port -- they would
618: * end up receiving duplicates of every unicast datagram.
619: * Those applications open the multiple sockets to overcome an
620: * inadequacy of the UDP socket interface, but for backwards
621: * compatibility we avoid the problem here rather than
622: * fixing the interface. Maybe 4.5BSD will remedy this?)
623: */
624:
625: /*
1.92 itojun 626: * KAME note: traditionally we dropped udpiphdr from mbuf here.
1.71 itojun 627: * we need udpiphdr for IPsec processing so we do that later.
1.53 itojun 628: */
629: /*
630: * Locate pcb(s) for datagram.
631: */
1.109 itojun 632: CIRCLEQ_FOREACH(inph, &udbtable.inpt_queue, inph_queue) {
633: inp = (struct inpcb *)inph;
634: if (inp->inp_af != AF_INET)
635: continue;
636:
1.53 itojun 637: if (inp->inp_lport != *dport)
638: continue;
639: if (!in_nullhost(inp->inp_laddr)) {
640: if (!in_hosteq(inp->inp_laddr, *dst4))
641: continue;
642: }
643: if (!in_nullhost(inp->inp_faddr)) {
644: if (!in_hosteq(inp->inp_faddr, *src4) ||
645: inp->inp_fport != *sport)
646: continue;
647: }
648:
649: udp4_sendup(m, off, (struct sockaddr *)src,
650: inp->inp_socket);
651: rcvcnt++;
652:
653: /*
654: * Don't look for additional matches if this one does
655: * not have either the SO_REUSEPORT or SO_REUSEADDR
656: * socket options set. This heuristic avoids searching
657: * through all pcbs in the common case of a non-shared
658: * port. It assumes that an application will never
659: * clear these options after setting them.
660: */
661: if ((inp->inp_socket->so_options &
662: (SO_REUSEPORT|SO_REUSEADDR)) == 0)
663: break;
664: }
665: } else {
666: /*
667: * Locate pcb for datagram.
668: */
669: inp = in_pcblookup_connect(&udbtable, *src4, *sport, *dst4, *dport);
670: if (inp == 0) {
671: ++udpstat.udps_pcbhashmiss;
672: inp = in_pcblookup_bind(&udbtable, *dst4, *dport);
1.82 itojun 673: if (inp == 0)
1.53 itojun 674: return rcvcnt;
675: }
676:
677: udp4_sendup(m, off, (struct sockaddr *)src, inp->inp_socket);
678: rcvcnt++;
679: }
680:
681: bad:
682: return rcvcnt;
683: }
1.72 itojun 684: #endif
1.53 itojun 685:
686: #ifdef INET6
687: static int
688: udp6_realinput(af, src, dst, m, off)
689: int af; /* af on packet */
690: struct sockaddr_in6 *src;
691: struct sockaddr_in6 *dst;
692: struct mbuf *m;
693: int off; /* offset of udphdr */
694: {
1.79 itojun 695: u_int16_t sport, dport;
1.53 itojun 696: int rcvcnt;
1.79 itojun 697: struct in6_addr src6, dst6;
698: const struct in_addr *dst4;
1.109 itojun 699: struct inpcb_hdr *inph;
1.53 itojun 700: struct in6pcb *in6p;
701:
702: rcvcnt = 0;
703: off += sizeof(struct udphdr); /* now, offset of payload */
704:
705: if (af != AF_INET && af != AF_INET6)
706: goto bad;
707: if (src->sin6_family != AF_INET6 || dst->sin6_family != AF_INET6)
708: goto bad;
709:
1.79 itojun 710: in6_embedscope(&src6, src, NULL, NULL);
711: sport = src->sin6_port;
712: in6_embedscope(&dst6, dst, NULL, NULL);
713: dport = dst->sin6_port;
1.88 itojun 714: dst4 = (struct in_addr *)&dst->sin6_addr.s6_addr[12];
1.53 itojun 715:
1.79 itojun 716: if (IN6_IS_ADDR_MULTICAST(&dst6) ||
717: (af == AF_INET && IN_MULTICAST(dst4->s_addr))) {
1.53 itojun 718: /*
719: * Deliver a multicast or broadcast datagram to *all* sockets
720: * for which the local and remote addresses and ports match
721: * those of the incoming datagram. This allows more than
722: * one process to receive multi/broadcasts on the same port.
723: * (This really ought to be done for unicast datagrams as
724: * well, but that would cause problems with existing
725: * applications that open both address-specific sockets and
726: * a wildcard socket listening to the same port -- they would
727: * end up receiving duplicates of every unicast datagram.
728: * Those applications open the multiple sockets to overcome an
729: * inadequacy of the UDP socket interface, but for backwards
730: * compatibility we avoid the problem here rather than
731: * fixing the interface. Maybe 4.5BSD will remedy this?)
732: */
733:
734: /*
1.92 itojun 735: * KAME note: traditionally we dropped udpiphdr from mbuf here.
1.71 itojun 736: * we need udpiphdr for IPsec processing so we do that later.
1.53 itojun 737: */
738: /*
739: * Locate pcb(s) for datagram.
740: */
1.109 itojun 741: CIRCLEQ_FOREACH(inph, &udbtable.inpt_queue, inph_queue) {
742: in6p = (struct in6pcb *)inph;
743: if (in6p->in6p_af != AF_INET6)
744: continue;
745:
1.79 itojun 746: if (in6p->in6p_lport != dport)
1.53 itojun 747: continue;
748: if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr)) {
1.90 itojun 749: if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr, &dst6))
1.53 itojun 750: continue;
1.92 itojun 751: } else {
1.79 itojun 752: if (IN6_IS_ADDR_V4MAPPED(&dst6) &&
1.85 itojun 753: (in6p->in6p_flags & IN6P_IPV6_V6ONLY))
1.55 itojun 754: continue;
755: }
1.53 itojun 756: if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
1.79 itojun 757: if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr,
758: &src6) || in6p->in6p_fport != sport)
1.53 itojun 759: continue;
1.92 itojun 760: } else {
1.79 itojun 761: if (IN6_IS_ADDR_V4MAPPED(&src6) &&
1.85 itojun 762: (in6p->in6p_flags & IN6P_IPV6_V6ONLY))
1.55 itojun 763: continue;
764: }
1.53 itojun 765:
766: udp6_sendup(m, off, (struct sockaddr *)src,
767: in6p->in6p_socket);
768: rcvcnt++;
769:
770: /*
771: * Don't look for additional matches if this one does
772: * not have either the SO_REUSEPORT or SO_REUSEADDR
773: * socket options set. This heuristic avoids searching
774: * through all pcbs in the common case of a non-shared
775: * port. It assumes that an application will never
776: * clear these options after setting them.
777: */
778: if ((in6p->in6p_socket->so_options &
779: (SO_REUSEPORT|SO_REUSEADDR)) == 0)
780: break;
781: }
782: } else {
783: /*
784: * Locate pcb for datagram.
785: */
1.109 itojun 786: in6p = in6_pcblookup_connect(&udbtable, &src6, sport,
1.79 itojun 787: &dst6, dport, 0);
1.53 itojun 788: if (in6p == 0) {
789: ++udpstat.udps_pcbhashmiss;
1.109 itojun 790: in6p = in6_pcblookup_bind(&udbtable, &dst6, dport, 0);
1.82 itojun 791: if (in6p == 0)
1.53 itojun 792: return rcvcnt;
793: }
794:
795: udp6_sendup(m, off, (struct sockaddr *)src, in6p->in6p_socket);
796: rcvcnt++;
797: }
798:
799: bad:
800: return rcvcnt;
801: }
802: #endif
1.1 cgd 803:
1.72 itojun 804: #ifdef INET
1.1 cgd 805: /*
806: * Notify a udp user of an asynchronous error;
807: * just wake up so that he can collect error status.
808: */
1.7 mycroft 809: static void
1.1 cgd 810: udp_notify(inp, errno)
1.66 augustss 811: struct inpcb *inp;
1.7 mycroft 812: int errno;
1.1 cgd 813: {
1.34 mycroft 814:
1.1 cgd 815: inp->inp_socket->so_error = errno;
816: sorwakeup(inp->inp_socket);
817: sowwakeup(inp->inp_socket);
818: }
819:
1.27 christos 820: void *
821: udp_ctlinput(cmd, sa, v)
1.1 cgd 822: int cmd;
823: struct sockaddr *sa;
1.27 christos 824: void *v;
1.1 cgd 825: {
1.66 augustss 826: struct ip *ip = v;
827: struct udphdr *uh;
1.18 mycroft 828: void (*notify) __P((struct inpcb *, int)) = udp_notify;
1.21 mycroft 829: int errno;
1.1 cgd 830:
1.53 itojun 831: if (sa->sa_family != AF_INET
832: || sa->sa_len != sizeof(struct sockaddr_in))
1.51 itojun 833: return NULL;
1.20 mycroft 834: if ((unsigned)cmd >= PRC_NCMDS)
1.27 christos 835: return NULL;
1.20 mycroft 836: errno = inetctlerrmap[cmd];
1.18 mycroft 837: if (PRC_IS_REDIRECT(cmd))
1.19 mycroft 838: notify = in_rtchange, ip = 0;
1.18 mycroft 839: else if (cmd == PRC_HOSTDEAD)
1.19 mycroft 840: ip = 0;
1.23 cgd 841: else if (errno == 0)
1.27 christos 842: return NULL;
1.19 mycroft 843: if (ip) {
1.1 cgd 844: uh = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2));
1.34 mycroft 845: in_pcbnotify(&udbtable, satosin(sa)->sin_addr, uh->uh_dport,
846: ip->ip_src, uh->uh_sport, errno, notify);
1.53 itojun 847:
848: /* XXX mapped address case */
1.19 mycroft 849: } else
1.34 mycroft 850: in_pcbnotifyall(&udbtable, satosin(sa)->sin_addr, errno,
851: notify);
1.27 christos 852: return NULL;
1.1 cgd 853: }
854:
1.7 mycroft 855: int
1.27 christos 856: #if __STDC__
857: udp_output(struct mbuf *m, ...)
858: #else
859: udp_output(m, va_alist)
860: struct mbuf *m;
861: va_dcl
862: #endif
863: {
1.66 augustss 864: struct inpcb *inp;
865: struct udpiphdr *ui;
866: int len = m->m_pkthdr.len;
1.31 mycroft 867: int error = 0;
1.27 christos 868: va_list ap;
869:
1.98 matt 870: MCLAIM(m, &udp_tx_mowner);
1.27 christos 871: va_start(ap, m);
872: inp = va_arg(ap, struct inpcb *);
873: va_end(ap);
1.1 cgd 874:
875: /*
876: * Calculate data length and get a mbuf
877: * for UDP and IP headers.
878: */
1.13 mycroft 879: M_PREPEND(m, sizeof(struct udpiphdr), M_DONTWAIT);
880: if (m == 0) {
881: error = ENOBUFS;
1.39 thorpej 882: goto release;
883: }
884:
885: /*
886: * Compute the packet length of the IP header, and
887: * punt if the length looks bogus.
888: */
1.96 itojun 889: if (len + sizeof(struct udpiphdr) > IP_MAXPACKET) {
1.39 thorpej 890: error = EMSGSIZE;
1.13 mycroft 891: goto release;
892: }
1.1 cgd 893:
894: /*
895: * Fill in mbuf with extended UDP header
896: * and addresses and length put into network format.
897: */
898: ui = mtod(m, struct udpiphdr *);
899: ui->ui_pr = IPPROTO_UDP;
900: ui->ui_src = inp->inp_laddr;
901: ui->ui_dst = inp->inp_faddr;
902: ui->ui_sport = inp->inp_lport;
903: ui->ui_dport = inp->inp_fport;
1.78 thorpej 904: ui->ui_ulen = htons((u_int16_t)len + sizeof(struct udphdr));
1.1 cgd 905:
906: /*
1.78 thorpej 907: * Set up checksum and output datagram.
1.1 cgd 908: */
909: if (udpcksum) {
1.78 thorpej 910: /*
911: * XXX Cache pseudo-header checksum part for
912: * XXX "connected" UDP sockets.
913: */
914: ui->ui_sum = in_cksum_phdr(ui->ui_src.s_addr,
915: ui->ui_dst.s_addr, htons((u_int16_t)len +
916: sizeof(struct udphdr) + IPPROTO_UDP));
917: m->m_pkthdr.csum_flags = M_CSUM_UDPv4;
918: m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum);
919: } else
920: ui->ui_sum = 0;
1.96 itojun 921: ((struct ip *)ui)->ip_len = htons(sizeof (struct udpiphdr) + len);
1.1 cgd 922: ((struct ip *)ui)->ip_ttl = inp->inp_ip.ip_ttl; /* XXX */
923: ((struct ip *)ui)->ip_tos = inp->inp_ip.ip_tos; /* XXX */
924: udpstat.udps_opackets++;
1.48 itojun 925:
1.31 mycroft 926: return (ip_output(m, inp->inp_options, &inp->inp_route,
1.12 mycroft 927: inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST),
1.107 itojun 928: inp->inp_moptions, inp->inp_socket));
1.1 cgd 929:
930: release:
931: m_freem(m);
932: return (error);
933: }
934:
1.42 thorpej 935: int udp_sendspace = 9216; /* really max datagram size */
936: int udp_recvspace = 40 * (1024 + sizeof(struct sockaddr_in));
1.1 cgd 937: /* 40 1K datagrams */
938:
939: /*ARGSUSED*/
1.7 mycroft 940: int
1.103 fvdl 941: udp_usrreq(so, req, m, nam, control, p)
1.1 cgd 942: struct socket *so;
943: int req;
1.31 mycroft 944: struct mbuf *m, *nam, *control;
1.103 fvdl 945: struct proc *p;
1.1 cgd 946: {
1.66 augustss 947: struct inpcb *inp;
1.1 cgd 948: int s;
1.66 augustss 949: int error = 0;
1.1 cgd 950:
951: if (req == PRU_CONTROL)
1.31 mycroft 952: return (in_control(so, (long)m, (caddr_t)nam,
1.30 mycroft 953: (struct ifnet *)control, p));
1.59 thorpej 954:
1.60 thorpej 955: if (req == PRU_PURGEIF) {
1.80 itojun 956: in_pcbpurgeif0(&udbtable, (struct ifnet *)control);
1.60 thorpej 957: in_purgeif((struct ifnet *)control);
958: in_pcbpurgeif(&udbtable, (struct ifnet *)control);
1.59 thorpej 959: return (0);
960: }
1.31 mycroft 961:
962: s = splsoftnet();
963: inp = sotoinpcb(so);
1.32 mycroft 964: #ifdef DIAGNOSTIC
965: if (req != PRU_SEND && req != PRU_SENDOOB && control)
966: panic("udp_usrreq: unexpected control mbuf");
967: #endif
1.31 mycroft 968: if (inp == 0 && req != PRU_ATTACH) {
969: error = EINVAL;
970: goto release;
971: }
972:
1.1 cgd 973: /*
974: * Note: need to block udp_input while changing
975: * the udp pcb queue and/or pcb addresses.
976: */
977: switch (req) {
978:
979: case PRU_ATTACH:
1.31 mycroft 980: if (inp != 0) {
981: error = EISCONN;
1.1 cgd 982: break;
983: }
1.98 matt 984: #ifdef MBUFTRACE
985: so->so_mowner = &udp_mowner;
986: so->so_rcv.sb_mowner = &udp_rx_mowner;
987: so->so_snd.sb_mowner = &udp_tx_mowner;
988: #endif
1.31 mycroft 989: if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
990: error = soreserve(so, udp_sendspace, udp_recvspace);
991: if (error)
992: break;
993: }
1.18 mycroft 994: error = in_pcballoc(so, &udbtable);
1.1 cgd 995: if (error)
996: break;
1.31 mycroft 997: inp = sotoinpcb(so);
998: inp->inp_ip.ip_ttl = ip_defttl;
1.1 cgd 999: break;
1000:
1001: case PRU_DETACH:
1.31 mycroft 1002: in_pcbdetach(inp);
1.1 cgd 1003: break;
1004:
1005: case PRU_BIND:
1.31 mycroft 1006: error = in_pcbbind(inp, nam, p);
1.1 cgd 1007: break;
1008:
1009: case PRU_LISTEN:
1010: error = EOPNOTSUPP;
1011: break;
1012:
1013: case PRU_CONNECT:
1.31 mycroft 1014: error = in_pcbconnect(inp, nam);
1015: if (error)
1.1 cgd 1016: break;
1.31 mycroft 1017: soisconnected(so);
1.1 cgd 1018: break;
1019:
1020: case PRU_CONNECT2:
1021: error = EOPNOTSUPP;
1022: break;
1023:
1024: case PRU_DISCONNECT:
1.31 mycroft 1025: /*soisdisconnected(so);*/
1026: so->so_state &= ~SS_ISCONNECTED; /* XXX */
1.1 cgd 1027: in_pcbdisconnect(inp);
1.34 mycroft 1028: inp->inp_laddr = zeroin_addr; /* XXX */
1.35 mycroft 1029: in_pcbstate(inp, INP_BOUND); /* XXX */
1.1 cgd 1030: break;
1031:
1032: case PRU_SHUTDOWN:
1033: socantsendmore(so);
1034: break;
1035:
1.31 mycroft 1036: case PRU_RCVD:
1037: error = EOPNOTSUPP;
1.1 cgd 1038: break;
1039:
1.31 mycroft 1040: case PRU_SEND:
1.32 mycroft 1041: if (control && control->m_len) {
1042: m_freem(control);
1043: m_freem(m);
1044: error = EINVAL;
1045: break;
1046: }
1.31 mycroft 1047: {
1.35 mycroft 1048: struct in_addr laddr; /* XXX */
1.1 cgd 1049:
1.31 mycroft 1050: if (nam) {
1.35 mycroft 1051: laddr = inp->inp_laddr; /* XXX */
1.31 mycroft 1052: if ((so->so_state & SS_ISCONNECTED) != 0) {
1053: error = EISCONN;
1.32 mycroft 1054: goto die;
1.31 mycroft 1055: }
1056: error = in_pcbconnect(inp, nam);
1.100 matt 1057: if (error)
1058: goto die;
1.31 mycroft 1059: } else {
1060: if ((so->so_state & SS_ISCONNECTED) == 0) {
1061: error = ENOTCONN;
1.32 mycroft 1062: goto die;
1.31 mycroft 1063: }
1064: }
1.33 mycroft 1065: error = udp_output(m, inp);
1.100 matt 1066: m = NULL;
1.31 mycroft 1067: if (nam) {
1068: in_pcbdisconnect(inp);
1.35 mycroft 1069: inp->inp_laddr = laddr; /* XXX */
1070: in_pcbstate(inp, INP_BOUND); /* XXX */
1.31 mycroft 1071: }
1.100 matt 1072: die:
1073: if (m)
1074: m_freem(m);
1.31 mycroft 1075: }
1.1 cgd 1076: break;
1077:
1078: case PRU_SENSE:
1079: /*
1080: * stat: don't bother with a blocksize.
1081: */
1.31 mycroft 1082: splx(s);
1.1 cgd 1083: return (0);
1084:
1.31 mycroft 1085: case PRU_RCVOOB:
1086: error = EOPNOTSUPP;
1087: break;
1088:
1.1 cgd 1089: case PRU_SENDOOB:
1.32 mycroft 1090: m_freem(control);
1.31 mycroft 1091: m_freem(m);
1.1 cgd 1092: error = EOPNOTSUPP;
1093: break;
1094:
1.31 mycroft 1095: case PRU_SOCKADDR:
1096: in_setsockaddr(inp, nam);
1097: break;
1098:
1099: case PRU_PEERADDR:
1100: in_setpeeraddr(inp, nam);
1101: break;
1.1 cgd 1102:
1103: default:
1104: panic("udp_usrreq");
1105: }
1106:
1107: release:
1.31 mycroft 1108: splx(s);
1.1 cgd 1109: return (error);
1.13 mycroft 1110: }
1111:
1112: /*
1113: * Sysctl for udp variables.
1114: */
1.114 atatat 1115: SYSCTL_SETUP(sysctl_net_inet_udp_setup, "sysctl net.inet.udp subtree setup")
1.13 mycroft 1116: {
1.114 atatat 1117:
1.116 atatat 1118: sysctl_createv(clog, 0, NULL, NULL,
1119: CTLFLAG_PERMANENT,
1.114 atatat 1120: CTLTYPE_NODE, "net", NULL,
1121: NULL, 0, NULL, 0,
1122: CTL_NET, CTL_EOL);
1.116 atatat 1123: sysctl_createv(clog, 0, NULL, NULL,
1124: CTLFLAG_PERMANENT,
1.114 atatat 1125: CTLTYPE_NODE, "inet", NULL,
1126: NULL, 0, NULL, 0,
1127: CTL_NET, PF_INET, CTL_EOL);
1.116 atatat 1128: sysctl_createv(clog, 0, NULL, NULL,
1129: CTLFLAG_PERMANENT,
1.114 atatat 1130: CTLTYPE_NODE, "udp", NULL,
1131: NULL, 0, NULL, 0,
1132: CTL_NET, PF_INET, IPPROTO_UDP, CTL_EOL);
1133:
1.116 atatat 1134: sysctl_createv(clog, 0, NULL, NULL,
1135: CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
1.114 atatat 1136: CTLTYPE_INT, "checksum", NULL,
1137: NULL, 0, &udpcksum, 0,
1138: CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_CHECKSUM,
1139: CTL_EOL);
1.116 atatat 1140: sysctl_createv(clog, 0, NULL, NULL,
1141: CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
1.114 atatat 1142: CTLTYPE_INT, "sendspace", NULL,
1143: NULL, 0, &udp_sendspace, 0,
1144: CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_SENDSPACE,
1145: CTL_EOL);
1.116 atatat 1146: sysctl_createv(clog, 0, NULL, NULL,
1147: CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
1.114 atatat 1148: CTLTYPE_INT, "recvspace", NULL,
1149: NULL, 0, &udp_recvspace, 0,
1150: CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_RECVSPACE,
1151: CTL_EOL);
1.1 cgd 1152: }
1.72 itojun 1153: #endif
CVSweb <webmaster@jp.NetBSD.org>