netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ebtables_u.h File Reference
#include <netinet/in.h>
#include <linux/netfilter_bridge/ebtables.h>
#include <linux/netfilter/x_tables.h>
Include dependency graph for ebtables_u.h:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  ebt_u_entries
 
struct  ebt_cntchanges
 
struct  ebt_u_replace
 
struct  ebt_u_table
 
struct  ebt_u_match_list
 
struct  ebt_u_watcher_list
 
struct  ebt_u_entry
 
struct  ebt_u_match
 
struct  ebt_u_watcher
 
struct  ebt_u_target
 

Macros

#define IPPROTO_SCTP   132
 
#define IPPROTO_DCCP   33
 
#define EXEC_STYLE_PRG   0
 
#define EXEC_STYLE_DAEMON   1
 
#define EBT_MIN_ALIGN   (__alignof__(struct _xt_align))
 
#define EBT_ALIGN(s)   (((s) + (EBT_MIN_ALIGN-1)) & ~(EBT_MIN_ALIGN-1))
 
#define ERRORMSG_MAXLEN   128
 
#define EBT_ORI_MAX_CHAINS   10
 
#define ebt_check_inverse(arg)   _ebt_check_inverse(arg, argc, argv)
 
#define ebt_to_chain(repl)
 
#define ebt_print_bug(format, args...)   __ebt_print_bug(__FILE__, __LINE__, format, ##args)
 
#define ebt_print_error(format, args...)   __ebt_print_error(format, ##args);
 
#define ebt_print_error2(format, args...)
 
#define ebt_check_option2(flags, mask)
 
#define ebt_check_inverse2(option)
 
#define ebt_print_memory()
 
#define CNT_NORM   0
 
#define CNT_DEL   1
 
#define CNT_ADD   2
 
#define CNT_CHANGE   3
 
#define FILL_TARGET(_str, _pos)
 
#define TARGET_INDEX(_value)   (-_value - 1)
 
#define TARGET_NAME(_value)   (ebt_standard_targets[TARGET_INDEX(_value)])
 
#define BASE_CHAIN   (hookmask & (1 << NF_BR_NUMHOOKS))
 
#define CLEAR_BASE_CHAIN_BIT   (hookmask &= ~(1 << NF_BR_NUMHOOKS))
 
#define PRINT_VERSION   printf(PROGNAME" v"PROGVERSION" ("PROGDATE")\n")
 
#define PROC_SYS_MODPROBE   "/proc/sys/kernel/modprobe"
 
#define ATOMIC_ENV_VARIABLE   "EBTABLES_ATOMIC_FILE"
 
#define ARRAY_SIZE(x)   (sizeof(x) / sizeof((x)[0]))
 

Functions

void ebt_register_table (struct ebt_u_table *)
 
void ebt_register_match (struct ebt_u_match *)
 
void ebt_register_watcher (struct ebt_u_watcher *)
 
void ebt_register_target (struct ebt_u_target *t)
 
int ebt_get_kernel_table (struct ebt_u_replace *replace, int init)
 
struct ebt_u_targetebt_find_target (const char *name)
 
struct ebt_u_matchebt_find_match (const char *name)
 
struct ebt_u_watcherebt_find_watcher (const char *name)
 
struct ebt_u_tableebt_find_table (const char *name)
 
int ebtables_insmod (const char *modname)
 
void ebt_list_extensions ()
 
void ebt_initialize_entry (struct ebt_u_entry *e)
 
void ebt_cleanup_replace (struct ebt_u_replace *replace)
 
void ebt_reinit_extensions ()
 
void ebt_double_chains (struct ebt_u_replace *replace)
 
void ebt_free_u_entry (struct ebt_u_entry *e)
 
struct ebt_u_entriesebt_name_to_chain (const struct ebt_u_replace *replace, const char *arg)
 
int ebt_get_chainnr (const struct ebt_u_replace *replace, const char *arg)
 
void ebt_change_policy (struct ebt_u_replace *replace, int policy)
 
void ebt_flush_chains (struct ebt_u_replace *replace)
 
int ebt_check_rule_exists (struct ebt_u_replace *replace, struct ebt_u_entry *new_entry)
 
