00001
00002
00004
00010 #ifndef __PHGLOBAL__H__
00011 #define __PHGLOBAL__H__
00012 #ifndef WIN32
00013 #include <sys/types.h>
00014 #include <sys/socket.h>
00015 #include <sys/ioctl.h>
00016 #include <netinet/in.h>
00017 #include <arpa/inet.h>
00018 #include <unistd.h>
00019 #include <errno.h>
00020 #include <netdb.h>
00021 #include <string.h>
00022 #include <time.h>
00023 #include <sys/timeb.h>
00024 #endif
00025
00026 #ifdef WIN32
00027 #include <winsock.h>
00028 #define sleep(x) Sleep(x*1000)
00029 #endif
00030
00031 #include <list>
00032 #include <string>
00033
00034 using namespace std;
00035 #define MAX_TCP_PACKET_LEN 8192
00036
00038 enum MessageCodes
00039 {
00040 okConnected = 0,
00041 okAuthpassed,
00042 okDomainListed,
00043 okDomainsRegistered,
00044 okKeepAliveRecved,
00045 okConnecting,
00046 okRetrievingMisc,
00047 okRedirecting,
00048
00049 errorConnectFailed = 0x100,
00050 errorSocketInitialFailed,
00051 errorAuthFailed,
00052 errorDomainListFailed,
00053 errorDomainRegisterFailed,
00054 errorUpdateTimeout,
00055 errorKeepAliveError,
00056 errorRetrying,
00057 errorAuthBusy,
00058 errorStatDetailInfoFailed,
00059
00060
00061 okNormal = 0x120,
00062 okNoData,
00063 okServerER,
00064 errorOccupyReconnect,
00065 };
00066
00068 #define COMMAND_AUTH "auth router6\r\n"
00069 #define COMMAND_REGI "regi a"
00070 #define COMMAND_CNFM "cnfm\r\n"
00071 #define COMMAND_STAT_USER "stat user\r\n"
00072 #define COMMAND_STAT_DOM "stat domain\r\n"
00073 #define COMMAND_QUIT "quit\r\n"
00074
00076 #define UDP_OPCODE_UPDATE_VER2 0x2010
00078 #define UDP_OPCODE_UPDATE_OK 0x2050
00080 #define UDP_OPCODE_UPDATE_ERROR 1000
00081
00083 #define UDP_OPCODE_LOGOUT 11
00084
00086 #define KEEPALIVE_PACKET_LEN 20
00087
00089 const char *convert_status_code(int nCode);
00090
00092 const char *my_inet_ntoa(long ip);
00093
00095 struct DATA_KEEPALIVE
00096 {
00098 long lChatID;
00100 long lOpCode;
00102 long lID;
00104 long lSum;
00106 long lReserved;
00107 };
00108
00110 struct DATA_KEEPALIVE_EXT
00111 {
00112 DATA_KEEPALIVE keepalive;
00113 long ip;
00114 };
00115
00117 struct PHGlobal
00118 {
00119 PHGlobal();
00120 ~PHGlobal();
00121
00123 long clientinfo;
00125 long challengekey;
00126
00128 char szHost[256];
00130 short nPort;
00132 char szUserID[256];
00134 char szUserPWD[256];
00136 char szBindAddress[256];
00137
00139 int nUserType;
00140 bool bTcpUpdateSuccessed;
00141 char szChallenge[256];
00142 int nChallengeLen;
00143 int nChatID,nStartID,nLastResponseID;
00144 long tmLastResponse;
00145 int nAddressIndex;
00146 char szTcpConnectAddress[32];
00147
00148 int cLastResult;
00149 long ip;
00150
00151 long uptime;
00152 long lasttcptime;
00153
00154 char szActiveDomains[255][255];
00155
00156 std::string szUserInfo;
00157 std::string szDomainInfo;
00158
00159 void init();
00160 };
00161
00162
00163 #endif