5 #include <netinet/in_systm.h>
7 #include <netinet/ip.h>
16 #include "stg/os_int.h"
17 #include "stg/blowfish.h"
23 typedef bool (PROTO::*PacketProcessor)(const void *, USER *);
27 PROTO(const std::string & server,
36 const std::string GetStrError() const { return errorStr; }
38 void AddUser(const USER & user, bool connect = false);
40 bool Connect(uint32_t ip);
41 bool Disconnect(uint32_t ip);
43 size_t UserCount() const { return users.size(); }
46 struct sockaddr_in localAddr;
47 struct sockaddr_in serverAddr;
50 std::list<std::pair<uint32_t, USER> > users;
51 std::vector<struct pollfd> pollFds;
57 pthread_mutex_t mutex;
61 std::map<std::string, PacketProcessor> processors;
63 static void * Runner(void * data);
68 bool SendPacket(const void * buffer, size_t length, USER * user);
69 bool HandlePacket(const char * buffer, size_t length, USER * user);
71 bool CONN_SYN_ACK_Proc(const void * buffer, USER * user);
72 bool ALIVE_SYN_Proc(const void * buffer, USER * user);
73 bool DISCONN_SYN_ACK_Proc(const void * buffer, USER * user);
74 bool FIN_Proc(const void * buffer, USER * user);
75 bool INFO_Proc(const void * buffer, USER * user);
76 bool ERR_Proc(const void * buffer, USER * user);
78 bool Send_CONN_SYN(USER * user);
79 bool Send_CONN_ACK(USER * user);
80 bool Send_DISCONN_SYN(USER * user);
81 bool Send_DISCONN_ACK(USER * user);
82 bool Send_ALIVE_ACK(USER * user);
84 bool RealConnect(USER * user);
85 bool RealDisconnect(USER * user);