libpcap  1.10.1
About: libpcap is a packet filter library used by tools like tcpdump.
  Fossies Dox: libpcap-1.10.1.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pcap.c File Reference
#include <pcap-types.h>
#include <sys/param.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
#include "diag-control.h"
#include "pcap-int.h"
#include "optimize.h"
Include dependency graph for pcap.c:

Go to the source code of this file.

Data Structures

struct  pcap_if_list
 
struct  capture_source_type
 
struct  dlt_choice
 
struct  tstamp_type_choice
 

Macros

#define IF_NAMESIZE   IFNAMSIZ
 
#define DLT_CHOICE(code, description)   { #code, description, DLT_ ## code }
 
#define DLT_CHOICE_SENTINEL   { NULL, NULL, 0 }
 

Functions

int pcap_init (unsigned int opts, char *errbuf)
 
static void pcap_set_not_initialized_message (pcap_t *pcap)
 
static int pcap_read_not_initialized (pcap_t *pcap, int cnt, pcap_handler callback, u_char *user)
 
static int pcap_inject_not_initialized (pcap_t *pcap, const void *buf, int size)
 
static int pcap_setfilter_not_initialized (pcap_t *pcap, struct bpf_program *fp)
 
static int pcap_setdirection_not_initialized (pcap_t *pcap, pcap_direction_t d)
 
static int pcap_set_datalink_not_initialized (pcap_t *pcap, int dlt)
 
static int pcap_getnonblock_not_initialized (pcap_t *pcap)
 
static int pcap_stats_not_initialized (pcap_t *pcap, struct pcap_stat *ps)
 
int pcap_can_set_rfmon (pcap_t *p)
 
static int pcap_cant_set_rfmon (pcap_t *p)
 
int pcap_list_tstamp_types (pcap_t *p, int **tstamp_typesp)
 
void pcap_free_tstamp_types (int *tstamp_type_list)
 
void pcap_oneshot (u_char *user, const struct pcap_pkthdr *h, const u_char *pkt)
 
const u_char * pcap_next (pcap_t *p, struct pcap_pkthdr *h)
 
int pcap_next_ex (pcap_t *p, struct pcap_pkthdr **pkt_header, const u_char **pkt_data)
 
int pcap_findalldevs (pcap_if_t **alldevsp, char *errbuf)
 
static struct sockaddr * dup_sockaddr (struct sockaddr *sa, size_t sa_length)
 
static u_int get_figure_of_merit (pcap_if_t *dev)
 
static char * get_if_description (const char *name)
 
pcap_if_tfind_or_add_if (pcap_if_list_t *devlistp, const char *name, bpf_u_int32 if_flags, get_if_flags_func get_flags_func, char *errbuf)
 
int add_addr_to_if (pcap_if_list_t *devlistp, const char *name, bpf_u_int32 if_flags, get_if_flags_func get_flags_func, struct sockaddr *addr, size_t addr_size, struct sockaddr *netmask, size_t netmask_size, struct sockaddr *broadaddr, size_t broadaddr_size, struct sockaddr *dstaddr, size_t dstaddr_size, char *errbuf)
 
int add_addr_to_dev (pcap_if_t *curdev, struct sockaddr *addr, size_t addr_size, struct sockaddr *netmask, size_t netmask_size, struct sockaddr *broadaddr, size_t broadaddr_size, struct sockaddr *dstaddr, size_t dstaddr_size, char *errbuf)
 
pcap_if_tfind_or_add_dev (pcap_if_list_t *devlistp, const char *name, bpf_u_int32 flags, get_if_flags_func get_flags_func, const char *description, char *errbuf)
 
pcap_if_tfind_dev (pcap_if_list_t *devlistp, const char *name)
 
pcap_if_tadd_dev (pcap_if_list_t *devlistp, const char *name, bpf_u_int32 flags, const char *description, char *errbuf)
 
void pcap_freealldevs (pcap_if_t *alldevs)
 
char * pcap_lookupdev (char *errbuf)
 
int pcap_lookupnet (const char *device, bpf_u_int32 *netp, bpf_u_int32 *maskp, char *errbuf)
 
pcap_tpcap_create (const char *device, char *errbuf)
 
static int pcap_setnonblock_unactivated (pcap_t *p, int nonblock)
 
static void initialize_ops (pcap_t *p)
 
static pcap_tpcap_alloc_pcap_t (char *ebuf, size_t total_size, size_t private_offset)
 
pcap_tpcap_create_common (char *ebuf, size_t total_size, size_t private_offset)
 
int pcap_check_activated (pcap_t *p)
 
int pcap_set_snaplen (pcap_t *p, int snaplen)
 
int pcap_set_promisc (pcap_t *p, int promisc)
 
int pcap_set_rfmon (pcap_t *p, int rfmon)
 
int pcap_set_timeout (pcap_t *p, int timeout_ms)
 
int pcap_set_tstamp_type (pcap_t *p, int tstamp_type)
 
int pcap_set_immediate_mode (pcap_t *p, int immediate)
 
int pcap_set_buffer_size (pcap_t *p, int buffer_size)
 
int pcap_set_tstamp_precision (pcap_t *p, int tstamp_precision)
 
int pcap_get_tstamp_precision (pcap_t *p)
 
int pcap_activate (pcap_t *p)
 
pcap_tpcap_open_live (const char *device, int snaplen, int promisc, int to_ms, char *errbuf)
 
pcap_tpcap_open_offline_common (char *ebuf, size_t total_size, size_t private_offset)
 
int pcap_dispatch (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)
 
void pcap_breakloop (pcap_t *p)
 
int pcap_datalink (pcap_t *p)
 
int pcap_datalink_ext (pcap_t *p)
 
int pcap_list_datalinks (pcap_t *p, int **dlt_buffer)
 
void pcap_free_datalinks (int *dlt_list)
 
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)
 
const char * pcap_datalink_val_to_description_or_dlt (int dlt)
 
int pcap_tstamp_type_name_to_val (const char *name)
 
const char * pcap_tstamp_type_val_to_name (int tstamp_type)
 
const char * pcap_tstamp_type_val_to_description (int tstamp_type)
 
int pcap_snapshot (pcap_t *p)
 
int pcap_is_swapped (pcap_t *p)
 
int pcap_major_version (pcap_t *p)
 
int pcap_minor_version (pcap_t *p)
 
int pcap_bufsize (pcap_t *p)
 
FILE * pcap_file (pcap_t *p)
 
int pcap_fileno (pcap_t *p)
 
int pcap_get_selectable_fd (pcap_t *p)
 
const struct timeval * pcap_get_required_select_timeout (pcap_t *p)
 
void pcap_perror (pcap_t *p, const char *prefix)
 
char * pcap_geterr (pcap_t *p)
 
int pcap_getnonblock (pcap_t *p, char *errbuf)
 
int pcap_getnonblock_fd (pcap_t *p)
 
int pcap_setnonblock (pcap_t *p, int nonblock, char *errbuf)
 
int pcap_setnonblock_fd (pcap_t *p, int nonblock)
 
const char * pcap_statustostr (int errnum)
 
const char * pcap_strerror (int errnum)
 
int pcap_setfilter (pcap_t *p, struct bpf_program *fp)
 
int pcap_setdirection (pcap_t *p, pcap_direction_t d)
 
int pcap_stats (pcap_t *p, struct pcap_stat *ps)
 
static void pcap_close_all (void)
 
int pcap_do_addexit (pcap_t *p)
 
void pcap_add_to_pcaps_to_close (pcap_t *p)
 
void pcap_remove_from_pcaps_to_close (pcap_t *p)
 
void pcap_breakloop_common (pcap_t *p)
 
void pcap_cleanup_live_common (pcap_t *p)
 
int pcap_sendpacket (pcap_t *p, const u_char *buf, int size)
 
int pcap_inject (pcap_t *p, const void *buf, size_t size)
 
void pcap_close (pcap_t *p)
 
int pcap_offline_filter (const struct bpf_program *fp, const struct pcap_pkthdr *h, const u_char *pkt)
 
static int pcap_can_set_rfmon_dead (pcap_t *p)
 
static int pcap_read_dead (pcap_t *p, int cnt, pcap_handler callback, u_char *user)
 
static int pcap_inject_dead (pcap_t *p, const void *buf, int size)
 
static int pcap_setfilter_dead (pcap_t *p, struct bpf_program *fp)
 
static int pcap_setdirection_dead (pcap_t *p, pcap_direction_t d)
 
static int pcap_set_datalink_dead (pcap_t *p, int dlt)
 
static int pcap_getnonblock_dead (pcap_t *p)
 
static int pcap_setnonblock_dead (pcap_t *p, int nonblock)
 
static int pcap_stats_dead (pcap_t *p, struct pcap_stat *ps)
 
static void pcap_cleanup_dead (pcap_t *p)
 
pcap_tpcap_open_dead_with_tstamp_precision (int linktype, int snaplen, u_int precision)
 
pcap_tpcap_open_dead (int linktype, int snaplen)
 

Variables

int pcap_new_api
 
int pcap_utf_8_mode
 
char pcap_version [] = PACKAGE_VERSION
 
static struct capture_source_type capture_source_types []
 
static const u_char charmap []
 
static struct dlt_choice dlt_choices []
 
static struct tstamp_type_choice tstamp_type_choices []
 
static struct pcappcaps_to_close
 
static int did_atexit
 

Macro Definition Documentation

◆ DLT_CHOICE

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

Definition at line 3148 of file pcap.c.

◆ DLT_CHOICE_SENTINEL

#define DLT_CHOICE_SENTINEL   { NULL, NULL, 0 }

Definition at line 3149 of file pcap.c.

◆ IF_NAMESIZE

#define IF_NAMESIZE   IFNAMSIZ

Function Documentation

◆ add_addr_to_dev()

int add_addr_to_dev ( pcap_if_t curdev,
struct sockaddr *  addr,
size_t  addr_size,
struct sockaddr *  netmask,
size_t  netmask_size,
struct sockaddr *  broadaddr,
size_t  broadaddr_size,
struct sockaddr *  dstaddr,
size_t  dstaddr_size,
char *  errbuf 
)

◆ add_addr_to_if()

int add_addr_to_if ( pcap_if_list_t devlistp,
const char *  name,
bpf_u_int32  if_flags,
get_if_flags_func  get_flags_func,
struct sockaddr *  addr,
size_t  addr_size,
struct sockaddr *  netmask,
size_t  netmask_size,
struct sockaddr *  broadaddr,
size_t  broadaddr_size,
struct sockaddr *  dstaddr,
size_t  dstaddr_size,
char *  errbuf 
)

Definition at line 1072 of file pcap.c.

References add_addr_to_dev(), and find_or_add_if().

Referenced by pcap_findalldevs_interfaces().

◆ add_dev()

◆ dup_sockaddr()

static struct sockaddr* dup_sockaddr ( struct sockaddr *  sa,
size_t  sa_length 
)
static

Definition at line 757 of file pcap.c.

Referenced by add_addr_to_dev().

◆ find_dev()

pcap_if_t* find_dev ( pcap_if_list_t devlistp,
const char *  name 
)

Definition at line 1274 of file pcap.c.

References pcap_if_list::beginning, pcap_if::name, and pcap_if::next.

Referenced by find_or_add_dev(), and snf_findalldevs().

◆ find_or_add_dev()

pcap_if_t* find_or_add_dev ( pcap_if_list_t devlistp,
const char *  name,
bpf_u_int32  flags,
get_if_flags_func  get_flags_func,
const char *  description,
char *  errbuf 
)

Definition at line 1233 of file pcap.c.

References add_dev(), and find_dev().

Referenced by find_or_add_if(), and pcap_platform_finddevs().

◆ find_or_add_if()

pcap_if_t* find_or_add_if ( pcap_if_list_t devlistp,
const char *  name,
bpf_u_int32  if_flags,
get_if_flags_func  get_flags_func,
char *  errbuf 
)

◆ get_figure_of_merit()

static u_int get_figure_of_merit ( pcap_if_t dev)
static

◆ get_if_description()

