libcoap  4.1.2
Data Structures | Macros | Functions
coap_io.c File Reference
#include "coap_config.h"
#include <errno.h>
#include "debug.h"
#include "mem.h"
#include "coap_io.h"
Include dependency graph for coap_io.c:

Go to the source code of this file.

Data Structures

struct  coap_packet_t
 
struct  in6_pktinfo
 
struct  in_pktinfo
 

Macros

#define INET6_ADDRSTRLEN   40
 
#define SOL_IP   IPPROTO_IP
 
#define UNUSED_PARAM
 
#define SIN6(A)   ((struct sockaddr_in6 *)(A))
 

Functions

static struct coap_endpoint_tcoap_malloc_posix_endpoint (void)
 
static void coap_free_posix_endpoint (struct coap_endpoint_t *ep)
 
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 UNUSED_PARAM, const coap_endpoint_t *local_interface, const coap_address_t *dst, unsigned char *data, size_t datalen)
 
static coap_packet_tcoap_malloc_packet (void)
 
void coap_free_packet (coap_packet_t *packet)
 Releases the storage allocated for packet. More...
 
static size_t coap_get_max_packetlength (const coap_packet_t *packet UNUSED_PARAM)
 
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...
 
static int is_local_if (const coap_address_t *local, const coap_address_t *dst)
 Checks if a message with destination address dst matches the local interface with address local. More...
 
ssize_t coap_network_read (coap_endpoint_t *ep, coap_packet_t **packet)
 Function interface for reading data. More...
 

Macro Definition Documentation

§ INET6_ADDRSTRLEN

#define INET6_ADDRSTRLEN   40

§ SIN6

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

Definition at line 356 of file coap_io.c.

§ SOL_IP

#define SOL_IP   IPPROTO_IP

Definition at line 239 of file coap_io.c.

§ UNUSED_PARAM

#define UNUSED_PARAM

Definition at line 245 of file coap_io.c.

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

static void coap_free_posix_endpoint ( struct coap_endpoint_t ep)
inlinestatic

Definition at line 133 of file coap_io.c.

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

§ coap_get_max_packetlength()

static size_t coap_get_max_packetlength ( const coap_packet_t *packet  UNUSED_PARAM)
inlinestatic

Definition at line 389 of file coap_io.c.

Here is the caller graph for this function:

§ coap_malloc_packet()

static coap_packet_t* coap_malloc_packet ( void  )
static

Definition at line 360 of file coap_io.c.

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

§ coap_malloc_posix_endpoint()

static struct coap_endpoint_t* coap_malloc_posix_endpoint ( void  )
static

Definition at line 128 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  UNUSED_PARAM,
const coap_endpoint_t local_interface,
const coap_address_t dst,
unsigned char *  data,
size_t  datalen 
)

Definition at line 249 of file coap_io.c.

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

§ 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:

§ is_local_if()

static int is_local_if ( const coap_address_t local,
const coap_address_t dst 
)
inlinestatic

Checks if a message with destination address dst matches the local interface with address local.

This function returns 1 if dst is a valid match, and 0 otherwise.

Definition at line 419 of file coap_io.c.

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