Ejemplo n.º 1
0
        public PyPacket(PyObject packetData)
            : base(PyObjectType.Packet)
        {
            if (!packetData.Name.StartsWith("carbon.common.script.net.machoNetPacket."))
            {
                // This is not a valid addressed packet.
                throw new InvalidDataException("PyPacket: Invalid typeString.");
            }
            typeString = packetData.Name;
            if (packetData.Arguments.Type != PyObjectType.Tuple)
            {
                // This is not a valid addressed packet.
                throw new InvalidDataException("PyPacket: Arguments not a Tuple.");
            }
            PyTuple args = packetData.Arguments as PyTuple;

            if (args.Items.Count != 9)
            {
                // This is not a correct size packet.
                throw new InvalidDataException("PyPacket: Expected Tuple size 9 got " + args.Items.Count + ".");
            }
            if (args.Items[0].Type != PyObjectType.Int)
            {
                // Incorrect packet type identifier.
                throw new InvalidDataException("PyPacket: Packet Type identifier.");
            }
            packetType = args.Items[0].IntValue;
            source     = new PyAddress(args.Items[1]);
            dest       = new PyAddress(args.Items[2]);
            userID     = 0;
            if (args.Items[3].Type == PyObjectType.Int)
            {
                userID = args.Items[3].IntValue;
            }
            else if (args.Items[3].Type != PyObjectType.None)
            {
                throw new InvalidDataException("PyPacket: UserID expected Int or None got " + args.Items[3].Type.ToString() + ".");
            }
            payload      = args.Items[4];
            namedPayload = args.Items[5];
            if (payload.Type != PyObjectType.Tuple && payload.Type != PyObjectType.Buffer)
            {
                throw new InvalidDataException("PyPacket: payload expected Tuple or Buffer got " + args.Items[3].Type.ToString() + ".");
            }
            if (namedPayload.Type != PyObjectType.None && namedPayload.Type != PyObjectType.Dict)
            {
                throw new InvalidDataException("PyPacket: named payload expected Dict or None got " + args.Items[3].Type.ToString() + ".");
            }
            RawOffset = args.RawOffset;
            RawSource = args.RawSource;
            try
            {
                if (typeString.EndsWith(".SessionChangeNotification"))
                {
                    payload = new SessionChangeNotification(payload as PyTuple);
                }
                else if (typeString.EndsWith(".CallRsp"))
                {
                    payload = new CallRsp(payload as PyTuple);
                }
                else if (typeString.EndsWith(".CallReq"))
                {
                    payload = new PyCallStream(payload as PyTuple);
                }
                else if (typeString.EndsWith(".ErrorResponse"))
                {
                    payload = new ErrorResponse(payload as PyTuple);
                }
                else if (typeString.EndsWith(".Notification"))
                {
                    payload = new NotificationStream(payload as PyTuple);
                }
            }
            catch (InvalidDataException e)
            {
                throw new InvalidDataException("PyPacket: Extended decode failed: " + e.Message, e);
            }
        }
Ejemplo n.º 2
0
        private PyRep analyseType2(PyObjectEx obj, out bool usedList, out bool usedDict)
        {
            usedDict = false;
            usedList = false;
            // type 2
            PyTuple headerTuple = obj.Header as PyTuple;

            if (headerTuple != null && headerTuple.Items.Count > 1)
            {
                int     headerCount = headerTuple.Items.Count;
                PyDict  dict        = headerTuple.Items[1] as PyDict;
                PyToken token       = null;
                PyTuple tokenTuple  = headerTuple.Items[0] as PyTuple;
                if (tokenTuple != null && tokenTuple.Items.Count == 1)
                {
                    token = tokenTuple.Items[0] as PyToken;
                }
                if (token != null)
                {
                    if (headerCount != 2)
                    {
                        unknown.AppendLine("PyObjectEx Type2: headerCount=" + headerCount + " token: " + token.Token);
                    }
                    if (headerCount == 2 && token.Token == "carbon.common.script.sys.crowset.CRowset")
                    {
                        usedList = true;
                        if (dict.Dictionary.Count > 1)
                        {
                            unknown.AppendLine("PyObjectEx Type2: Extra parameters in dict for CRowset");
                        }
                        return(new CRowSet(dict, obj.List));
                    }
                    if (headerCount == 2 && token.Token == "carbon.common.script.sys.crowset.CIndexedRowset")
                    {
                        usedDict = true;
                        if (dict.Dictionary.Count > 2)
                        {
                            unknown.AppendLine("PyObjectEx Type2: Extra parameters in dict for CIndexedRowset");
                        }
                        return(new CIndexedRowset(dict, obj.Dictionary));
                    }
                    if (token.Token == "eve.common.script.dogma.effect.BrainEffect")
                    {
                        return(obj);
                    }
                    if (token.Token == "industry.job.Location")
                    {
                        return(obj);
                    }
                    if (token.Token == "eve.common.script.sys.rowset.RowDict")
                    {
                        return(obj);
                    }
                    if (token.Token == "carbon.common.script.sys.crowset.CFilterRowset")
                    {
                        return(obj);
                    }
                    if (token.Token == "eve.common.script.sys.rowset.RowList")
                    {
                        return(obj);
                    }
                    if (token.Token == "eve.common.script.util.pagedCollection.PagedResultSet")
                    {
                        return(obj);
                    }
                    if (token.Token == "shipskins.storage.LicensedSkin")
                    {
                        return(obj);
                    }
                    if (token.Token == "seasons.common.challenge.Challenge")
                    {
                        return(obj);
                    }
                    unknown.AppendLine("Unknown Token type 2: " + token.Token);
                }
            }
            return(obj);
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        private PyRep analyseType1(PyObjectEx obj, out bool usedList, out bool usedDict)
        {
            usedDict = false;
            usedList = false;
            // Type1
            PyTuple headerTuple = obj.Header as PyTuple;

            if (headerTuple != null && headerTuple.Items.Count > 1)
            {
                int     headerCount = headerTuple.Items.Count;
                PyToken token       = headerTuple.Items[0] as PyToken;
                if (token != null)
                {
                    PyTuple tuple1      = null;
                    int     tuple1Count = 0;
                    if (headerCount > 1)
                    {
                        tuple1 = headerTuple.Items[1] as PyTuple;
                        if (tuple1 != null)
                        {
                            if (headerCount == 3 && token.Token == "eveexceptions.UserError")
                            {
                                return(new UserError(tuple1, headerTuple.Items[2] as PyDict));
                            }
                            tuple1Count = tuple1.Items.Count;
                            if (tuple1Count == 0)
                            {
                                if (headerCount == 3 && token.Token == "carbon.common.script.net.machoNetExceptions.WrongMachoNode")
                                {
                                    return(new WrongMachoNode(headerTuple.Items[2] as PyDict));
                                }
                            }
                            if (tuple1Count == 1)
                            {
                                if (token.Token == "blue.DBRowDescriptor")
                                {
                                    return(new DBRowDescriptor(headerTuple));
                                }
                                PyRep item1 = tuple1.Items[0];
                                if (item1 != null)
                                {
                                    if (token.Token == "__builtin__.set")
                                    {
                                        return(new BuiltinSet(item1 as PyList));
                                    }
                                    if (headerCount == 2 && token.Token == "collections.defaultdict")
                                    {
                                        PyToken tupleToken = item1 as PyToken;
                                        if (tupleToken.Token == "__builtin__.set")
                                        {
                                            usedDict = true;
                                            return(new DefaultDict(obj.Dictionary));
                                        }
                                    }
                                    if (token.Token == "carbon.common.script.net.objectCaching.CacheOK")
                                    {
                                        if (item1.StringValue == "CacheOK")
                                        {
                                            return(new CacheOK());
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (token.Token == "carbon.common.script.net.GPSExceptions.GPSTransportClosed")
                    {
                        return(obj);
                    }
                    unknown.AppendLine("Unknown or malformed token: " + token.Token);
                }
            }
            return(obj);
        }