1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef _LINUX_UDP_H
18#define _LINUX_UDP_H
19
20#include <net/inet_sock.h>
21#include <linux/skbuff.h>
22#include <net/netns/hash.h>
23#include <uapi/linux/udp.h>
24
25static inline struct udphdr *udp_hdr(const struct sk_buff *skb)
26{
27 return (struct udphdr *)skb_transport_header(skb);
28}
29
30#define UDP_HTABLE_SIZE_MIN (CONFIG_BASE_SMALL ? 128 : 256)
31
32static inline int udp_hashfn(struct net *net, unsigned num, unsigned mask)
33{
34 return (num + net_hash_mix(net)) & mask;
35}
36
37struct udp_sock {
38
39 struct inet_sock inet;
40#define udp_port_hash inet.sk.__sk_common.skc_u16hashes[0]
41#define udp_portaddr_hash inet.sk.__sk_common.skc_u16hashes[1]
42#define udp_portaddr_node inet.sk.__sk_common.skc_portaddr_node
43 int pending;
44 unsigned int corkflag;
45 __u16 encap_type;
46
47
48
49
50 __u16 len;
51
52
53
54 __u16 pcslen;
55 __u16 pcrlen;
56
57#define UDPLITE_BIT 0x1
58#define UDPLITE_SEND_CC 0x2
59#define UDPLITE_RECV_CC 0x4
60 __u8 pcflag;
61 __u8 unused[3];
62
63
64
65 int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);
66};
67
68static inline struct udp_sock *udp_sk(const struct sock *sk)
69{
70 return (struct udp_sock *)sk;
71}
72
73#define udp_portaddr_for_each_entry(__sk, node, list) \
74 hlist_nulls_for_each_entry(__sk, node, list, __sk_common.skc_portaddr_node)
75
76#define udp_portaddr_for_each_entry_rcu(__sk, node, list) \
77 hlist_nulls_for_each_entry_rcu(__sk, node, list, __sk_common.skc_portaddr_node)
78
79#define IS_UDPLITE(__sk) (udp_sk(__sk)->pcflag)
80
81#endif
82