netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
libiptc.c File Reference
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdbool.h>
#include <xtables.h>
#include <libiptc/xtcshared.h>
#include "linux_list.h"
Include dependency graph for libiptc.c:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  counter_map
 
struct  rule_head
 
struct  chain_head
 
struct  xtc_handle
 
struct  iptcb_chain_start
 
struct  iptcb_chain_foot
 
struct  iptcb_chain_error
 

Macros

#define DEBUGP(x, args...)
 
#define DEBUGP_C(x, args...)
 
#define debug(x, args...)
 
#define CHECK(h)
 
#define CHAIN_INDEX_BUCKET_LEN   40
 
#define CHAIN_INDEX_INSERT_MAX   355
 
#define IPTCB_CHAIN_START_SIZE
 
#define IPTCB_CHAIN_FOOT_SIZE
 
#define IPTCB_CHAIN_ERROR_SIZE
 

Enumerations

enum  iptcc_rule_type {
  IPTCC_R_STANDARD,
  IPTCC_R_MODULE,
  IPTCC_R_FALLTHROUGH,
  IPTCC_R_JUMP
}
 
enum  bsearch_type {
  BSEARCH_NAME,
  BSEARCH_OFFSET
}
 

Functions

struct xtc_handleTC_INIT (const char *tablename)
 
void TC_FREE (struct xtc_handle *h)
 
void TC_DUMP_ENTRIES (struct xtc_handle *const handle)
 
int TC_IS_CHAIN (const char *chain, struct xtc_handle *const handle)
 
const char * TC_FIRST_CHAIN (struct xtc_handle *handle)
 
const char * TC_NEXT_CHAIN (struct xtc_handle *handle)
 
const STRUCT_ENTRYTC_FIRST_RULE (const char *chain, struct xtc_handle *handle)
 
const STRUCT_ENTRYTC_NEXT_RULE (const STRUCT_ENTRY *prev, struct xtc_handle *handle)
 
const char * TC_GET_TARGET (const STRUCT_ENTRY *ce, struct xtc_handle *handle)
 
int TC_BUILTIN (const char *chain, struct xtc_handle *const handle)
 
const char * TC_GET_POLICY (const char *chain, STRUCT_COUNTERS *counters, struct xtc_handle *handle)
 
int TC_INSERT_ENTRY (const IPT_CHAINLABEL chain, const STRUCT_ENTRY *e, unsigned int rulenum, struct xtc_handle *handle)
 
int TC_REPLACE_ENTRY (const IPT_CHAINLABEL chain, const STRUCT_ENTRY *e, unsigned int rulenum, struct xtc_handle *handle)
 
int TC_APPEND_ENTRY (const IPT_CHAINLABEL chain, const STRUCT_ENTRY *e, struct xtc_handle *handle)
 
int TC_CHECK_ENTRY (const IPT_CHAINLABEL chain, const STRUCT_ENTRY *origfw, unsigned char *matchmask, struct xtc_handle *handle)
 
int TC_DELETE_ENTRY (const IPT_CHAINLABEL chain, const STRUCT_ENTRY *origfw, unsigned char *matchmask, struct xtc_handle *handle)
 
int TC_DELETE_NUM_ENTRY (const IPT_CHAINLABEL chain, unsigned int rulenum, struct xtc_handle *handle)
 
int TC_FLUSH_ENTRIES (const IPT_CHAINLABEL chain, struct xtc_handle *handle)
 
int TC_ZERO_ENTRIES (const IPT_CHAINLABEL chain, struct xtc_handle *handle)
 
STRUCT_COUNTERSTC_READ_COUNTER (const IPT_CHAINLABEL chain, unsigned int rulenum, struct xtc_handle *handle)
 
int TC_ZERO_COUNTER (const IPT_CHAINLABEL chain, unsigned int rulenum, struct xtc_handle *handle)
 
int TC_SET_COUNTER (const IPT_CHAINLABEL chain, unsigned int rulenum, STRUCT_COUNTERS *counters, struct xtc_handle *handle)
 
int TC_CREATE_CHAIN (const IPT_CHAINLABEL chain, struct xtc_handle *handle)
 
int TC_GET_REFERENCES (unsigned int *ref, const IPT_CHAINLABEL chain, struct xtc_handle *handle)
 
int TC_DELETE_CHAIN (const IPT_CHAINLABEL chain, struct xtc_handle *handle)
 
int TC_RENAME_CHAIN (const IPT_CHAINLABEL oldname, const IPT_CHAINLABEL newname, struct xtc_handle *handle)
 
