libcoap  4.1.2
Data Structures | Macros | Typedefs | Functions
coap_io.h File Reference
#include <assert.h>
#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_endpoint_t
 Abstraction of virtual endpoint that can be attached to coap_context_t. More...
 

Macros

#define COAP_IF_INVALID   -1
 Invalid interface handle. More...
 
#define COAP_ENDPOINT_NOSEC   0x00
 
#define COAP_ENDPOINT_DTLS   0x01
 
#define coap_mcast_interface(Local)   0
 

Typedefs

typedef int coap_if_handle_t
 Abstract handle that is used to identify a local network interface. More...
 
typedef struct coap_packet_t coap_packet_t
 
typedef struct coap_endpoint_t coap_endpoint_t
 Abstraction of virtual endpoint that can be attached to coap_context_t. More...
 

Functions

coap_endpoint_tcoap_new_endpoint (const coap_address_t *addr, int flags)
 
void coap_free_endpoint (coap_endpoint_t *ep)
 
ssize_t coap_network_send (struct coap_context_t *context, const coap_endpoint_t *local_interface, const coap_address_t *dst, unsigned char *data, size_t datalen)
 Function interface for data transmission. More...
 
ssize_t coap_network_read (coap_endpoint_t *ep, coap_packet_t **packet)
 Function interface for reading data. More...
 
void coap_free_packet (coap_packet_t *packet)
 Releases the storage allocated for packet. More...
 
void coap_packet_populate_endpoint (coap_packet_t *packet, coap_endpoint_t *target)
 Populate the coap_endpoint_t *target from the incoming packet's destination data. More...
 
void coap_packet_copy_source (coap_packet_t *packet, coap_address_t *target)
 Given an incoming packet, copy its source address into an address struct. 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...
 

Macro Definition Documentation

§ COAP_ENDPOINT_DTLS

#define COAP_ENDPOINT_DTLS   0x01

Definition at line 56 of file coap_io.h.

§ COAP_ENDPOINT_NOSEC

#define COAP_ENDPOINT_NOSEC   0x00

Definition at line 55 of file coap_io.h.

§ COAP_IF_INVALID

#define COAP_IF_INVALID   -1

Invalid interface handle.

Definition at line 24 of file coap_io.h.

§ coap_mcast_interface

#define coap_mcast_interface (   Local)    0

Definition at line 96 of file coap_io.h.

Typedef Documentation

§ coap_endpoint_t

Abstraction of virtual endpoint that can be attached to coap_context_t.

The tuple (handle, addr) must uniquely identify this endpoint.

§ coap_if_handle_t

typedef int coap_if_handle_t

Abstract handle that is used to identify a local network interface.

Definition at line 21 of file coap_io.h.

§ coap_packet_t

typedef struct coap_packet_t coap_packet_t

Definition at line 27 of file coap_io.h.

Function Documentation

§ coap_free_endpoint()

void coap_free_endpoint ( coap_endpoint_t ep)

Definition at line 208 of file coap_io.c.

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

§ coap_free_packet()

void coap_free_packet ( coap_packet_t packet)

Releases the storage allocated for packet.

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_network_read()

ssize_t coap_network_read ( coap_endpoint_t ep,
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
epThe endpoint that is used for reading data from the network.
packetA result parameter where a pointer to the received packet structure is stored. The caller must call coap_free_packet to release the storage used by this packet.
Returns
The number of bytes received on success, or a value less than zero on error.

Definition at line 425 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 ( struct coap_context_t context,
const coap_endpoint_t local_interface,
const coap_address_t dst,
unsigned char *  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
contextThe calling CoAP context.
local_interfaceThe local interface to send the data.
dstThe address of the receiver.
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_new_endpoint()

coap_endpoint_t* coap_new_endpoint ( const coap_address_t addr,
int  flags 
)

Definition at line 138 of file coap_io.c.

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

§ coap_packet_copy_source()

void coap_packet_copy_source ( coap_packet_t packet,
coap_address_t target 
)

Given an incoming packet, copy its source address into an address struct.

Definition at line 402 of file coap_io.c.

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

Here is the caller graph for this function:

§ coap_packet_populate_endpoint()

void coap_packet_populate_endpoint ( coap_packet_t packet,
coap_endpoint_t target 
)

Populate the coap_endpoint_t *target from the incoming packet's destination data.

This is usually used to copy a packet's data into a node's local_if member.

Definition at line 394 of file coap_io.c.

Here is the caller graph for this function: