IPnom Home • Manuals • FreeBSD

 FreeBSD Man Pages

Man Sections:Commands (1)System Calls (2)Library Functions (3)Device Drivers (4)File Formats (5)Miscellaneous (7)System Utilities (8)
Keyword Live Search (10 results max):
 Type in part of a command in the search box.
 
Index:
  CPU_ELAN(4)
  CPU_SOEKRIS(4)
  aac(4)
  acd(4)
  acpi(4)
  acpi_asus(4)
  acpi_panasonic(4)
  acpi_thermal(4)
  acpi_toshiba(4)
  acpi_video(4)
  ad(4)
  adv(4)
  adw(4)
  afd(4)
  agp(4)
  agpgart(4)
  aha(4)
  ahb(4)
  ahc(4)
  ahd(4)
  aic(4)
  aio(4)
  alpm(4)
  altq(4)
  amd(4)
  amdpm(4)
  amr(4)
  an(4)
  apm(4)
  ar(4)
  arcmsr(4)
  arl(4)
  arp(4)
  asr(4)
  ast(4)
  ata(4)
  atapicam(4)
  ath(4)
  ath_hal(4)
  atkbd(4)
  atkbdc(4)
  aue(4)
  awi(4)
  axe(4)
  bfe(4)
  bge(4)
  bktr(4)
  blackhole(4)
  bpf(4)
  bridge(4)
  brooktree(4)
  bt(4)
  cam(4)
  card(4)
  cardbus(4)
  carp(4)
  cbb(4)
  ccd(4)
  cd(4)
  cdce(4)
  ch(4)
  ciss(4)
  cm(4)
  cnw(4)
  cp(4)
  cpufreq(4)
  crypto(4)
  cryptodev(4)
  cs(4)
  ct(4)
  ctau(4)
  cue(4)
  cx(4)
  cy(4)
  da(4)
  dc(4)
  dcons(4)
  dcons_crom(4)
  ddb(4)
  de(4)
  devctl(4)
  digi(4)
  disc(4)
  divert(4)
  dpt(4)
  dummynet(4)
  ed(4)
  ef(4)
  ehci(4)
  el(4)
  em(4)
  en(4)
  ep(4)
  esp(4)
  ex(4)
  exca(4)
  faith(4)
  fast_ipsec(4)
  fatm(4)
  fd(4)
  fdc(4)
  fe(4)
  fea(4)
  firewire(4)
  fla(4)
  fpa(4)
  fwe(4)
  fwip(4)
  fwohci(4)
  fxp(4)
  gbde(4)
  gdb(4)
  gem(4)
  geom(4)
  gif(4)
  gre(4)
  gx(4)
  harp(4)
  hatm(4)
  hfa(4)
  hifn(4)
  hme(4)
  hptmv(4)
  i4b(4)
  i4bcapi(4)
  i4bctl(4)
  i4bing(4)
  i4bipr(4)
  i4bisppp(4)
  i4bq921(4)
  i4bq931(4)
  i4brbch(4)
  i4btel(4)
  i4btrc(4)
  iavc(4)
  ichsmb(4)
  ichwd(4)
  icmp(4)
  icmp6(4)
  ida(4)
  idt(4)
  ie(4)
  ieee80211(4)
  if_an(4)
  if_aue(4)
  if_awi(4)
  if_axe(4)
  if_bfe(4)
  if_bge(4)
  if_cue(4)
  if_dc(4)
  if_de(4)
  if_disc(4)
  if_ed(4)
  if_ef(4)
  if_em(4)
  if_en(4)
  if_faith(4)
  if_fatm(4)
  if_fwe(4)
  if_fwip(4)
  if_fxp(4)
  if_gem(4)
  if_gif(4)
  if_gre(4)
  if_gx(4)
  if_hatm(4)
  if_hme(4)
  if_idt(4)
  if_kue(4)
  if_lge(4)
  if_my(4)
  if_ndis(4)
  if_nge(4)
  if_oltr(4)
  if_patm(4)
  if_pcn(4)
  if_ppp(4)
  if_re(4)
  if_rl(4)
  if_rue(4)
  if_sbni(4)
  if_sbsh(4)
  if_sf(4)
  if_sis(4)
  if_sk(4)
  if_sl(4)
  if_sn(4)
  if_ste(4)
  if_stf(4)
  if_tap(4)
  if_ti(4)
  if_tl(4)
  if_tun(4)
  if_tx(4)
  if_txp(4)
  if_udav(4)
  if_vge(4)
  if_vlan(4)
  if_vr(4)
  if_wb(4)
  if_wi(4)
  if_xe(4)
  if_xl(4)
  ifmib(4)
  ifpi(4)
  ifpi2(4)
  ifpnp(4)
  ihfc(4)
  iic(4)
  iicbb(4)
  iicbus(4)
  iicsmb(4)
  iir(4)
  imm(4)
  inet(4)
  inet6(4)
  intpm(4)
  intro(4)
  io(4)
  ip(4)
  ip6(4)
  ipaccounting(4)
  ipacct(4)
  ipf(4)
  ipfirewall(4)
  ipfw(4)
  ipl(4)
  ipnat(4)
  ips(4)
  ipsec(4)
  isic(4)
  isp(4)
  ispfw(4)
  itjc(4)
  iwic(4)
  ixgb(4)
  joy(4)
  kame(4)
  keyboard(4)
  kld(4)
  kmem(4)
  ktr(4)
  kue(4)
  led(4)
  lge(4)
  linux(4)
  lnc(4)
  lo(4)
  longrun(4)
  loop(4)
  lp(4)
  lpbb(4)
  lpt(4)
  mac(4)
  mac_biba(4)
  mac_bsdextended(4)
  mac_ifoff(4)
  mac_lomac(4)
  mac_mls(4)
  mac_none(4)
  mac_partition(4)
  mac_portacl(4)
  mac_seeotheruids(4)
  mac_stub(4)
  mac_test(4)
  mcd(4)
  md(4)
  mem(4)
  meteor(4)
  miibus(4)
  mlx(4)
  mly(4)
  mouse(4)
  mpt(4)
  mse(4)
  mtio(4)
  multicast(4)
  my(4)
  natm(4)
  natmip(4)
  ncr(4)
  ncv(4)
  ndis(4)
  net(4)
  netgraph(4)
  netintro(4)
  networking(4)
  ng_UI(4)
  ng_async(4)
  ng_atm(4)
  ng_atmllc(4)
  ng_atmpif(4)
  ng_bluetooth(4)
  ng_bpf(4)
  ng_bridge(4)
  ng_bt3c(4)
  ng_btsocket(4)
  ng_ccatm(4)
  ng_cisco(4)
  ng_device(4)
  ng_echo(4)
  ng_eiface(4)
  ng_etf(4)
  ng_ether(4)
  ng_fec(4)
  ng_frame_relay(4)
  ng_gif(4)
  ng_gif_demux(4)
  ng_h4(4)
  ng_hci(4)
  ng_hole(4)
  ng_hub(4)
  ng_iface(4)
  ng_ip_input(4)
  ng_ksocket(4)
  ng_l2cap(4)
  ng_l2tp(4)
  ng_lmi(4)
  ng_mppc(4)
  ng_netflow(4)
  ng_one2many(4)
  ng_ppp(4)
  ng_pppoe(4)
  ng_pptpgre(4)
  ng_rfc1490(4)
  ng_socket(4)
  ng_split(4)
  ng_sppp(4)
  ng_sscfu(4)
  ng_sscop(4)
  ng_tee(4)
  ng_tty(4)
  ng_ubt(4)
  ng_uni(4)
  ng_vjc(4)
  ng_vlan(4)
  nge(4)
  nmdm(4)
  npx(4)
  nsp(4)
  null(4)
  ohci(4)
  oldcard(4)
  oltr(4)
  opie(4)
  orm(4)
  pae(4)
  pass(4)
  patm(4)
  pccard(4)
  pccbb(4)
  pcf(4)
  pci(4)
  pcic(4)
  pcm(4)
  pcn(4)
  pcvt(4)
  perfmon(4)
  pf(4)
  pflog(4)
  pfsync(4)
  pim(4)
  plip(4)
  pnp(4)
  pnpbios(4)
  polling(4)
  ppbus(4)
  ppc(4)
  ppi(4)
  ppp(4)
  psm(4)
  pst(4)
  pt(4)
  pty(4)
  puc(4)
  random(4)
  rawip(4)
  ray(4)
  rc(4)
  re(4)
  rl(4)
  rndtest(4)
  route(4)
  rp(4)
  rue(4)
  sa(4)
  sab(4)
  safe(4)
  sbni(4)
  sbp(4)
  sbp_targ(4)
  sbsh(4)
  sc(4)
  scbus(4)
  scd(4)
  sched_4bsd(4)
  sched_ule(4)
  screen(4)
  screensaver(4)
  scsi(4)
  sem(4)
  ses(4)
  sf(4)
  si(4)
  sio(4)
  sis(4)
  sk(4)
  skey(4)
  sl(4)
  smapi(4)
  smb(4)
  smbus(4)
  smp(4)
  sn(4)
  snc(4)
  snd(4)
  snd_ad1816(4)
  snd_als4000(4)
  snd_cmi(4)
  snd_cs4281(4)
  snd_csa(4)
  snd_ds1(4)
  snd_emu10k1(4)
  snd_es137x(4)
  snd_ess(4)
  snd_fm801(4)
  snd_gusc(4)
  snd_ich(4)
  snd_maestro(4)
  snd_maestro3(4)
  snd_neomagic(4)
  snd_sbc(4)
  snd_solo(4)
  snd_uaudio(4)
  snd_via8233(4)
  snd_via82c686(4)
  snd_vibes(4)
  snp(4)
  sound(4)
  speaker(4)
  spic(4)
  spkr(4)
  splash(4)
  sppp(4)
  sr(4)
  stderr(4)
  stdin(4)
  stdout(4)
  ste(4)
  stf(4)
  stg(4)
  streams(4)
  svr4(4)
  sym(4)
  syncache(4)
  syncer(4)
  syncookies(4)
  syscons(4)
  sysmouse(4)
  tap(4)
  targ(4)
  tcp(4)
  tdfx(4)
  termios(4)
  ti(4)
  tl(4)
  trm(4)
  ttcp(4)
  tty(4)
  tun(4)
  twa(4)
  twe(4)
  tx(4)
  txp(4)
  uart(4)
  ubsa(4)
  ubsec(4)
  ubser(4)
  ubtbcmfw(4)
  ucom(4)
  udav(4)
  udbp(4)
  udp(4)
  ufm(4)
  uftdi(4)
  ugen(4)
  uhci(4)
  uhid(4)
  uhidev(4)
  ukbd(4)
  ulpt(4)
  umass(4)
  umct(4)
  umodem(4)
  ums(4)
  unix(4)
  uplcom(4)
  urio(4)
  usb(4)
  uscanner(4)
  utopia(4)
  uvisor(4)
  uvscom(4)
  vga(4)
  vge(4)
  viapm(4)
  vinum(4)
  vinumdebug(4)
  vlan(4)
  vn(4)
  vpd(4)
  vpo(4)
  vr(4)
  vt(4)
  vx(4)
  watchdog(4)
  wb(4)
  wd(4)
  wdc(4)
  wi(4)
  witness(4)
  wl(4)
  wlan(4)
  worm(4)
  xe(4)
  xl(4)
  xpt(4)
  zero(4)

bpf(4)

NAME

     bpf -- Berkeley Packet Filter


SYNOPSIS

     device bpf


DESCRIPTION

     The Berkeley Packet Filter provides a raw interface to data link layers
     in a protocol independent fashion.  All packets on the network, even
     those destined for other hosts, are accessible through this mechanism.

     The packet filter appears as a character special device, /dev/bpf0,
     /dev/bpf1, etc.  After opening the device, the file descriptor must be
     bound to a specific network interface with the BIOCSETIF ioctl.  A given
     interface can be shared by multiple listeners, and the filter underlying
     each descriptor will see an identical packet stream.

     A separate device file is required for each minor device.	If a file is
     in use, the open will fail and errno will be set to EBUSY.

     Associated with each open instance of a bpf file is a user-settable
     packet filter.  Whenever a packet is received by an interface, all file
     descriptors listening on that interface apply their filter.  Each
     descriptor that accepts the packet receives its own copy.

     Reads from these files return the next group of packets that have matched
     the filter.  To improve performance, the buffer passed to read must be
     the same size as the buffers used internally by bpf.  This size is
     returned by the BIOCGBLEN ioctl (see below), and can be set with
     BIOCSBLEN.  Note that an individual packet larger than this size is nec-
     essarily truncated.

     The packet filter will support any link level protocol that has fixed
     length headers.  Currently, only Ethernet, SLIP, and PPP drivers have
     been modified to interact with bpf.

     Since packet data is in network byte order, applications should use the
     byteorder(3) macros to extract multi-byte values.

     A packet can be sent out on the network by writing to a bpf file descrip-
     tor.  The writes are unbuffered, meaning only one packet can be processed
     per write.  Currently, only writes to Ethernets and SLIP links are sup-
     ported.


