Commit 81bda383 authored by tepelmann's avatar tepelmann
Browse files

Initial DHCPv4.

parent d983c9ec
Loading
Loading
Loading
Loading
+121 −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 2131
 *            Also it provides some useful constant definitions.
 *  @url      http://www.ietf.org/rfc/rfc2131.txt
 *  
 */
 module AtsCommon_Dhcpv4_CommonRfcs_TypesAndValues {
  
  //LibCommon
  import from LibCommon_BasicTypesAndValues all;
  import from LibCommon_DataStrings all;
  
  //AtsCommon
  import from AtsCommon_Dhcpv4_Rfc1533_TypesAndValues all;
  import from AtsCommon_Dhcpv4_Rfc5969_TypesAndValues all;
  
  group dnsConstants {
    
    //UDPports
    const UInt16 c_dnsServerPort := 53;
    
  } // end dnsConstants
  
  /**
   * @desc Dynamic Host Configuration Protocol Message with BOOTP header
   * @reference http://tools.ietf.org/html/rfc2131 cl. 2
  */  
  type record Dhcpv4Msg {
      BootpHeader   bootpHeader,
      Oct4          magicCookie('63825363'O), //DHCP
      DHCPv4Options options
  }
  
  type charstring Ipv4Address (pattern "[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+");
  
  group bootpHeader {
      
      type record BootpHeader {
          BootpOpCode   op,
          UInt8         htype,
          UInt8         hlen,
          UInt8         hops,
          Oct4          xid,
          UInt16        secs,
          BootpFlags    flags,
          Ipv4Address   ciaddr,
          Ipv4Address   yiaddr,
          Ipv4Address   siaddr,
          Ipv4Address   giaddr,
          Oct16         chaddr,
          charstring    sname length(0..64), //null terminated string with fixed 64 characters, not given ==  64 x '\0'
          charstring    file length(0..128) //null terminated string with fixed 128 characters, not given == 128 x '\0'
      }
      
      type enumerated BootpOpCode {
          e_BOOTREQUEST(1),
          e_BOOTREPLY(2)
      }
      
      type record BootpFlags {
          Bit1  broadcast,
          Bit7  reserved
      }
      
  } // end bootpHeader
  
  group dhcpOptions {
    
    /**
     * @desc DHCP Option in raw format - any option code, data as plain octetstring
     * @reference http://tools.ietf.org/html/rfc1533#section-9
     */
    type record DHCPv4OptionRaw {
      UInt8            optionCode,
      UInt16           optionLen,
      octetstring      optionData
    }
    
    /**
     * @desc Collection of option datas defined in several RFCs.
     */
    type union DHCPv4Option {
      //RFC 1533
      PadOption                 pad,
      EndOption                 end,
      DHCPMessageTypeOption     dhcpMessageType,
      ServerIdentifierOption    serverIdentifier,
      ClientIdentifierOption    clientIdentifier,
      //RFC 5969
      SixrdDHCPv4Option         sixrdDHCPv4,
      //others
      DHCPv4OptionRaw           raw
    }
    
    /**
     * @desc List of options collected from different RFCs.
     */
    type set of DHCPv4Option DHCPv4Options;
    
    /**
     * @desc Collection of option codes defined in several RFCs.
     */
    type enumerated OptionCode {
      e_OPTION_PAD (0),
      e_OPTION_END (1),
      e_OPTION_DHCP_MESSAGE_TYPE (53),
      e_OPTION_SERVERID (54),
      e_OPTION_CLIENTID (61),
      e_OPTION_6RD (212),
      e_OPTION_UNKNOWN
    } 
    with {
        variant "unsigned 8 bit"
    }
    
  } //end group dhcpOptions
  
} // end AtsCommon_Dhcpv4_CommonRfcs_TypesAndValues
+88 −0
Original line number Diff line number Diff line
/**
 *  @author   STF 440
 *  @version  $Id$
 *  @desc     This module adds definition from RFC 1533.
 *  @url      http://www.ietf.org/rfc/rfc1533.txt
 *  
 */
 module AtsCommon_Dhcpv4_Rfc1533_TypesAndValues {
  
  //LibCommon
  import from LibCommon_BasicTypesAndValues all;
  import from LibCommon_DataStrings all;
  
  // AtsCommon
  import from AtsCommon_Dhcpv4_CommonRfcs_TypesAndValues all;
  
  group vendorOptions {
      
      /**
       * @desc Pad
       * @reference http://tools.ietf.org/html/rfc1533#section-3 cl 3.1
       */
      type record PadOption {
          OptionCode    optionCode(e_OPTION_PAD)
      }
      
      /**
       * @desc Pad
       * @reference http://tools.ietf.org/html/rfc1533#section-3 cl 3.2
       */
      type record EndOption {
          OptionCode    optionCode(e_OPTION_END)
      }
      
  } // end vendorOptions
  
  group dhcpExtensions {
      
      /**
       * @desc DHCP Message Type
       * @reference http://tools.ietf.org/html/rfc1533#section-9 cl. 9.4
       */
      type record DHCPMessageTypeOption {
          OptionCode            optionCode(e_OPTION_DHCP_MESSAGE_TYPE),
          UInt8                 optionLen(1),
          DHCPMessageTypeValue  messageType
      }
      
      type enumerated DHCPMessageTypeValue {
          e_DHCPDISCOVER(1),
          e_DHCPOFFER(2),
          e_DHCPREQUEST(3),
          e_DHCPDECLINE(4),
          e_DHCPACK(5),
          e_DHCPNAK(6),
          e_DHCPRELEASE(7),
          e_UNKNOWN
      }
      
      /**
       * @desc Server Identifier
       * @reference http://tools.ietf.org/html/rfc1533#section-9 cl. 9.5
       */
      type record ServerIdentifierOption {
        OptionCode  optionCode(e_OPTION_SERVERID),
        UInt8       optionLen(4),
        Ipv4Address serverIdentifier
      }
      
      /**
       * @desc Client Identifier
       * @reference http://tools.ietf.org/html/rfc1533#section-9 cl. 9.5
       */
      type record ClientIdentifierOption {
        OptionCode  optionCode(e_OPTION_CLIENTID),
        UInt8       optionLen,
        union {
            record {
                UInt8       hardwareType,
                octetstring val
            } hardware,
            octetstring raw
        } clientIdentifier
      }
      
  } // end dhcpExtensions
  
} // end AtsCommon_Dhcpv4_Rfc1533_TypesAndValues
+39 −0
Original line number Diff line number Diff line
/**
 *  @author   STF 440
 *  @version  $Id$
 *  @desc     This module adds definition from RFC 5959.
 *  @url      http://www.ietf.org/rfc/rfc5969.txt
 *  
 */
 module AtsCommon_Dhcpv4_Rfc5969_TypesAndValues {
  
  //LibCommon
  import from LibCommon_BasicTypesAndValues all;
  import from LibCommon_DataStrings all;
  
  // LibIPv6
  import from LibIpv6_CommonRfcs_TypesAndValues all;
  
  // AtsCommon
  import from AtsCommon_Dhcpv4_CommonRfcs_TypesAndValues all;
  
  group dhcpExtensions {
      
      /**
       * @desc 6rd DHCPv4 Option
       * @reference http://tools.ietf.org/html/rfc5969#section-7.1.1
       */
      type record SixrdDHCPv4Option {
          OptionCode            optionCode(e_OPTION_6RD),
          UInt8                 optionLen,
          UInt8                 ipv4MaskLen,
          UInt8                 sixrdPrefixLen,
          Ipv6Address           sixrdPrefix,
          SixrdBRIPv4Addresses  sixrdBRIPv4Addresses
      }
      
      type record length(1..infinity) of AtsCommon_Dhcpv4_CommonRfcs_TypesAndValues.Ipv4Address SixrdBRIPv4Addresses;
      
  } // end dhcpExtensions
  
} // end AtsCommon_Dhcpv4_Rfc5969_TypesAndValues