A DNS over CoAP client prototype based on gCoAP.  
More...
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. 
 | 
| file   | dns.h | 
|   | gcoap_dns definitions 
  | 
|   | 
◆ gcoap_dns_cred_add()
Adds a credential for the use with the configured DoC server. 
- Precondition
 - creds != NULL.
 
- Parameters
 - 
  
    | [in] | creds | A 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()
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] | tag | The tag of the credential.  | 
    | [in] | type | The type of the credential.  | 
  
   
 
 
◆ gcoap_dns_cred_reset()
      
        
          | void gcoap_dns_cred_reset  | 
          ( | 
          void  | 
           | ) | 
           | 
        
      
 
 
◆ 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_name | A '\0'-terminated domain name. Must not be NULL.  | 
    | [out] | addr_out | The resolved address. Must not be NULL.  | 
    | [in] | family | The 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] | proxy | The current proxy URI  | 
    | [in] | proxy_len | Maximum 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
 - 
  
    | true | A proxy URI is set.  | 
    | false | There 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] | proxy | A 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] | uri | The current URI for the DoC server  | 
    | [in] | uri_len | Maximum 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
 - 
  
    | true | A URI for the DoC server is set.  | 
    | false | There 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] | uri | A 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.