IOCTLS

     The ioctl(2) command codes below are defined in <net/bpf.h>.  All com-
     mands require these includes:

	     #include <sys/types.h>
	     #include <sys/time.h>
	     #include <sys/ioctl.h>
	     #include <net/bpf.h>

     Additionally, BIOCGETIF and BIOCSETIF require <sys/socket.h> and
     <net/if.h>.

     In addition to FIONREAD and SIOCGIFADDR, the following commands may be
		    interface with BIOCSETIF.  If the requested buffer size
		    cannot be accommodated, the closest allowable size will be
		    set and returned in the argument.  A read call will result
		    in EIO if it is passed a buffer that is not this size.

     BIOCGDLT	    (u_int) Returns the type of the data link layer underlying
		    the attached interface.  EINVAL is returned if no inter-
		    face has been specified.  The device types, prefixed with
		    ``DLT_'', are defined in <net/bpf.h>.

     BIOCPROMISC    Forces the interface into promiscuous mode.  All packets,
		    not just those destined for the local host, are processed.
		    Since more than one file can be listening on a given
		    interface, a listener that opened its interface non-
		    promiscuously may receive packets promiscuously.  This
		    problem can be remedied with an appropriate filter.

     BIOCFLUSH	    Flushes the buffer of incoming packets, and resets the
		    statistics that are returned by BIOCGSTATS.

     BIOCGETIF	    (struct ifreq) Returns the name of the hardware interface
		    that the file is listening on.  The name is returned in
		    the ifr_name field of the ifreq structure.	All other
		    fields are undefined.

     BIOCSETIF	    (struct ifreq) Sets the hardware interface associate with
		    the file.  This command must be performed before any pack-
		    ets can be read.  The device is indicated by name using
		    the ifr_name field of the ifreq structure.	Additionally,
		    performs the actions of BIOCFLUSH.

     BIOCSRTIMEOUT

     BIOCGRTIMEOUT  (struct timeval) Set or get the read timeout parameter.
		    The argument specifies the length of time to wait before
		    timing out on a read request.  This parameter is initial-
		    ized to zero by open(2), indicating no timeout.

     BIOCGSTATS     (struct bpf_stat) Returns the following structure of
		    packet statistics:

		    struct bpf_stat {
			    u_int bs_recv;    /* number of packets received */
			    u_int bs_drop;    /* number of packets dropped */
		    };

		    The fields are:

			  bs_recv the number of packets received by the
				  descriptor since opened or reset (including
				  any buffered since the last read call); and

			  bs_drop the number of packets which were accepted by
				  the filter but dropped by the kernel because
				  of buffer overflows (i.e., the application's
				  reads aren't keeping up with the packet
				  traffic).

     BIOCSETF	    (struct bpf_program) Sets the filter program used by the
		    kernel to discard uninteresting packets.  An array of
		    instructions and its length is passed in using the follow-
		    ing structure:

		    struct bpf_program {
			    int bf_len;
			    struct bpf_insn *bf_insns;
		    };

		    The filter program is pointed to by the bf_insns field
		    while its length in units of `struct bpf_insn' is given by
		    the bf_len field.  Also, the actions of BIOCFLUSH are per-
		    formed.  See section FILTER MACHINE for an explanation of
		    the filter language.

     BIOCVERSION    (struct bpf_version) Returns the major and minor version
		    numbers of the filter language currently recognized by the
		    kernel.  Before installing a filter, applications must
		    check that the current version is compatible with the run-
		    ning kernel.  Version numbers are compatible if the major
		    numbers match and the application minor is less than or
		    equal to the kernel minor.	The kernel version number is
		    returned in the following structure:

		    struct bpf_version {
			    u_short bv_major;
			    u_short bv_minor;
		    };

		    The current version numbers are given by BPF_MAJOR_VERSION
		    and BPF_MINOR_VERSION from <net/bpf.h>.  An incompatible
		    filter may result in undefined behavior (most likely, an
		    error returned by ioctl() or haphazard packet matching).

     BIOCSHDRCMPLT

     BIOCGHDRCMPLT  (u_int) Set or get the status of the ``header complete''
		    flag.  Set to zero if the link level source address should
		    be filled in automatically by the interface output rou-
		    tine.  Set to one if the link level source address will be
		    written, as provided, to the wire.	This flag is initial-
		    ized to zero by default.

     BIOCSSEESENT

     BIOCGSEESENT   (u_int) Set or get the flag determining whether locally
		    generated packets on the interface should be returned by
		    BPF.  Set to zero to see only incoming packets on the
		    interface.	Set to one to see packets originating locally
		    and remotely on the interface.  This flag is initialized
		    to one by default.


BPF HEADER

     The following structure is prepended to each packet returned by read(2):

     struct bpf_hdr {
	     struct timeval bh_tstamp;	   /* time stamp */

     bh_tstamp	 The time at which the packet was processed by the packet fil-
		 ter.
     bh_caplen	 The length of the captured portion of the packet.  This is
		 the minimum of the truncation amount specified by the filter
		 and the length of the packet.
     bh_datalen  The length of the packet off the wire.  This value is inde-
		 pendent of the truncation amount specified by the filter.
     bh_hdrlen	 The length of the bpf header, which may not be equal to
		 sizeof(struct bpf_hdr).

     The bh_hdrlen field exists to account for padding between the header and
     the link level protocol.  The purpose here is to guarantee proper align-
     ment of the packet data structures, which is required on alignment sensi-
     tive architectures and improves performance on many other architectures.
     The packet filter insures that the bpf_hdr and the network layer header
     will be word aligned.  Suitable precautions must be taken when accessing
     the link layer protocol fields on alignment restricted machines.  (This
     isn't a problem on an Ethernet, since the type field is a short falling
     on an even offset, and the addresses are probably accessed in a bytewise
     fashion).

     Additionally, individual packets are padded so that each starts on a word
     boundary.	This requires that an application has some knowledge of how to
     get from packet to packet.  The macro BPF_WORDALIGN is defined in
     <net/bpf.h> to facilitate this process.  It rounds up its argument to the
     nearest word aligned value (where a word is BPF_ALIGNMENT bytes wide).

     For example, if `p' points to the start of a packet, this expression will
     advance it to the next packet:
	   p = (char *)p + BPF_WORDALIGN(p->bh_hdrlen + p->bh_caplen)

     For the alignment mechanisms to work properly, the buffer passed to
     read(2) must itself be word aligned.  The malloc(3) function will always
     return an aligned buffer.


