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-int.h File Reference
#include <stddef.h>
#include <signal.h>
#include <pcap/pcap.h>
#include "varattrs.h"
#include "fmtutils.h"
#include <stdarg.h>
#include "portability.h"
Include dependency graph for pcap-int.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pcap_opt
 
struct  pcap
 
struct  pcap_timeval
 
struct  pcap_sf_pkthdr
 
struct  pcap_sf_patched_pkthdr
 
struct  oneshot_userdata
 
struct  pcap_bpf_aux_data
 

Macros

#define PCAP_VERSION_STRING   "libpcap version " PACKAGE_VERSION
 
#define SWAPLL(ull)
 
#define MAXIMUM_SNAPLEN   262144
 
#define PCAP_ISDIGIT(c)    ((c) >= '0' && (c) <= '9')
 
#define PCAP_ISXDIGIT(c)
 
#define BPF_SPECIAL_VLAN_HANDLING   0x00000001 /* special VLAN handling for Linux */
 
#define min(a, b)   ((a) > (b) ? (b) : (a))
 
#define PACKET_COUNT_IS_UNLIMITED(count)   ((count) <= 0)
 
#define PCAP_CREATE_COMMON(ebuf, type)
 
#define PCAP_OPEN_OFFLINE_COMMON(ebuf, type)
 
#define charset_fopen(path, mode)   fopen((path), (mode))
 

Typedefs

typedef int(* activate_op_t) (pcap_t *)
 
typedef int(* can_set_rfmon_op_t) (pcap_t *)
 
typedef int(* read_op_t) (pcap_t *, int cnt, pcap_handler, u_char *)
 
typedef int(* next_packet_op_t) (pcap_t *, struct pcap_pkthdr *, u_char **)
 
typedef int(* inject_op_t) (pcap_t *, const void *, int)
 
typedef void(* save_current_filter_op_t) (pcap_t *, const char *)
 
typedef int(* setfilter_op_t) (pcap_t *, struct bpf_program *)
 
typedef int(* setdirection_op_t) (pcap_t *, pcap_direction_t)
 
typedef int(* set_datalink_op_t) (pcap_t *, int)
 
typedef int(* getnonblock_op_t) (pcap_t *)
 
typedef int(* setnonblock_op_t) (pcap_t *, int)
 
typedef int(* stats_op_t) (pcap_t *, struct pcap_stat *)
 
typedef void(* breakloop_op_t) (pcap_t *)
 
typedef void(* cleanup_op_t) (pcap_t *)
 
typedef struct pcap_if_list pcap_if_list_t
 
typedef int(* get_if_flags_func) (const char *, bpf_u_int32 *, char *)
 

Functions

int pcap_offline_read (pcap_t *, int, pcap_handler, u_char *)
 
int pcap_getnonblock_fd (pcap_t *)
 
int pcap_setnonblock_fd (pcap_t *p, int)
 
pcap_tpcap_create_interface (const char *, char *)
 
pcap_tpcap_create_common (char *, size_t, size_t)
 
int pcap_do_addexit (pcap_t *)
 
void pcap_add_to_pcaps_to_close (pcap_t *)
 
void pcap_remove_from_pcaps_to_close (pcap_t *)
 
void pcap_cleanup_live_common (pcap_t *)
 
int pcap_check_activated (pcap_t *)
 
void pcap_breakloop_common (pcap_t *)
 
int pcap_platform_finddevs (pcap_if_list_t *, char *)
 
int pcap_findalldevs_interfaces (pcap_if_list_t *, char *, int(*)(const char *), get_if_flags_func)
 
pcap_if_tfind_or_add_dev (pcap_if_list_t *, const char *, bpf_u_int32, get_if_flags_func, const char *, char *)
 
pcap_if_tfind_dev (pcap_if_list_t *, const char *)
 
pcap_if_tadd_dev (pcap_if_list_t *, const char *, bpf_u_int32, const char *, char *)
 
int add_addr_to_dev (pcap_if_t *, struct sockaddr *, size_t, struct sockaddr *, size_t, struct sockaddr *, size_t, struct sockaddr *dstaddr, size_t, char *errbuf)
 
pcap_if_tfind_or_add_if (pcap_if_list_t *, const char *, bpf_u_int32, get_if_flags_func, char *)
 
int add_addr_to_if (pcap_if_list_t *, const char *, bpf_u_int32, get_if_flags_func, struct sockaddr *, size_t, struct sockaddr *, size_t, struct sockaddr *, size_t, struct sockaddr *, size_t, char *)
 
