Example #1
0
        internal EDns(EndianBinaryReader Reader)
        {
            this.Name          = DnsPacket.DecodeName(Reader);
            this.RecordType    = (RecordType)Reader.ReadUInt16(true);
            this.UdpSize       = Reader.ReadUInt16(true);
            this.ExtendedRCode = Reader.ReadByte();
            this.Version       = Reader.ReadByte();
            this.Flags         = (EDnsFlag)Reader.ReadUInt16(true);

            this.OptionLength = Reader.ReadUInt16();

            if (this.OptionLength > 0)
            {
                ArrayList OptionsTemp = new ArrayList();

                UInt16 BytesRemaining = this.OptionLength;
                do
                {
                    EDnsOption Option = new EDnsOption(Reader);
                    BytesRemaining -= (UInt16)(Option.OptionLength + 4);

                    OptionsTemp.Add(Option);
                } while (BytesRemaining > 0);
                this.Options = (EDnsOption[])OptionsTemp.ToArray(typeof(EDnsOption));
            }
        }
Example #2
0
 internal void UpdateProperties(EndianBinaryReader Reader)
 {
     this.Name        = DnsPacket.DecodeName(Reader);
     this.RecordType  = (RecordType)Reader.ReadUInt16(true);
     this.RecordClass = (RecordClass)Reader.ReadUInt16(true);
     this.TTL         = Reader.ReadUInt32(true);
     this.RDataLength = Reader.ReadUInt16(true);
 }
Example #3
0
        internal PTR(EndianBinaryReader Reader)
        {
            base.UpdateProperties(Reader);

            Hostname = DnsPacket.DecodeName(Reader);

            base.RecordData = Hostname;
        }
Example #4
0
        internal NSAP(EndianBinaryReader Reader)
        {
            base.UpdateProperties(Reader);

            DName = DnsPacket.DecodeName(Reader);

            base.RecordData = DName;
        }
Example #5
0
        internal MG(EndianBinaryReader Reader)
        {
            base.UpdateProperties(Reader);

            MailboxName = DnsPacket.DecodeName(Reader);

            base.RecordData = MailboxName.ToString();
        }
Example #6
0
        internal RT(EndianBinaryReader Reader)
        {
            base.UpdateProperties(Reader);

            Preference = Reader.ReadUInt16(true);
            TargetName = DnsPacket.DecodeName(Reader);

            base.RecordData = String.Format("{0} {1}", Preference, TargetName);
        }
Example #7
0
        internal MINFO(EndianBinaryReader Reader)
        {
            base.UpdateProperties(Reader);

            ResponsibleMailbox = DnsPacket.DecodeName(Reader);
            ErrorMailbox       = DnsPacket.DecodeName(Reader);

            base.RecordData = String.Format("{0} {1}", ResponsibleMailbox, ErrorMailbox);
        }
Example #8
0
        internal RP(EndianBinaryReader Reader)
        {
            base.UpdateProperties(Reader);

            ResponsibleMailbox = DnsPacket.DecodeName(Reader);
            TXTDomainName      = DnsPacket.DecodeName(Reader);

            base.RecordData = String.Format("{0} {1}", ResponsibleMailbox, TXTDomainName);
        }
Example #9
0
        internal AFSDB(EndianBinaryReader Reader)
        {
            base.UpdateProperties(Reader);

            SubType = Reader.ReadUInt16(true);
            if (Enum.IsDefined(typeof(AFSDBSubType), SubType))
            {
                SubTypeName = (AFSDBSubType)SubType;
            }
            TargetName = DnsPacket.DecodeName(Reader);

            base.RecordData = String.Format("{0} {1}", SubType, TargetName);
        }
Example #10
0
        internal SRV(EndianBinaryReader Reader)
        {
            base.UpdateProperties(Reader);

            Priority   = Reader.ReadUInt16(true);
            Weight     = Reader.ReadUInt16(true);
            Port       = Reader.ReadUInt16(true);
            TargetName = DnsPacket.DecodeName(Reader);

            base.RecordData = String.Format("{0} {1} {2} {3}",
                                            Priority,
                                            Weight,
                                            Port,
                                            TargetName);
        }
Example #11
0
        internal SOA(EndianBinaryReader Reader)
        {
            base.UpdateProperties(Reader);

            TargetName        = DnsPacket.DecodeName(Reader);
            ResponsiblePerson = DnsPacket.DecodeName(Reader);
            Serial            = Reader.ReadUInt32(true);
            Refresh           = Reader.ReadUInt32(true);
            Retry             = Reader.ReadUInt32(true);
            Expire            = Reader.ReadUInt32(true);
            MinimumTTL        = Reader.ReadUInt32(true);

            base.RecordData = String.Format("{0} {1} {2} {3} {4} {5} {6}",
                                            TargetName,
                                            ResponsiblePerson,
                                            Serial,
                                            Refresh,
                                            Retry,
                                            Expire,
                                            MinimumTTL);
        }
Example #12
0
        internal WINSR(EndianBinaryReader Reader)
        {
            base.UpdateProperties(Reader);

            MappingFlag   = (WINSMappingFlag)Reader.ReadUInt32(true);
            LookupTimeout = Reader.ReadUInt32(true);
            CacheTimeout  = Reader.ReadUInt32(true);

            ResultDomain = DnsPacket.DecodeName(Reader);

            String RecordData = String.Format("L{0} C{1} ( {2} )",
                                              LookupTimeout,
                                              CacheTimeout,
                                              ResultDomain);

            if (MappingFlag == WINSMappingFlag.NoReplication)
            {
                RecordData = "LOCAL " + RecordData;
            }

            base.RecordData = RecordData;
        }
Example #13
0
        // Private Methods

        private ResourceRecord ResourceRecord(EndianBinaryReader Reader)
        {
            Int64      Position   = Reader.BaseStream.Position;
            String     Name       = DnsPacket.DecodeName(Reader);
            RecordType RecordType = (RecordType)Reader.ReadUInt16(true);

            if (RecordType == RecordType.OPT)
            {
                Reader.BaseStream.Seek(Position, SeekOrigin.Begin);
                this.EDns = new EDns(Reader);
                return(null);
            }
            else
            {
                RecordClass RecordClass = (RecordClass)Reader.ReadUInt16(true);
                UInt32      TTL         = Reader.ReadUInt32(true);
                UInt16      RDataLength = Reader.ReadUInt16(true);
                Reader.BaseStream.Seek(Position, SeekOrigin.Begin);

                Object RData = new Object();
                switch (RecordType)
                {
                case RecordType.A: RData = new A(Reader); break;      // Tested

                case RecordType.NS: RData = new NS(Reader); break;    // Tested

                case RecordType.MD: RData = new MD(Reader); break;

                case RecordType.MF: RData = new MF(Reader); break;

                case RecordType.CNAME: RData = new CNAME(Reader); break; // Tested

                case RecordType.SOA: RData = new SOA(Reader); break;     // Tested

                case RecordType.MB: RData = new MB(Reader); break;       // Tested

                case RecordType.MG: RData = new MG(Reader); break;

                case RecordType.MR: RData = new MR(Reader); break;

                case RecordType.NULL: RData = new NULL(Reader, RDataLength); break;

                case RecordType.WKS: RData = new WKS(Reader, RDataLength); break;

                case RecordType.PTR: RData = new PTR(Reader); break;     // Tested

                case RecordType.HINFO: RData = new HINFO(Reader); break; // Tested

                case RecordType.MINFO: RData = new MINFO(Reader); break;

                case RecordType.MX: RData = new MX(Reader); break;     // Tested

                case RecordType.TXT: RData = new TXT(Reader); break;   // Tested

                case RecordType.RP: RData = new RP(Reader); break;

                case RecordType.AFSDB: RData = new AFSDB(Reader); break;     // Tested

                case RecordType.X25: RData = new X25(Reader); break;

                case RecordType.ISDN: RData = new ISDN(Reader); break;

                case RecordType.RT: RData = new RT(Reader); break;

                case RecordType.NSAP: RData = new NSAP(Reader); break;

                case RecordType.AAAA: RData = new AAAA(Reader); break;              // Tested

                case RecordType.SRV: RData = new SRV(Reader); break;                // Tested

                case RecordType.ATMA: RData = new ATMA(Reader, RDataLength); break; // Tested

                case RecordType.WINS: RData = new WINS(Reader); break;              // Tested

                case RecordType.WINSR: RData = new WINSR(Reader); break;            // Tested

                default: RData = Reader.ReadBytes(RDataLength); break;
                }

                return((ResourceRecord)RData);
            }
        }
Example #14
0
 internal Question(EndianBinaryReader Response)
 {
     this.Name        = DnsPacket.DecodeName(Response);
     this.RecordType  = (RecordType)(Response.ReadUInt16(true));
     this.RecordClass = (RecordClass)(Response.ReadUInt16(true));
 }
Example #15
0
 internal CNAME(EndianBinaryReader Reader)
 {
     base.UpdateProperties(Reader);
     Hostname        = DnsPacket.DecodeName(Reader);
     base.RecordData = Hostname.ToString();
 }