Blame include/libiptc/libip6tc.h

Packit Service 3880ab
/* SPDX-License-Identifier: GPL-2.0 */
Packit Service 3880ab
#ifndef _LIBIP6TC_H
Packit Service 3880ab
#define _LIBIP6TC_H
Packit Service 3880ab
/* Library which manipulates firewall rules. Version 0.2. */
Packit Service 3880ab
Packit Service 3880ab
#include <linux/types.h>
Packit Service 3880ab
#include <libiptc/ipt_kernel_headers.h>
Packit Service 3880ab
#ifdef __cplusplus
Packit Service 3880ab
#	include <climits>
Packit Service 3880ab
#else
Packit Service 3880ab
#	include <limits.h> /* INT_MAX in ip6_tables.h */
Packit Service 3880ab
#endif
Packit Service 3880ab
#include <linux/netfilter_ipv6/ip6_tables.h>
Packit Service 3880ab
#include <libiptc/xtcshared.h>
Packit Service 3880ab
Packit Service 3880ab
#define ip6tc_handle xtc_handle
Packit Service 3880ab
#define ip6t_chainlabel xt_chainlabel
Packit Service 3880ab
Packit Service 3880ab
#define IP6TC_LABEL_ACCEPT "ACCEPT"
Packit Service 3880ab
#define IP6TC_LABEL_DROP "DROP"
Packit Service 3880ab
#define IP6TC_LABEL_QUEUE   "QUEUE"
Packit Service 3880ab
#define IP6TC_LABEL_RETURN "RETURN"
Packit Service 3880ab
Packit Service 3880ab
/* Does this chain exist? */
Packit Service 3880ab
int ip6tc_is_chain(const char *chain, struct xtc_handle *const handle);
Packit Service 3880ab
Packit Service 3880ab
/* Take a snapshot of the rules. Returns NULL on error. */
Packit Service 3880ab
struct xtc_handle *ip6tc_init(const char *tablename);
Packit Service 3880ab
Packit Service 3880ab
/* Cleanup after ip6tc_init(). */
Packit Service 3880ab
void ip6tc_free(struct xtc_handle *h);
Packit Service 3880ab
Packit Service 3880ab
/* Iterator functions to run through the chains.  Returns NULL at end. */
Packit Service 3880ab
const char *ip6tc_first_chain(struct xtc_handle *handle);
Packit Service 3880ab
const char *ip6tc_next_chain(struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Get first rule in the given chain: NULL for empty chain. */
Packit Service 3880ab
const struct ip6t_entry *ip6tc_first_rule(const char *chain,
Packit Service 3880ab
					  struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Returns NULL when rules run out. */
Packit Service 3880ab
const struct ip6t_entry *ip6tc_next_rule(const struct ip6t_entry *prev,
Packit Service 3880ab
					 struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Returns a pointer to the target name of this position. */
Packit Service 3880ab
const char *ip6tc_get_target(const struct ip6t_entry *e,
Packit Service 3880ab
			     struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Is this a built-in chain? */
Packit Service 3880ab
int ip6tc_builtin(const char *chain, struct xtc_handle *const handle);
Packit Service 3880ab
Packit Service 3880ab
/* Get the policy of a given built-in chain */
Packit Service 3880ab
const char *ip6tc_get_policy(const char *chain,
Packit Service 3880ab
			     struct xt_counters *counters,
Packit Service 3880ab
			     struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* These functions return TRUE for OK or 0 and set errno. If errno ==
Packit Service 3880ab
   0, it means there was a version error (ie. upgrade libiptc). */
Packit Service 3880ab
/* Rule numbers start at 1 for the first rule. */
Packit Service 3880ab
Packit Service 3880ab
/* Insert the entry `fw' in chain `chain' into position `rulenum'. */
Packit Service 3880ab
int ip6tc_insert_entry(const xt_chainlabel chain,
Packit Service 3880ab
		       const struct ip6t_entry *e,
Packit Service 3880ab
		       unsigned int rulenum,
Packit Service 3880ab
		       struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Atomically replace rule `rulenum' in `chain' with `fw'. */
Packit Service 3880ab
int ip6tc_replace_entry(const xt_chainlabel chain,
Packit Service 3880ab
			const struct ip6t_entry *e,
Packit Service 3880ab
			unsigned int rulenum,
Packit Service 3880ab
			struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Append entry `fw' to chain `chain'. Equivalent to insert with
Packit Service 3880ab
   rulenum = length of chain. */
Packit Service 3880ab
int ip6tc_append_entry(const xt_chainlabel chain,
Packit Service 3880ab
		       const struct ip6t_entry *e,
Packit Service 3880ab
		       struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Check whether a matching rule exists */
Packit Service 3880ab
int ip6tc_check_entry(const xt_chainlabel chain,
Packit Service 3880ab
		       const struct ip6t_entry *origfw,
Packit Service 3880ab
		       unsigned char *matchmask,
Packit Service 3880ab
		       struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Delete the first rule in `chain' which matches `fw'. */
Packit Service 3880ab
int ip6tc_delete_entry(const xt_chainlabel chain,
Packit Service 3880ab
		       const struct ip6t_entry *origfw,
Packit Service 3880ab
		       unsigned char *matchmask,
Packit Service 3880ab
		       struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Delete the rule in position `rulenum' in `chain'. */
Packit Service 3880ab
int ip6tc_delete_num_entry(const xt_chainlabel chain,
Packit Service 3880ab
			   unsigned int rulenum,
Packit Service 3880ab
			   struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Check the packet `fw' on chain `chain'. Returns the verdict, or
Packit Service 3880ab
   NULL and sets errno. */
Packit Service 3880ab
const char *ip6tc_check_packet(const xt_chainlabel chain,
Packit Service 3880ab
			       struct ip6t_entry *,
Packit Service 3880ab
			       struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Flushes the entries in the given chain (ie. empties chain). */
Packit Service 3880ab
int ip6tc_flush_entries(const xt_chainlabel chain,
Packit Service 3880ab
			struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Zeroes the counters in a chain. */
Packit Service 3880ab
int ip6tc_zero_entries(const xt_chainlabel chain,
Packit Service 3880ab
		       struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Creates a new chain. */
Packit Service 3880ab
int ip6tc_create_chain(const xt_chainlabel chain,
Packit Service 3880ab
		       struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Deletes a chain. */
Packit Service 3880ab
int ip6tc_delete_chain(const xt_chainlabel chain,
Packit Service 3880ab
		       struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Renames a chain. */
Packit Service 3880ab
int ip6tc_rename_chain(const xt_chainlabel oldname,
Packit Service 3880ab
		       const xt_chainlabel newname,
Packit Service 3880ab
		       struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Sets the policy on a built-in chain. */
Packit Service 3880ab
int ip6tc_set_policy(const xt_chainlabel chain,
Packit Service 3880ab
		     const xt_chainlabel policy,
Packit Service 3880ab
		     struct xt_counters *counters,
Packit Service 3880ab
		     struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Get the number of references to this chain */
Packit Service 3880ab
int ip6tc_get_references(unsigned int *ref, const xt_chainlabel chain,
Packit Service 3880ab
			 struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* read packet and byte counters for a specific rule */
Packit Service 3880ab
struct xt_counters *ip6tc_read_counter(const xt_chainlabel chain,
Packit Service 3880ab
					unsigned int rulenum,
Packit Service 3880ab
					struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* zero packet and byte counters for a specific rule */
Packit Service 3880ab
int ip6tc_zero_counter(const xt_chainlabel chain,
Packit Service 3880ab
		       unsigned int rulenum,
Packit Service 3880ab
		       struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* set packet and byte counters for a specific rule */
Packit Service 3880ab
int ip6tc_set_counter(const xt_chainlabel chain,
Packit Service 3880ab
		      unsigned int rulenum,
Packit Service 3880ab
		      struct xt_counters *counters,
Packit Service 3880ab
		      struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Makes the actual changes. */
Packit Service 3880ab
int ip6tc_commit(struct xtc_handle *handle);
Packit Service 3880ab
Packit Service 3880ab
/* Get raw socket. */
Packit Service 3880ab
int ip6tc_get_raw_socket(void);
Packit Service 3880ab
Packit Service 3880ab
/* Translates errno numbers into more human-readable form than strerror. */
Packit Service 3880ab
const char *ip6tc_strerror(int err);
Packit Service 3880ab
Packit Service 3880ab
extern void dump_entries6(struct xtc_handle *const);
Packit Service 3880ab
Packit Service 3880ab
extern const struct xtc_ops ip6tc_ops;
Packit Service 3880ab
Packit Service 3880ab
#endif /* _LIBIP6TC_H */