Annotation of src/sys/netinet/udp_usrreq.c, Revision 1.116.2.1
1.116.2.1! 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.1! 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>
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;
! 436: } else if (in6_cksum(m, IPPROTO_UDP, off, ulen) != 0) {
1.53 itojun 437: udp6stat.udp6s_badsum++;
438: goto bad;
439: }
440:
441: /*
442: * Construct source and dst sockaddrs.
443: * Note that ifindex (s6_addr16[1]) is already filled.
444: */
445: bzero(&src, sizeof(src));
446: src.sin6_family = AF_INET6;
447: src.sin6_len = sizeof(struct sockaddr_in6);
1.69 itojun 448: /* KAME hack: recover scopeid */
449: (void)in6_recoverscope(&src, &ip6->ip6_src, m->m_pkthdr.rcvif);
1.53 itojun 450: src.sin6_port = uh->uh_sport;
451: bzero(&dst, sizeof(dst));
452: dst.sin6_family = AF_INET6;
453: dst.sin6_len = sizeof(struct sockaddr_in6);
1.69 itojun 454: /* KAME hack: recover scopeid */
455: (void)in6_recoverscope(&dst, &ip6->ip6_dst, m->m_pkthdr.rcvif);
1.53 itojun 456: dst.sin6_port = uh->uh_dport;
457:
458: if (udp6_realinput(AF_INET6, &src, &dst, m, off) == 0) {
459: if (m->m_flags & M_MCAST) {
460: udp6stat.udp6s_noportmcast++;
461: goto bad;
462: }
1.61 itojun 463: udp6stat.udp6s_noport++;
1.53 itojun 464: icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
465: m = NULL;
466: }
467:
468: bad:
469: if (m)
470: m_freem(m);
471: return IPPROTO_DONE;
472: }
473: #endif
474:
1.72 itojun 475: #ifdef INET
1.53 itojun 476: static void
477: udp4_sendup(m, off, src, so)
478: struct mbuf *m;
479: int off; /* offset of data portion */
480: struct sockaddr *src;
481: struct socket *so;
482: {
483: struct mbuf *opts = NULL;
484: struct mbuf *n;
485: struct inpcb *inp = NULL;
486:
487: if (!so)
488: return;
489: switch (so->so_proto->pr_domain->dom_family) {
490: case AF_INET:
491: inp = sotoinpcb(so);
492: break;
493: #ifdef INET6
494: case AF_INET6:
495: break;
496: #endif
497: default:
498: return;
499: }
500:
1.105 jonathan 501: #if defined(IPSEC) || defined(FAST_IPSEC)
1.53 itojun 502: /* check AH/ESP integrity. */
503: if (so != NULL && ipsec4_in_reject_so(m, so)) {
504: ipsecstat.in_polvio++;
1.110 itojun 505: if ((n = m_copy(m, 0, M_COPYALL)) != NULL)
506: icmp_error(n, ICMP_UNREACH, ICMP_UNREACH_ADMIN_PROHIBIT,
507: 0, 0);
1.53 itojun 508: return;
509: }
510: #endif /*IPSEC*/
511:
512: if ((n = m_copy(m, 0, M_COPYALL)) != NULL) {
513: if (inp && (inp->inp_flags & INP_CONTROLOPTS
514: || so->so_options & SO_TIMESTAMP)) {
515: struct ip *ip = mtod(n, struct ip *);
516: ip_savecontrol(inp, &opts, ip, n);
517: }
518:
519: m_adj(n, off);
520: if (sbappendaddr(&so->so_rcv, src, n,
521: opts) == 0) {
522: m_freem(n);
523: if (opts)
524: m_freem(opts);
1.81 enami 525: udpstat.udps_fullsock++;
1.53 itojun 526: } else
527: sorwakeup(so);
528: }
529: }
1.72 itojun 530: #endif
1.53 itojun 531:
532: #ifdef INET6
533: static void
534: udp6_sendup(m, off, src, so)
535: struct mbuf *m;
536: int off; /* offset of data portion */
537: struct sockaddr *src;
538: struct socket *so;
539: {
540: struct mbuf *opts = NULL;
541: struct mbuf *n;
542: struct in6pcb *in6p = NULL;
543:
544: if (!so)
545: return;
546: if (so->so_proto->pr_domain->dom_family != AF_INET6)
547: return;
548: in6p = sotoin6pcb(so);
549:
1.105 jonathan 550: #if defined(IPSEC) || defined(FAST_IPSEC)
1.53 itojun 551: /* check AH/ESP integrity. */
552: if (so != NULL && ipsec6_in_reject_so(m, so)) {
553: ipsec6stat.in_polvio++;
1.111 mycroft 554: if ((n = m_copy(m, 0, M_COPYALL)) != NULL)
1.110 itojun 555: icmp6_error(n, ICMP6_DST_UNREACH,
556: ICMP6_DST_UNREACH_ADMIN, 0);
1.53 itojun 557: return;
558: }
559: #endif /*IPSEC*/
560:
561: if ((n = m_copy(m, 0, M_COPYALL)) != NULL) {
562: if (in6p && (in6p->in6p_flags & IN6P_CONTROLOPTS
563: || in6p->in6p_socket->so_options & SO_TIMESTAMP)) {
564: struct ip6_hdr *ip6 = mtod(n, struct ip6_hdr *);
565: ip6_savecontrol(in6p, &opts, ip6, n);
566: }
567:
568: m_adj(n, off);
569: if (sbappendaddr(&so->so_rcv, src, n, opts) == 0) {
570: m_freem(n);
571: if (opts)
572: m_freem(opts);
573: udp6stat.udp6s_fullsock++;
574: } else
575: sorwakeup(so);
576: }
577: }
578: #endif
579:
1.72 itojun 580: #ifdef INET
1.53 itojun 581: static int
582: udp4_realinput(src, dst, m, off)
583: struct sockaddr_in *src;
584: struct sockaddr_in *dst;
585: struct mbuf *m;
586: int off; /* offset of udphdr */
587: {
588: u_int16_t *sport, *dport;
589: int rcvcnt;
590: struct in_addr *src4, *dst4;
1.109 itojun 591: struct inpcb_hdr *inph;
1.53 itojun 592: struct inpcb *inp;
593:
594: rcvcnt = 0;
595: off += sizeof(struct udphdr); /* now, offset of payload */
596:
597: if (src->sin_family != AF_INET || dst->sin_family != AF_INET)
598: goto bad;
599:
600: src4 = &src->sin_addr;
601: sport = &src->sin_port;
602: dst4 = &dst->sin_addr;
603: dport = &dst->sin_port;
604:
1.73 itojun 605: if (IN_MULTICAST(dst4->s_addr) ||
1.53 itojun 606: in_broadcast(*dst4, m->m_pkthdr.rcvif)) {
607: /*
608: * Deliver a multicast or broadcast datagram to *all* sockets
609: * for which the local and remote addresses and ports match
610: * those of the incoming datagram. This allows more than
611: * one process to receive multi/broadcasts on the same port.
612: * (This really ought to be done for unicast datagrams as
613: * well, but that would cause problems with existing
614: * applications that open both address-specific sockets and
615: * a wildcard socket listening to the same port -- they would
616: * end up receiving duplicates of every unicast datagram.
617: * Those applications open the multiple sockets to overcome an
618: * inadequacy of the UDP socket interface, but for backwards
619: * compatibility we avoid the problem here rather than
620: * fixing the interface. Maybe 4.5BSD will remedy this?)
621: */
622:
623: /*
1.92 itojun 624: * KAME note: traditionally we dropped udpiphdr from mbuf here.
1.71 itojun 625: * we need udpiphdr for IPsec processing so we do that later.
1.53 itojun 626: */
627: /*
628: * Locate pcb(s) for datagram.
629: */
1.109 itojun 630: CIRCLEQ_FOREACH(inph, &udbtable.inpt_queue, inph_queue) {
631: inp = (struct inpcb *)inph;
632: if (inp->inp_af != AF_INET)
633: continue;
634:
1.53 itojun 635: if (inp->inp_lport != *dport)
636: continue;
637: if (!in_nullhost(inp->inp_laddr)) {
638: if (!in_hosteq(inp->inp_laddr, *dst4))
639: continue;
640: }
641: if (!in_nullhost(inp->inp_faddr)) {
642: if (!in_hosteq(inp->inp_faddr, *src4) ||
643: inp->inp_fport != *sport)
644: continue;
645: }
646:
647: udp4_sendup(m, off, (struct sockaddr *)src,
648: inp->inp_socket);
649: rcvcnt++;
650:
651: /*
652: * Don't look for additional matches if this one does
653: * not have either the SO_REUSEPORT or SO_REUSEADDR
654: * socket options set. This heuristic avoids searching
655: * through all pcbs in the common case of a non-shared
656: * port. It assumes that an application will never
657: * clear these options after setting them.
658: */
659: if ((inp->inp_socket->so_options &
660: (SO_REUSEPORT|SO_REUSEADDR)) == 0)
661: break;
662: }
663: } else {
664: /*
665: * Locate pcb for datagram.
666: */
667: inp = in_pcblookup_connect(&udbtable, *src4, *sport, *dst4, *dport);
668: if (inp == 0) {
669: ++udpstat.udps_pcbhashmiss;
670: inp = in_pcblookup_bind(&udbtable, *dst4, *dport);
1.82 itojun 671: if (inp == 0)
1.53 itojun 672: return rcvcnt;
673: }
674:
675: udp4_sendup(m, off, (struct sockaddr *)src, inp->inp_socket);
676: rcvcnt++;
677: }
678:
679: bad:
680: return rcvcnt;
681: }
1.72 itojun 682: #endif
1.53 itojun 683:
684: #ifdef INET6
685: static int
686: udp6_realinput(af, src, dst, m, off)
687: int af; /* af on packet */
688: struct sockaddr_in6 *src;
689: struct sockaddr_in6 *dst;
690: struct mbuf *m;
691: int off; /* offset of udphdr */
692: {
1.79 itojun 693: u_int16_t sport, dport;
1.53 itojun 694: int rcvcnt;
1.79 itojun 695: struct in6_addr src6, dst6;
696: const struct in_addr *dst4;
1.109 itojun 697: struct inpcb_hdr *inph;
1.53 itojun 698: struct in6pcb *in6p;
699:
700: rcvcnt = 0;
701: off += sizeof(struct udphdr); /* now, offset of payload */
702:
703: if (af != AF_INET && af != AF_INET6)
704: goto bad;
705: if (src->sin6_family != AF_INET6 || dst->sin6_family != AF_INET6)
706: goto bad;
707:
1.79 itojun 708: in6_embedscope(&src6, src, NULL, NULL);
709: sport = src->sin6_port;
710: in6_embedscope(&dst6, dst, NULL, NULL);
711: dport = dst->sin6_port;
1.88 itojun 712: dst4 = (struct in_addr *)&dst->sin6_addr.s6_addr[12];
1.53 itojun 713:
1.79 itojun 714: if (IN6_IS_ADDR_MULTICAST(&dst6) ||
715: (af == AF_INET && IN_MULTICAST(dst4->s_addr))) {
1.53 itojun 716: /*
717: * Deliver a multicast or broadcast datagram to *all* sockets
718: * for which the local and remote addresses and ports match
719: * those of the incoming datagram. This allows more than
720: * one process to receive multi/broadcasts on the same port.
721: * (This really ought to be done for unicast datagrams as
722: * well, but that would cause problems with existing
723: * applications that open both address-specific sockets and
724: * a wildcard socket listening to the same port -- they would
725: * end up receiving duplicates of every unicast datagram.
726: * Those applications open the multiple sockets to overcome an
727: * inadequacy of the UDP socket interface, but for backwards
728: * compatibility we avoid the problem here rather than
729: * fixing the interface. Maybe 4.5BSD will remedy this?)
730: */
731:
732: /*
1.92 itojun 733: * KAME note: traditionally we dropped udpiphdr from mbuf here.
1.71 itojun 734: * we need udpiphdr for IPsec processing so we do that later.
1.53 itojun 735: */
736: /*
737: * Locate pcb(s) for datagram.
738: */
1.109 itojun 739: CIRCLEQ_FOREACH(inph, &udbtable.inpt_queue, inph_queue) {
740: in6p = (struct in6pcb *)inph;
741: if (in6p->in6p_af != AF_INET6)
742: continue;
743:
1.79 itojun 744: if (in6p->in6p_lport != dport)
1.53 itojun 745: continue;
746: if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr)) {
1.90 itojun 747: if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr, &dst6))
1.53 itojun 748: continue;
1.92 itojun 749: } else {
1.79 itojun 750: if (IN6_IS_ADDR_V4MAPPED(&dst6) &&
1.85 itojun 751: (in6p->in6p_flags & IN6P_IPV6_V6ONLY))
1.55 itojun 752: continue;
753: }
1.53 itojun 754: if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
1.79 itojun 755: if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr,
756: &src6) || in6p->in6p_fport != sport)
1.53 itojun 757: continue;
1.92 itojun 758: } else {
1.79 itojun 759: if (IN6_IS_ADDR_V4MAPPED(&src6) &&
1.85 itojun 760: (in6p->in6p_flags & IN6P_IPV6_V6ONLY))
1.55 itojun 761: continue;
762: }
1.53 itojun 763:
764: udp6_sendup(m, off, (struct sockaddr *)src,
765: in6p->in6p_socket);
766: rcvcnt++;
767:
768: /*
769: * Don't look for additional matches if this one does
770: * not have either the SO_REUSEPORT or SO_REUSEADDR
771: * socket options set. This heuristic avoids searching
772: * through all pcbs in the common case of a non-shared
773: * port. It assumes that an application will never
774: * clear these options after setting them.
775: */
776: if ((in6p->in6p_socket->so_options &
777: (SO_REUSEPORT|SO_REUSEADDR)) == 0)
778: break;
779: }
780: } else {
781: /*
782: * Locate pcb for datagram.
783: */
1.109 itojun 784: in6p = in6_pcblookup_connect(&udbtable, &src6, sport,
1.79 itojun 785: &dst6, dport, 0);
1.53 itojun 786: if (in6p == 0) {
787: ++udpstat.udps_pcbhashmiss;
1.109 itojun 788: in6p = in6_pcblookup_bind(&udbtable, &dst6, dport, 0);
1.82 itojun 789: if (in6p == 0)
1.53 itojun 790: return rcvcnt;
791: }
792:
793: udp6_sendup(m, off, (struct sockaddr *)src, in6p->in6p_socket);
794: rcvcnt++;
795: }
796:
797: bad:
798: return rcvcnt;
799: }
800: #endif
1.1 cgd 801:
1.72 itojun 802: #ifdef INET
1.1 cgd 803: /*
804: * Notify a udp user of an asynchronous error;
805: * just wake up so that he can collect error status.
806: */
1.7 mycroft 807: static void
1.1 cgd 808: udp_notify(inp, errno)
1.66 augustss 809: struct inpcb *inp;
1.7 mycroft 810: int errno;
1.1 cgd 811: {
1.34 mycroft 812:
1.1 cgd 813: inp->inp_socket->so_error = errno;
814: sorwakeup(inp->inp_socket);
815: sowwakeup(inp->inp_socket);
816: }
817:
1.27 christos 818: void *
819: udp_ctlinput(cmd, sa, v)
1.1 cgd 820: int cmd;
821: struct sockaddr *sa;
1.27 christos 822: void *v;
1.1 cgd 823: {
1.66 augustss 824: struct ip *ip = v;
825: struct udphdr *uh;
1.18 mycroft 826: void (*notify) __P((struct inpcb *, int)) = udp_notify;
1.21 mycroft 827: int errno;
1.1 cgd 828:
1.53 itojun 829: if (sa->sa_family != AF_INET
830: || sa->sa_len != sizeof(struct sockaddr_in))
1.51 itojun 831: return NULL;
1.20 mycroft 832: if ((unsigned)cmd >= PRC_NCMDS)
1.27 christos 833: return NULL;
1.20 mycroft 834: errno = inetctlerrmap[cmd];
1.18 mycroft 835: if (PRC_IS_REDIRECT(cmd))
1.19 mycroft 836: notify = in_rtchange, ip = 0;
1.18 mycroft 837: else if (cmd == PRC_HOSTDEAD)
1.19 mycroft 838: ip = 0;
1.23 cgd 839: else if (errno == 0)
1.27 christos 840: return NULL;
1.19 mycroft 841: if (ip) {
1.1 cgd 842: uh = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2));
1.34 mycroft 843: in_pcbnotify(&udbtable, satosin(sa)->sin_addr, uh->uh_dport,
844: ip->ip_src, uh->uh_sport, errno, notify);
1.53 itojun 845:
846: /* XXX mapped address case */
1.19 mycroft 847: } else
1.34 mycroft 848: in_pcbnotifyall(&udbtable, satosin(sa)->sin_addr, errno,
849: notify);
1.27 christos 850: return NULL;
1.1 cgd 851: }
852:
1.7 mycroft 853: int
1.27 christos 854: #if __STDC__
855: udp_output(struct mbuf *m, ...)
856: #else
857: udp_output(m, va_alist)
858: struct mbuf *m;
859: va_dcl
860: #endif
861: {
1.66 augustss 862: struct inpcb *inp;
863: struct udpiphdr *ui;
864: int len = m->m_pkthdr.len;
1.31 mycroft 865: int error = 0;
1.27 christos 866: va_list ap;
867:
1.98 matt 868: MCLAIM(m, &udp_tx_mowner);
1.27 christos 869: va_start(ap, m);
870: inp = va_arg(ap, struct inpcb *);
871: va_end(ap);
1.1 cgd 872:
873: /*
874: * Calculate data length and get a mbuf
875: * for UDP and IP headers.
876: */
1.13 mycroft 877: M_PREPEND(m, sizeof(struct udpiphdr), M_DONTWAIT);
878: if (m == 0) {
879: error = ENOBUFS;
1.39 thorpej 880: goto release;
881: }
882:
883: /*
884: * Compute the packet length of the IP header, and
885: * punt if the length looks bogus.
886: */
1.96 itojun 887: if (len + sizeof(struct udpiphdr) > IP_MAXPACKET) {
1.39 thorpej 888: error = EMSGSIZE;
1.13 mycroft 889: goto release;
890: }
1.1 cgd 891:
892: /*
893: * Fill in mbuf with extended UDP header
894: * and addresses and length put into network format.
895: */
896: ui = mtod(m, struct udpiphdr *);
897: ui->ui_pr = IPPROTO_UDP;
898: ui->ui_src = inp->inp_laddr;
899: ui->ui_dst = inp->inp_faddr;
900: ui->ui_sport = inp->inp_lport;
901: ui->ui_dport = inp->inp_fport;
1.78 thorpej 902: ui->ui_ulen = htons((u_int16_t)len + sizeof(struct udphdr));
1.1 cgd 903:
904: /*
1.78 thorpej 905: * Set up checksum and output datagram.
1.1 cgd 906: */
907: if (udpcksum) {
1.78 thorpej 908: /*
909: * XXX Cache pseudo-header checksum part for
910: * XXX "connected" UDP sockets.
911: */
912: ui->ui_sum = in_cksum_phdr(ui->ui_src.s_addr,
913: ui->ui_dst.s_addr, htons((u_int16_t)len +
914: sizeof(struct udphdr) + IPPROTO_UDP));
915: m->m_pkthdr.csum_flags = M_CSUM_UDPv4;
916: m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum);
917: } else
918: ui->ui_sum = 0;
1.96 itojun 919: ((struct ip *)ui)->ip_len = htons(sizeof (struct udpiphdr) + len);
1.1 cgd 920: ((struct ip *)ui)->ip_ttl = inp->inp_ip.ip_ttl; /* XXX */
921: ((struct ip *)ui)->ip_tos = inp->inp_ip.ip_tos; /* XXX */
922: udpstat.udps_opackets++;
1.48 itojun 923:
1.31 mycroft 924: return (ip_output(m, inp->inp_options, &inp->inp_route,
1.12 mycroft 925: inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST),
1.107 itojun 926: inp->inp_moptions, inp->inp_socket));
1.1 cgd 927:
928: release:
929: m_freem(m);
930: return (error);
931: }
932:
1.42 thorpej 933: int udp_sendspace = 9216; /* really max datagram size */
934: int udp_recvspace = 40 * (1024 + sizeof(struct sockaddr_in));
1.1 cgd 935: /* 40 1K datagrams */
936:
937: /*ARGSUSED*/
1.7 mycroft 938: int
1.103 fvdl 939: udp_usrreq(so, req, m, nam, control, p)
1.1 cgd 940: struct socket *so;
941: int req;
1.31 mycroft 942: struct mbuf *m, *nam, *control;
1.103 fvdl 943: struct proc *p;
1.1 cgd 944: {
1.66 augustss 945: struct inpcb *inp;
1.1 cgd 946: int s;
1.66 augustss 947: int error = 0;
1.1 cgd 948:
949: if (req == PRU_CONTROL)
1.31 mycroft 950: return (in_control(so, (long)m, (caddr_t)nam,
1.30 mycroft 951: (struct ifnet *)control, p));
1.59 thorpej 952:
1.60 thorpej 953: if (req == PRU_PURGEIF) {
1.80 itojun 954: in_pcbpurgeif0(&udbtable, (struct ifnet *)control);
1.60 thorpej 955: in_purgeif((struct ifnet *)control);
956: in_pcbpurgeif(&udbtable, (struct ifnet *)control);
1.59 thorpej 957: return (0);
958: }
1.31 mycroft 959:
960: s = splsoftnet();
961: inp = sotoinpcb(so);
1.32 mycroft 962: #ifdef DIAGNOSTIC
963: if (req != PRU_SEND && req != PRU_SENDOOB && control)
964: panic("udp_usrreq: unexpected control mbuf");
965: #endif
1.31 mycroft 966: if (inp == 0 && req != PRU_ATTACH) {
967: error = EINVAL;
968: goto release;
969: }
970:
1.1 cgd 971: /*
972: * Note: need to block udp_input while changing
973: * the udp pcb queue and/or pcb addresses.
974: */
975: switch (req) {
976:
977: case PRU_ATTACH:
1.31 mycroft 978: if (inp != 0) {
979: error = EISCONN;
1.1 cgd 980: break;
981: }
1.98 matt 982: #ifdef MBUFTRACE
983: so->so_mowner = &udp_mowner;
984: so->so_rcv.sb_mowner = &udp_rx_mowner;
985: so->so_snd.sb_mowner = &udp_tx_mowner;
986: #endif
1.31 mycroft 987: if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
988: error = soreserve(so, udp_sendspace, udp_recvspace);
989: if (error)
990: break;
991: }
1.18 mycroft 992: error = in_pcballoc(so, &udbtable);
1.1 cgd 993: if (error)
994: break;
1.31 mycroft 995: inp = sotoinpcb(so);
996: inp->inp_ip.ip_ttl = ip_defttl;
1.1 cgd 997: break;
998:
999: case PRU_DETACH:
1.31 mycroft 1000: in_pcbdetach(inp);
1.1 cgd 1001: break;
1002:
1003: case PRU_BIND:
1.31 mycroft 1004: error = in_pcbbind(inp, nam, p);
1.1 cgd 1005: break;
1006:
1007: case PRU_LISTEN:
1008: error = EOPNOTSUPP;
1009: break;
1010:
1011: case PRU_CONNECT:
1.31 mycroft 1012: error = in_pcbconnect(inp, nam);
1013: if (error)
1.1 cgd 1014: break;
1.31 mycroft 1015: soisconnected(so);
1.1 cgd 1016: break;
1017:
1018: case PRU_CONNECT2:
1019: error = EOPNOTSUPP;
1020: break;
1021:
1022: case PRU_DISCONNECT:
1.31 mycroft 1023: /*soisdisconnected(so);*/
1024: so->so_state &= ~SS_ISCONNECTED; /* XXX */
1.1 cgd 1025: in_pcbdisconnect(inp);
1.34 mycroft 1026: inp->inp_laddr = zeroin_addr; /* XXX */
1.35 mycroft 1027: in_pcbstate(inp, INP_BOUND); /* XXX */
1.1 cgd 1028: break;
1029:
1030: case PRU_SHUTDOWN:
1031: socantsendmore(so);
1032: break;
1033:
1.31 mycroft 1034: case PRU_RCVD:
1035: error = EOPNOTSUPP;
1.1 cgd 1036: break;
1037:
1.31 mycroft 1038: case PRU_SEND:
1.32 mycroft 1039: if (control && control->m_len) {
1040: m_freem(control);
1041: m_freem(m);
1042: error = EINVAL;
1043: break;
1044: }
1.31 mycroft 1045: {
1.35 mycroft 1046: struct in_addr laddr; /* XXX */
1.1 cgd 1047:
1.31 mycroft 1048: if (nam) {
1.35 mycroft 1049: laddr = inp->inp_laddr; /* XXX */
1.31 mycroft 1050: if ((so->so_state & SS_ISCONNECTED) != 0) {
1051: error = EISCONN;
1.32 mycroft 1052: goto die;
1.31 mycroft 1053: }
1054: error = in_pcbconnect(inp, nam);
1.100 matt 1055: if (error)
1056: goto die;
1.31 mycroft 1057: } else {
1058: if ((so->so_state & SS_ISCONNECTED) == 0) {
1059: error = ENOTCONN;
1.32 mycroft 1060: goto die;
1.31 mycroft 1061: }
1062: }
1.33 mycroft 1063: error = udp_output(m, inp);
1.100 matt 1064: m = NULL;
1.31 mycroft 1065: if (nam) {
1066: in_pcbdisconnect(inp);
1.35 mycroft 1067: inp->inp_laddr = laddr; /* XXX */
1068: in_pcbstate(inp, INP_BOUND); /* XXX */
1.31 mycroft 1069: }
1.100 matt 1070: die:
1071: if (m)
1072: m_freem(m);
1.31 mycroft 1073: }
1.1 cgd 1074: break;
1075:
1076: case PRU_SENSE:
1077: /*
1078: * stat: don't bother with a blocksize.
1079: */
1.31 mycroft 1080: splx(s);
1.1 cgd 1081: return (0);
1082:
1.31 mycroft 1083: case PRU_RCVOOB:
1084: error = EOPNOTSUPP;
1085: break;
1086:
1.1 cgd 1087: case PRU_SENDOOB:
1.32 mycroft 1088: m_freem(control);
1.31 mycroft 1089: m_freem(m);
1.1 cgd 1090: error = EOPNOTSUPP;
1091: break;
1092:
1.31 mycroft 1093: case PRU_SOCKADDR:
1094: in_setsockaddr(inp, nam);
1095: break;
1096:
1097: case PRU_PEERADDR:
1098: in_setpeeraddr(inp, nam);
1099: break;
1.1 cgd 1100:
1101: default:
1102: panic("udp_usrreq");
1103: }
1104:
1105: release:
1.31 mycroft 1106: splx(s);
1.1 cgd 1107: return (error);
1.13 mycroft 1108: }
1109:
1110: /*
1111: * Sysctl for udp variables.
1112: */
1.114 atatat 1113: SYSCTL_SETUP(sysctl_net_inet_udp_setup, "sysctl net.inet.udp subtree setup")
1.13 mycroft 1114: {
1.114 atatat 1115:
1.116 atatat 1116: sysctl_createv(clog, 0, NULL, NULL,
1117: CTLFLAG_PERMANENT,
1.114 atatat 1118: CTLTYPE_NODE, "net", NULL,
1119: NULL, 0, NULL, 0,
1120: CTL_NET, CTL_EOL);
1.116 atatat 1121: sysctl_createv(clog, 0, NULL, NULL,
1122: CTLFLAG_PERMANENT,
1.114 atatat 1123: CTLTYPE_NODE, "inet", NULL,
1124: NULL, 0, NULL, 0,
1125: CTL_NET, PF_INET, CTL_EOL);
1.116 atatat 1126: sysctl_createv(clog, 0, NULL, NULL,
1127: CTLFLAG_PERMANENT,
1.114 atatat 1128: CTLTYPE_NODE, "udp", NULL,
1129: NULL, 0, NULL, 0,
1130: CTL_NET, PF_INET, IPPROTO_UDP, CTL_EOL);
1131:
1.116 atatat 1132: sysctl_createv(clog, 0, NULL, NULL,
1133: CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
1.114 atatat 1134: CTLTYPE_INT, "checksum", NULL,
1135: NULL, 0, &udpcksum, 0,
1136: CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_CHECKSUM,
1137: CTL_EOL);
1.116 atatat 1138: sysctl_createv(clog, 0, NULL, NULL,
1139: CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
1.114 atatat 1140: CTLTYPE_INT, "sendspace", NULL,
1141: NULL, 0, &udp_sendspace, 0,
1142: CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_SENDSPACE,
1143: CTL_EOL);
1.116 atatat 1144: sysctl_createv(clog, 0, NULL, NULL,
1145: CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
1.114 atatat 1146: CTLTYPE_INT, "recvspace", NULL,
1147: NULL, 0, &udp_recvspace, 0,
1148: CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_RECVSPACE,
1149: CTL_EOL);
1.1 cgd 1150: }
1.72 itojun 1151: #endif
CVSweb <webmaster@jp.NetBSD.org>