libcoap 4.3.5-develop-19cef11
coap_io_internal.h File Reference

Internal network I/O functions. More...

#include "coap_internal.h"
#include "coap_layers_internal.h"
#include <sys/types.h>
#include "coap_address.h"
+ Include dependency graph for coap_io_internal.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  coap_socket_t
 
struct  coap_packet_t
 

Macros

#define COAP_SOCKET_EMPTY   0x0000
 coap_socket_flags_t values More...
 
#define COAP_SOCKET_NOT_EMPTY   0x0001
 the socket is not empty More...
 
#define COAP_SOCKET_BOUND   0x0002
 the socket is bound More...
 
#define COAP_SOCKET_CONNECTED   0x0004
 the socket is connected More...
 
#define COAP_SOCKET_WANT_READ   0x0010
 non blocking socket is waiting for reading More...
 
#define COAP_SOCKET_WANT_WRITE   0x0020
 non blocking socket is waiting for writing More...
 
#define COAP_SOCKET_WANT_ACCEPT   0x0040
 non blocking server socket is waiting for accept More...
 
#define COAP_SOCKET_WANT_CONNECT   0x0080
 non blocking client socket is waiting for connect More...
 
#define COAP_SOCKET_CAN_READ   0x0100
 non blocking socket can now read without blocking More...
 
#define COAP_SOCKET_CAN_WRITE   0x0200
 non blocking socket can now write without blocking More...
 
#define COAP_SOCKET_CAN_ACCEPT   0x0400
 non blocking server socket can now accept without blocking More...
 
#define COAP_SOCKET_CAN_CONNECT   0x0800
 non blocking client socket can now connect without blocking More...
 
#define COAP_SOCKET_MULTICAST   0x1000
 socket is used for multicast communication More...
 

Functions

coap_endpoint_tcoap_malloc_endpoint (void)
 
void coap_mfree_endpoint (coap_endpoint_t *ep)
 
const char * coap_socket_format_errno (int error)
 
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)
 
int coap_socket_bind_udp (coap_socket_t *sock, const coap_address_t *listen_addr, coap_address_t *bound_addr)
 
void coap_socket_close (coap_socket_t *sock)
 Function interface to close off a socket. More...
 
ssize_t coap_socket_write (coap_socket_t *sock, const uint8_t *data, size_t data_len)
 Function interface for data stream sending off a socket. More...
 
ssize_t coap_socket_read (coap_socket_t *sock, uint8_t *data, size_t data_len)
 Function interface for data stream receiving off a socket. More...
 
void coap_epoll_ctl_add (coap_socket_t *sock, uint32_t events, const char *func)
 Epoll specific function to add the state of events that epoll is to track for the appropriate file descriptor. More...
 
void coap_epoll_ctl_mod (coap_socket_t *sock, uint32_t events, const char *func)
 Epoll specific function to modify the state of events that epoll is tracking on the appropriate file descriptor. More...
 
void coap_update_io_timer (coap_context_t *context, coap_tick_t delay)
 Update when to continue with I/O processing, unless packets come in in the meantime. More...
 
ssize_t coap_socket_send (coap_socket_t *sock, coap_session_t *session, const uint8_t *data, size_t datalen)
 Function interface for data transmission. More...
 
ssize_t coap_socket_recv (coap_socket_t *sock, coap_packet_t *packet)
 Function interface for reading data. More...
 
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...
 

Detailed Description

Internal network I/O functions.

Definition in file coap_io_internal.h.

Macro Definition Documentation

◆ COAP_SOCKET_BOUND

#define COAP_SOCKET_BOUND   0x0002

the socket is bound

Definition at line 76 of file coap_io_internal.h.

◆ COAP_SOCKET_CAN_ACCEPT

#define COAP_SOCKET_CAN_ACCEPT   0x0400

non blocking server socket can now accept without blocking

Definition at line 84 of file coap_io_internal.h.

◆ COAP_SOCKET_CAN_CONNECT

#define COAP_SOCKET_CAN_CONNECT   0x0800

non blocking client socket can now connect without blocking

Definition at line 85 of file coap_io_internal.h.

◆ COAP_SOCKET_CAN_READ

#define COAP_SOCKET_CAN_READ   0x0100

non blocking socket can now read without blocking

Definition at line 82 of file coap_io_internal.h.

◆ COAP_SOCKET_CAN_WRITE

#define COAP_SOCKET_CAN_WRITE   0x0200

non blocking socket can now write without blocking

Definition at line 83 of file coap_io_internal.h.

◆ COAP_SOCKET_CONNECTED

#define COAP_SOCKET_CONNECTED   0x0004

the socket is connected

Definition at line 77 of file coap_io_internal.h.

◆ COAP_SOCKET_EMPTY

#define COAP_SOCKET_EMPTY   0x0000

coap_socket_flags_t values

the socket is not used

Definition at line 74 of file coap_io_internal.h.

◆ COAP_SOCKET_MULTICAST

#define COAP_SOCKET_MULTICAST   0x1000

socket is used for multicast communication

Definition at line 86 of file coap_io_internal.h.

◆ COAP_SOCKET_NOT_EMPTY

#define COAP_SOCKET_NOT_EMPTY   0x0001

the socket is not empty

Definition at line 75 of file coap_io_internal.h.

◆ COAP_SOCKET_WANT_ACCEPT

#define COAP_SOCKET_WANT_ACCEPT   0x0040

non blocking server socket is waiting for accept

Definition at line 80 of file coap_io_internal.h.

◆ COAP_SOCKET_WANT_CONNECT

#define COAP_SOCKET_WANT_CONNECT   0x0080

non blocking client socket is waiting for connect

Definition at line 81 of file coap_io_internal.h.

◆ COAP_SOCKET_WANT_READ

#define COAP_SOCKET_WANT_READ   0x0010

non blocking socket is waiting for reading

Definition at line 78 of file coap_io_internal.h.

◆ COAP_SOCKET_WANT_WRITE

#define COAP_SOCKET_WANT_WRITE   0x0020

non blocking socket is waiting for writing

Definition at line 79 of file coap_io_internal.h.

Function Documentation

◆ coap_epoll_ctl_add()

void coap_epoll_ctl_add ( coap_socket_t sock,
uint32_t  events,
const char *  func 
)

Epoll specific function to add the state of events that epoll is to track for the appropriate file descriptor.

Parameters
sockSocket information.
eventsThe Epoll events to update
funcFunction that this function was called from.

◆ coap_epoll_ctl_mod()

void coap_epoll_ctl_mod ( coap_socket_t sock,
uint32_t  events,
const char *  func 
)

Epoll specific function to modify the state of events that epoll is tracking on the appropriate file descriptor.

Parameters
sockSocket information.
eventsThe Epoll events to update
funcFunction that this function was called from.
+ Here is the caller graph for this function:

◆ coap_malloc_endpoint()

coap_endpoint_t * coap_malloc_endpoint ( void  )

◆ coap_mfree_endpoint()

void coap_mfree_endpoint ( coap_endpoint_t ep)

◆ 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 1008 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 
)

◆ coap_socket_close()

void coap_socket_close ( coap_socket_t sock)

Function interface to close off a socket.

Parameters
sockSocket to close.

Definition at line 375 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 
)

◆ coap_socket_format_errno()

const char * coap_socket_format_errno ( int  error)

Definition at line 1896 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 
)

Function interface for data stream receiving off a socket.

Parameters
sockSocket to receive data on.
dataThe data to receive.
data_lenThe maximum length of data.
Returns
>=0 Number of bytes read. -1 Error error in errno).

Definition at line 677 of file coap_io.c.

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

◆ coap_socket_recv()

ssize_t coap_socket_recv ( coap_socket_t sock,
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 1021 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  datalen 
)

Function interface for data transmission.

This function returns the number of bytes that have been transmitted, or a value less than zero on error.

Parameters
sockSocket to send data over.
sessionAddressing information for unconnected sockets, or NULL
dataThe data to send.
datalenThe actual length of data.
Returns
The number of bytes written on success, or a value less than zero on error.

Definition at line 824 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 
)

Function interface for data stream sending off a socket.

Parameters
sockSocket to send data over.
dataThe data to send.
data_lenThe length of data.
Returns
>=0 Number of bytes sent. -1 Error error in errno).

Definition at line 618 of file coap_io.c.

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

◆ coap_update_io_timer()

void coap_update_io_timer ( coap_context_t context,
coap_tick_t  delay 
)

Update when to continue with I/O processing, unless packets come in in the meantime.

Typically, this timeout triggers retransmissions.

Parameters
contextThe CoAP context.
delayThe time to delay before continuing with I/O processing.

Definition at line 504 of file coap_io.c.

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