X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=demos%2Ftunala%2Ftunala.h;h=3a752f259a949bee636ad6574cd2cd1e570e7430;hp=7d4e35dc9c68e9bcd8e652122992a6da31f2a921;hb=bd1fb772457891c99b6c676d04fdbd6c86aca45b;hpb=3465dd3853f000e042dc3fd26f4ce03cd92374ad diff --git a/demos/tunala/tunala.h b/demos/tunala/tunala.h index 7d4e35dc9c..3a752f259a 100644 --- a/demos/tunala/tunala.h +++ b/demos/tunala/tunala.h @@ -17,13 +17,57 @@ #ifndef _TUNALA_H #define _TUNALA_H +/* pull in autoconf fluff */ +#ifndef NO_CONFIG_H +#include "config.h" +#else +/* We don't have autoconf, we have to set all of these unless a tweaked Makefile + * tells us not to ... */ +/* headers */ +#ifndef NO_HAVE_SELECT +#define HAVE_SELECT +#endif +#ifndef NO_HAVE_SOCKET +#define HAVE_SOCKET +#endif +#ifndef NO_HAVE_UNISTD_H +#define HAVE_UNISTD_H +#endif +#ifndef NO_HAVE_FCNTL_H +#define HAVE_FCNTL_H +#endif +#ifndef NO_HAVE_LIMITS_H +#define HAVE_LIMITS_H +#endif +/* features */ +#ifndef NO_HAVE_STRSTR +#define HAVE_STRSTR +#endif +#ifndef NO_HAVE_STRTOUL +#define HAVE_STRTOUL +#endif +#endif + +#if !defined(HAVE_SELECT) || !defined(HAVE_SOCKET) +#error "can't build without some network basics like select() and socket()" +#endif + +#include #ifndef NO_SYSTEM_H #include +#ifdef HAVE_UNISTD_H #include +#endif +#ifdef HAVE_FCNTL_H #include +#endif +#ifdef HAVE_LIMITS_H +#include +#endif #include #include #include +#include #include #endif /* !defined(NO_SYSTEM_H) */ @@ -33,7 +77,7 @@ #include #endif /* !defined(NO_OPENSSL) */ -#ifndef NO_BUFFER +#ifndef OPENSSL_NO_BUFFER /* This is the generic "buffer" type that is used when feeding the * state-machine. It's basically a FIFO with respect to the "adddata" & * "takedata" type functions that operate on it. */ @@ -41,6 +85,9 @@ typedef struct _buffer_t { unsigned char data[MAX_DATA_SIZE]; unsigned int used; + /* Statistical values - counts the total number of bytes read in and + * read out (respectively) since "buffer_init()" */ + unsigned long total_in, total_out; } buffer_t; /* Initialise a buffer structure before use */ @@ -59,7 +106,11 @@ int buffer_full(buffer_t *buf); /* Boolean, is it full? */ int buffer_notfull(buffer_t *buf); /* Boolean, is it not full? */ int buffer_empty(buffer_t *buf); /* Boolean, is it empty? */ int buffer_notempty(buffer_t *buf); /* Boolean, is it not empty? */ +unsigned long buffer_total_in(buffer_t *buf); /* Total bytes written to buffer */ +unsigned long buffer_total_out(buffer_t *buf); /* Total bytes read from buffer */ +#if 0 /* Currently used only within buffer.c - better to expose only + * higher-level functions anyway */ /* Add data to the tail of the buffer, returns the amount that was actually * added (so, you need to check if return value is less than size) */ unsigned int buffer_adddata(buffer_t *buf, const unsigned char *ptr, @@ -76,6 +127,7 @@ unsigned int buffer_takedata(buffer_t *buf, unsigned char *ptr, * buffer. Return value is the amount moved. The amount moved can be restricted * to a maximum by specifying "cap" - setting it to -1 means no limit. */ unsigned int buffer_tobuffer(buffer_t *to, buffer_t *from, int cap); +#endif #ifndef NO_IP /* Read or write between a file-descriptor and a buffer */ @@ -91,17 +143,18 @@ void buffer_from_BIO(buffer_t *buf, BIO *bio); void buffer_to_BIO(buffer_t *buf, BIO *bio); /* Callbacks */ -void cb_ssl_info(SSL *s, int where, int ret); +void cb_ssl_info(const SSL *s, int where, int ret); void cb_ssl_info_set_output(FILE *fp); /* Called if output should be sent too */ int cb_ssl_verify(int ok, X509_STORE_CTX *ctx); void cb_ssl_verify_set_output(FILE *fp); void cb_ssl_verify_set_depth(unsigned int verify_depth); void cb_ssl_verify_set_level(unsigned int level); +RSA *cb_generate_tmp_rsa(SSL *s, int is_export, int keylength); #endif /* !defined(NO_OPENSSL) */ -#endif /* !defined(NO_BUFFER) */ +#endif /* !defined(OPENSSL_NO_BUFFER) */ #ifndef NO_TUNALA -#ifdef NO_BUFFER +#ifdef OPENSSL_NO_BUFFER #error "TUNALA section of tunala.h requires BUFFER support" #endif typedef struct _state_machine_t { @@ -135,20 +188,28 @@ int ip_initialise(void); /* ip is the 4-byte ip address (eg. 127.0.0.1 is {0x7F,0x00,0x00,0x01}), port is * the port to listen on (host byte order), and the return value is the * file-descriptor or -1 on error. */ -int ip_create_listener_split(const unsigned char *ip, unsigned short port); +int ip_create_listener_split(const char *ip, unsigned short port); /* Same semantics as above. */ -int ip_create_connection_split(const unsigned char *ip, unsigned short port); +int ip_create_connection_split(const char *ip, unsigned short port); /* Converts a string into the ip/port before calling the above */ int ip_create_listener(const char *address); int ip_create_connection(const char *address); /* Just does a string conversion on its own. NB: If accept_all_ip is non-zero, * then the address string could be just a port. Ie. it's suitable for a * listening address but not a connecting address. */ -int ip_parse_address(const char *address, unsigned char **parsed_ip, +int ip_parse_address(const char *address, const char **parsed_ip, unsigned short *port, int accept_all_ip); /* Accepts an incoming connection through the listener. Assumes selects and * what-not have deemed it an appropriate thing to do. */ int ip_accept_connection(int listen_fd); #endif /* !defined(NO_IP) */ +/* These functions wrap up things that can be portability hassles. */ +int int_strtoul(const char *str, unsigned long *val); +#ifdef HAVE_STRSTR +#define int_strstr strstr +#else +char *int_strstr(const char *haystack, const char *needle); +#endif + #endif /* !defined(_TUNALA_H) */