From 1703cacaab91a980c96458f0f49284ab68168130 Mon Sep 17 00:00:00 2001
From: Dalien Talbot
Date: Thu, 13 Sep 2007 16:39:04 +0000
Subject: Added CLI "debug packet 0..255" to enable the in/out packet dumps
with various verbosity
---
OpenSim/Region/Application/OpenSimMain.cs | 58 ++++++++++++++++++++++
.../ClientStack/ClientView.ProcessPackets.cs | 7 ---
OpenSim/Region/ClientStack/ClientView.cs | 34 ++++++++++++-
OpenSim/Region/ClientStack/ClientViewBase.cs | 2 -
.../Region/Examples/SimpleApp/MyNpcCharacter.cs | 1 +
5 files changed, 92 insertions(+), 10 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index 9ac5117..8327e26 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -380,11 +380,20 @@ namespace OpenSim
{
switch (command)
{
+ case "debug":
+ if (cmdparams.Length > 0)
+ {
+ Debug(cmdparams);
+ }
+ break;
+
case "help":
m_log.Error("alert - send alert to a designated user or all users.");
m_log.Error(" alert [First] [Last] [Message] - send an alert to a user. Case sensitive.");
m_log.Error(" alert general [Message] - send an alert to all users.");
m_log.Error("backup - trigger a simulator backup");
+ m_log.Error("debug - debugging commands");
+ m_log.Error(" packet 0..255 - print incoming/outgoing packets (0=off)");
m_log.Error("load-xml [filename] - load prims from XML");
m_log.Error("save-xml [filename] - save prims to XML");
m_log.Error("script - manually trigger scripts? or script commands?");
@@ -555,6 +564,55 @@ namespace OpenSim
}
}
+ private void DebugPacket(int newDebug)
+ {
+ for (int i = 0; i < m_localScenes.Count; i++)
+ {
+ Scene scene = m_localScenes[i];
+ foreach (EntityBase entity in scene.Entities.Values)
+ {
+ if (entity is ScenePresence)
+ {
+ ScenePresence scenePrescence = entity as ScenePresence;
+ if (!scenePrescence.childAgent)
+ {
+ m_log.Error(String.Format("Packet debug for {0} {1} set to {2}",
+ scenePrescence.Firstname, scenePrescence.Lastname,
+ newDebug));
+ scenePrescence.ControllingClient.SetDebug(newDebug);
+ }
+ }
+ }
+ }
+ }
+ public void Debug(string[] args)
+ {
+ switch(args[0])
+ {
+ case "packet":
+ if (args.Length > 1)
+ {
+ int newDebug;
+ if (int.TryParse(args[1], out newDebug))
+ {
+ DebugPacket(newDebug);
+ }
+ else
+ {
+ m_log.Error("packet debug should be 0..2");
+ }
+ System.Console.WriteLine("New packet debug: " + newDebug.ToString());
+
+ }
+
+ break;
+ default:
+ m_log.Error("Unknown debug");
+ break;
+ }
+
+ }
+
///
/// Outputs to the console information about the region
///
diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
index d2f311b..fab5433 100644
--- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
+++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
@@ -62,13 +62,6 @@ namespace OpenSim.Region.ClientStack
protected override void ProcessInPacket(Packet Pack)
{
ack_pack(Pack);
- if (debug)
- {
- if (Pack.Type != PacketType.AgentUpdate)
- {
- Console.WriteLine(CircuitCode + ":IN: " + Pack.Type.ToString());
- }
- }
if (this.ProcessPacketMethod(Pack))
{
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index 4d7dbda..54c9a0d 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -70,7 +70,7 @@ namespace OpenSim.Region.ClientStack
//private AgentAssetUpload UploadAssets;
private LLUUID newAssetFolder = LLUUID.Zero;
- private bool debug = false;
+ private int debug = 0;
protected IScene m_scene;
private Dictionary m_clientThreads;
private AssetCache m_assetCache;
@@ -116,6 +116,11 @@ namespace OpenSim.Region.ClientStack
ClientThread.Start();
}
+ public void SetDebug(int newDebug)
+ {
+ debug = newDebug;
+ }
+
# region Client Methods
public void KillClient()
@@ -192,6 +197,31 @@ namespace OpenSim.Region.ClientStack
return result;
}
+ protected void DebugPacket(string direction, Packet packet)
+ {
+ if (debug > 0) {
+ string info;
+ if (debug < 255 && packet.Type == PacketType.AgentUpdate)
+ return;
+ if (debug < 254 && packet.Type == PacketType.ViewerEffect)
+ return;
+ if (debug < 253 && (
+ packet.Type == PacketType.CompletePingCheck ||
+ packet.Type == PacketType.StartPingCheck
+ ) )
+ return;
+ if (debug < 252 && packet.Type == PacketType.PacketAck)
+ return;
+
+ if (debug > 1) {
+ info = packet.ToString();
+ } else {
+ info = packet.Type.ToString();
+ }
+ Console.WriteLine(CircuitCode + ":" + direction + ": " + info);
+ }
+ }
+
protected virtual void ClientLoop()
{
MainLog.Instance.Verbose("OpenSimClient.cs:ClientLoop() - Entered loop");
@@ -205,11 +235,13 @@ namespace OpenSim.Region.ClientStack
{
packetsReceived++;
}
+ DebugPacket("IN", nextPacket.Packet);
ProcessInPacket(nextPacket.Packet);
}
else
{
//is a out going packet
+ DebugPacket("OUT", nextPacket.Packet);
ProcessOutPacket(nextPacket.Packet);
}
}
diff --git a/OpenSim/Region/ClientStack/ClientViewBase.cs b/OpenSim/Region/ClientStack/ClientViewBase.cs
index 8ff5a11..80d7e53 100644
--- a/OpenSim/Region/ClientStack/ClientViewBase.cs
+++ b/OpenSim/Region/ClientStack/ClientViewBase.cs
@@ -71,8 +71,6 @@ namespace OpenSim.Region.ClientStack
// Keep track of when this packet was sent out
Pack.TickCount = System.Environment.TickCount;
- // Console.WriteLine(CircuitCode + ":OUT: " + Pack.Type.ToString());
-
if (!Pack.Header.Resent)
{
// Set the sequence number
diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
index 7053c84..7e6101c 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
@@ -227,5 +227,6 @@ namespace SimpleApp
public void SendViewerTime(int phase) { }
public void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID) { }
+ public void SetDebug(int newDebug) { }
}
}
--
cgit v1.1