Added CLI "debug packet 0..255" to enable the in/out packet dumps with various verbosity

afrisby
Dalien Talbot 2007-09-13 16:39:04 +00:00
parent 23b8e39c1b
commit 1703cacaab
7 changed files with 94 additions and 10 deletions

View File

@ -240,5 +240,6 @@ namespace OpenSim.Framework.Interfaces
void SendViewerTime(int phase);
void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID);
void SetDebug(int newDebug);
}
}

View File

@ -166,6 +166,7 @@ namespace OpenSim.Framework
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) { }
}
}

View File

@ -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;
}
}
/// <summary>
/// Outputs to the console information about the region
/// </summary>

View File

@ -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))
{

View File

@ -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<uint, ClientView> 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);
}
}

View File

@ -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

View File

@ -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) { }
}
}