netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
datatype.c File Reference
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <ctype.h>
#include <errno.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <linux/types.h>
#include <linux/netfilter.h>
#include <nftables.h>
#include <datatype.h>
#include <expression.h>
#include <gmputil.h>
#include <erec.h>
#include <netinet/ip_icmp.h>
#include <netinet/icmp6.h>
Include dependency graph for datatype.c:

Macros

#define RT_SYM_TAB_INITIAL_SIZE   16
 

Enumerations

enum  {
  DAY = (1 << 0),
  HOUR = (1 << 1),
  MIN = (1 << 2),
  SECS = (1 << 3)
}
 

Functions

void datatype_register (const struct datatype *dtype)
 
const struct datatypedatatype_lookup (enum datatypes type)
 
const struct datatypedatatype_lookup_byname (const char *name)
 
void datatype_print (const struct expr *expr)
 
struct error_recordsymbol_parse (const struct expr *sym, struct expr **res)
 
struct error_recordsymbolic_constant_parse (const struct expr *sym, const struct symbol_table *tbl, struct expr **res)
 
void symbolic_constant_print (const struct symbol_table *tbl, const struct expr *expr)
 
void symbol_table_print (const struct symbol_table *tbl, const struct datatype *dtype)
 
struct symbol_tablert_symbol_table_init (const char *filename)
 
void rt_symbol_table_free (struct symbol_table *tbl)
 
const struct datatypeconcat_type_alloc (uint32_t type)
 
void concat_type_destroy (const struct datatype *dtype)
 

Variables

const struct datatype invalid_type
 
const struct datatype verdict_type
 
const struct datatype nfproto_type
 
const struct datatype bitmask_type
 
const struct datatype integer_type
 
const struct datatype string_type
 
const struct datatype lladdr_type
 
const struct datatype ipaddr_type
 
const struct datatype ip6addr_type
 
const struct datatype inet_protocol_type
 
const struct datatype inet_service_type
 
const struct datatype mark_type
 
const struct datatype icmp_code_type
 
const struct datatype icmpv6_code_type
 
const struct datatype icmpx_code_type
 
const struct datatype time_type
 

Macro Definition Documentation

#define RT_SYM_TAB_INITIAL_SIZE   16

Referenced by rt_symbol_table_init().

Enumeration Type Documentation

anonymous enum
Enumerator
DAY 
HOUR 
MIN 
SECS 

Function Documentation

const struct datatype* concat_type_alloc ( uint32_t  type)
void concat_type_destroy ( const struct datatype dtype)
const struct datatype* datatype_lookup ( enum datatypes  type)

References NULL, type, and TYPE_MAX.

const struct datatype* datatype_lookup_byname ( const char *  name)
void datatype_print ( const struct expr expr)

References datatype::basetype, BUG, expr::dtype, datatype::name, NULL, datatype::print, datatype::sym_tbl, and symbolic_constant_print().

Here is the call graph for this function:

void datatype_register ( const struct datatype dtype)
void rt_symbol_table_free ( struct symbol_table tbl)
struct symbol_table* rt_symbol_table_init ( const char *  filename)
struct error_record* symbol_parse ( const struct expr sym,
struct expr **  res 
)
void symbol_table_print ( const struct symbol_table tbl,
const struct datatype dtype 
)

References BITS_PER_BYTE, symbolic_constant::identifier, NULL, s, datatype::size, size, symbol_table::symbols, and symbolic_constant::value.

Referenced by expr_describe().

Here is the caller graph for this function:

struct error_record* symbolic_constant_parse ( const struct expr sym,
const struct symbol_table tbl,
struct expr **  res 
)
void symbolic_constant_print ( const struct symbol_table tbl,
const struct expr expr 
)

References BITS_PER_BYTE, expr::byteorder, expr_basetype(), symbolic_constant::identifier, expr::len, mpz_export_data(), NULL, datatype::print, s, symbol_table::symbols, symbolic_constant::value, and expr::value.

Referenced by datatype_print().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const struct datatype bitmask_type
Initial value:
= {
.type = TYPE_BITMASK,
.name = "bitmask",
.desc = "bitmask",
.basetype = &integer_type,
}
Definition: datatype.h:48
const struct datatype integer_type
Definition: datatype.c:294
const struct datatype icmp_code_type
Initial value:
= {
.type = TYPE_ICMP_CODE,
.name = "icmp_code",
.desc = "icmp code",
.size = BITS_PER_BYTE,
.byteorder = BYTEORDER_BIG_ENDIAN,
.basetype = &integer_type,
.sym_tbl = &icmp_code_tbl,
}
#define BITS_PER_BYTE
Definition: utils.h:14
const struct datatype integer_type
Definition: datatype.c:294
Definition: datatype.h:77
Definition: datatype.h:98
const struct symbol_table * sym_tbl
Definition: datatype.h:143
const struct datatype icmpv6_code_type
Initial value:
= {
.name = "icmpv6_code",
.desc = "icmpv6 code",
.size = BITS_PER_BYTE,
.byteorder = BYTEORDER_BIG_ENDIAN,
.basetype = &integer_type,
.sym_tbl = &icmpv6_code_tbl,
}
#define BITS_PER_BYTE
Definition: utils.h:14
Definition: datatype.h:78
const struct datatype integer_type
Definition: datatype.c:294
Definition: datatype.h:98
const struct symbol_table * sym_tbl
Definition: datatype.h:143
const struct datatype icmpx_code_type
Initial value:
= {
.type = TYPE_ICMPX_CODE,
.name = "icmpx_code",
.desc = "icmpx code",
.size = BITS_PER_BYTE,
.byteorder = BYTEORDER_BIG_ENDIAN,
.basetype = &integer_type,
.sym_tbl = &icmpx_code_tbl,
}
#define BITS_PER_BYTE
Definition: utils.h:14
const struct datatype integer_type
Definition: datatype.c:294
Definition: datatype.h:79
Definition: datatype.h:98
const struct symbol_table * sym_tbl
Definition: datatype.h:143
const struct datatype inet_protocol_type
Initial value:
= {
.name = "inet_proto",
.desc = "Internet protocol",
.size = BITS_PER_BYTE,
.basetype = &integer_type,
.print = inet_protocol_type_print,
.parse = inet_protocol_type_parse,
}
#define BITS_PER_BYTE
Definition: utils.h:14
Definition: datatype.h:57
const struct datatype integer_type
Definition: datatype.c:294
void(* print)(const struct expr *expr)
Definition: datatype.h:140
const struct datatype inet_service_type
Initial value:
= {
.name = "inet_service",
.desc = "internet network service",
.byteorder = BYTEORDER_BIG_ENDIAN,
.size = 2 * BITS_PER_BYTE,
.basetype = &integer_type,
.print = inet_service_type_print,
.parse = inet_service_type_parse,
}
#define BITS_PER_BYTE
Definition: utils.h:14
const struct datatype integer_type
Definition: datatype.c:294
Definition: datatype.h:58
void(* print)(const struct expr *expr)
Definition: datatype.h:140
Definition: datatype.h:98

Referenced by ct_expr_update_type().

const struct datatype integer_type
Initial value:
= {
.type = TYPE_INTEGER,
.name = "integer",
.desc = "integer",
.print = integer_type_print,
.parse = integer_type_parse,
}
Definition: datatype.h:49
const struct datatype invalid_type
Initial value:
= {
.type = TYPE_INVALID,
.name = "invalid",
.desc = "invalid",
.print = invalid_type_print,
}
Definition: datatype.h:45

Referenced by constant_expr_join(), constant_expr_splice(), map_expr_alloc(), netlink_alloc_value(), prefix_expr_alloc(), range_expr_alloc(), symbol_expr_alloc(), and unary_expr_alloc().