pcap_tpcap_open_offline_common (char *ebuf, size_t total_size, size_t private_data)
 
bpf_u_int32 pcap_adjust_snapshot (bpf_u_int32 linktype, bpf_u_int32 snaplen)
 
void sf_cleanup (pcap_t *p)
 
u_int pcap_filter_with_aux_data (const struct bpf_insn *, const u_char *, u_int, u_int, const struct pcap_bpf_aux_data *)
 
u_int pcap_filter (const struct bpf_insn *, const u_char *, u_int, u_int)
 
int pcap_validate_filter (const struct bpf_insn *, int)
 
void pcap_oneshot (u_char *, const struct pcap_pkthdr *, const u_char *)
 
int install_bpf_program (pcap_t *, struct bpf_program *)
 
int pcap_strcasecmp (const char *, const char *)
 
int pcap_createsrcstr_ex (char *, int, const char *, const char *, const char *, unsigned char, char *)
 
int pcap_parsesrcstr_ex (const char *, int *, char *, char *, char *, unsigned char *, char *)
 

Variables

int pcap_new_api
 
int pcap_utf_8_mode
 

Macro Definition Documentation

◆ BPF_SPECIAL_VLAN_HANDLING

#define BPF_SPECIAL_VLAN_HANDLING   0x00000001 /* special VLAN handling for Linux */

Definition at line 352 of file pcap-int.h.

◆ charset_fopen

#define charset_fopen (   path,
  mode 
)    fopen((path), (mode))

Definition at line 572 of file pcap-int.h.

◆ MAXIMUM_SNAPLEN

#define MAXIMUM_SNAPLEN   262144

Definition at line 131 of file pcap-int.h.

◆ min

#define min (   a,
 
)    ((a) > (b) ? (b) : (a))

Definition at line 435 of file pcap-int.h.

◆ PACKET_COUNT_IS_UNLIMITED

#define PACKET_COUNT_IS_UNLIMITED (   count)    ((count) <= 0)

Definition at line 444 of file pcap-int.h.

◆ PCAP_CREATE_COMMON

#define PCAP_CREATE_COMMON (   ebuf,
  type 
)
Value:
sizeof (struct { pcap_t __common; type __private; }), \
offsetof (struct { pcap_t __common; type __private; }, __private))
#define offsetof(s, e)
Definition: gencode.c:91
pcap_t * pcap_create_common(char *, size_t, size_t)
Definition: pcap.c:2484
Definition: pcap-int.h:200

Definition at line 474 of file pcap-int.h.

◆ PCAP_ISDIGIT

#define PCAP_ISDIGIT (   c)     ((c) >= '0' && (c) <= '9')

Definition at line 138 of file pcap-int.h.

◆ PCAP_ISXDIGIT

#define PCAP_ISXDIGIT (   c)
Value:
(((c) >= '0' && (c) <= '9') || \
((c) >= 'A' && (c) <= 'F') || \
((c) >= 'a' && (c) <= 'f'))

Definition at line 140 of file pcap-int.h.

◆ PCAP_OPEN_OFFLINE_COMMON

#define PCAP_OPEN_OFFLINE_COMMON (   ebuf,
  type 
)
Value:
sizeof (struct { pcap_t __common; type __private; }), \
offsetof (struct { pcap_t __common; type __private; }, __private))
pcap_t * pcap_open_offline_common(char *ebuf, size_t total_size, size_t private_data)
Definition: pcap.c:2868

Definition at line 558 of file pcap-int.h.

◆ PCAP_VERSION_STRING

#define PCAP_VERSION_STRING   "libpcap version " PACKAGE_VERSION

Definition at line 59 of file pcap-int.h.

◆ SWAPLL

#define SWAPLL (   ull)
Value:
((ull & 0xff00000000000000ULL) >> 56) | \
((ull & 0x00ff000000000000ULL) >> 40) | \
((ull & 0x0000ff0000000000ULL) >> 24) | \
((ull & 0x000000ff00000000ULL) >> 8) | \
((ull & 0x00000000ff000000ULL) << 8) | \
((ull & 0x0000000000ff0000ULL) << 24) | \
((ull & 0x000000000000ff00ULL) << 40) | \
((ull & 0x00000000000000ffULL) << 56)

Definition at line 96 of file pcap-int.h.

Typedef Documentation

◆ activate_op_t

typedef int(* activate_op_t) (pcap_t *)

Definition at line 167 of file pcap-int.h.

◆ breakloop_op_t

typedef void(* breakloop_op_t) (pcap_t *)

Definition at line 179 of file pcap-int.h.

◆ can_set_rfmon_op_t

typedef int(* can_set_rfmon_op_t) (pcap_t *)

Definition at line 168 of file pcap-int.h.

◆ cleanup_op_t

typedef void(* cleanup_op_t) (pcap_t *)

Definition at line 194 of file pcap-int.h.

◆ get_if_flags_func

typedef int(* get_if_flags_func) (const char *, bpf_u_int32 *, char *)

Definition at line 509 of file pcap-int.h.

◆ getnonblock_op_t

typedef int(* getnonblock_op_t) (pcap_t *)

Definition at line 176 of file pcap-int.h.

◆ inject_op_t

typedef int(* inject_op_t) (pcap_t *, const void *, int)

Definition at line 171 of file pcap-int.h.

◆ next_packet_op_t

typedef int(* next_packet_op_t) (pcap_t *, struct pcap_pkthdr *, u_char **)

Definition at line 170 of file pcap-int.h.

◆ pcap_if_list_t

typedef struct pcap_if_list pcap_if_list_t

Definition at line 484 of file pcap-int.h.

◆ read_op_t

typedef int(* read_op_t) (pcap_t *, int cnt, pcap_handler, u_char *)

Definition at line 169 of file pcap-int.h.

◆ save_current_filter_op_t

typedef void(* save_current_filter_op_t) (pcap_t *, const char *)

Definition at line 172 of file pcap-int.h.

◆ set_datalink_op_t

typedef int(* set_datalink_op_t) (pcap_t *, int)

Definition at line 175 of file pcap-int.h.

◆ setdirection_op_t

typedef int(* setdirection_op_t) (pcap_t *, pcap_direction_t)

Definition at line 174 of file pcap-int.h.

◆ setfilter_op_t

typedef int(* setfilter_op_t) (pcap_t *, struct bpf_program *)

Definition at line 173 of file pcap-int.h.

◆ setnonblock_op_t

typedef int(* setnonblock_op_t) (pcap_t *, int)

Definition at line 177 of file pcap-int.h.

◆ stats_op_t

typedef int(* stats_op_t) (pcap_t *, struct pcap_stat *)

Definition at line 178 of file pcap-int.h.

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

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

◆ install_bpf_program()

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

bpf_u_int32 pcap_adjust_snapshot ( bpf_u_int32  linktype,
bpf_u_int32  snaplen 
)

Definition at line 444 of file savefile.c.

References max_snaplen_for_dlt().

Referenced by pcap_check_header(), pcap_ng_check_header(), and pcap_ng_next_packet().

◆ pcap_breakloop_common()

◆ pcap_check_activated()

◆ pcap_cleanup_live_common()

◆ pcap_create_common()

◆ pcap_create_interface()

◆ pcap_createsrcstr_ex()

int pcap_createsrcstr_ex ( char *  ,
int  ,
const char *  ,
const char *  ,
const char *  ,
unsigned char  ,
char *   
)

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

◆ pcap_filter_with_aux_data()

◆ pcap_findalldevs_interfaces()

int pcap_findalldevs_interfaces ( pcap_if_list_t devlistp,
char *  errbuf,
int(*)(const char *)  check_usable,
get_if_flags_func  get_flags_func 
)

◆ pcap_getnonblock_fd()

◆ pcap_offline_read()

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

◆ pcap_oneshot()

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

◆ pcap_open_offline_common()

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

◆ pcap_parsesrcstr_ex()

int pcap_parsesrcstr_ex ( const char *  ,
int *  ,
char *  ,
char *  ,
char *  ,
unsigned char *  ,
char *   
)

Referenced by rpcap_setup_session().

◆ pcap_platform_finddevs()

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

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

◆ sf_cleanup()

void sf_cleanup ( pcap_t p)

Definition at line 241 of file savefile.c.

References pcap::buffer, pcap::fcode, pcap_freecode(), and pcap::rfile.

Referenced by pcap_check_header(), and pcap_ng_cleanup().

Variable Documentation

◆ pcap_new_api

int pcap_new_api
extern

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
extern

Definition at line 241 of file pcap.c.

Referenced by pcap_init(), and rpcap_msg_err().