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-bpf.c File Reference
#include <sys/param.h>
#include <sys/socket.h>
#include <time.h>
#include <sys/ioctl.h>
#include <sys/utsname.h>
#include <net/if.h>
#include <net/bpf.h>
#include <fcntl.h>
#include <errno.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "pcap-int.h"
Include dependency graph for pcap-bpf.c:

Go to the source code of this file.

Data Structures

struct  pcap_bpf
 

Macros

#define MUST_CLEAR_RFMON   0x00000001 /* clear rfmon (monitor) mode */
 
#define MUST_DESTROY_USBUS   0x00000002 /* destroy usbusN interface */
 
#define BPF_BIND_SUCCEEDED   0
 
#define BPF_BIND_BUFFER_TOO_BIG   1
 
#define bhp   ((struct bpf_hdr *)bp)
 
#define DEFAULT_BUFSIZE   524288
 

Functions

static int pcap_can_set_rfmon_bpf (pcap_t *p)
 
static int pcap_activate_bpf (pcap_t *p)
 
static int pcap_setfilter_bpf (pcap_t *p, struct bpf_program *fp)
 
static int pcap_setdirection_bpf (pcap_t *, pcap_direction_t)
 
static int pcap_set_datalink_bpf (pcap_t *p, int dlt)
 
static int pcap_getnonblock_bpf (pcap_t *p)
 
static int pcap_setnonblock_bpf (pcap_t *p, int nonblock)
 
pcap_tpcap_create_interface (const char *device, char *ebuf)
 
static int bpf_open (char *errbuf)
 
static int bpf_bind (int fd, const char *name, char *errbuf)
 
static int bpf_open_and_bind (const char *name, char *errbuf)
 
static int pcap_stats_bpf (pcap_t *p, struct pcap_stat *ps)
 
static int pcap_read_bpf (pcap_t *p, int cnt, pcap_handler callback, u_char *user)
 
static int pcap_inject_bpf (pcap_t *p, const void *buf, int size)
 
static void pcap_cleanup_bpf (pcap_t *p)
 
static int check_setif_failure (pcap_t *p, int error)
 
static int check_bpf_bindable (const char *name)
 
static int get_if_flags (const char *name, bpf_u_int32 *flags, char *errbuf)
 
int pcap_platform_finddevs (pcap_if_list_t *devlistp, char *errbuf)
 
const char * pcap_lib_version (void)
 

Macro Definition Documentation

◆ bhp

#define bhp   ((struct bpf_hdr *)bp)

◆ BPF_BIND_BUFFER_TOO_BIG

#define BPF_BIND_BUFFER_TOO_BIG   1

Definition at line 626 of file pcap-bpf.c.

◆ BPF_BIND_SUCCEEDED

#define BPF_BIND_SUCCEEDED   0

Definition at line 625 of file pcap-bpf.c.

◆ DEFAULT_BUFSIZE

#define DEFAULT_BUFSIZE   524288

Definition at line 1742 of file pcap-bpf.c.

◆ MUST_CLEAR_RFMON

#define MUST_CLEAR_RFMON   0x00000001 /* clear rfmon (monitor) mode */

Definition at line 180 of file pcap-bpf.c.

◆ MUST_DESTROY_USBUS

#define MUST_DESTROY_USBUS   0x00000002 /* destroy usbusN interface */

Definition at line 181 of file pcap-bpf.c.

Function Documentation

◆ bpf_bind()

static int bpf_bind ( int  fd,
const char *  name,
char *  errbuf 
)
static

◆ bpf_open()

static int bpf_open ( char *  errbuf)
static

◆ bpf_open_and_bind()

static int bpf_open_and_bind ( const char *  name,
char *  errbuf 
)
static

Definition at line 703 of file pcap-bpf.c.

References bpf_bind(), BPF_BIND_BUFFER_TOO_BIG, BPF_BIND_SUCCEEDED, bpf_open(), close(), and PCAP_ERROR.

Referenced by check_bpf_bindable().

◆ check_bpf_bindable()

static int check_bpf_bindable ( const char *  name)
static

◆ check_setif_failure()

static int check_setif_failure ( pcap_t p,
int  error 
)
static

Definition at line 1720 of file pcap-bpf.c.

References error().

Referenced by pcap_activate_bpf().

◆ get_if_flags()

static int get_if_flags ( const char *  name,
bpf_u_int32 flags,
char *  errbuf 
)
static

Definition at line 2971 of file pcap-bpf.c.

References PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE, and PCAP_IF_LOOPBACK.

Referenced by pcap_platform_finddevs().

◆ pcap_activate_bpf()

static int pcap_activate_bpf ( pcap_t p)
static

◆ pcap_can_set_rfmon_bpf()

static int pcap_can_set_rfmon_bpf ( pcap_t p)
static

Definition at line 1014 of file pcap-bpf.c.

Referenced by pcap_create_interface().

◆ pcap_cleanup_bpf()

◆ pcap_create_interface()

◆ pcap_getnonblock_bpf()

static int pcap_getnonblock_bpf ( pcap_t p)
static

Definition at line 258 of file pcap-bpf.c.

References pcap_getnonblock_fd(), and pcap::priv.

Referenced by pcap_activate_bpf().

◆ pcap_inject_bpf()

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

◆ pcap_lib_version()

const char* pcap_lib_version ( void  )

Definition at line 3590 of file pcap-bpf.c.

References PCAP_VERSION_STRING.

Referenced by dag_get_datalink(), printusage(), and usage().

◆ pcap_platform_finddevs()

int pcap_platform_finddevs ( pcap_if_list_t devlistp,
char *  errbuf 
)

◆ pcap_read_bpf()

◆ pcap_set_datalink_bpf()

static int pcap_set_datalink_bpf ( pcap_t p,
int  dlt 
)
static

Definition at line 3580 of file pcap-bpf.c.

Referenced by pcap_activate_bpf().

◆ pcap_setdirection_bpf()

static int pcap_setdirection_bpf ( pcap_t p,
pcap_direction_t  d 
)
static

Definition at line 3559 of file pcap-bpf.c.

References pcap::errbuf, and snprintf().

Referenced by pcap_activate_bpf().

◆ pcap_setfilter_bpf()

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

◆ pcap_setnonblock_bpf()

static int pcap_setnonblock_bpf ( pcap_t p,
int  nonblock 
)
static

Definition at line 270 of file pcap-bpf.c.

References pcap_setnonblock_fd(), and pcap::priv.

Referenced by pcap_activate_bpf().

◆ pcap_stats_bpf()

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