dnsquery.h
2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// dnsquery.h
//
// Created by cairui01 on 18/11/9.
// Copyright (c) 2018年 baidu. All rights reserved.
//
#ifndef SDT_SRC_CHECKIMPL_DNSQUERY_H_
#define SDT_SRC_CHECKIMPL_DNSQUERY_H_
#include <arpa/inet.h>
#include <string>
#ifdef __cplusplus
extern "C"{
#endif
/**
*函数名: socket_gethostbyname
*功能: 输入域名,可得到该域名下所对应的IP地址列表
*输入: _host:输入的要查询的主机域名
*输入: _timeout:设置查询超时时间,单位为毫秒
*输入: _dnsserver 指定的dns服务器的IP
*输入: _qtype 指定query类型(1:A,28:AAAA)
*输入: _socket_errno 记录socket api 错误码引用
*输入::....._dns_server_ips 记录局域网中的dns服务器ip地址列表引用
*输入: _dns_server_used 记录所使用dns server ip地址引用
*输入:......_enable_dns_query_failover 是否需要过滤局域网dns server ip地址且在失败且存在多个可选dns server ip时进行再次探测
*输入:......_interface_name 使用指定网卡
*输出: _ipinfo为要输出的ip信息结构体
*返回值: 当返回-1表示查询失败,当返回0则表示查询成功
*
*/
#define SOCKET_MAX_IP_COUNT (20)
struct socket_ipinfo_t
{
int size;
int size6;
struct in_addr ip[SOCKET_MAX_IP_COUNT];
struct in6_addr ip6[SOCKET_MAX_IP_COUNT];
};
int socket_gethostbyname(const char* _host, struct socket_ipinfo_t* _ipinfo, int _timeout /*ms*/, const std::string& _dnsserver, int _qtype,
int& _socket_errno,
std::vector<std::string>& _dns_server_ips,
std::string& _dns_server_used,
bool _enable_dns_query_failover,
const std::string& _interface_name);
#ifdef __cplusplus
}
class NetCheckTrafficMonitor;
int socket_gethostbyname(const char* _host, struct socket_ipinfo_t* _ipinfo, int _timeout /*ms*/, const char* _dnsserver, NetCheckTrafficMonitor* _traffic_monitor);
#endif
#endif