FILTER MACHINE

     A filter program is an array of instructions, with all branches forwardly
     directed, terminated by a return instruction.  Each instruction performs
     some action on the pseudo-machine state, which consists of an accumula-
     tor, index register, scratch memory store, and implicit program counter.

     The following structure defines the instruction format:

     struct bpf_insn {
	     u_short code;
	     u_char  jt;
	     u_char  jf;
	     u_long k;
     };

     The k field is used in different ways by different instructions, and the
     jt and jf fields are used as offsets by the branch instructions.  The
     opcodes are encoded in a semi-hierarchical fashion.  There are eight
     classes of instructions: BPF_LD, BPF_LDX, BPF_ST, BPF_STX, BPF_ALU,
     BPF_JMP, BPF_RET, and BPF_MISC.  Various other mode and operator bits are
     or'd into the class to give the actual instructions.  The classes and
     modes are defined in <net/bpf.h>.

     the packet.

     BPF_LD    These instructions copy a value into the accumulator.  The type
	       of the source operand is specified by an ``addressing mode''
	       and can be a constant (BPF_IMM), packet data at a fixed offset
	       (BPF_ABS), packet data at a variable offset (BPF_IND), the
	       packet length (BPF_LEN), or a word in the scratch memory store
	       (BPF_MEM).  For BPF_IND and BPF_ABS, the data size must be
	       specified as a word (BPF_W), halfword (BPF_H), or byte (BPF_B).
	       The semantics of all the recognized BPF_LD instructions follow.

	       BPF_LD+BPF_W+BPF_ABS    A <- P[k:4]
	       BPF_LD+BPF_H+BPF_ABS    A <- P[k:2]
	       BPF_LD+BPF_B+BPF_ABS    A <- P[k:1]
	       BPF_LD+BPF_W+BPF_IND    A <- P[X+k:4]
	       BPF_LD+BPF_H+BPF_IND    A <- P[X+k:2]
	       BPF_LD+BPF_B+BPF_IND    A <- P[X+k:1]
	       BPF_LD+BPF_W+BPF_LEN    A <- len
	       BPF_LD+BPF_IMM	       A <- k
	       BPF_LD+BPF_MEM	       A <- M[k]

     BPF_LDX   These instructions load a value into the index register.  Note
	       that the addressing modes are more restrictive than those of
	       the accumulator loads, but they include BPF_MSH, a hack for
	       efficiently loading the IP header length.

	       BPF_LDX+BPF_W+BPF_IMM   X <- k
	       BPF_LDX+BPF_W+BPF_MEM   X <- M[k]
	       BPF_LDX+BPF_W+BPF_LEN   X <- len
	       BPF_LDX+BPF_B+BPF_MSH   X <- 4*(P[k:1]&0xf)

     BPF_ST    This instruction stores the accumulator into the scratch mem-
	       ory.  We do not need an addressing mode since there is only one
	       possibility for the destination.

	       BPF_ST		       M[k] <- A

     BPF_STX   This instruction stores the index register in the scratch mem-
	       ory store.

	       BPF_STX		       M[k] <- X

     BPF_ALU   The alu instructions perform operations between the accumulator
	       and index register or constant, and store the result back in
	       the accumulator.  For binary operations, a source mode is
	       required (BPF_K or BPF_X).

	       BPF_ALU+BPF_ADD+BPF_K   A <- A + k
	       BPF_ALU+BPF_SUB+BPF_K   A <- A - k
	       BPF_ALU+BPF_MUL+BPF_K   A <- A * k
	       BPF_ALU+BPF_DIV+BPF_K   A <- A / k
	       BPF_ALU+BPF_AND+BPF_K   A <- A & k
	       BPF_ALU+BPF_OR+BPF_K    A <- A | k
	       BPF_ALU+BPF_LSH+BPF_K   A <- A << k
	       BPF_ALU+BPF_RSH+BPF_K   A <- A >> k
	       BPF_ALU+BPF_ADD+BPF_X   A <- A + X
	       BPF_ALU+BPF_SUB+BPF_X   A <- A - X
	       BPF_ALU+BPF_MUL+BPF_X   A <- A * X
	       compare the accumulator against a constant (BPF_K) or the index
	       register (BPF_X).  If the result is true (or non-zero), the
	       true branch is taken, otherwise the false branch is taken.
	       Jump offsets are encoded in 8 bits so the longest jump is 256
	       instructions.  However, the jump always (BPF_JA) opcode uses
	       the 32 bit k field as the offset, allowing arbitrarily distant
	       destinations.  All conditionals use unsigned comparison conven-
	       tions.

	       BPF_JMP+BPF_JA	       pc += k
	       BPF_JMP+BPF_JGT+BPF_K   pc += (A > k) ? jt : jf
	       BPF_JMP+BPF_JGE+BPF_K   pc += (A >= k) ? jt : jf
	       BPF_JMP+BPF_JEQ+BPF_K   pc += (A == k) ? jt : jf
	       BPF_JMP+BPF_JSET+BPF_K  pc += (A & k) ? jt : jf
	       BPF_JMP+BPF_JGT+BPF_X   pc += (A > X) ? jt : jf
	       BPF_JMP+BPF_JGE+BPF_X   pc += (A >= X) ? jt : jf
	       BPF_JMP+BPF_JEQ+BPF_X   pc += (A == X) ? jt : jf
	       BPF_JMP+BPF_JSET+BPF_X  pc += (A & X) ? jt : jf

     BPF_RET   The return instructions terminate the filter program and spec-
	       ify the amount of packet to accept (i.e., they return the trun-
	       cation amount).	A return value of zero indicates that the
	       packet should be ignored.  The return value is either a con-
	       stant (BPF_K) or the accumulator (BPF_A).

	       BPF_RET+BPF_A	       accept A bytes
	       BPF_RET+BPF_K	       accept k bytes

     BPF_MISC  The miscellaneous category was created for anything that
	       doesn't fit into the above classes, and for any new instruc-
	       tions that might need to be added.  Currently, these are the
	       register transfer instructions that copy the index register to
	       the accumulator or vice versa.

	       BPF_MISC+BPF_TAX        X <- A
	       BPF_MISC+BPF_TXA        A <- X

     The bpf interface provides the following macros to facilitate array ini-
     tializers: BPF_STMT(opcode, operand) and BPF_JUMP(opcode, operand,
     true_offset, false_offset).


