netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
internal.h File Reference
#include "config.h"
#include "linux_list.h"
#include <stdint.h>
#include <stdbool.h>
#include <libnftnl/common.h>
#include <linux/netfilter/nf_tables.h>
#include <stdio.h>
#include "expr/data_reg.h"
#include <string.h>
Include dependency graph for internal.h:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  nft_parse_err
 
struct  nft_rule_expr
 
struct  nft_set
 
struct  nft_set_elem
 

Macros

#define EXPORT_SYMBOL
 
#define xfree(ptr)   free((void *)ptr);
 
#define BASE_DEC   10
 
#define BASE_HEX   16
 
#define NFT_SNPRINTF_BUFSIZ   4096
 
#define SNPRINTF_BUFFER_SIZE(ret, size, len, offset)
 
#define div_round_up(n, d)   (((n) + (d) - 1) / (d))
 
#define __init   __attribute__((constructor))
 
#define nft_assert(val, attr, expr)
 
#define nft_assert_validate(data, _validate_array, _attr, _data_len)
 
#define __noreturn   __attribute__((__noreturn__))
 
#define abi_breakage()   __abi_breakage(__FILE__, __LINE__, strerror(errno));
 

Enumerations

enum  nft_type {
  NFT_TYPE_U8,
  NFT_TYPE_U16,
  NFT_TYPE_U32,
  NFT_TYPE_U64,
  NFT_TYPE_S8,
  NFT_TYPE_S16,
  NFT_TYPE_S32,
  NFT_TYPE_S64
}
 
enum  nft_parse_input {
  NFT_PARSE_BUFFER,
  NFT_PARSE_FILE
}
 

Functions

int nft_set_lookup_id (struct nft_rule_expr *e, struct nft_set_list *set_list, uint32_t *set_id)
 
const char * nft_family2str (uint32_t family)
 
int nft_str2family (const char *family)
 
int nft_strtoi (const char *string, int base, void *number, enum nft_type type)
 
const char * nft_verdict2str (uint32_t verdict)
 
int nft_str2verdict (const char *verdict, int *verdict_num)
 
int nft_get_value (enum nft_type type, void *val, void *out)
 
int nft_fprintf (FILE *fp, void *obj, uint32_t type, uint32_t flags, int(*snprintf_cb)(char *buf, size_t bufsiz, void *obj, uint32_t type, uint32_t flags))
 
int nft_event_header_snprintf (char *buf, size_t bufsize, uint32_t format, uint32_t flags)
 
int nft_event_header_fprintf (FILE *fp, uint32_t format, uint32_t flags)
 
int nft_event_footer_snprintf (char *buf, size_t bufsize, uint32_t format, uint32_t flags)
 
int nft_event_footer_fprintf (FILE *fp, uint32_t format, uint32_t flags)
 
void __nft_assert_fail (uint16_t attr, const char *filename, int line)
 
void __noreturn __abi_breakage (const char *file, int line, const char *reason)
 

Macro Definition Documentation

#define __init   __attribute__((constructor))
#define __noreturn   __attribute__((__noreturn__))
#define abi_breakage ( )    __abi_breakage(__FILE__, __LINE__, strerror(errno));
#define BASE_DEC   10
#define BASE_HEX   16
#define div_round_up (   n,
 
)    (((n) + (d) - 1) / (d))
#define EXPORT_SYMBOL
#define nft_assert (   val,
  attr,
  expr 
)
Value:
((!val || expr) \
? (void)0 \
: __nft_assert_fail(attr, __FILE__, __LINE__))
Definition: expression.h:188
void __nft_assert_fail(uint16_t attr, const char *filename, int line)
Definition: utils.c:214

Referenced by nft_chain_attr_get_s32(), nft_chain_attr_get_u32(), nft_chain_attr_get_u64(), nft_chain_attr_get_u8(), nft_rule_attr_get_u32(), nft_rule_attr_get_u64(), nft_rule_attr_get_u8(), and nft_set_attr_get_u32().

#define nft_assert_validate (   data,
  _validate_array,
  _attr,
  _data_len 
)
Value:
({ \
if (!data) \
__nft_assert_fail(attr, __FILE__, __LINE__); \
if (_validate_array[_attr]) \
nft_assert(data, attr, _validate_array[_attr] == _data_len); \
})
void __nft_assert_fail(uint16_t attr, const char *filename, int line)
Definition: utils.c:214
#define nft_assert(val, attr, expr)
Definition: internal.h:217
enum nf_conntrack_query query const void * data
Definition: libnetfilter_conntrack.h:570

