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
family
is AF_INET
or AF_UNSPEC
a query for an A record will be added
- When
family
is AF_INET6
or AF_UNSPEC
a 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 , or AF_INET6 . Determines the address records for domain_name queried. |
- 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_out
on success.
-
-EBADMSG, when an address corresponding to
family
can not be found in buf
.