netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
expression.h File Reference
#include <stdbool.h>
#include <gmputil.h>
#include <linux/netfilter/nf_tables.h>
#include <nftables.h>
#include <datatype.h>
#include <utils.h>
#include <list.h>
#include <payload.h>
#include <exthdr.h>
#include <meta.h>
#include <ct.h>
Include dependency graph for expression.h:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  expr_ctx
 struct expr_ctx - type context for symbol parsing during evaluation More...
 
struct  expr_ops
 
struct  expr
 

Macros

#define OP_MAX   (__OP_MAX - 1)
 

Enumerations

enum  expr_types {
  EXPR_INVALID,
  EXPR_VERDICT,
  EXPR_SYMBOL,
  EXPR_VALUE,
  EXPR_PREFIX,
  EXPR_RANGE,
  EXPR_PAYLOAD,
  EXPR_EXTHDR,
  EXPR_META,
  EXPR_CT,
  EXPR_CONCAT,
  EXPR_LIST,
  EXPR_SET,
  EXPR_SET_REF,
  EXPR_MAPPING,
  EXPR_MAP,
  EXPR_UNARY,
  EXPR_BINOP,
  EXPR_RELATIONAL
}
 enum expr_types More...
 
enum  ops {
  OP_INVALID,
  OP_IMPLICIT,
  OP_HTON,
  OP_NTOH,
  OP_LSHIFT,
  OP_RSHIFT,
  OP_AND,
  OP_XOR,
  OP_OR,
  OP_EQ,
  OP_NEQ,
  OP_LT,
  OP_GT,
  OP_LTE,
  OP_GTE,
  OP_RANGE,
  OP_FLAGCMP,
  OP_LOOKUP,
  __OP_MAX
}
 
enum  symbol_types {
  SYMBOL_VALUE,
  SYMBOL_DEFINE,
  SYMBOL_SET
}
 

Variables

const char * expr_op_symbols []
 

: expression name for diagnostics

struct expr_ops

: expression type

: function to clone type specific data : destructor, must release inner expressions : function to promote type and byteorder of inner types : function to print the expression : function to compare two expressions of the same types :update protocol context

#define expr_error(msgs, expr, fmt, args...)   expr_binary_error(msgs, expr, NULL, fmt, ## args)
 
enum  expr_flags {
  EXPR_F_CONSTANT = 0x1,
  EXPR_F_SINGLETON = 0x2,
  EXPR_F_PROTOCOL = 0x4,
  EXPR_F_INTERVAL_END = 0x8
}
 enum expr_flags More...
 
struct exprexpr_alloc (const struct location *loc, const struct expr_ops *ops, const struct datatype *dtype, enum byteorder byteorder, unsigned int len)
 
struct exprexpr_clone (const struct expr *expr)
 
struct exprexpr_get (struct expr *expr)
 
void expr_free (struct expr *expr)
 
void expr_print (const struct expr *expr)
 
bool expr_cmp (const struct expr *e1, const struct expr *e2)
 
void expr_describe (const struct expr *expr)
 
const struct datatypeexpr_basetype (const struct expr *expr)
 
void expr_set_type (struct expr *expr, const struct datatype *dtype, enum byteorder byteorder)
 
