netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Expect object handling

Functions

struct nf_expectnfexp_new (void)
 nfexp_new - allocate a new expectation More...
 
void nfexp_destroy (struct nf_expect *exp)
 nfexp_destroy - release an expectation object More...
 
size_t nfexp_sizeof (const struct nf_expect *exp)
 nfexp_sizeof - return the size in bytes of a certain expect object More...
 
size_t nfexp_maxsize (void)
 nfexp_maxsize - return the maximum size in bytes of a expect object More...
 
struct nf_expectnfexp_clone (const struct nf_expect *exp)
 nfexp_clone - clone a expectation object More...
 
int nfexp_cmp (const struct nf_expect *exp1, const struct nf_expect *exp2, unsigned int flags)
 nfexp_cmp - compare two expectation objects More...
 
void nfexp_set_attr (struct nf_expect *exp, const enum nf_expect_attr type, const void *value)
 nfexp_set_attr - set the value of a certain expect attribute More...
 
void nfexp_set_attr_u8 (struct nf_expect *exp, const enum nf_expect_attr type, u_int8_t value)
 nfexp_set_attr_u8 - set the value of a certain expect attribute More...
 
void nfexp_set_attr_u16 (struct nf_expect *exp, const enum nf_expect_attr type, u_int16_t value)
 nfexp_set_attr_u16 - set the value of a certain expect attribute More...
 
void nfexp_set_attr_u32 (struct nf_expect *exp, const enum nf_expect_attr type, u_int32_t value)
 nfexp_set_attr_u32 - set the value of a certain expect attribute More...
 
const void * nfexp_get_attr (const struct nf_expect *exp, const enum nf_expect_attr type)
 nfexp_get_attr - get an expect attribute More...
 
u_int8_t nfexp_get_attr_u8 (const struct nf_expect *exp, const enum nf_expect_attr type)
 nfexp_get_attr_u8 - get attribute of unsigned 8-bits long More...
 
u_int16_t nfexp_get_attr_u16 (const struct nf_expect *exp, const enum nf_expect_attr type)
 nfexp_get_attr_u16 - get attribute of unsigned 16-bits long More...
 
u_int32_t nfexp_get_attr_u32 (const struct nf_expect *exp, const enum nf_expect_attr type)
 nfexp_get_attr_u32 - get attribute of unsigned 32-bits long More...
 
int nfexp_attr_is_set (const struct nf_expect *exp, const enum nf_expect_attr type)
 nfexp_attr_is_set - check if a certain attribute is set More...
 
int nfexp_attr_unset (struct nf_expect *exp, const enum nf_expect_attr type)
 nfexp_attr_unset - unset a certain attribute More...
 
int nfexp_snprintf (char *buf, unsigned int size, const struct nf_expect *exp, unsigned int msg_type, unsigned int out_type, unsigned int flags)
 nfexp_snprintf - print a conntrack object to a buffer More...
 

Detailed Description

Function Documentation

int nfexp_attr_is_set ( const struct nf_expect exp,
const enum nf_expect_attr  type 
)

nfexp_attr_is_set - check if a certain attribute is set

Parameters
exppointer to a valid expectation object
typeattribute type

On error, -1 is returned and errno is set appropiately, otherwise the value of the attribute is returned.

References ATTR_EXP_MAX, NULL, and nf_expect::set.

Referenced by exp2msg(), and exp_filter_find().

Here is the caller graph for this function:

int nfexp_attr_unset ( struct nf_expect exp,
const enum nf_expect_attr  type 
)

nfexp_attr_unset - unset a certain attribute

Parameters
typeattribute type
exppointer to a valid expectation object

On error, -1 is returned and errno is set appropiately, otherwise 0 is returned.

References ATTR_EXP_MAX, NULL, and nf_expect::set.

struct nf_expect* nfexp_clone ( const struct nf_expect exp)

nfexp_clone - clone a expectation object

Parameters
exppointer to a valid expectation object

On error, NULL is returned and errno is appropiately set. Otherwise, a valid pointer to the clone expect is returned.

References nfexp_new(), and NULL.

Referenced by nl_create_expect(), and nl_get_expect().

Here is the call graph for this function:

Here is the caller graph for this function:

int nfexp_cmp ( const struct nf_expect exp1,
const struct nf_expect exp2,
unsigned int  flags 
)

nfexp_cmp - compare two expectation objects

Parameters
exp1pointer to a valid expectation object
exp2pointer to a valid expectation object
flagsflags

This function only compare attribute set in both objects, by default the comparison is not strict, ie. if a certain attribute is not set in one of the objects, then such attribute is not used in the comparison. If you want more strict comparisons, you can use the appropriate flags to modify this behaviour (see NFCT_CMP_STRICT and NFCT_CMP_MASK).

The available flags are:

  • NFCT_CMP_STRICT: the compared objects must have the same attributes and the same values, otherwise it returns that the objects are different.
  • NFCT_CMP_MASK: the first object is used as mask, this means that if an attribute is present in exp1 but not in exp2, this function returns that the objects are different.

Other existing flags that are used by nfct_cmp() are ignored.

If both conntrack object are equal, this function returns 1, otherwise 0 is returned.

References __cmp_expect(), and NULL.

Here is the call graph for this function:

void nfexp_destroy ( struct nf_expect exp)

nfexp_destroy - release an expectation object

Parameters
exppointer to the expectation object

References NULL.

Referenced by __callback(), main(), nl_create_expect(), and nl_get_expect().

Here is the caller graph for this function:

const void* nfexp_get_attr ( const struct nf_expect exp,
const enum nf_expect_attr  type 
)

nfexp_get_attr - get an expect attribute

Parameters
exppointer to a valid expect
typeattribute type

In case of success a valid pointer to the attribute requested is returned, on error NULL is returned and errno is set appropiately.

References ATTR_EXP_MAX, exp, get_exp_attr_array, NULL, nf_expect::set, and type.

Referenced by exp2msg(), exp_filter_find(), main(), nfexp_get_attr_u16(), nfexp_get_attr_u32(), and nfexp_get_attr_u8().

Here is the caller graph for this function:

u_int16_t nfexp_get_attr_u16 ( const struct nf_expect exp,
const enum nf_expect_attr  type 
)

nfexp_get_attr_u16 - get attribute of unsigned 16-bits long

Parameters
exppointer to a valid expectation
typeattribute type

Returns the value of the requested attribute, if the attribute is not set, 0 is returned. In order to check if the attribute is set or not, use nfexp_attr_is_set.

References nfexp_get_attr(), and NULL.

Here is the call graph for this function:

u_int32_t nfexp_get_attr_u32 ( const struct nf_expect exp,
const enum nf_expect_attr  type 
)

nfexp_get_attr_u32 - get attribute of unsigned 32-bits long

Parameters
exppointer to a valid expectation
typeattribute type

Returns the value of the requested attribute, if the attribute is not set, 0 is returned. In order to check if the attribute is set or not, use nfexp_attr_is_set.

References nfexp_get_attr(), and NULL.

Here is the call graph for this function:

u_int8_t nfexp_get_attr_u8 ( const struct nf_expect exp,
const enum nf_expect_attr  type 
)

nfexp_get_attr_u8 - get attribute of unsigned 8-bits long

Parameters
exppointer to a valid expectation
typeattribute type

Returns the value of the requested attribute, if the attribute is not set, 0 is returned. In order to check if the attribute is set or not, use nfexp_attr_is_set.

References nfexp_get_attr(), and NULL.

Here is the call graph for this function:

size_t nfexp_maxsize ( void  )

nfexp_maxsize - return the maximum size in bytes of a expect object

Use this function if you want to allocate a expect object in the stack instead of the heap. For example:

char buf[nfexp_maxsize()]; struct nf_expect *exp = (struct nf_expect *) buf; memset(exp, 0, nfexp_maxsize());