void ebt_add_rule (struct ebt_u_replace *replace, struct ebt_u_entry *new_entry, int rule_nr)
 
void ebt_delete_rule (struct ebt_u_replace *replace, struct ebt_u_entry *new_entry, int begin, int end)
 
void ebt_zero_counters (struct ebt_u_replace *replace)
 
void ebt_change_counters (struct ebt_u_replace *replace, struct ebt_u_entry *new_entry, int begin, int end, struct ebt_counter *cnt, int mask)
 
void ebt_new_chain (struct ebt_u_replace *replace, const char *name, int policy)
 
void ebt_delete_chain (struct ebt_u_replace *replace)
 
void ebt_rename_chain (struct ebt_u_replace *replace, const char *name)
 
void ebt_do_final_checks (struct ebt_u_replace *replace, struct ebt_u_entry *e, struct ebt_u_entries *entries)
 
int ebt_check_for_references (struct ebt_u_replace *replace, int print_err)
 
int ebt_check_for_references2 (struct ebt_u_replace *replace, int chain_nr, int print_err)
 
void ebt_check_for_loops (struct ebt_u_replace *replace)
 
void ebt_add_match (struct ebt_u_entry *new_entry, struct ebt_u_match *m)
 
void ebt_add_watcher (struct ebt_u_entry *new_entry, struct ebt_u_watcher *w)
 
void ebt_iterate_matches (void(*f)(struct ebt_u_match *))
 
void ebt_iterate_watchers (void(*f)(struct ebt_u_watcher *))
 
void ebt_iterate_targets (void(*f)(struct ebt_u_target *))
 
void __ebt_print_bug (char *file, int line, char *format,...)
 
void __ebt_print_error (char *format,...)
 
int ebt_get_table (struct ebt_u_replace *repl, int init)
 
void ebt_deliver_counters (struct ebt_u_replace *repl)
 
void ebt_deliver_table (struct ebt_u_replace *repl)
 
void ebt_check_option (unsigned int *flags, unsigned int mask)
 
int _ebt_check_inverse (const char option[], int argc, char **argv)
 
void ebt_print_mac (const unsigned char *mac)
 
void ebt_print_mac_and_mask (const unsigned char *mac, const unsigned char *mask)
 
int ebt_get_mac_and_mask (const char *from, unsigned char *to, unsigned char *mask)
 
void ebt_parse_ip_address (char *address, uint32_t *addr, uint32_t *msk)
 
char * ebt_mask_to_dotted (uint32_t mask)
 
void ebt_parse_ip6_address (char *address, struct in6_addr *addr, struct in6_addr *msk)
 
char * ebt_ip6_to_numeric (const struct in6_addr *addrp)
 
char * ebt_ip6_mask_to_string (const struct in6_addr *msk)
 
int do_command (int argc, char *argv[], int exec_style, struct ebt_u_replace *replace_)
 
struct ethertypeentparseethertypebynumber (int type)
 

Variables

struct ebt_u_tableebt_tables
 
struct ebt_u_matchebt_matches
 
struct ebt_u_watcherebt_watchers
 
struct ebt_u_targetebt_targets
 
int use_lockfd
 
int ebt_invert
 
const char * ebt_hooknames [NF_BR_NUMHOOKS]
 
const char * ebt_standard_targets [NUM_STANDARD_TARGETS]
 
char ebt_errormsg [ERRORMSG_MAXLEN]
 
char * ebt_modprobe
 
int ebt_silent
 
int ebt_printstyle_mac
 

Macro Definition Documentation

#define ARRAY_SIZE (   x)    (sizeof(x) / sizeof((x)[0]))
#define ATOMIC_ENV_VARIABLE   "EBTABLES_ATOMIC_FILE"

Referenced by do_command().

