|
YAZ 5.35.1
|
Implements TCP/IP + SSL COMSTACK. More...
#include <yaz/yconfig.h>#include <stdio.h>#include <string.h>#include <assert.h>#include <stdlib.h>#include <errno.h>#include <fcntl.h>#include <signal.h>#include <yaz/thread_create.h>#include <yaz/log.h>#include <yaz/base64.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 | YAZ_SOCKLEN_T int |
| #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_state * | tcpip_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 void | parse_host_port (const char *host_port, char *tmp, size_t tmp_sz, const char **host, const char **port) |
| static struct addrinfo * | create_net_socket (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) |
Variables | |
| static int | log_level = 0 |
Implements TCP/IP + SSL COMSTACK.
Definition in file tcpip.c.
| typedef struct tcpip_state tcpip_state |
|
static |
Definition at line 248 of file tcpip.c.
References tcpip_state::bind_host, tcpip_state::connect_request_buf, tcpip_state::connect_request_len, comstack::cprivate, xmalloc, and yaz_base64encode().
Referenced by yaz_ssl_create(), and yaz_tcpip_create3().
|
static |
Definition at line 624 of file tcpip.c.
References tcpip_state::ai_connect, comstack::cerrno, comstack::cprivate, CS_ST_UNBND, CSYSERR, comstack::flags, comstack::iofile, log_level, ssl_type(), comstack::state, tcpip_connect(), tcpip_set_blocking(), comstack::type, and yaz_log().
Referenced by tcpip_connect(), tcpip_put(), and tcpip_rcvconnect().
|
static |
Definition at line 467 of file tcpip.c.
References tcpip_state::ai, tcpip_state::bind_host, comstack::cerrno, comstack::cprivate, CSYSERR, comstack::flags, comstack::iofile, tcpip_state::ipv6_only, log_level, tcpip_getaddrinfo(), tcpip_set_blocking(), and yaz_log().
Referenced by tcpip_straddr().
| int cs_get_peer_certificate_x509 | ( | COMSTACK | cs, |
| char ** | buf, | ||
| int * | len | ||
| ) |
Definition at line 1566 of file tcpip.c.
References tcpip_state::buf, comstack::cprivate, ssl_type(), comstack::type, and xstrdup.
Referenced by get_cert().
| void cs_print_session_info | ( | COMSTACK | cs | ) |
Definition at line 1492 of file tcpip.c.
References comstack::cprivate, ssl_type(), and comstack::type.
| int cs_set_head_only | ( | COMSTACK | cs, |
| int | head_only | ||
| ) |
Definition at line 1605 of file tcpip.c.
References comstack::cerrno, tcpip_state::complete, comstack::cprivate, cs_complete_auto(), cs_complete_auto_head(), CS_ST_INCON, ssl_type(), tcpip_type(), and comstack::type.
Referenced by yaz_url_exec().
| int cs_set_ssl_certificate_file | ( | COMSTACK | cs, |
| const char * | fname | ||
| ) |
Definition at line 1552 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 1540 of file tcpip.c.
References ssl_type(), and comstack::type.
|
static |
Definition at line 376 of file tcpip.c.
Referenced by tcpip_getaddrinfo(), and tcpip_rcvconnect().
| COMSTACK ssl_type | ( | int | s, |
| int | flags, | ||
| int | protocol, | ||
| void * | vp | ||
| ) |
Definition at line 324 of file tcpip.c.
References comstack::cprivate, ssl_type(), tcpip_type(), and comstack::type.
Referenced by cont_connect(), cs_create_host2(), cs_get_peer_certificate_x509(), cs_parse_host(), cs_print_session_info(), cs_set_head_only(), cs_set_ssl_certificate_file(), cs_set_ssl_ctx(), ssl_type(), tcpip_bind(), tcpip_rcvconnect(), tcpip_straddr(), and yaz_ssl_create().
Definition at line 950 of file tcpip.c.
References comstack::cerrno, comstack::cprivate, cs_close, CS_DATA, CS_ST_ACCEPT, CS_ST_DATAXFER, CS_ST_IDLE, CS_ST_INCON, CSOUTSTATE, CSYSERR, comstack::event, comstack::flags, comstack::io_pending, comstack::iofile, log_level, comstack::newfd, comstack::state, tcpip_set_blocking(), tcpip_state_create(), xfree, xmalloc, and yaz_log().
Referenced by tcpip_type().
|
static |
Definition at line 1359 of file tcpip.c.
References tcpip_state::buf, comstack::cerrno, comstack::cprivate, CS_FLAGS_NUMERICHOST, CSYSERR, comstack::flags, comstack::iofile, PROTO_HTTP, comstack::protocol, and YAZ_SOCKLEN_T.
Referenced by tcpip_type().
|
static |
Definition at line 813 of file tcpip.c.
References tcpip_state::ai, comstack::cerrno, comstack::cprivate, CS_LISTEN, CS_SERVER, CS_ST_IDLE, CSERRORSSL, CSYSERR, comstack::event, comstack::iofile, log_level, ssl_type(), comstack::state, comstack::type, and yaz_log().
Referenced by tcpip_type().
|
static |
Definition at line 1299 of file tcpip.c.
References tcpip_state::ai, tcpip_state::altbuf, tcpip_state::bind_host, tcpip_state::connect_request_buf, tcpip_state::connect_response_buf, comstack::cprivate, tcpip_state::host_port, comstack::iofile, log_level, xfree, yaz_log(), and yaz_thread_join().
Referenced by tcpip_type().
|
static |
Definition at line 664 of file tcpip.c.
References tcpip_state::ai_connect, comstack::cerrno, cont_connect(), comstack::cprivate, CS_CONNECT, CS_FLAGS_BLOCKING, CS_ST_CONNECTING, CS_ST_UNBND, CS_WANT_READ, CS_WANT_WRITE, CSOUTSTATE, comstack::event, comstack::flags, comstack::io_pending, comstack::iofile, log_level, comstack::state, tcpip_rcvconnect(), yaz_errno(), and yaz_log().
Referenced by cont_connect(), tcpip_rcvconnect(), and tcpip_type().
|
static |
Definition at line 1064 of file tcpip.c.
References tcpip_state::altbuf, tcpip_state::altlen, tcpip_state::altsize, comstack::cerrno, tcpip_state::complete, comstack::cprivate, CS_TCPIP_BUFCHUNK, CS_WANT_READ, CSBUFSIZE, CSYSERR, comstack::io_pending, comstack::iofile, log_level, comstack::max_recv_bytes, xmalloc, xrealloc, yaz_errno(), yaz_log(), and yaz_set_errno().
Referenced by tcpip_rcvconnect(), and tcpip_type().
| struct addrinfo * tcpip_getaddrinfo | ( | const char * | str, |
| const char * | port, | ||
| int * | ipv6_only | ||
| ) |
Definition at line 415 of file tcpip.c.
References parse_host_port().
Referenced by create_net_socket(), and tcpip_straddr().
|
static |
Definition at line 146 of file tcpip.c.
References log_level, log_level_set, yaz_init_globals(), and yaz_log_module_level().
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 | ||
| ) |
Definition at line 880 of file tcpip.c.
References comstack::cerrno, CS_ST_IDLE, CS_ST_INCON, CSDENY, CSNODATA, CSOUTSTATE, CSYSERR, comstack::iofile, log_level, comstack::newfd, comstack::state, yaz_errno(), yaz_log(), and YAZ_SOCKLEN_T.
|
static |
Referenced by tcpip_type().
|
static |
Definition at line 617 of file tcpip.c.
References tcpip_state::altbuf, tcpip_state::altlen, tcpip_state::complete, and comstack::cprivate.
Referenced by tcpip_type().
|
static |
Definition at line 1215 of file tcpip.c.
References tcpip_state::buf, comstack::cerrno, cont_connect(), comstack::cprivate, CS_DATA, CS_FLAGS_BLOCKING, CS_WANT_WRITE, CSWRONGBUF, CSYSERR, comstack::event, comstack::flags, comstack::io_pending, comstack::iofile, log_level, tcpip_state::towrite, tcpip_state::written, yaz_errno(), and yaz_log().
Referenced by tcpip_rcvconnect(), and tcpip_type().
|
static |
Definition at line 728 of file tcpip.c.
References comstack::cerrno, tcpip_state::complete, tcpip_state::connect_request_buf, tcpip_state::connect_request_len, tcpip_state::connect_response_buf, tcpip_state::connect_response_len, cont_connect(), comstack::cprivate, cs_complete_auto(), cs_complete_auto_head(), CS_CONNECT, CS_DATA, CS_ST_CONNECTING, CS_ST_DATAXFER, CS_ST_UNBND, CSOUTSTATE, comstack::event, tcpip_state::host_port, comstack::iofile, log_level, parse_host_port(), ssl_type(), comstack::state, tcpip_connect(), tcpip_get(), tcpip_put(), comstack::type, xfree, and yaz_log().
Referenced by tcpip_connect(), and tcpip_type().
|
static |
Definition at line 1398 of file tcpip.c.
References CS_FLAGS_BLOCKING, comstack::flags, and comstack::iofile.
Referenced by cont_connect(), create_net_socket(), tcpip_accept(), and tcpip_type().
|
static |
Definition at line 173 of file tcpip.c.
References tcpip_state::ai, tcpip_state::ai_connect, tcpip_state::altbuf, tcpip_state::altlen, tcpip_state::altsize, tcpip_state::bind_host, tcpip_state::complete, tcpip_state::connect_request_buf, tcpip_state::connect_request_len, tcpip_state::connect_response_buf, tcpip_state::connect_response_len, cs_complete_auto(), tcpip_state::host_port, tcpip_state::towrite, tcpip_state::written, and xmalloc.
Referenced by tcpip_accept(), and tcpip_type().
|
static |
Definition at line 577 of file tcpip.c.
References tcpip_state::ai, comstack::cprivate, create_net_socket(), CS_FLAGS_DNS_NO_BLOCK, CS_ST_UNBND, comstack::flags, tcpip_state::host_port, tcpip_state::ipv6_only, PROTO_HTTP, comstack::protocol, ssl_type(), comstack::state, tcpip_getaddrinfo(), tcpip_init(), comstack::type, xfree, xstrdup, and yaz_thread_create().
Referenced by tcpip_type().
| COMSTACK tcpip_type | ( | int | s, |
| int | flags, | ||
| int | protocol, | ||
| void * | vp | ||
| ) |
Definition at line 207 of file tcpip.c.
References comstack::cerrno, comstack::cprivate, CS_NONE, CS_ST_IDLE, CS_ST_UNBND, comstack::event, comstack::f_accept, comstack::f_addrstr, comstack::f_bind, comstack::f_close, comstack::f_connect, comstack::f_get, comstack::f_listen, comstack::f_more, comstack::f_put, comstack::f_rcvconnect, comstack::f_set_blocking, comstack::f_straddr, comstack::flags, comstack::io_pending, comstack::iofile, log_level, comstack::max_recv_bytes, comstack::protocol, comstack::state, tcpip_accept(), tcpip_addrstr(), tcpip_bind(), tcpip_close(), tcpip_connect(), tcpip_get(), tcpip_init(), tcpip_listen(), tcpip_more(), tcpip_put(), tcpip_rcvconnect(), tcpip_set_blocking(), tcpip_state_create(), tcpip_straddr(), tcpip_type(), comstack::type, comstack::user, xmalloc, and yaz_log().
Referenced by cs_create_host2(), cs_parse_host(), cs_set_head_only(), inetd_connection(), ssl_type(), tcpip_type(), and yaz_tcpip_create3().
| COMSTACK yaz_ssl_create | ( | int | s, |
| int | flags, | ||
| int | protocol, | ||
| const char * | connect_host, | ||
| const char * | connect_auth, | ||
| const char * | bind_host | ||
| ) |
Definition at line 345 of file tcpip.c.
References connect_and_bind(), and ssl_type().
Referenced by cs_create_host2().
| COMSTACK yaz_tcpip_create | ( | int | s, |
| int | flags, | ||
| int | protocol, | ||
| const char * | connect_host | ||
| ) |
Definition at line 307 of file tcpip.c.
References yaz_tcpip_create2().
| COMSTACK yaz_tcpip_create2 | ( | int | s, |
| int | flags, | ||
| int | protocol, | ||
| const char * | connect_host, | ||
| const char * | bind_host | ||
| ) |
Definition at line 300 of file tcpip.c.
References tcpip_state::bind_host, and 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 288 of file tcpip.c.
References tcpip_state::bind_host, connect_and_bind(), and tcpip_type().
Referenced by cs_create_host2(), and yaz_tcpip_create2().
|
static |
Definition at line 144 of file tcpip.c.
Referenced by cont_connect(), create_net_socket(), tcpip_accept(), tcpip_bind(), tcpip_close(), tcpip_connect(), tcpip_get(), tcpip_init(), tcpip_listen(), tcpip_put(), tcpip_rcvconnect(), and tcpip_type().