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-usb-linux.c File Reference
#include "pcap-int.h"
#include "pcap-usb-linux.h"
#include "pcap/usb.h"
#include "extract.h"
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <limits.h>
#include <string.h>
#include <dirent.h>
#include <byteswap.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/utsname.h>
Include dependency graph for pcap-usb-linux.c:

Go to the source code of this file.

Data Structures

struct  mon_bin_stats
struct  mon_bin_get
struct  mon_bin_mfetch
struct  pcap_usb_linux


#define USB_IFACE   "usbmon"
#define USB_LINE_LEN   4096
#define htols(s)   s
#define htoll(l)   l
#define htol64(ll)   ll
#define MON_IOC_MAGIC   0x92
#define MON_IOCX_URB   _IOWR(MON_IOC_MAGIC, 2, struct mon_bin_hdr)
#define MON_IOCG_STATS   _IOR(MON_IOC_MAGIC, 3, struct mon_bin_stats)
#define MON_IOCX_GET   _IOW(MON_IOC_MAGIC, 6, struct mon_bin_get)
#define MON_IOCX_MFETCH   _IOWR(MON_IOC_MAGIC, 7, struct mon_bin_mfetch)
#define MON_BIN_SETUP   0x1 /* setup hdr is present*/
#define MON_BIN_SETUP_ZERO   0x2 /* setup buffer is not available */
#define MON_BIN_DATA_ZERO   0x4 /* data buffer is not available */
#define MON_BIN_ERROR   0x8
#define MIN_RING_SIZE   (8*1024)
#define MAX_RING_SIZE   (1200*1024)
#define VEC_SIZE   32


static int usb_activate (pcap_t *)
static int usb_stats_linux_bin (pcap_t *, struct pcap_stat *)
static int usb_read_linux_bin (pcap_t *, int, pcap_handler, u_char *)
static int usb_read_linux_mmap (pcap_t *, int, pcap_handler, u_char *)
static int usb_inject_linux (pcap_t *, const void *, int)
static int usb_setdirection_linux (pcap_t *, pcap_direction_t)
static void usb_cleanup_linux_mmap (pcap_t *)
static int usb_dev_add (pcap_if_list_t *devlistp, int n, char *err_str)
int usb_findalldevs (pcap_if_list_t *devlistp, char *err_str)
static int usb_set_ring_size (pcap_t *handle, int header_size)
static int usb_mmap (pcap_t *handle)
pcap_tusb_create (const char *device, char *ebuf, int *is_ours)

Macro Definition Documentation

◆ htol64

#define htol64 (   ll)    ll

Definition at line 79 of file pcap-usb-linux.c.

◆ htoll

#define htoll (   l)    l

Definition at line 78 of file pcap-usb-linux.c.

◆ htols

#define htols (   s)    s

Definition at line 77 of file pcap-usb-linux.c.


#define MAX_RING_SIZE   (1200*1024)

Definition at line 235 of file pcap-usb-linux.c.


#define MIN_RING_SIZE   (8*1024)

Definition at line 234 of file pcap-usb-linux.c.


#define MON_BIN_DATA_ZERO   0x4 /* data buffer is not available */

Definition at line 116 of file pcap-usb-linux.c.


#define MON_BIN_ERROR   0x8

Definition at line 117 of file pcap-usb-linux.c.


#define MON_BIN_SETUP   0x1 /* setup hdr is present*/

Definition at line 114 of file pcap-usb-linux.c.


#define MON_BIN_SETUP_ZERO   0x2 /* setup buffer is not available */

Definition at line 115 of file pcap-usb-linux.c.


#define MON_IOC_MAGIC   0x92

Definition at line 103 of file pcap-usb-linux.c.


#define MON_IOCG_STATS   _IOR(MON_IOC_MAGIC, 3, struct mon_bin_stats)

Definition at line 107 of file pcap-usb-linux.c.



Definition at line 112 of file pcap-usb-linux.c.



Definition at line 109 of file pcap-usb-linux.c.



Definition at line 105 of file pcap-usb-linux.c.



Definition at line 108 of file pcap-usb-linux.c.


#define MON_IOCX_GET   _IOW(MON_IOC_MAGIC, 6, struct mon_bin_get)

Definition at line 110 of file pcap-usb-linux.c.


#define MON_IOCX_MFETCH   _IOWR(MON_IOC_MAGIC, 7, struct mon_bin_mfetch)

Definition at line 111 of file pcap-usb-linux.c.


#define MON_IOCX_URB   _IOWR(MON_IOC_MAGIC, 2, struct mon_bin_hdr)

Definition at line 106 of file pcap-usb-linux.c.


#define USB_IFACE   "usbmon"

Definition at line 73 of file pcap-usb-linux.c.


#define USB_LINE_LEN   4096

Definition at line 74 of file pcap-usb-linux.c.


#define VEC_SIZE   32

Definition at line 753 of file pcap-usb-linux.c.

Function Documentation

◆ usb_activate()

◆ usb_cleanup_linux_mmap()

static void usb_cleanup_linux_mmap ( pcap_t handle)

◆ usb_create()

pcap_t* usb_create ( const char *  device,
char *  ebuf,
int *  is_ours 

◆ usb_dev_add()

static int usb_dev_add ( pcap_if_list_t devlistp,
int  n,
char *  err_str 

Definition at line 140 of file pcap-usb-linux.c.

References add_dev(), PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE, snprintf(), and USB_IFACE.

Referenced by usb_findalldevs().

◆ usb_findalldevs()

int usb_findalldevs ( pcap_if_list_t devlistp,
char *  err_str 

Definition at line 174 of file pcap-usb-linux.c.

References pcap_strlcpy(), sscanf(), and usb_dev_add().

◆ usb_inject_linux()

static int usb_inject_linux ( pcap_t handle,
const void *  buf,
int  size 

Definition at line 622 of file pcap-usb-linux.c.

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

Referenced by usb_activate().

◆ usb_mmap()

static int usb_mmap ( pcap_t handle)

◆ usb_read_linux_bin()

◆ usb_read_linux_mmap()

◆ usb_set_ring_size()

static int usb_set_ring_size ( pcap_t handle,
int  header_size 

◆ usb_setdirection_linux()

static int usb_setdirection_linux ( pcap_t p,
pcap_direction_t  d 

Definition at line 630 of file pcap-usb-linux.c.

References pcap::direction.

Referenced by usb_activate().

◆ usb_stats_linux_bin()