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.h File Reference
#include "pcap/socket.h"
#include <unistd.h>
#include "sslutils.h"
Include dependency graph for sockutils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define closesocket(a)   close(a)
 In Winsock, the close() call cannot be used on a socket; closesocket() must be used. We define closesocket() to be a wrapper around close() on UN*X, so that it can be used on both platforms. More...
 
#define SOCKBUF_CHECKONLY   1
 
#define SOCKBUF_BUFFERIZE   0
 
#define SOCKOPEN_CLIENT   0
 
#define SOCKOPEN_SERVER   1
 
#define SOCK_RECEIVEALL_NO   0x00000000 /* Don't wait to receive all data */
 
#define SOCK_RECEIVEALL_YES   0x00000001 /* Wait to receive all data */
 
#define SOCK_EOF_ISNT_ERROR   0x00000000 /* Return 0 on EOF */
 
#define SOCK_EOF_IS_ERROR   0x00000002 /* Return an error on EOF */
 
#define SOCK_MSG_PEEK   0x00000004 /* Return data but leave it in the socket queue */
 

Functions

int sock_init (char *errbuf, int errbuflen)
 
void sock_cleanup (void)
 
void sock_fmterror (const char *caller, int errcode, char *errbuf, int errbuflen)
 
void sock_geterror (const char *caller, char *errbuf, int errbufsize)
 
int sock_initaddress (const char *address, const char *port, struct addrinfo *hints, struct addrinfo **addrinfo, char *errbuf, int errbuflen)
 
int sock_recv (int sock, void const *, void *buffer, size_t size, int receiveall, char *errbuf, int errbuflen)
 
int sock_recv_dgram (int sock, void const *, void *buffer, size_t size, char *errbuf, int errbuflen)
 
int sock_open (struct addrinfo *addrinfo, int server, int nconn, char *errbuf, int errbuflen)
 
int sock_close (int sock, char *errbuf, int errbuflen)
 
int sock_send (int sock, void const *, 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_discard (int sock, void const *, 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

◆ closesocket

#define closesocket (   a)    close(a)

In Winsock, the close() call cannot be used on a socket; closesocket() must be used. We define closesocket() to be a wrapper around close() on UN*X, so that it can be used on both platforms.

Definition at line 52 of file sockutils.h.

◆ SOCK_EOF_IS_ERROR

#define SOCK_EOF_IS_ERROR   0x00000002 /* Return an error on EOF */

Definition at line 107 of file sockutils.h.

◆ SOCK_EOF_ISNT_ERROR

#define SOCK_EOF_ISNT_ERROR   0x00000000 /* Return 0 on EOF */

Definition at line 106 of file sockutils.h.

◆ SOCK_MSG_PEEK

#define SOCK_MSG_PEEK   0x00000004 /* Return data but leave it in the socket queue */

Definition at line 109 of file sockutils.h.

◆ SOCK_RECEIVEALL_NO

#define SOCK_RECEIVEALL_NO   0x00000000 /* Don't wait to receive all data */

Definition at line 103 of file sockutils.h.

◆ SOCK_RECEIVEALL_YES

#define SOCK_RECEIVEALL_YES   0x00000001 /* Wait to receive all data */

Definition at line 104 of file sockutils.h.

◆ SOCKBUF_BUFFERIZE

#define SOCKBUF_BUFFERIZE   0

Definition at line 93 of file sockutils.h.

◆ SOCKBUF_CHECKONLY

#define SOCKBUF_CHECKONLY   1
  • Exported functions / definitions *

Definition at line 91 of file sockutils.h.

◆ SOCKOPEN_CLIENT

#define SOCKOPEN_CLIENT   0

Definition at line 96 of file sockutils.h.

◆ SOCKOPEN_SERVER

#define SOCKOPEN_SERVER   1

Definition at line 98 of file sockutils.h.

Function Documentation

◆ 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 *  address,
const char *  port,
struct addrinfo *  hints,
struct addrinfo **  addrinfo,
char *  errbuf,
int  errbuflen 
)

◆ 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  receiveall,
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()