#define BASE_CHAIN   (hookmask & (1 << NF_BR_NUMHOOKS))
#define CLEAR_BASE_CHAIN_BIT   (hookmask &= ~(1 << NF_BR_NUMHOOKS))
#define CNT_ADD   2
#define CNT_CHANGE   3
#define CNT_DEL   1
#define EBT_ALIGN (   s)    (((s) + (EBT_MIN_ALIGN-1)) & ~(EBT_MIN_ALIGN-1))
#define ebt_check_inverse (   arg)    _ebt_check_inverse(arg, argc, argv)
#define ebt_check_inverse2 (   option)
Value:
({int __ret = ebt_check_inverse(option); \
if (ebt_errormsg[0] != '\0') \
return -1; \
if (!optarg) { \
__ebt_print_error("Option without (mandatory) argument"); \
return -1; \
} \
__ret;})
void __ebt_print_error(char *format,...)
Definition: libebtc.c:1337
#define ebt_check_inverse(arg)
Definition: ebtables_u.h:296
char ebt_errormsg[ERRORMSG_MAXLEN]
Definition: libebtc.c:1332

Referenced by do_command().

#define ebt_check_option2 (   flags,
  mask 
)
Value:
if (ebt_errormsg[0] != '\0') \
return -1;})
static int struct nlattr enum ipset_adt adt u32 u32 flags
Definition: ip_set_hash_gen.h:1157
struct nf_conntrack * mask
Definition: conntrack.c:75
char ebt_errormsg[ERRORMSG_MAXLEN]
Definition: libebtc.c:1332
void ebt_check_option(unsigned int *flags, unsigned int mask)
Definition: useful_functions.c:168

Referenced by do_command().

#define EBT_MIN_ALIGN   (__alignof__(struct _xt_align))
#define EBT_ORI_MAX_CHAINS   10

Referenced by ebt_get_table().

#define ebt_print_bug (   format,
  args... 
)    __ebt_print_bug(__FILE__, __LINE__, format, ##args)
#define ebt_print_error2 (   format,
  args... 
)
Value:
do {__ebt_print_error(format, ##args); \
return -1;} while (0)
void format(printf, 2, 3)))
void __ebt_print_error(char *format,...)
Definition: libebtc.c:1337

Referenced by do_command(), and ebt_get_kernel_table().

#define ebt_print_memory ( )
Value:
do {printf("Ebtables: " __FILE__ \
" %s %d :Out of memory.\n", __FUNCTION__, __LINE__); exit(-1);} while (0)

Referenced by do_command(), ebt_add_match(), ebt_add_rule(), ebt_add_watcher(), ebt_check_for_loops(), ebt_deliver_counters(), ebt_double_chains(), ebt_get_table(), ebt_new_chain(), ebt_register_match(), ebt_register_target(), ebt_register_watcher(), and ebt_reinit_extensions().

#define ebt_to_chain (   repl)
Value:
({struct ebt_u_entries *_ch = NULL; \
if (repl->selected_chain != -1) \
_ch = repl->chains[repl->selected_chain]; \
_ch;})
#define NULL
Definition: linux_stddef.h:8
Definition: ebtables_u.h:46

Referenced by do_command(), ebt_add_rule(), ebt_change_counters(), ebt_change_policy(), ebt_check_rule_exists(), ebt_delete_rule(), ebt_flush_chains(), ebt_rename_chain(), and ebt_zero_counters().

#define ERRORMSG_MAXLEN   128

Referenced by __ebt_print_error().

#define EXEC_STYLE_DAEMON   1

Referenced by do_command(), and main().

#define EXEC_STYLE_PRG   0

Referenced by do_command(), and main().

#define FILL_TARGET (   _str,
  _pos 
)
Value:
({ \
int _i, _ret = 0; \
for (_i = 0; _i < NUM_STANDARD_TARGETS; _i++) \
if (!strcmp(_str, ebt_standard_targets[_i])) {\
_pos = -_i - 1; \
break; \
} \
if (_i == NUM_STANDARD_TARGETS) \
_ret = 1; \
_ret; \
})
#define NUM_STANDARD_TARGETS
Definition: ebtables.h:29
const char * ebt_standard_targets[NUM_STANDARD_TARGETS]
Definition: libebtc.c:54
#define IPPROTO_DCCP   33
#define IPPROTO_SCTP   132
#define PRINT_VERSION   printf(PROGNAME" v"PROGVERSION" ("PROGDATE")\n")

Referenced by do_command(), and ebt_list_extensions().

#define PROC_SYS_MODPROBE   "/proc/sys/kernel/modprobe"
#define TARGET_INDEX (   _value)    (-_value - 1)
#define TARGET_NAME (   _value)    (ebt_standard_targets[TARGET_INDEX(_value)])

