/******************************************************************************/
// @copyright   Copyright Notification
//   No part may be reproduced except as authorized by written permission.
//   The copyright and the foregoing restriction extend to reproduction in all media.
//   Trademark 2010, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC).
//   All rights reserved.
// @version: IWD_10wk37
// $Date: 2010-06-02 12:46:27 +0200 (Wed, 02 Jun 2010) $
// $Rev: 3219 $
/******************************************************************************/


module IP_PTC_CtrlMsgs {
  /* definition of coordination messages to be used by EUTRA_PTC/UTRAN_PTC/GERAN_PTC do configure
     routing table for the IP data */

  import from CommonDefs all;
  import from IP_ASP_TypeDefs all;
  import from EUTRA_CommonDefs all; // get CellId_Type

  //============================================================================
  // DHCP

  type record DHCP_Start_Type {
    IP_AddrInfo_Type ServerAddr,
    IP_DrbInfo_Type  DrbInfo
  };

  type union DHCP_ConfigReq_Type {
    DHCP_Start_Type Start,
    Null_Type       Stop
  };

  //============================================================================
  // ICMPv6

  type record ICMPv6_Start_Type {
    IP_AddrInfo_Type ServerAddr,
    IP_DrbInfo_Type  DrbInfo
  };

  type union ICMPv6_ConfigReq_Type {
    ICMPv6_Start_Type Start,
    Null_Type         Stop
  };

  //============================================================================

  type union IP_ConfigReq_Type {
    DHCP_ConfigReq_Type   DHCP,
    ICMPv6_ConfigReq_Type ICMPv6
  };

  type union IP_ConfigCnf_Type {
    Null_Type DHCP,
    Null_Type ICMPv6
  };

  //============================================================================

  type port IP_RAT_CTRL_PORT message {
    out IP_ConfigReq_Type;
    in  IP_ConfigCnf_Type;
  };

  type port IP_PTC_CTRL_PORT message {
    in  IP_ConfigReq_Type;
    out IP_ConfigCnf_Type;
  };

  //****************************************************************************
  // EUTRA/UTRAN/GERAN side
  //----------------------------------------------------------------------------
  // Commands:

  // DHCP

  template (value) IP_ConfigReq_Type cs_DHCPv4_StartReq(charstring p_IPv4Addr,
                                                        template (value) IP_DrbInfo_Type p_DrbInfo) :=
  {
    DHCP := {
      Start := {
        ServerAddr := {
          V4 := {
            Addr := p_IPv4Addr
          }
        },
        DrbInfo := p_DrbInfo
      }
    }
  };

  template (value) IP_ConfigReq_Type cs_DHCPv4_StopReq :=
  {
    DHCP := {
      Stop := true
    }
  };

  // ICMP

  template (value) IP_ConfigReq_Type cs_ICMPv6_StartReq(charstring p_IPv6Addr,
                                                        template (value) IP_DrbInfo_Type p_DrbInfo) :=
  {
    ICMPv6 := {
      Start := {
        ServerAddr := {
          V6 := {
            Addr := p_IPv6Addr,
            ScopeId := omit
          }
        },
        DrbInfo := p_DrbInfo
      }
    }
  };

  template (value) IP_ConfigReq_Type cs_ICMPv6_StopReq :=
  {
    ICMPv6 := {
      Stop := true
    }
  };

  //----------------------------------------------------------------------------
  // Confirmations:

  // DHCP

  template IP_ConfigCnf_Type cr_DHCP_Cnf :=
  {
    DHCP := true
  };

  // ICMP

  template IP_ConfigCnf_Type cr_ICMPv6_Cnf :=
  {
    ICMPv6 := true
  };

  //****************************************************************************
  // IP PTC side
  //----------------------------------------------------------------------------

  template IP_ConfigReq_Type cr_DHCP_Req :=
  {
    DHCP := ?
  };

  template (value) IP_ConfigCnf_Type cs_DHCP_Cnf :=
  {
    DHCP := true
  };

  template IP_ConfigReq_Type cr_ICMPv6_Req :=
  {
    ICMPv6 := ?
  };

  template (value) IP_ConfigCnf_Type cs_ICMPv6_Cnf :=
  {
    ICMPv6 := true
  };

  //****************************************************************************
  // templates for DRB info
  //----------------------------------------------------------------------------

  template (value) IP_DrbInfo_Type cs_DrbInfo_EUTRA(CellId_Type p_CellId,
                                                    IP_DrbIdType p_DrbId) :=
  {
    Eutra := {
      Cell := {
        Id := p_CellId
      },
      DrbId := p_DrbId
    }
  };

  //****************************************************************************
  // Functions to be called from the test cases
  //----------------------------------------------------------------------------

  function f_DHCPv4_Start(IP_RAT_CTRL_PORT p_Port,
                          charstring p_IPv4Addr,
                          template (value) IP_DrbInfo_Type p_DrbInfo)
  { /* RAT independent function */
    p_Port.send(cs_DHCPv4_StartReq(p_IPv4Addr, p_DrbInfo));
    p_Port.receive(cr_DHCP_Cnf);
  }

  function f_DHCPv4_Stop(IP_RAT_CTRL_PORT p_Port)
  { /* RAT independent function */
    p_Port.send(cs_DHCPv4_StopReq);
    p_Port.receive(cr_DHCP_Cnf);
  }

  function f_ICMPv6_Start(IP_RAT_CTRL_PORT p_Port,
                          charstring p_IPv6Addr,
                          template (value) IP_DrbInfo_Type p_DrbInfo)
  { /* RAT independent function */
    p_Port.send(cs_ICMPv6_StartReq(p_IPv6Addr, p_DrbInfo));
    p_Port.receive(cr_ICMPv6_Cnf);
  }

  function f_ICMPv6_Stop(IP_RAT_CTRL_PORT p_Port)
  { /* RAT independent function */
    p_Port.send(cs_ICMPv6_StopReq);
    p_Port.receive(cr_ICMPv6_Cnf);
  }

}
