Commit 7156a533 authored by tepelmann's avatar tepelmann
Browse files

Added DNS types.

parent 43d45343
Loading
Loading
Loading
Loading
+204 −0
Original line number Diff line number Diff line
/**
 *  @author   STF 440
 *  @version  $Id$
 *  @desc     This module defines DNS messages.
 *            DNS structures have been defined on the basis of RFC 1035
 *            Also it provides some useful constant definitions.
 *  @url      http://www.ietf.org/rfc/rfc1035.txt
 *  
 */
 module AtsCommon_DNS_CommonRfcs_TypesAndValues {
  
  //LibCommon
  import from LibCommon_BasicTypesAndValues all;
  import from LibCommon_DataStrings all;
  
  //AtsDSLite
  import from AtsCommon_DNS_Rfc1035_TypesAndValues all;
  import from AtsCommon_DNS_Rfc3596_TypesAndValues all;
  
  group dnsConstants {
    
    //UDPports
    const UInt16 c_dnsServerPort := 53;
    
  } // end dnsConstants
  
  /**
   * @desc Domain Name System Message
   * @reference http://tools.ietf.org/html/rfc1035 cl. 4.1
  */  
  type record DnsMsg {
    DnsHeader header,
    DnsData   data
  }
  
  group header {
    
    type record DnsHeader {
      UInt16 transactionId,
      Flags  flags,
      UInt16 questionsCount,
      UInt16 answerRRs,
      UInt16 nameServerRRs,
      UInt16 additionalRRs
    }
    
    type record Flags {
      Bit1   qr,
      OpCode opCode,
      Bit1   authoritativeAnswer,
      Bit1   truncation,
      Bit1   recursionDesired,
      Bit1   recursionAvailable,
      Bit3   z,
      RCode  rCode
    }
    
      /**
       * @desc Operation Codes
       * @reference http://tools.ietf.org/html/rfc1035 cl.4.1.1
       */
      type enumerated OpCode {
        e_QUERY (0),
        e_IQUERY (1),
        e_STATUS (2),
        e_reserved
      }
      with {
      variant "unsigned 4 bits"
    }
    
    /**
     * @desc Response Codes
     * @reference http://tools.ietf.org/html/rfc1035 cl.4.1.1
     */
    type enumerated RCode {
      e_noError (0),
      e_formatError (1),
      e_serverFailure (2),
      e_nameError (3),
      e_notImplemented (4),
      e_refused (5),
      e_reserved
    }
    with {
      variant "unsigned 4 bits"
    }
    
  } // end header
  
  group data {
    
    type record DnsData {
      Questions       questions optional,
      ResourceRecords answerRRs optional,
      ResourceRecords authorityRRs optional,
      ResourceRecords additionalRRs optional
    }
    
    group commonData {
      
      type enumerated RRType {
        e_A (1),       // a host address
        e_NS (2),      // an authoritative name server
        e_CNAME (5),   // the canonical name for an alias
        e_SOA (6),     // marks the start of a zone of authority
        e_WKS (11),    // a well known service description
        e_PTR (12),    // a domain name pointer
        e_HINFO (13),  // host information
        e_MINFO (14),  // mailbox or mail list information
        e_MX (15),     // mail exchange
        e_TXT (16),    // text strings
        e_AXFR (252),  // a request for a transfer of an entire zone (ONLY for Questions)
        e_ANY (255),   // a request for all records (ONLY for Questions)
        // RFC 3596
        e_AAAA (28),   // IPv6 address
        e_reserved
      }
      with {
        variant "unsigned bits 16";
      }
      
      type enumerated Class {
        e_IN (1),
        e_CS (2),
        e_CH (3),
        e_HS (4),
        e_ANY (255),
        e_reserved
      }
      with {
        variant "unsigned bits 16"
      }
      
    } // end commonData
    
    group questions {
      
      type set of Question Questions;
      
      type record Question {
        DomainName name,
        RRType     rrType,
        Class      class
      }
      
    } // end questions
    
    group resourceRecords {
      
      type set of ResourceRecord ResourceRecords;
      
      type record ResourceRecord {
        DomainName      name,
        RRType          rrType,
        Class           class,
        TimeStamp       ttl,
        UInt16          rdLength,
        ResourceData    rdData optional
      }
      
      type union ResourceData {
        CName               cName,
        HInfo               hInfo,
        MX                  mx,
        NS                  ns,
        PTR                 ptr,
        SOA                 soa,
        TXT                 txt,
        Aaddress            aAddress,
        WellKnowServices    wks,
        AAAAaddress         aaaaAddress,
        // raw data
        octetstring         data
      }
      
    } // end resourceRecords
    
  } // end data
  
  group auxilary {
    
    /**
     * @desc A unsigned 32bit timestamp
     */
    type UInt32 TimeStamp;
    
    /**
     * @desc Fully qualified domain name
     * Example encoding for www.example.com:
     * 
     * +------+------+------+------+------+------+------+------+------+
     * | 0x03 |   w  |   w  |   w  | 0x07 |   e  |   x  |   a  |   m  |
     * +------+------+------+------+------+------+------+------+------+
     * |   p  |   l  |   e  | 0x03 |   c  |   o  |   m  | 0x00 |
     * +------+------+------+------+------+------+------+------+
     * 
     * @reference http://tools.ietf.org/html/rfc1035 cl.3.1
     */
    type charstring DomainName;
    
  } // end auxilary
  
} // end AtsCommon_DNS_CommonRfcs_TypesAndValues
+67 −0
Original line number Diff line number Diff line
/**
 *  @author   STF 440
 *  @version  $Id$
 *  @desc     This module adds definition from RFC 3596.
 *  @url      http://www.ietf.org/rfc/rfc3596.txt
 *  
 */
 module AtsCommon_DNS_Rfc1035_TypesAndValues {
  
  //LibCommon
  import from LibCommon_BasicTypesAndValues all;
  import from LibCommon_DataStrings all;
  
  //AtsDSLite
  import from AtsCommon_DNS_CommonRfcs_TypesAndValues all;
  
  group data {
    
    group resourceRecords {
      
      type DomainName CName;
      
      type record HInfo {
        charstring cpu,
        charstring os
      }
      
      type record MX {
        UInt16      preference,
        DomainName  exchange
      }
      
      type DomainName NS;
      
      type DomainName PTR;
      
      type record SOA {
        DomainName  mName,
        DomainName  rName,
        UInt32      serial,
        TimeStamp   refresh,
        TimeStamp   retry,
        TimeStamp   expire,
        TimeStamp   minimumTTL
      }
      
      type charstring Text;
      
      type set of Text TXT;
      
      /**
       * @desc IPv4 address
       * @remark Will be encoded as 32bit Internet address.
       */
      type charstring Aaddress;
      
      type record WellKnowServices {
        Aaddress    aaAddress,
        UInt8       protocol,
        bitstring   bitMap
      }
      
    } // end resourceRecords
    
  } // end data
  
} // end AtsCommon_DNS_Rfc1035_TypesAndValues
+30 −0
Original line number Diff line number Diff line
/**
 *  @author   STF 440
 *  @version   $Id$
 *  @desc     This module adds definition from RFC 3596.
 *  @url        http://www.ietf.org/rfc/rfc3596.txt
 *  
 */
 module AtsCommon_DNS_Rfc3596_TypesAndValues {
  
  //LibIpv6
  import from LibIpv6_CommonRfcs_TypesAndValues all;

  //AtsDSLite
  import from AtsCommon_DNS_CommonRfcs_TypesAndValues all;
  
  group data {
    
    group resourceRecords {
      
      /**
       * @desc IPv6 address
       * @remark Will be encoded as 128bit Internet address.
       */
      type Ipv6Address AAAAaddress;
      
    } // end resourceRecords
    
  } // end data
  
} // end AtsCommon_DNS_Rfc3596_TypesAndValues