libcoap 4.3.4-develop-9f1418e
coap_address.c File Reference

Handling of network addresses. More...

+ Include dependency graph for coap_address.c:

Go to the source code of this file.

Macros

#define COAP_BCST_CNT   15
 
#define COAP_BCST_REFRESH_SECS   30
 

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_is_af_unix (const coap_address_t *a)
 Checks if given address a denotes a AF_UNIX 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...
 
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...
 
static void update_port (coap_address_t *addr, uint16_t port, uint16_t default_port, int update_port0)
 
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...
 
static coap_addr_info_tget_coap_addr_info (coap_uri_scheme_t scheme)
 
static void update_coap_addr_port (coap_uri_scheme_t scheme, coap_addr_info_t *info, uint16_t port, uint16_t secure_port, uint16_t ws_port, uint16_t ws_secure_port, coap_resolve_type_t type)
 
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)
 Free off the one or more linked sets of coap_addr_info_t returned from coap_resolve_address_info(). More...
 
void coap_address_copy (coap_address_t *dst, const coap_address_t *src)
 
int _coap_address_isany_impl (const coap_address_t *a)
 

Detailed Description

Handling of network addresses.

Definition in file coap_address.c.

Macro Definition Documentation

◆ COAP_BCST_CNT

#define COAP_BCST_CNT   15

Definition at line 149 of file coap_address.c.

◆ COAP_BCST_REFRESH_SECS

#define COAP_BCST_REFRESH_SECS   30

Definition at line 154 of file coap_address.c.

Function Documentation

◆ _coap_address_isany_impl()

int _coap_address_isany_impl ( const coap_address_t a)

Definition at line 772 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 743 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 81 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 44 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 253 of file coap_address.c.

+ 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 62 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 263 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 732 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 312 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 109 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 164 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 119 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 487 of file coap_address.c.

+ Here is the call graph for this function:

◆ get_coap_addr_info()

static coap_addr_info_t * get_coap_addr_info ( coap_uri_scheme_t  scheme)
static

Definition at line 384 of file coap_address.c.

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

◆ update_coap_addr_port()

static void update_coap_addr_port ( coap_uri_scheme_t  scheme,
coap_addr_info_t info,
uint16_t  port,
uint16_t  secure_port,
uint16_t  ws_port,
uint16_t  ws_secure_port,
coap_resolve_type_t  type 
)
static

Definition at line 443 of file coap_address.c.

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

◆ update_port()

static void update_port ( coap_address_t addr,
uint16_t  port,
uint16_t  default_port,
int  update_port0 
)
static

Definition at line 297 of file coap_address.c.

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