libcoap 4.3.2
|
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.
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_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. 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... | |
Representation of network addresses.
Definition in file coap_address.h.
#define COAP_UNIX_PATH_MAX (sizeof(struct sockaddr_in6) - sizeof(sa_family_t)) |
Definition at line 101 of file coap_address.h.
typedef struct coap_addr_info_t coap_addr_info_t |
Resolved addresses information.
typedef enum coap_resolve_type_t coap_resolve_type_t |
coap_resolve_type_t values
enum 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.
int _coap_address_isany_impl | ( | const coap_address_t * | a | ) |
void coap_address_copy | ( | coap_address_t * | dst, |
const coap_address_t * | src | ||
) |
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.
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.
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.
addr | The coap_address_t object to initialize. |
Definition at line 248 of file coap_address.c.
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.
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.
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.
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. |
1
success, 0
failure. Definition at line 258 of file coap_address.c.
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().
info_list | The set of coap_addr_info_t to free off. |
Definition at line 792 of file coap_address.c.
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().
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. |
0
if none) suitable for passing to coap_resolve_address_info(). Definition at line 307 of file coap_address.c.
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.
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.
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.
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.
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 |
NULL
if error. Definition at line 379 of file coap_address.c.