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)  

sockutils.c File Reference
#include "ftmacros.h"
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include "pcap-int.h"
#include "sockutils.h"
#include "portability.h"
Include dependency graph for sockutils.c:

Go to the source code of this file.

Macros

#define SOCK_ERRBUF_SIZE   1024
 
#define SOCKET_NO_NAME_AVAILABLE   "No name available"
 
#define SOCKET_NO_PORT_AVAILABLE   "No port available"
 
#define SOCKET_NAME_NULL_DAD   "Null address (possibly DAD Phase)"
 
#define TEMP_BUF_SIZE   32768
 

Functions

static int sock_ismcastaddr (const struct sockaddr *saddr)
 
void sock_fmterror (const char *caller, int errcode, char *errbuf, int errbuflen)
 
void sock_geterror (const char *caller, char *errbuf, int errbuflen)
 
int sock_init (char *errbuf, int errbuflen)
 
void sock_cleanup (void)
 
int sock_open (struct addrinfo *addrinfo, int server, int nconn, char *errbuf, int errbuflen)
 
int sock_close (int sock, char *errbuf, int errbuflen)
 
static void get_gai_errstring (char *errbuf, int errbuflen, const char *prefix, int err, const char *hostname, const char *portname)
 
int sock_initaddress (const char *host, const char *port, struct addrinfo *hints, struct addrinfo **addrinfo, char *errbuf, int errbuflen)
 
int sock_send (int sock, void const *ssl, const char *buffer, size_t size, char *errbuf, int errbuflen)
 
int sock_bufferize (const char *buffer, int size, char *tempbuf, int *offset, int totsize, int checkonly, char *errbuf, int errbuflen)
 
int sock_recv (int sock, void const *ssl, void *buffer, size_t size, int flags, char *errbuf, int errbuflen)
 
int sock_recv_dgram (int sock, void const *ssl, void *buffer, size_t size, char *errbuf, int errbuflen)
 
int sock_discard (int sock, void const *ssl, int size, char *errbuf, int errbuflen)
 
int sock_check_hostlist (char *hostlist, const char *sep, struct sockaddr_storage *from, char *errbuf, int errbuflen)
 
int sock_cmpaddr (struct sockaddr_storage *first, struct sockaddr_storage *second)
 
int sock_getmyinfo (int sock, char *address, int addrlen, char *port, int portlen, int flags, char *errbuf, int errbuflen)
 
int sock_getascii_addrport (const struct sockaddr_storage *sockaddr, char *address, int addrlen, char *port, int portlen, int flags, char *errbuf, int errbuflen)
 
int sock_present2network (const char *address, struct sockaddr_storage *sockaddr, int addr_family, char *errbuf, int errbuflen)
 

Macro Definition Documentation

◆ SOCK_ERRBUF_SIZE

#define SOCK_ERRBUF_SIZE   1024

Definition at line 84 of file sockutils.c.

◆ SOCKET_NAME_NULL_DAD

#define SOCKET_NAME_NULL_DAD   "Null address (possibly DAD Phase)"

Definition at line 89 of file sockutils.c.

◆ SOCKET_NO_NAME_AVAILABLE

#define SOCKET_NO_NAME_AVAILABLE   "No name available"

Definition at line 87 of file sockutils.c.

◆ SOCKET_NO_PORT_AVAILABLE

#define SOCKET_NO_PORT_AVAILABLE   "No port available"

Definition at line 88 of file sockutils.c.

◆ TEMP_BUF_SIZE

#define TEMP_BUF_SIZE   32768

Function Documentation

◆ get_gai_errstring()

static void get_gai_errstring ( char *  errbuf,
int  errbuflen,
const char *  prefix,
int  err,
const char *  hostname,
const char *  portname 
)
static

Definition at line 545 of file sockutils.c.

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

Referenced by sock_check_hostlist(), and sock_initaddress().

◆ sock_bufferize()

int sock_bufferize ( const char *  buffer,
int  size,
char *  tempbuf,
int *  offset,
int  totsize,
int  checkonly,
char *  errbuf,
int  errbuflen 
)

◆ sock_check_hostlist()

int sock_check_hostlist ( char *  hostlist,
const char *  sep,
struct sockaddr_storage *  from,
char *  errbuf,
int  errbuflen 
)

◆ sock_cleanup()

void sock_cleanup ( void  )

◆ sock_close()

◆ sock_cmpaddr()

int sock_cmpaddr ( struct sockaddr_storage *  first,
struct sockaddr_storage *  second 
)

◆ sock_discard()

int sock_discard ( int  sock,
void const *  ssl,
int  size,
char *  errbuf,
int  errbuflen 
)

Definition at line 1256 of file sockutils.c.

References SOCK_RECEIVEALL_YES, sock_recv(), and TEMP_BUF_SIZE.

Referenced by rpcap_discard(), and rpcapd_discard().

◆ sock_fmterror()

void sock_fmterror ( const char *  caller,
int  errcode,
char *  errbuf,
int  errbuflen 
)
  • Function bodies *

Definition at line 150 of file sockutils.c.

References pcap_fmt_errmsg_for_errno().

Referenced by accept_connections(), sock_geterror(), and sock_send().

◆ sock_getascii_addrport()

int sock_getascii_addrport ( const struct sockaddr_storage *  sockaddr,
char *  address,
int  addrlen,
char *  port,
int  portlen,
int  flags,
char *  errbuf,
int  errbuflen 
)

◆ sock_geterror()

◆ sock_getmyinfo()

int sock_getmyinfo ( int  sock,
char *  address,
int  addrlen,
char *  port,
int  portlen,
int  flags,
char *  errbuf,
int  errbuflen 
)

Definition at line 1513 of file sockutils.c.

References address, getsockname(), port, sock_getascii_addrport(), and sock_geterror().

◆ sock_init()

int sock_init ( char *  errbuf,
int  errbuflen 
)

Definition at line 235 of file sockutils.c.

Referenced by init_watt32(), main(), pcap_remoteact_accept_ex(), and rpcap_setup_session().

◆ sock_initaddress()

int sock_initaddress ( const char *  host,
const char *  port,
struct addrinfo *  hints,
struct addrinfo **  addrinfo,
char *  errbuf,
int  errbuflen 
)

◆ sock_ismcastaddr()

static int sock_ismcastaddr ( const struct sockaddr *  saddr)
static
  • Locally defined functions *

Definition at line 268 of file sockutils.c.

Referenced by sock_initaddress().

◆ sock_open()

int sock_open ( struct addrinfo *  addrinfo,
int  server,
int  nconn,
char *  errbuf,
int  errbuflen 
)

◆ sock_present2network()

int sock_present2network ( const char *  address,
struct sockaddr_storage *  sockaddr,
int  addr_family,
char *  errbuf,
int  errbuflen 
)

Definition at line 1669 of file sockutils.c.

References address, snprintf(), and sock_initaddress().

◆ sock_recv()

int sock_recv ( int  sock,
void const *  ssl,
void *  buffer,
size_t  size,
int  flags,
char *  errbuf,
int  errbuflen 
)

◆ sock_recv_dgram()

int sock_recv_dgram ( int  sock,
void const *  ssl,
void *  buffer,
size_t  size,
char *  errbuf,
int  errbuflen 
)

Definition at line 1109 of file sockutils.c.

References errno, recv(), snprintf(), and sock_geterror().

Referenced by pcap_read_nocb_remote().

◆ sock_send()