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-netfilter-linux.c File Reference
#include "pcap-int.h"
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <time.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <linux/types.h>
#include <linux/netlink.h>
#include <linux/netfilter.h>
#include <linux/netfilter/nfnetlink.h>
#include <linux/netfilter/nfnetlink_log.h>
#include <linux/netfilter/nfnetlink_queue.h>
#include "pcap-netfilter-linux.h"
Include dependency graph for pcap-netfilter-linux.c:

Go to the source code of this file.

Data Structures

struct  pcap_netfilter
 
struct  my_nfattr
 

Macros

#define HDR_LENGTH   (NLMSG_LENGTH(NLMSG_ALIGN(sizeof(struct nfgenmsg))))
 
#define NFLOG_IFACE   "nflog"
 
#define NFQUEUE_IFACE   "nfqueue"
 

Enumerations

enum  nftype_t { OTHER = -1 , NFLOG , NFQUEUE }
 

Functions

static int nfqueue_send_verdict (const pcap_t *handle, uint16_t group_id, u_int32_t id, u_int32_t verdict)
 
static int netfilter_read_linux (pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
 
static int netfilter_set_datalink (pcap_t *handle, int dlt)
 
static int netfilter_stats_linux (pcap_t *handle, struct pcap_stat *stats)
 
static int netfilter_inject_linux (pcap_t *handle, const void *buf, int size)
 
static int netfilter_send_config_msg (const pcap_t *handle, uint16_t msg_type, int ack, u_int8_t family, u_int16_t res_id, const struct my_nfattr *mynfa)
 
static int nflog_send_config_msg (const pcap_t *handle, uint8_t family, u_int16_t group_id, const struct my_nfattr *mynfa)
 
static int nflog_send_config_cmd (const pcap_t *handle, uint16_t group_id, u_int8_t cmd, u_int8_t family)
 
static int nflog_send_config_mode (const pcap_t *handle, uint16_t group_id, u_int8_t copy_mode, u_int32_t copy_range)
 
static int nfqueue_send_config_msg (const pcap_t *handle, uint8_t family, u_int16_t group_id, const struct my_nfattr *mynfa)
 
static int nfqueue_send_config_cmd (const pcap_t *handle, uint16_t group_id, u_int8_t cmd, u_int16_t pf)
 
static int nfqueue_send_config_mode (const pcap_t *handle, uint16_t group_id, u_int8_t copy_mode, u_int32_t copy_range)
 
static int netfilter_activate (pcap_t *handle)
 
pcap_tnetfilter_create (const char *device, char *ebuf, int *is_ours)
 
int netfilter_findalldevs (pcap_if_list_t *devlistp, char *err_str)
 

Macro Definition Documentation

◆ HDR_LENGTH

#define HDR_LENGTH   (NLMSG_LENGTH(NLMSG_ALIGN(sizeof(struct nfgenmsg))))

Definition at line 70 of file pcap-netfilter-linux.c.

◆ NFLOG_IFACE

#define NFLOG_IFACE   "nflog"

Definition at line 72 of file pcap-netfilter-linux.c.

◆ NFQUEUE_IFACE

#define NFQUEUE_IFACE   "nfqueue"

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

Enumeration Type Documentation

◆ nftype_t

enum nftype_t
Enumerator
OTHER 
NFLOG 
NFQUEUE 

Definition at line 75 of file pcap-netfilter-linux.c.

Function Documentation

◆ netfilter_activate()

◆ netfilter_create()

pcap_t* netfilter_create ( const char *  device,
char *  ebuf,
int *  is_ours 
)

◆ netfilter_findalldevs()

int netfilter_findalldevs ( pcap_if_list_t devlistp,
char *  err_str 
)

◆ netfilter_inject_linux()

static int netfilter_inject_linux ( pcap_t handle,
const void *  buf,
int  size 
)
static

Definition at line 320 of file pcap-netfilter-linux.c.

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

Referenced by netfilter_activate().

◆ netfilter_read_linux()

◆ netfilter_send_config_msg()

static int netfilter_send_config_msg ( const pcap_t handle,
uint16_t  msg_type,
int  ack,
u_int8_t  family,
u_int16_t  res_id,
const struct my_nfattr mynfa 
)
static

◆ netfilter_set_datalink()

static int netfilter_set_datalink ( pcap_t handle,
int  dlt 
)
static

Definition at line 302 of file pcap-netfilter-linux.c.

References pcap::linktype.

Referenced by netfilter_activate().

◆ netfilter_stats_linux()

static int netfilter_stats_linux ( pcap_t handle,
struct pcap_stat stats 
)
static

◆ nflog_send_config_cmd()

static int nflog_send_config_cmd ( const pcap_t handle,
uint16_t  group_id,
u_int8_t  cmd,
u_int8_t  family 
)
static

◆ nflog_send_config_mode()

static int nflog_send_config_mode ( const pcap_t handle,
uint16_t  group_id,
u_int8_t  copy_mode,
u_int32_t  copy_range 
)
static

◆ nflog_send_config_msg()

static int nflog_send_config_msg ( const pcap_t handle,
uint8_t  family,
u_int16_t  group_id,
const struct my_nfattr mynfa 
)
static

Definition at line 420 of file pcap-netfilter-linux.c.

References netfilter_send_config_msg().

Referenced by nflog_send_config_cmd(), and nflog_send_config_mode().

◆ nfqueue_send_config_cmd()

static int nfqueue_send_config_cmd ( const pcap_t handle,
uint16_t  group_id,
u_int8_t  cmd,
u_int16_t  pf 
)
static

◆ nfqueue_send_config_mode()

static int nfqueue_send_config_mode ( const pcap_t handle,
uint16_t  group_id,
u_int8_t  copy_mode,
u_int32_t  copy_range 
)
static

◆ nfqueue_send_config_msg()

static int nfqueue_send_config_msg ( const pcap_t handle,
uint8_t  family,
u_int16_t  group_id,
const struct my_nfattr mynfa 
)
static

◆ nfqueue_send_verdict()

static int nfqueue_send_verdict ( const pcap_t handle,
uint16_t  group_id,
u_int32_t  id,
u_int32_t  verdict 
)
static