netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
libebtc.c File Reference
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "include/ebtables_u.h"
#include "include/ethernetdb.h"
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
Include dependency graph for libebtc.c:

Data Structures

struct  ebt_u_stack
 

Macros

#define LOCKDIR   "/var/lib/ebtables"
 
#define LOCKFILE   LOCKDIR"/lock"
 
#define OPT_COUNT   0x1000 /* This value is also defined in ebtables.c */
 

Functions

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)
 
void ebt_list_extensions ()
 
void unlock_file ()
 
void __attribute__ ((destructor))
 
int ebt_get_kernel_table (struct ebt_u_replace *replace, int init)
 
void ebt_initialize_entry (struct ebt_u_entry *e)
 
void ebt_cleanup_replace (struct ebt_u_replace *replace)
 
void ebt_reinit_extensions ()
 
void ebt_free_u_entry (struct ebt_u_entry *e)
 
int ebtables_insmod (const char *modname)
 
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_delete_cc (struct ebt_cntchanges *cc)
 
void ebt_empty_chain (struct ebt_u_entries *entries)
 
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_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_zero_counters (struct ebt_u_replace *replace)
 
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_double_chains (struct ebt_u_replace *replace)
 
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_register_match (struct ebt_u_match *m)
 
void ebt_register_watcher (struct ebt_u_watcher *w)
 
void ebt_register_target (struct ebt_u_target *t)
 
void ebt_register_table (struct ebt_u_table *t)
 
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,...)
 

Variables

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

Macro Definition Documentation

#define LOCKDIR   "/var/lib/ebtables"
#define LOCKFILE   LOCKDIR"/lock"
#define OPT_COUNT   0x1000 /* This value is also defined in ebtables.c */

Referenced by ebt_check_rule_exists().

Function Documentation

void __attribute__ ( (destructor)  )

References unlock_file(), and use_lockfd.

Here is the call graph for this function:

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

References PROGNAME.

void __ebt_print_error ( char *  format,
  ... 
)

References ERRORMSG_MAXLEN.

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_delete_cc ( struct ebt_cntchanges cc)

References CNT_ADD, CNT_DEL, ebt_cntchanges::next, ebt_cntchanges::prev, and ebt_cntchanges::type.

Referenced by ebt_delete_rule(), and ebt_empty_chain().

Here is the caller graph for this function:

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_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:

void ebt_empty_chain ( struct ebt_u_entries entries)

References ebt_u_entry::cc, ebt_delete_cc(), ebt_free_u_entry(), ebt_u_entries::entries, ebt_u_entries::nentries, ebt_u_entry::next, and ebt_u_entry::prev.

Referenced by ebt_flush_chains().

Here is the call graph for this function:

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:

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:

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_register_table ( struct ebt_u_table t)

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:

void unlock_file ( )

References LOCKFILE.

Referenced by __attribute__().

Here is the caller graph for this function:

Variable Documentation

const char* ebt_hooknames[NF_BR_NUMHOOKS]
Initial value:
=
{
[NF_BR_PRE_ROUTING]"PREROUTING",
[NF_BR_LOCAL_IN]"INPUT",
[NF_BR_FORWARD]"FORWARD",
[NF_BR_LOCAL_OUT]"OUTPUT",
[NF_BR_POST_ROUTING]"POSTROUTING",
[NF_BR_BROUTING]"BROUTING"
}
#define NF_BR_POST_ROUTING
Definition: netfilter_bridge.h:22
#define NF_BR_LOCAL_OUT
Definition: netfilter_bridge.h:20
#define NF_BR_PRE_ROUTING
Definition: netfilter_bridge.h:14
#define NF_BR_BROUTING
Definition: netfilter_bridge.h:24
#define NF_BR_FORWARD
Definition: netfilter_bridge.h:18
#define NF_BR_LOCAL_IN
Definition: netfilter_bridge.h:16
char* ebt_modprobe

Referenced by do_command().

int ebt_silent

Referenced by main().

const char* ebt_standard_targets[NUM_STANDARD_TARGETS]
Initial value:
=
{
"ACCEPT",
"DROP",
"CONTINUE",
"RETURN",
}

Referenced by do_command(), and main().

struct ebt_u_target* ebt_targets
int use_lockfd