static char* get_if_description ( const char *  name)
static

Definition at line 999 of file pcap.c.

Referenced by find_or_add_if().

◆ initialize_ops()

◆ pcap_activate()

◆ pcap_add_to_pcaps_to_close()

void pcap_add_to_pcaps_to_close ( pcap_t p)

Definition at line 3946 of file pcap.c.

References pcap::next, and pcaps_to_close.

Referenced by pcap_activate_bpf().

◆ pcap_alloc_pcap_t()

static pcap_t* pcap_alloc_pcap_t ( char *  ebuf,
size_t  total_size,
size_t  private_offset 
)
static

◆ pcap_breakloop()

void pcap_breakloop ( pcap_t p)

Definition at line 2921 of file pcap.c.

References pcap::breakloop_op.

Referenced by main(), session_close(), sigint_handler(), and stop_capture().

◆ pcap_breakloop_common()

◆ pcap_bufsize()

int pcap_bufsize ( pcap_t p)

Definition at line 3443 of file pcap.c.

References pcap::activated, pcap::bufsize, and PCAP_ERROR_NOT_ACTIVATED.

Referenced by daemon_msg_startcap_req().

◆ pcap_can_set_rfmon()

int pcap_can_set_rfmon ( pcap_t p)

Definition at line 500 of file pcap.c.

References pcap::can_set_rfmon_op.

Referenced by main().

◆ pcap_can_set_rfmon_dead()

static int pcap_can_set_rfmon_dead ( pcap_t p)
static

Definition at line 4167 of file pcap.c.

References pcap::errbuf, PCAP_ERRBUF_SIZE, PCAP_ERROR, and snprintf().

Referenced by pcap_open_dead_with_tstamp_precision().

◆ pcap_cant_set_rfmon()

static int pcap_cant_set_rfmon ( pcap_t p)
static

Definition at line 509 of file pcap.c.

Referenced by pcap_create_common().

◆ pcap_check_activated()

◆ pcap_cleanup_dead()

static void pcap_cleanup_dead ( pcap_t p)
static

Definition at line 4340 of file pcap.c.

Referenced by pcap_open_dead_with_tstamp_precision().

◆ pcap_cleanup_live_common()

◆ pcap_close()

◆ pcap_close_all()

static void pcap_close_all ( void  )
static

Definition at line 3897 of file pcap.c.

References pcap_close(), and pcaps_to_close.

Referenced by pcap_do_addexit().

◆ pcap_create()

◆ pcap_create_common()

◆ pcap_datalink()

int pcap_datalink ( pcap_t p)

Definition at line 2927 of file pcap.c.

References pcap::activated, pcap::linktype, and PCAP_ERROR_NOT_ACTIVATED.

Referenced by daemon_msg_open_req(), init_linktype(), and main().

◆ pcap_datalink_ext()

int pcap_datalink_ext ( pcap_t p)

Definition at line 2935 of file pcap.c.

References pcap::activated, pcap::linktype_ext, and PCAP_ERROR_NOT_ACTIVATED.

◆ pcap_datalink_name_to_val()

int pcap_datalink_name_to_val ( const char *  name)

Definition at line 3308 of file pcap.c.

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

Referenced by main().

◆ pcap_datalink_val_to_description()

const char* pcap_datalink_val_to_description ( int  dlt)

◆ pcap_datalink_val_to_description_or_dlt()

const char* pcap_datalink_val_to_description_or_dlt ( int  dlt)

◆ pcap_datalink_val_to_name()

const char* pcap_datalink_val_to_name ( int  dlt)

Definition at line 3320 of file pcap.c.

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

Referenced by main(), and pcap_set_datalink().

◆ pcap_dispatch()

int pcap_dispatch ( pcap_t p,
int  cnt,
pcap_handler  callback,
u_char *  user 
)

Definition at line 2882 of file pcap.c.

References pcap::read_op.

Referenced by capture_thread_func(), main(), and pcap_next().

◆ pcap_do_addexit()

int pcap_do_addexit ( pcap_t p)

Definition at line 3926 of file pcap.c.

References did_atexit, pcap::errbuf, pcap_close_all(), PCAP_ERRBUF_SIZE, and pcap_strlcpy().

Referenced by pcap_activate_bpf().

◆ pcap_file()

FILE* pcap_file ( pcap_t p)

Definition at line 3451 of file pcap.c.

References pcap::rfile.

◆ pcap_fileno()

int pcap_fileno ( pcap_t p)

Definition at line 3478 of file pcap.c.

References pcap::fd.

Referenced by main().

◆ pcap_findalldevs()

◆ pcap_free_datalinks()

void pcap_free_datalinks ( int *  dlt_list)

Definition at line 2987 of file pcap.c.

Referenced by main().

◆ pcap_free_tstamp_types()

void pcap_free_tstamp_types ( int *  tstamp_type_list)

Definition at line 568 of file pcap.c.

◆ pcap_freealldevs()

◆ pcap_get_required_select_timeout()

const struct timeval* pcap_get_required_select_timeout ( pcap_t p)

Definition at line 3492 of file pcap.c.

References pcap::required_select_timeout.

Referenced by main().

◆ pcap_get_selectable_fd()

int pcap_get_selectable_fd ( pcap_t p)

Definition at line 3486 of file pcap.c.

References pcap::selectable_fd.

Referenced by main().

◆ pcap_get_tstamp_precision()

int pcap_get_tstamp_precision ( pcap_t p)

Definition at line 2702 of file pcap.c.

References pcap::opt, and pcap_opt::tstamp_precision.

◆ pcap_geterr()

char* pcap_geterr ( pcap_t p)

◆ pcap_getnonblock()

int pcap_getnonblock ( pcap_t p,
char *  errbuf 
)

Definition at line 3511 of file pcap.c.

References pcap::errbuf, pcap::getnonblock_op, PCAP_ERRBUF_SIZE, and pcap_strlcpy().

◆ pcap_getnonblock_dead()

static int pcap_getnonblock_dead ( pcap_t p)
static

Definition at line 4216 of file pcap.c.

References pcap::errbuf, PCAP_ERRBUF_SIZE, and snprintf().

Referenced by pcap_open_dead_with_tstamp_precision().

◆ pcap_getnonblock_fd()

◆ pcap_getnonblock_not_initialized()

static int pcap_getnonblock_not_initialized ( pcap_t pcap)
static

Definition at line 387 of file pcap.c.

References PCAP_ERROR_NOT_ACTIVATED, and pcap_set_not_initialized_message().

Referenced by initialize_ops().

◆ pcap_init()

int pcap_init ( unsigned int  opts,
char *  errbuf 
)

◆ pcap_inject()

int pcap_inject ( pcap_t p,
const void *  buf,
size_t  size 
)

◆ pcap_inject_dead()

static int pcap_inject_dead ( pcap_t p,
const void *  buf,
int  size 
)
static

Definition at line 4184 of file pcap.c.

References pcap::errbuf, PCAP_ERRBUF_SIZE, and snprintf().

Referenced by pcap_open_dead_with_tstamp_precision().

◆ pcap_inject_not_initialized()

static int pcap_inject_not_initialized ( pcap_t pcap,
const void *  buf,
int  size 
)
static

Definition at line 355 of file pcap.c.

References PCAP_ERROR_NOT_ACTIVATED, and pcap_set_not_initialized_message().

Referenced by initialize_ops().

◆ pcap_is_swapped()

int pcap_is_swapped ( pcap_t p)

Definition at line 3419 of file pcap.c.

References pcap::activated, PCAP_ERROR_NOT_ACTIVATED, and pcap::swapped.

◆ pcap_list_datalinks()

int pcap_list_datalinks ( pcap_t p,
int **  dlt_buffer 
)

◆ pcap_list_tstamp_types()

int pcap_list_tstamp_types ( pcap_t p,
int **  tstamp_typesp 
)

◆ pcap_lookupdev()

char* pcap_lookupdev ( char *  errbuf)

◆ pcap_lookupnet()

int pcap_lookupnet ( const char *  device,
bpf_u_int32 netp,
bpf_u_int32 maskp,
char *  errbuf 
)

