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.16 2003/06/10 11:04:56 fulvio Exp $ (LBL)
    00035  */
    00036
    00037
    00038
    00077 pcap_t *pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf);
    00078
    00091 pcap_t *pcap_open_dead(int linktype, int snaplen);
    00092
    00107 pcap_t *pcap_open_offline(const char *fname, char *errbuf);
    00108
    00118 pcap_dumper_t *pcap_dump_open(pcap_t *p, const char *fname);
    00119
    00137 int pcap_setnonblock(pcap_t *p, int nonblock, char *errbuf);
    00138
    00148 int pcap_getnonblock(pcap_t *p, char *errbuf);
    00149
    00167 int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf);
    00168
    00175 void pcap_freealldevs(pcap_if_t *alldevsp);
    00176
    00189 char *pcap_lookupdev(char *errbuf);
    00190
    00204 int pcap_lookupnet(char *device, bpf_u_int32 *netp, bpf_u_int32 *maskp, char *errbuf);
    00205
    00248 int pcap_dispatch(pcap_t *p, int cnt, pcap_handler callback, u_char *user);
    00249
    00269 int pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user);
    00270
    00281 void pcap_dump(u_char *user, const struct pcap_pkthdr *h, const u_char *sp);
    00282
    00297 int pcap_compile(pcap_t *p, struct bpf_program *fp, char *str, int optimize, bpf_u_int32 netmask);
    00298
    00318 int pcap_compile_nopcap(int snaplen_arg, int linktype_arg, struct bpf_program *program, char *buf, int optimize, bpf_u_int32 mask);
    00319
    00330 int pcap_setfilter(pcap_t *p, struct bpf_program *fp);
    00331
    00342 void pcap_freecode(struct bpf_program *fp);
    00343
    00354 u_char *pcap_next(pcap_t *p, struct pcap_pkthdr *h);
    00355
    00472 int pcap_datalink(pcap_t *p);
    00473
    00481 int pcap_snapshot(pcap_t *p);
    00482
    00487 int pcap_is_swapped(pcap_t *p);
    00488
    00494 int pcap_major_version(pcap_t *p);
    00495
    00501 int pcap_minor_version(pcap_t *p);
    00502
    00517 int pcap_stats(pcap_t *p, struct pcap_stat *ps);
    00518
    00528 FILE *pcap_file(pcap_t *p);
    00529
    00540 int pcap_fileno(pcap_t *p);
    00541
    00548 void pcap_perror(pcap_t *p, char *prefix);
    00549
    00560 char *pcap_geterr(pcap_t *p);
    00561
    00568 char *pcap_strerror(int error);
    00569
    00575 \fn void pcap_close(pcap_t *p);
    00576
    00582 \fn void pcap_dump_close(pcap_dumper_t *p);
    00583
    00593 \fn int pcap_setbuff(pcap_t *p, int dim);
    00600 int pcap_setmode(pcap_t *p, int mode);
    00601
    00613 int pcap_sendpacket(pcap_t *p, u_char *buf, int size);
    00614
    00627 int pcap_setmintocopy(pcap_t *p, int size);
    00628
    00636 HANDLE pcap_getevent(pcap_t *p);
    00637
    00650 pcap_send_queue* pcap_sendqueue_alloc(u_int memsize);
    00651
    00658 void pcap_sendqueue_destroy(pcap_send_queue* queue);
    00659
    00674 int pcap_sendqueue_queue(pcap_send_queue* queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data);
    00675
    00699 u_int pcap_sendqueue_transmit(pcap_t *p, pcap_send_queue* queue, int sync);
    00700
    00717 int pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header, u_char **pkt_data);
    00718
    00741 int pcap_live_dump(pcap_t *p, char *filename, int maxsize, int maxpacks);
    00742
    00757 int pcap_live_dump_ended(pcap_t *p, int sync);
    00758
    00782 struct pcap_stat *pcap_stats_ex(pcap_t *p, int *pcap_stat_size);
    00783
    00792 typedef void (*pcap_handler)(u_char *user, const struct pcap_pkthdr *pkt_header,
    00793                  const u_char *pkt_data);
    00794
    00795
    00813 bool pcap_offline_filter(struct bpf_program *prog, const struct pcap_pkthdr *header, const u_char *pkt_data);
    00814

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