00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef __TIEP_H__
00038 #define __TIEP_H__
00039
00040 #include "global.h"
00041
00045 struct tiep_pak_hdr {
00046 unsigned int type;
00047 unsigned int varkey;
00048 unsigned int entrynum;
00049 unsigned int priority;
00050 };
00051
00057
00058 class TiepPacket {
00061 pthread_mutex_t mutex_tpk_;
00064 void lock();
00067 void unlock();
00068 public:
00071 TiepPacket::TiepPacket();
00074 TiepPacket::~TiepPacket();
00078 struct tiep_pak_hdr *createhdr(int,int,int);
00082 int packet_type(char*);
00086 int packet_varkey(char*);
00090 int packet_num(char*);
00094 int packet_pri(char*);
00097 void create_md5_hash(unsigned char*,unsigned char*,unsigned char*);
00100 void md5_xor(unsigned char*,unsigned char*,unsigned char*,int);
00104 char *encrypt(char*,int,char*,int);
00108 char *decrypt(char*,int,char*,int);
00109 };
00110
00112
00113
00114 #define TIP_DT_PACKET 1
00115
00116 #define TIP_UT_PACKET 2
00117
00118 #define TIP_KA_PACKET 3
00119
00120 #define TIP_START_PACKET 4
00121
00122
00123 #define TIP_MAX_ENT 7
00124
00128 struct dt_pak_entry {
00131 unsigned int device;
00134 unsigned int status;
00137 unsigned int checknum;
00138 };
00139
00143 struct ut_pak_entry {
00146 char username[32];
00149 unsigned int device;
00152 unsigned int userip;
00155 unsigned int checknum;
00158 char port[32];
00161 char phone[32];
00164 unsigned int status;
00165 };
00166
00172 class TipPacket : public TiepPacket {
00175 pthread_mutex_t mutex_tp_;
00178 void lock();
00181 void unlock();
00182 public:
00185 TipPacket::TipPacket();
00188 TipPacket::~TipPacket();
00192 bool sendbuf(ipaddr,int,int,char*,int);
00195 struct dt_pak_entry *read_dt(char*,int,char*);
00198 struct ut_pak_entry *read_ut(char*,int,char*);
00202 int packetlen_dt(int);
00206 int packetlen_ut(int);
00207 };
00208
00214 class TipSystem : public TipPacket {
00217 pthread_mutex_t mutex_;
00220 void lock();
00223 void unlock();
00226 list<struct dt_pak_entry*> dt_pak;
00229 list<struct ut_pak_entry*> ut_pak;
00230 public:
00233 TipSystem::TipSystem();
00236 TipSystem::~TipSystem();
00239 void clear_dt();
00242 void clear_ut();
00245 void add_dt(ipaddr,bool);
00248 void add_ut(const string,ipaddr,ipaddr,const string,const string,bool);
00251 void send_dt();
00254 void send_ut();
00257 void send_ka();
00260 void send_start();
00261 };
00262
00264
00265
00266 #define TEP_DT_PACKET 6
00267
00268 #define TEP_UT_PACKET 7
00269
00274 class TepPacket : public TiepPacket {
00275 public:
00278 bool sendbuf(ipaddr,int,char*,int);
00281
00284
00287
00290
00291 };
00292
00297 class TepSystem : public TepPacket {
00298 public:
00299 };
00300
00301 #endif //__TIEP_H__