summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bio
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bio')
-rw-r--r--src/lib/libcrypto/bio/Makefile222
-rw-r--r--src/lib/libcrypto/bio/bio_lcl.h36
-rw-r--r--src/lib/libcrypto/bio/bss_dgram.c91
-rw-r--r--src/lib/libcrypto/bio/bss_log.c2
-rw-r--r--src/lib/libcrypto/bio/bss_rtcp.c294
5 files changed, 582 insertions, 63 deletions
diff --git a/src/lib/libcrypto/bio/Makefile b/src/lib/libcrypto/bio/Makefile
new file mode 100644
index 0000000000..c395d80496
--- /dev/null
+++ b/src/lib/libcrypto/bio/Makefile
@@ -0,0 +1,222 @@
1#
2# OpenSSL/crypto/bio/Makefile
3#
4
5DIR= bio
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10MAKEFILE= Makefile
11AR= ar r
12
13CFLAGS= $(INCLUDES) $(CFLAG)
14
15GENERAL=Makefile
16TEST=
17APPS=
18
19LIB=$(TOP)/libcrypto.a
20LIBSRC= bio_lib.c bio_cb.c bio_err.c \
21 bss_mem.c bss_null.c bss_fd.c \
22 bss_file.c bss_sock.c bss_conn.c \
23 bf_null.c bf_buff.c b_print.c b_dump.c \
24 b_sock.c bss_acpt.c bf_nbio.c bss_log.c bss_bio.c \
25 bss_dgram.c
26# bf_lbuf.c
27LIBOBJ= bio_lib.o bio_cb.o bio_err.o \
28 bss_mem.o bss_null.o bss_fd.o \
29 bss_file.o bss_sock.o bss_conn.o \
30 bf_null.o bf_buff.o b_print.o b_dump.o \
31 b_sock.o bss_acpt.o bf_nbio.o bss_log.o bss_bio.o \
32 bss_dgram.o
33# bf_lbuf.o
34
35SRC= $(LIBSRC)
36
37EXHEADER= bio.h
38HEADER= bio_lcl.h $(EXHEADER)
39
40ALL= $(GENERAL) $(SRC) $(HEADER)
41
42top:
43 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
44
45all: lib
46
47lib: $(LIBOBJ)
48 $(AR) $(LIB) $(LIBOBJ)
49 $(RANLIB) $(LIB) || echo Never mind.
50 @touch lib
51
52files:
53 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
54
55links:
56 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
57 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
58 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
59
60install:
61 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
62 @headerlist="$(EXHEADER)"; for i in $$headerlist; \
63 do \
64 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
65 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
66 done;
67
68tags:
69 ctags $(SRC)
70
71tests:
72
73lint:
74 lint -DLINT $(INCLUDES) $(SRC)>fluff
75
76depend:
77 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
78 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
79
80dclean:
81 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
82 mv -f Makefile.new $(MAKEFILE)
83
84clean:
85 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
86
87# DO NOT DELETE THIS LINE -- make depend depends on it.
88
89b_dump.o: ../../e_os.h ../../include/openssl/bio.h
90b_dump.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
91b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
92b_dump.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
93b_dump.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
94b_dump.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
95b_dump.o: ../../include/openssl/symhacks.h ../cryptlib.h b_dump.c bio_lcl.h
96b_print.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
97b_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
98b_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
99b_print.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
100b_print.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
101b_print.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
102b_print.o: ../../include/openssl/symhacks.h ../cryptlib.h b_print.c
103b_sock.o: ../../e_os.h ../../include/openssl/bio.h
104b_sock.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
105b_sock.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
106b_sock.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
107b_sock.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
108b_sock.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
109b_sock.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
110b_sock.o: ../cryptlib.h b_sock.c
111bf_buff.o: ../../e_os.h ../../include/openssl/bio.h
112bf_buff.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
113bf_buff.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
114bf_buff.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
115bf_buff.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
116bf_buff.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
117bf_buff.o: ../../include/openssl/symhacks.h ../cryptlib.h bf_buff.c
118bf_nbio.o: ../../e_os.h ../../include/openssl/bio.h
119bf_nbio.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
120bf_nbio.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
121bf_nbio.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
122bf_nbio.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
123bf_nbio.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
124bf_nbio.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
125bf_nbio.o: ../cryptlib.h bf_nbio.c
126bf_null.o: ../../e_os.h ../../include/openssl/bio.h
127bf_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
128bf_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
129bf_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
130bf_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
131bf_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
132bf_null.o: ../../include/openssl/symhacks.h ../cryptlib.h bf_null.c
133bio_cb.o: ../../e_os.h ../../include/openssl/bio.h
134bio_cb.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
135bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
136bio_cb.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
137bio_cb.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
138bio_cb.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
139bio_cb.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_cb.c
140bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
141bio_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
142bio_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
143bio_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
144bio_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
145bio_err.o: ../../include/openssl/symhacks.h bio_err.c
146bio_lib.o: ../../e_os.h ../../include/openssl/bio.h
147bio_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
148bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
149bio_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
150bio_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
151bio_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
152bio_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_lib.c
153bss_acpt.o: ../../e_os.h ../../include/openssl/bio.h
154bss_acpt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
155bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
156bss_acpt.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
157bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
158bss_acpt.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
159bss_acpt.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_acpt.c
160bss_bio.o: ../../e_os.h ../../include/openssl/bio.h
161bss_bio.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
162bss_bio.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
163bss_bio.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
164bss_bio.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
165bss_bio.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
166bss_bio.o: bss_bio.c
167bss_conn.o: ../../e_os.h ../../include/openssl/bio.h
168bss_conn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
169bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
170bss_conn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
171bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
172bss_conn.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
173bss_conn.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_conn.c
174bss_dgram.o: ../../e_os.h ../../include/openssl/bio.h
175bss_dgram.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
176bss_dgram.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
177bss_dgram.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
178bss_dgram.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
179bss_dgram.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
180bss_dgram.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_dgram.c
181bss_fd.o: ../../e_os.h ../../include/openssl/bio.h
182bss_fd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
183bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
184bss_fd.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
185bss_fd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
186bss_fd.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
187bss_fd.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_lcl.h bss_fd.c
188bss_file.o: ../../e_os.h ../../include/openssl/bio.h
189bss_file.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
190bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
191bss_file.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
192bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
193bss_file.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
194bss_file.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_lcl.h bss_file.c
195bss_log.o: ../../e_os.h ../../include/openssl/bio.h
196bss_log.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
197bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
198bss_log.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
199bss_log.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
200bss_log.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
201bss_log.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_log.c
202bss_mem.o: ../../e_os.h ../../include/openssl/bio.h
203bss_mem.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
204bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
205bss_mem.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
206bss_mem.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
207bss_mem.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
208bss_mem.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_mem.c
209bss_null.o: ../../e_os.h ../../include/openssl/bio.h
210bss_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
211bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
212bss_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
213bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
214bss_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
215bss_null.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_null.c
216bss_sock.o: ../../e_os.h ../../include/openssl/bio.h
217bss_sock.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
218bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
219bss_sock.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
220bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
221bss_sock.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
222bss_sock.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_sock.c
diff --git a/src/lib/libcrypto/bio/bio_lcl.h b/src/lib/libcrypto/bio/bio_lcl.h
new file mode 100644
index 0000000000..e7f7ec8d8b
--- /dev/null
+++ b/src/lib/libcrypto/bio/bio_lcl.h
@@ -0,0 +1,36 @@
1#include <openssl/bio.h>
2
3#if BIO_FLAGS_UPLINK==0
4/* Shortcut UPLINK calls on most platforms... */
5#define UP_stdin stdin
6#define UP_stdout stdout
7#define UP_stderr stderr
8#define UP_fprintf fprintf
9#define UP_fgets fgets
10#define UP_fread fread
11#define UP_fwrite fwrite
12#undef UP_fsetmod
13#define UP_feof feof
14#define UP_fclose fclose
15
16#define UP_fopen fopen
17#define UP_fseek fseek
18#define UP_ftell ftell
19#define UP_fflush fflush
20#define UP_ferror ferror
21#ifdef _WIN32
22#define UP_fileno _fileno
23#define UP_open _open
24#define UP_read _read
25#define UP_write _write
26#define UP_lseek _lseek
27#define UP_close _close
28#else
29#define UP_fileno fileno
30#define UP_open open
31#define UP_read read
32#define UP_write write
33#define UP_lseek lseek
34#define UP_close close
35#endif
36#endif
diff --git a/src/lib/libcrypto/bio/bss_dgram.c b/src/lib/libcrypto/bio/bss_dgram.c
index 54c012c47d..1b1e4bec81 100644
--- a/src/lib/libcrypto/bio/bss_dgram.c
+++ b/src/lib/libcrypto/bio/bss_dgram.c
@@ -77,20 +77,10 @@
77#define OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE 0xc0 77#define OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE 0xc0
78#endif 78#endif
79 79
80#if defined(OPENSSL_SYS_LINUX) && !defined(IP_MTU) 80#ifdef OPENSSL_SYS_LINUX
81#define IP_MTU 14 /* linux is lame */ 81#define IP_MTU 14 /* linux is lame */
82#endif 82#endif
83 83
84#if defined(__FreeBSD__) && defined(IN6_IS_ADDR_V4MAPPED)
85/* Standard definition causes type-punning problems. */
86#undef IN6_IS_ADDR_V4MAPPED
87#define s6_addr32 __u6_addr.__u6_addr32
88#define IN6_IS_ADDR_V4MAPPED(a) \
89 (((a)->s6_addr32[0] == 0) && \
90 ((a)->s6_addr32[1] == 0) && \
91 ((a)->s6_addr32[2] == htonl(0x0000ffff)))
92#endif
93
94#ifdef WATT32 84#ifdef WATT32
95#define sock_write SockWrite /* Watt-32 uses same names */ 85#define sock_write SockWrite /* Watt-32 uses same names */
96#define sock_read SockRead 86#define sock_read SockRead
@@ -265,7 +255,7 @@ static void dgram_adjust_rcv_timeout(BIO *b)
265 { 255 {
266#if defined(SO_RCVTIMEO) 256#if defined(SO_RCVTIMEO)
267 bio_dgram_data *data = (bio_dgram_data *)b->ptr; 257 bio_dgram_data *data = (bio_dgram_data *)b->ptr;
268 union { size_t s; int i; } sz = {0}; 258 int sz = sizeof(int);
269 259
270 /* Is a timer active? */ 260 /* Is a timer active? */
271 if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0) 261 if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0)
@@ -275,10 +265,8 @@ static void dgram_adjust_rcv_timeout(BIO *b)
275 /* Read current socket timeout */ 265 /* Read current socket timeout */
276#ifdef OPENSSL_SYS_WINDOWS 266#ifdef OPENSSL_SYS_WINDOWS
277 int timeout; 267 int timeout;
278
279 sz.i = sizeof(timeout);
280 if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, 268 if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
281 (void*)&timeout, &sz.i) < 0) 269 (void*)&timeout, &sz) < 0)
282 { perror("getsockopt"); } 270 { perror("getsockopt"); }
283 else 271 else
284 { 272 {
@@ -286,12 +274,9 @@ static void dgram_adjust_rcv_timeout(BIO *b)
286 data->socket_timeout.tv_usec = (timeout % 1000) * 1000; 274 data->socket_timeout.tv_usec = (timeout % 1000) * 1000;
287 } 275 }
288#else 276#else
289 sz.i = sizeof(data->socket_timeout);
290 if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, 277 if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
291 &(data->socket_timeout), (void *)&sz) < 0) 278 &(data->socket_timeout), (void *)&sz) < 0)
292 { perror("getsockopt"); } 279 { perror("getsockopt"); }
293 else if (sizeof(sz.s)!=sizeof(sz.i) && sz.i==0)
294 OPENSSL_assert(sz.s<=sizeof(data->socket_timeout));
295#endif 280#endif
296 281
297 /* Get current time */ 282 /* Get current time */
@@ -460,10 +445,11 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
460 int *ip; 445 int *ip;
461 struct sockaddr *to = NULL; 446 struct sockaddr *to = NULL;
462 bio_dgram_data *data = NULL; 447 bio_dgram_data *data = NULL;
463#if defined(OPENSSL_SYS_LINUX) && (defined(IP_MTU_DISCOVER) || defined(IP_MTU)) 448#if defined(IP_MTU_DISCOVER) || defined(IP_MTU)
464 int sockopt_val = 0; 449 long sockopt_val = 0;
465 socklen_t sockopt_len; /* assume that system supporting IP_MTU is 450 unsigned int sockopt_len = 0;
466 * modern enough to define socklen_t */ 451#endif
452#ifdef OPENSSL_SYS_LINUX
467 socklen_t addr_len; 453 socklen_t addr_len;
468 union { 454 union {
469 struct sockaddr sa; 455 struct sockaddr sa;
@@ -545,7 +531,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
545 break; 531 break;
546 /* (Linux)kernel sets DF bit on outgoing IP packets */ 532 /* (Linux)kernel sets DF bit on outgoing IP packets */
547 case BIO_CTRL_DGRAM_MTU_DISCOVER: 533 case BIO_CTRL_DGRAM_MTU_DISCOVER:
548#if defined(OPENSSL_SYS_LINUX) && defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO) 534#ifdef OPENSSL_SYS_LINUX
549 addr_len = (socklen_t)sizeof(addr); 535 addr_len = (socklen_t)sizeof(addr);
550 memset((void *)&addr, 0, sizeof(addr)); 536 memset((void *)&addr, 0, sizeof(addr));
551 if (getsockname(b->num, &addr.sa, &addr_len) < 0) 537 if (getsockname(b->num, &addr.sa, &addr_len) < 0)
@@ -553,6 +539,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
553 ret = 0; 539 ret = 0;
554 break; 540 break;
555 } 541 }
542 sockopt_len = sizeof(sockopt_val);
556 switch (addr.sa.sa_family) 543 switch (addr.sa.sa_family)
557 { 544 {
558 case AF_INET: 545 case AF_INET:
@@ -561,7 +548,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
561 &sockopt_val, sizeof(sockopt_val))) < 0) 548 &sockopt_val, sizeof(sockopt_val))) < 0)
562 perror("setsockopt"); 549 perror("setsockopt");
563 break; 550 break;
564#if OPENSSL_USE_IPV6 && defined(IPV6_MTU_DISCOVER) && defined(IPV6_PMTUDISC_DO) 551#if OPENSSL_USE_IPV6 && defined(IPV6_MTU_DISCOVER)
565 case AF_INET6: 552 case AF_INET6:
566 sockopt_val = IPV6_PMTUDISC_DO; 553 sockopt_val = IPV6_PMTUDISC_DO;
567 if ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER, 554 if ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER,
@@ -578,7 +565,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
578 break; 565 break;
579#endif 566#endif
580 case BIO_CTRL_DGRAM_QUERY_MTU: 567 case BIO_CTRL_DGRAM_QUERY_MTU:
581#if defined(OPENSSL_SYS_LINUX) && defined(IP_MTU) 568#ifdef OPENSSL_SYS_LINUX
582 addr_len = (socklen_t)sizeof(addr); 569 addr_len = (socklen_t)sizeof(addr);
583 memset((void *)&addr, 0, sizeof(addr)); 570 memset((void *)&addr, 0, sizeof(addr));
584 if (getsockname(b->num, &addr.sa, &addr_len) < 0) 571 if (getsockname(b->num, &addr.sa, &addr_len) < 0)
@@ -740,15 +727,12 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
740#endif 727#endif
741 break; 728 break;
742 case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT: 729 case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT:
743 {
744 union { size_t s; int i; } sz = {0};
745#ifdef OPENSSL_SYS_WINDOWS 730#ifdef OPENSSL_SYS_WINDOWS
746 int timeout; 731 {
732 int timeout, sz = sizeof(timeout);
747 struct timeval *tv = (struct timeval *)ptr; 733 struct timeval *tv = (struct timeval *)ptr;
748
749 sz.i = sizeof(timeout);
750 if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, 734 if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
751 (void*)&timeout, &sz.i) < 0) 735 (void*)&timeout, &sz) < 0)
752 { perror("getsockopt"); ret = -1; } 736 { perror("getsockopt"); ret = -1; }
753 else 737 else
754 { 738 {
@@ -756,20 +740,12 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
756 tv->tv_usec = (timeout % 1000) * 1000; 740 tv->tv_usec = (timeout % 1000) * 1000;
757 ret = sizeof(*tv); 741 ret = sizeof(*tv);
758 } 742 }
743 }
759#else 744#else
760 sz.i = sizeof(struct timeval);
761 if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, 745 if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
762 ptr, (void *)&sz) < 0) 746 ptr, (void *)&ret) < 0)
763 { perror("getsockopt"); ret = -1; } 747 { perror("getsockopt"); ret = -1; }
764 else if (sizeof(sz.s)!=sizeof(sz.i) && sz.i==0)
765 {
766 OPENSSL_assert(sz.s<=sizeof(struct timeval));
767 ret = (int)sz.s;
768 }
769 else
770 ret = sz.i;
771#endif 748#endif
772 }
773 break; 749 break;
774#endif 750#endif
775#if defined(SO_SNDTIMEO) 751#if defined(SO_SNDTIMEO)
@@ -789,15 +765,12 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
789#endif 765#endif
790 break; 766 break;
791 case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT: 767 case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT:
792 {
793 union { size_t s; int i; } sz = {0};
794#ifdef OPENSSL_SYS_WINDOWS 768#ifdef OPENSSL_SYS_WINDOWS
795 int timeout; 769 {
770 int timeout, sz = sizeof(timeout);
796 struct timeval *tv = (struct timeval *)ptr; 771 struct timeval *tv = (struct timeval *)ptr;
797
798 sz.i = sizeof(timeout);
799 if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, 772 if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,
800 (void*)&timeout, &sz.i) < 0) 773 (void*)&timeout, &sz) < 0)
801 { perror("getsockopt"); ret = -1; } 774 { perror("getsockopt"); ret = -1; }
802 else 775 else
803 { 776 {
@@ -805,20 +778,12 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
805 tv->tv_usec = (timeout % 1000) * 1000; 778 tv->tv_usec = (timeout % 1000) * 1000;
806 ret = sizeof(*tv); 779 ret = sizeof(*tv);
807 } 780 }
781 }
808#else 782#else
809 sz.i = sizeof(struct timeval);
810 if ( getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, 783 if ( getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,
811 ptr, (void *)&sz) < 0) 784 ptr, (void *)&ret) < 0)
812 { perror("getsockopt"); ret = -1; } 785 { perror("getsockopt"); ret = -1; }
813 else if (sizeof(sz.s)!=sizeof(sz.i) && sz.i==0)
814 {
815 OPENSSL_assert(sz.s<=sizeof(struct timeval));
816 ret = (int)sz.s;
817 }
818 else
819 ret = sz.i;
820#endif 786#endif
821 }
822 break; 787 break;
823#endif 788#endif
824 case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP: 789 case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP:
@@ -906,8 +871,8 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
906 memset(authchunks, 0, sizeof(sockopt_len)); 871 memset(authchunks, 0, sizeof(sockopt_len));
907 ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks, &sockopt_len); 872 ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks, &sockopt_len);
908 OPENSSL_assert(ret >= 0); 873 OPENSSL_assert(ret >= 0);
909 874
910 for (p = (unsigned char*) authchunks->gauth_chunks; 875 for (p = (unsigned char*) authchunks + sizeof(sctp_assoc_t);
911 p < (unsigned char*) authchunks + sockopt_len; 876 p < (unsigned char*) authchunks + sockopt_len;
912 p += sizeof(uint8_t)) 877 p += sizeof(uint8_t))
913 { 878 {
@@ -990,6 +955,7 @@ static int dgram_sctp_free(BIO *a)
990#ifdef SCTP_AUTHENTICATION_EVENT 955#ifdef SCTP_AUTHENTICATION_EVENT
991void dgram_sctp_handle_auth_free_key_event(BIO *b, union sctp_notification *snp) 956void dgram_sctp_handle_auth_free_key_event(BIO *b, union sctp_notification *snp)
992 { 957 {
958 unsigned int sockopt_len = 0;
993 int ret; 959 int ret;
994 struct sctp_authkey_event* authkeyevent = &snp->sn_auth_event; 960 struct sctp_authkey_event* authkeyevent = &snp->sn_auth_event;
995 961
@@ -999,8 +965,9 @@ void dgram_sctp_handle_auth_free_key_event(BIO *b, union sctp_notification *snp)
999 965
1000 /* delete key */ 966 /* delete key */
1001 authkeyid.scact_keynumber = authkeyevent->auth_keynumber; 967 authkeyid.scact_keynumber = authkeyevent->auth_keynumber;
968 sockopt_len = sizeof(struct sctp_authkeyid);
1002 ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_AUTH_DELETE_KEY, 969 ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_AUTH_DELETE_KEY,
1003 &authkeyid, sizeof(struct sctp_authkeyid)); 970 &authkeyid, sockopt_len);
1004 } 971 }
1005 } 972 }
1006#endif 973#endif
@@ -1197,7 +1164,7 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
1197 ii = getsockopt(b->num, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, authchunks, &optlen); 1164 ii = getsockopt(b->num, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, authchunks, &optlen);
1198 OPENSSL_assert(ii >= 0); 1165 OPENSSL_assert(ii >= 0);
1199 1166
1200 for (p = (unsigned char*) authchunks->gauth_chunks; 1167 for (p = (unsigned char*) authchunks + sizeof(sctp_assoc_t);
1201 p < (unsigned char*) authchunks + optlen; 1168 p < (unsigned char*) authchunks + optlen;
1202 p += sizeof(uint8_t)) 1169 p += sizeof(uint8_t))
1203 { 1170 {
@@ -1331,7 +1298,7 @@ static long dgram_sctp_ctrl(BIO *b, int cmd, long num, void *ptr)
1331 { 1298 {
1332 long ret=1; 1299 long ret=1;
1333 bio_dgram_sctp_data *data = NULL; 1300 bio_dgram_sctp_data *data = NULL;
1334 socklen_t sockopt_len = 0; 1301 unsigned int sockopt_len = 0;
1335 struct sctp_authkeyid authkeyid; 1302 struct sctp_authkeyid authkeyid;
1336 struct sctp_authkey *authkey; 1303 struct sctp_authkey *authkey;
1337 1304
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c
index 2227b2b52d..b7dce5c1a2 100644
--- a/src/lib/libcrypto/bio/bss_log.c
+++ b/src/lib/libcrypto/bio/bss_log.c
@@ -245,7 +245,7 @@ static int MS_CALLBACK slg_puts(BIO *bp, const char *str)
245 245
246static void xopenlog(BIO* bp, char* name, int level) 246static void xopenlog(BIO* bp, char* name, int level)
247{ 247{
248 if (check_winnt()) 248 if (GetVersion() < 0x80000000)
249 bp->ptr = RegisterEventSourceA(NULL,name); 249 bp->ptr = RegisterEventSourceA(NULL,name);
250 else 250 else
251 bp->ptr = NULL; 251 bp->ptr = NULL;
diff --git a/src/lib/libcrypto/bio/bss_rtcp.c b/src/lib/libcrypto/bio/bss_rtcp.c
new file mode 100644
index 0000000000..7dae485564
--- /dev/null
+++ b/src/lib/libcrypto/bio/bss_rtcp.c
@@ -0,0 +1,294 @@
1/* crypto/bio/bss_rtcp.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* Written by David L. Jones <jonesd@kcgl1.eng.ohio-state.edu>
60 * Date: 22-JUL-1996
61 * Revised: 25-SEP-1997 Update for 0.8.1, BIO_CTRL_SET -> BIO_C_SET_FD
62 */
63/* VMS */
64#include <stdio.h>
65#include <stdlib.h>
66#include <string.h>
67#include <errno.h>
68#include "cryptlib.h"
69#include <openssl/bio.h>
70
71#include <iodef.h> /* VMS IO$_ definitions */
72#include <starlet.h>
73
74typedef unsigned short io_channel;
75/*************************************************************************/
76struct io_status { short status, count; long flags; };
77
78struct rpc_msg { /* Should have member alignment inhibited */
79 char channel; /* 'A'-app data. 'R'-remote client 'G'-global */
80 char function; /* 'G'-get, 'P'-put, 'C'-confirm, 'X'-close */
81 unsigned short int length; /* Amount of data returned or max to return */
82 char data[4092]; /* variable data */
83};
84#define RPC_HDR_SIZE (sizeof(struct rpc_msg) - 4092)
85
86struct rpc_ctx {
87 int filled, pos;
88 struct rpc_msg msg;
89};
90
91static int rtcp_write(BIO *h,const char *buf,int num);
92static int rtcp_read(BIO *h,char *buf,int size);
93static int rtcp_puts(BIO *h,const char *str);
94static int rtcp_gets(BIO *h,char *str,int size);
95static long rtcp_ctrl(BIO *h,int cmd,long arg1,void *arg2);
96static int rtcp_new(BIO *h);
97static int rtcp_free(BIO *data);
98
99static BIO_METHOD rtcp_method=
100 {
101 BIO_TYPE_FD,
102 "RTCP",
103 rtcp_write,
104 rtcp_read,
105 rtcp_puts,
106 rtcp_gets,
107 rtcp_ctrl,
108 rtcp_new,
109 rtcp_free,
110 NULL,
111 };
112
113BIO_METHOD *BIO_s_rtcp(void)
114 {
115 return(&rtcp_method);
116 }
117/*****************************************************************************/
118/* Decnet I/O routines.
119 */
120
121#ifdef __DECC
122#pragma message save
123#pragma message disable DOLLARID
124#endif
125
126static int get ( io_channel chan, char *buffer, int maxlen, int *length )
127{
128 int status;
129 struct io_status iosb;
130 status = sys$qiow ( 0, chan, IO$_READVBLK, &iosb, 0, 0,
131 buffer, maxlen, 0, 0, 0, 0 );
132 if ( (status&1) == 1 ) status = iosb.status;
133 if ( (status&1) == 1 ) *length = iosb.count;
134 return status;
135}
136
137static int put ( io_channel chan, char *buffer, int length )
138{
139 int status;
140 struct io_status iosb;
141 status = sys$qiow ( 0, chan, IO$_WRITEVBLK, &iosb, 0, 0,
142 buffer, length, 0, 0, 0, 0 );
143 if ( (status&1) == 1 ) status = iosb.status;
144 return status;
145}
146
147#ifdef __DECC
148#pragma message restore
149#endif
150
151/***************************************************************************/
152
153static int rtcp_new(BIO *bi)
154{
155 struct rpc_ctx *ctx;
156 bi->init=1;
157 bi->num=0;
158 bi->flags = 0;
159 bi->ptr=OPENSSL_malloc(sizeof(struct rpc_ctx));
160 ctx = (struct rpc_ctx *) bi->ptr;
161 ctx->filled = 0;
162 ctx->pos = 0;
163 return(1);
164}
165
166static int rtcp_free(BIO *a)
167{
168 if (a == NULL) return(0);
169 if ( a->ptr ) OPENSSL_free ( a->ptr );
170 a->ptr = NULL;
171 return(1);
172}
173
174static int rtcp_read(BIO *b, char *out, int outl)
175{
176 int status, length;
177 struct rpc_ctx *ctx;
178 /*
179 * read data, return existing.
180 */
181 ctx = (struct rpc_ctx *) b->ptr;
182 if ( ctx->pos < ctx->filled ) {
183 length = ctx->filled - ctx->pos;
184 if ( length > outl ) length = outl;
185 memmove ( out, &ctx->msg.data[ctx->pos], length );
186 ctx->pos += length;
187 return length;
188 }
189 /*
190 * Requst more data from R channel.
191 */
192 ctx->msg.channel = 'R';
193 ctx->msg.function = 'G';
194 ctx->msg.length = sizeof(ctx->msg.data);
195 status = put ( b->num, (char *) &ctx->msg, RPC_HDR_SIZE );
196 if ( (status&1) == 0 ) {
197 return -1;
198 }
199 /*
200 * Read.
201 */
202 ctx->pos = ctx->filled = 0;
203 status = get ( b->num, (char *) &ctx->msg, sizeof(ctx->msg), &length );
204 if ( (status&1) == 0 ) length = -1;
205 if ( ctx->msg.channel != 'R' || ctx->msg.function != 'C' ) {
206 length = -1;
207 }
208 ctx->filled = length - RPC_HDR_SIZE;
209
210 if ( ctx->pos < ctx->filled ) {
211 length = ctx->filled - ctx->pos;
212 if ( length > outl ) length = outl;
213 memmove ( out, ctx->msg.data, length );
214 ctx->pos += length;
215 return length;
216 }
217
218 return length;
219}
220
221static int rtcp_write(BIO *b, const char *in, int inl)
222{
223 int status, i, segment, length;
224 struct rpc_ctx *ctx;
225 /*
226 * Output data, send in chunks no larger that sizeof(ctx->msg.data).
227 */
228 ctx = (struct rpc_ctx *) b->ptr;
229 for ( i = 0; i < inl; i += segment ) {
230 segment = inl - i;
231 if ( segment > sizeof(ctx->msg.data) ) segment = sizeof(ctx->msg.data);
232 ctx->msg.channel = 'R';
233 ctx->msg.function = 'P';
234 ctx->msg.length = segment;
235 memmove ( ctx->msg.data, &in[i], segment );
236 status = put ( b->num, (char *) &ctx->msg, segment + RPC_HDR_SIZE );
237 if ((status&1) == 0 ) { i = -1; break; }
238
239 status = get ( b->num, (char *) &ctx->msg, sizeof(ctx->msg), &length );
240 if ( ((status&1) == 0) || (length < RPC_HDR_SIZE) ) { i = -1; break; }
241 if ( (ctx->msg.channel != 'R') || (ctx->msg.function != 'C') ) {
242 printf("unexpected response when confirming put %c %c\n",
243 ctx->msg.channel, ctx->msg.function );
244
245 }
246 }
247 return(i);
248}
249
250static long rtcp_ctrl(BIO *b, int cmd, long num, void *ptr)
251 {
252 long ret=1;
253
254 switch (cmd)
255 {
256 case BIO_CTRL_RESET:
257 case BIO_CTRL_EOF:
258 ret = 1;
259 break;
260 case BIO_C_SET_FD:
261 b->num = num;
262 ret = 1;
263 break;
264 case BIO_CTRL_SET_CLOSE:
265 case BIO_CTRL_FLUSH:
266 case BIO_CTRL_DUP:
267 ret=1;
268 break;
269 case BIO_CTRL_GET_CLOSE:
270 case BIO_CTRL_INFO:
271 case BIO_CTRL_GET:
272 case BIO_CTRL_PENDING:
273 case BIO_CTRL_WPENDING:
274 default:
275 ret=0;
276 break;
277 }
278 return(ret);
279 }
280
281static int rtcp_gets(BIO *bp, char *buf, int size)
282 {
283 return(0);
284 }
285
286static int rtcp_puts(BIO *bp, const char *str)
287{
288 int length;
289 if (str == NULL) return(0);
290 length = strlen ( str );
291 if ( length == 0 ) return (0);
292 return rtcp_write ( bp,str, length );
293}
294