diff --git a/applications/Decoder/Decoder.cs b/applications/Decoder/Decoder.cs index 163c9352..9410a6bb 100644 --- a/applications/Decoder/Decoder.cs +++ b/applications/Decoder/Decoder.cs @@ -32,12 +32,14 @@ using System.Globalization; using System.IO; using System.Text.RegularExpressions; -using libsecondlife; +using libsecondlife; +using libsecondlife.Packets; class Decoder { - private static int BUFSIZE = 8096; - - private static ProtocolManager protocol = new SecondLife("keywords.txt", "message_template.msg").Protocol; + private static int BUFSIZE = 8096; + + private static SecondLife client = new SecondLife(); + private static ProtocolManager protocol = new ProtocolManager("keywords.txt", "message_template.msg", client); private static string grep = null; private static byte[] data = new byte[BUFSIZE]; private static byte[] temp = new byte[BUFSIZE]; @@ -169,34 +171,45 @@ class Decoder { } else buf = data; - Packet packet = new Packet(buf, pos, protocol); + //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); if (grep != null) { - bool match = false; - foreach (Block block in packet.Blocks()) - foreach (Field field in block.Fields) { - string value; - if (field.Layout.Type == FieldType.Variable) - value = DataConvert.toChoppedString(field.Data); - else - value = field.Data.ToString(); - if (Regex.Match(packet.Layout.Name + "." + block.Layout.Name + "." + field.Layout.Name + " = " + value, grep, RegexOptions.IgnoreCase).Success) { - match = true; - break; - } + bool match = false; + + //FIXME: This needs to be updated for the new libsecondlife API + //foreach (Block block in packet.Blocks()) + //{ + // foreach (Field field in block.Fields) + // { + // string value; + // if (field.Layout.Type == FieldType.Variable) + // value = DataConvert.toChoppedString(field.Data); + // else + // value = field.Data.ToString(); + // if (Regex.Match(packet.Layout.Name + "." + block.Layout.Name + "." + field.Layout.Name + " = " + value, grep, RegexOptions.IgnoreCase).Success) + // { + // match = true; + // break; + // } + + // // try matching variable fields in 0x notation + // if (field.Layout.Type == FieldType.Variable) + // { + // StringWriter sw = new StringWriter(); + // sw.Write("0x"); + // foreach (byte b in (byte[])field.Data) + // sw.Write("{0:x2}", b); + // if (Regex.Match(packet.Layout.Name + "." + block.Layout.Name + "." + field.Layout.Name + " = " + sw, grep, RegexOptions.IgnoreCase).Success) + // { + // match = true; + // break; + // } + // } + // } + //} - // try matching variable fields in 0x notation - if (field.Layout.Type == FieldType.Variable) { - StringWriter sw = new StringWriter(); - sw.Write("0x"); - foreach (byte b in (byte[])field.Data) - sw.Write("{0:x2}", b); - if (Regex.Match(packet.Layout.Name + "." + block.Layout.Name + "." + field.Layout.Name + " = " + sw, grep, RegexOptions.IgnoreCase).Success) { - match = true; - break; - } - } - } if (!match) { Reset(); return; @@ -204,8 +217,8 @@ class Decoder { } Console.WriteLine("{0,5} {1} {2}" - ,packet.Sequence - ,InterpretOptions(packet.Data[0]) + ,packet.Header.Sequence + ,InterpretOptions(packet.Header.Data[0]) ,endpoints ); Console.WriteLine(packet); @@ -216,6 +229,7 @@ class Decoder { Reset(); } + // FIXME: Would be much easier to pass packet.Header and use the existing properties private static string InterpretOptions(byte options) { return "[" + ((options & Helpers.MSG_APPENDED_ACKS) != 0 ? "Ack" : " ") diff --git a/applications/Decoder/Decoder.csproj b/applications/Decoder/Decoder.csproj new file mode 100644 index 00000000..830cd346 --- /dev/null +++ b/applications/Decoder/Decoder.csproj @@ -0,0 +1,56 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {7AE16AC1-E64C-4FDC-9B85-4BB6145D511C} + Exe + Properties + Decoder + Decoder + Decoder + + + true + full + false + ..\..\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + libsecondlife + + + + + + + + + + + \ No newline at end of file diff --git a/libsecondlife-cs/libsecondlife.sln b/libsecondlife-cs/libsecondlife.sln index 5290c0fd..75e23364 100644 --- a/libsecondlife-cs/libsecondlife.sln +++ b/libsecondlife-cs/libsecondlife.sln @@ -32,6 +32,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IA_NotecardTool", "examples EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Teleport", "examples\Teleport\Teleport.csproj", "{B5AC6795-E426-4BC3-950F-D7B2970E2394}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decoder", "..\applications\Decoder\Decoder.csproj", "{7AE16AC1-E64C-4FDC-9B85-4BB6145D511C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -102,6 +104,10 @@ Global {B5AC6795-E426-4BC3-950F-D7B2970E2394}.Debug|Any CPU.Build.0 = Debug|Any CPU {B5AC6795-E426-4BC3-950F-D7B2970E2394}.Release|Any CPU.ActiveCfg = Release|Any CPU {B5AC6795-E426-4BC3-950F-D7B2970E2394}.Release|Any CPU.Build.0 = Release|Any CPU + {7AE16AC1-E64C-4FDC-9B85-4BB6145D511C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7AE16AC1-E64C-4FDC-9B85-4BB6145D511C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7AE16AC1-E64C-4FDC-9B85-4BB6145D511C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7AE16AC1-E64C-4FDC-9B85-4BB6145D511C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE