diff options
author | beck <> | 1999-09-29 04:37:45 +0000 |
---|---|---|
committer | beck <> | 1999-09-29 04:37:45 +0000 |
commit | de8f24ea083384bb66b32ec105dc4743c5663cdf (patch) | |
tree | 1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/bio/bss_sock.c | |
parent | cb929d29896bcb87c2a97417fbd03e50078fc178 (diff) | |
download | openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2 openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip |
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/bio/bss_sock.c')
-rw-r--r-- | src/lib/libcrypto/bio/bss_sock.c | 118 |
1 files changed, 40 insertions, 78 deletions
diff --git a/src/lib/libcrypto/bio/bss_sock.c b/src/lib/libcrypto/bio/bss_sock.c index d907a2867b..d336b99fe8 100644 --- a/src/lib/libcrypto/bio/bss_sock.c +++ b/src/lib/libcrypto/bio/bss_sock.c | |||
@@ -62,10 +62,9 @@ | |||
62 | #include <errno.h> | 62 | #include <errno.h> |
63 | #define USE_SOCKETS | 63 | #define USE_SOCKETS |
64 | #include "cryptlib.h" | 64 | #include "cryptlib.h" |
65 | #include "bio.h" | 65 | #include <openssl/bio.h> |
66 | 66 | ||
67 | #ifndef BIO_FD | 67 | #ifndef BIO_FD |
68 | #ifndef NOPROTO | ||
69 | static int sock_write(BIO *h,char *buf,int num); | 68 | static int sock_write(BIO *h,char *buf,int num); |
70 | static int sock_read(BIO *h,char *buf,int size); | 69 | static int sock_read(BIO *h,char *buf,int size); |
71 | static int sock_puts(BIO *h,char *str); | 70 | static int sock_puts(BIO *h,char *str); |
@@ -74,18 +73,7 @@ static int sock_new(BIO *h); | |||
74 | static int sock_free(BIO *data); | 73 | static int sock_free(BIO *data); |
75 | int BIO_sock_should_retry(int s); | 74 | int BIO_sock_should_retry(int s); |
76 | #else | 75 | #else |
77 | static int sock_write(); | ||
78 | static int sock_read(); | ||
79 | static int sock_puts(); | ||
80 | static long sock_ctrl(); | ||
81 | static int sock_new(); | ||
82 | static int sock_free(); | ||
83 | int BIO_sock_should_retry(); | ||
84 | #endif | ||
85 | |||
86 | #else | ||
87 | 76 | ||
88 | #ifndef NOPROTO | ||
89 | static int fd_write(BIO *h,char *buf,int num); | 77 | static int fd_write(BIO *h,char *buf,int num); |
90 | static int fd_read(BIO *h,char *buf,int size); | 78 | static int fd_read(BIO *h,char *buf,int size); |
91 | static int fd_puts(BIO *h,char *str); | 79 | static int fd_puts(BIO *h,char *str); |
@@ -93,15 +81,6 @@ static long fd_ctrl(BIO *h,int cmd,long arg1,char *arg2); | |||
93 | static int fd_new(BIO *h); | 81 | static int fd_new(BIO *h); |
94 | static int fd_free(BIO *data); | 82 | static int fd_free(BIO *data); |
95 | int BIO_fd_should_retry(int s); | 83 | int BIO_fd_should_retry(int s); |
96 | #else | ||
97 | static int fd_write(); | ||
98 | static int fd_read(); | ||
99 | static int fd_puts(); | ||
100 | static long fd_ctrl(); | ||
101 | static int fd_new(); | ||
102 | static int fd_free(); | ||
103 | int BIO_fd_should_retry(); | ||
104 | #endif | ||
105 | #endif | 84 | #endif |
106 | 85 | ||
107 | #ifndef BIO_FD | 86 | #ifndef BIO_FD |
@@ -118,7 +97,7 @@ static BIO_METHOD methods_sockp= | |||
118 | sock_free, | 97 | sock_free, |
119 | }; | 98 | }; |
120 | 99 | ||
121 | BIO_METHOD *BIO_s_socket() | 100 | BIO_METHOD *BIO_s_socket(void) |
122 | { | 101 | { |
123 | return(&methods_sockp); | 102 | return(&methods_sockp); |
124 | } | 103 | } |
@@ -135,19 +114,17 @@ static BIO_METHOD methods_fdp= | |||
135 | fd_free, | 114 | fd_free, |
136 | }; | 115 | }; |
137 | 116 | ||
138 | BIO_METHOD *BIO_s_fd() | 117 | BIO_METHOD *BIO_s_fd(void) |
139 | { | 118 | { |
140 | return(&methods_fdp); | 119 | return(&methods_fdp); |
141 | } | 120 | } |
142 | #endif | 121 | #endif |
143 | 122 | ||
144 | #ifndef BIO_FD | 123 | #ifndef BIO_FD |
145 | BIO *BIO_new_socket(fd,close_flag) | 124 | BIO *BIO_new_socket(int fd, int close_flag) |
146 | #else | 125 | #else |
147 | BIO *BIO_new_fd(fd,close_flag) | 126 | BIO *BIO_new_fd(int fd,int close_flag) |
148 | #endif | 127 | #endif |
149 | int fd; | ||
150 | int close_flag; | ||
151 | { | 128 | { |
152 | BIO *ret; | 129 | BIO *ret; |
153 | 130 | ||
@@ -162,11 +139,10 @@ int close_flag; | |||
162 | } | 139 | } |
163 | 140 | ||
164 | #ifndef BIO_FD | 141 | #ifndef BIO_FD |
165 | static int sock_new(bi) | 142 | static int sock_new(BIO *bi) |
166 | #else | 143 | #else |
167 | static int fd_new(bi) | 144 | static int fd_new(BIO *bi) |
168 | #endif | 145 | #endif |
169 | BIO *bi; | ||
170 | { | 146 | { |
171 | bi->init=0; | 147 | bi->init=0; |
172 | bi->num=0; | 148 | bi->num=0; |
@@ -176,11 +152,10 @@ BIO *bi; | |||
176 | } | 152 | } |
177 | 153 | ||
178 | #ifndef BIO_FD | 154 | #ifndef BIO_FD |
179 | static int sock_free(a) | 155 | static int sock_free(BIO *a) |
180 | #else | 156 | #else |
181 | static int fd_free(a) | 157 | static int fd_free(BIO *a) |
182 | #endif | 158 | #endif |
183 | BIO *a; | ||
184 | { | 159 | { |
185 | if (a == NULL) return(0); | 160 | if (a == NULL) return(0); |
186 | if (a->shutdown) | 161 | if (a->shutdown) |
@@ -189,11 +164,7 @@ BIO *a; | |||
189 | { | 164 | { |
190 | #ifndef BIO_FD | 165 | #ifndef BIO_FD |
191 | shutdown(a->num,2); | 166 | shutdown(a->num,2); |
192 | # ifdef WINDOWS | ||
193 | closesocket(a->num); | 167 | closesocket(a->num); |
194 | # else | ||
195 | close(a->num); | ||
196 | # endif | ||
197 | #else /* BIO_FD */ | 168 | #else /* BIO_FD */ |
198 | close(a->num); | 169 | close(a->num); |
199 | #endif | 170 | #endif |
@@ -206,21 +177,18 @@ BIO *a; | |||
206 | } | 177 | } |
207 | 178 | ||
208 | #ifndef BIO_FD | 179 | #ifndef BIO_FD |
209 | static int sock_read(b,out,outl) | 180 | static int sock_read(BIO *b, char *out, int outl) |
210 | #else | 181 | #else |
211 | static int fd_read(b,out,outl) | 182 | static int fd_read(BIO *b, char *out,int outl) |
212 | #endif | 183 | #endif |
213 | BIO *b; | ||
214 | char *out; | ||
215 | int outl; | ||
216 | { | 184 | { |
217 | int ret=0; | 185 | int ret=0; |
218 | 186 | ||
219 | if (out != NULL) | 187 | if (out != NULL) |
220 | { | 188 | { |
221 | #if defined(WINDOWS) && !defined(BIO_FD) | 189 | #ifndef BIO_FD |
222 | clear_socket_error(); | 190 | clear_socket_error(); |
223 | ret=recv(b->num,out,outl,0); | 191 | ret=readsocket(b->num,out,outl); |
224 | #else | 192 | #else |
225 | clear_sys_error(); | 193 | clear_sys_error(); |
226 | ret=read(b->num,out,outl); | 194 | ret=read(b->num,out,outl); |
@@ -240,19 +208,16 @@ int outl; | |||
240 | } | 208 | } |
241 | 209 | ||
242 | #ifndef BIO_FD | 210 | #ifndef BIO_FD |
243 | static int sock_write(b,in,inl) | 211 | static int sock_write(BIO *b, char *in, int inl) |
244 | #else | 212 | #else |
245 | static int fd_write(b,in,inl) | 213 | static int fd_write(BIO *b, char *in, int inl) |
246 | #endif | 214 | #endif |
247 | BIO *b; | ||
248 | char *in; | ||
249 | int inl; | ||
250 | { | 215 | { |
251 | int ret; | 216 | int ret; |
252 | 217 | ||
253 | #if defined(WINDOWS) && !defined(BIO_FD) | 218 | #ifndef BIO_FD |
254 | clear_socket_error(); | 219 | clear_socket_error(); |
255 | ret=send(b->num,in,inl,0); | 220 | ret=writesocket(b->num,in,inl); |
256 | #else | 221 | #else |
257 | clear_sys_error(); | 222 | clear_sys_error(); |
258 | ret=write(b->num,in,inl); | 223 | ret=write(b->num,in,inl); |
@@ -271,14 +236,10 @@ int inl; | |||
271 | } | 236 | } |
272 | 237 | ||
273 | #ifndef BIO_FD | 238 | #ifndef BIO_FD |
274 | static long sock_ctrl(b,cmd,num,ptr) | 239 | static long sock_ctrl(BIO *b, int cmd, long num, char *ptr) |
275 | #else | 240 | #else |
276 | static long fd_ctrl(b,cmd,num,ptr) | 241 | static long fd_ctrl(BIO *b, int cmd, long num, char *ptr) |
277 | #endif | 242 | #endif |
278 | BIO *b; | ||
279 | int cmd; | ||
280 | long num; | ||
281 | char *ptr; | ||
282 | { | 243 | { |
283 | long ret=1; | 244 | long ret=1; |
284 | int *ip; | 245 | int *ip; |
@@ -286,14 +247,21 @@ char *ptr; | |||
286 | switch (cmd) | 247 | switch (cmd) |
287 | { | 248 | { |
288 | case BIO_CTRL_RESET: | 249 | case BIO_CTRL_RESET: |
250 | num=0; | ||
251 | case BIO_C_FILE_SEEK: | ||
289 | #ifdef BIO_FD | 252 | #ifdef BIO_FD |
290 | ret=(long)lseek(b->num,0,0); | 253 | ret=(long)lseek(b->num,num,0); |
291 | #else | 254 | #else |
292 | ret=0; | 255 | ret=0; |
293 | #endif | 256 | #endif |
294 | break; | 257 | break; |
258 | case BIO_C_FILE_TELL: | ||
295 | case BIO_CTRL_INFO: | 259 | case BIO_CTRL_INFO: |
260 | #ifdef BIO_FD | ||
261 | ret=(long)lseek(b->num,0,1); | ||
262 | #else | ||
296 | ret=0; | 263 | ret=0; |
264 | #endif | ||
297 | break; | 265 | break; |
298 | case BIO_C_SET_FD: | 266 | case BIO_C_SET_FD: |
299 | #ifndef BIO_FD | 267 | #ifndef BIO_FD |
@@ -329,7 +297,6 @@ char *ptr; | |||
329 | case BIO_CTRL_FLUSH: | 297 | case BIO_CTRL_FLUSH: |
330 | ret=1; | 298 | ret=1; |
331 | break; | 299 | break; |
332 | break; | ||
333 | default: | 300 | default: |
334 | ret=0; | 301 | ret=0; |
335 | break; | 302 | break; |
@@ -338,22 +305,17 @@ char *ptr; | |||
338 | } | 305 | } |
339 | 306 | ||
340 | #ifdef undef | 307 | #ifdef undef |
341 | static int sock_gets(bp,buf,size) | 308 | static int sock_gets(BIO *bp, char *buf,int size) |
342 | BIO *bp; | ||
343 | char *buf; | ||
344 | int size; | ||
345 | { | 309 | { |
346 | return(-1); | 310 | return(-1); |
347 | } | 311 | } |
348 | #endif | 312 | #endif |
349 | 313 | ||
350 | #ifndef BIO_FD | 314 | #ifndef BIO_FD |
351 | static int sock_puts(bp,str) | 315 | static int sock_puts(BIO *bp, char *str) |
352 | #else | 316 | #else |
353 | static int fd_puts(bp,str) | 317 | static int fd_puts(BIO *bp, char *str) |
354 | #endif | 318 | #endif |
355 | BIO *bp; | ||
356 | char *str; | ||
357 | { | 319 | { |
358 | int n,ret; | 320 | int n,ret; |
359 | 321 | ||
@@ -367,23 +329,22 @@ char *str; | |||
367 | } | 329 | } |
368 | 330 | ||
369 | #ifndef BIO_FD | 331 | #ifndef BIO_FD |
370 | int BIO_sock_should_retry(i) | 332 | int BIO_sock_should_retry(int i) |
371 | #else | 333 | #else |
372 | int BIO_fd_should_retry(i) | 334 | int BIO_fd_should_retry(int i) |
373 | #endif | 335 | #endif |
374 | int i; | ||
375 | { | 336 | { |
376 | int err; | 337 | int err; |
377 | 338 | ||
378 | if ((i == 0) || (i == -1)) | 339 | if ((i == 0) || (i == -1)) |
379 | { | 340 | { |
380 | #if !defined(BIO_FD) && defined(WINDOWS) | 341 | #ifndef BIO_FD |
381 | err=get_last_socket_error(); | 342 | err=get_last_socket_error(); |
382 | #else | 343 | #else |
383 | err=get_last_sys_error(); | 344 | err=get_last_sys_error(); |
384 | #endif | 345 | #endif |
385 | 346 | ||
386 | #if defined(WINDOWS) /* more microsoft stupidity */ | 347 | #if defined(WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */ |
387 | if ((i == -1) && (err == 0)) | 348 | if ((i == -1) && (err == 0)) |
388 | return(1); | 349 | return(1); |
389 | #endif | 350 | #endif |
@@ -398,11 +359,10 @@ int i; | |||
398 | } | 359 | } |
399 | 360 | ||
400 | #ifndef BIO_FD | 361 | #ifndef BIO_FD |
401 | int BIO_sock_non_fatal_error(err) | 362 | int BIO_sock_non_fatal_error(int err) |
402 | #else | 363 | #else |
403 | int BIO_fd_non_fatal_error(err) | 364 | int BIO_fd_non_fatal_error(int err) |
404 | #endif | 365 | #endif |
405 | int err; | ||
406 | { | 366 | { |
407 | switch (err) | 367 | switch (err) |
408 | { | 368 | { |
@@ -411,8 +371,10 @@ int err; | |||
411 | case WSAEWOULDBLOCK: | 371 | case WSAEWOULDBLOCK: |
412 | # endif | 372 | # endif |
413 | 373 | ||
414 | # if defined(WSAENOTCONN) | 374 | # if 0 /* This appears to always be an error */ |
375 | # if defined(WSAENOTCONN) | ||
415 | case WSAENOTCONN: | 376 | case WSAENOTCONN: |
377 | # endif | ||
416 | # endif | 378 | # endif |
417 | #endif | 379 | #endif |
418 | 380 | ||
@@ -452,7 +414,7 @@ int err; | |||
452 | case EALREADY: | 414 | case EALREADY: |
453 | #endif | 415 | #endif |
454 | return(1); | 416 | return(1); |
455 | break; | 417 | /* break; */ |
456 | default: | 418 | default: |
457 | break; | 419 | break; |
458 | } | 420 | } |