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.
6 * Definitions for the UDP module.
8 * Version: @(#)udp.h 1.0.2 05/07/93
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
14 * Alan Cox : Turned on udp checksums. I don't want to
15 * chase 'memory corruption' bugs that aren't!
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.
25 #include <linux/udp.h>
27 #include <linux/list.h>
30 #include <linux/seq_file.h>
32 #define UDP_HTABLE_SIZE 128
34 /* udp.c: This needs to be shared by v4 and v6 because the lookup
35 * and hashing code needs to work with different AF's yet
36 * the port space is shared.
38 extern struct hlist_head udp_hash[UDP_HTABLE_SIZE];
39 extern rwlock_t udp_hash_lock;
41 extern int udp_port_rover;
43 static inline int udp_lport_inuse(u16 num)
46 struct hlist_node *node;
48 sk_for_each(sk, node, &udp_hash[num & (UDP_HTABLE_SIZE - 1)])
49 if (inet_sk(sk)->num == num)
54 /* Note: this must match 'valbool' in sock_setsockopt */
55 #define UDP_CSUM_NOXMIT 1
57 /* Used by SunRPC/xprt layer. */
58 #define UDP_CSUM_NORCV 2
60 /* Default, as per the RFC, is to always do csums. */
61 #define UDP_CSUM_DEFAULT 0
63 extern struct proto udp_prot;
66 extern void udp_err(struct sk_buff *, u32);
68 extern int udp_sendmsg(struct kiocb *iocb, struct sock *sk,
69 struct msghdr *msg, size_t len);
71 extern int udp_rcv(struct sk_buff *skb);
72 extern int udp_ioctl(struct sock *sk, int cmd, unsigned long arg);
73 extern int udp_disconnect(struct sock *sk, int flags);
74 extern unsigned int udp_poll(struct file *file, struct socket *sock,
77 DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);
78 #define UDP_INC_STATS(field) SNMP_INC_STATS(udp_statistics, field)
79 #define UDP_INC_STATS_BH(field) SNMP_INC_STATS_BH(udp_statistics, field)
80 #define UDP_INC_STATS_USER(field) SNMP_INC_STATS_USER(udp_statistics, field)
83 struct udp_seq_afinfo {
87 int (*seq_show) (struct seq_file *m, void *v);
88 struct file_operations *seq_fops;
91 struct udp_iter_state {
94 struct seq_operations seq_ops;
98 extern int udp_proc_register(struct udp_seq_afinfo *afinfo);
99 extern void udp_proc_unregister(struct udp_seq_afinfo *afinfo);
101 extern int udp4_proc_init(void);
102 extern void udp4_proc_exit(void);