netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
nft.h File Reference
#include "xshared.h"
#include "nft-shared.h"
#include <libiptc/linux_list.h>
Include dependency graph for nft.h:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  builtin_chain
 
struct  builtin_table
 
struct  nft_handle
 

Macros

#define FILTER   0
 
#define MANGLE   1
 
#define RAW   2
 
#define SECURITY   3
 
#define NAT   4
 
#define TABLES_MAX   5
 
#define XTABLES_CONFIG_DEFAULT   "/etc/xtables.conf"
 

Enumerations

enum  nft_rule_print {
  NFT_RULE_APPEND,
  NFT_RULE_DEL
}
 
enum  { NFT_LOAD_VERBOSE = (1 << 0) }
 

Functions

int mnl_talk (struct nft_handle *h, struct nlmsghdr *nlh, int(*cb)(const struct nlmsghdr *nlh, void *data), void *data)
 
int nft_init (struct nft_handle *h, struct builtin_table *t)
 
void nft_fini (struct nft_handle *h)
 
int nft_table_add (struct nft_handle *h, struct nft_table *t, uint16_t flags)
 
int nft_for_each_table (struct nft_handle *h, int(*func)(struct nft_handle *h, const char *tablename, bool counters), bool counters)
 
bool nft_table_find (struct nft_handle *h, const char *tablename)
 
int nft_table_purge_chains (struct nft_handle *h, const char *table, struct nft_chain_list *list)
 
int nft_chain_add (struct nft_handle *h, struct nft_chain *c, uint16_t flags)
 
int nft_chain_set (struct nft_handle *h, const char *table, const char *chain, const char *policy, const struct xt_counters *counters)
 
struct nft_chain_listnft_chain_dump (struct nft_handle *h)
 
struct nft_chainnft_chain_list_find (struct nft_chain_list *list, const char *table, const char *chain)
 
int nft_chain_save (struct nft_handle *h, struct nft_chain_list *list, const char *table)
 
int nft_chain_user_add (struct nft_handle *h, const char *chain, const char *table)
 
int nft_chain_user_del (struct nft_handle *h, const char *chain, const char *table)
 
int nft_chain_user_rename (struct nft_handle *h, const char *chain, const char *table, const char *newname)
 
int nft_chain_zero_counters (struct nft_handle *h, const char *chain, const char *table)
 
int nft_rule_append (struct nft_handle *h, const char *chain, const char *table, void *data, uint64_t handle, bool verbose)
 
int nft_rule_insert (struct nft_handle *h, const char *chain, const char *table, void *data, int rulenum, bool verbose)
 
int nft_rule_check (struct nft_handle *h, const char *chain, const char *table, void *data, bool verbose)
 
int nft_rule_delete (struct nft_handle *h, const char *chain, const char *table, void *data, bool verbose)
 
int nft_rule_delete_num (struct nft_handle *h, const char *chain, const char *table, int rulenum, bool verbose)
 
int nft_rule_replace (struct nft_handle *h, const char *chain, const char *table, void *data, int rulenum, bool verbose)
 
int nft_rule_list (struct nft_handle *h, const char *chain, const char *table, int rulenum, unsigned int format)
 
int nft_rule_list_save (struct nft_handle *h, const char *chain, const char *table, int rulenum, int counters)
 
int nft_rule_save (struct nft_handle *h, const char *table, bool counters)
 
int nft_rule_flush (struct nft_handle *h, const char *chain, const char *table)
 
int nft_rule_zero_counters (struct nft_handle *h, const char *chain, const char *table, int rulenum)
 
struct nft_rule_listnft_rule_list_create (struct nft_handle *h)
 
void nft_rule_list_destroy (struct nft_rule_list *list)
 
int add_counters (struct nft_rule *r, uint64_t packets, uint64_t bytes)
 
int add_verdict (struct nft_rule *r, int verdict)
 
int add_match (struct nft_rule *r, struct xt_entry_match *m)
 
int add_target (struct nft_rule *r, struct xt_entry_target *t)
 
int add_jumpto (struct nft_rule *r, const char *name, int verdict)
 
