129 #ifndef NET_NANOCOAP_SOCK_H
130 #define NET_NANOCOAP_SOCK_H
139 #if IS_USED(MODULE_NANOCOAP_DTLS)
152 #ifndef CONFIG_NANOCOAP_SOCK_DTLS_TAG
153 #define CONFIG_NANOCOAP_SOCK_DTLS_TAG (0xc0ab)
169 #if IS_USED(MODULE_NANOCOAP_DTLS) || defined(DOXYGEN)
231 #if IS_USED(MODULE_NANOCOAP_DTLS)
239 #if IS_USED(MODULE_NANOCOAP_DTLS) || DOXYGEN
274 #if IS_USED(MODULE_NANOCOAP_DTLS)
311 const void *request,
size_t len,
312 void *response,
size_t len_max);
330 const void *request,
size_t len,
331 void *response,
size_t len_max);
346 const void *request,
size_t len,
347 void *response,
size_t len_max);
363 const void *request,
size_t len,
364 void *response,
size_t len_max);
382 const void *request,
size_t len,
383 void *response,
size_t len_max);
398 const void *request,
size_t len,
399 void *response,
size_t len_max);
484 void *buf,
size_t len);
549 void *buf,
size_t len);
598 const void *data,
size_t len,
bool more,
(D)TLS credentials management module definitions
coap_blksize_t
Coap block-wise-transfer size SZX.
uint16_t credman_tag_t
Tag of the credential.
int(* coap_blockwise_cb_t)(void *arg, size_t offset, uint8_t *buf, size_t len, int more)
Coap blockwise request callback descriptor.
int(* coap_request_cb_t)(void *arg, coap_pkt_t *pkt)
Coap equest callback descriptor.
ssize_t nanocoap_sock_put_non(nanocoap_sock_t *sock, const char *path, const void *request, size_t len, void *response, size_t len_max)
Simple non-confirmable PUT.
ssize_t nanocoap_sock_delete(nanocoap_sock_t *sock, const char *path)
Simple synchronous CoAP (confirmable) DELETE.
ssize_t nanocoap_sock_put(nanocoap_sock_t *sock, const char *path, const void *request, size_t len, void *response, size_t len_max)
Simple synchronous CoAP (confirmable) PUT.
int nanocoap_sock_url_connect(const char *url, nanocoap_sock_t *sock)
Create a CoAP client socket by URL.
ssize_t nanocoap_sock_post_url(const char *url, const void *request, size_t len, void *response, size_t len_max)
Simple synchronous CoAP (confirmable) POST to URL.
ssize_t nanocoap_sock_delete_url(const char *url)
Simple synchronous CoAP (confirmable) DELETE for URL.
ssize_t nanocoap_request(coap_pkt_t *pkt, const sock_udp_ep_t *local, const sock_udp_ep_t *remote, size_t len)
Simple synchronous CoAP request.
ssize_t nanocoap_get(const sock_udp_ep_t *remote, const char *path, void *buf, size_t len)
Simple synchronous CoAP (confirmable) get.
ssize_t nanocoap_sock_request(nanocoap_sock_t *sock, coap_pkt_t *pkt, size_t len)
Simple synchronous CoAP request.
int nanocoap_sock_dtls_connect(nanocoap_sock_t *sock, sock_udp_ep_t *local, const sock_udp_ep_t *remote, credman_tag_t tag)
Create a DTLS secured CoAP client socket.
static uint16_t nanocoap_sock_next_msg_id(nanocoap_sock_t *sock)
Get next consecutive message ID for use when building a new CoAP request.
ssize_t nanocoap_sock_post(nanocoap_sock_t *sock, const char *path, const void *request, size_t len, void *response, size_t len_max)
Simple synchronous CoAP (confirmable) POST.
int nanocoap_server(sock_udp_ep_t *local, uint8_t *buf, size_t bufsize)
Start a nanocoap server instance.
int nanocoap_sock_block_request(coap_block_request_t *ctx, const void *data, size_t len, bool more, coap_request_cb_t cb, void *arg)
Do a block-wise request, send a single block.
ssize_t nanocoap_sock_post_non(nanocoap_sock_t *sock, const char *path, const void *request, size_t len, void *response, size_t len_max)
Simple non-confirmable POST.
ssize_t nanocoap_sock_request_cb(nanocoap_sock_t *sock, coap_pkt_t *pkt, coap_request_cb_t cb, void *arg)
Simple synchronous CoAP request with callback.
ssize_t nanocoap_sock_get(nanocoap_sock_t *sock, const char *path, void *buf, size_t len)
Simple synchronous CoAP (confirmable) GET.
ssize_t nanocoap_get_blockwise_url_to_buf(const char *url, coap_blksize_t blksize, void *buf, size_t len)
Performs a blockwise coap get request to the specified url, store the response in a buffer.
int nanocoap_get_blockwise_url(const char *url, coap_blksize_t blksize, coap_blockwise_cb_t callback, void *arg)
Performs a blockwise coap get request to the specified url.
ssize_t nanocoap_sock_put_url(const char *url, const void *request, size_t len, void *response, size_t len_max)
Simple synchronous CoAP (confirmable) PUT to URL.
static int nanocoap_sock_connect(nanocoap_sock_t *sock, const sock_udp_ep_t *local, const sock_udp_ep_t *remote)
Create a CoAP client socket.
static int nanocoap_block_request_connect_url(coap_block_request_t *ctx, nanocoap_sock_t *sock, const char *url, uint8_t method, coap_blksize_t blksize)
Initialize block request context by URL and connect a socket.
int nanocoap_sock_get_blockwise(nanocoap_sock_t *sock, const char *path, coap_blksize_t blksize, coap_blockwise_cb_t callback, void *arg)
Performs a blockwise coap get request on a socket.
nanocoap_socket_type_t
NanoCoAP socket types.
static void nanocoap_sock_close(nanocoap_sock_t *sock)
Close a CoAP client socket.
@ COAP_SOCKET_TYPE_UDP
transport is plain UDP
@ COAP_SOCKET_TYPE_DTLS
transport is DTLS
void sock_dtls_close(sock_dtls_t *sock)
Closes a DTLS sock.
void sock_dtls_session_destroy(sock_dtls_t *sock, sock_dtls_session_t *remote)
Destroys an existing DTLS session.
int sock_udp_create(sock_udp_t *sock, const sock_udp_ep_t *local, const sock_udp_ep_t *remote, uint16_t flags)
Creates a new UDP sock object.
void sock_udp_close(sock_udp_t *sock)
Closes a UDP sock object.
const char * sock_urlpath(const char *url)
Returns a pointer to the path component in url.
uint32_t random_uint32(void)
generates a random number on [0,0xffffffff]-interval
Common interface to the software PRNG.
Common IP-based transport layer end point.
Blockwise request helper struct.
uint8_t method
request method (GET, POST, PUT)
nanocoap_sock_t * sock
socket used for the request
uint32_t blknum
current block number
const char * path
path on the server
uint8_t blksize
CoAP blocksize exponent
CoAP PDU parsing context structure.
uint16_t msg_id
next CoAP message ID
sock_dtls_session_t dtls_session
Session object for the stored socket.
sock_dtls_t dtls
DTLS socket
nanocoap_socket_type_t type
Socket type (UDP, DTLS)
Information about remote client connected to the server.
Information about DTLS sock.
sock utility function definitions