VirtualBox

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

Last change on this file since 28587 was 28449, checked in by vboxsync, 15 years ago

NAT: slirp file headers

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette