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-dlpi.c File Reference
#include <sys/types.h>
#include <sys/time.h>
#include <sys/dlpi.h>
#include <sys/stream.h>
#include <errno.h>
#include <fcntl.h>
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stropts.h>
#include <unistd.h>
#include <limits.h>
#include "pcap-int.h"
#include "dlpisubs.h"
Include dependency graph for pcap-dlpi.c:

Go to the source code of this file.

Macros

#define MAXDLBUF   8192
 
#define MAKE_DL_PRIMITIVES(ptr)   ((union DL_primitives *)(void *)(ptr))
 
#define STRINGIFY(n)   #n
 

Functions

static char * split_dname (char *, u_int *, char *)
 
static int dl_doattach (int, int, char *)
 
static int dlpromiscon (pcap_t *, bpf_u_int32)
 
static int dlbindreq (int, bpf_u_int32, char *)
 
static int dlbindack (int, char *, char *, int *)
 
static int dlokack (int, const char *, char *, char *)
 
static int dlinforeq (int, char *)
 
static int dlinfoack (int, char *, char *)
 
static int recv_ack (int, int, const char *, char *, char *, int *)
 
static char * dlstrerror (char *, size_t, bpf_u_int32)
 
static char * dlprim (char *, size_t, bpf_u_int32)
 
static int send_request (int, char *, int, char *, char *)
 
static int pcap_read_dlpi (pcap_t *p, int cnt, pcap_handler callback, u_char *user)
 
static int pcap_inject_dlpi (pcap_t *p, const void *buf, int size)
 
static void pcap_cleanup_dlpi (pcap_t *p)
 
static int open_dlpi_device (const char *name, u_int *ppa, char *errbuf)
 
static int pcap_activate_dlpi (pcap_t *p)
 
static int is_dlpi_interface (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)
 
pcap_tpcap_create_interface (const char *device, char *ebuf)
 
const char * pcap_lib_version (void)
 

Macro Definition Documentation

◆ MAKE_DL_PRIMITIVES

#define MAKE_DL_PRIMITIVES (   ptr)    ((union DL_primitives *)(void *)(ptr))

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

◆ MAXDLBUF

#define MAXDLBUF   8192

Definition at line 138 of file pcap-dlpi.c.

◆ STRINGIFY

#define STRINGIFY (   n)    #n

Definition at line 975 of file pcap-dlpi.c.

Function Documentation

◆ dl_doattach()

static int dl_doattach ( int  fd,
int  ppa,
char *  ebuf 
)
static

Definition at line 907 of file pcap-dlpi.c.

References dlokack(), MAXDLBUF, PCAP_ERROR, and send_request().

Referenced by pcap_activate_dlpi().

◆ dlbindack()

static int dlbindack ( int  fd,
char *  bufp,
char *  ebuf,
int *  uerror 
)
static

Definition at line 1448 of file pcap-dlpi.c.

References recv_ack().

Referenced by pcap_activate_dlpi().

◆ dlbindreq()

static int dlbindreq ( int  fd,
bpf_u_int32  sap,
char *  ebuf 
)
static

Definition at line 1428 of file pcap-dlpi.c.

References send_request().

Referenced by pcap_activate_dlpi().

◆ dlinfoack()

static int dlinfoack ( int  fd,
char *  bufp,
char *  ebuf 
)
static

Definition at line 1473 of file pcap-dlpi.c.

References recv_ack().

Referenced by pcap_activate_dlpi().

◆ dlinforeq()

static int dlinforeq ( int  fd,
char *  ebuf 
)
static

Definition at line 1463 of file pcap-dlpi.c.

References send_request().

Referenced by pcap_activate_dlpi().

◆ dlokack()

static int dlokack ( int  fd,
const char *  what,
char *  bufp,
char *  ebuf 
)
static

Definition at line 1455 of file pcap-dlpi.c.

References recv_ack().

Referenced by dl_doattach(), and dlpromiscon().

◆ dlprim()

static char * dlprim ( char *  primbuf,
size_t  primbufsize,
bpf_u_int32  prim 
)
static

Definition at line 1335 of file pcap-dlpi.c.

References snprintf().

Referenced by recv_ack().

◆ dlpromiscon()

static int dlpromiscon ( pcap_t p,
bpf_u_int32  level 
)
static

Definition at line 978 of file pcap-dlpi.c.

References dlokack(), pcap::errbuf, pcap::fd, MAXDLBUF, PCAP_ERROR, send_request(), and STRINGIFY.

Referenced by pcap_activate_dlpi().

◆ dlstrerror()

static char * dlstrerror ( char *  errbuf,
size_t  errbufsize,
bpf_u_int32  dl_errno 
)
static

Definition at line 1227 of file pcap-dlpi.c.

References snprintf().

Referenced by recv_ack().

◆ get_if_flags()

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

Definition at line 1047 of file pcap-dlpi.c.

References PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE, and PCAP_IF_LOOPBACK.

Referenced by pcap_platform_finddevs().

◆ is_dlpi_interface()

static int is_dlpi_interface ( const char *  name)
static

Definition at line 1004 of file pcap-dlpi.c.

References close(), open_dlpi_device(), PCAP_ERRBUF_SIZE, and PCAP_ERROR_NO_SUCH_DEVICE.

Referenced by pcap_platform_finddevs().

◆ open_dlpi_device()

static int open_dlpi_device ( const char *  name,
u_int *  ppa,
char *  errbuf 
)
static

◆ pcap_activate_dlpi()

◆ pcap_cleanup_dlpi()

static void pcap_cleanup_dlpi ( pcap_t p)
static

Definition at line 328 of file pcap-dlpi.c.

References close(), pcap_cleanup_live_common(), pd, and pcap::priv.

Referenced by pcap_activate_dlpi().

◆ pcap_create_interface()

pcap_t* pcap_create_interface ( const char *  device,
char *  ebuf 
)

Definition at line 1876 of file pcap-dlpi.c.

References pcap::activate_op, pcap_activate_dlpi(), PCAP_CREATE_COMMON, pd, and pcap::priv.

◆ pcap_inject_dlpi()

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

◆ pcap_lib_version()

const char* pcap_lib_version ( void  )

Definition at line 1900 of file pcap-dlpi.c.

References PCAP_VERSION_STRING.

◆ pcap_platform_finddevs()

int pcap_platform_finddevs ( pcap_if_list_t devlistp,
char *  errbuf 
)

◆ pcap_read_dlpi()

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

◆ recv_ack()

static int recv_ack ( int  fd,
int  size,
const char *  what,
char *  bufp,
char *  ebuf,
int *  uerror 
)
static

◆ send_request()

static int send_request ( int  fd,
char *  ptr,
int  len,
char *  what,
char *  ebuf 
)
static

Definition at line 1127 of file pcap-dlpi.c.

References errno, PCAP_ERRBUF_SIZE, and pcap_fmt_errmsg_for_errno().

Referenced by dl_doattach(), dlbindreq(), dlinforeq(), and dlpromiscon().

◆ split_dname()

static char * split_dname ( char *  device,
u_int *  unitp,
char *  ebuf 
)
static

Definition at line 866 of file pcap-dlpi.c.

References errno, PCAP_ERRBUF_SIZE, snprintf(), and strtol().

Referenced by open_dlpi_device().