YAZ  5.23.1
Data Structures | Macros | Typedefs | Functions
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/base64.h>
#include <yaz/thread_create.h>
#include <yaz/comstack.h>
#include <yaz/tcpip.h>

Go to the source code of this file.

Data Structures

struct  tcpip_state
 

Macros

#define RESOLVER_THREAD   1
 
#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_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)
 
struct addrinfo * tcpip_getaddrinfo (const char *str, const char *port, int *ipv6_only)
 
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)
 
static struct tcpip_statetcpip_state_create (void)
 
COMSTACK tcpip_type (int s, int flags, int protocol, void *vp)
 
static void connect_and_bind (COMSTACK p, const char *connect_host, const char *connect_auth, const char *bind_host)
 
COMSTACK yaz_tcpip_create3 (int s, int flags, int protocol, const char *connect_host, const char *connect_auth, const char *bind_host)
 
COMSTACK yaz_tcpip_create2 (int s, int flags, int protocol, const char *connect_host, const char *bind_host)
 
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)
 
COMSTACK yaz_ssl_create (int s, int flags, int protocol, const char *connect_host, const char *connect_auth, const char *bind_host)
 
static struct addrinfo * create_net_socket (COMSTACK h)
 
void * resolver_thread (void *arg)
 
static struct addrinfo * wait_resolver_thread (COMSTACK h)
 
static int cont_connect (COMSTACK h)
 
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)
 
int cs_set_head_only (COMSTACK cs, int head_only)
 

Detailed Description

Implements TCP/IP + SSL COMSTACK.

Definition in file tcpip.c.

Macro Definition Documentation

#define CERTF   "ztest.pem"

Definition at line 861 of file tcpip.c.

#define CS_TCPIP_BUFCHUNK   4096

Definition at line 1120 of file tcpip.c.

Referenced by tcpip_get().

#define KEYF   "ztest.pem"

Definition at line 862 of file tcpip.c.

#define RESOLVER_THREAD   1

Definition at line 72 of file tcpip.c.

#define TRC (   X)
#define YAZ_SOCKLEN_T   int

Definition at line 103 of file tcpip.c.

Referenced by tcpip_addrstr(), and tcpip_listen().

Typedef Documentation

typedef struct tcpip_state tcpip_state

Function Documentation

static void connect_and_bind ( COMSTACK  p,
const char *  connect_host,
const char *  connect_auth,
const char *  bind_host 
)
static
static int cont_connect ( COMSTACK  h)
static
static struct addrinfo* create_net_socket ( COMSTACK  h)
static
int cs_get_peer_certificate_x509 ( COMSTACK  cs,
char **  buf,
int *  len 
)

Definition at line 1655 of file tcpip.c.

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

Referenced by get_cert().

void* cs_get_ssl ( COMSTACK  cs)

Definition at line 1623 of file tcpip.c.

void cs_print_session_info ( COMSTACK  cs)

Definition at line 1581 of file tcpip.c.

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

int cs_set_head_only ( COMSTACK  cs,
int  head_only 
)
int cs_set_ssl_certificate_file ( COMSTACK  cs,
const char *  fname 
)

Definition at line 1641 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 1629 of file tcpip.c.

References ssl_type(), and comstack::type.

void* resolver_thread ( void *  arg)
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
struct addrinfo * tcpip_getaddrinfo ( const char *  str,
const char *  port,
int *  ipv6_only 
)

Definition at line 375 of file tcpip.c.

References TRC.

Referenced by create_net_socket(), resolver_thread(), and tcpip_straddr().

static int tcpip_init ( void  )
static

Definition at line 149 of file tcpip.c.

References yaz_init_globals().

Referenced by tcpip_straddr(), and tcpip_type().

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_listen ( COMSTACK  h,
char *  raddr,
int *  addrlen,
int(*)(void *cd, const char *a, int len, int t)  check_ip,
void *  cd 
)
int tcpip_more ( COMSTACK  h)
static

Definition at line 658 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
int tcpip_rcvconnect ( COMSTACK  h)
static
static int tcpip_set_blocking ( COMSTACK  p,
int  blocking 
)
static
static struct tcpip_state* tcpip_state_create ( void  )
static
void * tcpip_straddr ( COMSTACK  h,
const char *  str 
)
static
COMSTACK tcpip_type ( int  s,
int  flags,
int  protocol,
void *  vp 
)
static struct addrinfo* wait_resolver_thread ( COMSTACK  h)
static
COMSTACK yaz_ssl_create ( int  s,
int  flags,
int  protocol,
const char *  connect_host,
const char *  connect_auth,
const char *  bind_host 
)
COMSTACK yaz_tcpip_create ( int  s,
int  flags,
int  protocol,
const char *  connect_host 
)

Definition at line 305 of file tcpip.c.

References comstack::cprivate, xmalloc, and yaz_tcpip_create2().

COMSTACK yaz_tcpip_create2 ( int  s,
int  flags,
int  protocol,
const char *  connect_host,
const char *  bind_host 
)

Definition at line 298 of file tcpip.c.

References yaz_tcpip_create3().

Referenced by yaz_tcpip_create().

COMSTACK yaz_tcpip_create3 ( int  s,
int  flags,
int  protocol,
const char *  connect_host,
const char *  connect_auth,
const char *  bind_host 
)

Definition at line 286 of file tcpip.c.

References connect_and_bind(), and tcpip_type().

Referenced by cs_create_host2(), and yaz_tcpip_create2().