Main Page   Modules   Data Structures   File List   Data Fields   Globals  

gencode.c File Reference

#include <pcap-stdinc.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <setjmp.h>
#include <stdarg.h>
#include "pcap-int.h"
#include "ethertype.h"
#include "nlpid.h"
#include "llc.h"
#include "gencode.h"
#include "atmuni31.h"
#include "sunatmpos.h"
#include "ppp.h"
#include "sll.h"
#include "arcnet.h"
#include <pcap-namedb.h>

Go to the source code of this file.

Data Structures

struct  chunk

Defines

#define ETHERMTU   1500
#define IPPROTO_SCTP   132
#define JMP(c)   ((c)|BPF_JMP|BPF_K)
#define NCHUNKS   16
#define CHUNK0SIZE   1024
#define SWAPLONG(y)   ((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
#define IPPROTO_IGMP   2
#define IPPROTO_IGRP   9
#define IPPROTO_PIM   103
#define IPPROTO_VRRP   112
#define IPPROTO_AH   51
#define IPPROTO_ESP   50
#define IPPROTO_NONE   59

Functions

void bpf_error (const char *fmt,...)
void init_linktype (int)
int alloc_reg (void)
void free_reg (int)
void * newchunk (u_int)
void freechunks (void)
block * new_block (int)
slist * new_stmt (int)
block * gen_retblk (int)
void syntax (void)
void backpatch (struct block *, struct block *)
void merge (struct block *, struct block *)
block * gen_cmp (u_int, u_int, bpf_int32)
block * gen_cmp_gt (u_int, u_int, bpf_int32)
block * gen_mcmp (u_int, u_int, bpf_int32, bpf_u_int32)
block * gen_bcmp (u_int, u_int, const u_char *)
block * gen_ncmp (bpf_u_int32, bpf_u_int32, bpf_u_int32, bpf_u_int32, bpf_u_int32, int)
block * gen_uncond (int)
block * gen_true (void)
block * gen_false (void)
block * gen_linktype (int)
block * gen_snap (bpf_u_int32, bpf_u_int32, u_int)
block * gen_llc (int)
block * gen_hostop (bpf_u_int32, bpf_u_int32, int, int, u_int, u_int)
block * gen_ahostop (const u_char *, int)
block * gen_ehostop (const u_char *, int)
block * gen_fhostop (const u_char *, int)
block * gen_thostop (const u_char *, int)
block * gen_dnhostop (bpf_u_int32, int, u_int)
block * gen_host (bpf_u_int32, bpf_u_int32, int, int)
block * gen_gateway (const u_char *, bpf_u_int32 **, int, int)
block * gen_ipfrag (void)
block * gen_portatom (int, bpf_int32)
block * gen_portop (int, int, int)
block * gen_port (int, int, int)
int lookup_proto (const char *, int)
block * gen_protochain (int, int, int)
block * gen_proto (int, int, int)
slist * xfer_to_x (struct arth *)
slist * xfer_to_a (struct arth *)
block * gen_len (int, int)
block * gen_msg_abbrev (int type)
void * newchunk (n) u_int n
int pcap_compile (pcap_t *p, struct bpf_program *program, char *buf, int optimize, bpf_u_int32 mask)
 Compiles a packet filter. Converts an high level filtering expression (see Filtering expression syntax) in a program that can be interpreted by the kernel-level filtering engine. More...

int pcap_compile_nopcap (int snaplen_arg, int linktype_arg, struct bpf_program *program, char *buf, int optimize, bpf_u_int32 mask)
  Deprecated, use pcap_open_dead() and pcap_compile() instead .
Compiles a packet filter without the need of opening an adapter. Converts an high level filtering expression (see Filtering expression syntax) in a program that can be interpreted by the kernel-level filtering engine.
More...


void pcap_freecode (struct bpf_program *program)
 Frees a filter. More...

void backpatch (list, target) struct block *list
void init_linktype (type) int type
void free_reg (n) int n
block * gen_broadcast (proto) int proto

Variables

const char rcsid []
jmp_buf top_ctx
pcap_tbpf_pcap
u_int orig_linktype = -1
u_int orig_nl = -1
u_int orig_nl_nosnap = -1
int pcap_fddipad
block * root
chunk chunks [NCHUNKS]
int cur_chunk
int snaplen
int no_optimize
void * target
b1
 size
bpf_int32 v
bpf_u_int32 mask
 offset
 jtype
 jvalue
