Example #1
0
        internal static ResourceRecord ReadFrom(PacketReader reader)
        {
            string name = reader.ReadName();
            RecordType type = (RecordType)reader.ReadUShort();
            RecordClass rClass = (RecordClass)reader.ReadUShort();
            DateTime expiry = DateTime.UtcNow + TimeSpan.FromSeconds(reader.ReadInt());

            switch (type)
            {
                case RecordType.Pointer:
                    return new PointerRecord(name, type, rClass, expiry, reader);

                case RecordType.CanonicalName:
                    return new CanonicalNameRecord(name, type, rClass, expiry, reader);

                case RecordType.Address:
                    return new IP4AddressRecord(name, type, rClass, expiry, reader);

                case RecordType.Text:
                    return new TextRecord(name, type, rClass, expiry, reader);

                case RecordType.Service:
                    return new ServiceRecord(name, type, rClass, expiry, reader);

                default:
                    int len = reader.ReadUShort();
                    reader.Position += len;
                    return new ResourceRecord(name, type, rClass, expiry);
            }
        }
Example #2
0
        internal static ResourceRecord ReadFrom(PacketReader reader)
        {
            string      name   = reader.ReadName();
            RecordType  type   = (RecordType)reader.ReadUShort();
            RecordClass rClass = (RecordClass)reader.ReadUShort();
            DateTime    expiry = DateTime.UtcNow + TimeSpan.FromSeconds(reader.ReadInt());

            switch (type)
            {
            case RecordType.Pointer:
                return(new PointerRecord(name, type, rClass, expiry, reader));

            case RecordType.CanonicalName:
                return(new CanonicalNameRecord(name, type, rClass, expiry, reader));

            case RecordType.Address:
                return(new IP4AddressRecord(name, type, rClass, expiry, reader));

            case RecordType.Text:
                return(new TextRecord(name, type, rClass, expiry, reader));

            case RecordType.Service:
                return(new ServiceRecord(name, type, rClass, expiry, reader));

            default:
                int len = reader.ReadUShort();
                reader.Position += len;
                return(new ResourceRecord(name, type, rClass, expiry));
            }
        }
Example #3
0
        internal PointerRecord(string name, RecordType type, RecordClass rClass, DateTime expiry, PacketReader reader)
            : base(name, type, rClass, expiry)
        {
            ushort dataLen = reader.ReadUShort();
            int    pos     = reader.Position;

            _targetName = reader.ReadName();

            reader.Position = pos + dataLen;
        }
Example #4
0
        internal PointerRecord(string name, RecordType type, RecordClass rClass, DateTime expiry, PacketReader reader)
            : base(name, type, rClass, expiry)
        {
            ushort dataLen = reader.ReadUShort();
            int pos = reader.Position;

            _targetName = reader.ReadName();

            reader.Position = pos + dataLen;
        }
Example #5
0
        internal ServiceRecord(string name, RecordType type, RecordClass rClass, DateTime expiry, PacketReader reader)
            : base(name, type, rClass, expiry)
        {
            ushort dataLen = reader.ReadUShort();
            int pos = reader.Position;

            _priority = reader.ReadUShort();
            _weight = reader.ReadUShort();
            _port = reader.ReadUShort();
            _target = reader.ReadName();

            reader.Position = pos + dataLen;
        }
        internal ServiceRecord(string name, RecordType type, RecordClass rClass, DateTime expiry, PacketReader reader)
            : base(name, type, rClass, expiry)
        {
            ushort dataLen = reader.ReadUShort();
            int    pos     = reader.Position;

            _priority = reader.ReadUShort();
            _weight   = reader.ReadUShort();
            _port     = reader.ReadUShort();
            _target   = reader.ReadName();

            reader.Position = pos + dataLen;
        }