Basic Tests pass
This commit is contained in:
35
dns_server.c
35
dns_server.c
@@ -98,40 +98,7 @@ struct dns_request {
|
|||||||
|
|
||||||
static struct dns_server server;
|
static struct dns_server server;
|
||||||
|
|
||||||
void _dns_server_period_run()
|
void _dns_server_period_run() {}
|
||||||
{
|
|
||||||
return;
|
|
||||||
unsigned char packet_data[DNS_PACKSIZE];
|
|
||||||
unsigned char data[DNS_IN_PACKSIZE];
|
|
||||||
|
|
||||||
struct dns_packet *packet = (struct dns_packet *)packet_data;
|
|
||||||
|
|
||||||
struct dns_head head;
|
|
||||||
memset(&head, 0, sizeof(head));
|
|
||||||
head.rcode = 0;
|
|
||||||
head.qr = 0;
|
|
||||||
head.rd = 1;
|
|
||||||
head.ra = 0;
|
|
||||||
head.id = 1;
|
|
||||||
|
|
||||||
int len;
|
|
||||||
struct sockaddr_in to;
|
|
||||||
socklen_t to_len = sizeof(to);
|
|
||||||
|
|
||||||
dns_packet_init(packet, DNS_PACKSIZE, &head);
|
|
||||||
dns_add_domain(packet, "www.huawei.com", DNS_T_A, 1);
|
|
||||||
len = dns_encode(data, DNS_IN_PACKSIZE, packet);
|
|
||||||
|
|
||||||
memset(&to, 0, sizeof(to));
|
|
||||||
to.sin_addr.s_addr = inet_addr("192.168.1.1");
|
|
||||||
to.sin_port = htons(53);
|
|
||||||
|
|
||||||
len = sendto(server.fd, data, len, 0, (struct sockaddr *)&to, to_len);
|
|
||||||
if (len < 0) {
|
|
||||||
tlog(TLOG_ERROR, "send failed.");
|
|
||||||
}
|
|
||||||
tlog(TLOG_ERROR, "send.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _dns_server_forward_request(unsigned char *inpacket, int inpacket_len)
|
static int _dns_server_forward_request(unsigned char *inpacket, int inpacket_len)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -246,6 +246,12 @@ static void _fast_ping_host_put(struct ping_host_struct *ping_host)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct timeval tv;
|
||||||
|
tv.tv_sec = 0;
|
||||||
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
|
ping_host->ping_callback(ping_host, ping_host->host, PING_RESULT_END, &ping_host->addr, ping_host->addr_len, ping_host->seq, &tv, ping_host->userptr);
|
||||||
|
|
||||||
free(ping_host);
|
free(ping_host);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +271,7 @@ static void _fast_ping_host_put_locked(struct ping_host_struct *ping_host)
|
|||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
ping_host->ping_callback(ping_host, ping_host->host, PING_RESULT_END, &ping_host->addr, ping_host->addr_len, ping_host->seq, &tv, ping_host->userptr);
|
ping_host->ping_callback(ping_host, ping_host->host, PING_RESULT_END, &ping_host->addr, ping_host->addr_len, ping_host->seq, &tv, ping_host->userptr);
|
||||||
|
|
||||||
free(ping_host);
|
free(ping_host);
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ static inline int atomic_sub_and_test( int i, atomic_t *v )
|
|||||||
*/
|
*/
|
||||||
static inline void atomic_inc( atomic_t *v )
|
static inline void atomic_inc( atomic_t *v )
|
||||||
{
|
{
|
||||||
(void)__sync_fetch_and_add(&v->counter, 1);
|
(void)__sync_add_and_fetch(&v->counter, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,7 +88,7 @@ static inline void atomic_inc( atomic_t *v )
|
|||||||
*/
|
*/
|
||||||
static inline void atomic_dec( atomic_t *v )
|
static inline void atomic_dec( atomic_t *v )
|
||||||
{
|
{
|
||||||
(void)__sync_fetch_and_sub(&v->counter, 1);
|
(void)__sync_sub_and_fetch(&v->counter, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user