#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

//traffic
#define LIMIT_WARNING_STR_VLM_OVER     "VolumeOver"
#define LIMIT_WARNING_STR_TIME_OVER    "TimeOver"
//traffic end

//CMM

#ifdef CMMIF_DEBUG
#define CMMIF_TRACE(fmt, args...) \
	printf("%s:%s:%d "fmt,  __FILE__, __func__, __LINE__, ##args)
#else
#define CMMIF_TRACE(fmt, args...) ((void)(fmt))
#endif


#define CMM_INIT_NONE			0
#define CMM_INIT_SUCCESS		1
#define CMM_INIT_FAILED		2

#define CMM_SUCCESS	MSG_OK
#define CMM_FAIL		(MSG_OK+1)
#define CMM_ERR_SEND	(MSG_OK+2)
#define CMM_ERR_RECV	(MSG_OK+3)
#define CMM_ERR_TIMEOUT	(MSG_OK+4)
#define CMM_ERR_MEM	(MSG_OK+5)

#define CALL_CMM_TIMEOUT	5 /* seconds */

//--
#include "tbsmsg.h"
#include "tbserror.h"
//#include "cfg_api.h"
#include "pc_api.h"
//#include "tbsutil.h"
//#include "warnlog.h"
//#include "common.h"
#include <unistd.h>


#include <memory.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>

// #ifdef ZTE_HOT_AP_SNMP_IF
//#include "snmpProcess.h"
//#endif

/* for inet_ntoa */
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <sys/times.h>
//--
#include "tbsmsg.h"
#include "tbserror.h"
//#include "cfg_api.h"
#include "pc_api.h"
//#include "tbsutil.h"
//#include "warnlog.h"
//#include "common.h"
//#include "timer.h"

//#include "cmmif.h"
#include <memory.h>

 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <sys/times.h>

 int CMM_Init();
 void CMM_Free();
 int CMM_Call(ST_MSG* pReq, ST_MSG** ppRsp);

 ST_MSG* CMM_CreateMessage(
	unsigned short usSrcMID, unsigned short usDstMID,
	unsigned short usMsgType, unsigned long ulBodyLength);
 ST_MSG* CMM_CreateGetValMessage(const char* szLeafName);
 int CMM_GetStr(const char* szLeafName, char* szValue, unsigned int uSize, char **pv, int pvLen);
//CMM END

#ifndef DPROXY_H
#define DPROXY_H

#define PORT 53
#define NAME_SIZE 255
#define MAX_PACKET_SIZE 512
#define BUF_SIZE NAME_SIZE

typedef u_int16_t uint16;
typedef u_int32_t uint32;

#include "dns.h"

#define REQUEST_CNT 32
#ifndef DNS_TIMEOUT
#define DNS_TIMEOUT 60
#endif
#ifndef DNS_SERVER_TIMEOUT
#define DNS_SERVER_TIMEOUT 2
#endif
#ifndef MAX_NAME_SERVER
#define MAX_NAME_SERVER 5
#endif

#ifndef NAME_SERVER_DEFAULT
#define NAME_SERVER_DEFAULT "0.0.0.0"
#endif
#ifndef CONFIG_FILE_DEFAULT
#define CONFIG_FILE_DEFAULT "/etc/dproxy.conf"
#endif
#ifndef DENY_FILE_DEFAULT
#define DENY_FILE_DEFAULT "/etc/dproxy.deny"
#endif
#ifndef CACHE_FILE_DEFAULT
#define CACHE_FILE_DEFAULT "/var/cache/dproxy.cache"
#endif
#ifndef HOSTS_FILE_DEFAULT
#define HOSTS_FILE_DEFAULT "/etc/hosts"
#endif
#ifndef PURGE_TIME_DEFAULT
//#define PURGE_TIME_DEFAULT 48 * 60 * 60  Original
#define PURGE_TIME_DEFAULT 5 * 60
#endif
#ifndef PPP_DEV_DEFAULT
#define PPP_DEV_DEFAULT "/var/run/ppp0.pid"
#endif
#ifndef DHCP_LEASES_DEFAULT
#define DHCP_LEASES_DEFAULT "/var/lib/misc/udhcpd.leases"
#endif
#ifndef PPP_DETECT_DEFAULT
#define PPP_DETECT_DEFAULT 0
#endif
#ifndef DEBUG_FILE_DEFAULT
#define DEBUG_FILE_DEFAULT "/var/log/dproxy.debug.log"
#endif

#if 1
#define debug(fmt, args...)
#define debug_perror(fmt)
#else
#define debug_perror(fmt)	perror(fmt)
#define debug(fmt, args...)	printf(fmt, ##args)
#endif
/*TBS_TAG:START added by sdh 2012-07-02
宏开关，同时往多个DNS SERVER地址发请求包
*/
#ifndef SENDTO_ALL_DNSSERVER_AT_ONCE 
#define SENDTO_ALL_DNSSERVER_AT_ONCE 
#endif
/*TBS_TAG:end*/
#endif

