Update code

This commit is contained in:
Nick Peng
2018-06-08 21:57:33 +08:00
parent 4ee70e3eac
commit 4a6b0baddd
5 changed files with 595 additions and 537 deletions

10
dns.c
View File

@@ -35,10 +35,10 @@ short dns_read_short(unsigned char **buffer)
{
unsigned short value;
value = *((unsigned short *)(*buffer));
value = ntohs(*((unsigned short *)(*buffer)));
*buffer += 2;
return ntohs(value);
return value;
}
void dns_write_char(unsigned char **buffer, unsigned char value)
@@ -63,7 +63,7 @@ void dns_write_short(unsigned char **buffer, unsigned short value)
void dns_write_int(unsigned char **buffer, unsigned int value)
{
value = htons(value);
value = htonl(value);
*((unsigned int *)(*buffer)) = value;
*buffer += 4;
}
@@ -72,10 +72,10 @@ unsigned int dns_read_int(unsigned char **buffer)
{
unsigned int value;
value = *((unsigned int *)(*buffer));
value = ntohl(*((unsigned int *)(*buffer)));
*buffer += 4;
return ntohs(value);
return value;
}
struct dns_rrs *dns_get_rrs_start(struct dns_packet *packet, dns_rr_type type, int *count)