Skip to content

Commit

Permalink
Merge pull request #18373 from miri64/backport/2022.07/gcoap_dns/fix/…
Browse files Browse the repository at this point in the history
…various

gcoap_dns: various fixes [backport 2022.07]
  • Loading branch information
miri64 authored Jul 27, 2022
2 parents 7e9a860 + dfbf597 commit 4592a53
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sys/net/application_layer/gcoap/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ static int _do_block(coap_pkt_t *pdu, const sock_udp_ep_t *remote,
coap_block1_finish(&slicer);

if ((len = _send(pdu->hdr, len, remote, slicer.start == 0, context, tl_type)) <= 0) {
printf("gcoap_dns: msg send failed: %d\n", (int)len);
DEBUG("gcoap_dns: msg send failed: %d\n", (int)len);
return len;
}
return len;
Expand Down Expand Up @@ -621,12 +621,12 @@ static void _resp_handler(const gcoap_request_memo_t *memo, coap_pkt_t *pdu,
int family = context->family;

if (memo->state == GCOAP_MEMO_TIMEOUT) {
printf("gcoap_dns: CoAP request timed out\n");
DEBUG("gcoap_dns: CoAP request timed out\n");
context->res = -ETIMEDOUT;
goto unlock;
}
else if (memo->state != GCOAP_MEMO_RESP) {
printf("gcoap_dns: error in response\n");
DEBUG("gcoap_dns: error in response\n");
context->res = -EBADMSG;
goto unlock;
}
Expand Down Expand Up @@ -668,7 +668,7 @@ static void _resp_handler(const gcoap_request_memo_t *memo, coap_pkt_t *pdu,
memcpy(&dns_buf[block.offset], pdu->payload, pdu->payload_len);
if (block.blknum == 0) {
context->dns_buf_len = pdu->payload_len;
if (block.more && strlen(_uri) > 0) {
if (block.more && strlen(_uri) == 0) {
DEBUG("gcoap_dns: Cannot complete block-wise\n");
context->res = -EINVAL;
goto unlock;
Expand All @@ -682,6 +682,8 @@ static void _resp_handler(const gcoap_request_memo_t *memo, coap_pkt_t *pdu,
unsigned msg_type = coap_get_type(pdu);
int len;

pdu->payload = (uint8_t *)pdu->hdr;
pdu->payload_len = CONFIG_GCOAP_DNS_PDU_BUF_SIZE;
tl_type = _req_init(pdu, &_uri_comp, msg_type == COAP_TYPE_ACK);
block.blknum++;
if (coap_opt_add_block2_control(pdu, &block) < 0) {
Expand Down

0 comments on commit 4592a53

Please sign in to comment.