libcoap  4.2.1
coap_io.h File Reference
#include <sys/types.h>
#include "address.h"
+ Include dependency graph for coap_io.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  coap_addr_tuple_t
 
struct  coap_socket_t
 
struct  coap_packet_t
 

Macros

#define COAP_RXBUFFER_SIZE   1472
 
#define COAP_MAX_EPOLL_EVENTS   10
 
#define coap_closesocket   close
 
#define COAP_SOCKET_ERROR   (-1)
 
#define COAP_INVALID_SOCKET   (-1)
 
#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...
 
#define coap_mcast_interface(Local)   0
 

Typedefs

typedef int coap_fd_t
 
typedef uint16_t coap_socket_flags_t
 
typedef struct coap_addr_tuple_t coap_addr_tuple_t
 
typedef struct coap_socket_t coap_socket_t
 
typedef struct coap_packet_t coap_packet_t
 

Enumerations

enum  coap_nack_reason_t {
  COAP_NACK_TOO_MANY_RETRIES, COAP_NACK_NOT_DELIVERABLE, COAP_NACK_RST, COAP_NACK_TLS_FAILED,
  COAP_NACK_ICMP_ISSUE
}
 

Functions

struct coap_endpoint_tcoap_malloc_endpoint (void)
 
void coap_mfree_endpoint (struct coap_endpoint_t *ep)
 
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)
 
int coap_socket_connect_tcp1 (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_connect_tcp2 (coap_socket_t *sock, coap_address_t *local_addr, coap_address_t *remote_addr)
 
int coap_socket_bind_tcp (coap_socket_t *sock, const coap_address_t *listen_addr, coap_address_t *bound_addr)
 
int coap_socket_accept_tcp (coap_socket_t *server, coap_socket_t *new_client, coap_address_t *local_addr, coap_address_t *remote_addr)
 
void coap_socket_close (coap_socket_t *sock)
 
ssize_t coap_socket_send (coap_socket_t *sock, struct coap_session_t *session, const uint8_t *data, size_t data_len)
 
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)
 
void coap_epoll_ctl_mod (coap_socket_t *sock, uint32_t events, const char *func)
 
const char * coap_socket_strerror (void)
 
ssize_t coap_network_send (coap_socket_t *sock, const struct coap_session_t *session, const uint8_t *data, size_t datalen)
 Function interface for data transmission. More...
 
ssize_t coap_network_read (coap_socket_t *sock, struct coap_packet_t *packet)
 Function interface for reading data. More...
 