const struct datatype ip6addr_type
Initial value:
= {
.type = TYPE_IP6ADDR,
.name = "ipv6_addr",
.desc = "IPv6 address",
.byteorder = BYTEORDER_BIG_ENDIAN,
.size = 16 * BITS_PER_BYTE,
.basetype = &integer_type,
.print = ip6addr_type_print,
.parse = ip6addr_type_parse,
.flags = DTYPE_F_PREFIX,
}
#define BITS_PER_BYTE
Definition: utils.h:14
const struct datatype integer_type
Definition: datatype.c:294
Definition: datatype.h:111
Definition: datatype.h:53
void(* print)(const struct expr *expr)
Definition: datatype.h:140
Definition: datatype.h:98

Referenced by ct_expr_update_type().

Initial value:
= {
.type = TYPE_IPADDR,
.name = "ipv4_addr",
.desc = "IPv4 address",
.byteorder = BYTEORDER_BIG_ENDIAN,
.size = 4 * BITS_PER_BYTE,
.basetype = &integer_type,
.print = ipaddr_type_print,
.parse = ipaddr_type_parse,
.flags = DTYPE_F_PREFIX,
}
#define BITS_PER_BYTE
Definition: utils.h:14
const struct datatype integer_type
Definition: datatype.c:294
Definition: datatype.h:111
Definition: datatype.h:52
void(* print)(const struct expr *expr)
Definition: datatype.h:140
Definition: datatype.h:98
const struct datatype lladdr_type
Initial value:
= {
.type = TYPE_LLADDR,
.name = "ll_addr",
.desc = "link layer address",
.byteorder = BYTEORDER_HOST_ENDIAN,
.basetype = &integer_type,
.print = lladdr_type_print,
.parse = lladdr_type_parse,
}
Definition: datatype.h:51
const struct datatype integer_type
Definition: datatype.c:294
Definition: datatype.h:97
void(* print)(const struct expr *expr)
Definition: datatype.h:140
const struct datatype mark_type
Initial value:
= {
.type = TYPE_MARK,
.name = "mark",
.desc = "packet mark",
.size = 4 * BITS_PER_BYTE,
.byteorder = BYTEORDER_HOST_ENDIAN,
.basetype = &integer_type,
.basefmt = "0x%.8Zx",
.print = mark_type_print,
.parse = mark_type_parse,
.flags = DTYPE_F_PREFIX,
}
#define BITS_PER_BYTE
Definition: utils.h:14
const char * basefmt
Definition: datatype.h:139
const struct datatype integer_type
Definition: datatype.c:294
Definition: datatype.h:111
Definition: datatype.h:97
Definition: datatype.h:64
const struct datatype nfproto_type
Initial value:
= {
.type = TYPE_NFPROTO,
.name = "nf_proto",
.desc = "netfilter protocol",
.size = 1 * BITS_PER_BYTE,
.basetype = &integer_type,
.sym_tbl = &nfproto_tbl,
}
#define BITS_PER_BYTE
Definition: utils.h:14
const struct datatype integer_type
Definition: datatype.c:294
Definition: datatype.h:47
const struct symbol_table * sym_tbl
Definition: datatype.h:143
const struct datatype string_type
Initial value:
= {
.type = TYPE_STRING,
.name = "string",
.desc = "string",
.byteorder = BYTEORDER_HOST_ENDIAN,
.print = string_type_print,
.parse = string_type_parse,
}
Definition: datatype.h:97
Definition: datatype.h:50
const struct datatype time_type
Initial value:
= {
.type = TYPE_TIME,
.name = "time",
.desc = "relative time",
.byteorder = BYTEORDER_HOST_ENDIAN,
.size = 8 * BITS_PER_BYTE,
.basetype = &integer_type,
.print = time_type_print,
.parse = time_type_parse,
}
#define BITS_PER_BYTE
Definition: utils.h:14
Definition: datatype.h:63
const struct datatype integer_type
Definition: datatype.c:294
Definition: datatype.h:97
void(* print)(const struct expr *expr)
Definition: datatype.h:140
const struct datatype verdict_type
Initial value:
= {
.type = TYPE_VERDICT,
.name = "verdict",
.desc = "netfilter verdict",
.print = verdict_type_print,
}
Definition: datatype.h:46

Referenced by relational_expr_alloc(), and verdict_expr_alloc().