1 /*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions for the UDP module.
7 *
8 * Version: @(#)udp.h 1.0.2 05/07/93
9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu>
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 *
13 * Fixes:
14 * Alan Cox : Turned on udp checksums. I don't want to
15 * chase 'memory corruption' bugs that aren't!
16 *
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version
20 * 2 of the License, or (at your option) any later version.
21 */
22 #ifndef _UDP_H
23 #define _UDP_H
24
25 #include <linux/udp.h>
26 #include <linux/poll.h>
27 #include <net/sock.h>
28 #include <net/snmp.h>
29
30 #define UDP_HTABLE_SIZE 128
31
32 /* udp.c: This needs to be shared by v4 and v6 because the lookup
33 * and hashing code needs to work with different AF's yet
34 * the port space is shared.
35 */
36 extern struct sock *udp_hash[UDP_HTABLE_SIZE];
37 extern rwlock_t udp_hash_lock;
38
39 extern int udp_port_rover;
40
udp_lport_inuse(u16 num)41 static inline int udp_lport_inuse(u16 num)
42 {
43 struct sock *sk = udp_hash[num & (UDP_HTABLE_SIZE - 1)];
44
45 for(; sk != NULL; sk = sk->next) {
46 if(sk->num == num)
47 return 1;
48 }
49 return 0;
50 }
51
52 /* Note: this must match 'valbool' in sock_setsockopt */
53 #define UDP_CSUM_NOXMIT 1
54
55 /* Used by SunRPC/xprt layer. */
56 #define UDP_CSUM_NORCV 2
57
58 /* Default, as per the RFC, is to always do csums. */
59 #define UDP_CSUM_DEFAULT 0
60
61 extern struct proto udp_prot;
62
63
64 extern void udp_err(struct sk_buff *, u32);
65 extern int udp_connect(struct sock *sk,
66 struct sockaddr *usin, int addr_len);
67
68 extern int udp_sendmsg(struct sock *sk, struct msghdr *msg, int len);
69
70 extern int udp_rcv(struct sk_buff *skb);
71 extern int udp_ioctl(struct sock *sk, int cmd, unsigned long arg);
72 extern int udp_disconnect(struct sock *sk, int flags);
73 extern unsigned int udp_poll(struct file *file, struct socket *sock,
74 poll_table *wait);
75
76 extern struct udp_mib udp_statistics[NR_CPUS*2];
77 #define UDP_INC_STATS(field) SNMP_INC_STATS(udp_statistics, field)
78 #define UDP_INC_STATS_BH(field) SNMP_INC_STATS_BH(udp_statistics, field)
79 #define UDP_INC_STATS_USER(field) SNMP_INC_STATS_USER(udp_statistics, field)
80
81 #endif /* _UDP_H */
82