Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

# 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 "pf.h"`
`#include <pcap-namedb.h>`

Go to the source code of this file.

## Data Structures
struct | chunk
## Defines
#define | offsetof(s, e) ((size_t)&((s *)0)->e)
#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_ether_linktype (int)
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_wlanhostop (const u_char *, int)
block * | gen_ipfchostop (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_mac_multicast (int)
block * | gen_len (int, int)
block * | gen_msg_abbrev (int type)
char * | sdup (const char *s)
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.
int | pcap_compile_nopcap (int snaplen_arg, int linktype_arg, struct bpf_program *program, char *buf, int optimize, bpf_u_int32 mask)
| 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.
void | pcap_freecode (struct bpf_program *program)
| Frees a filter.
void | finish_parse (struct block *p)
void | gen_and (struct block *b0, struct block *b1)
void | gen_or (struct block *b0, struct block *b1)
void | gen_not (struct block *b)
block * | gen_gateway (u_char *eaddr, bpf_u_int32 **alist, int proto, int dir) const
block * | gen_proto_abbrev (int proto)
block * | gen_scode (const char *name, struct qual q)
block * | gen_mcode (const char *s1, const char *s2, int masklen, struct qual q)
block * | gen_ncode (const char *s, bpf_u_int32 v, struct qual q)
block * | gen_ecode (const u_char *eaddr, struct qual q)
void | sappend (struct slist *s0, struct slist *s1)
arth * | gen_load (int proto, struct arth *index, int size)
block * | gen_relation (int code, struct arth *a0, struct arth *a1, int reversed)
arth * | gen_loadlen ()
arth * | gen_loadi (int val)
arth * | gen_neg (struct arth *a)
arth * | gen_arth (int code, struct arth *a0, struct arth *a1)
block * | gen_greater (int n)
block * | gen_less (int n)
block * | gen_byteop (int op, int idx, int val)
block * | gen_broadcast (int proto)
block * | gen_multicast (int proto)
block * | gen_inbound (int dir)
block * | gen_pf_ifname (const char *ifname)
block * | gen_pf_ruleset (char *ruleset)
block * | gen_pf_rnr (int rnr)
block * | gen_pf_srnr (int srnr)
block * | gen_pf_reason (int reason)
block * | gen_pf_action (int action)
block * | gen_acode (const u_char *eaddr, struct qual q)
block * | gen_vlan (int vlan_num)
block * | gen_atmfield_code (int atmfield, bpf_u_int32 jvalue, bpf_u_int32 jtype, int reverse)
block * | gen_atmtype_abbrev (int type)
block * | gen_atmmulti_abbrev (int type)
## Variables
const char rcsid[] | _U_
jmp_buf | top_ctx
pcap_t * | bpf_pcap
u_int | orig_linktype = -1 orig_nl = -1 orig_nl_nosnap = -1
int | pcap_fddipad
block * | root
chunk | chunks [NCHUNKS]
int | cur_chunk
bpf_u_int32 | netmask
int | snaplen
int | no_optimize
u_int | off_mac
u_int | off_linktype
int | is_atm = 0
int | is_lane = 0
u_int | off_vpi
u_int | off_vci
u_int | off_proto
u_int | off_payload
u_int | off_nl
u_int | off_nl_nosnap
int | linktype
int | regused [BPF_MEMWORDS]
int | curreg
u_char | abroadcast [] = { 0x0 }

## Define Documentation

#define CHUNK0SIZE 1024

| Definition at line 140 of file gencode.c. Referenced by newchunk().

#define ETHERMTU 1500

| Definition at line 84 of file gencode.c. Referenced by gen_ether_linktype(), gen_linktype(), and gen_llc().

#define IPPROTO_AH 51

| Referenced by gen_proto_abbrev(), and gen_protochain().

#define IPPROTO_ESP 50

| Referenced by gen_proto_abbrev().

#define IPPROTO_IGMP 2

| Referenced by gen_proto_abbrev().

#define IPPROTO_IGRP 9

| Referenced by gen_proto_abbrev().

#define IPPROTO_NONE 59

| Referenced by gen_protochain().

#define IPPROTO_PIM 103

| Referenced by gen_proto_abbrev().

#define IPPROTO_SCTP 132

| Definition at line 87 of file gencode.c. Referenced by gen_ncode(), gen_port(), gen_proto_abbrev(), and gen_scode().

#define IPPROTO_VRRP 112

| Referenced by gen_proto_abbrev().

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

| Definition at line 94 of file gencode.c.

#define NCHUNKS 16

| Definition at line 139 of file gencode.c. Referenced by freechunks(), and newchunk().

#define offsetof | ( | s,
|  | e |  | ) | ((size_t)&((s *)0)->e)

| Definition at line 75 of file gencode.c. Referenced by gen_inbound(), gen_linktype(), gen_pf_action(), gen_pf_ifname(), gen_pf_reason(), gen_pf_rnr(), gen_pf_ruleset(), and gen_pf_srnr().

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

| Definition at line 1076 of file gencode.c. Referenced by gen_linktype(), pcap_open_offline(), sf_next_packet(), and swap_hdr().

## Function Documentation

int alloc_reg | ( | void |  | ) | `[static]`

| Definition at line 4641 of file gencode.c. References bpf_error(), curreg, and regused. Referenced by gen_arth(), gen_load(), gen_loadi(), gen_loadlen(), and gen_protochain().

void backpatch | ( | struct block * | ,
|  | struct block * |
| ) | `[static]`

| Definition at line 436 of file gencode.c. Referenced by finish_parse(), gen_and(), and gen_or().

void bpf_error | ( | const char * | fmt,
|  |  | ...
| ) |

| Definition at line 112 of file gencode.c. References bpf_pcap, PCAP_ERRBUF_SIZE, pcap_geterr(), and top_ctx. Referenced by alloc_reg(), gen_acode(), gen_atmfield_code(), gen_atmmulti_abbrev(), gen_atmtype_abbrev(), gen_broadcast(), gen_dnhostop(), gen_ecode(), gen_gateway(), gen_host(), gen_inbound(), gen_linktype(), gen_load(), gen_mcode(), gen_multicast(), gen_ncode(), gen_pf_action(), gen_pf_ifname(), gen_pf_reason(), gen_pf_rnr(), gen_pf_ruleset(), gen_pf_srnr(), gen_proto(), gen_proto_abbrev(), gen_protochain(), gen_scode(), gen_vlan(), init_linktype(), lookup_proto(), newchunk(), pcap_compile(), and syntax().

void finish_parse | ( | struct block * | p | ) |

| Definition at line 472 of file gencode.c. References backpatch(), gen_retblk(), root, and snaplen.

void free_reg | ( | int |  | ) | `[static]`

| Definition at line 4662 of file gencode.c. References regused. Referenced by gen_arth(), gen_load(), gen_protochain(), and gen_relation().

void freechunks | ( | void |  | ) | `[static]`

| Definition at line 245 of file gencode.c. References chunks, cur_chunk, chunk::m, and NCHUNKS. Referenced by pcap_compile().

struct block* gen_acode | ( | const u_char * | eaddr,
|  | struct qual | q
| ) |

| Definition at line 5188 of file gencode.c. References bpf_error(), gen_ahostop(), and linktype.

struct block * gen_ahostop | ( | const u_char * | ,
|  | int |
| ) | `[static]`

| Definition at line 5201 of file gencode.c. References gen_and(), gen_bcmp(), and gen_or(). Referenced by gen_acode(), gen_broadcast(), and gen_multicast().

void gen_and | ( | struct block * | b0,
|  | struct block * | b1
| ) |

| Definition at line 482 of file gencode.c. References backpatch(), and merge(). Referenced by gen_ahostop(), gen_atmmulti_abbrev(), gen_atmtype_abbrev(), gen_bcmp(), gen_broadcast(), gen_dnhostop(), gen_ecode(), gen_ehostop(), gen_ether_linktype(), gen_fhostop(), gen_gateway(), gen_hostop(), gen_ipfchostop(), gen_linktype(), gen_load(), gen_multicast(), gen_port(), gen_portop(), gen_proto(), gen_protochain(), gen_relation(), gen_scode(), gen_thostop(), gen_vlan(), and gen_wlanhostop().

struct arth* gen_arth | ( | int | code,
|  | struct arth * | a0,
|  | struct arth * | a1
| ) |

| Definition at line 4605 of file gencode.c. References alloc_reg(), free_reg(), new_stmt(), sappend(), xfer_to_a(), and xfer_to_x().

struct block* gen_atmfield_code | ( | int | atmfield,
|  | bpf_u_int32 | jvalue,
|  | bpf_u_int32 | jtype,
|  | int | reverse
| ) |

| Definition at line 5281 of file gencode.c. References bpf_error(), gen_ncmp(), is_atm, off_payload, off_proto, off_vci, and off_vpi. Referenced by gen_atmmulti_abbrev(), gen_atmtype_abbrev(), gen_linktype(), and gen_msg_abbrev().

struct block* gen_atmmulti_abbrev | ( | int | type | ) |

| Definition at line 5483 of file gencode.c. References bpf_error(), gen_and(), gen_atmfield_code(), gen_atmtype_abbrev(), gen_msg_abbrev(), gen_or(), and is_atm.

struct block* gen_atmtype_abbrev | ( | int | type | ) |

| Definition at line 5339 of file gencode.c. References bpf_error(), gen_and(), gen_atmfield_code(), is_atm, is_lane, off_linktype, off_mac, off_nl, off_nl_nosnap, and off_payload. Referenced by gen_atmmulti_abbrev().

struct block * gen_bcmp | ( | u_int | ,
|  | u_int | ,
|  | const u_char * |
| ) | `[static]`

| Definition at line 565 of file gencode.c. References bpf_int32, gen_and(), and gen_cmp(). Referenced by gen_ahostop(), gen_ehostop(), gen_fhostop(), gen_ipfchostop(), gen_pf_ifname(), gen_pf_ruleset(), gen_snap(), gen_thostop(), and gen_wlanhostop().

struct block* gen_broadcast | ( | int | proto | ) |

| Definition at line 4749 of file gencode.c. References abroadcast, bpf_error(), bpf_int32, bpf_u_int32, gen_ahostop(), gen_and(), gen_cmp(), gen_ehostop(), gen_fhostop(), gen_ipfchostop(), gen_linktype(), gen_mcmp(), gen_not(), gen_or(), gen_thostop(), gen_wlanhostop(), is_lane, linktype, netmask, and off_nl.

struct block* gen_byteop | ( | int | op,
|  | int | idx,
|  | int | val
| ) |

| Definition at line 4706 of file gencode.c. References bpf_int32, gen_cmp(), gen_not(), JMP, new_block(), and new_stmt().

struct block * gen_cmp | ( | u_int | ,
|  | u_int | ,
|  | bpf_int32 |
| ) | `[static]`

| Definition at line 512 of file gencode.c. References JMP, new_block(), and new_stmt(). Referenced by gen_bcmp(), gen_broadcast(), gen_byteop(), gen_dnhostop(), gen_ecode(), gen_ether_linktype(), gen_gateway(), gen_inbound(), gen_linktype(), gen_llc(), gen_mcmp(), gen_multicast(), gen_pf_action(), gen_pf_reason(), gen_pf_rnr(), gen_pf_srnr(), gen_portop(), gen_proto(), gen_scode(), and gen_vlan().

struct block * gen_cmp_gt | ( | u_int | ,
|  | u_int | ,
|  | bpf_int32 |
| ) | `[static]`

| Definition at line 530 of file gencode.c. References JMP, new_block(), and new_stmt(). Referenced by gen_ether_linktype().

struct block * gen_dnhostop | ( | bpf_u_int32 | ,
|  | int | ,
|  | u_int |
| ) | `[static]`

| Definition at line 2499 of file gencode.c. References bpf_error(), bpf_int32, gen_and(), gen_cmp(), gen_linktype(), gen_mcmp(), and gen_or(). Referenced by gen_host().

struct block* gen_ecode | ( | const u_char * | eaddr,
|  | struct qual | q
| ) |

| Definition at line 4317 of file gencode.c. References bpf_error(), gen_and(), gen_cmp(), gen_ehostop(), gen_fhostop(), gen_ipfchostop(), gen_not(), gen_thostop(), gen_wlanhostop(), is_lane, and linktype.

struct block * gen_ehostop | ( | const u_char * | ,
|  | int |
| ) | `[static]`

| Definition at line 2032 of file gencode.c. References gen_and(), gen_bcmp(), gen_or(), and off_mac. Referenced by gen_broadcast(), gen_ecode(), gen_gateway(), and gen_scode().

struct block * gen_ether_linktype | ( | int |  | ) | `[static]`

| Definition at line 1080 of file gencode.c. References bpf_int32, ETHERMTU, gen_and(), gen_cmp(), gen_cmp_gt(), gen_not(), gen_or(), gen_snap(), and off_linktype. Referenced by gen_linktype().

struct block * gen_false | ( | void |  | ) | `[inline, static]`

| Definition at line 1066 of file gencode.c. References gen_uncond(). Referenced by gen_linktype().

struct block * gen_fhostop | ( | const u_char * | ,
|  | int |
| ) | `[static]`

| Definition at line 2066 of file gencode.c. References gen_and(), gen_bcmp(), gen_or(), and pcap_fddipad. Referenced by gen_broadcast(), gen_ecode(), gen_gateway(), and gen_scode().

struct block* gen_gateway | ( | u_char * | eaddr,
|  | bpf_u_int32 ** | alist,
|  | int | proto,
|  | int | dir
| ) | const`[static]`

| Definition at line 2800 of file gencode.c. References bpf_error(), gen_and(), gen_cmp(), gen_ehostop(), gen_fhostop(), gen_host(), gen_ipfchostop(), gen_not(), gen_or(), gen_thostop(), gen_wlanhostop(), is_lane, and linktype. Referenced by gen_scode().

struct block* gen_gateway | ( | const u_char * | ,
|  | bpf_u_int32 ** | ,
|  | int | ,
|  | int |
| ) | `[static]`

struct block* gen_greater | ( | int | n | ) |

| Definition at line 4684 of file gencode.c. References gen_len().

struct block * gen_host | ( | bpf_u_int32 | ,
|  | bpf_u_int32 | ,
|  | int | ,
|  | int |
| ) | `[static]`

| Definition at line 2572 of file gencode.c. References bpf_error(), gen_dnhostop(), gen_hostop(), gen_or(), off_linktype, and off_nl. Referenced by gen_gateway(), gen_mcode(), gen_ncode(), and gen_scode().

struct block * gen_hostop | ( | bpf_u_int32 | ,
|  | bpf_u_int32 | ,
|  | int | ,
|  | int | ,
|  | u_int | ,
|  | u_int |
| ) | `[static]`

| Definition at line 1936 of file gencode.c. References bpf_int32, gen_and(), gen_linktype(), gen_mcmp(), and gen_or(). Referenced by gen_host().

struct block* gen_inbound | ( | int | dir | ) |

| Definition at line 5026 of file gencode.c. References bpf_error(), bpf_int32, gen_cmp(), gen_load(), gen_loadi(), gen_relation(), linktype, and offsetof.

struct block * gen_ipfchostop | ( | const u_char * | ,
|  | int |
| ) | `[static]`

| Definition at line 2450 of file gencode.c. References gen_and(), gen_bcmp(), and gen_or(). Referenced by gen_broadcast(), gen_ecode(), gen_gateway(), and gen_scode().

struct block * gen_ipfrag | ( | void |  | ) | `[static]`

| Definition at line 3104 of file gencode.c. References gen_not(), JMP, new_block(), new_stmt(), and off_nl. Referenced by gen_load(), and gen_portop().

struct block * gen_len | ( | int | ,
|  | int |
| ) | `[static]`

| Definition at line 4669 of file gencode.c. References JMP, new_block(), and new_stmt(). Referenced by gen_greater(), and gen_less().

struct block* gen_less | ( | int | n | ) |

| Definition at line 4694 of file gencode.c. References gen_len(), and gen_not().

struct block * gen_linktype | ( | int |  | ) | `[static]`

| Definition at line 1264 of file gencode.c. References bpf_error(), bpf_int32, bpf_pcap, ETHERMTU, gen_and(), gen_atmfield_code(), gen_cmp(), gen_ether_linktype(), gen_false(), gen_llc(), gen_not(), gen_or(), gen_snap(), gen_true(), is_lane, linktype, off_linktype, offsetof, and SWAPLONG. Referenced by gen_broadcast(), gen_dnhostop(), gen_hostop(), gen_multicast(), gen_port(), gen_proto(), gen_proto_abbrev(), and gen_protochain().

struct block * gen_llc | ( | int |  | ) | `[static]`

| Definition at line 1859 of file gencode.c. References bpf_int32, ETHERMTU, gen_cmp(), gen_snap(), and off_linktype. Referenced by gen_linktype().

struct arth* gen_load | ( | int | proto,
|  | struct arth * | index,
|  | int | size
| ) |

| Definition at line 4392 of file gencode.c. References alloc_reg(), bpf_error(), free_reg(), gen_and(), gen_ipfrag(), gen_proto_abbrev(), new_stmt(), off_nl, sappend(), xfer_to_a(), and xfer_to_x(). Referenced by gen_inbound().

struct arth* gen_loadi | ( | int | val | ) |

| Definition at line 4565 of file gencode.c. References alloc_reg(), new_stmt(), and newchunk(). Referenced by gen_inbound().

struct arth* gen_loadlen | ( |  | ) |

| Definition at line 4549 of file gencode.c. References alloc_reg(), new_stmt(), and newchunk().

struct block * gen_mac_multicast | ( | int |  | ) | `[static]`

| Definition at line 4809 of file gencode.c. References JMP, new_block(), and new_stmt(). Referenced by gen_multicast().

struct block * gen_mcmp | ( | u_int | ,
|  | u_int | ,
|  | bpf_int32 | ,
|  | bpf_u_int32 |
| ) | `[static]`

| Definition at line 548 of file gencode.c. References gen_cmp(), and new_stmt(). Referenced by gen_broadcast(), gen_dnhostop(), gen_hostop(), and gen_vlan().

struct block* gen_mcode | ( | const char * | s1,
|  | const char * | s2,
|  | int | masklen,
|  | struct qual | q
| ) |

| Definition at line 4130 of file gencode.c. References bpf_error(), bpf_u_int32, and gen_host().

struct block * gen_msg_abbrev | ( | int | type | ) | `[static]`

| Definition at line 5441 of file gencode.c. References gen_atmfield_code(). Referenced by gen_atmmulti_abbrev().

struct block* gen_multicast | ( | int | proto | ) |

| Definition at line 4825 of file gencode.c. References abroadcast, bpf_error(), bpf_int32, gen_ahostop(), gen_and(), gen_cmp(), gen_linktype(), gen_mac_multicast(), gen_not(), gen_or(), is_lane, JMP, linktype, new_block(), new_stmt(), off_mac, and off_nl.

struct block * gen_ncmp | ( | bpf_u_int32 | ,
|  | bpf_u_int32 | ,
|  | bpf_u_int32 | ,
|  | bpf_u_int32 | ,
|  | bpf_u_int32 | ,
|  | int |
| ) | `[static]`

| Definition at line 603 of file gencode.c. References gen_not(), JMP, new_block(), and new_stmt(). Referenced by gen_atmfield_code().

struct block* gen_ncode | ( | const char * | s,
|  | bpf_u_int32 | v,
|  | struct qual | q
| ) |

| Definition at line 4171 of file gencode.c. References bpf_error(), bpf_u_int32, gen_host(), gen_or(), gen_port(), gen_proto(), gen_protochain(), IPPROTO_SCTP, and syntax().

struct arth* gen_neg | ( | struct arth * | a | ) |

| Definition at line 4587 of file gencode.c. References new_stmt(), sappend(), and xfer_to_a().

void gen_not | ( | struct block * | b | ) |

| Definition at line 505 of file gencode.c. Referenced by gen_broadcast(), gen_byteop(), gen_ecode(), gen_ether_linktype(), gen_gateway(), gen_ipfrag(), gen_less(), gen_linktype(), gen_multicast(), gen_ncmp(), gen_relation(), gen_scode(), and gen_wlanhostop().

void gen_or | ( | struct block * | b0,
|  | struct block * | b1
| ) |

| Definition at line 494 of file gencode.c. References backpatch(), and merge(). Referenced by gen_ahostop(), gen_atmmulti_abbrev(), gen_broadcast(), gen_dnhostop(), gen_ehostop(), gen_ether_linktype(), gen_fhostop(), gen_gateway(), gen_host(), gen_hostop(), gen_ipfchostop(), gen_linktype(), gen_multicast(), gen_ncode(), gen_port(), gen_portop(), gen_proto(), gen_proto_abbrev(), gen_protochain(), gen_scode(), gen_thostop(), and gen_wlanhostop().

struct block* gen_pf_action | ( | int | action | ) |

| Definition at line 5172 of file gencode.c. References bpf_error(), bpf_int32, gen_cmp(), linktype, and offsetof.

struct block* gen_pf_ifname | ( | const char * | ifname | ) |

| Definition at line 5079 of file gencode.c. References bpf_error(), gen_bcmp(), linktype, and offsetof.

struct block* gen_pf_reason | ( | int | reason | ) |

| Definition at line 5155 of file gencode.c. References bpf_error(), bpf_int32, gen_cmp(), linktype, and offsetof.

struct block* gen_pf_rnr | ( | int | rnr | ) |

| Definition at line 5122 of file gencode.c. References bpf_error(), bpf_int32, gen_cmp(), linktype, and offsetof.

struct block* gen_pf_ruleset | ( | char * | ruleset | ) |

| Definition at line 5102 of file gencode.c. References bpf_error(), gen_bcmp(), linktype, and offsetof.

struct block* gen_pf_srnr | ( | int | srnr | ) |

| Definition at line 5139 of file gencode.c. References bpf_error(), bpf_int32, gen_cmp(), linktype, and offsetof.

struct block * gen_port | ( | int | ,
|  | int | ,
|  | int |
| ) | `[static]`

| Definition at line 3193 of file gencode.c. References gen_and(), gen_linktype(), gen_or(), gen_portop(), IPPROTO_SCTP, and port. Referenced by gen_ncode(), and gen_scode().

struct block * gen_portatom | ( | int | ,
|  | bpf_int32 |
| ) | `[static]`

| Definition at line 3121 of file gencode.c. References JMP, new_block(), new_stmt(), and off_nl. Referenced by gen_portop().

struct block * gen_portop | ( | int | ,
|  | int | ,
|  | int |
| ) |

| Definition at line 3152 of file gencode.c. References bpf_int32, gen_and(), gen_cmp(), gen_ipfrag(), gen_or(), gen_portatom(), off_nl, and port. Referenced by gen_port().

struct block * gen_proto | ( | int | ,
|  | int | ,
|  | int |
| ) | `[static]`

| Definition at line 3660 of file gencode.c. References bpf_error(), bpf_int32, gen_and(), gen_cmp(), gen_linktype(), gen_or(), gen_protochain(), linktype, off_nl, and off_nl_nosnap. Referenced by gen_ncode(), gen_proto_abbrev(), gen_protochain(), and gen_scode().

struct block* gen_proto_abbrev | ( | int | proto | ) |

| Definition at line 2860 of file gencode.c. References bpf_error(), gen_linktype(), gen_or(), gen_proto(), IPPROTO_AH, IPPROTO_ESP, IPPROTO_IGMP, IPPROTO_IGRP, IPPROTO_PIM, IPPROTO_SCTP, and IPPROTO_VRRP. Referenced by gen_load().

struct block * gen_protochain | ( | int | ,
|  | int | ,
|  | int |
| ) | `[static]`

| Definition at line 3368 of file gencode.c. References alloc_reg(), bpf_error(), free_reg(), gen_and(), gen_linktype(), gen_or(), gen_proto(), IPPROTO_AH, IPPROTO_NONE, JMP, new_block(), new_stmt(), no_optimize, and off_nl. Referenced by gen_ncode(), gen_proto(), and gen_scode().

struct block* gen_relation | ( | int | code,
|  | struct arth * | a0,
|  | struct arth * | a1,
|  | int | reversed
| ) |

| Definition at line 4503 of file gencode.c. References free_reg(), gen_and(), gen_not(), JMP, new_block(), new_stmt(), sappend(), xfer_to_a(), and xfer_to_x(). Referenced by gen_inbound().

struct block * gen_retblk | ( | int |  | ) | `[static]`

| Definition at line 297 of file gencode.c. References new_block(). Referenced by finish_parse(), and pcap_compile().

struct block* gen_scode | ( | const char * | name,
|  | struct qual | q
| ) |

| Definition at line 3863 of file gencode.c. References bpf_error(), bpf_u_int32, gen_and(), gen_cmp(), gen_ehostop(), gen_fhostop(), gen_gateway(), gen_host(), gen_ipfchostop(), gen_not(), gen_or(), gen_port(), gen_proto(), gen_protochain(), gen_thostop(), gen_wlanhostop(), IPPROTO_SCTP, is_lane, linktype, lookup_proto(), off_linktype, port, and syntax().

struct block * gen_snap | ( | bpf_u_int32 | ,
|  | bpf_u_int32 | ,
|  | u_int |
| ) | `[static]`

| Definition at line 1837 of file gencode.c. References gen_bcmp(). Referenced by gen_ether_linktype(), gen_linktype(), and gen_llc().

struct block * gen_thostop | ( | const u_char * | ,
|  | int |
| ) | `[static]`

| Definition at line 2108 of file gencode.c. References gen_and(), gen_bcmp(), and gen_or(). Referenced by gen_broadcast(), gen_ecode(), gen_gateway(), and gen_scode().

struct block * gen_true | ( | void |  | ) | `[inline, static]`

| Definition at line 1060 of file gencode.c. References gen_uncond(). Referenced by gen_linktype().

struct block * gen_uncond | ( | int |  | ) | `[static]`

| Definition at line 1045 of file gencode.c. References JMP, new_block(), and new_stmt(). Referenced by gen_false(), and gen_true().

struct block* gen_vlan | ( | int | vlan_num | ) |

| Definition at line 5236 of file gencode.c. References bpf_error(), bpf_int32, gen_and(), gen_cmp(), gen_mcmp(), linktype, off_linktype, off_nl, off_nl_nosnap, and orig_linktype.

struct block * gen_wlanhostop | ( | const u_char * | ,
|  | int |
| ) | `[static]`

| Definition at line 2142 of file gencode.c. References gen_and(), gen_bcmp(), gen_not(), gen_or(), JMP, new_block(), and new_stmt(). Referenced by gen_broadcast(), gen_ecode(), gen_gateway(), and gen_scode().

void init_linktype | ( | int |  | ) | `[static]`

| Definition at line 710 of file gencode.c. References bpf_error(), is_atm, is_lane, linktype, off_linktype, off_mac, off_nl, off_nl_nosnap, off_payload, off_proto, off_vci, off_vpi, orig_linktype, and pcap_fddipad. Referenced by pcap_compile().

int lookup_proto | ( | const char * | ,
|  | int |
| ) | `[static]`

| Definition at line 3316 of file gencode.c. References bpf_error(). Referenced by gen_scode().

void merge | ( | struct block * | ,
|  | struct block * |
| ) | `[static]`

| Definition at line 458 of file gencode.c. Referenced by gen_and(), and gen_or().

struct block * new_block | ( | int |  | ) | `[inline, static]`

| Definition at line 272 of file gencode.c. References newchunk(). Referenced by gen_byteop(), gen_cmp(), gen_cmp_gt(), gen_ipfrag(), gen_len(), gen_mac_multicast(), gen_multicast(), gen_ncmp(), gen_portatom(), gen_protochain(), gen_relation(), gen_retblk(), gen_uncond(), and gen_wlanhostop().

struct slist * new_stmt | ( | int |  | ) | `[inline, static]`

| Definition at line 285 of file gencode.c. References newchunk(). Referenced by gen_arth(), gen_byteop(), gen_cmp(), gen_cmp_gt(), gen_ipfrag(), gen_len(), gen_load(), gen_loadi(), gen_loadlen(), gen_mac_multicast(), gen_mcmp(), gen_multicast(), gen_ncmp(), gen_neg(), gen_portatom(), gen_protochain(), gen_relation(), gen_uncond(), gen_wlanhostop(), xfer_to_a(), and xfer_to_x().

void * newchunk | ( | u_int |  | ) | `[static]`

| Definition at line 211 of file gencode.c. References bpf_error(), CHUNK0SIZE, chunks, cur_chunk, and NCHUNKS. Referenced by gen_loadi(), gen_loadlen(), new_block(), new_stmt(), and sdup().

void sappend | ( | struct slist * | s0,
|  | struct slist * | s1
| ) |

| Definition at line 4357 of file gencode.c. Referenced by gen_arth(), gen_load(), gen_neg(), and gen_relation().

char* sdup | ( | const char * | s | ) |

| Definition at line 261 of file gencode.c. References newchunk().

void syntax | ( | void |  | ) | `[inline, static]`

| Definition at line 307 of file gencode.c. References bpf_error(). Referenced by gen_ncode(), gen_scode(), and pcap_compile().

struct slist * xfer_to_a | ( | struct arth * |  | ) | `[static]`

| Definition at line 4381 of file gencode.c. References new_stmt(). Referenced by gen_arth(), gen_load(), gen_neg(), and gen_relation().

struct slist * xfer_to_x | ( | struct arth * |  | ) | `[static]`

| Definition at line 4370 of file gencode.c. References new_stmt(). Referenced by gen_arth(), gen_load(), and gen_relation().

## Variable Documentation

const char rcsid [] _U_`[static]`

| Initial value:
        "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.193.2.9 2004/08/27 07:38:11 guy Exp $ (LBL)"
Definition at line 23 of file gencode.c.

u_char abroadcast[] = { 0x0 }`[static]`

| Definition at line 4746 of file gencode.c. Referenced by gen_broadcast(), and gen_multicast().

pcap_t* bpf_pcap`[static]`

| Definition at line 98 of file gencode.c. Referenced by bpf_error(), gen_linktype(), and pcap_compile().

struct chunk chunks[NCHUNKS]`[static]`

| Definition at line 146 of file gencode.c. Referenced by freechunks(), and newchunk().

int cur_chunk`[static]`

| Definition at line 147 of file gencode.c. Referenced by freechunks(), and newchunk().

int curreg`[static]`

| Definition at line 4635 of file gencode.c. Referenced by alloc_reg().

int is_atm = 0`[static]`

| Definition at line 661 of file gencode.c. Referenced by gen_atmfield_code(), gen_atmmulti_abbrev(), gen_atmtype_abbrev(), and init_linktype().

int is_lane = 0`[static]`

| Definition at line 667 of file gencode.c. Referenced by gen_atmtype_abbrev(), gen_broadcast(), gen_ecode(), gen_gateway(), gen_linktype(), gen_multicast(), gen_scode(), and init_linktype().

int linktype`[static]`

| Definition at line 707 of file gencode.c. Referenced by gen_acode(), gen_broadcast(), gen_ecode(), gen_gateway(), gen_inbound(), gen_linktype(), gen_multicast(), gen_pf_action(), gen_pf_ifname(), gen_pf_reason(), gen_pf_rnr(), gen_pf_ruleset(), gen_pf_srnr(), gen_proto(), gen_scode(), gen_vlan(), and init_linktype().

bpf_u_int32 netmask`[static]`

| Definition at line 312 of file gencode.c. Referenced by gen_broadcast(), and pcap_compile().

int no_optimize

| Definition at line 314 of file gencode.c. Referenced by gen_protochain(), and pcap_compile().

u_int off_linktype`[static]`

| Definition at line 656 of file gencode.c. Referenced by gen_atmtype_abbrev(), gen_ether_linktype(), gen_host(), gen_linktype(), gen_llc(), gen_scode(), gen_vlan(), and init_linktype().

u_int off_mac`[static]`

| Definition at line 635 of file gencode.c. Referenced by gen_atmtype_abbrev(), gen_ehostop(), gen_multicast(), and init_linktype().

u_int off_nl`[static]`

| Definition at line 704 of file gencode.c. Referenced by gen_atmtype_abbrev(), gen_broadcast(), gen_host(), gen_ipfrag(), gen_load(), gen_multicast(), gen_portatom(), gen_portop(), gen_proto(), gen_protochain(), gen_vlan(), and init_linktype().

u_int off_nl_nosnap`[static]`

| Definition at line 705 of file gencode.c. Referenced by gen_atmtype_abbrev(), gen_proto(), gen_vlan(), and init_linktype().

u_int off_payload`[static]`

| Definition at line 680 of file gencode.c. Referenced by gen_atmfield_code(), gen_atmtype_abbrev(), and init_linktype().

u_int off_proto`[static]`

| Definition at line 674 of file gencode.c. Referenced by gen_atmfield_code(), and init_linktype().

u_int off_vci`[static]`

| Definition at line 673 of file gencode.c. Referenced by gen_atmfield_code(), and init_linktype().

u_int off_vpi`[static]`

| Definition at line 672 of file gencode.c. Referenced by gen_atmfield_code(), and init_linktype().

u_int orig_linktype = -1 orig_nl = -1 orig_nl_nosnap = -1`[static]`

| Definition at line 101 of file gencode.c. Referenced by gen_vlan(), and init_linktype().

int pcap_fddipad

| Definition at line 107 of file gencode.c. Referenced by gen_fhostop(), init_linktype(), and pcap_open_offline().

int regused[BPF_MEMWORDS]`[static]`

| Definition at line 4634 of file gencode.c. Referenced by alloc_reg(), and free_reg().

struct block* root`[static]`

| Definition at line 131 of file gencode.c. Referenced by finish_parse(), and pcap_compile().

int snaplen`[static]`

| Definition at line 313 of file gencode.c. Referenced by finish_parse(), and pcap_compile().

jmp_buf top_ctx`[static]`

| Definition at line 97 of file gencode.c. Referenced by bpf_error(), and pcap_compile().

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