M17 Packet sending a DEBUG help

unstable
Tom Early 4 years ago
parent 1a6b3291f7
commit 610da89ab4

@ -262,9 +262,8 @@ void CM17Protocol::HandleQueue(void)
// is this client busy ?
if ( !client->IsAMaster() && (client->GetReflectorModule() == module) )
{
CBuffer Buffer(frame.magic, sizeof(SM17Frame));
// no, send the packet
Send(Buffer, client->GetIp());
Send(frame, client->GetIp());
}
}

@ -337,6 +337,22 @@ void CProtocol::Send(const char *buf, const CIp &Ip, uint16_t port) const
}
}
void CProtocol::Send(const SM17Frame &frame, const CIp &Ip) const
{
switch (Ip.GetFamily())
{
case AF_INET:
m_Socket4.Send(frame.magic, sizeof(SM17Frame), Ip);
break;
case AF_INET6:
m_Socket6.Send(frame.magic, sizeof(SM17Frame), Ip);
break;
default:
std::cerr << "WrongFamily: " << Ip.GetFamily() << std::endl;
break;
}
}
#ifdef DEBUG
void CProtocol::Dump(const char *title, const uint8_t *data, int length)
{

@ -113,6 +113,7 @@ protected:
void Send(const char *buf, const CIp &Ip) const;
void Send(const CBuffer &buf, const CIp &Ip, uint16_t port) const;
void Send(const char *buf, const CIp &Ip, uint16_t port) const;
void Send(const SM17Frame &frame, const CIp &Ip) const;
// socket
CUdpSocket m_Socket4;

@ -173,3 +173,8 @@ void CUdpSocket::Send(const char *Buffer, const CIp &Ip, uint16_t destport) cons
temp.SetPort(destport);
sendto(m_fd, Buffer, ::strlen(Buffer), 0, temp.GetCPointer(), temp.GetSize());
}
void CUdpSocket::Send(const uint8_t *data, size_t size, const CIp &Ip) const
{
sendto(m_fd, data, size, 0, Ip.GetCPointer(), Ip.GetSize());
}

@ -57,6 +57,7 @@ public:
void Send(const char *, const CIp &) const;
void Send(const CBuffer &, const CIp &, uint16_t) const;
void Send(const char *, const CIp &, uint16_t) const;
void Send(const u_int8_t *, size_t size, const CIp &) const;
protected:
// data

Loading…
Cancel
Save

Powered by TurnKey Linux.