net/dns: Fix DNS answer RR computation

- Remove a routine that erroneously computes an answer RR value:
  dns_answer_rdlength.

- Change: dns_unpack_answer_rdlength -> dns_answer_rdlength.

- Change: htonl -> ntohl in the dns_answer_ttl routine.

Change-Id: I8b5a16f63560d3e23dd38cb7339b6e232bb706ea
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
This commit is contained in:
Flavio Santes 2017-03-10 02:28:29 -06:00 committed by Jukka Rissanen
parent 86e6a5d00a
commit 87fc47e1fe
2 changed files with 3 additions and 8 deletions

View File

@ -143,7 +143,7 @@ int dns_unpack_answer(struct dns_msg_t *dns_msg, int dname_ptr, uint32_t *ttl)
/* TTL value */
*ttl = dns_answer_ttl(DNS_COMMON_UINT_SIZE, answer);
pos = dns_msg->answer_offset + DNS_ANSWER_MIN_SIZE;
len = dns_unpack_answer_rdlength(DNS_COMMON_UINT_SIZE, answer);
len = dns_answer_rdlength(DNS_COMMON_UINT_SIZE, answer);
switch (dns_answer_type(DNS_COMMON_UINT_SIZE, answer)) {
case DNS_RR_TYPE_A:

View File

@ -220,15 +220,10 @@ static inline int dns_answer_class(uint16_t dname_size, uint8_t *answer)
static inline int dns_answer_ttl(uint16_t dname_size, uint8_t *answer)
{
return htonl(UNALIGNED_GET((uint32_t *)(answer + dname_size + 4)));
return ntohl(UNALIGNED_GET((uint32_t *)(answer + dname_size + 4)));
}
static inline int dns_answer_rdlength(uint16_t dname_size, uint8_t *answer)
{
return htons(UNALIGNED_GET((uint16_t *)(answer + dname_size + 8)));
}
static inline int dns_unpack_answer_rdlength(uint16_t dname_size,
static inline int dns_answer_rdlength(uint16_t dname_size,
uint8_t *answer)
{
return ntohs(UNALIGNED_GET((uint16_t *)(answer + dname_size + 8)));