Commit 28a0841b authored by Richard Levitte's avatar Richard Levitte
Browse files

Refactoring BIO: add wrappers around sockaddr et al

Because different platforms have different levels of support for IPv6,
different kinds of sockaddr variants, and some have getaddrinfo et al
while others don't, we could end up with a mess if ifdefs, duplicate
code and other maintainance nightmares.

Instead, we're introducing wrappers around the common form for socket
communication:
BIO_ADDR, closely related to struct sockaddr and some of its variants.
BIO_ADDRINFO, closely related to struct addrinfo.

With that comes support routines, both convenient creators and
accessors, plus a few utility functions:

BIO_parse_hostserv, takes a string of the form host:service and
splits it into host and service.  It checks for * in both parts, and
converts any [ipv6-address] syntax to ust the IPv6 address.

BIO_lookup, looks up information on a host.

All routines handle IPv4 (AF_INET) and IPv6 (AF_INET6) addresses, and
there is support for local sockets (AF_UNIX) as well.

Reviewed-by: default avatarKurt Roeckx <kurt@openssl.org>
parent ba2de73b
Loading
Loading
Loading
Loading
+2 −2
Changes for crypto/bio/Makefile.in: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -18,14 +18,14 @@ LIB=$(TOP)/libcrypto.a
LIBSRC= bio_lib.c bio_cb.c bio_err.c \
	bss_mem.c bss_null.c bss_fd.c \
	bss_file.c bss_sock.c bss_conn.c \
	bf_null.c bf_buff.c b_print.c b_dump.c \
	bf_null.c bf_buff.c b_print.c b_dump.c b_addr.c \
	b_sock.c bss_acpt.c bf_nbio.c bss_log.c bss_bio.c \
	bss_dgram.c
#	bf_lbuf.c
LIBOBJ= bio_lib.o bio_cb.o bio_err.o \
	bss_mem.o bss_null.o bss_fd.o \
	bss_file.o bss_sock.o bss_conn.o \
	bf_null.o bf_buff.o b_print.o b_dump.o \
	bf_null.o bf_buff.o b_print.o b_dump.o b_addr.o \
	b_sock.o bss_acpt.o bf_nbio.o bss_log.o bss_bio.o \
	bss_dgram.o
#	bf_lbuf.o

crypto/bio/b_addr.c

0 → 100644
+795 −0

File added.

Preview size limit exceeded, changes collapsed.

+1 −6
Changes for crypto/bio/b_sock.c: 1 added line, 6 removed lines.
Original line number Diff line number Diff line
@@ -58,16 +58,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define USE_SOCKETS
#include "internal/cryptlib.h"
#include <openssl/bio.h>
#if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_BSDSOCK)
# include <netdb.h>
#include "bio_lcl.h"
#if defined(NETWARE_CLIB)
# include <sys/ioctl.h>
NETDB_DEFINE_CONTEXT
#endif
#endif
#ifndef OPENSSL_NO_SOCK
# include <openssl/dso.h>
# define SOCKET_PROTOCOL IPPROTO_TCP
+78 −0

File changed.

Preview size limit exceeded, changes collapsed.

+109 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading