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.18 2004/06/23 08:29:17 varenni Exp $ (LBL) 00035 */ 00036 00037 00038 00051 //\{ 00052 00053 00086 pcap_t *pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, char *ebuf); 00087 00088 00099 pcap_t *pcap_open_dead(int linktype, int snaplen); 00100 00101 00114 pcap_t *pcap_open_offline(const char *fname, char *errbuf); 00115 00116 00134 int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf); 00135 00136 00147 char *pcap_lookupdev(char *errbuf); 00148 00149 00161 int pcap_lookupnet(const char *device, bpf_u_int32 *netp, bpf_u_int32 *maskp, char *errbuf); 00162 00163 00164 //\} 00165 // End of deprecated functions 00166 00167 00168 00169 00170 00171 00172 00173 00179 //\{ 00180 00223 int pcap_dispatch(pcap_t *p, int cnt, pcap_handler callback, u_char *user); 00224 00225 00244 int pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user); 00245 00246 00258 u_char *pcap_next(pcap_t *p, struct pcap_pkthdr *h); 00259 00260 00276 int pcap_stats(pcap_t *p, struct pcap_stat *ps); 00277 00278 00289 FILE *pcap_file(pcap_t *p); 00290 00291 00303 int pcap_fileno(pcap_t *p); 00304 00305 //\} 00306 // End of discouraged functions 00307 00308 00309 00310 00311 00312 00317 //\{ 00318 00319 00320 00327 void pcap_freealldevs(pcap_if_t *alldevsp); 00328 00329 00344 int pcap_compile(pcap_t *p, struct bpf_program *fp, char *str, int optimize, bpf_u_int32 netmask); 00345 00365 int pcap_compile_nopcap(int snaplen_arg, int linktype_arg, struct bpf_program *program, char *buf, int optimize, bpf_u_int32 mask); 00366 00367 00378 int pcap_setfilter(pcap_t *p, struct bpf_program *fp); 00379 00380 00391 void pcap_freecode(struct bpf_program *fp); 00392 00393 00411 bool pcap_offline_filter(struct bpf_program *prog, const struct pcap_pkthdr *header, const u_char *pkt_data); 00412 00413 00423 pcap_dumper_t *pcap_dump_open(pcap_t *p, const char *fname); 00424 00425 00436 void pcap_dump(u_char *user, const struct pcap_pkthdr *h, const u_char *sp); 00437 00443 void pcap_close(pcap_t *p); 00444 00445 00451 void pcap_dump_close(pcap_dumper_t *p); 00452 00453 00470 int pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header, const u_char **pkt_data); 00471 00472 00495 int pcap_live_dump(pcap_t *p, char *filename, int maxsize, int maxpacks); 00496 00497 00512 int pcap_live_dump_ended(pcap_t *p, int sync); 00513 00514 00538 struct pcap_stat *pcap_stats_ex(pcap_t *p, int *pcap_stat_size); 00539 00540 00549 typedef void (*pcap_handler)(u_char *user, const struct pcap_pkthdr *pkt_header, 00550 const u_char *pkt_data); 00551 00552 00553 //\} 00554 // End of basic functions 00555 00556 00557 00558 00559 00560 00561 00562 00563 00568 //\{ 00569 00570 00588 int pcap_setnonblock(pcap_t *p, int nonblock, char *errbuf); 00589 00590 00600 int pcap_getnonblock(pcap_t *p, char *errbuf); 00601 00602 00612 int pcap_setbuff(pcap_t *p, int dim); 00613 00614 00621 int pcap_setmode(pcap_t *p, int mode); 00622 00623 00636 int pcap_setmintocopy(pcap_t *p, int size); 00637 00638 00755 int pcap_datalink(pcap_t *p); 00756 00757 00765 int pcap_snapshot(pcap_t *p); 00766 00767 00772 int pcap_is_swapped(pcap_t *p); 00773 00774 00780 int pcap_major_version(pcap_t *p); 00781 00782 00788 int pcap_minor_version(pcap_t *p); 00789 00790 00800 HANDLE pcap_getevent(pcap_t *p); 00801 00802 00809 void pcap_perror(pcap_t *p, char *prefix); 00810 00811 00822 char *pcap_geterr(pcap_t *p); 00823 00824 00831 char *pcap_strerror(int error); 00832 00833 //\} 00834 // End of miscellaneous functions 00835 00836 00837 00838 00839 00840 00841 00842 00843 00849 //\{ 00850 00851 00863 int pcap_sendpacket(pcap_t *p, u_char *buf, int size); 00864 00865 00878 pcap_send_queue* pcap_sendqueue_alloc(u_int memsize); 00879 00886 void pcap_sendqueue_destroy(pcap_send_queue* queue); 00887 00902 int pcap_sendqueue_queue(pcap_send_queue* queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data); 00903 00904 00928 u_int pcap_sendqueue_transmit(pcap_t *p, pcap_send_queue* queue, int sync); 00929 00930 00931 //\} 00932 // End of sending functions 00933 00934 00935

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