xref: /openbsd-src/sys/netinet/udp_var.h (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1 /*	$OpenBSD: udp_var.h,v 1.12 2001/06/23 06:03:14 angelos Exp $	*/
2 /*	$NetBSD: udp_var.h,v 1.12 1996/02/13 23:44:41 christos Exp $	*/
3 
4 /*
5  * Copyright (c) 1982, 1986, 1989, 1993
6  *	The Regents of the University of California.  All rights reserved.
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. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *	This product includes software developed by the University of
19  *	California, Berkeley and its contributors.
20  * 4. Neither the name of the University nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  *	@(#)udp_var.h	8.1 (Berkeley) 6/10/93
37  */
38 
39 #ifndef _NETINET_UDP_VAR_H_
40 #define _NETINET_UDP_VAR_H_
41 
42 /*
43  * UDP kernel structures and variables.
44  */
45 struct	udpiphdr {
46 	struct	ipovly ui_i;		/* overlaid ip structure */
47 	struct	udphdr ui_u;		/* udp header */
48 };
49 #define	ui_x1		ui_i.ih_x1
50 #define	ui_pr		ui_i.ih_pr
51 #define	ui_len		ui_i.ih_len
52 #define	ui_src		ui_i.ih_src
53 #define	ui_dst		ui_i.ih_dst
54 #define	ui_sport	ui_u.uh_sport
55 #define	ui_dport	ui_u.uh_dport
56 #define	ui_ulen		ui_u.uh_ulen
57 #define	ui_sum		ui_u.uh_sum
58 
59 struct	udpstat {
60 				/* input statistics: */
61 	u_long	udps_ipackets;		/* total input packets */
62 	u_long	udps_hdrops;		/* packet shorter than header */
63 	u_long	udps_badsum;		/* checksum error */
64 	u_long	udps_nosum;		/* no checksum */
65 	u_long	udps_badlen;		/* data length larger than packet */
66 	u_long	udps_noport;		/* no socket on port */
67 	u_long	udps_noportbcast;	/* of above, arrived as broadcast */
68 	u_long	udps_nosec;		/* dropped for lack of ipsec */
69 	u_long	udps_fullsock;		/* not delivered, input socket full */
70 	u_long	udps_pcbhashmiss;	/* input packets missing pcb hash */
71 	u_long	udps_inhwcsum;		/* input hardware-csummed packets */
72 				/* output statistics: */
73 	u_long	udps_opackets;		/* total output packets */
74 	u_long	udps_outhwcsum;		/* output hardware-csummed packets */
75 };
76 
77 /*
78  * Names for UDP sysctl objects
79  */
80 #define	UDPCTL_CHECKSUM		1 /* checksum UDP packets */
81 #define	UDPCTL_BADDYNAMIC	2 /* return bad dynamic port bitmap */
82 #define UDPCTL_RECVSPACE	3 /* receive buffer space */
83 #define UDPCTL_SENDSPACE	4 /* send buffer space */
84 #define UDPCTL_MAXID		5
85 
86 #define UDPCTL_NAMES { \
87 	{ 0, 0 }, \
88 	{ "checksum", CTLTYPE_INT }, \
89 	{ "baddynamic", CTLTYPE_STRUCT }, \
90 	{ "recvspace",  CTLTYPE_INT }, \
91 	{ "sendspace",  CTLTYPE_INT }, \
92 }
93 
94 #ifdef _KERNEL
95 struct	inpcbtable udbtable;
96 struct	udpstat udpstat;
97 
98 #if defined(INET6) && !defined(TCP6)
99 void	udp6_ctlinput __P((int, struct sockaddr *, void *));
100 int	udp6_input __P((struct mbuf **, int *, int));
101 int	udp6_usrreq __P((struct socket *,
102 	    int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *));
103 #endif /* INET6 && !TCP6 */
104 void	 *udp_ctlinput __P((int, struct sockaddr *, void *));
105 void	 udp_init __P((void));
106 void	 udp_input __P((struct mbuf *, ...));
107 #ifdef INET6
108 int	 udp6_output __P((struct inpcb *, struct mbuf *, struct mbuf *,
109 	struct mbuf *));
110 #endif /* INET6 */
111 int	 udp_output __P((struct mbuf *, ...));
112 int	 udp_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
113 int	 udp_usrreq __P((struct socket *,
114 	    int, struct mbuf *, struct mbuf *, struct mbuf *));
115 #endif /* _KERNEL */
116 #endif /* _NETINET_UDP_VAR_H_ */
117