int add_action (struct nft_rule *r, struct iptables_command_state *cs, bool goto_set)
 
void nft_rule_print_save (const void *data, struct nft_rule *r, enum nft_rule_print type, unsigned int format)
 
uint32_t nft_invflags2cmp (uint32_t invflags, uint32_t flag)
 
int nft_commit (struct nft_handle *h)
 
int nft_abort (struct nft_handle *h)
 
int nft_compatible_revision (const char *name, uint8_t rev, int opt)
 
const char * nft_strerror (int err)
 
int do_commandx (struct nft_handle *h, int argc, char *argv[], char **table, bool restore)
 
int do_commandarp (struct nft_handle *h, int argc, char *argv[], char **table)
 
int xtables_config_parse (const char *filename, struct nft_table_list *table_list, struct nft_chain_list *chain_list)
 
int nft_xtables_config_load (struct nft_handle *h, const char *filename, uint32_t flags)
 
int nft_arp_rule_append (struct nft_handle *h, const char *chain, const char *table, struct arpt_entry *fw, bool verbose)
 
int nft_arp_rule_insert (struct nft_handle *h, const char *chain, const char *table, struct arpt_entry *fw, int rulenum, bool verbose)
 
void nft_rule_to_arpt_entry (struct nft_rule *r, struct arpt_entry *fw)
 

Variables

struct builtin_table xtables_ipv4 [TABLES_MAX]
 
struct builtin_table xtables_arp [TABLES_MAX]
 

Macro Definition Documentation

#define FILTER   0
#define MANGLE   1
#define NAT   4
#define RAW   2
#define SECURITY   3
#define TABLES_MAX   5

Enumeration Type Documentation

anonymous enum
Enumerator
NFT_LOAD_VERBOSE 
Enumerator
NFT_RULE_APPEND 
NFT_RULE_DEL 

Function Documentation

int add_counters ( struct nft_rule r,
uint64_t  packets,
uint64_t  bytes 
)

References NFT_EXPR_CTR_BYTES, NFT_EXPR_CTR_PACKETS, nft_rule_add_expr(), nft_rule_expr_alloc(), nft_rule_expr_set_u64(), and NULL.

Here is the call graph for this function:

int add_jumpto ( struct nft_rule r,
const char *  name,
int  verdict 
)

References NFT_EXPR_IMM_CHAIN, NFT_EXPR_IMM_DREG, NFT_EXPR_IMM_VERDICT, NFT_REG_VERDICT, nft_rule_add_expr(), nft_rule_expr_alloc(), nft_rule_expr_set_str(), nft_rule_expr_set_u32(), and NULL.

Referenced by add_action().

Here is the call graph for this function:

Here is the caller graph for this function:

int add_match ( struct nft_rule r,
struct xt_entry_match m 
)

References nft_rule_add_expr(), nft_rule_expr_alloc(), and NULL.

Here is the call graph for this function:

int add_target ( struct nft_rule r,
struct xt_entry_target t 
)

References nft_rule_add_expr(), nft_rule_expr_alloc(), and NULL.

Referenced by add_action().

Here is the call graph for this function:

Here is the caller graph for this function:

int add_verdict ( struct nft_rule r,
int  verdict 
)

References NFT_EXPR_IMM_DREG, NFT_EXPR_IMM_VERDICT, NFT_REG_VERDICT, nft_rule_add_expr(), nft_rule_expr_alloc(), nft_rule_expr_set_u32(), and NULL.

Referenced by add_action().

Here is the call graph for this function:

Here is the caller graph for this function:

int do_commandarp ( struct nft_handle h,
int  argc,
char *  argv[],
char **  table 
)

References arpt_devaddr_info::addr, arpt_arp::arhln, arpt_arp::arhln_mask, arpt_arp::arhrd, arpt_arp::arhrd_mask, arpt_entry::arp, arpt_arp::arpop, arpt_arp::arpop_mask, arpt_arp::arpro, arpt_arp::arpro_mask, ARPT_FUNCTION_MAXNAMELEN, ARPT_INV_SRCIP, ARPT_INV_TGTIP, arpt_counters::bcnt, check_inverse(), CMD_APPEND, CMD_DELETE, CMD_DELETE_CHAIN, CMD_DELETE_NUM, CMD_FLUSH, CMD_INSERT, CMD_LIST, CMD_NEW_CHAIN, CMD_NONE, CMD_RENAME_CHAIN, CMD_REPLACE, CMD_SET_POLICY, CMD_ZERO, arpt_entry::counters, exit_printhelp(), exit_tryhelp(), FALSE, nft_handle::family, arptables_command_state::fw, generic_opt_check(), get16_and_mask(), getlength_and_mask(), getmac_and_mask(), arpt_arp::iniface, arpt_arp::iniface_mask, arpt_arp::invflags, arptables_command_state::jumpto, arpt_devaddr_info::mask, xtables_target::next, nft_chain_set(), nft_chain_user_add(), nft_chain_user_del(), nft_chain_user_rename(), nft_chain_zero_counters(), nft_family_ops_lookup(), nft_init(), nft_rule_delete_num(), nft_rule_flush(), NULL, NUMOPCODES, opcodes, nft_handle::ops, OPT_COUNTERS, OPT_D_IP, OPT_D_MAC, OPT_H_LENGTH, OPT_H_TYPE, OPT_JUMP, OPT_LINENUMBERS, OPT_NUMERIC, OPT_OPCODE, OPT_P_TYPE, OPT_S_IP, OPT_S_MAC, OPT_VERBOSE, OPT_VIANAMEIN, OPT_VIANAMEOUT, opts, xtables_globals::orig_opts, OTHER_PROBLEM, arpt_arp::outiface, arpt_arp::outiface_mask, PARAMETER_PROBLEM, parse_hostnetworkmask(), arpt_counters::pcnt, program_name, program_version, size, arpt_arp::src_devaddr, xtables_target::t, arptables_command_state::target, arpt_entry_target::target, xtables_target::tflags, arpt_arp::tgt_devaddr, arpt_arp::tmsk, TRUE, xtables_target::used, XT_STANDARD_TARGET, xtables_arp, xtables_calloc(), xtables_error, xtables_find_target(), xtables_option_tfcall(), xtables_option_tpcall(), xtables_targets, XTF_LOAD_MUST_SUCCEED, and XTF_TRY_LOAD.

Referenced by xtables_arp_main().

Here is the call graph for this function:

Here is the caller graph for this function:

int do_commandx ( struct nft_handle h,
int  argc,
char *  argv[],
char **  table,
bool  restore 
)

References addr_mask::addr, iptables_command_state::argv, xtables_args::bcnt, xtables_args::bcnt_cnt, iptables_command_state::c, CMD_APPEND, CMD_CHECK, CMD_DELETE, CMD_DELETE_CHAIN, CMD_DELETE_NUM, CMD_FLUSH, CMD_INSERT, CMD_LIST, CMD_LIST_RULES, CMD_NEW_CHAIN, CMD_NONE, CMD_RENAME_CHAIN, CMD_REPLACE, CMD_SET_POLICY, CMD_ZERO, CMD_ZERO_NUM, command_default(), xtables_args::d, xtables_args::dhostnetworkmask, exit_printhelp(), exit_tryhelp(), FALSE, nft_handle::family, xtables_args::family, xtables_args::flags, generic_opt_check(), xtables_args::goto_set, xtables_args::iniface, xtables_args::iniface_mask, iptables_command_state::invert, xtables_args::invflags, IPT_F_FRAG, iptables_command_state::jumpto, xtables_match::m, addr_mask::mask, xtables_rule_match::match, iptables_command_state::matches, xtables_match::mflags, addr_mask::naddrs, xtables_match::next, xtables_target::next, xtables_rule_match::next, nft_chain_set(), nft_chain_user_add(), nft_chain_user_del(), nft_chain_user_rename(), nft_chain_zero_counters(), nft_family_ops_lookup(), nft_rule_delete_num(), nft_rule_flush(), nft_rule_zero_counters(), NULL, nft_handle::ops, OPT_COUNTERS, OPT_DESTINATION, OPT_EXPANDED, OPT_FRAGMENT, OPT_JUMP, OPT_LINENUMBERS, OPT_NUMERIC, OPT_PROTOCOL, OPT_SOURCE, OPT_VERBOSE, OPT_VIANAMEIN, OPT_VIANAMEOUT, iptables_command_state::options, opts, xtables_globals::orig_opts, xtables_args::outiface, xtables_args::outiface_mask, PARAMETER_PROBLEM, xtables_args::pcnt, xtables_args::pcnt_cnt, nft_family_ops::post_parse, prog_name, prog_vers, xtables_args::proto, nft_family_ops::proto_parse, iptables_command_state::protocol, xtables_args::shostnetworkmask, xtables_target::t, iptables_command_state::target, xtables_target::tflags, TRUE, xtables_target::used, addr_mask::v4, addr_mask::v6, XT_EXTENSION_MAXNAMELEN, XT_INV_PROTO, xt_params, xtables_error, xtables_find_match(), xtables_find_target(), xtables_free_opts(), xtables_matches, xtables_modprobe_program, xtables_option_mfcall(), xtables_option_tfcall(), xtables_parse_interface(), xtables_parse_protocol(), xtables_rule_matches_free(), xtables_set_nfproto(), xtables_targets, and XTF_TRY_LOAD.

Here is the call graph for this function:

int mnl_talk ( struct nft_handle h,
struct nlmsghdr nlh,
int(*)(const struct nlmsghdr *nlh, void *data cb,
void *  data 
)
int nft_abort ( struct nft_handle h)

References NFT_COMPAT_ABORT.

int nft_arp_rule_append ( struct nft_handle h,
const char *  chain,
const char *  table,
struct arpt_entry fw,
bool  verbose 
)
int nft_arp_rule_insert ( struct nft_handle h,
const char *  chain,
const char *  table,
struct arpt_entry fw,
int  rulenum,
bool  verbose 
)
int nft_chain_add ( struct nft_handle h,
struct nft_chain c,
uint16_t  flags 
)
struct nft_chain_list* nft_chain_dump ( struct nft_handle h)

Referenced by nft_rule_list(), and nft_rule_list_save().

Here is the caller graph for this function:

struct nft_chain* nft_chain_list_find ( struct nft_chain_list list,
const char *  table,
const char *  chain 
)
int nft_chain_save ( struct nft_handle h,
struct nft_chain_list list,
const char *  table 
)
int nft_chain_set ( struct nft_handle h,
const char *  table,
const char *  chain,
const char *  policy,
const struct xt_counters counters 
)

References nft_handle::batch_support, NF_ACCEPT, NF_DROP, nft_chain_add(), nft_chain_set(), NFT_COMPAT_CHAIN_UPDATE, and NULL.

Referenced by do_commandarp(), do_commandx(), nft_chain_set(), and nft_strerror().

Here is the call graph for this function:

Here is the caller graph for this function:

int nft_chain_user_del ( struct nft_handle h,
const char *  chain,
const char *  table 
)
int nft_commit ( struct nft_handle h)

References NFT_COMPAT_COMMIT.

Referenced by nft_rule_list(), and xtables_arp_main().

Here is the caller graph for this function:

void nft_fini ( struct nft_handle h)

References nft_handle::batch, mnl_nlmsg_batch_head(), mnl_nlmsg_batch_stop(), mnl_socket_close(), and nft_handle::nl.

Referenced by xtables_arp_main().

Here is the call graph for this function:

Here is the caller graph for this function:

int nft_for_each_table ( struct nft_handle h,
int(*)(struct nft_handle *h, const char *tablename, bool counters)  func,
bool  counters 
)
uint32_t nft_invflags2cmp ( uint32_t  invflags,
uint32_t  flag 
)

References NFT_CMP_EQ, and NFT_CMP_NEQ.

int nft_rule_append ( struct nft_handle h,
const char *  chain,
const char *  table,
void *  data,
uint64_t  handle,
bool  verbose 
)
int nft_rule_check ( struct nft_handle h,
const char *  chain,
const char *  table,
void *  data,
bool  verbose 
)

References nft_rule_list::list, nft_rule_check(), nft_rule_list_create(), nft_rule_list_destroy(), and NULL.

Referenced by nft_rule_check(), and nft_strerror().

Here is the call graph for this function:

Here is the caller graph for this function:

int nft_rule_delete ( struct nft_handle h,
const char *  chain,
const char *  table,
void *  data,
bool  verbose 
)

References nft_rule_list::list, nft_rule_delete(), nft_rule_list_create(), nft_rule_list_destroy(), and NULL.

Referenced by nft_rule_delete(), nft_rule_zero_counters(), and nft_strerror().

Here is the call graph for this function:

Here is the caller graph for this function:

int nft_rule_delete_num ( struct nft_handle h,
const char *  chain,
const char *  table,
int  rulenum,
bool  verbose 
)

References DEBUGP, nft_rule_list::list, nft_rule_delete_num(), nft_rule_list_create(), nft_rule_list_destroy(), and NULL.

Referenced by do_commandarp(), do_commandx(), nft_rule_delete_num(), and nft_strerror().

Here is the call graph for this function:

Here is the caller graph for this function:

int nft_rule_flush ( struct nft_handle h,
const char *  chain,
const char *  table 
)
int nft_rule_insert ( struct nft_handle h,
const char *  chain,
const char *  table,
void *  data,
int  rulenum,
bool  verbose 
)

References DEBUGP, nft_rule_list::list, nft_rule_attr_get_u64(), NFT_RULE_ATTR_HANDLE, nft_rule_insert(), nft_rule_list_create(), nft_rule_list_destroy(), nft_xtables_config_load(), NULL, and XTABLES_CONFIG_DEFAULT.

Referenced by nft_rule_insert().

Here is the call graph for this function:

Here is the caller graph for this function:

struct nft_rule_list* nft_rule_list_create ( struct nft_handle h)
void nft_rule_list_destroy ( struct nft_rule_list list)

References nft_rule_list_free().

Referenced by nft_rule_check(), nft_rule_delete(), nft_rule_delete_num(), nft_rule_insert(), nft_rule_replace(), and nft_rule_zero_counters().

Here is the call graph for this function:

Here is the caller graph for this function:

int nft_rule_list_save ( struct nft_handle h,
const char *  chain,
const char *  table,
int  rulenum,
int  counters 
)
void nft_rule_print_save ( const void *  data,
struct nft_rule r,
enum nft_rule_print  type,
unsigned int  format 
)
int nft_rule_replace ( struct nft_handle h,
const char *  chain,
const char *  table,
void *  data,
int  rulenum,
bool  verbose 
)

References DEBUGP, nft_rule_list::list, nft_rule_append(), nft_rule_attr_get_u64(), NFT_RULE_ATTR_HANDLE, nft_rule_list_create(), nft_rule_list_destroy(), nft_rule_replace(), and NULL.

Referenced by nft_rule_replace(), and nft_strerror().

Here is the call graph for this function:

Here is the caller graph for this function:

void nft_rule_to_arpt_entry ( struct nft_rule r,
struct arpt_entry fw 
)
int nft_rule_zero_counters ( struct nft_handle h,
const char *  chain,
const char *  table,
int  rulenum 
)
const char* nft_strerror ( int  err)

References nft_chain_set(), nft_chain_user_add(), nft_chain_user_del(), nft_rule_check(), nft_rule_delete(), nft_rule_delete_num(), nft_rule_replace(), and NULL.

Referenced by xtables_arp_main().

Here is the call graph for this function:

Here is the caller graph for this function:

bool nft_table_find ( struct nft_handle h,
const char *  tablename 
)
int nft_table_purge_chains ( struct nft_handle h,
const char *  table,
struct nft_chain_list list 
)
int xtables_config_parse ( const char *  filename,
struct nft_table_list table_list,
struct nft_chain_list chain_list 
)

Referenced by nft_xtables_config_load().

Here is the caller graph for this function:

Variable Documentation

Referenced by do_commandarp().

Referenced by xtables_config_main().