LumiSoft.Net.Dns.Client.Dns_Client.ParseSOARecord C# (CSharp) Method

ParseSOARecord() private method

private ParseSOARecord ( byte reply, int &offset, int rdLength, int ttl ) : SOA_Record
reply byte
offset int
rdLength int
ttl int
return SOA_Record
        private SOA_Record ParseSOARecord(byte[] reply,ref int offset,int rdLength,int ttl)
        {
            /* RFC 1035 3.3.13. SOA RDATA format

                +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
                /                     MNAME                     /
                /                                               /
                +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
                /                     RNAME                     /
                +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
                |                    SERIAL                     |
                |                                               |
                +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
                |                    REFRESH                    |
                |                                               |
                +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
                |                     RETRY                     |
                |                                               |
                +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
                |                    EXPIRE                     |
                |                                               |
                +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
                |                    MINIMUM                    |
                |                                               |
                +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

            where:

            MNAME           The <domain-name> of the name server that was the
                            original or primary source of data for this zone.

            RNAME           A <domain-name> which specifies the mailbox of the
                            person responsible for this zone.

            SERIAL          The unsigned 32 bit version number of the original copy
                            of the zone.  Zone transfers preserve this value.  This
                            value wraps and should be compared using sequence space
                            arithmetic.

            REFRESH         A 32 bit time interval before the zone should be
                            refreshed.

            RETRY           A 32 bit time interval that should elapse before a
                            failed refresh should be retried.

            EXPIRE          A 32 bit time value that specifies the upper limit on
                            the time interval that can elapse before the zone is no
                            longer authoritative.

            MINIMUM         The unsigned 32 bit minimum TTL field that should be
                            exported with any RR from this zone.
            */

            //---- Parse record -------------------------------------------------------------//
            // MNAME
            string nameserver = "";
            GetQName(reply,ref offset,ref nameserver);

            // RNAME
            string adminMailBox = "";
            GetQName(reply,ref offset,ref adminMailBox);
            char[] adminMailBoxAr = adminMailBox.ToCharArray();
            for(int i=0;i<adminMailBoxAr.Length;i++){
                if(adminMailBoxAr[i] == '.'){
                    adminMailBoxAr[i] = '@';
                    break;
                }
            }
            adminMailBox = new string(adminMailBoxAr);

            // SERIAL
            long serial = reply[offset++] << 24 | reply[offset++] << 16 | reply[offset++] << 8 | reply[offset++];

            // REFRESH
            long refresh = reply[offset++] << 24 | reply[offset++] << 16 | reply[offset++] << 8 | reply[offset++];

            // RETRY
            long retry = reply[offset++] << 24 | reply[offset++] << 16 | reply[offset++] << 8 | reply[offset++];

            // EXPIRE
            long expire = reply[offset++] << 24 | reply[offset++] << 16 | reply[offset++] << 8 | reply[offset++];

            // MINIMUM
            long minimum = reply[offset++] << 24 | reply[offset++] << 16 | reply[offset++] << 8 | reply[offset++];
            //--------------------------------------------------------------------------------//

            return new SOA_Record(nameserver,adminMailBox,serial,refresh,retry,expire,minimum,ttl);
        }