libcoap 4.3.2
coap_address.h File Reference

Representation of network addresses. More...

#include <assert.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
#include "libcoap.h"
#include "coap3/coap_pdu.h"
+ Include dependency graph for coap_address.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  coap_sockaddr_un
 
struct  coap_address_t
 Multi-purpose address abstraction. More...
 
struct  coap_addr_info_t
 Resolved addresses information. More...
 

Macros

#define COAP_UNIX_PATH_MAX   (sizeof(struct sockaddr_in6) - sizeof(sa_family_t))
 

Typedefs

typedef struct coap_addr_info_t coap_addr_info_t
 Resolved addresses information. More...
 
typedef enum coap_resolve_type_t coap_resolve_type_t
 coap_resolve_type_t values More...
 

Enumerations

enum  coap_resolve_type_t { COAP_RESOLVE_TYPE_LOCAL , COAP_RESOLVE_TYPE_REMOTE }
 coap_resolve_type_t values More...
 

Functions

uint16_t coap_address_get_port (const coap_address_t *addr)
 Returns the port from addr in host byte order. More...
 
void coap_address_set_port (coap_address_t *addr, uint16_t port)
 Set the port field of addr to port (in host byte order). More...
 
int coap_address_equals (const coap_address_t *a, const coap_address_t *b)
 Compares given address objects a and b. More...
 
int _coap_address_isany_impl (const coap_address_t *a)
 
uint32_t coap_get_available_scheme_hint_bits (int have_pki_psk, int ws_check, coap_proto_t use_unix_proto)
 Determine and set up scheme_hint_bits for a server that can be used in a call to coap_resolve_address_info(). More...
 
coap_addr_info_tcoap_resolve_address_info (const coap_str_const_t *address, uint16_t port, uint16_t secure_port, uint16_t ws_port, uint16_t ws_secure_port, int ai_hints_flags, int scheme_hint_bits, coap_resolve_type_t type)
 Resolve the specified address into a set of coap_address_t that can be used to bind() (local) or connect() (remote) to. More...
 
void coap_free_address_info (coap_addr_info_t *info_list)
 Free off the one or more linked sets of coap_addr_info_t returned from coap_resolve_address_info(). More...
 
void coap_address_init (coap_address_t *addr)
 Resets the given coap_address_t object addr to its default values. More...
 
int coap_address_set_unix_domain (coap_address_t *addr, const uint8_t *host, size_t host_len)
 Copy the parsed unix domain host into coap_address_t structure translating %2F into / on the way. More...
 
void coap_address_copy (coap_address_t *dst, const coap_address_t *src)
 
COAP_STATIC_INLINE int coap_address_isany (const coap_address_t *a)
 Checks if given address object a denotes the wildcard address. More...
 
int coap_is_mcast (const coap_address_t *a)
 Checks if given address a denotes a multicast address. More...
 
int coap_is_bcast (const coap_address_t *a)
 Checks if given address a denotes a broadcast address. More...
 
int coap_is_af_unix (const coap_address_t *a)
 Checks if given address a denotes a AF_UNIX address. More...
 

Detailed Description

Representation of network addresses.

Definition in file coap_address.h.

Macro Definition Documentation

◆ COAP_UNIX_PATH_MAX

#define COAP_UNIX_PATH_MAX   (sizeof(struct sockaddr_in6) - sizeof(sa_family_t))

Definition at line 101 of file coap_address.h.

Typedef Documentation

◆ coap_addr_info_t

Resolved addresses information.

◆ coap_resolve_type_t

coap_resolve_type_t values

Enumeration Type Documentation

◆ coap_resolve_type_t

coap_resolve_type_t values

Enumerator
COAP_RESOLVE_TYPE_LOCAL 

local side of session

COAP_RESOLVE_TYPE_REMOTE 

remote side of session

Definition at line 166 of file coap_address.h.

Function Documentation

◆ _coap_address_isany_impl()

int _coap_address_isany_impl ( const coap_address_t a)

Definition at line 832 of file coap_address.c.

+ Here is the caller graph for this function:

◆ coap_address_copy()

void coap_address_copy ( coap_address_t dst,
const coap_address_t src 
)

Definition at line 803 of file coap_address.c.

+ Here is the caller graph for this function:

◆ coap_address_equals()

int coap_address_equals ( const coap_address_t a,
const coap_address_t b 
)

Compares given address objects a and b.

This function returns 1 if addresses are equal, 0 otherwise. The parameters a and b must not be NULL;

Definition at line 75 of file coap_address.c.

+ Here is the caller graph for this function:

◆ coap_address_get_port()

