Blame view

include/linux/udp.h 3.44 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  /*
   * INET		An implementation of the TCP/IP protocol suite for the LINUX
   *		operating system.  INET is implemented using the  BSD Socket
   *		interface as the means of communication with the user level.
   *
   *		Definitions for the UDP protocol.
   *
   * Version:	@(#)udp.h	1.0.2	04/28/93
   *
   * Author:	Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
   *
   *		This program is free software; you can redistribute it and/or
   *		modify it under the terms of the GNU General Public License
   *		as published by the Free Software Foundation; either version
   *		2 of the License, or (at your option) any later version.
   */
  #ifndef _LINUX_UDP_H
  #define _LINUX_UDP_H
14c850212   Arnaldo Carvalho de Melo   [INET_SOCK]: Move...
19
  #include <net/inet_sock.h>
310afe86a   Joe Perches   [NET]: include/li...
20
  #include <linux/skbuff.h>
0b4419162   Pavel Emelyanov   netns: introduce ...
21
  #include <net/netns/hash.h>
607ca46e9   David Howells   UAPI: (Scripted) ...
22
  #include <uapi/linux/udp.h>
310afe86a   Joe Perches   [NET]: include/li...
23
24
25
26
27
  
  static inline struct udphdr *udp_hdr(const struct sk_buff *skb)
  {
  	return (struct udphdr *)skb_transport_header(skb);
  }
6a674e9c7   Joseph Gasparakis   net: Add support ...
28
29
30
31
  static inline struct udphdr *inner_udp_hdr(const struct sk_buff *skb)
  {
  	return (struct udphdr *)skb_inner_transport_header(skb);
  }
f86dcc5aa   Eric Dumazet   udp: dynamically ...
32
  #define UDP_HTABLE_SIZE_MIN		(CONFIG_BASE_SMALL ? 128 : 256)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
33

6eada0110   Eric Dumazet   netns: constify n...
34
  static inline u32 udp_hashfn(const struct net *net, u32 num, u32 mask)
d6266281f   Pavel Emelyanov   udp: introduce a ...
35
  {
f86dcc5aa   Eric Dumazet   udp: dynamically ...
36
  	return (num + net_hash_mix(net)) & mask;
d6266281f   Pavel Emelyanov   udp: introduce a ...
37
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
38
39
40
  struct udp_sock {
  	/* inet_sock has to be the first member */
  	struct inet_sock inet;
d4cada4ae   Eric Dumazet   udp: split sk_has...
41
42
  #define udp_port_hash		inet.sk.__sk_common.skc_u16hashes[0]
  #define udp_portaddr_hash	inet.sk.__sk_common.skc_u16hashes[1]
512615b6b   Eric Dumazet   udp: secondary ha...
43
  #define udp_portaddr_node	inet.sk.__sk_common.skc_portaddr_node
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
44
45
  	int		 pending;	/* Any pending frames ? */
  	unsigned int	 corkflag;	/* Cork is required */
1c19448c9   Tom Herbert   net: Make enablin...
46
47
  	__u8		 encap_type;	/* Is this an Encapsulation socket? */
  	unsigned char	 no_check6_tx:1,/* Send zero UDP6 checksums on TX? */
224d019c4   Tom Herbert   ip: Move checksum...
48
  			 no_check6_rx:1;/* Allow zero UDP6 checksums on RX? */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
49
  	/*
47bdd718c   Adrian Bunk   typo fixes: infom...
50
  	 * Following member retains the information to create a UDP header
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
51
52
53
  	 * when the socket is uncorked.
  	 */
  	__u16		 len;		/* total length of pending frames */
ba4e58eca   Gerrit Renker   [NET]: Supporting...
54
55
56
57
58
59
60
61
62
63
  	/*
  	 * Fields specific to UDP-Lite.
  	 */
  	__u16		 pcslen;
  	__u16		 pcrlen;
  /* indicator bits used by pcflag: */
  #define UDPLITE_BIT      0x1  		/* set by udplite proto init function */
  #define UDPLITE_SEND_CC  0x2  		/* set via udplite setsockopt         */
  #define UDPLITE_RECV_CC  0x4		/* set via udplite setsocktopt        */
  	__u8		 pcflag;        /* marks socket as UDP-Lite if > 0    */
342f0234c   James Chapman   [UDP]: Introduce ...
64
65
66
67
68
  	__u8		 unused[3];
  	/*
  	 * For encapsulation sockets.
  	 */
  	int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);
44046a593   Tom Parkin   udp: add encap_de...
69
  	void (*encap_destroy)(struct sock *sk);
a6024562f   Tom Herbert   udp: Add GRO func...
70
71
72
73
74
75
76
77
  
  	/* GRO functions for UDP socket */
  	struct sk_buff **	(*gro_receive)(struct sock *sk,
  					       struct sk_buff **head,
  					       struct sk_buff *skb);
  	int			(*gro_complete)(struct sock *sk,
  						struct sk_buff *skb,
  						int nhoff);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
78
79
80
81
82
83
  };
  
  static inline struct udp_sock *udp_sk(const struct sock *sk)
  {
  	return (struct udp_sock *)sk;
  }
e898d4db2   YOSHIFUJI Hideaki   [UDP]: Allow user...
84

1c19448c9   Tom Herbert   net: Make enablin...
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
  static inline void udp_set_no_check6_tx(struct sock *sk, bool val)
  {
  	udp_sk(sk)->no_check6_tx = val;
  }
  
  static inline void udp_set_no_check6_rx(struct sock *sk, bool val)
  {
  	udp_sk(sk)->no_check6_rx = val;
  }
  
  static inline bool udp_get_no_check6_tx(struct sock *sk)
  {
  	return udp_sk(sk)->no_check6_tx;
  }
  
  static inline bool udp_get_no_check6_rx(struct sock *sk)
  {
  	return udp_sk(sk)->no_check6_rx;
  }
ca065d0cf   Eric Dumazet   udp: no longer us...
104
105
  #define udp_portaddr_for_each_entry(__sk, list) \
  	hlist_for_each_entry(__sk, list, __sk_common.skc_portaddr_node)
30fff9231   Eric Dumazet   udp: bind() optim...
106

ca065d0cf   Eric Dumazet   udp: no longer us...
107
108
  #define udp_portaddr_for_each_entry_rcu(__sk, list) \
  	hlist_for_each_entry_rcu(__sk, list, __sk_common.skc_portaddr_node)
30fff9231   Eric Dumazet   udp: bind() optim...
109

ba4e58eca   Gerrit Renker   [NET]: Supporting...
110
  #define IS_UDPLITE(__sk) (udp_sk(__sk)->pcflag)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
111

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
112
  #endif	/* _LINUX_UDP_H */