Main Page   Modules   Data Structures   File List   Data Fields   Globals  

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.7 2002/08/01 10:20:25 degioanni Exp $ (LBL)
00035  */
00036 
00075 pcap_t *pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf);
00076 
00086 pcap_t *pcap_open_dead(int linktype, int snaplen);
00087 
00099 pcap_t *pcap_open_offline(const char *fname, char *errbuf);
00100 
00110 pcap_dumper_t *pcap_dump_open(pcap_t *p, const char *fname);
00111 
00129 int pcap_setnonblock(pcap_t *p, int nonblock, char *errbuf);
00130 
00140 int pcap_getnonblock(pcap_t *p, char *errbuf);
00141 
00156 int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf);
00157 
00164 void pcap_freealldevs(pcap_if_t *alldevsp);
00165 
00175 char *pcap_lookupdev(char *errbuf);
00176 
00187 int pcap_lookupnet(char *device, bpf_u_int32 *netp, bpf_u_int32 *maskp, char *errbuf);
00188 
00228 int pcap_dispatch(pcap_t *p, int cnt, pcap_handler callback, u_char *user);
00229 
00246 int pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user);
00247 
00258 void pcap_dump(u_char *user, const struct pcap_pkthdr *h, const u_char *sp);
00259 
00274 int pcap_compile(pcap_t *p, struct bpf_program *fp, char *str, int optimize, bpf_u_int32 netmask);
00275 
00296 int pcap_compile_nopcap(int snaplen_arg, int linktype_arg, struct bpf_program *program, char *buf, int optimize, bpf_u_int32 mask);
00297 
00308 int pcap_setfilter(pcap_t *p, struct bpf_program *fp);
00309 
00320 void pcap_freecode(struct bpf_program *fp);
00321 
00332 u_char *pcap_next(pcap_t *p, struct pcap_pkthdr *h);
00333 
00450 int pcap_datalink(pcap_t *p);
00451 
00459 int pcap_snapshot(pcap_t *p);
00460 
00465 int pcap_is_swapped(pcap_t *p);
00466 
00472 int pcap_major_version(pcap_t *p);
00473 
00479 int pcap_minor_version(pcap_t *p);
00480 
00495 int pcap_stats(pcap_t *p, struct pcap_stat *ps);
00496 
00506 FILE *pcap_file(pcap_t *p);
00507 
00517 int pcap_fileno(pcap_t *p);
00518 
00525 void pcap_perror(pcap_t *p, char *prefix);
00526 
00537 char *pcap_geterr(pcap_t *p);
00538 
00545 char *pcap_strerror(int error);
00546 
00552 \fn void pcap_close(pcap_t *p);
00553 
00559 \fn void pcap_dump_close(pcap_dumper_t *p);
00560 
00570 \fn int pcap_setbuff(pcap_t *p, int dim);
00577 int pcap_setmode(pcap_t *p, int mode);
00578 
00589 int pcap_sendpacket(pcap_t *p, u_char *buf, int size);
00590 
00603 int pcap_setmintocopy(pcap_t *p, int size);
00604 
00612 HANDLE pcap_getevent(pcap_t *p);
00613 
00626 pcap_send_queue* pcap_sendqueue_alloc(u_int memsize);
00627 
00634 void pcap_sendqueue_destroy(pcap_send_queue* queue);
00635 
00650 int pcap_sendqueue_queue(pcap_send_queue* queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data);
00651 
00675 u_int pcap_sendqueue_transmit(pcap_t *p, pcap_send_queue* queue, int sync);
00676 
00693 int pcap_read_ex(pcap_t *p, struct pcap_pkthdr **pkt_header, u_char **pkt_data);
00694 
00717 int pcap_live_dump(pcap_t *p, char *filename, int maxsize, int maxpacks);
00718 
00733 int pcap_live_dump_ended(pcap_t *p, int sync);
00734 
00742 int pcap_stats_ex(pcap_t *p, struct pcap_stat *ps);
00743 
00752 typedef void (*pcap_handler)(u_char *user, const struct pcap_pkthdr *pkt_header,
00753                  const u_char *pkt_data);
00754 

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