udp_var.h revision 190962
1139823Simp/*-
21541Srgrimes * Copyright (c) 1982, 1986, 1989, 1993
3166841Srwatson *	The Regents of the University of California.
4166841Srwatson * All rights reserved.
51541Srgrimes *
61541Srgrimes * Redistribution and use in source and binary forms, with or without
71541Srgrimes * modification, are permitted provided that the following conditions
81541Srgrimes * are met:
91541Srgrimes * 1. Redistributions of source code must retain the above copyright
101541Srgrimes *    notice, this list of conditions and the following disclaimer.
111541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
121541Srgrimes *    notice, this list of conditions and the following disclaimer in the
131541Srgrimes *    documentation and/or other materials provided with the distribution.
141541Srgrimes * 4. Neither the name of the University nor the names of its contributors
151541Srgrimes *    may be used to endorse or promote products derived from this software
161541Srgrimes *    without specific prior written permission.
171541Srgrimes *
181541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
191541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
201541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
211541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
221541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
231541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
241541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
251541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
261541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
271541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
281541Srgrimes * SUCH DAMAGE.
291541Srgrimes *
301541Srgrimes *	@(#)udp_var.h	8.1 (Berkeley) 6/10/93
3150477Speter * $FreeBSD: head/sys/netinet/udp_var.h 190962 2009-04-12 11:42:40Z rwatson $
321541Srgrimes */
331541Srgrimes
342169Spaul#ifndef _NETINET_UDP_VAR_H_
35166841Srwatson#define	_NETINET_UDP_VAR_H_
362169Spaul
371541Srgrimes/*
381541Srgrimes * UDP kernel structures and variables.
391541Srgrimes */
40166841Srwatsonstruct udpiphdr {
41166841Srwatson	struct ipovly	ui_i;		/* overlaid ip structure */
42166841Srwatson	struct udphdr	ui_u;		/* udp header */
431541Srgrimes};
441541Srgrimes#define	ui_x1		ui_i.ih_x1
451541Srgrimes#define	ui_pr		ui_i.ih_pr
461541Srgrimes#define	ui_len		ui_i.ih_len
471541Srgrimes#define	ui_src		ui_i.ih_src
481541Srgrimes#define	ui_dst		ui_i.ih_dst
491541Srgrimes#define	ui_sport	ui_u.uh_sport
501541Srgrimes#define	ui_dport	ui_u.uh_dport
511541Srgrimes#define	ui_ulen		ui_u.uh_ulen
521541Srgrimes#define	ui_sum		ui_u.uh_sum
531541Srgrimes
54166841Srwatsonstruct udpstat {
551541Srgrimes				/* input statistics: */
561541Srgrimes	u_long	udps_ipackets;		/* total input packets */
571541Srgrimes	u_long	udps_hdrops;		/* packet shorter than header */
581541Srgrimes	u_long	udps_badsum;		/* checksum error */
5952904Sshin	u_long	udps_nosum;		/* no checksum */
601541Srgrimes	u_long	udps_badlen;		/* data length larger than packet */
611541Srgrimes	u_long	udps_noport;		/* no socket on port */
621541Srgrimes	u_long	udps_noportbcast;	/* of above, arrived as broadcast */
631541Srgrimes	u_long	udps_fullsock;		/* not delivered, input socket full */
641541Srgrimes	u_long	udpps_pcbcachemiss;	/* input packets missing pcb cache */
6516143Swollman	u_long	udpps_pcbhashmiss;	/* input packets not for hashed pcb */
661541Srgrimes				/* output statistics: */
671541Srgrimes	u_long	udps_opackets;		/* total output packets */
6828270Swollman	u_long	udps_fastout;		/* output packets on fast path */
6952904Sshin	/* of no socket on port, arrived as multicast */
7052904Sshin	u_long	udps_noportmcast;
71170613Sbms	u_long	udps_filtermcast;	/* blocked by multicast filter */
721541Srgrimes};
731541Srgrimes
74190962Srwatson#ifdef _KERNEL
75190962Srwatson#define	UDPSTAT_ADD(name, val)	V_udpstat.name += (val)
76190962Srwatson#define	UDPSTAT_INC(name)	UDPSTAT_ADD(name, 1)
77190962Srwatson#endif
78190962Srwatson
791541Srgrimes/*
80166841Srwatson * Names for UDP sysctl objects.
811541Srgrimes */
821541Srgrimes#define	UDPCTL_CHECKSUM		1	/* checksum UDP packets */
83166841Srwatson#define	UDPCTL_STATS		2	/* statistics (read-only) */
846472Swollman#define	UDPCTL_MAXDGRAM		3	/* max datagram size */
856472Swollman#define	UDPCTL_RECVSPACE	4	/* default receive buffer space */
8636079Swollman#define	UDPCTL_PCBLIST		5	/* list of PCBs for UDP sockets */
87166841Srwatson#define	UDPCTL_MAXID		6
881541Srgrimes
89166841Srwatson#define	UDPCTL_NAMES	{						\
90166841Srwatson	{ 0, 0 },							\
91166841Srwatson	{ "checksum", CTLTYPE_INT },					\
92166841Srwatson	{ "stats", CTLTYPE_STRUCT },					\
93166841Srwatson	{ "maxdgram", CTLTYPE_INT },					\
94166841Srwatson	{ "recvspace", CTLTYPE_INT },					\
95166841Srwatson	{ "pcblist", CTLTYPE_STRUCT },					\
961541Srgrimes}
971541Srgrimes
9855205Speter#ifdef _KERNEL
9944078SdfrSYSCTL_DECL(_net_inet_udp);
10044078Sdfr
101166841Srwatsonextern struct pr_usrreqs	udp_usrreqs;
102185937Sbz
103185937Sbz#ifdef VIMAGE_GLOBALS
104166841Srwatsonextern struct inpcbhead		udb;
105166841Srwatsonextern struct inpcbinfo		udbinfo;
106185937Sbzextern struct udpstat		udpstat;
107185937Sbzextern int			udp_blackhole;
108185937Sbz#endif
109166841Srwatsonextern u_long			udp_sendspace;
110166841Srwatsonextern u_long			udp_recvspace;
111166842Srwatsonextern int			udp_log_in_vain;
1121541Srgrimes
113166841Srwatsonvoid		 udp_ctlinput(int, struct sockaddr *, void *);
114166841Srwatsonvoid		 udp_init(void);
115166841Srwatsonvoid		 udp_input(struct mbuf *, int);
116166841Srwatsonstruct inpcb	*udp_notify(struct inpcb *inp, int errno);
117166841Srwatsonint		 udp_shutdown(struct socket *so);
118186813Srrs
119186813Srrs
120186813Srrstypedef void(*udp_tun_func_t)(struct mbuf *, int off, struct inpcb *);
121186813Srrsint udp_set_kernel_tunneling(struct socket *so, udp_tun_func_t f);
1221541Srgrimes#endif
1232169Spaul
1242169Spaul#endif
125