int TC_SET_POLICY (const IPT_CHAINLABEL chain, const IPT_CHAINLABEL policy, STRUCT_COUNTERS *counters, struct xtc_handle *handle)
 
int TC_COMMIT (struct xtc_handle *handle)
 
const char * TC_STRERROR (int err)
 

Variables

const struct xtc_ops TC_OPS
 

Macro Definition Documentation

#define CHAIN_INDEX_BUCKET_LEN   40

Referenced by TC_CREATE_CHAIN().

#define CHAIN_INDEX_INSERT_MAX   355

Referenced by TC_CREATE_CHAIN().

#define debug (   x,
  args... 
)

Referenced by TC_CREATE_CHAIN().

#define DEBUGP_C (   x,
  args... 
)

Referenced by TC_FIRST_RULE(), and TC_NEXT_RULE().

#define IPTCB_CHAIN_ERROR_SIZE
Value:
(sizeof(STRUCT_ENTRY) + \
ALIGN(sizeof(struct xt_error_target)))
Definition: x_tables.h:69
#define STRUCT_ENTRY
Definition: libarptc.c:36
#define ALIGN
Definition: libarptc.c:103
#define IPTCB_CHAIN_FOOT_SIZE
Value:
(sizeof(STRUCT_ENTRY) + \
#define STRUCT_ENTRY
Definition: libarptc.c:36
#define STRUCT_STANDARD_TARGET
Definition: libarptc.c:42
#define ALIGN
Definition: libarptc.c:103
#define IPTCB_CHAIN_START_SIZE
Value:
(sizeof(STRUCT_ENTRY) + \
ALIGN(sizeof(struct xt_error_target)))
Definition: x_tables.h:69
#define STRUCT_ENTRY
Definition: libarptc.c:36
#define ALIGN
Definition: libarptc.c:103

Enumeration Type Documentation

Enumerator
BSEARCH_NAME 
BSEARCH_OFFSET 
Enumerator
IPTCC_R_STANDARD 
IPTCC_R_MODULE 
IPTCC_R_FALLTHROUGH 
IPTCC_R_JUMP 

Function Documentation

int TC_BUILTIN ( const char *  chain,
struct xtc_handle *const  handle 
)

Referenced by TC_DELETE_CHAIN(), and TC_RENAME_CHAIN().

Here is the caller graph for this function:

int TC_CHECK_ENTRY ( const IPT_CHAINLABEL  chain,
const STRUCT_ENTRY origfw,
unsigned char *  matchmask,
struct xtc_handle handle 
)
int TC_CREATE_CHAIN ( const IPT_CHAINLABEL  chain,
struct xtc_handle handle 
)
int TC_DELETE_CHAIN ( const IPT_CHAINLABEL  chain,
struct xtc_handle handle 
)

References xtc_handle::chain_iterator_cur, DEBUGP, xtc_handle::num_chains, chain_head::num_rules, chain_head::references, TC_BUILTIN(), and TC_GET_REFERENCES().

Referenced by TC_STRERROR().

Here is the call graph for this function:

Here is the caller graph for this function:

int TC_DELETE_ENTRY ( const IPT_CHAINLABEL  chain,
const STRUCT_ENTRY origfw,
unsigned char *  matchmask,
struct xtc_handle handle 
)

Referenced by TC_STRERROR().

Here is the caller graph for this function:

int TC_DELETE_NUM_ENTRY ( const IPT_CHAINLABEL  chain,
unsigned int  rulenum,
struct xtc_handle handle 
)

References rule_head::list, list_entry, chain_head::num_rules, list_head::prev, and xtc_handle::rule_iterator_cur.

Referenced by TC_STRERROR().

Here is the caller graph for this function:

void TC_DUMP_ENTRIES ( struct xtc_handle *const  handle)

References CHECK, dump_entry(), xtc_handle::entries, ENTRY_ITERATE, HOOK_FORWARD, HOOK_LOCAL_IN, HOOK_LOCAL_OUT, HOOK_POST_ROUTING, HOOK_PRE_ROUTING, and xtc_handle::info.

Referenced by TC_COMMIT().

Here is the call graph for this function:

Here is the caller graph for this function:

int TC_FLUSH_ENTRIES ( const IPT_CHAINLABEL  chain,
struct xtc_handle handle 
)
void TC_FREE ( struct xtc_handle h)
const char* TC_GET_POLICY ( const char *  chain,
STRUCT_COUNTERS counters,
struct xtc_handle handle 
)
int TC_GET_REFERENCES ( unsigned int *  ref,
const IPT_CHAINLABEL  chain,
struct xtc_handle handle 
)

References chain_head::references.

Referenced by TC_DELETE_CHAIN().

Here is the caller graph for this function:

const char* TC_GET_TARGET ( const STRUCT_ENTRY ce,
struct xtc_handle handle 
)
struct xtc_handle* TC_INIT ( const char *  tablename)

References CHECK, DEBUGP, xtc_handle::entries, error, info, xtc_handle::info, NULL, s, SO_GET_ENTRIES, SO_GET_INFO, sockfd, xtc_handle::sockfd, STRUCT_GET_ENTRIES, STRUCT_GETINFO, TABLE_MAXNAMELEN, TC_AF, TC_FREE(), and TC_IPPROTO.

Referenced by TC_STRERROR().

Here is the call graph for this function:

Here is the caller graph for this function:

int TC_INSERT_ENTRY ( const IPT_CHAINLABEL  chain,
const STRUCT_ENTRY e,
unsigned int  rulenum,
struct xtc_handle handle 
)
int TC_IS_CHAIN ( const char *  chain,
struct xtc_handle *const  handle 
)

References NULL.

const char* TC_NEXT_CHAIN ( struct xtc_handle handle)
STRUCT_COUNTERS* TC_READ_COUNTER ( const IPT_CHAINLABEL  chain,
unsigned int  rulenum,
struct xtc_handle handle 
)

References CHECK, rule_head::entry, and NULL.

Referenced by TC_STRERROR().

Here is the caller graph for this function:

int TC_RENAME_CHAIN ( const IPT_CHAINLABEL  oldname,
const IPT_CHAINLABEL  newname,
struct xtc_handle handle 
)

References IPT_CHAINLABEL, LABEL_ACCEPT, LABEL_DROP, LABEL_QUEUE, LABEL_RETURN, chain_head::name, and TC_BUILTIN().

Here is the call graph for this function:

int TC_REPLACE_ENTRY ( const IPT_CHAINLABEL  chain,
const STRUCT_ENTRY e,
unsigned int  rulenum,
struct xtc_handle handle 
)

References rule_head::counter_map, rule_head::entry, rule_head::list, counter_map::maptype, and chain_head::num_rules.

Referenced by TC_STRERROR().

Here is the caller graph for this function:

int TC_SET_COUNTER ( const IPT_CHAINLABEL  chain,
unsigned int  rulenum,
STRUCT_COUNTERS counters,
struct xtc_handle handle 
)
int TC_SET_POLICY ( const IPT_CHAINLABEL  chain,
const IPT_CHAINLABEL  policy,
STRUCT_COUNTERS counters,
struct xtc_handle handle 
)
const char* TC_STRERROR ( int  err)
int TC_ZERO_COUNTER ( const IPT_CHAINLABEL  chain,
unsigned int  rulenum,
struct xtc_handle handle 
)

References CHECK, rule_head::counter_map, and counter_map::maptype.

Referenced by TC_STRERROR().

Here is the caller graph for this function:

Variable Documentation

const struct xtc_ops TC_OPS
Initial value:
= {
.commit = TC_COMMIT,
.free = TC_FREE,
.builtin = TC_BUILTIN,
.is_chain = TC_IS_CHAIN,
.flush_entries = TC_FLUSH_ENTRIES,
.create_chain = TC_CREATE_CHAIN,
.set_policy = TC_SET_POLICY,
.strerror = TC_STRERROR,
}
int TC_COMMIT(struct xtc_handle *handle)
Definition: libiptc.c:2518
int TC_IS_CHAIN(const char *chain, struct xtc_handle *const handle)
Definition: libiptc.c:1441
int TC_FLUSH_ENTRIES(const IPT_CHAINLABEL chain, struct xtc_handle *handle)
Definition: libiptc.c:2093
void TC_FREE(struct xtc_handle *h)
Definition: libiptc.c:1382
const char * TC_STRERROR(int err)
Definition: libiptc.c:2699
int TC_CREATE_CHAIN(const IPT_CHAINLABEL chain, struct xtc_handle *handle)
Definition: libiptc.c:2231
int TC_SET_POLICY(const IPT_CHAINLABEL chain, const IPT_CHAINLABEL policy, STRUCT_COUNTERS *counters, struct xtc_handle *handle)
Definition: libiptc.c:2408
int TC_BUILTIN(const char *chain, struct xtc_handle *const handle)
Definition: libiptc.c:1623