void coap_packet_get_memmapped (struct 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...
 

Macro Definition Documentation

◆ coap_closesocket

#define coap_closesocket   close

Definition at line 37 of file coap_io.h.

◆ COAP_INVALID_SOCKET

#define COAP_INVALID_SOCKET   (-1)

Definition at line 39 of file coap_io.h.

◆ COAP_MAX_EPOLL_EVENTS

#define COAP_MAX_EPOLL_EVENTS   10

Definition at line 27 of file coap_io.h.

◆ coap_mcast_interface

#define coap_mcast_interface (   Local)    0

Definition at line 181 of file coap_io.h.

◆ COAP_RXBUFFER_SIZE

#define COAP_RXBUFFER_SIZE   1472

Definition at line 18 of file coap_io.h.

◆ COAP_SOCKET_BOUND

#define COAP_SOCKET_BOUND   0x0002

the socket is bound

Definition at line 78 of file coap_io.h.

◆ COAP_SOCKET_CAN_ACCEPT

#define COAP_SOCKET_CAN_ACCEPT   0x0400

non blocking server socket can now accept without blocking

Definition at line 86 of file coap_io.h.

◆ COAP_SOCKET_CAN_CONNECT

#define COAP_SOCKET_CAN_CONNECT   0x0800

non blocking client socket can now connect without blocking

Definition at line 87 of file coap_io.h.

◆ COAP_SOCKET_CAN_READ

#define COAP_SOCKET_CAN_READ   0x0100

non blocking socket can now read without blocking

Definition at line 84 of file coap_io.h.

◆ COAP_SOCKET_CAN_WRITE

#define COAP_SOCKET_CAN_WRITE   0x0200

non blocking socket can now write without blocking

Definition at line 85 of file coap_io.h.

◆ COAP_SOCKET_CONNECTED

#define COAP_SOCKET_CONNECTED   0x0004

the socket is connected

Definition at line 79 of file coap_io.h.

◆ COAP_SOCKET_EMPTY

#define COAP_SOCKET_EMPTY   0x0000

coap_socket_flags_t values

the socket is not used

Definition at line 76 of file coap_io.h.

◆ COAP_SOCKET_ERROR

#define COAP_SOCKET_ERROR   (-1)

Definition at line 38 of file coap_io.h.

◆ COAP_SOCKET_MULTICAST

#define COAP_SOCKET_MULTICAST   0x1000

socket is used for multicast communication

Definition at line 88 of file coap_io.h.

◆ COAP_SOCKET_NOT_EMPTY

#define COAP_SOCKET_NOT_EMPTY   0x0001

the socket is not empty

Definition at line 77 of file coap_io.h.

◆ COAP_SOCKET_WANT_ACCEPT

#define COAP_SOCKET_WANT_ACCEPT   0x0040

non blocking server socket is waiting for accept

Definition at line 82 of file coap_io.h.

◆ COAP_SOCKET_WANT_CONNECT

#define COAP_SOCKET_WANT_CONNECT   0x0080

non blocking client socket is waiting for connect

Definition at line 83 of file coap_io.h.

◆ COAP_SOCKET_WANT_READ

#define COAP_SOCKET_WANT_READ   0x0010

non blocking socket is waiting for reading

Definition at line 80 of file coap_io.h.

◆ COAP_SOCKET_WANT_WRITE

#define COAP_SOCKET_WANT_WRITE   0x0020

non blocking socket is waiting for writing

Definition at line 81 of file coap_io.h.

Typedef Documentation

◆ coap_addr_tuple_t

◆ coap_fd_t

typedef int coap_fd_t

Definition at line 36 of file coap_io.h.

◆ coap_packet_t

typedef struct coap_packet_t coap_packet_t

Definition at line 224 of file coap_io.h.

◆ coap_socket_flags_t

typedef uint16_t coap_socket_flags_t

Definition at line 45 of file coap_io.h.

◆ coap_socket_t

typedef struct coap_socket_t coap_socket_t

Enumeration Type Documentation

◆ coap_nack_reason_t

Enumerator
COAP_NACK_TOO_MANY_RETRIES 
COAP_NACK_NOT_DELIVERABLE 
COAP_NACK_RST 
COAP_NACK_TLS_FAILED 
COAP_NACK_ICMP_ISSUE 

Definition at line 226 of file coap_io.h.

Function Documentation

◆ coap_epoll_ctl_mod()

void coap_epoll_ctl_mod ( coap_socket_t sock,
uint32_t  events,
const char *  func 
)
+ Here is the caller graph for this function:

◆ coap_malloc_endpoint()

struct coap_endpoint_t* coap_malloc_endpoint ( void  )

Definition at line 175 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 ( struct coap_endpoint_t ep)

Definition at line 180 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 1008 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 struct 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 with
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.

◆ coap_packet_get_memmapped()

void coap_packet_get_memmapped ( struct 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 1002 of file coap_io.c.

+ Here is the caller graph for this function:

◆ coap_socket_accept_tcp()

int coap_socket_accept_tcp ( coap_socket_t server,
coap_socket_t new_client,
coap_address_t local_addr,
coap_address_t remote_addr 
)

Definition at line 492 of file coap_io.c.

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

◆ coap_socket_bind_tcp()

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

Definition at line 412 of file coap_io.c.

+ Here is the call graph for this function:
+ 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 185 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 631 of file coap_io.c.

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

◆ coap_socket_connect_tcp1()

int coap_socket_connect_tcp1 ( 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 264 of file coap_io.c.

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

◆ coap_socket_connect_tcp2()

int coap_socket_connect_tcp2 ( coap_socket_t sock,
coap_address_t local_addr,
coap_address_t remote_addr 
)

Definition at line 372 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 529 of file coap_io.c.

+ Here is the call graph for this function:
+ 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 735 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,
struct coap_session_t session,
const uint8_t data,
size_t  data_len 
)

Definition at line 1657 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 1651 of file coap_io.c.

+ 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 690 of file coap_io.c.

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