coap_io.c, coap_io_riot.c: RIOT-specific coap_network_send()

The RIOT-specific version of coap_network_send() has been moved
to coap_io_riot.c for clarity.
This commit is contained in:
Olaf Bergmann authored and Jon Shallow committed 2020-04-24 20:16:10 +01:00
1 parent ad1c985fcf
commit 648d8b9a33
2 files changed
+25

No files matched your search

+2
View File
@@ -538,6 +538,7 @@ static __declspec(thread) LPFN_WSARECVMSG lpWSARecvMsg = NULL;
#define iov_len_t size_t
#endif
#ifndef RIOT_VERSION
ssize_t
coap_network_send(coap_socket_t *sock, const coap_session_t *session, const uint8_t *data, size_t datalen) {
ssize_t bytes_written = 0;
@@ -712,6 +713,7 @@ coap_network_send(coap_socket_t *sock, const coap_session_t *session, const uint
return bytes_written;
}
#endif /* RIOT_VERSION */
#define SIN6(A) ((struct sockaddr_in6 *)(A))
+23
View File
@@ -45,6 +45,29 @@
#include "utlist.h"
#include "resource.h"
ssize_t
coap_network_send(coap_socket_t *sock,
const coap_session_t *session,
const uint8_t *data,
size_t datalen) {
ssize_t bytes_written = 0;
if (!coap_debug_send_packet()) {
bytes_written = (ssize_t)datalen;
} else if (sock->flags & COAP_SOCKET_CONNECTED) {
bytes_written = send(sock->fd, data, datalen, 0);
} else {
bytes_written = sendto(sock->fd, data, datalen, 0,
&session->remote_addr.addr.sa,
session->remote_addr.size);
}
if (bytes_written < 0)
coap_log(LOG_CRIT, "coap_network_send: %s\n", coap_socket_strerror());
return bytes_written;
}
ssize_t
coap_network_read(coap_socket_t *sock, struct coap_packet_t *packet) {
size_t len;