/* * Attempt to analyse */ public PyRep analyse(PyRep obj, string filename) { if (obj.Type == PyObjectType.ObjectData) { eveMarshal.PyObject packetData = obj as eveMarshal.PyObject; try { return(new PyPacket(packetData)); } catch (InvalidDataException e) { addText(filename + Environment.NewLine); addText("Packet Decode failed: " + e.Message + Environment.NewLine); return(obj); } } return(obj); }
public PyAddress(PyRep args) : base(PyObjectType.Address) { if (args.Type != PyObjectType.ObjectData) { throw new InvalidDataException("PyAddress: Incorrect object type expected ObjectData got " + args.Type.ToString() + "."); } PyObject data = args as PyObject; if (data.Name != "carbon.common.script.net.machoNetAddress.MachoAddress") { throw new InvalidDataException("PyAddress: Unrecognized address name got " + data.Name + "."); } if (data.Arguments.Type != PyObjectType.Tuple) { throw new InvalidDataException("PyAddress: Address contents expected Tuple got " + data.Arguments.Type.ToString() + "."); } PyTuple tuple = data.Arguments as PyTuple; if (tuple.Items.Count < 3) { throw new InvalidDataException("PyAddress: Incorrect tupple size requires at least 3 got " + tuple.Items.Count + "."); } if (tuple.Items[0].Type != PyObjectType.Int) { throw new InvalidDataException("PyAddress: Address type expected Int got " + data.Arguments.Type.ToString() + "."); } addrType = (PyAddressType)tuple.Items[0].IntValue; if (addrType != PyAddressType.Any && tuple.Items.Count != 4) { throw new InvalidDataException("PyAddress: Incorrect tupple size requires 4 got " + tuple.Items.Count + "."); } switch (addrType) { case PyAddressType.Any: service = tuple.Items[1].StringValue; callID = tuple.Items[2].IntValue; break; case PyAddressType.Node: addrID = tuple.Items[1].IntValue; service = tuple.Items[2].StringValue; callID = tuple.Items[3].IntValue; break; case PyAddressType.Client: addrID = tuple.Items[1].IntValue; callID = tuple.Items[2].IntValue; service = tuple.Items[3].StringValue; break; case PyAddressType.Broadcast: service = tuple.Items[1].StringValue; broadcastType = tuple.Items[3].StringValue; break; default: throw new InvalidDataException("PyAddress: Unknown address type got " + addrType + "."); } RawOffset = args.RawOffset; RawSource = args.RawSource; }