1 /*
2  * Copyright (c) 2012
3  *      Inferno Nettverk A/S, Norway.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. The above copyright notice, this list of conditions and the following
9  *    disclaimer must appear in all copies of the software, derivative works
10  *    or modified versions, and any portions thereof, aswell as in all
11  *    supporting documentation.
12  * 2. All advertising materials mentioning features or use of this software
13  *    must display the following acknowledgement:
14  *      This product includes software developed by
15  *      Inferno Nettverk A/S, Norway.
16  * 3. The name of the author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * Inferno Nettverk A/S requests users of this software to return to
31  *
32  *  Software Distribution Coordinator  or  sdc@inet.no
33  *  Inferno Nettverk A/S
34  *  Oslo Research Park
35  *  Gaustadall�en 21
36  *  NO-0349 Oslo
37  *  Norway
38  *
39  * any improvements or extensions that they make and grant Inferno Nettverk A/S
40  * the rights to redistribute these changes.
41  *
42  */
43 
44 #ifdef HAVE_CONFIG_H
45 #include "autoconf.h"
46 #endif /* HAVE_CONFIG_H */
47 
48 /*
49  * The uh_dport/uh_sport values are only available on Linux when
50  * _BSD_SOURCE is set and _XOPEN_SOURCE/_XOPEN_SOURCE_EXTENDED
51  * is not set.
52  *
53  * Functions to access these fields are placed in this file,
54  * making this the only file where _XOPEN_SOURCE/_XOPEN_SOURCE_EXTENDED
55  * are not set.
56  */
57 
58 #if HAVE_LINUX_BUGS
59 #undef _XOPEN_SOURCE
60 #undef _XOPEN_SOURCE_EXTENDED
61 #endif /* HAVE_LINUX_BUGS */
62 
63 #include <sys/types.h>
64 #include <netinet/in_systm.h>
65 #include <netinet/in.h>
66 #include <netinet/ip.h>
67 #include <netinet/udp.h>
68 
69 static const char rcsid[] =
70 "$Id: udp_port.c,v 1.3 2012/08/08 13:17:05 michaels Exp $";
71 
72 in_port_t *udphdr_uh_dport(struct udphdr *udp);
73 in_port_t *udphdr_uh_sport(struct udphdr *udp);
74 uint16_t *udphdr_uh_ulen(struct udphdr *udp);
75 uint16_t *udphdr_uh_sum(struct udphdr *udp);
76 
77 in_port_t *
udphdr_uh_dport(struct udphdr * udp)78 udphdr_uh_dport(struct udphdr *udp)
79 {
80 
81    return &udp->uh_dport;
82 }
83 
84 in_port_t *
udphdr_uh_sport(struct udphdr * udp)85 udphdr_uh_sport(struct udphdr *udp)
86 {
87 
88    return &udp->uh_sport;
89 }
90 
91 uint16_t *
udphdr_uh_ulen(struct udphdr * udp)92 udphdr_uh_ulen(struct udphdr *udp)
93 {
94 
95    return &udp->uh_ulen;
96 }
97 
98 uint16_t *
udphdr_uh_sum(struct udphdr * udp)99 udphdr_uh_sum(struct udphdr *udp)
100 {
101 
102    return &udp->uh_sum;
103 }
104