2019-07-28 10:31:56 +08:00
|
|
|
|
#ifndef ACL_RES_INCLUDE_H
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#define ACL_RES_INCLUDE_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../stdlib/acl_define.h"
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#include "acl_netdb.h"
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* DNS<EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ洢<EFBFBD>ṹ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
typedef struct ACL_RES {
|
2019-07-28 10:31:56 +08:00
|
|
|
|
char dns_ip[64]; /**< DNS<4E><53>IP<49><50>ַ */
|
|
|
|
|
unsigned short dns_port; /**< DNS<4E><53>Port */
|
|
|
|
|
unsigned short cur_qid; /**< <20>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0>ı<EFBFBD>ʶ */
|
|
|
|
|
time_t tm_spent; /**< <20><>ѯʱ<D1AF><CAB1><EFBFBD>ķ<EFBFBD>(<28><>) */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
int errnum;
|
2019-07-28 10:31:56 +08:00
|
|
|
|
#define ACL_RES_ERR_SEND -100 /**< д<><D0B4><EFBFBD><EFBFBD> */
|
|
|
|
|
#define ACL_RES_ERR_READ -101 /**< <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
#define ACL_RES_ERR_RTMO -102 /**< <20><><EFBFBD><EFBFBD>ʱ */
|
|
|
|
|
#define ACL_RES_ERR_NULL -103 /**< <20>ս<EFBFBD><D5BD><EFBFBD> */
|
|
|
|
|
#define ACL_RES_ERR_CONN -104 /**< TCP<43><50>ʽʱ<CABD><CAB1><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
int transfer; /**< TCP/UDP <20><><EFBFBD><EFBFBD>ģʽ */
|
|
|
|
|
#define ACL_RES_USE_UDP 0 /**< UDP <20><><EFBFBD><EFBFBD>ģʽ */
|
|
|
|
|
#define ACL_RES_USE_TCP 1 /**< TCP <20><><EFBFBD><EFBFBD>ģʽ */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
int conn_timeout; /**< TCP <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>ʱʱ<CAB1><CAB1>, Ĭ<><C4AC>Ϊ10<31><30> */
|
|
|
|
|
int rw_timeout; /**< TCP/UDP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO<49><4F>ʱʱ<CAB1><CAB1>, Ĭ<><C4AC>Ϊ10<31><30> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
} ACL_RES;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>DNS<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param dns_ip {const char*} DNS<EFBFBD><EFBFBD>IP<EFBFBD><EFBFBD>ַ
|
|
|
|
|
* @param dns_port {unsigned short} DNS<EFBFBD><EFBFBD>Port
|
|
|
|
|
* @return {ACL_RES*} <EFBFBD>´<EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API ACL_RES *acl_res_new(const char *dns_ip, unsigned short dns_port);
|
|
|
|
|
|
2017-04-13 21:50:55 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>DNS<EFBFBD><EFBFBD>ѯ<EFBFBD>ij<EFBFBD>ʱʱ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param conn_timeout {int} TCP <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>ʱʱ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param rw_timeout {int} TCP/UDP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>
|
2017-04-13 21:50:55 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API void acl_res_set_timeout(int conn_timeout, int rw_timeout);
|
|
|
|
|
|
2014-11-19 00:25:21 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>ͷ<EFBFBD>һ<EFBFBD><EFBFBD>DNS<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param res {ACL_RES*} DNS<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API void acl_res_free(ACL_RES *res);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ѯij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<EFBFBD><EFBFBD>ַ
|
|
|
|
|
* @param res {ACL_RES*} DNS<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param domain {const char*} Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {ACL_DNS_DB*} <EFBFBD><EFBFBD>ѯ<EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API ACL_DNS_DB *acl_res_lookup(ACL_RES *res, const char *domain);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ż<EFBFBD><EFBFBD>ò<EFBFBD>ѯʧ<EFBFBD>ܵ<EFBFBD>ԭ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param errnum {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API const char *acl_res_strerror(int errnum);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><EFBFBD>ѯ<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* @param res {ACL_RES*} DNS<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API const char *acl_res_errmsg(const ACL_RES *res);
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|