Lines Matching refs:tlsctx
494 struct tls_ctx *tlsctx; in tls_connect() local
541 tlsctx = calloc(1, sizeof(*tlsctx)); in tls_connect()
542 if (tlsctx == NULL) { in tls_connect()
549 tlsctx->tls_sock = sock; in tls_connect()
550 tlsctx->tls_tcp = NULL; in tls_connect()
551 tlsctx->tls_side = TLS_SIDE_CLIENT; in tls_connect()
552 tlsctx->tls_wait_called = false; in tls_connect()
553 tlsctx->tls_magic = TLS_CTX_MAGIC; in tls_connect()
555 error = tls_connect_wait(tlsctx, timeout); in tls_connect()
558 tls_close(tlsctx); in tls_connect()
562 *ctxp = tlsctx; in tls_connect()
570 struct tls_ctx *tlsctx = ctx; in tls_connect_wait() local
574 PJDLOG_ASSERT(tlsctx != NULL); in tls_connect_wait()
575 PJDLOG_ASSERT(tlsctx->tls_magic == TLS_CTX_MAGIC); in tls_connect_wait()
576 PJDLOG_ASSERT(tlsctx->tls_side == TLS_SIDE_CLIENT); in tls_connect_wait()
577 PJDLOG_ASSERT(tlsctx->tls_sock != NULL); in tls_connect_wait()
578 PJDLOG_ASSERT(!tlsctx->tls_wait_called); in tls_connect_wait()
581 sockfd = proto_descriptor(tlsctx->tls_sock); in tls_connect_wait()
599 tlsctx->tls_wait_called = true; in tls_connect_wait()
612 struct tls_ctx *tlsctx; in tls_server() local
619 tlsctx = malloc(sizeof(*tlsctx)); in tls_server()
620 if (tlsctx == NULL) { in tls_server()
627 free(tlsctx); in tls_server()
635 free(tlsctx); in tls_server()
641 tlsctx->tls_sock = NULL; in tls_server()
642 tlsctx->tls_tcp = tcp; in tls_server()
643 tlsctx->tls_side = TLS_SIDE_SERVER_LISTEN; in tls_server()
644 tlsctx->tls_wait_called = true; in tls_server()
645 tlsctx->tls_magic = TLS_CTX_MAGIC; in tls_server()
646 *ctxp = tlsctx; in tls_server()
776 struct tls_ctx *tlsctx = ctx; in tls_accept() local
782 PJDLOG_ASSERT(tlsctx != NULL); in tls_accept()
783 PJDLOG_ASSERT(tlsctx->tls_magic == TLS_CTX_MAGIC); in tls_accept()
784 PJDLOG_ASSERT(tlsctx->tls_side == TLS_SIDE_SERVER_LISTEN); in tls_accept()
790 if (proto_accept(tlsctx->tls_tcp, &tcp) == -1) { in tls_accept()
810 proto_close(tlsctx->tls_tcp); in tls_accept()
816 newtlsctx = calloc(1, sizeof(*tlsctx)); in tls_accept()
849 struct tls_ctx *tlsctx; in tls_wrap() local
853 tlsctx = calloc(1, sizeof(*tlsctx)); in tls_wrap()
854 if (tlsctx == NULL) in tls_wrap()
859 free(tlsctx); in tls_wrap()
863 tlsctx->tls_sock = sock; in tls_wrap()
864 tlsctx->tls_tcp = NULL; in tls_wrap()
865 tlsctx->tls_wait_called = (client ? false : true); in tls_wrap()
866 tlsctx->tls_side = (client ? TLS_SIDE_CLIENT : TLS_SIDE_SERVER_WORK); in tls_wrap()
867 tlsctx->tls_magic = TLS_CTX_MAGIC; in tls_wrap()
868 *ctxp = tlsctx; in tls_wrap()
876 struct tls_ctx *tlsctx = ctx; in tls_send() local
878 PJDLOG_ASSERT(tlsctx != NULL); in tls_send()
879 PJDLOG_ASSERT(tlsctx->tls_magic == TLS_CTX_MAGIC); in tls_send()
880 PJDLOG_ASSERT(tlsctx->tls_side == TLS_SIDE_CLIENT || in tls_send()
881 tlsctx->tls_side == TLS_SIDE_SERVER_WORK); in tls_send()
882 PJDLOG_ASSERT(tlsctx->tls_sock != NULL); in tls_send()
883 PJDLOG_ASSERT(tlsctx->tls_wait_called); in tls_send()
886 if (proto_send(tlsctx->tls_sock, data, size) == -1) in tls_send()
895 struct tls_ctx *tlsctx = ctx; in tls_recv() local
897 PJDLOG_ASSERT(tlsctx != NULL); in tls_recv()
898 PJDLOG_ASSERT(tlsctx->tls_magic == TLS_CTX_MAGIC); in tls_recv()
899 PJDLOG_ASSERT(tlsctx->tls_side == TLS_SIDE_CLIENT || in tls_recv()
900 tlsctx->tls_side == TLS_SIDE_SERVER_WORK); in tls_recv()
901 PJDLOG_ASSERT(tlsctx->tls_sock != NULL); in tls_recv()
902 PJDLOG_ASSERT(tlsctx->tls_wait_called); in tls_recv()
905 if (proto_recv(tlsctx->tls_sock, data, size) == -1) in tls_recv()
914 const struct tls_ctx *tlsctx = ctx; in tls_descriptor() local
916 PJDLOG_ASSERT(tlsctx != NULL); in tls_descriptor()
917 PJDLOG_ASSERT(tlsctx->tls_magic == TLS_CTX_MAGIC); in tls_descriptor()
919 switch (tlsctx->tls_side) { in tls_descriptor()
922 PJDLOG_ASSERT(tlsctx->tls_sock != NULL); in tls_descriptor()
924 return (proto_descriptor(tlsctx->tls_sock)); in tls_descriptor()
926 PJDLOG_ASSERT(tlsctx->tls_tcp != NULL); in tls_descriptor()
928 return (proto_descriptor(tlsctx->tls_tcp)); in tls_descriptor()
930 PJDLOG_ABORT("Invalid side (%d).", tlsctx->tls_side); in tls_descriptor()
937 const struct tls_ctx *tlsctx = ctx; in tcp_address_match() local
939 PJDLOG_ASSERT(tlsctx != NULL); in tcp_address_match()
940 PJDLOG_ASSERT(tlsctx->tls_magic == TLS_CTX_MAGIC); in tcp_address_match()
942 return (strcmp(tlsctx->tls_raddr, addr) == 0); in tcp_address_match()
948 const struct tls_ctx *tlsctx = ctx; in tls_local_address() local
950 PJDLOG_ASSERT(tlsctx != NULL); in tls_local_address()
951 PJDLOG_ASSERT(tlsctx->tls_magic == TLS_CTX_MAGIC); in tls_local_address()
952 PJDLOG_ASSERT(tlsctx->tls_wait_called); in tls_local_address()
954 switch (tlsctx->tls_side) { in tls_local_address()
956 PJDLOG_ASSERT(tlsctx->tls_sock != NULL); in tls_local_address()
961 PJDLOG_ASSERT(tlsctx->tls_sock != NULL); in tls_local_address()
963 PJDLOG_VERIFY(strlcpy(addr, tlsctx->tls_laddr, size) < size); in tls_local_address()
966 PJDLOG_ASSERT(tlsctx->tls_tcp != NULL); in tls_local_address()
968 proto_local_address(tlsctx->tls_tcp, addr, size); in tls_local_address()
974 PJDLOG_ABORT("Invalid side (%d).", tlsctx->tls_side); in tls_local_address()
981 const struct tls_ctx *tlsctx = ctx; in tls_remote_address() local
983 PJDLOG_ASSERT(tlsctx != NULL); in tls_remote_address()
984 PJDLOG_ASSERT(tlsctx->tls_magic == TLS_CTX_MAGIC); in tls_remote_address()
985 PJDLOG_ASSERT(tlsctx->tls_wait_called); in tls_remote_address()
987 switch (tlsctx->tls_side) { in tls_remote_address()
989 PJDLOG_ASSERT(tlsctx->tls_sock != NULL); in tls_remote_address()
994 PJDLOG_ASSERT(tlsctx->tls_sock != NULL); in tls_remote_address()
996 PJDLOG_VERIFY(strlcpy(addr, tlsctx->tls_raddr, size) < size); in tls_remote_address()
999 PJDLOG_ASSERT(tlsctx->tls_tcp != NULL); in tls_remote_address()
1001 proto_remote_address(tlsctx->tls_tcp, addr, size); in tls_remote_address()
1007 PJDLOG_ABORT("Invalid side (%d).", tlsctx->tls_side); in tls_remote_address()
1014 struct tls_ctx *tlsctx = ctx; in tls_close() local
1016 PJDLOG_ASSERT(tlsctx != NULL); in tls_close()
1017 PJDLOG_ASSERT(tlsctx->tls_magic == TLS_CTX_MAGIC); in tls_close()
1019 if (tlsctx->tls_sock != NULL) { in tls_close()
1020 proto_close(tlsctx->tls_sock); in tls_close()
1021 tlsctx->tls_sock = NULL; in tls_close()
1023 if (tlsctx->tls_tcp != NULL) { in tls_close()
1024 proto_close(tlsctx->tls_tcp); in tls_close()
1025 tlsctx->tls_tcp = NULL; in tls_close()
1027 tlsctx->tls_side = 0; in tls_close()
1028 tlsctx->tls_magic = 0; in tls_close()
1029 free(tlsctx); in tls_close()