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-npf.c File Reference
#include <errno.h>
#include <Packet32.h>
#include <pcap-int.h>
#include <pcap/dlt.h>
#include <ntddndis.h>
#include "diag-control.h"
#include "pcap-airpcap.h"
Include dependency graph for pcap-npf.c:

Go to the source code of this file.

Data Structures

struct  pcap_win
 

Macros

#define PCAP_DONT_INCLUDE_PCAP_BPF_H
 
#define BPF_RET   0x06
 
#define BPF_K   0x00
 
#define WIN32_DEFAULT_USER_BUFFER_SIZE   256000
 
#define WIN32_DEFAULT_KERNEL_BUFFER_SIZE   1000000
 
#define SWAPS(_X)   ((_X & 0xff) << 8) | (_X >> 8)
 
#define NDIS_STATUS_INVALID_OID   0xc0010017
 
#define NDIS_STATUS_NOT_SUPPORTED   0xc00000bb /* STATUS_NOT_SUPPORTED */
 
#define NDIS_STATUS_NOT_RECOGNIZED   0x00010001
 
#define bhp   ((struct bpf_hdr *)bp)
 
#define NPF_SURFACE_MOBILE_NONPROMISC   0xe00000bb
 
#define ADAPTERSNAME_LEN   8192
 

Functions

static int pcap_setfilter_npf (pcap_t *, struct bpf_program *)
 
static int pcap_setfilter_win32_dag (pcap_t *, struct bpf_program *)
 
static int pcap_getnonblock_npf (pcap_t *)
 
static int pcap_setnonblock_npf (pcap_t *, int)
 
static int PacketIsMonitorModeSupported (PCHAR AdapterName)
 
static int PacketSetMonitorMode (PCHAR AdapterName, int mode)
 
static int PacketGetMonitorMode (PCHAR AdapterName)
 
static int oid_get_request (ADAPTER *adapter, bpf_u_int32 oid, void *data, size_t *lenp, char *errbuf)
 
static int pcap_stats_npf (pcap_t *p, struct pcap_stat *ps)
 
static struct pcap_statpcap_stats_ex_npf (pcap_t *p, int *pcap_stat_size)
 
static int pcap_setbuff_npf (pcap_t *p, int dim)
 
static int pcap_setmode_npf (pcap_t *p, int mode)
 
static int pcap_setmintocopy_npf (pcap_t *p, int size)
 
static HANDLE pcap_getevent_npf (pcap_t *p)
 
static int pcap_oid_get_request_npf (pcap_t *p, bpf_u_int32 oid, void *data, size_t *lenp)
 
static int pcap_oid_set_request_npf (pcap_t *p, bpf_u_int32 oid, const void *data, size_t *lenp)
 
static u_int pcap_sendqueue_transmit_npf (pcap_t *p, pcap_send_queue *queue, int sync)
 
static int pcap_setuserbuffer_npf (pcap_t *p, int size)
 
static int pcap_live_dump_npf (pcap_t *p, char *filename, int maxsize, int maxpacks)
 
static int pcap_live_dump_ended_npf (pcap_t *p, int sync)
 
static PAirpcapHandle pcap_get_airpcap_handle_npf (pcap_t *p)
 
static int pcap_read_npf (pcap_t *p, int cnt, pcap_handler callback, u_char *user)
 
static int pcap_inject_npf (pcap_t *p, const void *buf, int size)
 
static void pcap_cleanup_npf (pcap_t *p)
 
static void pcap_breakloop_npf (pcap_t *p)
 
static int pcap_activate_npf (pcap_t *p)
 
static int pcap_can_set_rfmon_npf (pcap_t *p)
 
pcap_tpcap_create_interface (const char *device, char *ebuf)
 
static int pcap_add_if_npf (pcap_if_list_t *devlistp, char *name, bpf_u_int32 flags, const char *description, char *errbuf)
 
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)
 
char * pcap_lookupdev (char *errbuf)
 
int pcap_lookupnet (const char *device, bpf_u_int32 *netp, bpf_u_int32 *maskp, char *errbuf)
 
const char * pcap_lib_version (void)
 

Variables

static const char * pcap_lib_version_string
 

Macro Definition Documentation

◆ ADAPTERSNAME_LEN

#define ADAPTERSNAME_LEN   8192

