linux/include/linux/netfilter/ipset/ip_set.h

/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (C) 2000-2002 Joakim Axelsson <[email protected]>
 *                         Patrick Schaaf <[email protected]>
 *                         Martin Josefsson <[email protected]>
 * Copyright (C) 2003-2013 Jozsef Kadlecsik <[email protected]>
 */
#ifndef _IP_SET_H
#define _IP_SET_H

#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/netlink.h>
#include <linux/netfilter.h>
#include <linux/netfilter/x_tables.h>
#include <linux/stringify.h>
#include <linux/vmalloc.h>
#include <net/netlink.h>
#include <uapi/linux/netfilter/ipset/ip_set.h>

#define _IP_SET_MODULE_DESC(a, b, c)
#define IP_SET_MODULE_DESC(a, b, c)

/* Set features */
enum ip_set_feature {};

/* Set extensions */
enum ip_set_extension {};

#define SET_WITH_TIMEOUT(s)
#define SET_WITH_COUNTER(s)
#define SET_WITH_COMMENT(s)
#define SET_WITH_SKBINFO(s)
#define SET_WITH_FORCEADD(s)

/* Extension id, in size order */
enum ip_set_ext_id {};

struct ip_set;

/* Extension type */
struct ip_set_ext_type {};

extern const struct ip_set_ext_type ip_set_extensions[];

struct ip_set_counter {};

struct ip_set_comment_rcu {};

struct ip_set_comment {};

struct ip_set_skbinfo {};

struct ip_set_ext {};

#define ext_timeout(e, s)
#define ext_counter(e, s)
#define ext_comment(e, s)
#define ext_skbinfo(e, s)

ipset_adtfn;

/* Kernel API function options */
struct ip_set_adt_opt {};

/* Set type, variant-specific part */
struct ip_set_type_variant {};

struct ip_set_region {};

/* Max range where every element is added/deleted in one step */
#define IPSET_MAX_RANGE

/* The max revision number supported by any set type + 1 */
#define IPSET_REVISION_MAX

/* The core set type structure */
struct ip_set_type {};

/* register and unregister set type */
extern int ip_set_type_register(struct ip_set_type *set_type);
extern void ip_set_type_unregister(struct ip_set_type *set_type);

/* A generic IP set */
struct ip_set {};

static inline void
ip_set_ext_destroy(struct ip_set *set, void *data)
{}

int ip_set_put_flags(struct sk_buff *skb, struct ip_set *set);

/* Netlink CB args */
enum {};

/* register and unregister set references */
extern ip_set_id_t ip_set_get_byname(struct net *net,
				     const char *name, struct ip_set **set);
extern void ip_set_put_byindex(struct net *net, ip_set_id_t index);
extern void ip_set_name_byindex(struct net *net, ip_set_id_t index, char *name);
extern ip_set_id_t ip_set_nfnl_get_byindex(struct net *net, ip_set_id_t index);
extern void ip_set_nfnl_put(struct net *net, ip_set_id_t index);

/* API for iptables set match, and SET target */

extern int ip_set_add(ip_set_id_t id, const struct sk_buff *skb,
		      const struct xt_action_param *par,
		      struct ip_set_adt_opt *opt);
extern int ip_set_del(ip_set_id_t id, const struct sk_buff *skb,
		      const struct xt_action_param *par,
		      struct ip_set_adt_opt *opt);
extern int ip_set_test(ip_set_id_t id, const struct sk_buff *skb,
		       const struct xt_action_param *par,
		       struct ip_set_adt_opt *opt);

/* Utility functions */
extern void *ip_set_alloc(size_t size);
extern void ip_set_free(void *members);
extern int ip_set_get_ipaddr4(struct nlattr *nla,  __be32 *ipaddr);
extern int ip_set_get_ipaddr6(struct nlattr *nla, union nf_inet_addr *ipaddr);
extern size_t ip_set_elem_len(struct ip_set *set, struct nlattr *tb[],
			      size_t len, size_t align);
extern int ip_set_get_extensions(struct ip_set *set, struct nlattr *tb[],
				 struct ip_set_ext *ext);
extern int ip_set_put_extensions(struct sk_buff *skb, const struct ip_set *set,
				 const void *e, bool active);
extern bool ip_set_match_extensions(struct ip_set *set,
				    const struct ip_set_ext *ext,
				    struct ip_set_ext *mext,
				    u32 flags, void *data);

static inline int
ip_set_get_hostipaddr4(struct nlattr *nla, u32 *ipaddr)
{}

/* Ignore IPSET_ERR_EXIST errors if asked to do so? */
static inline bool
ip_set_eexist(int ret, u32 flags)
{}

/* Match elements marked with nomatch */
static inline bool
ip_set_enomatch(int ret, u32 flags, enum ipset_adt adt, struct ip_set *set)
{}

/* Check the NLA_F_NET_BYTEORDER flag */
static inline bool
ip_set_attr_netorder(struct nlattr *tb[], int type)
{}

static inline bool
ip_set_optattr_netorder(struct nlattr *tb[], int type)
{}

/* Useful converters */
static inline u32
ip_set_get_h32(const struct nlattr *attr)
{}

static inline u16
ip_set_get_h16(const struct nlattr *attr)
{}

static inline int nla_put_ipaddr4(struct sk_buff *skb, int type, __be32 ipaddr)
{}

static inline int nla_put_ipaddr6(struct sk_buff *skb, int type,
				  const struct in6_addr *ipaddrptr)
{}

/* Get address from skbuff */
static inline __be32
ip4addr(const struct sk_buff *skb, bool src)
{}

static inline void
ip4addrptr(const struct sk_buff *skb, bool src, __be32 *addr)
{}

static inline void
ip6addrptr(const struct sk_buff *skb, bool src, struct in6_addr *addr)
{}

/* How often should the gc be run by default */
#define IPSET_GC_TIME

/* Timeout period depending on the timeout value of the given set */
#define IPSET_GC_PERIOD(timeout)

/* Entry is set with no timeout value */
#define IPSET_ELEM_PERMANENT

/* Set is defined with timeout support: timeout value may be 0 */
#define IPSET_NO_TIMEOUT

/* Max timeout value, see msecs_to_jiffies() in jiffies.h */
#define IPSET_MAX_TIMEOUT

#define ip_set_adt_opt_timeout(opt, set)

static inline unsigned int
ip_set_timeout_uget(struct nlattr *tb)
{}

static inline bool
ip_set_timeout_expired(const unsigned long *t)
{}

static inline void
ip_set_timeout_set(unsigned long *timeout, u32 value)
{}

void ip_set_init_comment(struct ip_set *set, struct ip_set_comment *comment,
			 const struct ip_set_ext *ext);

static inline void
ip_set_init_counter(struct ip_set_counter *counter,
		    const struct ip_set_ext *ext)
{}

static inline void
ip_set_init_skbinfo(struct ip_set_skbinfo *skbinfo,
		    const struct ip_set_ext *ext)
{}

static inline void
nf_inet_addr_mask_inplace(union nf_inet_addr *a1,
			  const union nf_inet_addr *mask)
{}

#define IP_SET_INIT_KEXT(skb, opt, set)

#define IP_SET_INIT_UEXT(set)

#define IPSET_CONCAT(a, b)
#define IPSET_TOKEN(a, b)

#endif /*_IP_SET_H */