int expr_binary_error (struct list_head *msgs, const struct expr *e1, const struct expr *e2, const char *fmt,...) __gmp_fmtstring(4
 
struct exprunary_expr_alloc (const struct location *loc, enum ops op, struct expr *arg)
 
struct exprbinop_expr_alloc (const struct location *loc, enum ops op, struct expr *left, struct expr *right)
 
struct exprrelational_expr_alloc (const struct location *loc, enum ops op, struct expr *left, struct expr *right)
 
struct exprverdict_expr_alloc (const struct location *loc, int verdict, const char *chain)
 
struct exprsymbol_expr_alloc (const struct location *loc, enum symbol_types type, struct scope *scope, const char *identifier)
 
struct exprconstant_expr_alloc (const struct location *loc, const struct datatype *dtype, enum byteorder byteorder, unsigned int len, const void *data)
 
struct exprconstant_expr_join (const struct expr *e1, const struct expr *e2)
 
struct exprconstant_expr_splice (struct expr *expr, unsigned int len)
 
struct exprflag_expr_alloc (const struct location *loc, const struct datatype *dtype, enum byteorder byteorder, unsigned int len, unsigned long n)
 
struct exprbitmask_expr_to_binops (struct expr *expr)
 
struct exprprefix_expr_alloc (const struct location *loc, struct expr *expr, unsigned int prefix_len)
 
struct exprrange_expr_alloc (const struct location *loc, struct expr *low, struct expr *high)
 
void compound_expr_add (struct expr *compound, struct expr *expr)
 
void compound_expr_remove (struct expr *compound, struct expr *expr)
 
struct exprconcat_expr_alloc (const struct location *loc)
 
struct exprlist_expr_alloc (const struct location *loc)
 
struct exprset_expr_alloc (const struct location *loc)
 
int set_to_intervals (struct list_head *msgs, struct set *set)
 
struct exprmapping_expr_alloc (const struct location *loc, struct expr *from, struct expr *to)
 
struct exprmap_expr_alloc (const struct location *loc, struct expr *arg, struct expr *list)
 
struct exprset_ref_expr_alloc (const struct location *loc, struct set *set)
 
void range_expr_value_low (mpz_t rop, const struct expr *expr)
 
void range_expr_value_high (mpz_t rop, const struct expr *expr)
 

Macro Definition Documentation

#define expr_error (   msgs,
  expr,
  fmt,
  args... 
)    expr_binary_error(msgs, expr, NULL, fmt, ## args)

Referenced by payload_gen_dependency().

#define OP_MAX   (__OP_MAX - 1)

Enumeration Type Documentation

enum expr_flags

enum expr_flags

: constant expression : singleton (implies primary and constant) : expressions describes upper layer protocol : set member ends an open interval

Enumerator
EXPR_F_CONSTANT 
EXPR_F_SINGLETON 
EXPR_F_PROTOCOL 
EXPR_F_INTERVAL_END 
enum expr_types

enum expr_types

: uninitialized type, should not happen : nftables verdict expression : unparsed symbol : literal numeric or string expression : prefixed expression : literal range : payload expression : exthdr expression : meta expression : conntrack expression : concatenation : list of expressions : literal set : set reference : a single mapping (key : value) : map operation (expr map { EXPR_MAPPING, ... }) : byteorder conversion, generated during evaluation : binary operations (bitwise, shifts) : equality and relational expressions

Enumerator
EXPR_INVALID 
EXPR_VERDICT 
EXPR_SYMBOL 
EXPR_VALUE 
EXPR_PREFIX 
EXPR_RANGE 
EXPR_PAYLOAD 
EXPR_EXTHDR 
EXPR_META 
EXPR_CT 
EXPR_CONCAT 
EXPR_LIST 
EXPR_SET 
EXPR_SET_REF 
EXPR_MAPPING 
EXPR_MAP 
EXPR_UNARY 
EXPR_BINOP 
EXPR_RELATIONAL 
enum ops
Enumerator
OP_INVALID 
OP_IMPLICIT 
OP_HTON 
OP_NTOH 
OP_LSHIFT 
OP_RSHIFT 
OP_AND 
OP_XOR 
OP_OR 
OP_EQ 
OP_NEQ 
OP_LT 
OP_GT 
OP_LTE 
OP_GTE 
OP_RANGE 
OP_FLAGCMP 
OP_LOOKUP 
__OP_MAX 
Enumerator
SYMBOL_VALUE 
SYMBOL_DEFINE 
SYMBOL_SET 

Function Documentation

struct expr* binop_expr_alloc ( const struct location loc,
enum ops  op,
struct expr left,
struct expr right 
)

References expr::byteorder, expr::dtype, expr_alloc(), expr::left, expr::op, and expr::right.

Referenced by bitmask_expr_to_binops().

Here is the call graph for this function:

Here is the caller graph for this function:

void compound_expr_add ( struct expr compound,
struct expr expr 
)

References expr::expressions, expr::list, and expr::size.

Referenced by interval_map_decompose().

Here is the caller graph for this function:

void compound_expr_remove ( struct expr compound,
struct expr expr 
)

References expr::list, and expr::size.

Referenced by interval_map_decompose().

Here is the caller graph for this function:

struct expr* concat_expr_alloc ( const struct location loc)
struct expr* constant_expr_alloc ( const struct location loc,
const struct datatype dtype,
enum byteorder  byteorder,
unsigned int  len,
const void *  data 
)
struct expr* constant_expr_join ( const struct expr e1,
const struct expr e2 
)
const struct datatype* expr_basetype ( const struct expr expr)

References datatype::basetype, expr::dtype, NULL, and type.

Referenced by expr_describe(), and symbolic_constant_print().

Here is the caller graph for this function:

int expr_binary_error ( struct list_head msgs,
const struct expr e1,
const struct expr e2,
const char *  fmt,
  ... 
)
struct expr* expr_clone ( const struct expr expr)

References expr::byteorder, expr_ops::clone, expr::dtype, expr_alloc(), expr::flags, expr::len, expr::location, expr::op, and expr::ops.

Referenced by interval_map_decompose().

Here is the call graph for this function:

Here is the caller graph for this function:

bool expr_cmp ( const struct expr e1,
const struct expr e2 
)
void expr_describe ( const struct expr expr)
void expr_free ( struct expr expr)

References expr_ops::destroy, NULL, expr::ops, expr::refcnt, and xfree.

Referenced by bitmask_expr_to_binops(), cmd_free(), interval_map_decompose(), scope_release(), and set_free().

Here is the caller graph for this function:

struct expr* expr_get ( struct expr expr)

References expr::refcnt.

Referenced by interval_map_decompose().

Here is the caller graph for this function:

void expr_print ( const struct expr expr)

References expr::ops, and expr_ops::print.

Referenced by set_to_intervals().

Here is the caller graph for this function:

void expr_set_type ( struct expr expr,
const struct datatype dtype,
enum byteorder  byteorder 
)
struct expr* flag_expr_alloc ( const struct location loc,
const struct datatype dtype,
enum byteorder  byteorder,
unsigned int  len,
unsigned long  n 
)

References constant_expr_alloc(), mpz_lshift_ui(), mpz_set_ui(), NULL, and expr::value.

Referenced by bitmask_expr_to_binops().

Here is the call graph for this function:

Here is the caller graph for this function:

struct expr* list_expr_alloc ( const struct location loc)
struct expr* map_expr_alloc ( const struct location loc,
struct expr arg,
struct expr list 
)

References expr::arg, BYTEORDER_INVALID, expr_alloc(), invalid_type, expr::map, and expr::mappings.

Here is the call graph for this function:

struct expr* mapping_expr_alloc ( const struct location loc,
struct expr from,
struct expr to 
)

References expr::byteorder, expr::dtype, expr_alloc(), expr::left, and expr::right.

Referenced by interval_map_decompose().

Here is the call graph for this function:

Here is the caller graph for this function:

struct expr* prefix_expr_alloc ( const struct location loc,
struct expr expr,
unsigned int  prefix_len 
)

References BYTEORDER_INVALID, expr_alloc(), invalid_type, expr::prefix, and expr::prefix_len.

Referenced by interval_map_decompose().

Here is the call graph for this function:

Here is the caller graph for this function:

struct expr* range_expr_alloc ( const struct location loc,
struct expr low,
struct expr high 
)

References BYTEORDER_INVALID, expr_alloc(), invalid_type, expr::left, and expr::right.

Referenced by interval_map_decompose().

Here is the call graph for this function:

Here is the caller graph for this function:

void range_expr_value_low ( mpz_t  rop,
const struct expr expr 
)

References BUG, EXPR_MAPPING, EXPR_PREFIX, EXPR_RANGE, EXPR_VALUE, expr::left, mpz_set(), expr_ops::name, expr::ops, expr::prefix, expr_ops::type, and expr::value.

Referenced by range_expr_value_high().

Here is the call graph for this function:

Here is the caller graph for this function:

struct expr* relational_expr_alloc ( const struct location loc,
enum ops  op,
struct expr left,
struct expr right 
)

References BYTEORDER_INVALID, expr_alloc(), expr::left, expr::op, expr::right, and verdict_type.

Referenced by payload_gen_dependency().

Here is the call graph for this function:

Here is the caller graph for this function:

struct expr* set_expr_alloc ( const struct location loc)

Referenced by netlink_get_setelems().

Here is the caller graph for this function:

struct expr* set_ref_expr_alloc ( const struct location loc,
struct set set 
)

References expr_alloc(), EXPR_F_CONSTANT, expr::flags, set::keytype, expr::set, and set_get().

Here is the call graph for this function:

int set_to_intervals ( struct list_head msgs,
struct set set 
)
struct expr* symbol_expr_alloc ( const struct location loc,
enum symbol_types  type,
struct scope scope,
const char *  identifier 
)

References BYTEORDER_INVALID, expr_alloc(), expr::identifier, invalid_type, expr::scope, expr::symtype, type, and xstrdup().

Here is the call graph for this function:

struct expr* unary_expr_alloc ( const struct location loc,
enum ops  op,
struct expr arg 
)

References expr::arg, BYTEORDER_INVALID, expr_alloc(), invalid_type, and expr::op.

Here is the call graph for this function:

struct expr* verdict_expr_alloc ( const struct location loc,
int  verdict,
const char *  chain 
)

Variable Documentation

const char* expr_op_symbols[]