OLD | NEW |
1 /* crypto/bio/bss_acpt.c */ | 1 /* crypto/bio/bss_acpt.c */ |
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
8 * | 8 * |
9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } BIO_ACCEPT; | 93 } BIO_ACCEPT; |
94 | 94 |
95 static int acpt_write(BIO *h, const char *buf, int num); | 95 static int acpt_write(BIO *h, const char *buf, int num); |
96 static int acpt_read(BIO *h, char *buf, int size); | 96 static int acpt_read(BIO *h, char *buf, int size); |
97 static int acpt_puts(BIO *h, const char *str); | 97 static int acpt_puts(BIO *h, const char *str); |
98 static long acpt_ctrl(BIO *h, int cmd, long arg1, void *arg2); | 98 static long acpt_ctrl(BIO *h, int cmd, long arg1, void *arg2); |
99 static int acpt_new(BIO *h); | 99 static int acpt_new(BIO *h); |
100 static int acpt_free(BIO *data); | 100 static int acpt_free(BIO *data); |
101 static int acpt_state(BIO *b, BIO_ACCEPT *c); | 101 static int acpt_state(BIO *b, BIO_ACCEPT *c); |
102 static void acpt_close_socket(BIO *data); | 102 static void acpt_close_socket(BIO *data); |
103 BIO_ACCEPT *BIO_ACCEPT_new(void ); | 103 static BIO_ACCEPT *BIO_ACCEPT_new(void ); |
104 void BIO_ACCEPT_free(BIO_ACCEPT *a); | 104 static void BIO_ACCEPT_free(BIO_ACCEPT *a); |
105 | 105 |
106 #define ACPT_S_BEFORE 1 | 106 #define ACPT_S_BEFORE 1 |
107 #define ACPT_S_GET_ACCEPT_SOCKET 2 | 107 #define ACPT_S_GET_ACCEPT_SOCKET 2 |
108 #define ACPT_S_OK 3 | 108 #define ACPT_S_OK 3 |
109 | 109 |
110 static BIO_METHOD methods_acceptp= | 110 static BIO_METHOD methods_acceptp= |
111 { | 111 { |
112 BIO_TYPE_ACCEPT, | 112 BIO_TYPE_ACCEPT, |
113 "socket accept", | 113 "socket accept", |
114 acpt_write, | 114 acpt_write, |
(...skipping 19 matching lines...) Expand all Loading... |
134 bi->num=INVALID_SOCKET; | 134 bi->num=INVALID_SOCKET; |
135 bi->flags=0; | 135 bi->flags=0; |
136 if ((ba=BIO_ACCEPT_new()) == NULL) | 136 if ((ba=BIO_ACCEPT_new()) == NULL) |
137 return(0); | 137 return(0); |
138 bi->ptr=(char *)ba; | 138 bi->ptr=(char *)ba; |
139 ba->state=ACPT_S_BEFORE; | 139 ba->state=ACPT_S_BEFORE; |
140 bi->shutdown=1; | 140 bi->shutdown=1; |
141 return(1); | 141 return(1); |
142 } | 142 } |
143 | 143 |
144 BIO_ACCEPT *BIO_ACCEPT_new(void) | 144 static BIO_ACCEPT *BIO_ACCEPT_new(void) |
145 { | 145 { |
146 BIO_ACCEPT *ret; | 146 BIO_ACCEPT *ret; |
147 | 147 |
148 if ((ret=(BIO_ACCEPT *)OPENSSL_malloc(sizeof(BIO_ACCEPT))) == NULL) | 148 if ((ret=(BIO_ACCEPT *)OPENSSL_malloc(sizeof(BIO_ACCEPT))) == NULL) |
149 return(NULL); | 149 return(NULL); |
150 | 150 |
151 memset(ret,0,sizeof(BIO_ACCEPT)); | 151 memset(ret,0,sizeof(BIO_ACCEPT)); |
152 ret->accept_sock=INVALID_SOCKET; | 152 ret->accept_sock=INVALID_SOCKET; |
153 ret->bind_mode=BIO_BIND_NORMAL; | 153 ret->bind_mode=BIO_BIND_NORMAL; |
154 return(ret); | 154 return(ret); |
155 } | 155 } |
156 | 156 |
157 void BIO_ACCEPT_free(BIO_ACCEPT *a) | 157 static void BIO_ACCEPT_free(BIO_ACCEPT *a) |
158 { | 158 { |
159 if(a == NULL) | 159 if(a == NULL) |
160 return; | 160 return; |
161 | 161 |
162 if (a->param_addr != NULL) OPENSSL_free(a->param_addr); | 162 if (a->param_addr != NULL) OPENSSL_free(a->param_addr); |
163 if (a->addr != NULL) OPENSSL_free(a->addr); | 163 if (a->addr != NULL) OPENSSL_free(a->addr); |
164 if (a->bio_chain != NULL) BIO_free(a->bio_chain); | 164 if (a->bio_chain != NULL) BIO_free(a->bio_chain); |
165 OPENSSL_free(a); | 165 OPENSSL_free(a); |
166 } | 166 } |
167 | 167 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 if (ret <= 0) return(ret); | 333 if (ret <= 0) return(ret); |
334 } | 334 } |
335 | 335 |
336 ret=BIO_write(b->next_bio,in,inl); | 336 ret=BIO_write(b->next_bio,in,inl); |
337 BIO_copy_next_retry(b); | 337 BIO_copy_next_retry(b); |
338 return(ret); | 338 return(ret); |
339 } | 339 } |
340 | 340 |
341 static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr) | 341 static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr) |
342 { | 342 { |
343 BIO *dbio; | |
344 int *ip; | 343 int *ip; |
345 long ret=1; | 344 long ret=1; |
346 BIO_ACCEPT *data; | 345 BIO_ACCEPT *data; |
347 char **pp; | 346 char **pp; |
348 | 347 |
349 data=(BIO_ACCEPT *)b->ptr; | 348 data=(BIO_ACCEPT *)b->ptr; |
350 | 349 |
351 switch (cmd) | 350 switch (cmd) |
352 { | 351 { |
353 case BIO_CTRL_RESET: | 352 case BIO_CTRL_RESET: |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 break; | 429 break; |
431 case BIO_CTRL_FLUSH: | 430 case BIO_CTRL_FLUSH: |
432 break; | 431 break; |
433 case BIO_C_SET_BIND_MODE: | 432 case BIO_C_SET_BIND_MODE: |
434 data->bind_mode=(int)num; | 433 data->bind_mode=(int)num; |
435 break; | 434 break; |
436 case BIO_C_GET_BIND_MODE: | 435 case BIO_C_GET_BIND_MODE: |
437 ret=(long)data->bind_mode; | 436 ret=(long)data->bind_mode; |
438 break; | 437 break; |
439 case BIO_CTRL_DUP: | 438 case BIO_CTRL_DUP: |
440 » » dbio=(BIO *)ptr; | 439 /*» » dbio=(BIO *)ptr; |
441 /*» » if (data->param_port) EAY EAY | 440 » » if (data->param_port) EAY EAY |
442 BIO_set_port(dbio,data->param_port); | 441 BIO_set_port(dbio,data->param_port); |
443 if (data->param_hostname) | 442 if (data->param_hostname) |
444 BIO_set_hostname(dbio,data->param_hostname); | 443 BIO_set_hostname(dbio,data->param_hostname); |
445 BIO_set_nbio(dbio,data->nbio); */ | 444 BIO_set_nbio(dbio,data->nbio); */ |
446 break; | 445 break; |
447 | 446 |
448 default: | 447 default: |
449 ret=0; | 448 ret=0; |
450 break; | 449 break; |
451 } | 450 } |
(...skipping 18 matching lines...) Expand all Loading... |
470 if (BIO_set_accept_port(ret,str)) | 469 if (BIO_set_accept_port(ret,str)) |
471 return(ret); | 470 return(ret); |
472 else | 471 else |
473 { | 472 { |
474 BIO_free(ret); | 473 BIO_free(ret); |
475 return(NULL); | 474 return(NULL); |
476 } | 475 } |
477 } | 476 } |
478 | 477 |
479 #endif | 478 #endif |
OLD | NEW |