blob: 0b9e017c9038d1efea3e02523e4d08d4f75db59f [file] [log] [blame]
Tom Herbert8024e022014-07-13 19:49:37 -07001#ifndef __NET_UDP_TUNNEL_H
2#define __NET_UDP_TUNNEL_H
3
4struct udp_port_cfg {
5 u8 family;
6
7 /* Used only for kernel-created sockets */
8 union {
9 struct in_addr local_ip;
10#if IS_ENABLED(CONFIG_IPV6)
11 struct in6_addr local_ip6;
12#endif
13 };
14
15 union {
16 struct in_addr peer_ip;
17#if IS_ENABLED(CONFIG_IPV6)
18 struct in6_addr peer_ip6;
19#endif
20 };
21
22 __be16 local_udp_port;
23 __be16 peer_udp_port;
24 unsigned int use_udp_checksums:1,
25 use_udp6_tx_checksums:1,
26 use_udp6_rx_checksums:1;
27};
28
Andy Zhoufd384412014-09-16 17:31:16 -070029int udp_sock_create4(struct net *net, struct udp_port_cfg *cfg,
30 struct socket **sockp);
31
32#if IS_ENABLED(CONFIG_IPV6)
33int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg,
34 struct socket **sockp);
35#else
36static inline int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg,
37 struct socket **sockp)
38{
39 return 0;
40}
41#endif
42
43static inline int udp_sock_create(struct net *net,
44 struct udp_port_cfg *cfg,
45 struct socket **sockp)
46{
47 if (cfg->family == AF_INET)
48 return udp_sock_create4(net, cfg, sockp);
49
50 if (cfg->family == AF_INET6)
51 return udp_sock_create6(net, cfg, sockp);
52
53 return -EPFNOSUPPORT;
54}
Tom Herbert8024e022014-07-13 19:49:37 -070055
56#endif