Referenced by nft_chain_attr_set_data(), nft_gen_attr_set_data(), nft_rule_attr_set_data(), nft_set_attr_set_data(), and nft_table_attr_set_data().

#define NFT_SNPRINTF_BUFSIZ   4096

Referenced by nft_fprintf().

#define SNPRINTF_BUFFER_SIZE (   ret,
  size,
  len,
  offset 
)
Value:
if (ret < 0) \
return ret; \
offset += ret; \
if (ret > len) \
ret = len; \
size += ret; \
len -= ret;
u8 size
Definition: ip_set_hash_gen.h:186
int len
Definition: utils.c:56

Referenced by nft_chain_snprintf(), nft_gen_snprintf(), nft_rule_expr_snprintf(), nft_rule_snprintf(), nft_set_elem_snprintf(), nft_set_snprintf(), and nft_table_snprintf().

Enumeration Type Documentation

Enumerator
NFT_PARSE_BUFFER 
NFT_PARSE_FILE 
enum nft_type
Enumerator
NFT_TYPE_U8 
NFT_TYPE_U16 
NFT_TYPE_U32 
NFT_TYPE_U64 
NFT_TYPE_S8 
NFT_TYPE_S16 
NFT_TYPE_S32 
NFT_TYPE_S64 

Function Documentation

void __noreturn __abi_breakage ( const char *  file,
int  line,
const char *  reason 
)
void __nft_assert_fail ( uint16_t  attr,
const char *  filename,
int  line 
)
int nft_event_footer_fprintf ( FILE *  fp,
uint32_t  format,
uint32_t  flags 
)

References nft_fprintf(), and NULL.

Referenced by nft_ruleset_fprintf().

Here is the call graph for this function:

Here is the caller graph for this function:

int nft_event_footer_snprintf ( char *  buf,
size_t  bufsize,
uint32_t  format,
uint32_t  flags 
)
int nft_event_header_fprintf ( FILE *  fp,
uint32_t  format,
uint32_t  flags 
)

References nft_fprintf(), and NULL.

Referenced by nft_ruleset_fprintf().

Here is the call graph for this function:

Here is the caller graph for this function:

int nft_event_header_snprintf ( char *  buf,
size_t  bufsize,
uint32_t  format,
uint32_t  flags 
)
const char* nft_family2str ( uint32_t  family)

References NULL.

int nft_fprintf ( FILE *  fp,
void *  obj,
uint32_t  type,
uint32_t  flags,
int(*)(char *buf, size_t bufsiz, void *obj, uint32_t type, uint32_t flags snprintf_cb 
)

References NFT_SNPRINTF_BUFSIZ, NULL, and xfree().

Referenced by nft_chain_fprintf(), nft_event_footer_fprintf(), nft_event_header_fprintf(), nft_gen_fprintf(), nft_rule_fprintf(), nft_set_elem_fprintf(), nft_set_fprintf(), and nft_table_fprintf().

Here is the call graph for this function:

Here is the caller graph for this function:

int nft_get_value ( enum nft_type  type,
void *  val,
void *  out 
)

References len, max, min, NFT_TYPE_S16, NFT_TYPE_S32, NFT_TYPE_S64, NFT_TYPE_S8, NFT_TYPE_U16, NFT_TYPE_U32, NFT_TYPE_U64, NFT_TYPE_U8, and type.

Referenced by nft_strtoi().

Here is the caller graph for this function:

int nft_set_lookup_id ( struct nft_rule_expr e,
struct nft_set_list set_list,
uint32_t *  set_id 
)

References NFT_EXPR_LOOKUP_SET, nft_rule_expr_get_str(), nft_set_attr_get_u32(), NFT_SET_ATTR_ID, NULL, and s.

Here is the call graph for this function:

int nft_str2family ( const char *  family)

References NFPROTO_NUMPROTO, and NULL.

int nft_str2verdict ( const char *  verdict,
int *  verdict_num 
)
int nft_strtoi ( const char *  string,
int  base,
void *  number,
enum nft_type  type 
)

References nft_get_value(), NFT_TYPE_S16, NFT_TYPE_S32, NFT_TYPE_S64, NFT_TYPE_S8, NFT_TYPE_U16, NFT_TYPE_U32, NFT_TYPE_U64, and NFT_TYPE_U8.

Here is the call graph for this function:

const char* nft_verdict2str ( uint32_t  verdict)