libcoap  4.3.0beta
coap_io.c File Reference
#include "coap_internal.h"
#include <errno.h>
+ Include dependency graph for coap_io.c:

Go to the source code of this file.

Data Structures

struct  in6_pktinfo
 
struct  in_pktinfo
 

Macros

#define SOL_IP   IPPROTO_IP
 
#define UNUSED_PARAM
 
#define iov_len_t   size_t
 
#define SIN6(A)   ((struct sockaddr_in6 *)(A))
 

Functions

coap_endpoint_tcoap_malloc_endpoint (void)
 
void coap_mfree_endpoint (coap_endpoint_t *ep)
 
int coap_socket_bind_udp (coap_socket_t *sock, const coap_address_t *listen_addr, coap_address_t *bound_addr)
 
int coap_socket_connect_udp (coap_socket_t *sock, const coap_address_t *local_if, const coap_address_t *server, int default_port, coap_address_t *local_addr, coap_address_t *remote_addr)
 
void coap_socket_close (coap_socket_t *sock)
 
ssize_t coap_socket_write (coap_socket_t *sock, const uint8_t *data, size_t data_len)
 
ssize_t coap_socket_read (coap_socket_t *sock, uint8_t *data, size_t data_len)
 
ssize_t coap_network_send (coap_socket_t *sock, const coap_session_t *session, const uint8_t *data, size_t datalen)
 
void coap_packet_get_memmapped (coap_packet_t *packet, unsigned char **address, size_t *length)
 Given a packet, set msg and msg_len to an address and length of the packet's data in memory. More...
 
ssize_t coap_network_read (coap_socket_t *sock, coap_packet_t *packet)
 Function interface for reading data. More...
 
unsigned int coap_io_prepare_epoll (coap_context_t *ctx, coap_tick_t now)
 Any now timed out delayed packet is transmitted, along with any packets associated with requested observable response. More...
 
unsigned int coap_io_prepare_io (coap_context_t *ctx, coap_socket_t *sockets[], unsigned int max_sockets, unsigned int *num_sockets, coap_tick_t now)
 Iterates through all the coap_socket_t structures embedded in endpoints or sessions associated with the ctx to determine which are wanting any read, write, accept or connect I/O (COAP_SOCKET_WANT_xxx is set). More...
 
int coap_io_process (coap_context_t *ctx, uint32_t timeout_ms)
 The main I/O processing function. More...
 
int coap_io_process_with_fds (coap_context_t *ctx, uint32_t timeout_ms, int enfds, fd_set *ereadfds, fd_set *ewritefds, fd_set *eexceptfds)
 The main message processing loop with additional fds for internal select. More...
 
const char * coap_socket_format_errno (int error)
 
const char * coap_socket_strerror (void)
 
ssize_t coap_socket_send (coap_socket_t *sock, coap_session_t *session, const uint8_t *data, size_t data_len)
 

Macro Definition Documentation

◆ iov_len_t

#define iov_len_t   size_t

Definition at line 546 of file coap_io.c.

◆ SIN6

#define SIN6 (   A)    ((struct sockaddr_in6 *)(A))

Definition at line 726 of file coap_io.c.

◆ SOL_IP

#define SOL_IP   IPPROTO_IP

Definition at line 518 of file coap_io.c.

◆ UNUSED_PARAM

#define UNUSED_PARAM

Definition at line 524 of file coap_io.c.

Function Documentation

◆ coap_malloc_endpoint()

coap_endpoint_t* coap_malloc_endpoint ( void  )

Definition at line 142 of file coap_io.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_mfree_endpoint()

void coap_mfree_endpoint ( coap_endpoint_t ep)

Definition at line 147 of file coap_io.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_network_read()

ssize_t coap_network_read ( coap_socket_t sock,
struct coap_packet_t packet 
)

Function interface for reading data.

This function returns the number of bytes that have been read, or a value less than zero on error. In case of an error, *packet is set to NULL.

Parameters
sockSocket to read data from
packetReceived packet metadata and payload. src and dst should be preset.
Returns
The number of bytes received on success, or a value less than zero on error.

Definition at line 736 of file coap_io.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_network_send()

ssize_t coap_network_send ( coap_socket_t sock,
const coap_session_t session,
const uint8_t data,
size_t  datalen 
)

Definition at line 555 of file coap_io.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_packet_get_memmapped()

void coap_packet_get_memmapped ( coap_packet_t packet,
unsigned char **  address,
size_t *  length 
)

Given a packet, set msg and msg_len to an address and length of the packet's data in memory.

Definition at line 729 of file coap_io.c.

+ Here is the caller graph for this function:

◆ coap_socket_bind_udp()

int coap_socket_bind_udp ( coap_socket_t sock,
const coap_address_t listen_addr,
coap_address_t bound_addr 
)

Definition at line 152 of file coap_io.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_socket_close()

void coap_socket_close ( coap_socket_t sock)

Definition at line 347 of file coap_io.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_socket_connect_udp()

int coap_socket_connect_udp ( coap_socket_t sock,
const coap_address_t local_if,
const coap_address_t server,
int  default_port,
coap_address_t local_addr,
coap_address_t remote_addr 
)

Definition at line 236 of file coap_io.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_socket_format_errno()

static const char * coap_socket_format_errno ( int  error)

Definition at line 1456 of file coap_io.c.

+ Here is the caller graph for this function:

◆ coap_socket_read()

ssize_t coap_socket_read ( coap_socket_t sock,
uint8_t data,
size_t  data_len 
)

Definition at line 457 of file coap_io.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_socket_send()

ssize_t coap_socket_send ( coap_socket_t sock,
coap_session_t session,
const uint8_t data,
size_t  data_len 
)

Definition at line 1465 of file coap_io.c.

+ Here is the caller graph for this function:

◆ coap_socket_strerror()

const char* coap_socket_strerror ( void  )

Definition at line 1459 of file coap_io.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_socket_write()

ssize_t coap_socket_write ( coap_socket_t sock,
const uint8_t data,
size_t  data_len 
)

Definition at line 406 of file coap_io.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: