netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
api.c File Reference
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include "internal/internal.h"
Include dependency graph for api.c:

Macros

#define __CP_ORIG_MAX   sizeof(cp_orig_mask)/sizeof(int)
 
#define __CP_REPL_MAX   sizeof(cp_repl_mask)/sizeof(int)
 

Functions

struct nf_conntracknfct_new (void)
 nfct_conntrack_new - allocate a new conntrack More...
 
void nfct_destroy (struct nf_conntrack *ct)
 nf_conntrack_destroy - release a conntrack object More...
 
size_t nfct_sizeof (const struct nf_conntrack *ct)
 nf_sizeof - return the size in bytes of a certain conntrack object More...
 
size_t nfct_maxsize (void)
 nfct_maxsize - return the maximum size in bytes of a conntrack object More...
 
struct nf_conntracknfct_clone (const struct nf_conntrack *ct)
 nfct_clone - clone a conntrack object More...
 
int nfct_setobjopt (struct nf_conntrack *ct, unsigned int option)
 nfct_setobjopt - set a certain option for a conntrack object More...
 
int nfct_getobjopt (const struct nf_conntrack *ct, unsigned int option)
 nfct_getobjopt - get a certain option for a conntrack object More...
 
int nfct_callback_register (struct nfct_handle *h, enum nf_conntrack_msg_type type, int(*cb)(enum nf_conntrack_msg_type type, struct nf_conntrack *ct, void *data), void *data)
 nf_callback_register - register a callback More...
 
void nfct_callback_unregister (struct nfct_handle *h)
 nfct_callback_unregister - unregister a callback More...
 
int nfct_callback_register2 (struct nfct_handle *h, enum nf_conntrack_msg_type type, int(*cb)(const struct nlmsghdr *nlh, enum nf_conntrack_msg_type type, struct nf_conntrack *ct, void *data), void *data)
 nf_callback_register2 - register a callback More...
 
void nfct_callback_unregister2 (struct nfct_handle *h)
 nfct_callback_unregister2 - unregister a callback More...
 
void nfct_set_attr_l (struct nf_conntrack *ct, const enum nf_conntrack_attr type, const void *value, size_t len)
 nfct_set_attr_l - set the value of a certain conntrack attribute More...
 
void nfct_set_attr (struct nf_conntrack *ct, const enum nf_conntrack_attr type, const void *value)
 nfct_set_attr - set the value of a certain conntrack attribute More...
 
void nfct_set_attr_u8 (struct nf_conntrack *ct, const enum nf_conntrack_attr type, u_int8_t value)
 nfct_set_attr_u8 - set the value of a certain conntrack attribute More...
 
void nfct_set_attr_u16 (struct nf_conntrack *ct, const enum nf_conntrack_attr type, u_int16_t value)
 nfct_set_attr_u16 - set the value of a certain conntrack attribute More...
 
void nfct_set_attr_u32 (struct nf_conntrack *ct, const enum nf_conntrack_attr type, u_int32_t value)
 nfct_set_attr_u32 - set the value of a certain conntrack attribute More...
 
void nfct_set_attr_u64 (struct nf_conntrack *ct, const enum nf_conntrack_attr type, u_int64_t value)
 nfct_set_attr_u64 - set the value of a certain conntrack attribute More...
 
const void * nfct_get_attr (const struct nf_conntrack *ct, const enum nf_conntrack_attr type)
 nfct_get_attr - get a conntrack attribute More...
 
u_int8_t nfct_get_attr_u8 (const struct nf_conntrack *ct, const enum nf_conntrack_attr type)
 nfct_get_attr_u8 - get attribute of unsigned 8-bits long More...
 
u_int16_t nfct_get_attr_u16 (const struct nf_conntrack *ct, const enum nf_conntrack_attr type)
 nfct_get_attr_u16 - get attribute of unsigned 16-bits long More...
 
u_int32_t nfct_get_attr_u32 (const struct nf_conntrack *ct, const enum nf_conntrack_attr type)
 nfct_get_attr_u32 - get attribute of unsigned 32-bits long More...
 
u_int64_t nfct_get_attr_u64 (const struct nf_conntrack *ct, const enum nf_conntrack_attr type)
 nfct_get_attr_u64 - get attribute of unsigned 32-bits long More...
 
int nfct_attr_is_set (const struct nf_conntrack *ct, const enum nf_conntrack_attr type)
 nfct_attr_is_set - check if a certain attribute is set More...
 
int nfct_attr_is_set_array (const struct nf_conntrack *ct, const enum nf_conntrack_attr *type_array, int size)
 nfct_attr_is_set_array - check if an array of attribute types is set More...
 
int nfct_attr_unset (struct nf_conntrack *ct, const enum nf_conntrack_attr type)
 nfct_attr_unset - unset a certain attribute More...
 
void nfct_set_attr_grp (struct nf_conntrack *ct, const enum nf_conntrack_attr_grp type, const void *data)
 nfct_set_attr_grp - set a group of attributes More...
 
int nfct_get_attr_grp (const struct nf_conntrack *ct, const enum nf_conntrack_attr_grp type, void *data)
 nfct_get_attr_grp - get an attribute group More...
 
int nfct_attr_grp_is_set (const struct nf_conntrack *ct, const enum nf_conntrack_attr_grp type)
 nfct_attr_grp_is_set - check if an attribute group is set More...
 
int nfct_attr_grp_unset (struct nf_conntrack *ct, const enum nf_conntrack_attr_grp type)
 nfct_attr_grp_unset - unset an attribute group More...
 
int nfct_build_conntrack (struct nfnl_subsys_handle *ssh, void *req, size_t size, u_int16_t type, u_int16_t flags, const struct nf_conntrack *ct)
 nfct_build_conntrack - build a netlink message from a conntrack object More...
 
int nfct_build_query (struct nfnl_subsys_handle *ssh, const enum nf_conntrack_query qt, const void *data, void *buffer, unsigned int size)
 nfct_build_query - build a query in netlink message format for ctnetlink More...
 
int nfct_parse_conntrack (enum nf_conntrack_msg_type type, const struct nlmsghdr *nlh, struct nf_conntrack *ct)
 nfct_parse_conntrack - translate a netlink message to a conntrack object More...
 
int nfct_query (struct nfct_handle *h, const enum nf_conntrack_query qt, const void *data)
 nfct_query - send a query to ctnetlink and handle the reply More...
 
int nfct_send (struct nfct_handle *h, const enum nf_conntrack_query qt, const void *data)
 nfct_send - send a query to ctnetlink More...
 
int nfct_catch (struct nfct_handle *h)
 nfct_catch - catch events More...
 
int nfct_snprintf (char *buf, unsigned int size, const struct nf_conntrack *ct, unsigned int msg_type, unsigned int out_type, unsigned int flags)
 nfct_snprintf - print a conntrack object to a buffer More...
 
int nfct_snprintf_labels (char *buf, unsigned int size, const struct nf_conntrack *ct, unsigned int msg_type, unsigned int out_type, unsigned int flags, struct nfct_labelmap *map)
 nfct_snprintf_labels - print a bitmask object to a buffer including labels More...
 
int nfct_compare (const struct nf_conntrack *ct1, const struct nf_conntrack *ct2)
 nfct_compare - compare two conntrack objects More...
 
int nfct_cmp (const struct nf_conntrack *ct1, const struct nf_conntrack *ct2, unsigned int flags)
 nfct_cmp - compare two conntrack objects More...
 
void nfct_copy (struct nf_conntrack *ct1, const struct nf_conntrack *ct2, unsigned int flags)
 nfct_copy - copy part of one source object to another More...
 
void nfct_copy_attr (struct nf_conntrack *ct1, const struct nf_conntrack *ct2, const enum nf_conntrack_attr type)
 nfct_copy_attr - copy an attribute of one source object to another More...
 
struct nfct_filternfct_filter_create (void)
 nfct_filter_create - create a filter More...
 
void nfct_filter_destroy (struct nfct_filter *filter)
 nfct_filter_destroy - destroy a filter More...
 
void nfct_filter_add_attr (struct nfct_filter *filter, const enum nfct_filter_attr type, const void *value)
 nfct_filter_add_attr - add a filter attribute of the filter object More...
 
void nfct_filter_add_attr_u32 (struct nfct_filter *filter, const enum nfct_filter_attr type, u_int32_t value)
 nfct_filter_add_attr_u32 - add an u32 filter attribute of the filter object More...
 
int nfct_filter_set_logic (struct nfct_filter *filter, const enum nfct_filter_attr type, const enum nfct_filter_logic logic)
 nfct_filter_set_logic - set the filter logic for an attribute type More...
 
