1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _IP_SET_GETPORT_H
3 #define _IP_SET_GETPORT_H
4 
5 #include <linux/skbuff.h>
6 #include <linux/types.h>
7 #include <uapi/linux/in.h>
8 
9 extern bool ip_set_get_ip4_port(const struct sk_buff *skb, bool src,
10 				__be16 *port, u8 *proto);
11 
12 #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
13 extern bool ip_set_get_ip6_port(const struct sk_buff *skb, bool src,
14 				__be16 *port, u8 *proto);
15 #else
16 static inline bool ip_set_get_ip6_port(const struct sk_buff *skb, bool src,
17 				       __be16 *port, u8 *proto)
18 {
19 	return false;
20 }
21 #endif
22 
23 extern bool ip_set_get_ip_port(const struct sk_buff *skb, u8 pf, bool src,
24 				__be16 *port);
25 
26 static inline bool ip_set_proto_with_ports(u8 proto)
27 {
28 	switch (proto) {
29 	case IPPROTO_TCP:
30 	case IPPROTO_SCTP:
31 	case IPPROTO_UDP:
32 	case IPPROTO_UDPLITE:
33 		return true;
34 	}
35 	return false;
36 }
37 
38 #endif /*_IP_SET_GETPORT_H*/
39