int reverse
int is_atm = 0
u_int off_vpi
u_int off_vci
u_int off_proto
u_int off_msg_type
u_int off_nl
u_int off_nl_nosnap
int linktype
bpf_u_int32 ptype
int dir
int proto
u_int src_off
u_int dst_off
u_int base_off
bpf_u_int32 ** alist
int ip_proto
qual q
s2
register int masklen
s1
arth * index
arth * a0
arth * a1
int reversed
int curreg
 n
 idx
 val


Define Documentation

#define CHUNK0SIZE   1024
 

Definition at line 136 of file gencode.c.

#define ETHERMTU   1500
 

Definition at line 80 of file gencode.c.

#define IPPROTO_AH   51
 

#define IPPROTO_ESP   50
 

#define IPPROTO_IGMP   2
 

#define IPPROTO_IGRP   9
 

#define IPPROTO_NONE   59
 

#define IPPROTO_PIM   103
 

#define IPPROTO_SCTP   132
 

Definition at line 83 of file gencode.c.

#define IPPROTO_VRRP   112
 

#define JMP      ((c)|BPF_JMP|BPF_K)
 

Definition at line 90 of file gencode.c.

#define NCHUNKS   16
 

Definition at line 135 of file gencode.c.

#define SWAPLONG      ((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
 


Function Documentation

int alloc_reg void    [static]
 

Definition at line 3851 of file gencode.c.

References bpf_error, curreg, and n.

void backpatch list   ,
target   
[static]
 

void backpatch struct block *   ,
struct block *   
[static]
 

void bpf_error const char *    fmt,
...   
 

Definition at line 108 of file gencode.c.

References bpf_pcap, PCAP_ERRBUF_SIZE, pcap_geterr, and top_ctx.

Referenced by alloc_reg, and pcap_compile.

void free_reg n    [static]
 

void free_reg int    [static]
 

void freechunks void    [static]
 

Referenced by pcap_compile.

struct block* gen_ahostop const u_char *   ,
int   
[static]
 

struct block* gen_bcmp u_int   ,
u_int   ,
const u_char *   
[static]
 

struct block* gen_broadcast proto   
 

struct block* gen_cmp u_int   ,
u_int   ,
bpf_int32   
[static]
 

struct block* gen_cmp_gt u_int   ,
u_int   ,
bpf_int32   
[static]
 

struct block* gen_dnhostop bpf_u_int32   ,
int   ,
u_int   
[static]
 

struct block* gen_ehostop const u_char *   ,
int   
[static]
 

struct block* gen_false void    [inline, static]
 

struct block* gen_fhostop const u_char *   ,
int   
[static]
 

struct block* gen_gateway const u_char *   ,
bpf_u_int32 **   ,
int   ,
int   
[static]
 

struct block* gen_host bpf_u_int32   ,
bpf_u_int32   ,
int   ,
int   
[static]
 

struct block* gen_hostop bpf_u_int32   ,
bpf_u_int32   ,
int   ,
int   ,
u_int   ,
u_int   
[static]
 

struct block* gen_ipfrag void    [static]
 

struct block* gen_len int   ,
int   
[static]
 

struct block* gen_linktype int    [static]
 

struct block* gen_llc int    [static]
 

struct block* gen_mcmp u_int   ,
u_int   ,
bpf_int32   ,
bpf_u_int32   
[static]
 

struct block* gen_msg_abbrev int    type [static]
 

struct block* gen_ncmp bpf_u_int32   ,
bpf_u_int32   ,
bpf_u_int32   ,
bpf_u_int32   ,
bpf_u_int32   ,
int   
[static]
 

struct block* gen_port int   ,
int   ,
int   
[static]
 

struct block* gen_portatom int   ,
bpf_int32   
[static]
 

struct block* gen_portop int   ,
int   ,
int   
 

struct block* gen_proto int   ,
int   ,
int   
[static]
 

struct block* gen_protochain int   ,
int   ,
int   
[static]
 

struct block* gen_retblk int    [static]
 

Referenced by pcap_compile.

struct block* gen_snap bpf_u_int32   ,
bpf_u_int32   ,
u_int   
[static]
 

struct block* gen_thostop const u_char *   ,
int   
[static]
 

struct block* gen_true void    [inline, static]
 

struct block* gen_uncond int    [static]
 

void init_linktype type    [static]
 

Referenced by pcap_compile.

void init_linktype int    [static]
 

int lookup_proto const char *   ,
int   
[static]
 

void merge struct block *   ,
struct block *   
[static]
 

struct block* new_block int    [inline, static]
 

struct slist* new_stmt int    [inline, static]
 

void* newchunk n    [static]
 

void* newchunk u_int    [static]
 

