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

pcap.c File Reference

#include <pcap-stdinc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "pcap-int.h"

Go to the source code of this file.

Data Structures

struct  singleton
struct  pkt_for_fakecallback
struct  dlt_choice

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)
 Read a packet from an interface or from an offline capture.

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_tpcap_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.1 beta4"
const char pcap_version_string_fmt []
const char pcap_version_string_packet_dll_fmt []
char * pcap_version_string


Define Documentation

#define DLT_CHOICE code,
description   )     { #code, description, code }
 

Definition at line 337 of file pcap.c.

#define DLT_CHOICE_SENTINEL   { NULL, NULL, 0 }
 

Definition at line 338 of file pcap.c.


Function Documentation

void pcap_breakloop pcap_t p  ) 
 

Definition at line 243 of file pcap.c.

void pcap_close_dead pcap_t p  )  [static]
 

Definition at line 704 of file pcap.c.

Referenced by pcap_open_dead().

int pcap_datalink_name_to_val const char *  name  ) 
 

Definition at line 460 of file pcap.c.

References dlt_choice::dlt, dlt_choices, dlt_choice::name, and pcap_strcasecmp().

const char* pcap_datalink_val_to_description int  dlt  ) 
 

Definition at line 485 of file pcap.c.

References dlt_choice::description, dlt_choice::dlt, dlt_choices, and dlt_choice::name.

const char* pcap_datalink_val_to_name int  dlt  ) 
 

Definition at line 473 of file pcap.c.

References dlt_choice::dlt, dlt_choices, and dlt_choice::name.

Referenced by pcap_set_datalink().

void pcap_fakecallback u_char *  userData,
const struct pcap_pkthdr h,
const u_char *  pkt
[static]
 

Definition at line 165 of file pcap.c.

Referenced by pcap_next_ex().

const char* pcap_lib_version void   ) 
 

Definition at line 761 of file pcap.c.

References PacketGetVersion(), pcap_version_string, pcap_version_string_fmt, pcap_version_string_packet_dll_fmt, and wpcap_version_string.

int pcap_list_datalinks pcap_t p,
int **  dlt_buffer
 

Definition at line 255 of file pcap.c.

References pcap_strerror(), and snprintf.

void pcap_oneshot u_char *  userData,
const struct pcap_pkthdr h,
const u_char *  pkt
[static]
 

Definition at line 141 of file pcap.c.

Referenced by pcap_next().

int pcap_read pcap_t p,
int  cnt,
pcap_handler  callback,
u_char *  user
 

Definition at line 84 of file pcap.c.

int pcap_set_datalink pcap_t p,
int  dlt
 

Definition at line 286 of file pcap.c.

References pcap_datalink_val_to_name(), and snprintf.

int pcap_stats_dead pcap_t p,
struct pcap_stat ps
[static]
 

Definition at line 696 of file pcap.c.

References PCAP_ERRBUF_SIZE, and snprintf.

Referenced by pcap_open_dead().

int pcap_strcasecmp const char *  s1,
const char *  s2
 

Definition at line 447 of file pcap.c.

References charmap.

Referenced by pcap_datalink_name_to_val().

char* pcap_win32strerror void   ) 
 

Definition at line 640 of file pcap.c.

References PCAP_ERRBUF_SIZE.

Referenced by pcap_lookupdev(), pcap_open_live(), pcap_setfilter_win32(), pcap_setnonblock_win32(), pcap_stats_ex(), and pcap_stats_win32().


Variable Documentation

const char rcsid [] _U_ [static]
 

Initial value:

"@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.63.2.9 2004/03/25 22:40:52 guy Exp $ (LBL)"

Definition at line 35 of file pcap.c.

const u_char charmap[] [static]
 

Definition at line 379 of file pcap.c.

Referenced by pcap_strcasecmp().

struct dlt_choice dlt_choices[] [static]
 

Definition at line 340 of file pcap.c.

Referenced by pcap_datalink_name_to_val(), pcap_datalink_val_to_description(), and pcap_datalink_val_to_name().

char* pcap_version_string [static]
 

Definition at line 758 of file pcap.c.

Referenced by pcap_lib_version().

const char pcap_version_string_fmt[] [static]
 

Initial value:

"WinPcap version %s, based on libpcap version 0.8.3"

Definition at line 754 of file pcap.c.

Referenced by pcap_lib_version().

const char pcap_version_string_packet_dll_fmt[] [static]
 

Initial value:

"WinPcap version %s (packet.dll version %s), based on libpcap version 0.8.3"

Definition at line 756 of file pcap.c.

Referenced by pcap_lib_version().

const char wpcap_version_string[] = "3.1 beta4" [static]
 

Definition at line 753 of file pcap.c.

Referenced by pcap_lib_version().


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