Definition at line 2270 of file pcap-npf.c.

◆ bhp

#define bhp   ((struct bpf_hdr *)bp)

◆ BPF_K

#define BPF_K   0x00

Definition at line 53 of file pcap-npf.c.

◆ BPF_RET

#define BPF_RET   0x06

Definition at line 52 of file pcap-npf.c.

◆ NDIS_STATUS_INVALID_OID

#define NDIS_STATUS_INVALID_OID   0xc0010017

Definition at line 154 of file pcap-npf.c.

◆ NDIS_STATUS_NOT_RECOGNIZED

#define NDIS_STATUS_NOT_RECOGNIZED   0x00010001

Definition at line 156 of file pcap-npf.c.

◆ NDIS_STATUS_NOT_SUPPORTED

#define NDIS_STATUS_NOT_SUPPORTED   0xc00000bb /* STATUS_NOT_SUPPORTED */

Definition at line 155 of file pcap-npf.c.

◆ NPF_SURFACE_MOBILE_NONPROMISC

#define NPF_SURFACE_MOBILE_NONPROMISC   0xe00000bb

Definition at line 961 of file pcap-npf.c.

◆ PCAP_DONT_INCLUDE_PCAP_BPF_H

#define PCAP_DONT_INCLUDE_PCAP_BPF_H

Definition at line 39 of file pcap-npf.c.

◆ SWAPS

#define SWAPS (   _X)    ((_X & 0xff) << 8) | (_X >> 8)

Definition at line 85 of file pcap-npf.c.

◆ WIN32_DEFAULT_KERNEL_BUFFER_SIZE

#define WIN32_DEFAULT_KERNEL_BUFFER_SIZE   1000000

Definition at line 82 of file pcap-npf.c.

◆ WIN32_DEFAULT_USER_BUFFER_SIZE

#define WIN32_DEFAULT_USER_BUFFER_SIZE   256000

Definition at line 79 of file pcap-npf.c.

Function Documentation

◆ get_if_flags()

◆ oid_get_request()

static int oid_get_request ( ADAPTER *  adapter,
bpf_u_int32  oid,
void *  data,
size_t *  lenp,
char *  errbuf 
)
static

Definition at line 159 of file pcap-npf.c.

References FALSE, PCAP_ERRBUF_SIZE, PCAP_ERROR, and snprintf().

Referenced by get_if_flags(), and pcap_oid_get_request_npf().

◆ PacketGetMonitorMode()

static int PacketGetMonitorMode ( PCHAR  AdapterName)
static

Definition at line 133 of file pcap-npf.c.

Referenced by pcap_activate_npf().

◆ PacketIsMonitorModeSupported()

static int PacketIsMonitorModeSupported ( PCHAR  AdapterName)
static

Definition at line 113 of file pcap-npf.c.

Referenced by pcap_can_set_rfmon_npf().

◆ PacketSetMonitorMode()

static int PacketSetMonitorMode ( PCHAR  AdapterName,
int  mode 
)
static

Definition at line 122 of file pcap-npf.c.

Referenced by pcap_activate_npf(), and pcap_cleanup_npf().

◆ pcap_activate_npf()

static int pcap_activate_npf ( pcap_t p)
static

Definition at line 964 of file pcap-npf.c.

