Parsing and composition of DNS messages.  
More...
Parsing and composition of DNS messages. 
|  | 
| file | msg.h | 
|  | Definitions for parsing and composition of DNS messages. 
 | 
|  | 
|  | 
| size_t | dns_msg_compose_query (void *dns_buf, const char *domain_name, uint16_t id, int family) | 
|  | Composes a DNS query message. 
 | 
|  | 
| int | dns_msg_parse_reply (const uint8_t *buf, size_t len, int family, void *addr_out, uint32_t *ttl) | 
|  | Parses a DNS response message. 
 | 
|  | 
◆ dns_msg_compose_query()
      
        
          | size_t dns_msg_compose_query | ( | void * | dns_buf, | 
        
          |  |  | const char * | domain_name, | 
        
          |  |  | uint16_t | id, | 
        
          |  |  | int | family ) | 
      
 
Composes a DNS query message. 
The query will request an A or AAAA IN record for domain_name depending on family: 
- When familyisAF_INETorAF_UNSPECa query for an A record will be added
- When familyisAF_INET6orAF_UNSPECa query for an AAAA record will be added
- Parameters
- 
  
    | [out] | dns_buf | A buffer of length CONFIG_DNS_MSG_LEN |  | [in] | domain_name | The domain name to query. |  | [in] | id | The ID for the query. |  | [in] | family | Either AF_UNSPEC,AF_INET, orAF_INET6. Determines the address records fordomain_namequeried. |  
 
- Returns
- Size of the composed query in bytes. 
 
 
◆ dns_msg_parse_reply()
      
        
          | int dns_msg_parse_reply | ( | const uint8_t * | buf, | 
        
          |  |  | size_t | len, | 
        
          |  |  | int | family, | 
        
          |  |  | void * | addr_out, | 
        
          |  |  | uint32_t * | ttl ) | 
      
 
Parses a DNS response message. 
- Parameters
- 
  
    | [in] | buf | The message to parse. |  | [in] | len | Length of buf. |  | [in] | family | The address family used to compose the query for this response (see dns_msg_compose_query()) |  | [out] | addr_out | The IP address returned by the response. |  | [out] | ttl | The live time of the entry in seconds |  
 
- Returns
- Length of the addr_outon success.
- 
-EBADMSG, when an address corresponding to familycan not be found inbuf.