Skip to content

Commit 2730858

Browse files
committed
gcoap: make gcoap_req_send_tl() an alias of gcoap_req_send()
As per the deprecation notice from July 2021 ;-).
1 parent 84bf921 commit 2730858

File tree

8 files changed

+41
-34
lines changed

8 files changed

+41
-34
lines changed

examples/gcoap/client.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ static void _resp_handler(const gcoap_request_memo_t *memo, coap_pkt_t* pdu,
146146

147147
int len = coap_opt_finish(pdu, COAP_OPT_FINISH_NONE);
148148
gcoap_req_send((uint8_t *)pdu->hdr, len, remote,
149-
_resp_handler, memo->context);
149+
_resp_handler, memo->context,
150+
GCOAP_SOCKET_TYPE_UNDEF);
150151
}
151152
else {
152153
puts("--- blockwise complete ---");
@@ -158,7 +159,8 @@ static size_t _send(uint8_t *buf, size_t len, sock_udp_ep_t *remote)
158159
{
159160
size_t bytes_sent;
160161

161-
bytes_sent = gcoap_req_send(buf, len, remote, _resp_handler, NULL);
162+
bytes_sent = gcoap_req_send(buf, len, remote, _resp_handler, NULL,
163+
GCOAP_SOCKET_TYPE_UNDEF);
162164
if (bytes_sent > 0) {
163165
req_count++;
164166
}

sys/include/net/gcoap.h

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@
330330
* coap_opt_add_proxy_uri(&pdu, uri);
331331
* unsigned len = coap_opt_finish(&pdu, COAP_OPT_FINISH_NONE);
332332
*
333-
* gcoap_req_send((uint8_t *) pdu->hdr, len, proxy_remote, _resp_handler, NULL);
333+
* gcoap_req_send((uint8_t *) pdu->hdr, len, proxy_remote, _resp_handler, NULL,
334+
* GCOAP_SOCKET_TYPE_UNDEF);
334335
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
335336
*
336337
* See the gcoap example for a sample implementation.
@@ -960,9 +961,6 @@ static inline ssize_t gcoap_request(coap_pkt_t *pdu, uint8_t *buf, size_t len,
960961
/**
961962
* @brief Sends a buffer containing a CoAP request to the provided endpoint
962963
*
963-
* @deprecated Will be an alias for @ref gcoap_req_send after the 2022.01
964-
* release. Will be removed after the 2022.04 release.
965-
*
966964
* @param[in] buf Buffer containing the PDU
967965
* @param[in] len Length of the buffer
968966
* @param[in] remote Destination for the packet
@@ -973,39 +971,45 @@ static inline ssize_t gcoap_request(coap_pkt_t *pdu, uint8_t *buf, size_t len,
973971
* available (by value) will be selected. Only single
974972
* types are allowed, not a combination of them.
975973
*
974+
* @note The highest supported (by value) gcoap_socket_type_t will be selected
975+
* as transport type.
976+
*
976977
* @return length of the packet
977978
* @return -ENOTCONN, if DTLS was used and session establishment failed
978979
* @return -EINVAL, if @p tl_type is is not supported
979980
* @return 0 if cannot send
980981
*/
981-
ssize_t gcoap_req_send_tl(const uint8_t *buf, size_t len,
982-
const sock_udp_ep_t *remote,
983-
gcoap_resp_handler_t resp_handler, void *context,
984-
gcoap_socket_type_t tl_type);
982+
ssize_t gcoap_req_send(const uint8_t *buf, size_t len,
983+
const sock_udp_ep_t *remote,
984+
gcoap_resp_handler_t resp_handler, void *context,
985+
gcoap_socket_type_t tl_type);
985986

986987
/**
987988
* @brief Sends a buffer containing a CoAP request to the provided endpoint
988989
*
990+
* @deprecated Will be removed after the 2023.10 release. Use alias @ref gcoap_req_send() instead.
991+
*
989992
* @param[in] buf Buffer containing the PDU
990993
* @param[in] len Length of the buffer
991994
* @param[in] remote Destination for the packet
992995
* @param[in] resp_handler Callback when response received, may be NULL
993996
* @param[in] context User defined context passed to the response handler
994-
*
995-
* @note The highest supported (by value) gcoap_socket_type_t will be selected
996-
* as transport type.
997+
* @param[in] tl_type The transport type to use for send. When
998+
* @ref GCOAP_SOCKET_TYPE_UNDEF is selected, the highest
999+
* available (by value) will be selected. Only single
1000+
* types are allowed, not a combination of them.
9971001
*
9981002
* @return length of the packet
9991003
* @return -ENOTCONN, if DTLS was used and session establishment failed
1004+
* @return -EINVAL, if @p tl_type is is not supported
10001005
* @return 0 if cannot send
10011006
*/
1002-
static inline ssize_t gcoap_req_send(const uint8_t *buf, size_t len,
1003-
const sock_udp_ep_t *remote,
1004-
gcoap_resp_handler_t resp_handler,
1005-
void *context)
1007+
static inline ssize_t gcoap_req_send_tl(const uint8_t *buf, size_t len,
1008+
const sock_udp_ep_t *remote,
1009+
gcoap_resp_handler_t resp_handler, void *context,
1010+
gcoap_socket_type_t tl_type)
10061011
{
1007-
return gcoap_req_send_tl(buf, len, remote, resp_handler, context,
1008-
GCOAP_SOCKET_TYPE_UNDEF);
1012+
return gcoap_req_send(buf, len, remote, resp_handler, context, tl_type);
10091013
}
10101014

10111015
/**

sys/net/application_layer/cord/ep/cord_ep.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static int _update_remove(unsigned code, gcoap_resp_handler_t handle)
151151
ssize_t pkt_len = coap_opt_finish(&pkt, COAP_OPT_FINISH_NONE);
152152

153153
/* send request */
154-
ssize_t send_len = gcoap_req_send(buf, pkt_len, &_rd_remote, handle, NULL);
154+
ssize_t send_len = gcoap_req_send(buf, pkt_len, &_rd_remote, handle, NULL, GCOAP_SOCKET_TYPE_UNDEF);
155155
if (send_len <= 0) {
156156
return CORD_EP_ERR;
157157
}
@@ -225,7 +225,7 @@ static int _discover_internal(const sock_udp_ep_t *remote,
225225
coap_hdr_set_type(pkt.hdr, COAP_TYPE_CON);
226226
coap_opt_add_uri_query(&pkt, "rt", "core.rd");
227227
size_t pkt_len = coap_opt_finish(&pkt, COAP_OPT_FINISH_NONE);
228-
res = gcoap_req_send(buf, pkt_len, remote, _on_discover, NULL);
228+
res = gcoap_req_send(buf, pkt_len, remote, _on_discover, NULL, GCOAP_SOCKET_TYPE_UNDEF);
229229
if (res <= 0) {
230230
return CORD_EP_ERR;
231231
}
@@ -296,7 +296,7 @@ int cord_ep_register(const sock_udp_ep_t *remote, const char *regif)
296296
pkt_len += res;
297297

298298
/* send out the request */
299-
res = gcoap_req_send(buf, pkt_len, remote, _on_register, NULL);
299+
res = gcoap_req_send(buf, pkt_len, remote, _on_register, NULL, GCOAP_SOCKET_TYPE_UNDEF);
300300
if (res <= 0) {
301301
retval = CORD_EP_ERR;
302302
goto end;

sys/net/application_layer/cord/epsim/cord_epsim.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int cord_epsim_register(const sock_udp_ep_t *rd_ep)
6767
/* finish, we don't have any payload */
6868
ssize_t len = coap_opt_finish(&pkt, COAP_OPT_FINISH_NONE);
6969
_state = CORD_EPSIM_BUSY;
70-
if (gcoap_req_send(buf, len, rd_ep, _req_handler, NULL) == 0) {
70+
if (gcoap_req_send(buf, len, rd_ep, _req_handler, NULL, GCOAP_SOCKET_TYPE_UNDEF) == 0) {
7171
return CORD_EPSIM_ERROR;
7272
}
7373

sys/net/application_layer/cord/lc/cord_lc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static ssize_t _lookup_raw(const cord_lc_rd_t *rd, unsigned content_format,
190190
if (pkt_len < 0) {
191191
return CORD_LC_ERR;
192192
}
193-
res = gcoap_req_send(reqbuf, pkt_len, rd->remote, _on_lookup, NULL);
193+
res = gcoap_req_send(reqbuf, pkt_len, rd->remote, _on_lookup, NULL, GCOAP_SOCKET_TYPE_UNDEF);
194194
if (res < 0) {
195195
return CORD_LC_ERR;
196196
}
@@ -250,7 +250,7 @@ static int _send_rd_init_req(coap_pkt_t *pkt, const sock_udp_ep_t *remote,
250250
return CORD_LC_ERR;
251251
}
252252

253-
if (!gcoap_req_send(buf, pkt_len, remote, _on_rd_init, NULL)) {
253+
if (!gcoap_req_send(buf, pkt_len, remote, _on_rd_init, NULL, GCOAP_SOCKET_TYPE_UNDEF)) {
254254
DEBUG("cord_lc: error gcoap_req_send()\n");
255255
return CORD_LC_ERR;
256256
}

sys/net/application_layer/gcoap/dns.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,6 @@ static ssize_t _send(const void *buf, size_t len, const sock_udp_ep_t *remote,
765765
if (lock_resp_wait) {
766766
mutex_lock(&context->resp_wait);
767767
}
768-
return gcoap_req_send_tl(buf, len, remote, _resp_handler, context, tl_type);
768+
return gcoap_req_send(buf, len, remote, _resp_handler, context, tl_type);
769769
}
770770
/** @} */

sys/net/application_layer/gcoap/forward_proxy.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ static bool _parse_endpoint(sock_udp_ep_t *remote,
208208
static ssize_t _dispatch_msg(const void *buf, size_t len, sock_udp_ep_t *remote)
209209
{
210210
/* Yes it's not a request -- but turns out there is nothing in
211-
* gcoap_req_send_tl that is actually request specific, especially if we
211+
* gcoap_req_send that is actually request specific, especially if we
212212
* don't assign a callback. */
213-
ssize_t res = gcoap_req_send_tl(buf, len, remote, NULL, NULL,
214-
GCOAP_SOCKET_TYPE_UDP);
213+
ssize_t res = gcoap_req_send(buf, len, remote, NULL, NULL,
214+
GCOAP_SOCKET_TYPE_UDP);
215215
if (res <= 0) {
216216
DEBUG("gcoap_forward_proxy: unable to dispatch message: %d\n", -res);
217217
}
@@ -440,7 +440,8 @@ static int _gcoap_forward_proxy_via_coap(coap_pkt_t *client_pkt,
440440

441441
len = gcoap_req_send((uint8_t *)pkt.hdr, len,
442442
&origin_server_ep,
443-
_forward_resp_handler, (void *)client_ep);
443+
_forward_resp_handler, (void *)client_ep,
444+
GCOAP_SOCKET_TYPE_UNDEF);
444445
return len;
445446
}
446447

sys/net/application_layer/gcoap/gcoap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,10 +1612,10 @@ int gcoap_obs_req_forget(const sock_udp_ep_t *remote, const uint8_t *token,
16121612
return res;
16131613
}
16141614

1615-
ssize_t gcoap_req_send_tl(const uint8_t *buf, size_t len,
1616-
const sock_udp_ep_t *remote,
1617-
gcoap_resp_handler_t resp_handler, void *context,
1618-
gcoap_socket_type_t tl_type)
1615+
ssize_t gcoap_req_send(const uint8_t *buf, size_t len,
1616+
const sock_udp_ep_t *remote,
1617+
gcoap_resp_handler_t resp_handler, void *context,
1618+
gcoap_socket_type_t tl_type)
16191619
{
16201620
gcoap_socket_t socket = { 0 };
16211621
gcoap_request_memo_t *memo = NULL;

0 commit comments

Comments
 (0)