◆ pcap_loop()

int pcap_loop ( pcap_t p,
int  cnt,
pcap_handler  callback,
u_char *  user 
)

Definition at line 2888 of file pcap.c.

References PACKET_COUNT_IS_UNLIMITED, pcap_offline_read(), pcap::read_op, and pcap::rfile.

◆ pcap_major_version()

int pcap_major_version ( pcap_t p)

Definition at line 3427 of file pcap.c.

References pcap::activated, PCAP_ERROR_NOT_ACTIVATED, and pcap::version_major.

◆ pcap_minor_version()

int pcap_minor_version ( pcap_t p)

Definition at line 3435 of file pcap.c.

References pcap::activated, PCAP_ERROR_NOT_ACTIVATED, and pcap::version_minor.

◆ pcap_next()

const u_char* pcap_next ( pcap_t p,
struct pcap_pkthdr h 
)

◆ pcap_next_ex()

int pcap_next_ex ( pcap_t p,
struct pcap_pkthdr **  pkt_header,
const u_char **  pkt_data 
)

◆ pcap_offline_filter()

int pcap_offline_filter ( const struct bpf_program fp,
const struct pcap_pkthdr h,
const u_char *  pkt 
)

Definition at line 4155 of file pcap.c.

References bpf_program::bf_insns, pcap_pkthdr::caplen, pcap_pkthdr::len, and pcap_filter().

Referenced by LLVMFuzzerTestOneInput().

◆ pcap_oneshot()

void pcap_oneshot ( u_char *  user,
const struct pcap_pkthdr h,
const u_char *  pkt 
)

◆ pcap_open_dead()

pcap_t* pcap_open_dead ( int  linktype,
int  snaplen 
)

◆ pcap_open_dead_with_tstamp_precision()

◆ pcap_open_live()

◆ pcap_open_offline_common()

pcap_t* pcap_open_offline_common ( char *  ebuf,
size_t  total_size,
size_t  private_offset 
)

◆ pcap_perror()

void pcap_perror ( pcap_t p,
const char *  prefix 
)

Definition at line 3499 of file pcap.c.

References pcap::errbuf.

◆ pcap_read_dead()

static int pcap_read_dead ( pcap_t p,
int  cnt,
pcap_handler  callback,
u_char *  user 
)
static

Definition at line 4175 of file pcap.c.

References pcap::errbuf, PCAP_ERRBUF_SIZE, and snprintf().

Referenced by pcap_open_dead_with_tstamp_precision().

◆ pcap_read_not_initialized()

static int pcap_read_not_initialized ( pcap_t pcap,
int  cnt,
pcap_handler  callback,
u_char *  user 
)
static

Definition at line 346 of file pcap.c.

References PCAP_ERROR_NOT_ACTIVATED, and pcap_set_not_initialized_message().

Referenced by initialize_ops().

◆ pcap_remove_from_pcaps_to_close()

void pcap_remove_from_pcaps_to_close ( pcap_t p)

Definition at line 3953 of file pcap.c.

References pcap::next, and pcaps_to_close.

Referenced by pcap_cleanup_bpf(), and pcap_cleanup_linux().

◆ pcap_sendpacket()

int pcap_sendpacket ( pcap_t p,
const u_char *  buf,
int  size 
)

◆ pcap_set_buffer_size()

int pcap_set_buffer_size ( pcap_t p,
int  buffer_size 
)

Definition at line 2638 of file pcap.c.

References pcap_opt::buffer_size, pcap::opt, pcap_check_activated(), and PCAP_ERROR_ACTIVATED.

Referenced by main().

◆ pcap_set_datalink()

int pcap_set_datalink ( pcap_t p,
int  dlt 
)

◆ pcap_set_datalink_dead()

static int pcap_set_datalink_dead ( pcap_t p,
int  dlt 
)
static

Definition at line 4208 of file pcap.c.

References pcap::errbuf, PCAP_ERRBUF_SIZE, and snprintf().

Referenced by pcap_open_dead_with_tstamp_precision().

◆ pcap_set_datalink_not_initialized()