References pcap_win::adapter, bpf_program::bf_insns, bpf_program::bf_len, BPF_K, BPF_RET, pcap::breakloop_op, pcap::buffer, pcap_opt::buffer_size, pcap::bufsize, pcap::cleanup_op, pcap_opt::device, DLT_ARCNET, DLT_ATM_RFC1483, DLT_CHDLC, pcap::dlt_count, DLT_DOCSIS, DLT_EN10MB, DLT_FDDI, DLT_IEEE802, DLT_IEEE802_11, DLT_IEEE802_11_RADIO, pcap::dlt_list, DLT_NULL, DLT_PPI, DLT_PPP_SERIAL, DLT_RAW, pcap::errbuf, errno, FALSE, pcap::getnonblock_op, pcap_opt::immediate, pcap::inject_op, pcap::linktype, MAXIMUM_SNAPLEN, NPF_SURFACE_MOBILE_NONPROMISC, pcap::opt, PacketGetMonitorMode(), PacketSetMonitorMode(), pcap_breakloop_npf(), pcap_cleanup_npf(), PCAP_ERRBUF_SIZE, PCAP_ERROR, PCAP_ERROR_NO_SUCH_DEVICE, PCAP_ERROR_PERM_DENIED, PCAP_ERROR_RFMON_NOTSUP, pcap_fmt_errmsg_for_errno(), pcap_get_airpcap_handle_npf(), pcap_getevent_npf(), pcap_getnonblock_npf(), pcap_inject_npf(), pcap_live_dump_ended_npf(), pcap_live_dump_npf(), pcap_oid_get_request_npf(), pcap_oid_set_request_npf(), pcap_read_npf(), pcap_sendqueue_transmit_npf(), pcap_setbuff_npf(), pcap_setfilter_npf(), pcap_setfilter_win32_dag(), pcap_setmintocopy_npf(), pcap_setmode_npf(), pcap_setnonblock_npf(), pcap_setuserbuffer_npf(), pcap_stats_ex_npf(), pcap_stats_npf(), PCAP_TSTAMP_HOST, PCAP_TSTAMP_HOST_HIPREC, PCAP_TSTAMP_HOST_HIPREC_UNSYNCED, PCAP_TSTAMP_HOST_LOWPREC, PCAP_WARNING, pcap::priv, pcap_opt::promisc, pcap::read_op, pcap_opt::rfmon, pcap_win::rfmon_selfstart, pcap::set_datalink_op, pcap::setdirection_op, pcap::setfilter_op, pcap::setnonblock_op, pcap::snapshot, snprintf(), pcap::stats_op, pcap_opt::timeout, total_insn, pcap_opt::tstamp_type, WIN32_DEFAULT_KERNEL_BUFFER_SIZE, and WIN32_DEFAULT_USER_BUFFER_SIZE.

Referenced by pcap_create_interface().

◆ pcap_add_if_npf()

static int pcap_add_if_npf ( pcap_if_list_t devlistp,
char *  name,
bpf_u_int32  flags,
const char *  description,
char *  errbuf 
)
static

Definition at line 1802 of file pcap-npf.c.

References add_addr_to_dev(), and add_dev().

Referenced by pcap_platform_finddevs().

◆ pcap_breakloop_npf()

static void pcap_breakloop_npf ( pcap_t p)
static

Definition at line 933 of file pcap-npf.c.

References pcap_win::adapter, pcap_breakloop_common(), and pcap::priv.

Referenced by pcap_activate_npf().

◆ pcap_can_set_rfmon_npf()

static int pcap_can_set_rfmon_npf ( pcap_t p)
static

Definition at line 1496 of file pcap-npf.c.

References pcap_opt::device, pcap::opt, and PacketIsMonitorModeSupported().

Referenced by pcap_create_interface().

◆ pcap_cleanup_npf()

static void pcap_cleanup_npf ( pcap_t p)
static

◆ pcap_create_interface()

◆ pcap_get_airpcap_handle_npf()

static PAirpcapHandle pcap_get_airpcap_handle_npf ( pcap_t p)
static

Definition at line 499 of file pcap-npf.c.

Referenced by pcap_activate_npf().

◆ pcap_getevent_npf()

static HANDLE pcap_getevent_npf ( pcap_t p)
static

Definition at line 342 of file pcap-npf.c.

References pcap_win::adapter, and pcap::priv.

Referenced by pcap_activate_npf().

◆ pcap_getnonblock_npf()

static int pcap_getnonblock_npf ( pcap_t p)
static

Definition at line 1757 of file pcap-npf.c.

References pcap_win::nonblock, and pcap::priv.

Referenced by pcap_activate_npf().

◆ pcap_inject_npf()

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

Definition at line 896 of file pcap-npf.c.

References pcap_win::adapter, pcap::errbuf, FALSE, PCAP_ERRBUF_SIZE, pcap::priv, and TRUE.

Referenced by pcap_activate_npf().

◆ pcap_lib_version()

const char* pcap_lib_version ( void  )

Definition at line 2525 of file pcap-npf.c.

References pcap_asprintf(), pcap_lib_version_string, and PCAP_VERSION_STRING.

◆ pcap_live_dump_ended_npf()

static int pcap_live_dump_ended_npf ( pcap_t p,
int  sync 
)
static

Definition at line 482 of file pcap-npf.c.

