Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

fw-pktfilter.c File Reference

#include "config.h"
#include <iphlpapi.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dnet.h"

Go to the source code of this file.

Classes

struct  fw_handle

Defines

#define PKTFILTER_PIPE   "\\\\.\\pipe\\PktFltPipe"
#define MAX_RULE_LENGTH   256
#define FILTER_FAILURE   0
#define FILTER_SUCCESS   1
#define FILTER_MESSAGE   2

Functions

static int parse_addr (char *p, struct addr *a)
static int parse_portspec (char *str, uint16_t *ports)
static int parse_icmpspec (char *str, uint16_t *type, uint16_t *code)
static int parse_rule (char *str, struct fw_rule *rule)
static int format_rule (const struct fw_rule *rule, char *buf, int len)
static char * call_pipe (const char *msg, int len)
fw_tfw_open (void)
int fw_add (fw_t *f, const struct fw_rule *rule)
int fw_delete (fw_t *f, const struct fw_rule *rule)
int fw_loop (fw_t *f, fw_handler callback, void *arg)
fw_tfw_close (fw_t *f)

Variables

char * icmp_types []


Define Documentation

#define FILTER_FAILURE   0
 

Definition at line 25 of file fw-pktfilter.c.

Referenced by call_pipe().

#define FILTER_MESSAGE   2
 

Definition at line 27 of file fw-pktfilter.c.

Referenced by call_pipe().

#define FILTER_SUCCESS   1
 

Definition at line 26 of file fw-pktfilter.c.

Referenced by call_pipe().

#define MAX_RULE_LENGTH   256
 

Definition at line 23 of file fw-pktfilter.c.

Referenced by fw_add(), fw_delete(), and fw_loop().

#define PKTFILTER_PIPE   "\\\\.\\pipe\\PktFltPipe"
 

Definition at line 22 of file fw-pktfilter.c.

Referenced by call_pipe().


Function Documentation

static char* call_pipe const char *  msg,
int  len
[static]
 

Definition at line 278 of file fw-pktfilter.c.

References DWORD, FILTER_FAILURE, FILTER_MESSAGE, FILTER_SUCCESS, HANDLE, NULL, and PKTFILTER_PIPE.

Referenced by fw_add(), fw_delete(), and fw_loop().

static int format_rule const struct fw_rule rule,
char *  buf,
int  len
[static]
 

Definition at line 215 of file fw-pktfilter.c.

References addr_ntoa(), addr::addr_type, ADDR_TYPE_NONE, fw_rule::fw_device, fw_rule::fw_dir, FW_DIR_IN, fw_rule::fw_dport, fw_rule::fw_dst, fw_rule::fw_op, FW_OP_ALLOW, fw_rule::fw_proto, fw_rule::fw_sport, fw_rule::fw_src, IP_PROTO_ICMP, IP_PROTO_TCP, IP_PROTO_UDP, snprintf, strlcat(), and strlcpy.

Referenced by fw_add(), and fw_delete().

int fw_add fw_t f,
const struct fw_rule rule
 

Definition at line 355 of file fw-pktfilter.c.

References call_pipe(), format_rule(), MAX_RULE_LENGTH, and NULL.

Referenced by __pyx_f_4dnet_2fw_add(), and fw_main().

fw_t* fw_close fw_t f  ) 
 

Definition at line 437 of file fw-pktfilter.c.

References NULL.

Referenced by __pyx_f_4dnet_2fw___dealloc__(), fw_main(), fw_open(), and START_TEST().

int fw_delete fw_t f,
const struct fw_rule rule
 

Definition at line 369 of file fw-pktfilter.c.

References call_pipe(), errno, format_rule(), fw_rule::fw_device, MAX_RULE_LENGTH, memcmp(), NULL, parse_rule(), snprintf, and strsep().

Referenced by __pyx_f_4dnet_2fw_delete(), and fw_main().

int fw_loop fw_t f,
fw_handler  callback,
void *  arg
 

Definition at line 408 of file fw-pktfilter.c.

References call_pipe(), fw_handle::ifinfo, MAX_RULE_LENGTH, NULL, parse_rule(), snprintf, and strsep().

Referenced by __pyx_f_4dnet_2fw_loop(), and fw_main().

fw_t* fw_open void   ) 
 

Definition at line 316 of file fw-pktfilter.c.

References _IP_ADAPTER_INFO::AdapterName, _IP_ADAPTER_INFO::ComboIndex, GetAdaptersInfo(), _IP_ADAPTER_INFO::Next, NULL, and _IP_ADAPTER_INFO::Type.

Referenced by __pyx_f_4dnet_2fw___init__(), fw_main(), and START_TEST().

static int parse_addr char *  p,
struct addr a
[static]
 

Definition at line 58 of file fw-pktfilter.c.

References addr_aton.

Referenced by parse_rule().

static int parse_icmpspec char *  str,
uint16_t type,
uint16_t code
[static]
 

Definition at line 89 of file fw-pktfilter.c.

References icmp_types, NULL, strsep(), and strtol().

Referenced by parse_rule().

static int parse_portspec char *  str,
uint16_t ports
[static]
 

Definition at line 66 of file fw-pktfilter.c.

References strsep(), and TCP_PORT_MAX.

Referenced by parse_rule().

static int parse_rule char *  str,
struct fw_rule rule
[static]
 

Definition at line 125 of file fw-pktfilter.c.

References FW_DIR_IN, FW_DIR_OUT, FW_OP_ALLOW, FW_OP_BLOCK, IP_PROTO_ICMP, IP_PROTO_TCP, IP_PROTO_UDP, memset, NULL, parse_addr(), parse_icmpspec(), parse_portspec(), strlcpy, strsep(), and strstr().

Referenced by fw_delete(), and fw_loop().


Variable Documentation

char* icmp_types[]
 

Initial value:

 {
        "echorep",      
        "",             
        "",             
        "unreach",      
        "squench",      
        "redir",        
        "",             
        "",             
        "echo",         
        "router_adv",   
        "router_sol",   
        "timex",        
        "paramprob",    
        "timest",       
        "timestrep",    
        "inforeq",      
        "inforep",      
        "maskreq",      
        "maskrep",      
        NULL
}

Definition at line 29 of file fw-pktfilter.c.

Referenced by parse_icmpspec().


Generated on Sun May 14 14:51:22 2006 by  doxygen 1.4.2