int nfct_filter_attach (int fd, struct nfct_filter *filter)
 nfct_filter_attach - attach a filter to a socket descriptor More...
 
int nfct_filter_detach (int fd)
 nfct_filter_detach - detach an existing filter More...
 
struct nfct_filter_dumpnfct_filter_dump_create (void)
 nfct_filter_dump_create - create a dump filter More...
 
void nfct_filter_dump_destroy (struct nfct_filter_dump *filter)
 nfct_filter_dump_destroy - destroy a dump filter More...
 
void nfct_filter_dump_set_attr (struct nfct_filter_dump *filter_dump, const enum nfct_filter_dump_attr type, const void *value)
 nfct_filter_dump_attr_set - set filter attribute More...
 
void nfct_filter_dump_set_attr_u8 (struct nfct_filter_dump *filter_dump, const enum nfct_filter_dump_attr type, u_int8_t value)
 nfct_filter_dump_attr_set_u8 - set u8 dump filter attribute More...
 
const char * nfct_labelmap_get_name (struct nfct_labelmap *m, unsigned int bit)
 nfct_labelmap_get_name - get name of the label bit More...
 
int nfct_labelmap_get_bit (struct nfct_labelmap *m, const char *name)
 nfct_labelmap_get_bit - get bit associated with the name More...
 
struct nfct_labelmapnfct_labelmap_new (const char *mapfile)
 nfct_labelmap_new - create a new label map More...
 
void nfct_labelmap_destroy (struct nfct_labelmap *map)
 nfct_labelmap_destroy - destroy nfct_labelmap object More...
 
struct nfct_bitmasknfct_bitmask_new (unsigned int max)
 nfct_bitmask_new - allocate a new bitmask More...
 
struct nfct_bitmasknfct_bitmask_clone (const struct nfct_bitmask *b)
 
void nfct_bitmask_set_bit (struct nfct_bitmask *b, unsigned int bit)
 
int nfct_bitmask_test_bit (const struct nfct_bitmask *b, unsigned int bit)
 
void nfct_bitmask_unset_bit (struct nfct_bitmask *b, unsigned int bit)
 
unsigned int nfct_bitmask_maxbit (const struct nfct_bitmask *b)
 
void nfct_bitmask_destroy (struct nfct_bitmask *b)
 
void nfct_bitmask_clear (struct nfct_bitmask *b)
 
bool nfct_bitmask_equal (const struct nfct_bitmask *b1, const struct nfct_bitmask *b2)
 

Macro Definition Documentation

#define __CP_ORIG_MAX   sizeof(cp_orig_mask)/sizeof(int)

Referenced by nfct_copy().

#define __CP_REPL_MAX   sizeof(cp_repl_mask)/sizeof(int)

Referenced by nfct_copy().

Function Documentation

void nfct_bitmask_clear ( struct nfct_bitmask b)
struct nfct_bitmask* nfct_bitmask_clone ( const struct nfct_bitmask b)
void nfct_bitmask_destroy ( struct nfct_bitmask b)

Referenced by nfct_destroy().

Here is the caller graph for this function:

bool nfct_bitmask_equal ( const struct nfct_bitmask b1,
const struct nfct_bitmask b2 
)
unsigned int nfct_bitmask_maxbit ( const struct nfct_bitmask b)

References nfct_bitmask::words.

Referenced by __snprintf_connlabels().

Here is the caller graph for this function:

struct nfct_bitmask* nfct_bitmask_new ( unsigned int  max)

nfct_bitmask_new - allocate a new bitmask

Parameters
maxhighest valid bit that can be set/unset.

In case of success, this function returns a valid pointer to a memory blob, otherwise NULL is returned and errno is set appropiately.

References nfct_bitmask::bits, bytes, DIV_ROUND_UP, NULL, and nfct_bitmask::words.

Referenced by main().

Here is the caller graph for this function:

void nfct_bitmask_set_bit ( struct nfct_bitmask b,
unsigned int  bit 
)
int nfct_bitmask_test_bit ( const struct nfct_bitmask b,
unsigned int  bit 
)

References nfct_bitmask::bits, and nfct_bitmask::words.

Referenced by __snprintf_connlabels().

Here is the caller graph for this function:

void nfct_bitmask_unset_bit ( struct nfct_bitmask b,
unsigned int  bit 
)