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