dns_msg: make parsing input buffer const
This commit is contained in:
parent
e8cbc6da85
commit
7920ab2b95
@ -109,7 +109,8 @@ size_t dns_msg_compose_query(void *dns_buf, const char *domain_name,
|
|||||||
* @return -EBADMSG, when an address corresponding to @p family can not be found
|
* @return -EBADMSG, when an address corresponding to @p family can not be found
|
||||||
* in @p buf.
|
* in @p buf.
|
||||||
*/
|
*/
|
||||||
int dns_msg_parse_reply(uint8_t *buf, size_t len, int family, void *addr_out);
|
int dns_msg_parse_reply(const uint8_t *buf, size_t len, int family,
|
||||||
|
void *addr_out);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,14 +61,15 @@ static unsigned _put_short(uint8_t *out, uint16_t val)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned _get_short(uint8_t *buf)
|
static unsigned _get_short(const uint8_t *buf)
|
||||||
{
|
{
|
||||||
uint16_t _tmp;
|
uint16_t _tmp;
|
||||||
memcpy(&_tmp, buf, 2);
|
memcpy(&_tmp, buf, 2);
|
||||||
return _tmp;
|
return _tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t _skip_hostname(const uint8_t *buf, size_t len, uint8_t *bufpos)
|
static ssize_t _skip_hostname(const uint8_t *buf, size_t len,
|
||||||
|
const uint8_t *bufpos)
|
||||||
{
|
{
|
||||||
const uint8_t *buflim = buf + len;
|
const uint8_t *buflim = buf + len;
|
||||||
unsigned res = 0;
|
unsigned res = 0;
|
||||||
@ -129,11 +130,12 @@ size_t dns_msg_compose_query(void *dns_buf, const char *domain_name,
|
|||||||
return bufpos - buf;
|
return bufpos - buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dns_msg_parse_reply(uint8_t *buf, size_t len, int family, void *addr_out)
|
int dns_msg_parse_reply(const uint8_t *buf, size_t len, int family,
|
||||||
|
void *addr_out)
|
||||||
{
|
{
|
||||||
const uint8_t *buflim = buf + len;
|
const uint8_t *buflim = buf + len;
|
||||||
dns_hdr_t *hdr = (dns_hdr_t *)buf;
|
const dns_hdr_t *hdr = (dns_hdr_t *)buf;
|
||||||
uint8_t *bufpos = buf + sizeof(*hdr);
|
const uint8_t *bufpos = buf + sizeof(*hdr);
|
||||||
|
|
||||||
/* skip all queries that are part of the reply */
|
/* skip all queries that are part of the reply */
|
||||||
for (unsigned n = 0; n < ntohs(hdr->qdcount); n++) {
|
for (unsigned n = 0; n < ntohs(hdr->qdcount); n++) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user