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"
Go to the source code of this file.
|
uint16_t | coap_address_get_port (const coap_address_t *addr) |
| Returns the port from addr in host byte order.
|
|
void | coap_address_set_port (coap_address_t *addr, uint16_t port) |
| Set the port field of addr to port (in host byte order).
|
|
int | coap_address_equals (const coap_address_t *a, const coap_address_t *b) |
| Compares given address objects a and b .
|
|
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().
|
|
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.
|
|
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().
|
|
void | coap_address_init (coap_address_t *addr) |
| Resets the given coap_address_t object addr to its default values.
|
|
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.
|
|
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.
|
|
int | coap_is_mcast (const coap_address_t *a) |
| Checks if given address a denotes a multicast address.
|
|
int | coap_is_bcast (const coap_address_t *a) |
| Checks if given address a denotes a broadcast address.
|
|
int | coap_is_af_unix (const coap_address_t *a) |
| Checks if given address a denotes a AF_UNIX address.
|
|
Representation of network addresses.
Definition in file coap_address.h.
◆ COAP_UNIX_PATH_MAX
#define COAP_UNIX_PATH_MAX (sizeof(struct sockaddr_in6) - sizeof(sa_family_t)) |
◆ coap_addr_info_t
Resolved addresses information.
◆ coap_resolve_type_t
coap_resolve_type_t values
◆ 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 203 of file coap_address.h.
◆ _coap_address_isany_impl()
◆ coap_address_copy()
◆ coap_address_equals()
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.
◆ coap_address_get_port()
Returns the port from addr
in host byte order.
Definition at line 44 of file coap_address.c.
◆ coap_address_init()
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
-
Definition at line 258 of file coap_address.c.
◆ coap_address_isany()
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 294 of file coap_address.h.
◆ coap_address_set_port()
Set the port field of addr
to port
(in host byte order).
Definition at line 62 of file coap_address.c.
◆ 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
-
addr | coap_address_t to update. |
host | The parsed host from the CoAP URI with potential %2F encoding. |
host_len | The length of the parsed host from the CoAP URI with potential %2F encoding. |
- Returns
1
success, 0
failure.
Definition at line 268 of file coap_address.c.
◆ coap_free_address_info()
◆ 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_psk | Set to 1 if PSK/PKI information is known else 0 . |
ws_check | Set to 1 is WebSockets is to be included in the list else 0 . |
use_unix_proto | Set 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 316 of file coap_address.c.
◆ coap_is_af_unix()
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 114 of file coap_address.c.
◆ coap_is_bcast()
Checks if given address a
denotes a broadcast address.
This function returns 1
if a
is broadcast, 0
otherwise.
Definition at line 169 of file coap_address.c.
◆ coap_is_mcast()
Checks if given address a
denotes a multicast address.
This function returns 1
if a
is multicast, 0
otherwise.
Definition at line 124 of file coap_address.c.
◆ coap_resolve_address_info()
Resolve the specified address
into a set of coap_address_t that can be used to bind() (local) or connect() (remote) to.
- Parameters
-
address | The Address to resolve. |
port | The unsecured protocol port to use. |
secure_port | The secured protocol port to use. |
ws_port | The unsecured WebSockets port to use. |
ws_secure_port | The secured WebSockets port to use. |
ai_hints_flags | AI_* Hint flags to use for internal getaddrinfo(). |
scheme_hint_bits | Which schemes to return information for. One or more of COAP_URI_SCHEME_*_BIT or'd together. |
type | COAP_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 491 of file coap_address.c.