1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-16 01:53:51 +01:00

sys/net/gcoap_dns: update use of deprecated nanocoap APIs

This commit is contained in:
Marian Buschsieweke 2024-10-15 16:49:29 +02:00 committed by Marian Buschsieweke
parent 9b18061719
commit 4de5e9f413
No known key found for this signature in database
GPG Key ID: 77AA882EC78084E6

View File

@ -17,22 +17,17 @@
#include <errno.h>
#include <stdbool.h>
#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;