acl/app/jaws/global/service_struct.h

104 lines
2.9 KiB
C
Raw Normal View History

2014-11-19 00:25:21 +08:00
#ifndef __SERVICE_STRUCT_INCLUDE_H__
#define __SERVICE_STRUCT_INCLUDE_H__
#include "lib_acl.h"
#include "conn_cache.h"
#include "dns.h"
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct SERVICE SERVICE;
typedef struct CLIENT_ENTRY CLIENT_ENTRY;
/* <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD><D8BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD> */
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD> */
typedef void (*module_service_init_fn)(ACL_DLL_ENV *dll_env, const char *cfgdir);
/* <20><><EFBFBD>񴴽<EFBFBD><F1B4B4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD> */
typedef SERVICE *(*module_service_create_fn)(void);
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><DABA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD> */
typedef void (*module_service_main_fn)(SERVICE *service, ACL_ASTREAM *stream);
typedef struct {
module_service_init_fn mod_init;
module_service_create_fn mod_create;
module_service_main_fn mod_main;
} MODULE_SERVICE;
struct SERVICE {
char name[256]; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
ACL_AIO *aio; /* <20>첽IO<49><4F><EFBFBD><EFBFBD> */
acl_pthread_pool_t *wq; /* Ϊ<>˼<EFBFBD><CBBC><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>̳߳ؾ<CCB3><D8BE><EFBFBD> */
ACL_ASTREAM *sstream; /* <20><><EFBFBD><EFBFBD><EFBFBD>׽ӿ<D7BD> */
int conn_timeout; /* Ĭ<>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>ӳ<EFBFBD>ʱʱ<CAB1><CAB1> */
int rw_timeout; /* Ĭ<>ϵ<EFBFBD>IO<49><4F>ʱʱ<CAB1><CAB1> */
ACL_DNS *dns_handle; /* <20><><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>DNSЭ<53>ʽ<E9B7BD><CABD>ѯ */
DNS_SERVER *dns_server; /* DNS<4E><53>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD> */
ACL_HTABLE *dns_table; /* DNS<4E><53>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3> */
char local_addr[256]; /* <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1>ص<EFBFBD>ַ */
char **bind_ip_list; /* <20><><EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>󶨱<EFBFBD><F3B6A8B1><EFBFBD><EFBFBD><EFBFBD>IP<49><50>ַ<EFBFBD>б<EFBFBD> */
int bind_ip_index; /* <20><>ǰ<EFBFBD><C7B0>Ҫ<EFBFBD>󶨵<EFBFBD>IP */
CONN_CACHE *conn_cache; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳض<D3B3><D8B6><EFBFBD> */
MODULE_SERVICE *module; /* <20><><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>ģ<EFBFBD><C4A3> */
};
typedef struct DNS_RING {
char domain_key[256];
ACL_RING ring;
int nrefer;
} DNS_RING;
struct CLIENT_ENTRY {
SERVICE *service; /* ָ<><D6B8><EFBFBD><EFBFBD><ECB2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
ACL_ASTREAM *client; /* <20><><EFBFBD><EFBFBD><EFBFBD>ڿͻ<DABF><CDBB>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
ACL_ASTREAM *server; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
int nrefer; /* <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD> */
ACL_RING dns_entry; /* DNS<4E><53>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
char domain_key[256]; /* <20><><EFBFBD><EFBFBD>(Сд) */
char domain_addr[64]; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>һ<EFBFBD><D2BB>IP<49><50>ַ */
DNS_CTX dns_ctx; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>صĵ<D8B5>ַ<EFBFBD><D6B7>Ϣ */
int ip_idx; /* <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>IP<49><50>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
int ip_ntry; /* <20><><EFBFBD><EFBFBD> IP <20><><EFBFBD><EFBFBD> */
int server_port; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PORT */
char client_ip[32]; /* <20>ͻ<EFBFBD><CDBB><EFBFBD>IP<49><50>ַ */
int client_port; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PORT */
const char *dns_errmsg;
struct {
time_t begin; /* <20><EFBFBD><E1BBB0>ʼʱ<CABC><CAB1><EFBFBD><EFBFBD> */
time_t stamp; /* <20><>̬<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> */
time_t dns_lookup; /* DNS<4E><53>ѯʱ<D1AF><CAB1>(<28><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>λ) */
time_t connect; /* <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>(<28><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>λ) */
} tm;
int flag_has_replied;
int flag_conn_reuse; /* <20>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD> */
int nretry_on_error; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD> */
#define MAX_RETRIED 10
void (*free_fn)(CLIENT_ENTRY*);
void (*nslookup_notify_fn)(CLIENT_ENTRY*, int);
#define NSLOOKUP_OK 0
#define NSLOOKUP_ERR -1
int (*connect_notify_fn)(CLIENT_ENTRY*);
void (*connect_timeout_fn)(CLIENT_ENTRY*);
void (*connect_error_fn)(CLIENT_ENTRY*);
};
#ifdef __cplusplus
}
#endif
#endif