mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
get packet logging working with mvds
This commit is contained in:
parent
dc74519205
commit
2173151560
6 changed files with 56 additions and 60 deletions
|
@ -73,11 +73,11 @@ qboolean NET_IsClientLegal(netadr_t *adr);
|
||||||
|
|
||||||
|
|
||||||
int Net_Log_Init (const char **sound_precache);
|
int Net_Log_Init (const char **sound_precache);
|
||||||
void Log_Incoming_Packet (const char *p, int len);
|
void Log_Incoming_Packet (const char *p, int len, int has_sequence);
|
||||||
void Log_Outgoing_Packet (const char *p, int len);
|
void Log_Outgoing_Packet (const char *p, int len, int has_sequence);
|
||||||
void Net_LogStop (void);
|
void Net_LogStop (void);
|
||||||
void Analyze_Client_Packet (const byte * data, int len);
|
void Analyze_Client_Packet (const byte * data, int len, int has_sequence);
|
||||||
void Analyze_Server_Packet (const byte * data, int len);
|
void Analyze_Server_Packet (const byte * data, int len, int has_sequence);
|
||||||
|
|
||||||
extern struct cvar_s *net_packetlog;
|
extern struct cvar_s *net_packetlog;
|
||||||
|
|
||||||
|
@ -147,23 +147,11 @@ void Netchan_Setup (netchan_t *chan, netadr_t adr, int qport);
|
||||||
qboolean Netchan_CanPacket (netchan_t *chan);
|
qboolean Netchan_CanPacket (netchan_t *chan);
|
||||||
qboolean Netchan_CanReliable (netchan_t *chan);
|
qboolean Netchan_CanReliable (netchan_t *chan);
|
||||||
|
|
||||||
static inline int
|
|
||||||
Netchan_GetPacket (void)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = NET_GetPacket ();
|
|
||||||
if (ret && net_packetlog->int_val)
|
|
||||||
Log_Incoming_Packet(net_message->message->data,
|
|
||||||
net_message->message->cursize);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
Netchan_SendPacket (int length, void *data, netadr_t to)
|
Netchan_SendPacket (int length, void *data, netadr_t to)
|
||||||
{
|
{
|
||||||
if (net_packetlog->int_val)
|
if (net_packetlog->int_val)
|
||||||
Log_Outgoing_Packet(data, length);
|
Log_Outgoing_Packet(data, length, 1);
|
||||||
NET_SendPacket (length, data, to);
|
NET_SendPacket (length, data, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -402,9 +402,12 @@ CL_GetMessage (void)
|
||||||
if (cls.demoplayback)
|
if (cls.demoplayback)
|
||||||
return CL_GetDemoMessage ();
|
return CL_GetDemoMessage ();
|
||||||
|
|
||||||
if (!Netchan_GetPacket ())
|
if (!NET_GetPacket ())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Log_Incoming_Packet(net_message->message->data,
|
||||||
|
net_message->message->cursize, 1);
|
||||||
|
|
||||||
CL_WriteDemoMessage (net_message->message);
|
CL_WriteDemoMessage (net_message->message);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1014,7 +1014,7 @@ CL_ReadPackets (void)
|
||||||
|
|
||||||
if (cls.demoplayback && net_packetlog->int_val)
|
if (cls.demoplayback && net_packetlog->int_val)
|
||||||
Log_Incoming_Packet(net_message->message->data,
|
Log_Incoming_Packet(net_message->message->data,
|
||||||
net_message->message->cursize);
|
net_message->message->cursize, 0);
|
||||||
|
|
||||||
// remote command packet
|
// remote command packet
|
||||||
if (*(int *) net_message->message->data == -1) {
|
if (*(int *) net_message->message->data == -1) {
|
||||||
|
|
|
@ -250,7 +250,7 @@ ascii_dump_buf (unsigned char *buf, int len)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Log_Incoming_Packet (const char *p, int len)
|
Log_Incoming_Packet (const char *p, int len, int has_sequence)
|
||||||
{
|
{
|
||||||
if (!net_loglevel->int_val)
|
if (!net_loglevel->int_val)
|
||||||
return;
|
return;
|
||||||
|
@ -261,20 +261,20 @@ Log_Incoming_Packet (const char *p, int len)
|
||||||
if (net_loglevel->int_val != 3)
|
if (net_loglevel->int_val != 3)
|
||||||
hex_dump_buf ((unsigned char *) p, len);
|
hex_dump_buf ((unsigned char *) p, len);
|
||||||
if (net_loglevel->int_val > 1)
|
if (net_loglevel->int_val > 1)
|
||||||
Analyze_Client_Packet (p, len);
|
Analyze_Client_Packet (p, len, has_sequence);
|
||||||
} else {
|
} else {
|
||||||
Net_LogPrintf ("\n>>>>>>>>>>>>>>>>>>>>> server to client %d bytes: "
|
Net_LogPrintf ("\n>>>>>>>>>>>>>>>>>>>>> server to client %d bytes: "
|
||||||
">>>>>>>>>>>>>>>>>>>>>>>>\n", len);
|
">>>>>>>>>>>>>>>>>>>>>>>>\n", len);
|
||||||
if (net_loglevel->int_val != 3)
|
if (net_loglevel->int_val != 3)
|
||||||
hex_dump_buf ((unsigned char *) p, len);
|
hex_dump_buf ((unsigned char *) p, len);
|
||||||
if (net_loglevel->int_val > 1)
|
if (net_loglevel->int_val > 1)
|
||||||
Analyze_Server_Packet (p, len);
|
Analyze_Server_Packet (p, len, has_sequence);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Log_Outgoing_Packet (const char *p, int len)
|
Log_Outgoing_Packet (const char *p, int len, int has_sequence)
|
||||||
{
|
{
|
||||||
if (!net_loglevel->int_val)
|
if (!net_loglevel->int_val)
|
||||||
return;
|
return;
|
||||||
|
@ -285,14 +285,14 @@ Log_Outgoing_Packet (const char *p, int len)
|
||||||
if (net_loglevel->int_val != 3)
|
if (net_loglevel->int_val != 3)
|
||||||
hex_dump_buf ((unsigned char *) p, len);
|
hex_dump_buf ((unsigned char *) p, len);
|
||||||
if (net_loglevel->int_val > 1)
|
if (net_loglevel->int_val > 1)
|
||||||
Analyze_Server_Packet (p, len);
|
Analyze_Server_Packet (p, len, has_sequence);
|
||||||
} else {
|
} else {
|
||||||
Net_LogPrintf ("\n<<<<<<<<<<<<<<<<<<<<< client to server %d bytes: "
|
Net_LogPrintf ("\n<<<<<<<<<<<<<<<<<<<<< client to server %d bytes: "
|
||||||
"<<<<<<<<<<<<<<<<<<<<<<<<\n", len);
|
"<<<<<<<<<<<<<<<<<<<<<<<<\n", len);
|
||||||
if (net_loglevel->int_val != 3)
|
if (net_loglevel->int_val != 3)
|
||||||
hex_dump_buf ((unsigned char *) p, len);
|
hex_dump_buf ((unsigned char *) p, len);
|
||||||
if (net_loglevel->int_val > 1)
|
if (net_loglevel->int_val > 1)
|
||||||
Analyze_Client_Packet (p, len);
|
Analyze_Client_Packet (p, len, has_sequence);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -376,29 +376,33 @@ Log_Delta(int bits)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Parse_Server_Packet (void)
|
Parse_Server_Packet (int has_sequence)
|
||||||
{
|
{
|
||||||
const char *s;
|
const char *s;
|
||||||
int c, i, ii, iii, mask1, mask2;
|
int c, i, ii, iii, mask1, mask2;
|
||||||
long seq1, seq2;
|
long seq1 = 0, seq2;
|
||||||
|
|
||||||
seq1 = MSG_ReadLong (&packet);
|
if (has_sequence) {
|
||||||
if (packet.badread)
|
seq1 = MSG_ReadLong (&packet);
|
||||||
return;
|
if (packet.badread)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (seq1 == -1) {
|
if (seq1 == -1) {
|
||||||
Net_LogPrintf ("Special Packet");
|
Net_LogPrintf ("Special Packet");
|
||||||
} else {
|
} else {
|
||||||
seq2 = MSG_ReadLong (&packet);
|
if (has_sequence) {
|
||||||
// FIXME: display seqs right when reliable
|
seq2 = MSG_ReadLong (&packet);
|
||||||
Net_LogPrintf ("\nSeq: %ld Ack: %ld ", seq1 & 0x7FFFFFFF,
|
// FIXME: display seqs right when reliable
|
||||||
seq2 & 0x7FFFFFFF);
|
Net_LogPrintf ("\nSeq: %ld Ack: %ld ", seq1 & 0x7FFFFFFF,
|
||||||
|
seq2 & 0x7FFFFFFF);
|
||||||
|
|
||||||
if ((seq1 >> 31) & 0x01)
|
if ((seq1 >> 31) & 0x01)
|
||||||
Net_LogPrintf ("SV_REL ");
|
Net_LogPrintf ("SV_REL ");
|
||||||
if ((seq2 >> 31) & 0x01)
|
if ((seq2 >> 31) & 0x01)
|
||||||
Net_LogPrintf ("SV_RELACK");
|
Net_LogPrintf ("SV_RELACK");
|
||||||
Net_LogPrintf ("\n");
|
Net_LogPrintf ("\n");
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (packet.badread)
|
if (packet.badread)
|
||||||
|
@ -806,36 +810,39 @@ Parse_Server_Packet (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Analyze_Server_Packet (const byte * data, int len)
|
Analyze_Server_Packet (const byte * data, int len, int has_sequence)
|
||||||
{
|
{
|
||||||
if (!Net_PacketLog)
|
if (!Net_PacketLog)
|
||||||
Net_PacketLog = _stdout;
|
Net_PacketLog = _stdout;
|
||||||
packet.message->data = (byte*)data;
|
packet.message->data = (byte*)data;
|
||||||
packet.message->cursize = len;
|
packet.message->cursize = len;
|
||||||
MSG_BeginReading (&packet);
|
MSG_BeginReading (&packet);
|
||||||
Parse_Server_Packet ();
|
Parse_Server_Packet (has_sequence);
|
||||||
if (Net_PacketLog == _stdout)
|
if (Net_PacketLog == _stdout)
|
||||||
Net_PacketLog = NULL;
|
Net_PacketLog = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Parse_Client_Packet (void)
|
Parse_Client_Packet (int has_sequence)
|
||||||
{
|
{
|
||||||
int mask, i, c, ii;
|
int mask, i, c, ii;
|
||||||
long seq1, seq2;
|
long seq1 = 0, seq2;
|
||||||
|
|
||||||
seq1 = MSG_ReadLong (&packet);
|
if (has_sequence)
|
||||||
|
seq1 = MSG_ReadLong (&packet);
|
||||||
if (seq1 == -1) {
|
if (seq1 == -1) {
|
||||||
Net_LogPrintf ("Special: %s\n", MSG_ReadString (&packet));
|
Net_LogPrintf ("Special: %s\n", MSG_ReadString (&packet));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// FIXME: display seqs right when reliable
|
if (has_sequence) {
|
||||||
seq2 = MSG_ReadLong (&packet);
|
// FIXME: display seqs right when reliable
|
||||||
|
seq2 = MSG_ReadLong (&packet);
|
||||||
|
|
||||||
Net_LogPrintf ("\nSeq: %ld Ack: %ld ", seq1 & 0x7FFFFFFF,
|
Net_LogPrintf ("\nSeq: %ld Ack: %ld ", seq1 & 0x7FFFFFFF,
|
||||||
seq2 & 0x7FFFFFFF);
|
seq2 & 0x7FFFFFFF);
|
||||||
|
|
||||||
Net_LogPrintf ("QP: %u\n", MSG_ReadShort (&packet));
|
Net_LogPrintf ("QP: %u\n", MSG_ReadShort (&packet));
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (packet.badread)
|
if (packet.badread)
|
||||||
|
@ -912,14 +919,14 @@ Parse_Client_Packet (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Analyze_Client_Packet (const byte * data, int len)
|
Analyze_Client_Packet (const byte * data, int len, int has_sequence)
|
||||||
{
|
{
|
||||||
if (!Net_PacketLog)
|
if (!Net_PacketLog)
|
||||||
Net_PacketLog = _stdout;
|
Net_PacketLog = _stdout;
|
||||||
packet.message->data = (byte*)data;
|
packet.message->data = (byte*)data;
|
||||||
packet.message->cursize = len;
|
packet.message->cursize = len;
|
||||||
MSG_BeginReading (&packet);
|
MSG_BeginReading (&packet);
|
||||||
Parse_Client_Packet ();
|
Parse_Client_Packet (has_sequence);
|
||||||
if (Net_PacketLog == _stdout)
|
if (Net_PacketLog == _stdout)
|
||||||
Net_PacketLog = NULL;
|
Net_PacketLog = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1750,7 +1750,9 @@ SV_ReadPackets (void)
|
||||||
double until;
|
double until;
|
||||||
|
|
||||||
good = false;
|
good = false;
|
||||||
while (Netchan_GetPacket ()) {
|
while (NET_GetPacket ()) {
|
||||||
|
Log_Incoming_Packet(net_message->message->data,
|
||||||
|
net_message->message->cursize, 1);
|
||||||
if (SV_FilterIP (net_from.ip, &until)) {
|
if (SV_FilterIP (net_from.ip, &until)) {
|
||||||
SV_SendBan (until); // tell them we aren't listening...
|
SV_SendBan (until); // tell them we aren't listening...
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -848,17 +848,13 @@ SV_SendClientMessages (void)
|
||||||
// if the reliable message overflowed, drop the client
|
// if the reliable message overflowed, drop the client
|
||||||
if (c->netchan.message.overflowed) {
|
if (c->netchan.message.overflowed) {
|
||||||
int i;
|
int i;
|
||||||
byte *data = Hunk_TempAlloc (MAX_MSGLEN + 8);
|
|
||||||
|
|
||||||
memset (data, 0, 8);
|
Analyze_Server_Packet (c->netchan.message.data,
|
||||||
|
c->netchan.message.cursize, 0);
|
||||||
memcpy (data + 8, c->netchan.message.data,
|
|
||||||
c->netchan.message.cursize);
|
|
||||||
Analyze_Server_Packet (data, c->netchan.message.cursize + 8);
|
|
||||||
|
|
||||||
for (i = 0; i < c->num_backbuf; i++) {
|
for (i = 0; i < c->num_backbuf; i++) {
|
||||||
memcpy (data + 8, c->backbuf_data[i], c->backbuf_size[i]);
|
Analyze_Server_Packet (c->backbuf_data[i],
|
||||||
Analyze_Server_Packet (data, c->backbuf_size[i] + 8);
|
c->backbuf_size[i], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SZ_Clear (&c->netchan.message);
|
SZ_Clear (&c->netchan.message);
|
||||||
|
|
Loading…
Reference in a new issue