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

# pcap.h

Go to the documentation of this file.

    00001 /* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
    00002 /*
    00003  * Copyright (c) 1993, 1994, 1995, 1996, 1997
    00004  *  The Regents of the University of California.  All rights reserved.
    00005  *
    00006  * Redistribution and use in source and binary forms, with or without
    00007  * modification, are permitted provided that the following conditions
    00008  * are met:
    00009  * 1. Redistributions of source code must retain the above copyright
    00010  *    notice, this list of conditions and the following disclaimer.
    00011  * 2. Redistributions in binary form must reproduce the above copyright
    00012  *    notice, this list of conditions and the following disclaimer in the
    00013  *    documentation and/or other materials provided with the distribution.
    00014  * 3. All advertising materials mentioning features or use of this software
    00015  *    must display the following acknowledgement:
    00016  *  This product includes software developed by the Computer Systems
    00017  *  Engineering Group at Lawrence Berkeley Laboratory.
    00018  * 4. Neither the name of the University nor of the Laboratory may be used
    00019  *    to endorse or promote products derived from this software without
    00020  *    specific prior written permission.
    00021  *
    00022  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    00023  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    00024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    00025  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    00026  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    00027  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    00028  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    00030  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    00031  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    00032  * SUCH DAMAGE.
    00033  *
    00034  * @(#) $Header: /usr/cvsroot/winpcap/dox/libpcap/funcs/pcap.h,v 1.10 2003/03/13 13:05:47 fulvio Exp $ (LBL)
    00035  */
    00036
    00037
    00108 pcap_t *pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf);
    00109
    00119 pcap_t *pcap_open_dead(int linktype, int snaplen);
    00120
    00132 pcap_t *pcap_open_offline(const char *fname, char *errbuf);
    00133
    00143 pcap_dumper_t *pcap_dump_open(pcap_t *p, const char *fname);
    00144
    00162 int pcap_setnonblock(pcap_t *p, int nonblock, char *errbuf);
    00163
    00173 int pcap_getnonblock(pcap_t *p, char *errbuf);
    00174
    00189 int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf);
    00190
    00197 void pcap_freealldevs(pcap_if_t *alldevsp);
    00198
    00208 char *pcap_lookupdev(char *errbuf);
    00209
    00220 int pcap_lookupnet(char *device, bpf_u_int32 *netp, bpf_u_int32 *maskp, char *errbuf);
    00221
    00261 int pcap_dispatch(pcap_t *p, int cnt, pcap_handler callback, u_char *user);
    00262
    00279 int pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user);
    00280
    00291 void pcap_dump(u_char *user, const struct pcap_pkthdr *h, const u_char *sp);
    00292
    00307 int pcap_compile(pcap_t *p, struct bpf_program *fp, char *str, int optimize, bpf_u_int32 netmask);
    00308
    00329 int pcap_compile_nopcap(int snaplen_arg, int linktype_arg, struct bpf_program *program, char *buf, int optimize, bpf_u_int32 mask);
    00330
    00341 int pcap_setfilter(pcap_t *p, struct bpf_program *fp);
    00342
    00353 void pcap_freecode(struct bpf_program *fp);
    00354
    00365 u_char *pcap_next(pcap_t *p, struct pcap_pkthdr *h);
    00366
    00483 int pcap_datalink(pcap_t *p);
    00484
    00492 int pcap_snapshot(pcap_t *p);
    00493
    00498 int pcap_is_swapped(pcap_t *p);
    00499
    00505 int pcap_major_version(pcap_t *p);
    00506
    00512 int pcap_minor_version(pcap_t *p);
    00513
    00528 int pcap_stats(pcap_t *p, struct pcap_stat *ps);
    00529
    00539 FILE *pcap_file(pcap_t *p);
    00540
    00550 int pcap_fileno(pcap_t *p);
    00551
    00558 void pcap_perror(pcap_t *p, char *prefix);
    00559
    00570 char *pcap_geterr(pcap_t *p);
    00571
    00578 char *pcap_strerror(int error);
    00579
    00585 \fn void pcap_close(pcap_t *p);
    00586
    00592 \fn void pcap_dump_close(pcap_dumper_t *p);
    00593
    00603 \fn int pcap_setbuff(pcap_t *p, int dim);
    00610 int pcap_setmode(pcap_t *p, int mode);
    00611
    00623 int pcap_sendpacket(pcap_t *p, u_char *buf, int size);
    00624
    00637 int pcap_setmintocopy(pcap_t *p, int size);
    00638
    00646 HANDLE pcap_getevent(pcap_t *p);
    00647
    00660 pcap_send_queue* pcap_sendqueue_alloc(u_int memsize);
    00661
    00668 void pcap_sendqueue_destroy(pcap_send_queue* queue);
    00669
    00684 int pcap_sendqueue_queue(pcap_send_queue* queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data);
    00685
    00709 u_int pcap_sendqueue_transmit(pcap_t *p, pcap_send_queue* queue, int sync);
    00710
    00727 int pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header, u_char **pkt_data);
    00728
    00751 int pcap_live_dump(pcap_t *p, char *filename, int maxsize, int maxpacks);
    00752
    00767 int pcap_live_dump_ended(pcap_t *p, int sync);
    00768
    00776 int pcap_stats_ex(pcap_t *p, struct pcap_stat *ps);
    00777
    00786 typedef void (*pcap_handler)(u_char *user, const struct pcap_pkthdr *pkt_header,
    00787                  const u_char *pkt_data);
    00788

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