EXAMPLES

     The following filter is taken from the Reverse ARP Daemon.  It accepts
     only Reverse ARP requests.

     struct bpf_insn insns[] = {
	     BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 12),
	     BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ETHERTYPE_REVARP, 0, 3),
	     BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 20),
	     BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, REVARP_REQUEST, 0, 1),
	     BPF_STMT(BPF_RET+BPF_K, sizeof(struct ether_arp) +
		      sizeof(struct ether_header)),
	     BPF_STMT(BPF_RET+BPF_K, 0),
     };

     This filter accepts only IP packets between host 128.3.112.15 and
     128.3.112.35.

	     BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 30),
	     BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 0, 1),
	     BPF_STMT(BPF_RET+BPF_K, (u_int)-1),
	     BPF_STMT(BPF_RET+BPF_K, 0),
     };

     Finally, this filter returns only TCP finger packets.  We must parse the
     IP header to reach the TCP header.  The BPF_JSET instruction checks that
     the IP fragment offset is 0 so we are sure that we have a TCP header.

     struct bpf_insn insns[] = {
	     BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 12),
	     BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ETHERTYPE_IP, 0, 10),
	     BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 23),
	     BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, IPPROTO_TCP, 0, 8),
	     BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 20),
	     BPF_JUMP(BPF_JMP+BPF_JSET+BPF_K, 0x1fff, 6, 0),
	     BPF_STMT(BPF_LDX+BPF_B+BPF_MSH, 14),
	     BPF_STMT(BPF_LD+BPF_H+BPF_IND, 14),
	     BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 79, 2, 0),
	     BPF_STMT(BPF_LD+BPF_H+BPF_IND, 16),
	     BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 79, 0, 1),
	     BPF_STMT(BPF_RET+BPF_K, (u_int)-1),
	     BPF_STMT(BPF_RET+BPF_K, 0),
     };