void syntax void    [inline, static]
 

Referenced by pcap_compile.

struct slist* xfer_to_a struct arth *    [static]
 

struct slist* xfer_to_x struct arth *    [static]
 


Variable Documentation

struct arth * a0
 

Definition at line 3817 of file gencode.c.

struct arth * a1
 

Definition at line 3817 of file gencode.c.

bpf_u_int32** alist
 

Definition at line 2207 of file gencode.c.

* b1
 

Definition at line 455 of file gencode.c.

u_int base_off
 

Definition at line 1907 of file gencode.c.

pcap_t* bpf_pcap [static]
 

Definition at line 94 of file gencode.c.

Referenced by bpf_error, and pcap_compile.

struct chunk chunks[NCHUNKS] [static]
 

Definition at line 142 of file gencode.c.

int cur_chunk [static]
 

Definition at line 143 of file gencode.c.

int curreg [static]
 

Definition at line 3845 of file gencode.c.

Referenced by alloc_reg.

register int dir
 

Definition at line 4123 of file gencode.c.

u_int dst_off
 

Definition at line 1687 of file gencode.c.

idx
 

Definition at line 3917 of file gencode.c.

struct arth* index
 

Definition at line 3612 of file gencode.c.

int ip_proto
 

Definition at line 2524 of file gencode.c.

int is_atm = 0 [static]
 

Definition at line 615 of file gencode.c.

bpf_u_int32 jtype
 

Definition at line 4204 of file gencode.c.

bpf_u_int32 jvalue
 

Definition at line 4203 of file gencode.c.

int linktype [static]
 

Definition at line 654 of file gencode.c.

bpf_u_int32 mask
 

Definition at line 1979 of file gencode.c.

Referenced by pcap_compile, pcap_compile_nopcap, and pcap_setmode.

register int masklen
 

Definition at line 3372 of file gencode.c.

n
 

Definition at line 3880 of file gencode.c.

Referenced by alloc_reg.

int no_optimize
 

Definition at line 303 of file gencode.c.

Referenced by pcap_compile.

u_int off_msg_type [static]
 

Definition at line 627 of file gencode.c.

u_int off_nl [static]
 

Definition at line 651 of file gencode.c.

u_int off_nl_nosnap [static]
 

Definition at line 652 of file gencode.c.

u_int off_proto [static]
 

Definition at line 622 of file gencode.c.

u_int off_vci [static]
 

Definition at line 621 of file gencode.c.

u_int off_vpi [static]
 

Definition at line 620 of file gencode.c.

u_int offset
 

Definition at line 1591 of file gencode.c.

u_int orig_linktype = -1 [static]
 

Definition at line 97 of file gencode.c.

u_int orig_nl = -1 [static]
 

Definition at line 97 of file gencode.c.

u_int orig_nl_nosnap = -1 [static]
 

Definition at line 97 of file gencode.c.

int pcap_fddipad
 

Definition at line 103 of file gencode.c.

Referenced by pcap_open_offline.

int proto
 

Definition at line 2975 of file gencode.c.

bpf_u_int32 ptype
 

Definition at line 1590 of file gencode.c.

struct qual q
 

Definition at line 4110 of file gencode.c.

const char rcsid[] [static]
 

Initial value:

    "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.175 2002/08/06 07:35:46 guy Exp $ (LBL)"

Definition at line 23 of file gencode.c.

int reverse
 

Definition at line 4205 of file gencode.c.

int reversed
 

Definition at line 3716 of file gencode.c.

struct block* root [static]
 

Definition at line 127 of file gencode.c.

Referenced by pcap_compile.

* s1
 

Definition at line 3576 of file gencode.c.

* s2
 

Definition at line 3371 of file gencode.c.

int size
 

Definition at line 3613 of file gencode.c.

Referenced by pcap_sendpacket, pcap_sendqueue_destroy, pcap_setmintocopy, pcap_setmode, and pcap_setuserbuffer.

int snaplen [static]
 

Definition at line 302 of file gencode.c.

Referenced by pcap_compile.

u_int src_off
 

Definition at line 1687 of file gencode.c.

void * target
 

Definition at line 397 of file gencode.c.

jmp_buf top_ctx [static]
 

Definition at line 93 of file gencode.c.

Referenced by bpf_error, and pcap_compile.

bpf_u_int32 v
 

Definition at line 3413 of file gencode.c.

val
 

Definition at line 3917 of file gencode.c.

Referenced by inet_addrU.


documentation. Copyright (c) 2002 Politecnico di Torino. All rights reserved.