static int pcap_set_datalink_not_initialized ( pcap_t pcap,
int  dlt 
)
static

Definition at line 379 of file pcap.c.

References PCAP_ERROR_NOT_ACTIVATED, and pcap_set_not_initialized_message().

Referenced by initialize_ops().

◆ pcap_set_immediate_mode()

int pcap_set_immediate_mode ( pcap_t p,
int  immediate 
)

Definition at line 2629 of file pcap.c.

References pcap_opt::immediate, pcap::opt, pcap_check_activated(), and PCAP_ERROR_ACTIVATED.

Referenced by main(), and pcap_open().

◆ pcap_set_not_initialized_message()

◆ pcap_set_promisc()

int pcap_set_promisc ( pcap_t p,
int  promisc 
)

Definition at line 2557 of file pcap.c.

References pcap::opt, pcap_check_activated(), PCAP_ERROR_ACTIVATED, and pcap_opt::promisc.

Referenced by main(), pcap_open(), and pcap_open_live().

◆ pcap_set_rfmon()

int pcap_set_rfmon ( pcap_t p,
int  rfmon 
)

Definition at line 2566 of file pcap.c.

References pcap::opt, pcap_check_activated(), PCAP_ERROR_ACTIVATED, and pcap_opt::rfmon.

Referenced by main().

◆ pcap_set_snaplen()

int pcap_set_snaplen ( pcap_t p,
int  snaplen 
)

Definition at line 2548 of file pcap.c.

References pcap_check_activated(), PCAP_ERROR_ACTIVATED, and pcap::snapshot.

Referenced by main(), open_interface(), pcap_open(), and pcap_open_live().

◆ pcap_set_timeout()

int pcap_set_timeout ( pcap_t p,
int  timeout_ms 
)

◆ pcap_set_tstamp_precision()

◆ pcap_set_tstamp_type()

◆ pcap_setdirection()

int pcap_setdirection ( pcap_t p,
pcap_direction_t  d 
)

◆ pcap_setdirection_dead()

static int pcap_setdirection_dead ( pcap_t p,
pcap_direction_t  d 
)
static

Definition at line 4200 of file pcap.c.

References pcap::errbuf, PCAP_ERRBUF_SIZE, and snprintf().

Referenced by pcap_open_dead_with_tstamp_precision().

◆ pcap_setdirection_not_initialized()

static int pcap_setdirection_not_initialized ( pcap_t pcap,
pcap_direction_t  d 
)
static

Definition at line 371 of file pcap.c.

References PCAP_ERROR_NOT_ACTIVATED, and pcap_set_not_initialized_message().

Referenced by initialize_ops().

◆ pcap_setfilter()

int pcap_setfilter ( pcap_t p,
struct bpf_program fp 
)

Definition at line 3695 of file pcap.c.

References pcap::setfilter_op.

Referenced by daemon_unpackapplyfilter(), LLVMFuzzerTestOneInput(), and main().

◆ pcap_setfilter_dead()

static int pcap_setfilter_dead ( pcap_t p,
struct bpf_program fp 
)
static

Definition at line 4192 of file pcap.c.

References pcap::errbuf, PCAP_ERRBUF_SIZE, and snprintf().

Referenced by pcap_open_dead_with_tstamp_precision().

◆ pcap_setfilter_not_initialized()

static int pcap_setfilter_not_initialized ( pcap_t pcap,
struct bpf_program fp 
)
static

Definition at line 363 of file pcap.c.

References PCAP_ERROR_NOT_ACTIVATED, and pcap_set_not_initialized_message().

Referenced by initialize_ops().

◆ pcap_setnonblock()

int pcap_setnonblock ( pcap_t p,
int  nonblock,
char *  errbuf 
)

Definition at line 3555 of file pcap.c.

References pcap::errbuf, PCAP_ERRBUF_SIZE, pcap_strlcpy(), and pcap::setnonblock_op.

Referenced by main().

◆ pcap_setnonblock_dead()

static int pcap_setnonblock_dead ( pcap_t p,
int  nonblock 
)
static

Definition at line 4224 of file pcap.c.