References pcap_win::adapter, pcap::priv, and sync().

Referenced by pcap_activate_npf().

◆ pcap_live_dump_npf()

static int pcap_live_dump_npf ( pcap_t p,
char *  filename,
int  maxsize,
int  maxpacks 
)
static

Definition at line 449 of file pcap-npf.c.

References pcap_win::adapter, pcap::errbuf, FALSE, PCAP_ERRBUF_SIZE, pcap::priv, and snprintf().

Referenced by pcap_activate_npf().

◆ 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 
)

Definition at line 2428 of file pcap-npf.c.

◆ pcap_oid_get_request_npf()

static int pcap_oid_get_request_npf ( pcap_t p,
bpf_u_int32  oid,
void *  data,
size_t *  lenp 
)
static

Definition at line 350 of file pcap-npf.c.

References pcap_win::adapter, pcap::errbuf, oid_get_request(), and pcap::priv.

Referenced by pcap_activate_npf().

◆ pcap_oid_set_request_npf()

static int pcap_oid_set_request_npf ( pcap_t p,
bpf_u_int32  oid,
const void *  data,
size_t *  lenp 
)
static

Definition at line 358 of file pcap-npf.c.

References pcap_win::adapter, pcap::errbuf, PCAP_ERRBUF_SIZE, PCAP_ERROR, pcap::priv, snprintf(), and TRUE.

Referenced by pcap_activate_npf().

◆ pcap_platform_finddevs()

int pcap_platform_finddevs ( pcap_if_list_t devlistp,
char *  errbuf 
)

◆ pcap_read_npf()

◆ pcap_sendqueue_transmit_npf()

static u_int pcap_sendqueue_transmit_npf ( pcap_t p,
pcap_send_queue *  queue,
int  sync 
)
static

Definition at line 401 of file pcap-npf.c.

References pcap_win::adapter, pcap::errbuf, PCAP_ERRBUF_SIZE, pcap::priv, and sync().

Referenced by pcap_activate_npf().

◆ pcap_setbuff_npf()

static int pcap_setbuff_npf ( pcap_t p,
int  dim 
)
static

Definition at line 300 of file pcap-npf.c.

References pcap_win::adapter, pcap::errbuf, FALSE, PCAP_ERRBUF_SIZE, pcap::priv, and snprintf().

Referenced by pcap_activate_npf().

◆ pcap_setfilter_npf()

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

◆ pcap_setfilter_win32_dag()

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

Definition at line 1741 of file pcap-npf.c.

References pcap::errbuf, install_bpf_program(), and pcap_strlcpy().

Referenced by pcap_activate_npf().

◆ pcap_setmintocopy_npf()

static int pcap_setmintocopy_npf ( pcap_t p,
int  size 
)
static

Definition at line 329 of file pcap-npf.c.

References pcap_win::adapter, pcap::errbuf, FALSE, PCAP_ERRBUF_SIZE, pcap::priv, and snprintf().

Referenced by pcap_activate_npf().

◆ pcap_setmode_npf()

static int pcap_setmode_npf ( pcap_t p,
int  mode 
)
static

Definition at line 314 of file pcap-npf.c.

References pcap_win::adapter, pcap::errbuf, FALSE, PCAP_ERRBUF_SIZE, pcap::priv, and snprintf().

Referenced by pcap_activate_npf().

◆ pcap_setnonblock_npf()

static int pcap_setnonblock_npf ( pcap_t p,
int  nonblock 
)
static

◆ pcap_setuserbuffer_npf()

static int pcap_setuserbuffer_npf ( pcap_t p,
int  size 
)
static

Definition at line 420 of file pcap-npf.c.

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

Referenced by pcap_activate_npf().

◆ pcap_stats_ex_npf()

static struct pcap_stat* pcap_stats_ex_npf ( pcap_t p,
int *  pcap_stat_size 
)
static

Definition at line 265 of file pcap-npf.c.

References pcap_win::adapter, pcap::errbuf, PCAP_ERRBUF_SIZE, and pcap::priv.

Referenced by pcap_activate_npf().

◆ pcap_stats_npf()

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

Variable Documentation

◆ pcap_lib_version_string

const char* pcap_lib_version_string
static

Definition at line 2464 of file pcap-npf.c.

Referenced by pcap_lib_version().