uint16_t coap_address_get_port ( const coap_address_t addr)

Returns the port from addr in host byte order.

Definition at line 38 of file coap_address.c.

+ Here is the caller graph for this function:

◆ coap_address_init()

void coap_address_init ( coap_address_t addr)

Resets the given coap_address_t object addr to its default values.

In particular, the member size must be initialized to the available size for storing addresses.

Parameters
addrThe coap_address_t object to initialize.

Definition at line 248 of file coap_address.c.

+ Here is the caller graph for this function:

◆ coap_address_isany()

COAP_STATIC_INLINE int coap_address_isany ( const coap_address_t a)

Checks if given address object a denotes the wildcard address.

This function returns 1 if this is the case, 0 otherwise. The parameters a must not be NULL;

Definition at line 257 of file coap_address.h.

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

◆ coap_address_set_port()

void coap_address_set_port ( coap_address_t addr,
uint16_t  port 
)

Set the port field of addr to port (in host byte order).

Definition at line 56 of file coap_address.c.

+ Here is the caller graph for this function:

◆ coap_address_set_unix_domain()

int coap_address_set_unix_domain ( coap_address_t addr,
const uint8_t *  host,
size_t  host_len 
)

Copy the parsed unix domain host into coap_address_t structure translating %2F into / on the way.

All other fields set as appropriate.

Parameters
addrcoap_address_t to update.
hostThe parsed host from the CoAP URI with potential %2F encoding.
host_lenThe length of the parsed host from the CoAP URI with potential %2F encoding.
Returns
1 success, 0 failure.

Definition at line 258 of file coap_address.c.

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

◆ coap_free_address_info()

void coap_free_address_info ( coap_addr_info_t info_list)

Free off the one or more linked sets of coap_addr_info_t returned from coap_resolve_address_info().

Parameters
info_listThe set of coap_addr_info_t to free off.

Definition at line 792 of file coap_address.c.

+ Here is the call graph for this function:

◆ coap_get_available_scheme_hint_bits()

uint32_t coap_get_available_scheme_hint_bits ( int  have_pki_psk,
int  ws_check,
coap_proto_t  use_unix_proto 
)

Determine and set up scheme_hint_bits for a server that can be used in a call to coap_resolve_address_info().

Parameters
have_pki_pskSet to 1 if PSK/PKI information is known else 0.
ws_checkSet to 1 is WebSockets is to be included in the list else 0.
use_unix_protoSet to the appropriate protocol to use for Unix sockets, else set to COAP_PROTO_NONE for INET / INET6 sockets.
Returns
A bit mask of the available CoAP protocols (can be 0 if none) suitable for passing to coap_resolve_address_info().

Definition at line 307 of file coap_address.c.

+ Here is the call graph for this function:

◆ coap_is_af_unix()

int coap_is_af_unix ( const coap_address_t a)

Checks if given address a denotes a AF_UNIX address.

This function returns 1 if a is of type AF_UNIX, 0 otherwise.

Definition at line 103 of file coap_address.c.

◆ coap_is_bcast()

int coap_is_bcast ( const coap_address_t a)

Checks if given address a denotes a broadcast address.

This function returns 1 if a is broadcast, 0 otherwise.

Definition at line 165 of file coap_address.c.

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

◆ coap_is_mcast()

int coap_is_mcast ( const coap_address_t a)

Checks if given address a denotes a multicast address.

This function returns 1 if a is multicast, 0 otherwise.

Definition at line 113 of file coap_address.c.

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

◆ coap_resolve_address_info()

coap_addr_info_t * coap_resolve_address_info ( const coap_str_const_t address,
uint16_t  port,
uint16_t  secure_port,
uint16_t  ws_port,
uint16_t  ws_secure_port,
int  ai_hints_flags,
int  scheme_hint_bits,
coap_resolve_type_t  type 
)

Resolve the specified address into a set of coap_address_t that can be used to bind() (local) or connect() (remote) to.

Parameters
addressThe Address to resolve.
portThe unsecured protocol port to use.
secure_portThe secured protocol port to use.
ws_portThe unsecured WebSockets port to use.
ws_secure_portThe secured WebSockets port to use.
ai_hints_flagsAI_* Hint flags to use for internal getaddrinfo().
scheme_hint_bitsWhich schemes to return information for. One or more of COAP_URI_SCHEME_*_BIT or'd together.
typeCOAP_ADDRESS_TYPE_LOCAL or COAP_ADDRESS_TYPE_REMOTE
Returns
One or more linked sets of coap_addr_info_t or NULL if error.

Definition at line 379 of file coap_address.c.

+ Here is the call graph for this function: