+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
void PROTO::AddUser(const USER & user, bool connect)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
users.push_back(std::make_pair(user.GetIP(), user));
users.back().second.InitNetwork();
bool PROTO::Connect(uint32_t ip)
{
std::list<std::pair<uint32_t, USER> >::iterator it;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
it = std::find_if(users.begin(), users.end(), HasIP(ip));
if (it == users.end())
return false;
bool PROTO::Disconnect(uint32_t ip)
{
std::list<std::pair<uint32_t, USER> >::iterator it;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
it = std::find_if(users.begin(), users.end(), HasIP(ip));
if (it == users.end())
return false;
{
int res;
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
res = poll(&pollFds.front(), pollFds.size(), timeout);
}
if (res < 0)
void PROTO::CheckTimeouts()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::list<std::pair<uint32_t, USER> >::iterator it;
for (it = users.begin(); it != users.end(); ++it)
{
bool result = true;
std::vector<struct pollfd>::iterator it;
std::list<std::pair<uint32_t, USER> >::iterator userIt;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
for (it = pollFds.begin(), userIt = users.begin(); it != pollFds.end() && userIt != users.end(); ++it, ++userIt)
{
if (it->revents)
return true;
}
-bool PROTO::ERR_Proc(const void * buffer, USER * user)
+bool PROTO::ERR_Proc(const void * /*buffer*/, USER * user)
{
-const ERR_8 * packet = static_cast<const ERR_8 *>(buffer);
-const char * ptr = static_cast<const char *>(buffer);
-
//uint32_t len = packet->len;
#ifdef ARCH_BE
hdr.protoVer[1] = 8; // IA_PROTO_VER
unsigned char buffer[2048];
-memset(buffer, 0, sizeof(buffer));
-memcpy(buffer, packet, length);
memcpy(buffer, &hdr, sizeof(hdr));
+memcpy(buffer + sizeof(hdr), packet, length);
size_t offset = sizeof(HDR_8);
for (size_t i = 0; i < IA_LOGIN_LEN / 8; i++)