1 /* $OpenBSD: udp_var.h,v 1.35 2020/08/22 17:54:57 gnezdo 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_inswcsum; /* input software-csummed packets */ 68 /* output statistics: */ 69 u_long udps_opackets; /* total output packets */ 70 u_long 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_ROOTONLY 6 /* root only port bitmap */ 82 #define UDPCTL_MAXID 7 83 84 #define UDPCTL_NAMES { \ 85 { 0, 0 }, \ 86 { "checksum", CTLTYPE_INT }, \ 87 { "baddynamic", CTLTYPE_STRUCT }, \ 88 { "recvspace", CTLTYPE_INT }, \ 89 { "sendspace", CTLTYPE_INT }, \ 90 { "stats", CTLTYPE_STRUCT }, \ 91 { "rootonly", CTLTYPE_STRUCT }, \ 92 } 93 94 #ifdef _KERNEL 95 96 #include <sys/percpu.h> 97 98 enum udpstat_counters { 99 /* input statistics: */ 100 udps_ipackets, /* total input packets */ 101 udps_hdrops, /* packet shorter than header */ 102 udps_badsum, /* checksum error */ 103 udps_nosum, /* no checksum */ 104 udps_badlen, /* data length larger than packet */ 105 udps_noport, /* no socket on port */ 106 udps_noportbcast, /* of above, arrived as broadcast */ 107 udps_nosec, /* dropped for lack of ipsec */ 108 udps_fullsock, /* not delivered, input socket full */ 109 udps_pcbhashmiss, /* input packets missing pcb hash */ 110 udps_inswcsum, /* input software-csummed packets */ 111 /* output statistics: */ 112 udps_opackets, /* total output packets */ 113 udps_outswcsum, /* output software-csummed packets */ 114 115 udps_ncounters 116 }; 117 118 extern struct cpumem *udpcounters; 119 120 static inline void 121 udpstat_inc(enum udpstat_counters c) 122 { 123 counters_inc(udpcounters, c); 124 } 125 126 extern struct inpcbtable udbtable; 127 extern struct udpstat udpstat; 128 129 #ifdef INET6 130 void udp6_ctlinput(int, struct sockaddr *, u_int, void *); 131 #endif /* INET6 */ 132 void udp_ctlinput(int, struct sockaddr *, u_int, void *); 133 void udp_init(void); 134 int udp_input(struct mbuf **, int *, int, int); 135 #ifdef INET6 136 int udp6_output(struct inpcb *, struct mbuf *, struct mbuf *, 137 struct mbuf *); 138 #endif /* INET6 */ 139 int udp_sysctl(int *, u_int, void *, size_t *, void *, size_t); 140 int udp_usrreq(struct socket *, 141 int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *); 142 int udp_attach(struct socket *, int); 143 int udp_detach(struct socket *); 144 #endif /* _KERNEL */ 145 #endif /* _NETINET_UDP_VAR_H_ */ 146