Loading...
Searching...
No Matches
DNS over CoAP client implementation

A DNS over CoAP client prototype based on gCoAP. More...

Detailed Description

A DNS over CoAP client prototype based on gCoAP.

Enable DNS over CoAP client implementation.

DNS over CoAP allows a node to use a CoAP server to resolve DNS request, following draft-ietf-core-dns-over-coap.

The gcoap_dns module does not replace the sock_dns_query function when built, and is not used as a back-end to netutils_get_ipv6 automatically. It does, however, provide a drop-in replacement for sock_dns_query in its gcoap_dns_query function.

Modules

 GCoAP DNS over CoAP client configuration
 

Files

file  dns.h
 gcoap_dns definitions
 

Functions

int gcoap_dns_query (const char *domain_name, void *addr_out, int family)
 Query a domain name via CoAP synchronously.
 
int gcoap_dns_server_uri_set (const char *uri)
 Sets and checks a URI for a DoC server.
 
bool gcoap_dns_server_uri_is_set (void)
 Checks if the URI for the DoC server is set.
 
ssize_t gcoap_dns_server_uri_get (char *uri, size_t uri_len)
 Gets the URI for the DoC server.
 
void gcoap_dns_cred_reset (void)
 Deletes all added credentials.
 
int gcoap_dns_cred_add (credman_credential_t *creds)
 Adds a credential for the use with the configured DoC server.
 
void gcoap_dns_cred_remove (credman_tag_t tag, credman_type_t type)
 Remove a credential for the use with the configured DoC server.
 
void gcoap_dns_server_proxy_reset (void)
 Deletes the proxy URI.
 
int gcoap_dns_server_proxy_set (const char *proxy)
 Sets and checks a proxy URI.
 
bool gcoap_dns_server_proxy_is_set (void)
 Checks if a proxy URI is set.
 
ssize_t gcoap_dns_server_proxy_get (char *proxy, size_t proxy_len)
 Gets the proxy URI.
 

Function Documentation

◆ gcoap_dns_cred_add()

int gcoap_dns_cred_add ( credman_credential_t creds)

Adds a credential for the use with the configured DoC server.

Precondition
creds != NULL.
Parameters
[in]credsA crential. May not be NULL.
Returns
0 on success
-ENOTSUP if DTLS is not supported (because gcoap_dtls is not compiled in)
-ENOMEM if CONFIG_GCOAP_DNS_CREDS_MAX is exceeded (duplicates may be added).
-EBADF if the credential can not be added to (D)TLS Credential Manager or the GCoAP DTLS sock.

◆ gcoap_dns_cred_remove()

void gcoap_dns_cred_remove ( credman_tag_t  tag,
credman_type_t  type 
)

Remove a credential for the use with the configured DoC server.

This also removes the credentials from the (D)TLS Credential Manager and the GCoAP DTLS sock.

Parameters
[in]tagThe tag of the credential.
[in]typeThe type of the credential.

◆ gcoap_dns_cred_reset()

void gcoap_dns_cred_reset ( void  )

Deletes all added credentials.

This also removes the credentials from the (D)TLS Credential Manager and the GCoAP DTLS sock.

◆ gcoap_dns_query()

int gcoap_dns_query ( const char *  domain_name,
void *  addr_out,
int  family 
)

Query a domain name via CoAP synchronously.

Parameters
[in]domain_nameA '\0'-terminated domain name. Must not be NULL.
[out]addr_outThe resolved address. Must not be NULL.
[in]familyThe desired address family for addr_out. AF_UNSPEC for any address family (an IPv6 address will take preference over an IPv4 address).
Returns
length of addr_out in bytes on success
-EAFNOSUPPORT, if the hostname of the URI resolves to an unknown address family.
-EBADMSG, when receiving erroneous response or response containing an error code.
-ECONNABORTED, if CoAP request cannot be sent.
-ECONNREFUSED, if no URI is set for the client (see gcoap_dns_server_uri_set()).
-EDESTADDRREQ, if CoAP response was received from an unexpected remote.
-EHOSTUNREACH, if the hostname of the URI can not be resolved
-ENOBUFS, if there was not enough buffer space for the request.
-ENOBUFS, if length of received CoAP body is greater than CONFIG_DNS_MSG_LEN.
-ENOENT, if Zone-ID of the URI can not be found locally.
-ENOMSG, if CoAP response did not contain a DNS response.
-ENOTRECOVERABLE, on gCoAP-internal error.
-ENOTSUP, if credential can not be added for to client.
-ETIMEDOUT, if CoAP request timed out.

◆ gcoap_dns_server_proxy_get()

ssize_t gcoap_dns_server_proxy_get ( char *  proxy,
size_t  proxy_len 
)

Gets the proxy URI.

Parameters
[out]proxyThe current proxy URI
[in]proxy_lenMaximum length for proxy
Returns
Length of the proxy on return. 0, if no URI is set.
-ENOBUFS, if the configured URI is longer than proxy_len.

◆ gcoap_dns_server_proxy_is_set()

bool gcoap_dns_server_proxy_is_set ( void  )

Checks if a proxy URI is set.

Return values
trueA proxy URI is set.
falseThere is no URI set for the DoC server.

◆ gcoap_dns_server_proxy_set()

int gcoap_dns_server_proxy_set ( const char *  proxy)

Sets and checks a proxy URI.

Parameters
[in]proxyA proxy URI. Must contain a dns query variable.
Returns
length of proxy on success.
-ENOBUFS, if the client implementation has not enough buffer space to process the proxy URI.
-ENOSUP, if module gcoap_dns_proxied is not compiled in.

◆ gcoap_dns_server_uri_get()

ssize_t gcoap_dns_server_uri_get ( char *  uri,
size_t  uri_len 
)

Gets the URI for the DoC server.

Parameters
[out]uriThe current URI for the DoC server
[in]uri_lenMaximum length for uri
Returns
Length of the uri on return. 0, if no URI is set.
-ENOBUFS, if the configured URI is longer than uri_len.

◆ gcoap_dns_server_uri_is_set()

bool gcoap_dns_server_uri_is_set ( void  )

Checks if the URI for the DoC server is set.

Return values
trueA URI for the DoC server is set.
falseThere is no URI set for the DoC server.

◆ gcoap_dns_server_uri_set()

int gcoap_dns_server_uri_set ( const char *  uri)

Sets and checks a URI for a DoC server.

Parameters
[in]uriA URI. May be NULL to remove the URI. Unless the DNS sock API module is also used, the host component of the URI needs to be an IP literal.
Returns
length of uri on success (0 when URI is removed).
-EINVAL, if uri is not a valid URI for DNS over CoAP.
-ENOBUFS, if the client implementation has not enough buffer space to process the URI.