]> git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/bio/bio_lcl.h
24f8b1859529a3104c553be5fd3d847aae898d9c
[thirdparty/openssl.git] / crypto / bio / bio_lcl.h
1 #define USE_SOCKETS
2 #include "e_os.h"
3
4 /* BEGIN BIO_ADDRINFO/BIO_ADDR stuff. */
5
6 #ifndef OPENSSL_NO_SOCK
7 /*
8 * Throughout this file and b_addr.c, the existence of the macro
9 * AI_PASSIVE is used to detect the availability of struct addrinfo,
10 * getnameinfo() and getaddrinfo(). If that macro doesn't exist,
11 * we use our own implementation instead.
12 */
13
14 /*
15 * It's imperative that these macros get defined before openssl/bio.h gets
16 * included. Otherwise, the AI_PASSIVE hack will not work properly.
17 * For clarity, we check for internal/cryptlib.h since it's a common header
18 * that also includes bio.h.
19 */
20 # ifdef HEADER_CRYPTLIB_H
21 # error internal/cryptlib.h included before bio_lcl.h
22 # endif
23 # ifdef HEADER_BIO_H
24 # error openssl/bio.h included before bio_lcl.h
25 # endif
26
27 /*
28 * Undefine AF_UNIX on systems that define it but don't support it.
29 */
30 # if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_VMS)
31 # undef AF_UNIX
32 # endif
33
34 # ifdef AI_PASSIVE
35 # define bio_addrinfo_st addrinfo
36 # define bai_family ai_family
37 # define bai_socktype ai_socktype
38 # define bai_protocol ai_protocol
39 # define bai_addrlen ai_addrlen
40 # define bai_addr ai_addr
41 # define bai_next ai_next
42 # else
43 struct bio_addrinfo_st {
44 int bai_family;
45 int bai_socktype;
46 int bai_protocol;
47 size_t bai_addrlen;
48 struct sockaddr *bai_addr;
49 struct bio_addrinfo_st *bai_next;
50 };
51 # endif
52
53 union bio_addr_st {
54 struct sockaddr sa;
55 # ifdef AF_INET6
56 struct sockaddr_in6 s_in6;
57 # endif
58 struct sockaddr_in s_in;
59 # ifdef AF_UNIX
60 struct sockaddr_un s_un;
61 # endif
62 };
63 #endif
64
65 /* END BIO_ADDRINFO/BIO_ADDR stuff. */
66
67 #include "internal/cryptlib.h"
68 #include <openssl/bio.h>
69
70 #ifndef OPENSSL_NO_SOCK
71 # ifdef OPENSSL_SYS_VMS
72 typedef unsigned int socklen_t;
73 # endif
74
75 int BIO_ADDR_make(BIO_ADDR *ap, const struct sockaddr *sa);
76 const struct sockaddr *BIO_ADDR_sockaddr(const BIO_ADDR *ap);
77 struct sockaddr *BIO_ADDR_sockaddr_noconst(BIO_ADDR *ap);
78 socklen_t BIO_ADDR_sockaddr_size(const BIO_ADDR *ap);
79 socklen_t BIO_ADDRINFO_sockaddr_size(const BIO_ADDRINFO *bai);
80 const struct sockaddr *BIO_ADDRINFO_sockaddr(const BIO_ADDRINFO *bai);
81 #endif
82
83 #if BIO_FLAGS_UPLINK==0
84 /* Shortcut UPLINK calls on most platforms... */
85 # define UP_stdin stdin
86 # define UP_stdout stdout
87 # define UP_stderr stderr
88 # define UP_fprintf fprintf
89 # define UP_fgets fgets
90 # define UP_fread fread
91 # define UP_fwrite fwrite
92 # undef UP_fsetmod
93 # define UP_feof feof
94 # define UP_fclose fclose
95
96 # define UP_fopen fopen
97 # define UP_fseek fseek
98 # define UP_ftell ftell
99 # define UP_fflush fflush
100 # define UP_ferror ferror
101 # ifdef _WIN32
102 # define UP_fileno _fileno
103 # define UP_open _open
104 # define UP_read _read
105 # define UP_write _write
106 # define UP_lseek _lseek
107 # define UP_close _close
108 # else
109 # define UP_fileno fileno
110 # define UP_open open
111 # define UP_read read
112 # define UP_write write
113 # define UP_lseek lseek
114 # define UP_close close
115 # endif
116
117 #endif
118