diff options
Diffstat (limited to 'src/lib/libcrypto/bio')
| -rw-r--r-- | src/lib/libcrypto/bio/Makefile | 222 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bio_lcl.h | 36 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_dgram.c | 91 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_log.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_rtcp.c | 294 |
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 | |||
| 5 | DIR= bio | ||
| 6 | TOP= ../.. | ||
| 7 | CC= cc | ||
| 8 | INCLUDES= -I.. -I$(TOP) -I../../include | ||
| 9 | CFLAG=-g | ||
| 10 | MAKEFILE= Makefile | ||
| 11 | AR= ar r | ||
| 12 | |||
| 13 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
| 14 | |||
| 15 | GENERAL=Makefile | ||
| 16 | TEST= | ||
| 17 | APPS= | ||
| 18 | |||
| 19 | LIB=$(TOP)/libcrypto.a | ||
| 20 | LIBSRC= 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 | ||
| 27 | LIBOBJ= 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 | |||
| 35 | SRC= $(LIBSRC) | ||
| 36 | |||
| 37 | EXHEADER= bio.h | ||
| 38 | HEADER= bio_lcl.h $(EXHEADER) | ||
| 39 | |||
| 40 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
| 41 | |||
| 42 | top: | ||
| 43 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
| 44 | |||
| 45 | all: lib | ||
| 46 | |||
| 47 | lib: $(LIBOBJ) | ||
| 48 | $(AR) $(LIB) $(LIBOBJ) | ||
| 49 | $(RANLIB) $(LIB) || echo Never mind. | ||
| 50 | @touch lib | ||
| 51 | |||
| 52 | files: | ||
| 53 | $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO | ||
| 54 | |||
| 55 | links: | ||
| 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 | |||
| 60 | install: | ||
| 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 | |||
| 68 | tags: | ||
| 69 | ctags $(SRC) | ||
| 70 | |||
| 71 | tests: | ||
| 72 | |||
| 73 | lint: | ||
| 74 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
| 75 | |||
| 76 | depend: | ||
| 77 | @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile... | ||
| 78 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) | ||
| 79 | |||
| 80 | dclean: | ||
| 81 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
| 82 | mv -f Makefile.new $(MAKEFILE) | ||
| 83 | |||
| 84 | clean: | ||
| 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 | |||
| 89 | b_dump.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 90 | b_dump.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 91 | b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 92 | b_dump.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 93 | b_dump.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 94 | b_dump.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 95 | b_dump.o: ../../include/openssl/symhacks.h ../cryptlib.h b_dump.c bio_lcl.h | ||
| 96 | b_print.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 97 | b_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 98 | b_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 99 | b_print.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 100 | b_print.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 101 | b_print.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 102 | b_print.o: ../../include/openssl/symhacks.h ../cryptlib.h b_print.c | ||
| 103 | b_sock.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 104 | b_sock.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 105 | b_sock.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 106 | b_sock.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 107 | b_sock.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 108 | b_sock.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | ||
| 109 | b_sock.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 110 | b_sock.o: ../cryptlib.h b_sock.c | ||
| 111 | bf_buff.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 112 | bf_buff.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 113 | bf_buff.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 114 | bf_buff.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 115 | bf_buff.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 116 | bf_buff.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 117 | bf_buff.o: ../../include/openssl/symhacks.h ../cryptlib.h bf_buff.c | ||
| 118 | bf_nbio.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 119 | bf_nbio.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 120 | bf_nbio.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 121 | bf_nbio.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 122 | bf_nbio.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 123 | bf_nbio.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | ||
| 124 | bf_nbio.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 125 | bf_nbio.o: ../cryptlib.h bf_nbio.c | ||
| 126 | bf_null.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 127 | bf_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 128 | bf_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 129 | bf_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 130 | bf_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 131 | bf_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 132 | bf_null.o: ../../include/openssl/symhacks.h ../cryptlib.h bf_null.c | ||
| 133 | bio_cb.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 134 | bio_cb.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 135 | bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 136 | bio_cb.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 137 | bio_cb.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 138 | bio_cb.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 139 | bio_cb.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_cb.c | ||
| 140 | bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h | ||
| 141 | bio_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 142 | bio_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 143 | bio_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 144 | bio_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 145 | bio_err.o: ../../include/openssl/symhacks.h bio_err.c | ||
| 146 | bio_lib.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 147 | bio_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 148 | bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 149 | bio_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 150 | bio_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 151 | bio_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 152 | bio_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_lib.c | ||
| 153 | bss_acpt.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 154 | bss_acpt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 155 | bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 156 | bss_acpt.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 157 | bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 158 | bss_acpt.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 159 | bss_acpt.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_acpt.c | ||
| 160 | bss_bio.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 161 | bss_bio.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
| 162 | bss_bio.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 163 | bss_bio.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 164 | bss_bio.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | ||
| 165 | bss_bio.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 166 | bss_bio.o: bss_bio.c | ||
| 167 | bss_conn.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 168 | bss_conn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 169 | bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 170 | bss_conn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 171 | bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 172 | bss_conn.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 173 | bss_conn.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_conn.c | ||
| 174 | bss_dgram.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 175 | bss_dgram.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 176 | bss_dgram.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 177 | bss_dgram.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 178 | bss_dgram.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 179 | bss_dgram.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 180 | bss_dgram.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_dgram.c | ||
| 181 | bss_fd.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 182 | bss_fd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 183 | bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 184 | bss_fd.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 185 | bss_fd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 186 | bss_fd.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 187 | bss_fd.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_lcl.h bss_fd.c | ||
| 188 | bss_file.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 189 | bss_file.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 190 | bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 191 | bss_file.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 192 | bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 193 | bss_file.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 194 | bss_file.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_lcl.h bss_file.c | ||
| 195 | bss_log.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 196 | bss_log.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 197 | bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 198 | bss_log.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 199 | bss_log.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 200 | bss_log.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 201 | bss_log.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_log.c | ||
| 202 | bss_mem.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 203 | bss_mem.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 204 | bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 205 | bss_mem.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 206 | bss_mem.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 207 | bss_mem.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 208 | bss_mem.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_mem.c | ||
| 209 | bss_null.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 210 | bss_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 211 | bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 212 | bss_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 213 | bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 214 | bss_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 215 | bss_null.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_null.c | ||
| 216 | bss_sock.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 217 | bss_sock.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 218 | bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 219 | bss_sock.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 220 | bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 221 | bss_sock.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 222 | bss_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 |
| 991 | void dgram_sctp_handle_auth_free_key_event(BIO *b, union sctp_notification *snp) | 956 | void 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 | ||
| 246 | static void xopenlog(BIO* bp, char* name, int level) | 246 | static 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 | |||
| 74 | typedef unsigned short io_channel; | ||
| 75 | /*************************************************************************/ | ||
| 76 | struct io_status { short status, count; long flags; }; | ||
| 77 | |||
| 78 | struct 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 | |||
| 86 | struct rpc_ctx { | ||
| 87 | int filled, pos; | ||
| 88 | struct rpc_msg msg; | ||
| 89 | }; | ||
| 90 | |||
| 91 | static int rtcp_write(BIO *h,const char *buf,int num); | ||
| 92 | static int rtcp_read(BIO *h,char *buf,int size); | ||
| 93 | static int rtcp_puts(BIO *h,const char *str); | ||
| 94 | static int rtcp_gets(BIO *h,char *str,int size); | ||
| 95 | static long rtcp_ctrl(BIO *h,int cmd,long arg1,void *arg2); | ||
| 96 | static int rtcp_new(BIO *h); | ||
| 97 | static int rtcp_free(BIO *data); | ||
| 98 | |||
| 99 | static 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 | |||
| 113 | BIO_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 | |||
| 126 | static 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 | |||
| 137 | static 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 | |||
| 153 | static 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 | |||
| 166 | static 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 | |||
| 174 | static 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 | |||
| 221 | static 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 | |||
| 250 | static 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 | |||
| 281 | static int rtcp_gets(BIO *bp, char *buf, int size) | ||
| 282 | { | ||
| 283 | return(0); | ||
| 284 | } | ||
| 285 | |||
| 286 | static 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 | |||
