1 /* 2 * Copyright (c) 2003, 2004 Jeffrey M. Hsu. All rights reserved. 3 * Copyright (c) 2003, 2004 The DragonFly Project. All rights reserved. 4 * 5 * This code is derived from software contributed to The DragonFly Project 6 * by Jeffrey M. Hsu. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of The DragonFly Project nor the names of its 17 * contributors may be used to endorse or promote products derived 18 * from this software without specific, prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34 /* 35 * Copyright (c) 2003, 2004 Jeffrey M. Hsu. All rights reserved. 36 * 37 * License terms: all terms for the DragonFly license above plus the following: 38 * 39 * 4. All advertising materials mentioning features or use of this software 40 * must display the following acknowledgement: 41 * 42 * This product includes software developed by Jeffrey M. Hsu 43 * for the DragonFly Project. 44 * 45 * This requirement may be waived with permission from Jeffrey Hsu. 46 * This requirement will sunset and may be removed on July 8 2005, 47 * after which the standard DragonFly license (as shown above) will 48 * apply. 49 */ 50 51 /* 52 * Copyright (c) 1982, 1986, 1989, 1993 53 * The Regents of the University of California. All rights reserved. 54 * 55 * Redistribution and use in source and binary forms, with or without 56 * modification, are permitted provided that the following conditions 57 * are met: 58 * 1. Redistributions of source code must retain the above copyright 59 * notice, this list of conditions and the following disclaimer. 60 * 2. Redistributions in binary form must reproduce the above copyright 61 * notice, this list of conditions and the following disclaimer in the 62 * documentation and/or other materials provided with the distribution. 63 * 3. All advertising materials mentioning features or use of this software 64 * must display the following acknowledgement: 65 * This product includes software developed by the University of 66 * California, Berkeley and its contributors. 67 * 4. Neither the name of the University nor the names of its contributors 68 * may be used to endorse or promote products derived from this software 69 * without specific prior written permission. 70 * 71 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 72 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 73 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 74 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 75 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 76 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 77 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 78 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 79 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 80 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 81 * SUCH DAMAGE. 82 * 83 * @(#)udp_var.h 8.1 (Berkeley) 6/10/93 84 * $FreeBSD: src/sys/netinet/udp_var.h,v 1.22.2.1 2001/02/18 07:12:25 luigi Exp $ 85 * $DragonFly: src/sys/netinet/udp_var.h,v 1.14 2006/05/20 02:42:12 dillon Exp $ 86 */ 87 88 #ifndef _NETINET_UDP_VAR_H_ 89 #define _NETINET_UDP_VAR_H_ 90 91 #ifndef _NETINET_IP_VAR_H_ 92 #include <netinet/ip_var.h> 93 #endif 94 #ifndef _NETINET_UDP_H_ 95 #include <netinet/udp.h> 96 #endif 97 98 /* 99 * UDP kernel structures and variables. 100 */ 101 struct udpiphdr { 102 struct ipovly ui_i; /* overlaid ip structure */ 103 struct udphdr ui_u; /* udp header */ 104 }; 105 #define ui_x1 ui_i.ih_x1 106 #define ui_pr ui_i.ih_pr 107 #define ui_len ui_i.ih_len 108 #define ui_src ui_i.ih_src 109 #define ui_dst ui_i.ih_dst 110 #define ui_sport ui_u.uh_sport 111 #define ui_dport ui_u.uh_dport 112 #define ui_ulen ui_u.uh_ulen 113 #define ui_sum ui_u.uh_sum 114 115 struct udpstat { 116 /* input statistics: */ 117 u_long udps_ipackets; /* total input packets */ 118 u_long udps_hdrops; /* packet shorter than header */ 119 u_long udps_badsum; /* checksum error */ 120 u_long udps_nosum; /* no checksum */ 121 u_long udps_badlen; /* data length larger than packet */ 122 u_long udps_noport; /* no socket on port */ 123 u_long udps_noportbcast; /* of above, arrived as broadcast */ 124 u_long udps_fullsock; /* not delivered, input socket full */ 125 u_long udpps_pcbcachemiss; /* input packets missing pcb cache */ 126 u_long udpps_pcbhashmiss; /* input packets not for hashed pcb */ 127 /* output statistics: */ 128 u_long udps_opackets; /* total output packets */ 129 u_long udps_fastout; /* output packets on fast path */ 130 /* of no socket on port, arrived as multicast */ 131 u_long udps_noportmcast; 132 }; 133 134 /* 135 * Names for UDP sysctl objects 136 */ 137 #define UDPCTL_CHECKSUM 1 /* checksum UDP packets */ 138 #define UDPCTL_STATS 2 /* statistics (read-only) */ 139 #define UDPCTL_MAXDGRAM 3 /* max datagram size */ 140 #define UDPCTL_RECVSPACE 4 /* default receive buffer space */ 141 #define UDPCTL_PCBLIST 5 /* list of PCBs for UDP sockets */ 142 #define UDPCTL_MAXID 6 143 144 #define UDPCTL_NAMES { \ 145 { 0, 0 }, \ 146 { "checksum", CTLTYPE_INT }, \ 147 { "stats", CTLTYPE_STRUCT }, \ 148 { "maxdgram", CTLTYPE_INT }, \ 149 { "recvspace", CTLTYPE_INT }, \ 150 { "pcblist", CTLTYPE_STRUCT }, \ 151 } 152 153 #ifdef _KERNEL 154 #ifdef SYSCTL_DECL 155 SYSCTL_DECL(_net_inet_udp); 156 #endif 157 158 extern struct pr_usrreqs udp_usrreqs; 159 extern struct inpcbinfo udbinfo; 160 extern u_long udp_sendspace; 161 extern u_long udp_recvspace; 162 extern struct udpstat udpstat; 163 extern int log_in_vain; 164 165 int udp_addrcpu (in_addr_t faddr, in_port_t fport, 166 in_addr_t laddr, in_port_t lport); 167 void udp_ctlinput (int, struct sockaddr *, void *); 168 void udp_init (void); 169 void udp_thread_init (void); 170 void udp_input (struct mbuf *, ...); 171 void udp_notify (struct inpcb *inp, int errno); 172 int udp_shutdown (struct socket *so); 173 struct lwkt_port *udp_soport (struct socket *, struct sockaddr *, int); 174 175 #endif 176 177 #endif 178