par tomtom » 18 Août 2003 20:55
[root@lnx_delb root]# vi /usr/include/pcap.h
<BR>
<BR>/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
<BR>/*
<BR> * Copyright (c) 1993, 1994, 1995, 1996, 1997
<BR> * The Regents of the University of California. All rights reserved.
<BR> *
<BR> * Redistribution and use in source and binary forms, with or without
<BR> * modification, are permitted provided that the following conditions
<BR> * are met:
<BR> * 1. Redistributions of source code must retain the above copyright
<BR> * notice, this list of conditions and the following disclaimer.
<BR> * 2. Redistributions in binary form must reproduce the above copyright
<BR> * notice, this list of conditions and the following disclaimer in the
<BR> * documentation and/or other materials provided with the distribution.
<BR> * 3. All advertising materials mentioning features or use of this software
<BR> * must display the following acknowledgement:
<BR> * This product includes software developed by the Computer Systems
<BR> * Engineering Group at Lawrence Berkeley Laboratory.
<BR> * 4. Neither the name of the University nor of the Laboratory may be used
<BR> * to endorse or promote products derived from this software without
<BR> * specific prior written permission.
<BR> *
<BR> * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
<BR> * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
<BR> * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
<BR> * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
<BR> * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
<BR> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
<BR> * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
<BR> * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
<BR> * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
<BR> * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
<BR> * SUCH DAMAGE.
<BR> *
<BR> * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.34 2001/12/09 05:10:03 guy Exp $ (LBL)
<BR> */
<BR>
<BR>#ifndef lib_pcap_h
<BR>#define lib_pcap_h
<BR>
<BR>#include <sys/types.h>
<BR>#include <sys/time.h>
<BR>
<BR>#include <net/bpf.h>
<BR>
<BR>#include <stdio.h>
<BR>
<BR>#ifdef __cplusplus
<BR>extern "C" {
<BR>#endif
<BR>
<BR>#define PCAP_VERSION_MAJOR 2
<BR>#define PCAP_VERSION_MINOR 4
<BR>
<BR>#define PCAP_ERRBUF_SIZE 256
<BR>
<BR>/*
<BR> * Compatibility for systems that have a bpf.h that
<BR> * predates the bpf typedefs for 64-bit support.
<BR> */
<BR>#if BPF_RELEASE - 0 < 199406
<BR>typedef int bpf_int32;
<BR>typedef u_int bpf_u_int32;
<BR>#endif
<BR>
<BR>typedef struct pcap pcap_t;
<BR>typedef struct pcap_dumper pcap_dumper_t;
<BR>typedef struct pcap_if pcap_if_t;
<BR>typedef struct pcap_addr pcap_addr_t;
<BR>
<BR>/*
<BR> * The first record in the file contains saved values for some
<BR> * of the flags used in the printout phases of tcpdump.
<BR> * Many fields here are 32 bit ints so compilers won't insert unwanted
<BR> * padding; these files need to be interchangeable across architectures.
<BR> *
<BR> * Do not change the layout of this structure, in any way (this includes
<BR> * changes that only affect the length of fields in this structure).
<BR> *
<BR> * Also, do not change the interpretation of any of the members of this
<BR> * structure, in any way (this includes using values other than
<BR> * LINKTYPE_ values, as defined in "savefile.c", in the "linktype"
<BR> * field).
<BR> *
<BR> * Instead:
<BR> *
<BR> * introduce a new structure for the new format, if the layout
<BR> * of the structure changed;
<BR> *
<BR> * send mail to "tcpdump-workers@tcpdump.org", requesting a new
<BR> * magic number for your new capture file format, and, when
<BR> * you get the new magic number, put it in "savefile.c";
<BR> *
<BR> * use that magic number for save files with the changed file
<BR> * header;
<BR> *
<BR> * make the code in "savefile.c" capable of reading files with
<BR> * the old file header as well as files with the new file header
<BR> * (using the magic number to determine the header format).
<BR> *
<BR> * Then supply the changes to "patches@tcpdump.org", so that future
<BR> * versions of libpcap and programs that use it (such as tcpdump) will
<BR> * be able to read your new capture file format.
<BR> */
<BR>struct pcap_file_header {
<BR> bpf_u_int32 magic;
<BR> u_short version_major;
<BR> u_short version_minor;
<BR> bpf_int32 thiszone; /* gmt to local correction */
<BR> bpf_u_int32 sigfigs; /* accuracy of timestamps */
<BR> bpf_u_int32 snaplen; /* max length saved portion of each pkt */
<BR> bpf_u_int32 linktype; /* data link type (LINKTYPE_*) */
<BR>};
<BR>
<BR>/*
<BR> * Each packet in the dump file is prepended with this generic header.
<BR> * This gets around the problem of different headers for different
<BR> * packet interfaces.
<BR> */
<BR>struct pcap_pkthdr {
<BR> struct timeval ts; /* time stamp */
<BR> bpf_u_int32 caplen; /* length of portion present */
<BR> bpf_u_int32 len; /* length this packet (off wire) */
<BR>};
<BR>
<BR>/*
<BR> * As returned by the pcap_stats()
<BR> */
<BR>struct pcap_stat {
<BR> u_int ps_recv; /* number of packets received */
<BR> u_int ps_drop; /* number of packets dropped */
<BR> u_int ps_ifdrop; /* drops by interface XXX not yet supported */
<BR>};
<BR>
<BR>/*
<BR> * Item in a list of interfaces.
<BR> */
<BR>struct pcap_if {
<BR> struct pcap_if *next;
<BR> char *name; /* name to hand to "pcap_open_live()" */
<BR> char *description; /* textual description of interface, or NULL */
<BR> struct pcap_addr *addresses;
<BR> u_int flags; /* PCAP_IF_ interface flags */
<BR>};
<BR>
<BR>#define PCAP_IF_LOOPBACK 0x00000001 /* interface is loopback */
<BR>
<BR>/*
<BR> * Representation of an interface address.
<BR> */
<BR>struct pcap_addr {
<BR> struct pcap_addr *next;
<BR> struct sockaddr *addr; /* address */
<BR> struct sockaddr *netmask; /* netmask for that address */
<BR> struct sockaddr *broadaddr; /* broadcast address for that address */
<BR> struct sockaddr *dstaddr; /* P2P destination address for that address */
<BR>};
<BR>
<BR>typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
<BR> const u_char *);
<BR>
<BR>char *pcap_lookupdev(char *);
<BR>int pcap_lookupnet(char *, bpf_u_int32 *, bpf_u_int32 *, char *);
<BR>pcap_t *pcap_open_live(char *, int, int, int, char *);
<BR>pcap_t *pcap_open_dead(int, int);
<BR>pcap_t *pcap_open_offline(const char *, char *);
<BR>void pcap_close(pcap_t *);
<BR>int pcap_loop(pcap_t *, int, pcap_handler, u_char *);
<BR>int pcap_dispatch(pcap_t *, int, pcap_handler, u_char *);
<BR>const u_char*
<BR> pcap_next(pcap_t *, struct pcap_pkthdr *);
<BR>int pcap_stats(pcap_t *, struct pcap_stat *);
<BR>int pcap_setfilter(pcap_t *, struct bpf_program *);
<BR>int pcap_getnonblock(pcap_t *, char *);
<BR>int pcap_setnonblock(pcap_t *, int, char *);
<BR>void pcap_perror(pcap_t *, char *);
<BR>char *pcap_strerror(int);
<BR>char *pcap_geterr(pcap_t *);
<BR>int pcap_compile(pcap_t *, struct bpf_program *, char *, int,
<BR> bpf_u_int32);
<BR>int pcap_compile_nopcap(int, int, struct bpf_program *,
<BR> char *, int, bpf_u_int32);
<BR>void pcap_freecode(struct bpf_program *);
<BR>int pcap_datalink(pcap_t *);
<BR>int pcap_snapshot(pcap_t *);
<BR>int pcap_is_swapped(pcap_t *);
<BR>int pcap_major_version(pcap_t *);
<BR>int pcap_minor_version(pcap_t *);
<BR>
<BR>/* XXX */
<BR>FILE *pcap_file(pcap_t *);
<BR>int pcap_fileno(pcap_t *);
<BR>
<BR>pcap_dumper_t *pcap_dump_open(pcap_t *, const char *);
<BR>void pcap_dump_close(pcap_dumper_t *);
<BR>void pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *);
<BR>
<BR>int pcap_findalldevs(pcap_if_t **, char *);
<BR>void pcap_freealldevs(pcap_if_t *);
<BR>
<BR>/* XXX this guy lives in the bpf tree */
<BR>u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int);
<BR>int bpf_validate(struct bpf_insn *f, int len);
<BR>char *bpf_image(struct bpf_insn *, int);
<BR>void bpf_dump(struct bpf_program *, int);
<BR>
<BR>#ifdef __cplusplus
<BR>}
<BR>#endif
<BR>
<BR>#endif
One hundred thousand lemmings can't be wrong...