From 4de5e9f413e81b48e15ea236cc9538fb680805f0 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Tue, 15 Oct 2024 16:49:29 +0200 Subject: [PATCH] sys/net/gcoap_dns: update use of deprecated nanocoap APIs --- sys/net/application_layer/gcoap/dns.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sys/net/application_layer/gcoap/dns.c b/sys/net/application_layer/gcoap/dns.c index 7273ac1193..886c4b4b0b 100644 --- a/sys/net/application_layer/gcoap/dns.c +++ b/sys/net/application_layer/gcoap/dns.c @@ -17,22 +17,17 @@ #include #include -#include "fmt.h" -#include "log.h" #include "mutex.h" #include "net/credman.h" #include "net/gcoap.h" -#include "net/af.h" #include "net/dns/cache.h" #include "net/ipv4/addr.h" #include "net/ipv6/addr.h" #include "net/sock/dns.h" #include "net/sock/udp.h" -#include "net/sock/util.h" #include "random.h" #include "string_utils.h" #include "uri_parser.h" -#include "ut_process.h" #include "net/gcoap/dns.h" @@ -493,7 +488,7 @@ static ssize_t _req_init(coap_pkt_t *pdu, uri_parser_result_t *uri_comp, bool co gcoap_req_init_path_buffer(pdu, pdu->payload, pdu->payload_len, COAP_METHOD_FETCH, uri_comp->path, uri_comp->path_len); if (con) { - coap_hdr_set_type(pdu->hdr, COAP_TYPE_CON); + coap_pkt_set_type(pdu, COAP_TYPE_CON); } if (coap_opt_add_format(pdu, COAP_FORMAT_DNS_MESSAGE) < 0) { @@ -545,7 +540,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) { + if ((len = _send(pdu->buf, len, remote, slicer.start == 0, context, tl_type)) <= 0) { DEBUG("gcoap_dns: msg send failed: %" PRIdSIZE "\n", len); return len; } @@ -583,7 +578,7 @@ static ssize_t _req(_req_ctx_t *context) } len = coap_opt_finish(pdu, COAP_OPT_FINISH_PAYLOAD); memcpy(pdu->payload, context->dns_buf, context->dns_buf_len); - return _send(pdu->hdr, len + context->dns_buf_len, &_remote, true, context, tl_type); + return _send(pdu->buf, len + context->dns_buf_len, &_remote, true, context, tl_type); } } @@ -698,7 +693,7 @@ 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 = pdu->buf; pdu->payload_len = CONFIG_GCOAP_DNS_PDU_BUF_SIZE; tl_type = _req_init(pdu, &_uri_comp, msg_type == COAP_TYPE_ACK); block.blknum++; @@ -712,7 +707,7 @@ static void _resp_handler(const gcoap_request_memo_t *memo, coap_pkt_t *pdu, goto unlock; } len = coap_opt_finish(pdu, COAP_OPT_FINISH_NONE); - if ((len = _send((uint8_t *)pdu->hdr, len, remote, false, context, tl_type)) <= 0) { + if ((len = _send(pdu->buf, len, remote, false, context, tl_type)) <= 0) { DEBUG("gcoap_dns: Unable to request next block: %d\n", len); context->res = len; goto unlock;