Branch Coverage

src/ldns/net.c
Criterion Covered Total %
branch 84 198 42.4


line true false branch
43 26 0 if (query_pkt && ldns_pkt_tsig(query_pkt)) {
0 26 if (query_pkt && ldns_pkt_tsig(query_pkt)) {
69 0 28 if (!data) {
104 28 0 return ldns_rdf2native_sockaddr_storage_port(
114 27 0 if((flag = fcntl(sockfd, F_GETFL)) != -1) {
134 2 0 if((flag = fcntl(sockfd, F_GETFL)) != -1) {
157 2 34 if(write)
162 3 33 if(ret == 0)
165 0 33 else if(ret == -1)
180 0 2 if ((sockfd = socket((int)((struct sockaddr*)to)->sa_family, SOCK_STREAM,
185 0 2 if (from && bind(sockfd, (const struct sockaddr*)from, fromlen) == -1){
0 0 if (from && bind(sockfd, (const struct sockaddr*)from, fromlen) == -1){
191 2 0 if (connect(sockfd, (struct sockaddr*)to, tolen) == -1) {
194 0 2 if(errno != EINPROGRESS) {
216 0 2 if(!ldns_sock_wait(sockfd, timeout, 1)) {
226 0 2 if(getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void*)&error,
236 2 0 if(error == EINPROGRESS || error == EWOULDBLOCK)
0 2 if(error == EINPROGRESS || error == EWOULDBLOCK)
239 0 2 else if(error != 0) {
283 0 0 if (sockfd == 0) {
287 0 0 if (ldns_tcp_send_query(qbin, sockfd, to, tolen) == 0) {
322 0 0 if (sockfd == 0) {
333 0 0 if (*answer_size == 0) {
340 0 0 if(!*result) {
362 0 28 if ((sockfd = socket((int)((struct sockaddr*)to)->sa_family, SOCK_DGRAM,
381 0 28 if (sockfd == 0) {
385 0 28 if (from && bind(sockfd, (const struct sockaddr*)from, fromlen) == -1){
0 0 if (from && bind(sockfd, (const struct sockaddr*)from, fromlen) == -1){
389 0 28 if (ldns_udp_send_query(qbin, sockfd, to, tolen) == 0) {
419 0 28 if (sockfd == 0) {
424 3 25 if(!ldns_sock_wait(sockfd, timeout, 0)) {
445 0 25 if (*answer_size == 0) {
495 26 0 if (ldns_resolver_random(r)) {
499 0 26 if(ldns_resolver_source(r)) {
505 26 1 for (i = 0; i < ldns_resolver_nameserver_count(r); i++) {
506 0 26 if (rtt[i] == LDNS_RESOLV_RTT_INF) {
543 0 26 if (ldns_resolver_usevc(r)) {
544 0 0 for (retries = ldns_resolver_retry(r); retries > 0; retries--) {
551 0 0 if (send_status == LDNS_STATUS_OK) {
556 28 1 for (retries = ldns_resolver_retry(r); retries > 0; retries--) {
564 25 3 if (send_status == LDNS_STATUS_OK) {
570 1 25 if (send_status != LDNS_STATUS_OK) {
576 1 25 if (!reply_bytes) {
578 0 1 if (ldns_resolver_fail(r)) {
588 0 25 if (status != LDNS_STATUS_OK) {
597 25 0 if (reply) {
607 0 0 if (ldns_resolver_fail(r)) {
618 0 26 if(src) {
621 0 26 if (all_servers_rtt_inf) {
626 0 26 if (tsig_mac && reply && reply_bytes) {
0 0 if (tsig_mac && reply && reply_bytes) {
0 0 if (tsig_mac && reply && reply_bytes) {
627 0 0 if (!ldns_pkt_tsig_verify(reply,
640 26 0 if (result) {
656 0 2 if(!sendbuf) return 0;
665 2 0 if (bytes == -1 || (size_t) bytes != ldns_buffer_position(qbin) + 2 ) {
0 2 if (bytes == -1 || (size_t) bytes != ldns_buffer_position(qbin) + 2 ) {
681 28 0 if (bytes == -1 || (size_t)bytes != ldns_buffer_position(qbin)) {
0 28 if (bytes == -1 || (size_t)bytes != ldns_buffer_position(qbin)) {
684 0 28 if ((size_t) bytes != ldns_buffer_position(qbin)) {
698 0 25 if (!wire) {
707 25 0 if (wire_size == -1 || wire_size == 0) {
0 25 if (wire_size == -1 || wire_size == 0) {
715 0 25 if(!wireout) LDNS_FREE(wire);
728 0 2 if (!wire) {
733 2 2 while (bytes < 2) {
734 0 2 if(!ldns_sock_wait(sockfd, timeout, 0)) {
741 2 0 if (rc == -1 || rc == 0) {
0 2 if (rc == -1 || rc == 0) {
753 0 2 if (!wire) {
759 4 2 while (bytes < (ssize_t) wire_size) {
760 0 4 if(!ldns_sock_wait(sockfd, timeout, 0)) {
767 4 0 if (rc == -1 || rc == 0) {
0 4 if (rc == -1 || rc == 0) {
787 0 0 if (!wire) {
792 0 0 while (bytes < 2) {
795 0 0 if (rc == -1 || rc == 0) {
0 0 if (rc == -1 || rc == 0) {
807 0 0 if (!wire) {
813 0 0 while (bytes < (ssize_t) wire_size) {
816 0 0 if (rc == -1 || rc == 0) {
0 0 if (rc == -1 || rc == 0) {
839 0 0 if (port) {
847 0 0 if (port) {
854 0 0 if (port) {
877 2 0 if (!resolver || ldns_resolver_nameserver_count(resolver) < 1) {
0 2 if (!resolver || ldns_resolver_nameserver_count(resolver) < 1) {
883 0 2 if (!query) {
886 0 2 if(ldns_resolver_source(resolver)) {
893 2 2 for (ns_i = 0;
894 2 0 ns_i < ldns_resolver_nameserver_count(resolver) &&
897 0 2 if (ns != NULL) {
910 0 2 if (resolver->_socket == 0) {
917 0 2 if (ldns_resolver_tsig_keyname(resolver) && ldns_resolver_tsig_keydata(resolver)) {
0 0 if (ldns_resolver_tsig_keyname(resolver) && ldns_resolver_tsig_keydata(resolver)) {
922 0 0 if (status != LDNS_STATUS_OK) {
944 0 2 if(!query_wire) {
957 0 2 if (status != LDNS_STATUS_OK) {
974 0 2 if (ldns_tcp_send_query(query_wire, resolver->_socket, ns,