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
9extern 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)
13extern bool ip_set_get_ip6_port(const struct sk_buff *skb, bool src,
14				__be16 *port, u8 *proto);
15#else
16static 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
23static inline bool ip_set_proto_with_ports(u8 proto)
24{
25	switch (proto) {
26	case IPPROTO_TCP:
27	case IPPROTO_SCTP:
28	case IPPROTO_UDP:
29	case IPPROTO_UDPLITE:
30		return true;
31	}
32	return false;
33}
34
35#endif /*_IP_SET_GETPORT_H*/
36