Function Documentation

void __ebt_print_bug ( char *  file,
int  line,
char *  format,
  ... 
)

References PROGNAME.

void __ebt_print_error ( char *  format,
  ... 
)

References ERRORMSG_MAXLEN.

int _ebt_check_inverse ( const char  option[],
int  argc,
char **  argv 
)

References ebt_invert, ebt_print_error, and NULL.

int do_command ( int  argc,
char *  argv[],
int  exec_style,
struct ebt_u_replace replace_ 
)

References _PATH_ETHERTYPES, ATOMIC_ENV_VARIABLE, ebt_counter::bcnt, ebt_u_entry::bitmask, buffer, ebt_u_replace::chains, ebt_u_table::check, ebt_u_entry::cnt, ebt_u_entry::cnt_surplus, ebt_u_replace::command, ebt_u_entry::destmac, ebt_u_entry::destmsk, ethertypeent::e_ethertype, EBT_802_3, EBT_ACCEPT, ebt_add_match(), ebt_add_rule(), ebt_add_watcher(), EBT_CHAIN_MAXNAMELEN, ebt_change_counters(), ebt_change_policy(), ebt_check_for_loops(), ebt_check_inverse2, ebt_check_option2, EBT_CONTINUE, ebt_delete_chain(), ebt_delete_rule(), ebt_deliver_counters(), ebt_deliver_table(), EBT_DESTMAC, ebt_do_final_checks(), ebt_errormsg, ebt_find_match(), ebt_find_table(), ebt_find_target(), ebt_find_watcher(), ebt_flush_chains(), ebt_get_chainnr(), ebt_get_kernel_table(), ebt_get_mac_and_mask(), ebt_get_table(), EBT_IDEST, EBT_IIN, EBT_ILOGICALIN, EBT_ILOGICALOUT, ebt_initialize_entry(), ebt_invert, EBT_IOUT, EBT_IPROTO, EBT_ISOURCE, ebt_list_extensions(), ebt_matches, ebt_modprobe, ebt_new_chain(), EBT_NOPROTO, ebt_print_bug, ebt_print_error, ebt_print_error2, ebt_print_memory, ebt_rename_chain(), EBT_RETURN, EBT_SOURCEMAC, EBT_STANDARD_TARGET, ebt_standard_targets, EBT_TABLE_MAXNAMELEN, ebt_to_chain, ebt_watchers, ebt_zero_counters(), ebt_u_entries::entries, entries, ebt_u_entry::ethproto, EXEC_STYLE_DAEMON, EXEC_STYLE_PRG, ebt_u_replace::filename, ebt_u_match::final_check, ebt_u_watcher::final_check, ebt_u_target::final_check, ebt_u_replace::flags, ebt_u_match::flags, ebt_u_watcher::flags, ebt_u_target::flags, getethertypebyname(), ebt_u_entries::hook_mask, IFNAMSIZ, ebt_u_entry::in, ebt_u_entry::invflags, LIST_C, LIST_MAC2, LIST_N, LIST_X, ebt_u_entry::logical_in, ebt_u_entry::logical_out, ebt_u_match_list::m, ebt_u_match::m, ebt_u_entry::m_list, ebt_u_replace::name, ebt_entry_target::name, ebt_u_target::name, ebt_u_replace::nentries, ebt_u_match_list::next, ebt_u_watcher_list::next, ebt_u_entry::next, ebt_u_match::next, ebt_u_watcher::next, NF_BR_BROUTING, NF_BR_NUMHOOKS, NULL, ebt_u_replace::num_chains, ebt_u_replace::num_counters, NUM_STANDARD_TARGETS, OPT_COMMAND, OPT_COMMANDS, OPT_COUNT, OPT_DEST, OPT_IN, OPT_JUMP, OPT_KERNELDATA, OPT_LOGICALIN, OPT_LOGICALOUT, OPT_OUT, OPT_PROTOCOL, OPT_SOURCE, OPT_TABLE, OPT_ZERO, ebt_u_match::option_offset, ebt_u_watcher::option_offset, ebt_u_target::option_offset, ebt_u_entry::out, ebt_u_match::parse, ebt_u_watcher::parse, ebt_u_target::parse, ebt_counter::pcnt, PRINT_VERSION, PROGNAME, ebt_u_entry::replace, ebt_u_replace::selected_chain, ebt_u_entry::sourcemac, ebt_u_entry::sourcemsk, ebt_u_entry::t, ebt_u_target::t, ebt_entry_target::u, use_lockfd, ebt_u_match::used, ebt_u_watcher::used, ebt_u_target::used, ebt_u_watcher_list::w, ebt_u_watcher::w, and ebt_u_entry::w_list.

Here is the call graph for this function:

void ebt_add_match ( struct ebt_u_entry new_entry,
struct ebt_u_match m 
)

References ebt_print_memory, ebt_u_entry::m_list, ebt_u_match_list::next, and NULL.

Referenced by do_command().

Here is the caller graph for this function:

void ebt_add_watcher ( struct ebt_u_entry new_entry,
struct ebt_u_watcher w 
)

References ebt_print_memory, ebt_u_watcher_list::next, NULL, and ebt_u_entry::w_list.

Referenced by do_command().

Here is the caller graph for this function:

void ebt_change_counters ( struct ebt_u_replace replace,
struct ebt_u_entry new_entry,
int  begin,
int  end,
struct ebt_counter cnt,
int  mask 
)
void ebt_change_policy ( struct ebt_u_replace replace,
int  policy 
)

References EBT_CONTINUE, ebt_print_bug, ebt_to_chain, entries, NUM_STANDARD_TARGETS, and ebt_u_entries::policy.

Referenced by do_command().

Here is the caller graph for this function:

int ebt_check_for_references ( struct ebt_u_replace replace,
int  print_err 
)
int ebt_check_for_references2 ( struct ebt_u_replace replace,
int  chain_nr,
int  print_err 
)
void ebt_check_option ( unsigned int *  flags,
unsigned int  mask 
)

References ebt_print_error, and mask.

void ebt_delete_chain ( struct ebt_u_replace replace)

References ebt_print_bug, NF_BR_NUMHOOKS, and ebt_u_replace::selected_chain.

Referenced by do_command().

Here is the caller graph for this function:

void ebt_delete_rule ( struct ebt_u_replace replace,
struct ebt_u_entry new_entry,
int  begin,
int  end 
)
void ebt_deliver_table ( struct ebt_u_replace repl)

References ebt_u_replace::command, ebt_print_error, EBT_SO_SET_ENTRIES, ebtables_insmod(), ebt_replace::entries, ebt_u_replace::filename, NULL, and sockfd.

