4 #include <netinet/ip.h>
13 #include "stg/os_int.h"
14 #include "stg/blowfish.h"
20 typedef bool (PROTO::*PacketProcessor)(const void *, USER *);
24 PROTO(const std::string & server,
33 const std::string GetStrError() const { return errorStr; }
35 void AddUser(const USER & user, bool connect = false);
37 bool Connect(uint32_t ip);
38 bool Disconnect(uint32_t ip);
40 size_t UserCount() const { return users.size(); }
43 struct sockaddr_in localAddr;
44 struct sockaddr_in serverAddr;
47 std::list<std::pair<uint32_t, USER> > users;
48 std::vector<struct pollfd> pollFds;
54 pthread_mutex_t mutex;
58 std::map<std::string, PacketProcessor> processors;
60 static void * Runner(void * data);
64 bool SendPacket(const void * buffer, size_t length, USER * user);
65 bool HandlePacket(const char * buffer, size_t length, USER * user);
67 bool CONN_SYN_ACK_Proc(const void * buffer, USER * user);
68 bool ALIVE_SYN_Proc(const void * buffer, USER * user);
69 bool DISCONN_SYN_ACK_Proc(const void * buffer, USER * user);
70 bool FIN_Proc(const void * buffer, USER * user);
71 bool INFO_Proc(const void * buffer, USER * user);
72 bool ERR_Proc(const void * buffer, USER * user);
74 bool Send_CONN_SYN(USER * user);
75 bool Send_CONN_ACK(USER * user);
76 bool Send_DISCONN_SYN(USER * user);
77 bool Send_DISCONN_ACK(USER * user);
78 bool Send_ALIVE_ACK(USER * user);
80 bool RealConnect(USER * user);
81 bool RealDisconnect(USER * user);