References pcap::errbuf, PCAP_ERRBUF_SIZE, and snprintf().

Referenced by pcap_open_dead_with_tstamp_precision().

◆ pcap_setnonblock_fd()

◆ pcap_setnonblock_unactivated()

static int pcap_setnonblock_unactivated ( pcap_t p,
int  nonblock 
)
static

Definition at line 2382 of file pcap.c.

References pcap_opt::nonblock, and pcap::opt.

Referenced by pcap_create_common().

◆ pcap_snapshot()

int pcap_snapshot ( pcap_t p)

Definition at line 3411 of file pcap.c.

References pcap::activated, PCAP_ERROR_NOT_ACTIVATED, and pcap::snapshot.

Referenced by daemon_thrdatamain(), and pcap_compile().

◆ pcap_stats()

int pcap_stats ( pcap_t p,
struct pcap_stat ps 
)

◆ pcap_stats_dead()

static int pcap_stats_dead ( pcap_t p,
struct pcap_stat ps 
)
static

Definition at line 4232 of file pcap.c.

References pcap::errbuf, PCAP_ERRBUF_SIZE, and snprintf().

Referenced by pcap_open_dead_with_tstamp_precision().

◆ pcap_stats_not_initialized()

static int pcap_stats_not_initialized ( pcap_t pcap,
struct pcap_stat ps 
)
static

Definition at line 395 of file pcap.c.

References PCAP_ERROR_NOT_ACTIVATED, and pcap_set_not_initialized_message().

Referenced by initialize_ops().

◆ pcap_statustostr()

◆ pcap_strcasecmp()

int pcap_strcasecmp ( const char *  s1,
const char *  s2 
)

Definition at line 3130 of file pcap.c.

Referenced by pcap_datalink_name_to_val(), and pcap_tstamp_type_name_to_val().

◆ pcap_strerror()

const char* pcap_strerror ( int  errnum)

◆ pcap_tstamp_type_name_to_val()

int pcap_tstamp_type_name_to_val ( const char *  name)

◆ pcap_tstamp_type_val_to_description()

const char* pcap_tstamp_type_val_to_description ( int  tstamp_type)

◆ pcap_tstamp_type_val_to_name()

const char* pcap_tstamp_type_val_to_name ( int  tstamp_type)

Definition at line 3387 of file pcap.c.

References tstamp_type_choice::name, tstamp_type_choices, and tstamp_type_choice::type.

Variable Documentation

◆ capture_source_types

struct capture_source_type capture_source_types[]
static

Referenced by pcap_create(), and pcap_findalldevs().

◆ charmap

const u_char charmap[]
static

Definition at line 3062 of file pcap.c.

◆ did_atexit

int did_atexit
static

Definition at line 3894 of file pcap.c.

Referenced by pcap_do_addexit().

◆ dlt_choices

struct dlt_choice dlt_choices[]
static

◆ pcap_new_api

int pcap_new_api

Definition at line 240 of file pcap.c.

Referenced by pcap_create(), pcap_init(), and pcap_lookupdev().

◆ pcap_utf_8_mode

int pcap_utf_8_mode

Definition at line 241 of file pcap.c.

Referenced by pcap_init(), and rpcap_msg_err().

◆ pcap_version

char pcap_version = PACKAGE_VERSION

Definition at line 329 of file pcap.c.

◆ pcaps_to_close

struct pcap* pcaps_to_close
static

◆ tstamp_type_choices

struct tstamp_type_choice tstamp_type_choices[]
static
Initial value:
= {
{ "host", "Host", 0 },
{ "host_lowprec", "Host, low precision", 1 },
{ "host_hiprec", "Host, high precision", 2 },
{ "adapter", "Adapter", 3 },
{ "adapter_unsynced", "Adapter, not synced with system time", 4 },
{ "host_hiprec_unsynced", "Host, high precision, not synced with system time", 5 },
{ NULL, NULL, 0 }
}

Definition at line 3344 of file pcap.c.

Referenced by pcap_tstamp_type_name_to_val(), pcap_tstamp_type_val_to_description(), and pcap_tstamp_type_val_to_name().