1 /* $OpenBSD: udp_var.h,v 1.16 2004/02/17 12:07:45 markus 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 */
41 struct 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
55 struct udpstat {
56 /* input statistics: */
57 u_long udps_ipackets; /* total input packets */
58 u_long udps_hdrops; /* packet shorter than header */
59 u_long udps_badsum; /* checksum error */
60 u_long udps_nosum; /* no checksum */
61 u_long udps_badlen; /* data length larger than packet */
62 u_long udps_noport; /* no socket on port */
63 u_long udps_noportbcast; /* of above, arrived as broadcast */
64 u_long udps_nosec; /* dropped for lack of ipsec */
65 u_long udps_fullsock; /* not delivered, input socket full */
66 u_long udps_pcbhashmiss; /* input packets missing pcb hash */
67 u_long udps_inhwcsum; /* input hardware-csummed packets */
68 /* output statistics: */
69 u_long udps_opackets; /* total output packets */
70 u_long udps_outhwcsum; /* output hardware-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_MAXID 5
81
82 #define UDPCTL_NAMES { \
83 { 0, 0 }, \
84 { "checksum", CTLTYPE_INT }, \
85 { "baddynamic", CTLTYPE_STRUCT }, \
86 { "recvspace", CTLTYPE_INT }, \
87 { "sendspace", CTLTYPE_INT }, \
88 }
89
90 #define UDPCTL_VARS { \
91 NULL, \
92 &udpcksum, \
93 NULL, \
94 &udp_recvspace, \
95 &udp_sendspace, \
96 }
97
98 #ifdef _KERNEL
99 extern struct inpcbtable udbtable;
100 extern struct udpstat udpstat;
101
102 #if defined(INET6) && !defined(TCP6)
103 void udp6_ctlinput(int, struct sockaddr *, void *);
104 int udp6_input(struct mbuf **, int *, int);
105 int udp6_usrreq(struct socket *,
106 int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
107 #endif /* INET6 && !TCP6 */
108 void *udp_ctlinput(int, struct sockaddr *, void *);
109 void udp_init(void);
110 void udp_input(struct mbuf *, ...);
111 #ifdef INET6
112 int udp6_output(struct inpcb *, struct mbuf *, struct mbuf *,
113 struct mbuf *);
114 #endif /* INET6 */
115 int udp_output(struct mbuf *, ...);
116 int udp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
117 int udp_usrreq(struct socket *,
118 int, struct mbuf *, struct mbuf *, struct mbuf *);
119 #endif /* _KERNEL */
120 #endif /* _NETINET_UDP_VAR_H_ */