#include <pcap-stdinc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include "pcap-int.h"
Go to the source code of this file.
Data Structures | |
struct | dlt_choice |
struct | pkt_for_fakecallback |
struct | singleton |
Defines | |
#define | DLT_CHOICE(code, description) { #code, description, code } |
#define | DLT_CHOICE_SENTINEL { NULL, NULL, 0 } |
Functions | |
int | pcap_dispatch (pcap_t *p, int cnt, pcap_handler callback, u_char *user) |
It collects a group of packets. | |
int | pcap_read (pcap_t *p, int cnt, pcap_handler callback, u_char *user) |
int | pcap_loop (pcap_t *p, int cnt, pcap_handler callback, u_char *user) |
It collects a group of packets. | |
void | pcap_oneshot (u_char *userData, const struct pcap_pkthdr *h, const u_char *pkt) |
const u_char * | pcap_next (pcap_t *p, struct pcap_pkthdr *h) |
It returns the next available packet. | |
void | pcap_fakecallback (u_char *userData, const struct pcap_pkthdr *h, const u_char *pkt) |
int | pcap_next_ex (pcap_t *p, struct pcap_pkthdr **pkt_header, const u_char **pkt_data) |
void | pcap_breakloop (pcap_t *p) |
int | pcap_datalink (pcap_t *p) |
Returns the link layer of an adapter. | |
int | pcap_list_datalinks (pcap_t *p, int **dlt_buffer) |
int | pcap_set_datalink (pcap_t *p, int dlt) |
int | pcap_strcasecmp (const char *s1, const char *s2) |
int | pcap_datalink_name_to_val (const char *name) |
const char * | pcap_datalink_val_to_name (int dlt) |
const char * | pcap_datalink_val_to_description (int dlt) |
int | pcap_snapshot (pcap_t *p) |
Returns the dimension of the packet portion (in bytes) that is delivered to the application. | |
int | pcap_is_swapped (pcap_t *p) |
returns true if the current savefile uses a different byte order than the current system. | |
int | pcap_major_version (pcap_t *p) |
returns the major version number of the pcap library used to write the savefile. | |
int | pcap_minor_version (pcap_t *p) |
returns the minor version number of the pcap library used to write the savefile. | |
FILE * | pcap_file (pcap_t *p) |
It returns the stdio stream of an offile capture. | |
int | pcap_fileno (pcap_t *p) |
It returns the file descriptor of a capture device. | |
void | pcap_perror (pcap_t *p, char *prefix) |
prints the text of the last pcap library error on stderr, prefixed by prefix. | |
char * | pcap_geterr (pcap_t *p) |
returns the error text pertaining to the last pcap library error. | |
int | pcap_getnonblock (pcap_t *p, char *errbuf) |
Gets the "non-blocking" state of an interface. | |
int | pcap_setnonblock (pcap_t *p, int nonblock, char *errbuf) |
Switches between blocking and nonblocking mode. | |
char * | pcap_win32strerror (void) |
char * | pcap_strerror (int errnum) |
pcap_strerror() is provided in case strerror() isn't available. | |
int | pcap_setfilter (pcap_t *p, struct bpf_program *fp) |
Associates a filter to a capture. | |
int | pcap_stats (pcap_t *p, struct pcap_stat *ps) |
It returns statistics on current capture. | |
int | pcap_stats_dead (pcap_t *p, struct pcap_stat *ps) |
void | pcap_close_dead (pcap_t *p) |
pcap_t * | pcap_open_dead (int linktype, int snaplen) |
It creates a pcap_t structure without starting a capture. | |
void | pcap_close (pcap_t *p) |
closes the files associated with p and deallocates resources. | |
const char * | pcap_lib_version (void) |
Variables | |
const char rcsid[] | _U_ |
dlt_choice | dlt_choices [] |
const u_char | charmap [] |
const char | wpcap_version_string [] = "3.0" |
const char | pcap_version_string_fmt [] |
const char | pcap_version_string_packet_dll_fmt [] |
char * | pcap_version_string |
|
|
|
|
|
|
|
closes the files associated with p and deallocates resources.
Definition at line 728 of file pcap.c. References pcap_freecode(). Referenced by daemon_endcapture(), daemon_opensource(), daemon_serviceloop(), daemon_startcapture(), pcap_compile_nopcap(), pcap_findalldevs_ex(), and pcap_opensource_remote(). |
|
Definition at line 706 of file pcap.c. Referenced by pcap_open_dead(). |
|
Returns the link layer of an adapter. pcap_datalink() returns the link layer type; link layer types it can return include:
Definition at line 236 of file pcap.c. Referenced by pcap_compile(). |
|
Definition at line 462 of file pcap.c. References dlt_choice::dlt, dlt_choices, dlt_choice::name, and pcap_strcasecmp(). |
|
Definition at line 487 of file pcap.c. References dlt_choice::description, dlt_choice::dlt, dlt_choices, and dlt_choice::name. |
|
Definition at line 475 of file pcap.c. References dlt_choice::dlt, dlt_choices, and dlt_choice::name. Referenced by pcap_set_datalink(). |
|
It collects a group of packets.
pcap_dispatch() is used to collect and process packets. cnt specifies the maximum number of packets to process before returning. This is not a minimum number; when reading a live capture, only one bufferful of packets is read at a time, so fewer than cnt packets may be processed. A cnt of -1 processes all the packets received in one buffer when reading a live capture, or all the packets in the file when reading a "savefile". callback specifies a routine to be called with three arguments: a u_char pointer which is passed in from pcap_dispatch(), a pointer packet data. The number of packets read is returned. 0 is returned if no packets were read from a live capture (if, for example, they were discarded because they didn't pass the packet filter, or if, on platforms that support a read timeout that starts before any packets arrive, the timeout expires before any packets arrive, or if the file descriptor for the capture device is in non-blocking mode and no packets were available to be read) or if no more packets are available in a "savefile." A return of -1 indicates an error in which case pcap_perror() or pcap_geterr() may be used to display the error text.
Definition at line 75 of file pcap.c. Referenced by pcap_next(). |
|
Definition at line 152 of file pcap.c. References pkt_for_fakecallback::hdr, and pkt_for_fakecallback::pkt. |
|
It returns the stdio stream of an offile capture.
|
|
It returns the file descriptor of a capture device.
|
|
returns the error text pertaining to the last pcap library error.
Definition at line 561 of file pcap.c. Referenced by bpf_error(), and daemon_thrdatamain(). |
|
Gets the "non-blocking" state of an interface. pcap_getnonblock() returns the current "non-blocking" state of the capture descriptor; it always returns 0 on "savefiles". If there is an error, -1 is returned and errbuf is filled in with an appropriate error message.
|
|
returns true if the current savefile uses a different byte order than the current system.
|
|
Definition at line 763 of file pcap.c. References PacketGetVersion(), pcap_version_string, pcap_version_string_fmt, and pcap_version_string_packet_dll_fmt. |
|
Definition at line 242 of file pcap.c. References pcap_strerror(), and snprintf. |
|
It collects a group of packets.
pcap_loop() is similar to pcap_dispatch() except it keeps reading packets until cnt packets are processed or an error occurs. It does not return when live read timeouts occur. Rather, specifying a non-zero read timeout to pcap_open_live() and then calling pcap_dispatch() allows the reception and processing of any packets that arrive when the timeout occurs. A negative cnt causes pcap_loop() to loop forever (or at least until an error occur s).
Definition at line 92 of file pcap.c. References n, and pcap_offline_read(). Referenced by main(). |
|
returns the major version number of the pcap library used to write the savefile.
|
|
returns the minor version number of the pcap library used to write the savefile.
|
|
It returns the next available packet.
Definition at line 136 of file pcap.c. References singleton::hdr, pcap_dispatch(), and singleton::pkt. |
|
Definition at line 162 of file pcap.c. References pkt_for_fakecallback::hdr, pcap_offline_read(), pcap_read_nocb_remote(), pcap_startcapture_remote(), and pkt_for_fakecallback::pkt. Referenced by daemon_thrdatamain(), and main(). |
|
Definition at line 128 of file pcap.c. References singleton::hdr, and singleton::pkt. |
|
It creates a pcap_t structure without starting a capture.
Definition at line 712 of file pcap.c. References pcap_close_dead(), pcap_stats_dead(), and pcap_t. Referenced by pcap_compile_nopcap(). |
|
prints the text of the last pcap library error on stderr, prefixed by prefix.
|
|
|
|
Definition at line 273 of file pcap.c. References pcap_datalink_val_to_name(), and snprintf. |
|
Associates a filter to a capture. pcap_setfilter() is used to specify a filter program. fp is a pointer to a bpf_program struct, usually the result of a call to pcap_compile(). -1 is returned on failure, in which case pcap_geterr() may be used to display the error text; 0 is returned on success.
Definition at line 686 of file pcap.c. Referenced by daemon_unpackapplyfilter(), and main(). |
|
Switches between blocking and nonblocking mode. pcap_setnonblock() puts a capture descriptor, opened with pcap_open_live(), into "non-blocking" mode, or takes it out of "non-blocking" mode, depending on whether the nonblock argument is non-zero or zero. It has no effect on "savefiles". If there is an error, -1 is returned and errbuf is filled in with an appropriate error message; otherwise, 0 is returned. In "non-blocking" mode, an attempt to read from the capture descriptor with pcap_dispatch() will, if no packets are currently available to be read, return 0 immediately rather than blocking waiting for packets to arrive. pcap_loop() and pcap_next() will not work in "non-blocking" mode.
|
|
Returns the dimension of the packet portion (in bytes) that is delivered to the application. pcap_snapshot() returns the snapshot length specified when pcap_open_live was called.
Definition at line 499 of file pcap.c. Referenced by pcap_compile(). |
|
It returns statistics on current capture.
Definition at line 692 of file pcap.c. Referenced by daemon_getstats(), and daemon_serviceloop(). |
|
Definition at line 698 of file pcap.c. References snprintf. Referenced by pcap_open_dead(). |
|
Definition at line 449 of file pcap.c. References charmap, s1, and s2. Referenced by pcap_datalink_name_to_val(). |
|
pcap_strerror() is provided in case strerror() isn't available.
Definition at line 669 of file pcap.c. References snprintf. Referenced by add_addr_to_iflist(), add_or_find_if(), daemon_AuthUserPwd(), daemon_checkauth(), daemon_unpackapplyfilter(), main_active(), main_passive(), pcap_dump_open(), pcap_findalldevs_ex(), pcap_list_datalinks(), pcap_open_live(), pcap_open_offline(), pcap_opensource_remote(), pcap_remoteact_accept(), pcap_setfilter_win32_dag(), pcap_startcapture_remote(), rpcap_deseraddr(), and sf_next_packet(). |
|
Definition at line 642 of file pcap.c. References errbuf, and PCAP_ERRBUF_SIZE. Referenced by pcap_open_live(), pcap_setfilter_win32_npf(), pcap_setnonblock_win32(), pcap_stats_ex(), and pcap_stats_win32(). |
|
Initial value:
"@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.70 2003/12/18 23:32:34 guy Exp $ (LBL)"
|
|
Definition at line 381 of file pcap.c. Referenced by pcap_strcasecmp(). |
|
Definition at line 343 of file pcap.c. Referenced by pcap_datalink_name_to_val(), pcap_datalink_val_to_description(), and pcap_datalink_val_to_name(). |
|
Definition at line 760 of file pcap.c. Referenced by pcap_lib_version(). |
|
Initial value:
"WinPcap version %s, based on libpcap version 0.8"
Definition at line 756 of file pcap.c. Referenced by pcap_lib_version(). |
|
Initial value:
"WinPcap version %s (packet.dll version %s), based on libpcap version 0.8"
Definition at line 758 of file pcap.c. Referenced by pcap_lib_version(). |
|
|
documentation. Copyright (c) 2002-2003 Politecnico di Torino. All rights reserved.