SEE ALSO

     tcpdump(1), ioctl(2), byteorder(3), ng_bpf(4), bpf(9)

     McCanne, S.  and Jacobson V., An efficient, extensible, and portable
     network monitor.


FILES

     /dev/bpfn	  the packet filter device


BUGS

     The read buffer must be of a fixed size (returned by the BIOCGBLEN
     ioctl).

     A file that does not request promiscuous mode may receive promiscuously
     received packets as a side effect of another file requesting this mode on
     the same hardware interface.  This could be fixed in the kernel with
     additional processing overhead.  However, we favor the model where all
     files must assume that the interface is promiscuous, and if so desired,
     must utilize a filter to reject foreign packets.

     Data link protocols with variable length headers are not currently sup-
     ported.

     The SEESENT flag has been observed to work incorrectly on some interface
     types, including those with hardware loopback rather than software loop-
     back, and point-to-point interfaces.  It appears to function correctly on
     a broad range of Ethernet-style interfaces.


HISTORY

     The Enet packet filter was created in 1980 by Mike Accetta and Rick
     Rashid at Carnegie-Mellon University.  Jeffrey Mogul, at Stanford, ported
     the code to BSD and continued its development from 1983 on.  Since then,

SPONSORED LINKS




Man(1) output converted with man2html , sed , awk