Referenced by do_command(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

void ebt_double_chains ( struct ebt_u_replace replace)

References ebt_u_replace::chains, ebt_print_memory, and ebt_u_replace::max_chains.

Referenced by ebt_new_chain().

Here is the caller graph for this function:

struct ebt_u_match* ebt_find_match ( const char *  name)

References ebt_matches, ebt_u_match::m, ebt_u_match::name, and ebt_u_match::next.

Referenced by do_command(), and ebt_do_final_checks().

Here is the caller graph for this function:

struct ebt_u_table* ebt_find_table ( const char *  name)

References ebt_tables, ebt_u_table::name, and ebt_u_table::next.

Referenced by do_command(), and ebt_get_kernel_table().

Here is the caller graph for this function:

struct ebt_u_target* ebt_find_target ( const char *  name)

References ebt_targets, ebt_u_target::name, ebt_u_target::next, and ebt_u_target::t.

Referenced by do_command(), ebt_do_final_checks(), and ebt_initialize_entry().

Here is the caller graph for this function:

struct ebt_u_watcher* ebt_find_watcher ( const char *  name)

References ebt_watchers, ebt_u_watcher::name, ebt_u_watcher::next, and ebt_u_watcher::w.

Referenced by do_command(), and ebt_do_final_checks().

Here is the caller graph for this function:

void ebt_flush_chains ( struct ebt_u_replace replace)

References ebt_u_replace::chains, ebt_u_entries::counter_offset, ebt_empty_chain(), ebt_to_chain, entries, ebt_u_entries::nentries, ebt_u_replace::nentries, ebt_u_replace::num_chains, and ebt_u_replace::selected_chain.

Referenced by do_command().

Here is the call graph for this function:

Here is the caller graph for this function:

int ebt_get_chainnr ( const struct ebt_u_replace replace,
const char *  arg 
)

References ebt_u_replace::chains, ebt_u_entries::name, and ebt_u_replace::num_chains.

Referenced by do_command(), and main().

Here is the caller graph for this function:

int ebt_get_kernel_table ( struct ebt_u_replace replace,
int  init 
)

References ebt_errormsg, ebt_find_table(), ebt_get_table(), ebt_print_error, ebt_print_error2, ebtables_insmod(), LOCKFILE, ebt_u_replace::name, and use_lockfd.

Referenced by do_command(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

int ebt_get_mac_and_mask ( const char *  from,
unsigned char *  to,
unsigned char *  mask 
)
char* ebt_ip6_mask_to_string ( const struct in6_addr *  msk)

References buf, and ebt_ip6_to_numeric().

Here is the call graph for this function:

char* ebt_ip6_to_numeric ( const struct in6_addr *  addrp)

Referenced by ebt_ip6_mask_to_string().

Here is the caller graph for this function:

void ebt_iterate_matches ( void(*)(struct ebt_u_match *)  f)

References ebt_u_match::next.

Referenced by ebt_early_init_once().

Here is the caller graph for this function:

void ebt_iterate_targets ( void(*)(struct ebt_u_target *)  f)

References ebt_u_target::next.

Referenced by ebt_early_init_once().

Here is the caller graph for this function:

void ebt_iterate_watchers ( void(*)(struct ebt_u_watcher *)  f)

References ebt_u_watcher::next.

Referenced by ebt_early_init_once().

Here is the caller graph for this function:

char* ebt_mask_to_dotted ( uint32_t  mask)

References buf.

struct ebt_u_entries * ebt_name_to_chain ( const struct ebt_u_replace replace,
const char *  arg 
)
void ebt_new_chain ( struct ebt_u_replace replace,
const char *  name,
int  policy 
)

References ebt_u_replace::chains, ebt_double_chains(), ebt_print_memory, ebt_u_replace::max_chains, ebt_u_entries::nentries, ebt_u_replace::nentries, new, NULL, ebt_u_replace::num_chains, and ebt_u_entries::policy.

Referenced by do_command(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

void ebt_parse_ip6_address ( char *  address,
struct in6_addr *  addr,
struct in6_addr *  msk 
)

References buf, ebt_print_error, and NULL.

void ebt_parse_ip_address ( char *  address,
uint32_t *  addr,
uint32_t *  msk 
)

References ebt_print_error, and NULL.

void ebt_print_mac ( const unsigned char *  mac)

References ebt_printstyle_mac, and ETH_ALEN.

Referenced by ebt_print_mac_and_mask().

Here is the caller graph for this function:

void ebt_print_mac_and_mask ( const unsigned char *  mac,
const unsigned char *  mask 
)
void ebt_register_table ( struct ebt_u_table )

References ebt_tables, and ebt_u_table::next.

Referenced by _init().

Here is the caller graph for this function:

void ebt_rename_chain ( struct ebt_u_replace replace,
const char *  name 
)

References ebt_print_bug, ebt_to_chain, and ebt_u_entries::name.

Referenced by do_command().

Here is the caller graph for this function:

int ebtables_insmod ( const char *  modname)

References buf, and NULL.

Referenced by ebt_deliver_table(), and ebt_get_kernel_table().

Here is the caller graph for this function:

struct ethertypeent* parseethertypebynumber ( int  type)

References ebt_print_error, and getethertypebynumber().

Here is the call graph for this function:

Variable Documentation

const char* ebt_hooknames[NF_BR_NUMHOOKS]
int ebt_invert

Referenced by _ebt_check_inverse(), and do_command().

char* ebt_modprobe

Referenced by do_command().

int ebt_printstyle_mac

Referenced by ebt_print_mac().

int ebt_silent

Referenced by main().

const char* ebt_standard_targets[NUM_STANDARD_TARGETS]

Referenced by do_command(), and main().

struct ebt_u_target* ebt_targets
int use_lockfd