diff options
Diffstat (limited to 'src/lib/libcrypto/bio/bss_conn.c')
-rw-r--r-- | src/lib/libcrypto/bio/bss_conn.c | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/src/lib/libcrypto/bio/bss_conn.c b/src/lib/libcrypto/bio/bss_conn.c index 68c46e3d69..22d00b369e 100644 --- a/src/lib/libcrypto/bio/bss_conn.c +++ b/src/lib/libcrypto/bio/bss_conn.c | |||
@@ -90,11 +90,11 @@ typedef struct bio_connect_st | |||
90 | struct sockaddr_in them; | 90 | struct sockaddr_in them; |
91 | 91 | ||
92 | /* int socket; this will be kept in bio->num so that it is | 92 | /* int socket; this will be kept in bio->num so that it is |
93 | * compatable with the bss_sock bio */ | 93 | * compatible with the bss_sock bio */ |
94 | 94 | ||
95 | /* called when the connection is initially made | 95 | /* called when the connection is initially made |
96 | * callback(BIO,state,ret); The callback should return | 96 | * callback(BIO,state,ret); The callback should return |
97 | * 'ret'. state is for compatablity with the ssl info_callback */ | 97 | * 'ret'. state is for compatibility with the ssl info_callback */ |
98 | int (*info_callback)(); | 98 | int (*info_callback)(); |
99 | } BIO_CONNECT; | 99 | } BIO_CONNECT; |
100 | 100 | ||
@@ -104,6 +104,7 @@ static int conn_puts(BIO *h,char *str); | |||
104 | static long conn_ctrl(BIO *h,int cmd,long arg1,char *arg2); | 104 | static long conn_ctrl(BIO *h,int cmd,long arg1,char *arg2); |
105 | static int conn_new(BIO *h); | 105 | static int conn_new(BIO *h); |
106 | static int conn_free(BIO *data); | 106 | static int conn_free(BIO *data); |
107 | static long conn_callback_ctrl(BIO *h,int cmd,void *(*fp)()); | ||
107 | 108 | ||
108 | static int conn_state(BIO *b, BIO_CONNECT *c); | 109 | static int conn_state(BIO *b, BIO_CONNECT *c); |
109 | static void conn_close_socket(BIO *data); | 110 | static void conn_close_socket(BIO *data); |
@@ -121,6 +122,7 @@ static BIO_METHOD methods_connectp= | |||
121 | conn_ctrl, | 122 | conn_ctrl, |
122 | conn_new, | 123 | conn_new, |
123 | conn_free, | 124 | conn_free, |
125 | conn_callback_ctrl, | ||
124 | }; | 126 | }; |
125 | 127 | ||
126 | static int conn_state(BIO *b, BIO_CONNECT *c) | 128 | static int conn_state(BIO *b, BIO_CONNECT *c) |
@@ -494,7 +496,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr) | |||
494 | *((int *)ptr)=data->port; | 496 | *((int *)ptr)=data->port; |
495 | } | 497 | } |
496 | if ((!b->init) || (ptr == NULL)) | 498 | if ((!b->init) || (ptr == NULL)) |
497 | *pptr="not initalised"; | 499 | *pptr="not initialized"; |
498 | ret=1; | 500 | ret=1; |
499 | } | 501 | } |
500 | break; | 502 | break; |
@@ -564,16 +566,25 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr) | |||
564 | case BIO_CTRL_FLUSH: | 566 | case BIO_CTRL_FLUSH: |
565 | break; | 567 | break; |
566 | case BIO_CTRL_DUP: | 568 | case BIO_CTRL_DUP: |
569 | { | ||
567 | dbio=(BIO *)ptr; | 570 | dbio=(BIO *)ptr; |
568 | if (data->param_port) | 571 | if (data->param_port) |
569 | BIO_set_conn_port(dbio,data->param_port); | 572 | BIO_set_conn_port(dbio,data->param_port); |
570 | if (data->param_hostname) | 573 | if (data->param_hostname) |
571 | BIO_set_conn_hostname(dbio,data->param_hostname); | 574 | BIO_set_conn_hostname(dbio,data->param_hostname); |
572 | BIO_set_nbio(dbio,data->nbio); | 575 | BIO_set_nbio(dbio,data->nbio); |
573 | (void)BIO_set_info_callback(dbio,data->info_callback); | 576 | (void)BIO_set_info_callback(dbio,(void *(*)())(data->info_callback)); |
577 | } | ||
574 | break; | 578 | break; |
575 | case BIO_CTRL_SET_CALLBACK: | 579 | case BIO_CTRL_SET_CALLBACK: |
576 | data->info_callback=(int (*)())ptr; | 580 | { |
581 | #if 0 /* FIXME: Should this be used? -- Richard Levitte */ | ||
582 | BIOerr(BIO_F_CONN_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | ||
583 | ret = -1; | ||
584 | #else | ||
585 | ret=0; | ||
586 | #endif | ||
587 | } | ||
577 | break; | 588 | break; |
578 | case BIO_CTRL_GET_CALLBACK: | 589 | case BIO_CTRL_GET_CALLBACK: |
579 | { | 590 | { |
@@ -590,6 +601,27 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr) | |||
590 | return(ret); | 601 | return(ret); |
591 | } | 602 | } |
592 | 603 | ||
604 | static long conn_callback_ctrl(BIO *b, int cmd, void *(*fp)()) | ||
605 | { | ||
606 | long ret=1; | ||
607 | BIO_CONNECT *data; | ||
608 | |||
609 | data=(BIO_CONNECT *)b->ptr; | ||
610 | |||
611 | switch (cmd) | ||
612 | { | ||
613 | case BIO_CTRL_SET_CALLBACK: | ||
614 | { | ||
615 | data->info_callback=(int (*)())fp; | ||
616 | } | ||
617 | break; | ||
618 | default: | ||
619 | ret=0; | ||
620 | break; | ||
621 | } | ||
622 | return(ret); | ||
623 | } | ||
624 | |||
593 | static int conn_puts(BIO *bp, char *str) | 625 | static int conn_puts(BIO *bp, char *str) |
594 | { | 626 | { |
595 | int n,ret; | 627 | int n,ret; |