diff options
author | Richard Levitte <levitte@openssl.org> | 2016-02-03 00:47:42 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2016-02-03 20:36:49 +0100 |
commit | ab69ac00f3c7a04151662813794ac82bc591a89b (patch) | |
tree | 8f06f8c8c3b867449d621d3394c9da301e5e751a /apps/s_apps.h | |
parent | d858c87653257185ead1c5baf3d84cd7276dd912 (diff) | |
download | openssl-ab69ac00f3c7a04151662813794ac82bc591a89b.tar.gz |
Refactoring BIO: Adapt s_client and s_server
s_socket.c gets brutally cleaned out and now consists of only two
functions, one for client and the other for server. They both handle
AF_INET, AF_INET6 and additionally AF_UNIX where supported. The rest
is just easy adaptation.
Both s_client and s_server get the new flags -4 and -6 to force the
use of IPv4 or IPv6 only.
Also, the default host "localhost" in s_client is removed. It's not
certain that this host is set up for both IPv4 and IPv6. For example,
Debian has "ip6-localhost" as the default hostname for [::1]. The
better way is to default |host| to NULL and rely on BIO_lookup() to
return a BIO_ADDRINFO with the appropriate loopback address for IPv4
or IPv6 as indicated by the |family| parameter.
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Diffstat (limited to 'apps/s_apps.h')
-rw-r--r-- | apps/s_apps.h | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/apps/s_apps.h b/apps/s_apps.h index 9339b41609..e9b6f40288 100644 --- a/apps/s_apps.h +++ b/apps/s_apps.h @@ -146,20 +146,14 @@ typedef fd_mask fd_set; # define FD_ZERO(p) memset((p), 0, sizeof(*(p))) #endif -#define PORT 4433 -#define PORT_STR "4433" +#define PORT "4433" #define PROTOCOL "tcp" -int do_server(int port, int type, int *ret, - int (*cb) (char *hostname, int s, int stype, +int do_server(int *accept_sock, const char *host, const char *port, + int family, int type, + int (*cb) (const char *hostname, int s, int stype, unsigned char *context), unsigned char *context, int naccept); -#ifndef NO_SYS_UN_H -int do_server_unix(const char *path, int *ret, - int (*cb) (char *hostname, int s, int stype, - unsigned char *context), unsigned char *context, - int naccept); -#endif #ifdef HEADER_X509_H int verify_callback(int ok, X509_STORE_CTX *ctx); #endif @@ -172,14 +166,9 @@ int ssl_print_point_formats(BIO *out, SSL *s); int ssl_print_curves(BIO *out, SSL *s, int noshared); #endif int ssl_print_tmp_key(BIO *out, SSL *s); -int init_client(int *sock, const char *server, int port, int type); -#ifndef NO_SYS_UN_H -int init_client_unix(int *sock, const char *server); -#endif +int init_client(int *sock, const char *host, const char *port, + int family, int type); int should_retry(int i); -int extract_port(const char *str, unsigned short *port_ptr); -int extract_host_port(char *str, char **host_ptr, unsigned char *ip, - unsigned short *p); long bio_dump_callback(BIO *bio, int cmd, const char *argp, int argi, long argl, long ret); |