Decoder cleanups

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@439 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
axial
2006-10-30 04:42:22 +00:00
parent 398d083609
commit 4f83744730

View File

@@ -38,7 +38,7 @@ using libsecondlife.Packets;
class Decoder {
private static int BUFSIZE = 8096;
private static SecondLife client = new SecondLife();
private static SecondLife client = new SecondLife();
private static string grep = null;
private static byte[] data = new byte[BUFSIZE];
private static byte[] temp = new byte[BUFSIZE];
@@ -72,6 +72,9 @@ class Decoder {
public static void Main(string[] args) {
if (args.Length > 0) {
// FIXME
Console.WriteLine("sorry, filtering is currently broken :(");
return;
grep = String.Join(" ", args);
}
@@ -170,9 +173,7 @@ class Decoder {
} else
buf = data;
//Packet packet = new Packet(buf, pos, protocol);
// FIXME: Is this right? I haven't really looked at this code at all
Packet packet = Packet.BuildPacket(buf, ref pos);
Packet packet = Packet.BuildPacket(buf, ref pos);
if (grep != null) {
bool match = false;
@@ -217,7 +218,7 @@ class Decoder {
Console.WriteLine("{0,5} {1} {2}"
,packet.Header.Sequence
,InterpretOptions(packet.Header.Data[0])
,InterpretOptions(packet.Header)
,endpoints
);
Console.WriteLine(packet);
@@ -228,16 +229,15 @@ class Decoder {
Reset();
}
// FIXME: Would be much easier to pass packet.Header and use the existing properties
private static string InterpretOptions(byte options) {
private static string InterpretOptions(Header header) {
return "["
+ ((options & Helpers.MSG_APPENDED_ACKS) != 0 ? "Ack" : " ")
+ (header.AppendedAcks ? "Ack" : " ")
+ " "
+ ((options & Helpers.MSG_RESENT) != 0 ? "Res" : " ")
+ (header.Resent ? "Res" : " ")
+ " "
+ ((options & Helpers.MSG_RELIABLE) != 0 ? "Rel" : " ")
+ (header.Reliable ? "Rel" : " ")
+ " "
+ ((options & Helpers.MSG_ZEROCODED) != 0 ? "Zer" : " ")
+ (header.ZeroCoded ? "Zer" : " ")
+ "]"
;
}