2014-11-19 00:06:40 +08:00
|
|
|
|
#ifndef ACL_RES_INCLUDE_H
|
|
|
|
|
#define ACL_RES_INCLUDE_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "stdlib/acl_define.h"
|
|
|
|
|
#include "acl_netdb.h"
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* DNS<EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ洢<EFBFBD>ṹ
|
|
|
|
|
*/
|
|
|
|
|
typedef struct ACL_RES {
|
|
|
|
|
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><>) */
|
|
|
|
|
int errnum;
|
|
|
|
|
#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> */
|
|
|
|
|
|
|
|
|
|
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>ģʽ */
|
|
|
|
|
|
|
|
|
|
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> */
|
|
|
|
|
} ACL_RES;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <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>
|
|
|
|
|
*/
|
|
|
|
|
ACL_API ACL_RES *acl_res_new(const char *dns_ip, unsigned short dns_port);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>ͷ<EFBFBD>һ<EFBFBD><EFBFBD>DNS<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param res {ACL_RES*} DNS<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
ACL_API void acl_res_free(ACL_RES *res);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <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>
|
|
|
|
|
*/
|
|
|
|
|
ACL_API ACL_DNS_DB *acl_res_lookup(ACL_RES *res, const char *domain);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <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>Ϣ
|
|
|
|
|
*/
|
|
|
|
|
ACL_API const char *acl_res_strerror(int errnum);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <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>Ϣ
|
|
|
|
|
*/
|
|
|
|
|
ACL_API const char *acl_res_errmsg(const ACL_RES *res);
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|