netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
nft_rule_obj.c File Reference
#include <sys/types.h>
#include <linux/netfilter/nf_tables.h>
#include <netlink-local.h>
#include <netlink/netfilter/nfnl.h>
#include <netlink/netfilter/netfilter.h>
#include <netlink/netfilter/nft_rule.h>
#include <netlink/netfilter/nft_expr.h>
Include dependency graph for nft_rule_obj.c:

Macros

#define NFT_RULE_DIFF(ATTR, EXPR)   ATTR_DIFF(attrs, RULE_ATTR_##ATTR, a, b, EXPR)
 
#define NFT_RULE_DIFF_VAL(ATTR, FIELD)   NFT_RULE_DIFF(ATTR, a->FIELD != b->FIELD)
 
#define NFT_RULE_DIFF_DATA(ATTR, FIELD)
 

Functions

Allocation/Freeing
struct nfnl_nft_rulenfnl_nft_rule_alloc (void)
 
void nfnl_nft_rule_get (struct nfnl_nft_rule *rule)
 
void nfnl_nft_rule_put (struct nfnl_nft_rule *rule)
 
Attributes
void nfnl_nft_rule_set_family (struct nfnl_nft_rule *rule, uint8_t family)
 
int nfnl_nft_rule_test_family (const struct nfnl_nft_rule *rule)
 
uint8_t nfnl_nft_rule_get_family (const struct nfnl_nft_rule *rule)
 
int nfnl_nft_rule_set_table (struct nfnl_nft_rule *rule, const char *table, int len)
 
int nfnl_nft_rule_test_table (const struct nfnl_nft_rule *rule)
 
const char * nfnl_nft_rule_get_table (const struct nfnl_nft_rule *rule)
 
int nfnl_nft_rule_set_chain (struct nfnl_nft_rule *rule, const char *chain, int len)
 
int nfnl_nft_rule_test_chain (const struct nfnl_nft_rule *rule)
 
const char * nfnl_nft_rule_get_chain (const struct nfnl_nft_rule *rule)
 
void nfnl_nft_rule_set_handle (struct nfnl_nft_rule *rule, uint64_t handle)
 
int nfnl_nft_rule_test_handle (const struct nfnl_nft_rule *rule)
 
uint64_t nfnl_nft_rule_get_handle (const struct nfnl_nft_rule *rule)
 
void nfnl_nft_rule_add_expr (struct nfnl_nft_rule *rule, struct nfnl_nft_expr *expr)
 
void nfnl_nft_rule_foreach_expr (const struct nfnl_nft_rule *rule, void(*cb)(struct nl_object *, void *), void *arg)
 

Variables

struct nl_object_ops nft_rule_obj_ops
 

Macro Definition Documentation

#define NFT_RULE_DIFF (   ATTR,
  EXPR 
)    ATTR_DIFF(attrs, RULE_ATTR_##ATTR, a, b, EXPR)
#define NFT_RULE_DIFF_DATA (   ATTR,
  FIELD 
)
Value:
NFT_RULE_DIFF(ATTR, nl_data_get_size(a->FIELD) != nl_data_get_size(b->FIELD) || \
memcmp(nl_data_get(a->FIELD), nl_data_get(b->FIELD), \
nl_data_get_size(a->FIELD)))
#define NFT_RULE_DIFF(ATTR, EXPR)
void * nl_data_get(const struct nl_data *)
Get data buffer of abstract data object.
Definition: data.c:144
size_t nl_data_get_size(const struct nl_data *)
Get size of data buffer of abstract data object.
Definition: data.c:154
#define NFT_RULE_DIFF_VAL (   ATTR,
  FIELD 
)    NFT_RULE_DIFF(ATTR, a->FIELD != b->FIELD)

Function Documentation

void nfnl_nft_rule_add_expr ( struct nfnl_nft_rule rule,
struct nfnl_nft_expr expr 
)

References nfnl_nft_expr::expr_list, and nfnl_nft_rule::rule_expressions.

Referenced by main().

Here is the caller graph for this function:

struct nfnl_nft_rule* nfnl_nft_rule_alloc ( void  )

References nft_rule_obj_ops, and nl_object_alloc().

Referenced by main(), and nfnlmsg_nft_rule_parse().

Here is the call graph for this function:

Here is the caller graph for this function:

void nfnl_nft_rule_foreach_expr ( const struct nfnl_nft_rule rule,
void(*)(struct nl_object *, void *)  cb,
void *  arg 
)
void nfnl_nft_rule_get ( struct nfnl_nft_rule rule)

References nl_object_get().

Here is the call graph for this function:

const char* nfnl_nft_rule_get_chain ( const struct nfnl_nft_rule rule)

References nl_data_get(), and nfnl_nft_rule::rule_chain.

Here is the call graph for this function:

uint8_t nfnl_nft_rule_get_family ( const struct nfnl_nft_rule rule)
uint64_t nfnl_nft_rule_get_handle ( const struct nfnl_nft_rule rule)
const char* nfnl_nft_rule_get_table ( const struct nfnl_nft_rule rule)

References nl_data_get(), and nfnl_nft_rule::rule_table.

Here is the call graph for this function:

void nfnl_nft_rule_put ( struct nfnl_nft_rule rule)

References nl_object_put().

Referenced by main(), and nfnlmsg_nft_rule_parse().

Here is the call graph for this function:

Here is the caller graph for this function:

int nfnl_nft_rule_set_chain ( struct nfnl_nft_rule rule,
const char *  chain,
int  len 
)

References data, nl_data_alloc(), nl_data_free(), NLE_NOMEM, NULL, and nfnl_nft_rule::rule_chain.

Referenced by main(), and nfnlmsg_nft_rule_parse().

Here is the call graph for this function:

Here is the caller graph for this function:

void nfnl_nft_rule_set_family ( struct nfnl_nft_rule rule,
uint8_t  family 
)

References nfnl_nft_rule::rule_family.

Referenced by main(), and nfnlmsg_nft_rule_parse().

Here is the caller graph for this function:

void nfnl_nft_rule_set_handle ( struct nfnl_nft_rule rule,
uint64_t  handle 
)

References nfnl_nft_rule::rule_handle.

Referenced by main(), and nfnlmsg_nft_rule_parse().

Here is the caller graph for this function:

int nfnl_nft_rule_set_table ( struct nfnl_nft_rule rule,
const char *  table,
int  len 
)

References data, nl_data_alloc(), nl_data_free(), NLE_NOMEM, NULL, and nfnl_nft_rule::rule_table.

Referenced by main(), and nfnlmsg_nft_rule_parse().

Here is the call graph for this function:

Here is the caller graph for this function:

int nfnl_nft_rule_test_chain ( const struct nfnl_nft_rule rule)
int nfnl_nft_rule_test_family ( const struct nfnl_nft_rule rule)
int nfnl_nft_rule_test_handle ( const struct nfnl_nft_rule rule)
int nfnl_nft_rule_test_table ( const struct nfnl_nft_rule rule)

Variable Documentation

struct nl_object_ops nft_rule_obj_ops
Initial value:
= {
.oo_name = "netfilter/nft_rule",
.oo_size = sizeof(struct nfnl_nft_rule),
.oo_constructor = nft_rule_constructor,
.oo_free_data = nft_rule_free_data,
.oo_clone = nft_rule_clone,
.oo_dump = {
[NL_DUMP_LINE] = nft_rule_dump,
[NL_DUMP_DETAILS] = nft_rule_dump,
[NL_DUMP_STATS] = nft_rule_dump,
},
.oo_compare = nft_rule_compare,
.oo_attrs2str = nft_rule_attrs2str,
}
Dump object briefly on one line.
Definition: types.h:22
Dump all attributes but no statistics.
Definition: types.h:23
Definition: netlink-types.h:847
Dump all attributes including statistics.
Definition: types.h:24

Referenced by nfnl_nft_rule_alloc().