X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=doc%2Fcomstack.xml;h=65e3d1d5f1465075660ad566bc870c052257e062;hp=4c2c6ba5811ac728fadc6c262dcf62755ff51134;hb=32e80f00a5c06ad5d5de0d4205897197a770fd31;hpb=d82eeac05d2899fa30704e2c40e9dd603ff2c581 diff --git a/doc/comstack.xml b/doc/comstack.xml index 4c2c6ba..65e3d1d 100644 --- a/doc/comstack.xml +++ b/doc/comstack.xml @@ -1,57 +1,62 @@ - The COMSTACK Module Synopsis (blocking mode) - + @@ -60,8 +65,8 @@ if (buf) The &comstack; subsystem provides a transparent interface to different types of transport - stacks for the exchange of BER-encoded data. At present, the - RFC1729 method (BER over TCP/IP), local UNIX socket and an + stacks for the exchange of BER-encoded data and HTTP packets. + At present, the RFC1729 method (BER over TCP/IP), local UNIX socket and an experimental SSL stack are supported, but others may be added in time. The philosophy of the module is to provide a simple interface by hiding unused options and @@ -101,7 +106,7 @@ if (buf) Common Functions - Managing Endpoints + Managing Endpoints COMSTACK cs_create(CS_TYPE type, int blocking, int protocol); @@ -115,16 +120,17 @@ if (buf) tcpip_type - TCP/IP (BER over TCP/IP) + TCP/IP (BER over TCP/IP or HTTP over TCP/IP) ssl_type Secure Socket Layer (SSL). This COMSTACK - is experimental and is not fully implemented. + is experimental and is not fully implemented. If + HTTP is used, this effectively is HTTPS. unix_type - Unix socket (unix only). Fast local transfer via + Unix socket (unix only). Local Transfer via file socket. See unix 7. @@ -137,12 +143,12 @@ if (buf) The blocking parameter should be one if you wish the association to operate in blocking mode, zero otherwise. The protocol field should be - PROTO_Z3950. + PROTO_Z3950 or PROTO_HTTP. Protocol PROTO_SR is no longer supported. - int cs_close(COMSTACK handle); + void cs_close(COMSTACK handle); @@ -161,7 +167,7 @@ if (buf) - Data Exchange + Data Exchange int cs_put(COMSTACK handle, char *buf, int len); @@ -186,7 +192,8 @@ if (buf) - Receives a PDU from the peer. Returns the number of bytes read. + Receives a PDU or HTTP Response from the peer. Returns the number of + bytes read. In nonblocking mode, it is possible that not all of the packet can be read at once. In this case, the function returns 1. To simplify the interface, the function is @@ -397,7 +404,7 @@ if (buf) - char *cs_addrstr(COMSTACK); + const char *cs_addrstr(COMSTACK); @@ -429,7 +436,7 @@ if (buf) - <host> [ ':' <portnum> ] + <host> [ ':' <portnum> ] @@ -453,7 +460,7 @@ if (buf) - char *cs_addrstr(COMSTACK h); + const char *cs_addrstr(COMSTACK h); @@ -488,6 +495,47 @@ if (buf) + SSL + + + void *cs_get_ssl(COMSTACK cs); + + Returns the SSL handle, SSL * for comstack. If comstack + is not of type SSL, NULL is returned. + + + + + int cs_set_ssl_ctx(COMSTACK cs, void *ctx); + + Sets SSL context for comstack. The parameter is expected to be of type + SSL_CTX *. This function should be called just + after comstack has been created (before connect, bind, etc). + This function returns 1 for success; 0 for failure. + + + + + int cs_set_ssl_certificate_file(COMSTACK cs, const char *fname); + + Sets SSL certificate for comstack as a PEM file. This function + returns 1 for success; 0 for failure. + + + + + + int cs_get_ssl_peer_certificate_x509(COMSTACK cs, char **buf, int *len); + + This function returns the peer certificate. If successful, + *buf and *len holds + X509 buffer and length respectively. Buffer should be freed + with xfree. This function returns 1 for success; + 0 for failure. + + + + Diagnostics @@ -499,55 +547,52 @@ if (buf) - When a function (including the data exchange functions) reports an - error condition, use the function - cs_errno() to determine the cause of the - problem. The function + The error code for the COMSTACK can be retrieved using C macro + cs_errno which will return one + of the error codes CSYSERR, + CSOUTSTATE, + CSNODATA, ... - void cs_perror(COMSTACK handle char *message); + int cs_errno(COMSTACK handle); - works like perror(2) and prints the - message argument, along with a system message, to - stderr. Use the character array + You can the textual representation of the error code + by using cs_errmsg - which + works like strerror(3) - extern const char *cs_errlist[]; + const char *cs_errmsg(int n); - + - to get hold of the message, if you want to process it differently. - The function + It is also possible to get straight to the textual represenataion + without the error code by using + cs_strerror. - + - const char *cs_stackerr(COMSTACK handle); + const char *cs_strerror(COMSTACK h); - - - Returns an error message from the lower layer, if one has been - provided. - + Summary and Synopsis - - #include <yaz/comstack.h> + - #include <yaz/tcpip.h> /* this is for TCP/IP and SSL support */ - #include <yaz/unix.h> /* this is for UNIX sockeL support */ + #include /* this is for TCP/IP and SSL support */ + #include /* this is for UNIX socket support */ - COMSTACK cs_create(CS_TYPE type, int blocking, int protocol); COMSTACK cs_createbysocket(int s, CS_TYPE type, int blocking, int protocol); - COMSTACK cs_create_host (const char *str, int blocking, - void **vp); + COMSTACK cs_create_host(const char *str, int blocking, + void **vp); int cs_bind(COMSTACK handle, int mode); @@ -565,21 +610,14 @@ if (buf) int cs_more(COMSTACK handle); - int cs_close(COMSTACK handle); + void cs_close(COMSTACK handle); int cs_look(COMSTACK handle); void *cs_straddr(COMSTACK handle, const char *str); - char *cs_addrstr(COMSTACK h); - - extern int cs_errno; - - void cs_perror(COMSTACK handle char *message); - - const char *cs_stackerr(COMSTACK handle); - - extern const char *cs_errlist[]; + const char *cs_addrstr(COMSTACK h); +]]>