Lines Matching defs:bio
57 #include <openssl/bio.h>
101 /* the file descriptor is kept in bio->num in order to match the socket
107 int (*info_callback)(const BIO *bio, int state, int ret);
167 static int conn_state(BIO *bio, BIO_CONNECT *c) {
205 &bio->num, &c->them, &c->them_length, c->param_hostname,
213 if (!bio_socket_nbio(bio->num, 1)) {
222 ret = setsockopt(bio->num, SOL_SOCKET, SO_KEEPALIVE, (char *)&i,
231 BIO_clear_retry_flags(bio);
232 ret = connect(bio->num, (struct sockaddr*) &c->them, c->them_length);
235 BIO_set_flags(bio, (BIO_FLAGS_IO_SPECIAL | BIO_FLAGS_SHOULD_RETRY));
237 bio->retry_reason = BIO_RR_CONNECT;
251 i = bio_sock_error(bio->num);
254 BIO_set_flags(bio, (BIO_FLAGS_IO_SPECIAL | BIO_FLAGS_SHOULD_RETRY));
256 bio->retry_reason = BIO_RR_CONNECT;
259 BIO_clear_retry_flags(bio);
280 ret = cb((BIO *)bio, c->state, ret);
289 ret = cb((BIO *)bio, c->state, ret);
318 static int conn_new(BIO *bio) {
319 bio->init = 0;
320 bio->num = -1;
321 bio->flags = 0;
322 bio->ptr = (char *)BIO_CONNECT_new();
323 return bio->ptr != NULL;
326 static void conn_close_socket(BIO *bio) {
327 BIO_CONNECT *c = (BIO_CONNECT *) bio->ptr;
329 if (bio->num == -1) {
335 shutdown(bio->num, 2);
337 closesocket(bio->num);
338 bio->num = -1;
341 static int conn_free(BIO *bio) {
342 if (bio == NULL) {
346 if (bio->shutdown) {
347 conn_close_socket(bio);
350 BIO_CONNECT_free((BIO_CONNECT*) bio->ptr);
355 static int conn_read(BIO *bio, char *out, int out_len) {
359 data = (BIO_CONNECT *)bio->ptr;
361 ret = conn_state(bio, data);
368 ret = recv(bio->num, out, out_len, 0);
369 BIO_clear_retry_flags(bio);
372 BIO_set_retry_read(bio);
379 static int conn_write(BIO *bio, const char *in, int in_len) {
383 data = (BIO_CONNECT *)bio->ptr;
385 ret = conn_state(bio, data);
392 ret = send(bio->num, in, in_len, 0);
393 BIO_clear_retry_flags(bio);
396 BIO_set_retry_write(bio);
403 static long conn_ctrl(BIO *bio, int cmd, long num, void *ptr) {
408 data = (BIO_CONNECT *)bio->ptr;
414 conn_close_socket(bio);
415 bio->flags = 0;
420 ret = (long)conn_state(bio, data);
427 bio->init = 1;
449 if (bio->init) {
452 *ip = bio->num;
454 ret = bio->num;
460 ret = bio->shutdown;
463 bio->shutdown = (int)num;
472 int (**fptr)(const BIO *bio, int state, int xret);
473 fptr = (int (**)(const BIO *bio, int state, int xret))ptr;
483 static long conn_callback_ctrl(BIO *bio, int cmd, bio_info_cb fp) {
487 data = (BIO_CONNECT *)bio->ptr;
522 int BIO_set_conn_hostname(BIO *bio, const char *name) {
523 return BIO_ctrl(bio, BIO_C_SET_CONNECT, 0, (void*) name);
526 int BIO_set_conn_port(BIO *bio, const char *port_str) {
527 return BIO_ctrl(bio, BIO_C_SET_CONNECT, 1, (void*) port_str);
530 int BIO_set_conn_int_port(BIO *bio, const int *port) {
533 return BIO_set_conn_port(bio, buf);
536 int BIO_set_nbio(BIO *bio, int on) {
537 return BIO_ctrl(bio, BIO_C_SET_NBIO, on, NULL);
540 int BIO_do_connect(BIO *bio) {
541 return BIO_ctrl(bio, BIO_C_DO_STATE_MACHINE, 0, NULL);