VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/slirp/udp.h

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1/* $Id: udp.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * NAT - UDP protocol (declarations/defines).
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*
30 * This code is based on:
31 *
32 * Copyright (c) 1982, 1986, 1993
33 * The Regents of the University of California. All rights reserved.
34 *
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
37 * are met:
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 * notice, this list of conditions and the following disclaimer in the
42 * documentation and/or other materials provided with the distribution.
43 * 3. Neither the name of the University nor the names of its contributors
44 * may be used to endorse or promote products derived from this software
45 * without specific prior written permission.
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
48 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * SUCH DAMAGE.
58 *
59 * @(#)udp.h 8.1 (Berkeley) 6/10/93
60 * udp.h,v 1.3 1994/08/21 05:27:41 paul Exp
61 */
62
63#ifndef _UDP_H_
64#define _UDP_H_
65
66#define UDP_TTL 0x60
67#define UDP_UDPDATALEN 16192
68
69extern struct socket *udp_last_so;
70
71/*
72 * Udp protocol header.
73 * Per RFC 768, September, 1981.
74 */
75struct udphdr
76{
77 uint16_t uh_sport; /* source port */
78 uint16_t uh_dport; /* destination port */
79 int16_t uh_ulen; /* udp length */
80 uint16_t uh_sum; /* udp checksum */
81};
82AssertCompileSize(struct udphdr, 8);
83
84/*
85 * UDP kernel structures and variables.
86 */
87struct udpiphdr
88{
89 struct ipovly ui_i; /* overlaid ip structure */
90 struct udphdr ui_u; /* udp header */
91};
92AssertCompileSize(struct udpiphdr, 28);
93#define ui_next ui_i.ih_next
94#define ui_prev ui_i.ih_prev
95#define ui_x1 ui_i.ih_x1
96#define ui_pr ui_i.ih_pr
97#define ui_len ui_i.ih_len
98#define ui_src ui_i.ih_src
99#define ui_dst ui_i.ih_dst
100#define ui_sport ui_u.uh_sport
101#define ui_dport ui_u.uh_dport
102#define ui_ulen ui_u.uh_ulen
103#define ui_sum ui_u.uh_sum
104
105struct udpstat_t
106{
107 /* input statistics: */
108 u_long udps_ipackets; /* total input packets */
109 u_long udps_hdrops; /* packet shorter than header */
110 u_long udps_badsum; /* checksum error */
111 u_long udps_badlen; /* data length larger than packet */
112 u_long udps_noport; /* no socket on port */
113 u_long udps_noportbcast; /* of above, arrived as broadcast */
114 u_long udps_fullsock; /* not delivered, input socket full */
115 u_long udpps_pcbcachemiss; /* input packets missing pcb cache */
116 /* output statistics: */
117 u_long udps_opackets; /* total output packets */
118};
119
120/*
121 * Names for UDP sysctl objects
122 */
123#define UDPCTL_CHECKSUM 1 /* checksum UDP packets */
124#define UDPCTL_MAXID 2
125
126extern struct udpstat udpstat;
127extern struct socket udb;
128struct mbuf;
129
130void udp_init (PNATState);
131void udp_input (PNATState, register struct mbuf *, int);
132int udp_output (PNATState, struct socket *, struct mbuf *, struct sockaddr_in *);
133int udp_attach (PNATState, struct socket *);
134void udp_detach (PNATState, struct socket *);
135u_int8_t udp_tos (struct socket *);
136void udp_emu (PNATState, struct socket *, struct mbuf *);
137struct socket * udp_listen (PNATState, u_int32_t, u_int, u_int32_t, u_int, int);
138int udp_output2(PNATState pData, struct socket *so, struct mbuf *m,
139 struct sockaddr_in *saddr, struct sockaddr_in *daddr,
140 int iptos);
141
142#endif
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use