Tom Herbert | 8024e02 | 2014-07-13 19:49:37 -0700 | [diff] [blame] | 1 | #ifndef __NET_UDP_TUNNEL_H |
| 2 | #define __NET_UDP_TUNNEL_H |
| 3 | |
| 4 | struct 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 Zhou | fd38441 | 2014-09-16 17:31:16 -0700 | [diff] [blame^] | 29 | int udp_sock_create4(struct net *net, struct udp_port_cfg *cfg, |
| 30 | struct socket **sockp); |
| 31 | |
| 32 | #if IS_ENABLED(CONFIG_IPV6) |
| 33 | int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg, |
| 34 | struct socket **sockp); |
| 35 | #else |
| 36 | static 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 | |
| 43 | static 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 Herbert | 8024e02 | 2014-07-13 19:49:37 -0700 | [diff] [blame] | 55 | |
| 56 | #endif |