4 #include <netinet/ip.h>
12 #include "stg/os_int.h"
13 #include "stg/blowfish.h"
19 typedef bool (PROTO::*PacketProcessor)(const void *, USER *);
23 PROTO(const std::string & server,
32 const std::string GetStrError() const { return errorStr; }
34 void AddUser(const USER & user, bool connect = false);
36 bool Connect(uint32_t ip);
37 bool Disconnect(uint32_t ip);
39 size_t UserCount() const { return users.size(); }
42 struct sockaddr_in localAddr;
43 struct sockaddr_in serverAddr;
46 std::vector<std::pair<uint32_t, USER> > users;
47 std::vector<struct pollfd> pollFds;
56 std::map<std::string, PacketProcessor> processors;
58 static void * Runner(void * data);
62 bool SendPacket(const void * buffer, size_t length, USER * user);
63 bool HandlePacket(const char * buffer, USER * user);
65 bool CONN_SYN_ACK_Proc(const void * buffer, USER * user);
66 bool ALIVE_SYN_Proc(const void * buffer, USER * user);
67 bool DISCONN_SYN_ACK_Proc(const void * buffer, USER * user);
68 bool FIN_Proc(const void * buffer, USER * user);
69 bool INFO_Proc(const void * buffer, USER * user);
70 bool ERR_Proc(const void * buffer, USER * user);
72 bool Send_CONN_SYN(USER * user);
73 bool Send_CONN_ACK(USER * user);
74 bool Send_DISCONN_SYN(USER * user);
75 bool Send_DISCONN_ACK(USER * user);
76 bool Send_ALIVE_ACK(USER * user);
78 bool RealConnect(USER * user);
79 bool RealDisconnect(USER * user);