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