tcpip.c File Reference

Implements TCP/IP + SSL COMSTACK. More...

#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <yaz/comstack.h>
#include <yaz/tcpip.h>

Go to the source code of this file.

Data Structures

struct  tcpip_state

Defines

#define TRC(X)
#define YAZ_SOCKLEN_T   int
#define CERTF   "ztest.pem"
#define KEYF   "ztest.pem"
#define CS_TCPIP_BUFCHUNK   4096

Typedefs

typedef struct tcpip_state tcpip_state

Functions

static void tcpip_close (COMSTACK h)
static int tcpip_put (COMSTACK h, char *buf, int size)
static int tcpip_get (COMSTACK h, char **buf, int *bufsize)
static int tcpip_put_connect (COMSTACK h, char *buf, int size)
static int tcpip_get_connect (COMSTACK h, char **buf, int *bufsize)
static int tcpip_connect (COMSTACK h, void *address)
static int tcpip_more (COMSTACK h)
static int tcpip_rcvconnect (COMSTACK h)
static int tcpip_bind (COMSTACK h, void *address, int mode)
static int tcpip_listen (COMSTACK h, char *raddr, int *addrlen, int(*check_ip)(void *cd, const char *a, int len, int type), void *cd)
static int tcpip_set_blocking (COMSTACK p, int blocking)
static COMSTACK tcpip_accept (COMSTACK h)
static const char * tcpip_addrstr (COMSTACK h)
static void * tcpip_straddr (COMSTACK h, const char *str)
static int tcpip_init (void)
COMSTACK tcpip_type (int s, int flags, int protocol, void *vp)
COMSTACK yaz_tcpip_create (int s, int flags, int protocol, const char *connect_host)
COMSTACK ssl_type (int s, int flags, int protocol, void *vp)
struct addrinfo * tcpip_getaddrinfo (const char *str, const char *port)
int tcpip_strtoaddr_ex (const char *str, struct sockaddr_in *add, int default_port)
int tcpip_listen (COMSTACK h, char *raddr, int *addrlen, int(*check_ip)(void *cd, const char *a, int len, int t), void *cd)
void cs_print_session_info (COMSTACK cs)
void * cs_get_ssl (COMSTACK cs)
int cs_set_ssl_ctx (COMSTACK cs, void *ctx)
int cs_set_ssl_certificate_file (COMSTACK cs, const char *fname)
int cs_get_peer_certificate_x509 (COMSTACK cs, char **buf, int *len)

Detailed Description

Implements TCP/IP + SSL COMSTACK.

Definition in file tcpip.c.


Define Documentation

#define CERTF   "ztest.pem"

Definition at line 635 of file tcpip.c.

#define CS_TCPIP_BUFCHUNK   4096

Definition at line 994 of file tcpip.c.

Referenced by tcpip_get().

#define KEYF   "ztest.pem"

Definition at line 636 of file tcpip.c.

#define TRC (  ) 
#define YAZ_SOCKLEN_T   int

Definition at line 103 of file tcpip.c.

Referenced by tcpip_addrstr(), tcpip_listen(), and unix_listen().


Typedef Documentation

typedef struct tcpip_state tcpip_state

Function Documentation

int cs_get_peer_certificate_x509 ( COMSTACK  cs,
char **  buf,
int *  len 
)

Definition at line 1574 of file tcpip.c.

References cs_get_ssl(), and xmalloc.

Referenced by get_cert().

void* cs_get_ssl ( COMSTACK  cs  ) 

Definition at line 1528 of file tcpip.c.

References comstack::cprivate, ssl_type(), and comstack::type.

Referenced by cs_get_peer_certificate_x509().

void cs_print_session_info ( COMSTACK  cs  ) 

Definition at line 1490 of file tcpip.c.

References comstack::cprivate.

int cs_set_ssl_certificate_file ( COMSTACK  cs,
const char *  fname 
)

Definition at line 1559 of file tcpip.c.

References comstack::cprivate, ssl_type(), and comstack::type.

Referenced by add_listener().

int cs_set_ssl_ctx ( COMSTACK  cs,
void *  ctx 
)

Definition at line 1541 of file tcpip.c.

References comstack::cprivate, ssl_type(), and comstack::type.

COMSTACK ssl_type ( int  s,
int  flags,
int  protocol,
void *  vp 
)
COMSTACK tcpip_accept ( COMSTACK  h  )  [static]
const char * tcpip_addrstr ( COMSTACK  h  )  [static]
static int tcpip_bind ( COMSTACK  h,
void *  address,
int  mode 
) [static]
void tcpip_close ( COMSTACK  h  )  [static]
int tcpip_connect ( COMSTACK  h,
void *  address 
) [static]
int tcpip_get ( COMSTACK  h,
char **  buf,
int *  bufsize 
) [static]
static int tcpip_get_connect ( COMSTACK  h,
char **  buf,
int *  bufsize 
) [static]
struct addrinfo* tcpip_getaddrinfo ( const char *  str,
const char *  port 
) [read]

Definition at line 338 of file tcpip.c.

Referenced by tcpip_straddr().

static int tcpip_init ( void   )  [static]

Definition at line 162 of file tcpip.c.

Referenced by tcpip_straddr(), and tcpip_type().

int tcpip_listen ( COMSTACK  h,
char *  raddr,
int *  addrlen,
int(*)(void *cd, const char *a, int len, int t)  check_ip,
void *  cd 
)
static int tcpip_listen ( COMSTACK  h,
char *  raddr,
int *  addrlen,
int(*)(void *cd, const char *a, int len, int type)  check_ip,
void *  cd 
) [static]

Referenced by tcpip_type().

int tcpip_more ( COMSTACK  h  )  [static]

Definition at line 494 of file tcpip.c.

References tcpip_state::altbuf, tcpip_state::altlen, tcpip_state::complete, and comstack::cprivate.

Referenced by tcpip_type().

int tcpip_put ( COMSTACK  h,
char *  buf,
int  size 
) [static]
static int tcpip_put_connect ( COMSTACK  h,
char *  buf,
int  size 
) [static]
int tcpip_rcvconnect ( COMSTACK  h  )  [static]
static int tcpip_set_blocking ( COMSTACK  p,
int  blocking 
) [static]

Definition at line 1466 of file tcpip.c.

References CS_FLAGS_BLOCKING, comstack::flags, and comstack::iofile.

Referenced by tcpip_accept(), tcpip_straddr(), and tcpip_type().

void * tcpip_straddr ( COMSTACK  h,
const char *  str 
) [static]
int tcpip_strtoaddr_ex ( const char *  str,
struct sockaddr_in *  add,
int  default_port 
)

Definition at line 379 of file tcpip.c.

References TRC.

COMSTACK tcpip_type ( int  s,
int  flags,
int  protocol,
void *  vp 
)
COMSTACK yaz_tcpip_create ( int  s,
int  flags,
int  protocol,
const char *  connect_host 
)
Generated on Tue Aug 17 13:13:20 2010 for YAZ by  doxygen 1.6.3