Note: As for now this function returns the same size that nfexp_sizeof(exp) does although this could change in the future. Therefore, do not assume that nfexp_sizeof(exp) == nfexp_maxsize().

struct nf_expect* nfexp_new ( void  )

nfexp_new - allocate a new expectation

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

References exp, and NULL.

Referenced by __callback(), main(), and nfexp_clone().

Here is the caller graph for this function:

void nfexp_set_attr ( struct nf_expect exp,
const enum nf_expect_attr  type,
const void *  value 
)

nfexp_set_attr - set the value of a certain expect attribute

Parameters
exppointer to a valid expect
typeattribute type
valuepointer to the attribute value

Note that certain attributes are unsettable:

  • ATTR_EXP_USE
  • ATTR_EXP_ID
  • ATTR_EXP_*_COUNTER_* The call of this function for such attributes do nothing.

References ATTR_EXP_MAX, exp, NULL, set_exp_attr_array, type, and value.

Referenced by cthelper_expect_init(), main(), msg2exp(), nfexp_set_attr_u16(), nfexp_set_attr_u32(), and nfexp_set_attr_u8().

Here is the caller graph for this function:

void nfexp_set_attr_u16 ( struct nf_expect exp,
const enum nf_expect_attr  type,
u_int16_t  value 
)

nfexp_set_attr_u16 - set the value of a certain expect attribute

Parameters
exppointer to a valid expect
typeattribute type
valueunsigned 16 bits attribute value

References nfexp_set_attr().

Here is the call graph for this function:

void nfexp_set_attr_u32 ( struct nf_expect exp,
const enum nf_expect_attr  type,
u_int32_t  value 
)

nfexp_set_attr_u32 - set the value of a certain expect attribute

Parameters
exppointer to a valid expect
typeattribute type
valueunsigned 32 bits attribute value

References nfexp_set_attr().

Referenced by cthelper_expect_init(), main(), and nl_create_expect().

Here is the call graph for this function:

Here is the caller graph for this function:

void nfexp_set_attr_u8 ( struct nf_expect exp,
const enum nf_expect_attr  type,
u_int8_t  value 
)

nfexp_set_attr_u8 - set the value of a certain expect attribute

Parameters
exppointer to a valid expect
typeattribute type
valueunsigned 8 bits attribute value

References nfexp_set_attr().

Here is the call graph for this function:

size_t nfexp_sizeof ( const struct nf_expect exp)

nfexp_sizeof - return the size in bytes of a certain expect object

Parameters
exppointer to the expect object

References NULL.

int nfexp_snprintf ( char *  buf,
unsigned int  size,
const struct nf_expect exp,
unsigned int  msg_type,
unsigned int  out_type,
unsigned int  flags 
)

nfexp_snprintf - print a conntrack object to a buffer

Parameters
bufbuffer used to build the printable conntrack
sizesize of the buffer
exppointer to a valid expectation object
message_typeprint message type (NFEXP_T_UNKNOWN, NFEXP_T_NEW,...)
output_typeprint type (NFEXP_O_DEFAULT, NFEXP_O_XML, ...)
flagsextra flags for the output type (NFEXP_OF_LAYER3)

If you are listening to events, probably you want to display the message type as well. In that case, set the message type parameter to any of the known existing types, ie. NFEXP_T_NEW, NFEXP_T_UPDATE, NFEXP_T_DESTROY. If you pass NFEXP_T_UNKNOWN, the message type will not be output.

Currently, the output available are:

  • NFEXP_O_DEFAULT: default /proc-like output
  • NFEXP_O_XML: XML output

The output flags are:

  • NFEXP_O_LAYER: include layer 3 information in the output, this is only required by NFEXP_O_DEFAULT.

On error, -1 is returned and errno is set appropiately. Otherwise, 0 is returned.

References __snprintf_expect(), and NULL.

Referenced by dlog_exp().

Here is the call graph for this function:

Here is the caller graph for this function: