Commit fd2c5135 authored by Bostjan Pintar's avatar Bostjan Pintar
Browse files

Merge branch 'pespin/pr-qos-rules' into 'main'

NG_NAS: Fix QoS_Rule type and template definitions

See merge request !14
parents a40f1c99 d5f4433e
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -174,16 +174,13 @@ module NG_NAS_Common {
    B32_Type        NG_TMSI
  };

  template (value) NG_PacketFilterList cs_PacketFilterList_RemoteAddress (B4_Type p_Id, octetstring p_Component) :=
  template (value) NG_PacketFilter_Type2 cs_PacketFilter_RemoteAddress (B4_Type p_Id, octetstring p_Component) :=
  { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
   new := {{
     spare          := tsc_Spare2,
     direction      := '11'B,       // bi-directional
     packetFilterId := p_Id,
     len            := int2oct(lengthof(p_Component), 1),
     contents       := p_Component

   }}
  };

  template (value) QoS_Rule cs_QoS_RuleRemoteAccess (O1_Type p_Id,
@@ -196,14 +193,18 @@ module NG_NAS_Common {
   { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    identifier          := p_Id,
    iel                 := p_Length,
    u := {
      creat := {
        ruleOperationCode   := '001'B,
        dqrBit              := p_DQR,
        numOfPacketFilters  := '0001'B,
    packetFilterList    := cs_PacketFilterList_RemoteAddress (p_FilterId, p_Component),
        packetFilterList    := { cs_PacketFilter_RemoteAddress (p_FilterId, p_Component) },
        precedence          := p_Precedence,
        spare               := tsc_Spare1,
        segregation         := tsc_Spare1,
        flowIdentifier      := p_FlowId
      }
    }
  };

  template (value) NG_NAS_GutiParameters_Type cs_NG_NAS_GutiParameters(B8_Type p_AMF_RegionId,
+153 −56
Original line number Diff line number Diff line
@@ -2470,27 +2470,19 @@ module NG_NAS_Templates {
  template (value) QoSFlowDescr cs_QoSFlowDescr1 := cs_QoSFlowDescr ({cs_QoS_Flow1});           /* @status      */
  template (value) QoSFlowDescr cs_QoSFlowDescr2 := cs_QoSFlowDescr ({cs_QoS_Flow2});           /* @status      */

  template (value) NG_PacketFilterList cs_PacketFilterList_1MatchAll :=
  template (value) NG_PacketFilter_Type2 cs_PacketFilter_1MatchAll :=
  { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    new := {
      {
    spare          := tsc_Spare2,
    direction      := '11'B,       // bi-directional
    packetFilterId := '0001'B,     // @sic R5-216158 sic@
    len            := '01'O,
    contents       := '01'O        // match-all
      }
    }
  };

  template (value) NG_PacketFilterList cs_PacketFilterList_MediaUDP (B4_Type p_Id, integer p_Port) :=
  { /* @status    APPROVED (IMS, NR5GC, NR5GC_IRAT, POS) */
    new := {
  template (value) NG_PacketFilter_Type2 cs_PacketFilter_MediaUDP (B4_Type p_Id, integer p_Port) :=
      cs_NG_PacketFilter_Type2 ('11'B,       // bi-directional
                                p_Id,
                                fl_BuildRemotePortRange(p_Port) & fl_BuildProtocolIdNextHeaderUDP())  // @sic R5s220046 sic@                                                        // Protocol id / Next Header UDP
    }
  };
                                fl_BuildRemotePortRange(p_Port) & fl_BuildProtocolIdNextHeaderUDP());

  template (value) NG_PacketFilter_Type2 cs_NG_PacketFilter_Type2 (B2_Type p_Dir,
                                                                   B4_Type p_Id,
@@ -2532,24 +2524,91 @@ module NG_NAS_Templates {
    return v_PacketFilter;
  }


  template (value) QoS_Rule cs_QoS_Rule (O1_Type p_Id,
                                         B6_Type p_QFI,
                                         O1_Type p_Precedence,
                                         B3_Type p_OperationCode := '001'B,
                                         template (value) NG_PacketFilterList p_FilterList := cs_PacketFilterList_1MatchAll,
                                         B1_Type p_DQR := '1'B) :=
  template (value) QoS_Rule cs_QoS_Rule (template (value) O1_Type p_Id,
                                         template (value) QoS_RuleU qos_rule_u) :=
  { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    identifier          := p_Id,
    iel                 := fl_NR5GC_QoSRuleLength(p_FilterList),   // @sic R5s210074 sic@
    ruleOperationCode   := p_OperationCode,  // @sic R5s190987 sic@
    iel                 := fl_NR5GC_QoSRuleLength(valueof(qos_rule_u)),   // @sic R5s210074 sic@
    u                   := qos_rule_u
  };


  template (value) QoS_RuleU cs_QoS_RuleU_Create(
                                  template (value) B6_Type p_QFI,
                                  template (value) O1_Type p_Precedence,
                                  template (omit) NG_PacketFilterList_Type2 p_FilterList := {cs_PacketFilter_1MatchAll},
                                  template (value) B1_Type p_DQR := '1'B,
                                  template (value) B1_Type spare := tsc_Spare1,
                                  template (value) B1_Type segregation := tsc_Spare1) :=
  { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    creat := {
      ruleOperationCode   := '001'B,
      dqrBit              := p_DQR,
    numOfPacketFilters  := '0001'B,
      numOfPacketFilters  := fl_NR5GC_numOfPacketFilters(p_FilterList),
      packetFilterList    := p_FilterList,
      precedence          := p_Precedence,
    spare               := tsc_Spare1,
    segregation         := tsc_Spare1,
      spare               := spare,
      segregation         := segregation,
      flowIdentifier      := p_QFI
    }
  };

  template (value) QoS_RuleU cs_QoS_RuleU_Modify_and_add_PF(
                                  template (omit) B6_Type p_QFI := omit,
                                  template (omit) O1_Type p_Precedence := omit,
                                  template (value) NG_PacketFilterList_Type2 p_FilterList := {cs_PacketFilter_1MatchAll},
                                  template (value) B1_Type p_DQR := '1'B,
                                  template (omit) B1_Type spare := tsc_Spare1,
                                  template (omit) B1_Type segregation := tsc_Spare1) :=
  { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    modify_and_add_pf := {
      ruleOperationCode   := '011'B,
      dqrBit              := p_DQR,
      numOfPacketFilters  := fl_NR5GC_numOfPacketFilters(p_FilterList),
      packetFilterList    := p_FilterList,
      precedence          := p_Precedence,
      spare               := spare,
      segregation         := segregation,
      flowIdentifier      := p_QFI
    }
  };

  template (value) QoS_RuleU cs_QoS_RuleU_Modify_and_replace_PF(
                                  template (omit) B6_Type p_QFI := omit,
                                  template (omit) O1_Type p_Precedence := omit,
                                  template (omit) NG_PacketFilterList_Type2 p_FilterList := {cs_PacketFilter_1MatchAll},
                                  template (value) B1_Type p_DQR := '1'B,
                                  template (omit) B1_Type spare := tsc_Spare1,
                                  template (omit) B1_Type segregation := tsc_Spare1) :=
  { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    modify_and_replace_pf := {
      ruleOperationCode   := '100'B,
      dqrBit              := p_DQR,
      numOfPacketFilters  := fl_NR5GC_numOfPacketFilters(p_FilterList),
      packetFilterList    := p_FilterList,
      precedence          := p_Precedence,
      spare               := spare,
      segregation         := segregation,
      flowIdentifier      := p_QFI
    }
  };

  template (value) QoS_RuleU cs_QoS_RuleU_Modify_no_PF(
                                  template (omit) B6_Type p_QFI := omit,
                                  template (omit) O1_Type p_Precedence := omit,
                                  template (value) B1_Type p_DQR := '1'B,
                                  template (omit) B1_Type spare := tsc_Spare1,
                                  template (omit) B1_Type segregation := tsc_Spare1) :=
  { /* @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS) */
    modify_no_pf := {
      ruleOperationCode   := '110'B,
      dqrBit              := p_DQR,
      numOfPacketFilters  := '0000'B,
      precedence          := p_Precedence,
      spare               := spare,
      segregation         := segregation,
      flowIdentifier      := p_QFI
    }
  };

  /*
@@ -2566,14 +2625,27 @@ module NG_NAS_Templates {
                                   template (omit) IEI8_Type p_IEI := omit) return template (value) QoS_Rules
  {
    var template (value) QoS_Rules v_QoS_Rules;
    var template (value) QoS_Rule v_VoiceQoS := cs_QoS_Rule('03'O, int2bit(7, 6), '01'O, -, cs_PacketFilterList_MediaUDP('0110'B, tsc_IMS_MediaPort_M1), '0'B); // @sic R5-210627, R5s220046 sic@;
    var template (value) QoS_Rule v_VoiceQoS;
    var template (value) QoS_Rule v_VoiceQoS2;

    v_VoiceQoS := cs_QoS_Rule('03'O,
                              cs_QoS_RuleU_Create(int2bit(7, 6),
                                                  '01'O,
                                                  { cs_PacketFilter_MediaUDP('0110'B, tsc_IMS_MediaPort_M1) },
                                                  '0'B)); // @sic R5-210627, R5s220046 sic@;
    v_VoiceQoS2 := cs_QoS_Rule('04'O,
                               cs_QoS_RuleU_Create(int2bit(8, 6),
                                                   '02'O,
                                                   { cs_PacketFilter_MediaUDP('0111'B, tsc_IMS_MediaPort_M2) },
                                                   '0'B));


    if (p_RuleNum == "7_Voice") {
      v_QoS_Rules := cs_QoS_Rules ({v_VoiceQoS}, p_IEI) // @sic R5-213440 sic@
    } else if (p_RuleNum == "7_Video") {
      v_QoS_Rules := cs_QoS_Rules ({cs_QoS_Rule('04'O, int2bit(8, 6), '02'O, -, cs_PacketFilterList_MediaUDP('0111'B, tsc_IMS_MediaPort_M2), '0'B)}, p_IEI) // @sic R5-217796, R5s220046, R5s220336 sic@
      v_QoS_Rules := cs_QoS_Rules ({v_VoiceQoS2}, p_IEI) // @sic R5-217796, R5s220046, R5s220336 sic@
    } else if (p_RuleNum == "7_VoiceVideo") {
      v_QoS_Rules := cs_QoS_Rules ({v_VoiceQoS, cs_QoS_Rule('04'O, int2bit(8, 6), '02'O, -, cs_PacketFilterList_MediaUDP('0111'B, tsc_IMS_MediaPort_M2), '0'B)}, p_IEI) // @sic R5-210627, R5-216161, R5s220046 sic@
      v_QoS_Rules := cs_QoS_Rules ({v_VoiceQoS, v_VoiceQoS2}, p_IEI) // @sic R5-210627, R5-216161, R5s220046 sic@
    } else {
      v_QoS_Rules := cs_QoS_Rules ({f_BuildDefaultQoSRule(p_RuleNum)}, p_IEI);
    }
@@ -2593,43 +2665,68 @@ module NG_NAS_Templates {

    select (p_RuleNum) {
      case ("1") {
        v_QoS_Rule := cs_QoS_Rule('01'O, int2bit(1, 6), 'FF'O); // @sic R5-202585 sic@
        v_QoS_Rule := cs_QoS_Rule('01'O,
                                  cs_QoS_RuleU_Create(int2bit(1, 6),
                                                      'FF'O)); // @sic R5-202585 sic@
      }
      case ("2") {
        v_QoS_Rule := cs_QoS_Rule('02'O, int2bit(2, 6), 'FF'O); // @sic R5-202585 sic@
        v_QoS_Rule := cs_QoS_Rule('02'O,
                                  cs_QoS_RuleU_Create(int2bit(2, 6),
                                                      'FF'O)); // @sic R5-202585 sic@
      }
      case ("3", "4", "4a", "5", "6") {
        v_QoS_Rule := f_BuildQoSRuleRemoteAccess (p_RuleNum);
      }
      case ("8") {
        v_QoS_Rule := cs_QoS_Rule('07'O, int2bit(9, 6), 'FF'O); // @sic R5-211499 sic@
        v_QoS_Rule := cs_QoS_Rule('07'O,
                                  cs_QoS_RuleU_Create(int2bit(9, 6),
                                                      'FF'O)); // @sic R5-211499 sic@
      }
    }
    return v_QoS_Rule;
  }

  /*
   * @desc      Returns "number of packet filters" for a given input NG_PacketFilterList
   * @param     p_FilterList
   * @return    B4_Type
   */
  function fl_NR5GC_numOfPacketFilters (template (omit) NG_PacketFilterList_Type2 p_FilterList) return B4_Type
  {
    if (isvalue(p_FilterList)) {
      return int2bit(lengthof(valueof(p_FilterList)), 4);
    }
    return '0000'B;
  }


  /*
   * @desc      Returns length of QoS Rule for a given input
   * @param     p_FilterList
   * @return    Type6Length_Type
   * @status    APPROVED (ENDC, IMS, NR5GC, NR5GC_IRAT, POS)
   */
   function fl_NR5GC_QoSRuleLength (template (value) NG_PacketFilterList p_FilterList) return Type6Length_Type
   function fl_NR5GC_QoSRuleLength (QoS_RuleU u) return Type6Length_Type
  {
    var integer i;
    var integer v_Length:=0;

    if (ischosen(p_FilterList.modify)) {
      v_Length := 1;
    if (ischosen(u.creat)) {
      return int2oct(lengthof(bit2oct(encvalue(u.creat))), 2);
    }
    if (ischosen(p_FilterList.new)) {
      for (i:= 0; i < lengthof(p_FilterList.new); i:= i+1) {
        v_Length := v_Length + oct2int(valueof(p_FilterList.new[i].len));
        v_Length := v_Length + 2; // 1 octet of header + length
    if (ischosen(u.delete)) {
      return int2oct(lengthof(bit2oct(encvalue(u.delete))), 2);
    }
    if (ischosen(u.modify_and_add_pf)) {
      return int2oct(lengthof(bit2oct(encvalue(u.modify_and_add_pf))), 2);
    }
    v_Length := v_Length + 3; // 1 octet of header + precedence + 1 octet of footer
    return int2oct(v_Length, 2);
    if (ischosen(u.modify_and_replace_pf)) {
      return int2oct(lengthof(bit2oct(encvalue(u.modify_and_replace_pf))), 2);
    }
    if (ischosen(u.modify_and_delete_pf)) {
      return int2oct(lengthof(bit2oct(encvalue(u.modify_and_delete_pf))), 2);
    }
    if (ischosen(u.modify_no_pf)) {
      return int2oct(lengthof(bit2oct(encvalue(u.modify_no_pf))), 2);
    }
    return int2oct(0, 2);
 }

  /*
+102 −11
Original line number Diff line number Diff line
@@ -2538,25 +2538,116 @@ module NG_NAS_TypeDefs {
  type record QoS_Rule {
    IEI8_Type                   identifier,
    Type6Length_Type            iel,
    B3_Type                     ruleOperationCode,
    QoS_RuleU                   u
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (u)";
    variant (iel) "BYTEORDER(last)";
  };

  type union QoS_RuleU {
    QoS_Rule_Create creat,
    QoS_Rule_Delete delete,
    QoS_Rule_Modify_and_add_PF modify_and_add_pf,
    QoS_Rule_Modify_and_replace_PF modify_and_replace_pf,
    QoS_Rule_Modify_and_delete_PF modify_and_delete_pf,
    QoS_Rule_Modify_no_PF modify_no_pf
  } with {
    variant "TAG(creat, ruleOperationCode = '001'B;
                 delete, ruleOperationCode = '010'B;
                 modify_and_add_pf, ruleOperationCode = '011'B;
                 modify_and_replace_pf, ruleOperationCode = '100'B;
                 modify_and_delete_pf, ruleOperationCode = '101'B;
                 modify_no_pf, ruleOperationCode = '110'B)"
  };

  type record QoS_Rule_Create {
    B3_Type                     ruleOperationCode ('001'B),
    B1_Type                     dqrBit,
    B4_Type                     numOfPacketFilters,
    NG_PacketFilterList         packetFilterList   optional,
    B4_Type                     numOfPacketFilters, /* >= 0 */
    NG_PacketFilterList_Type2   packetFilterList   optional,
    /*  For the "create new QoS rule" operation, the QoS rule precedence value field shall be included */
    O1_Type                     precedence,
    /* For the "create new QoS rule" operation, the QoS flow identifier value field shall be included. */
    B1_Type                     spare,
    B1_Type                     segregation,        /* Dec18 */
    B6_Type                     flowIdentifier
  } with {
    variant "FIELDORDER(msb)";
    variant (numOfPacketFilters) "LENGTHTO(packetFilterList)";
    variant (numOfPacketFilters) "UNIT(elements)"
  };

  type record QoS_Rule_Delete {
    B3_Type                     ruleOperationCode ('010'B),
    B1_Type                     dqrBit,
    /* For the "delete existing QoS rule" operation the number of packet filters shall be coded as 0. */
    B4_Type                     numOfPacketFilters ('0000'B)
    /* For the "delete existing QoS rule" operation, the QoS rule precedence
     * value field shall not be included */
    /* For the "delete existing QoS rule" operation, the QoS flow identifier
     * value field shall not be included. */
  } with {
    variant "FIELDORDER(msb)";
  };

  type record QoS_Rule_Modify_and_add_PF {
    B3_Type                     ruleOperationCode ('011'B),
    B1_Type                     dqrBit,
    B4_Type                     numOfPacketFilters, /* > 0 */
    NG_PacketFilterList_Type2   packetFilterList,
    O1_Type                     precedence         optional,
    B1_Type                     spare              optional,
    B1_Type                     segregation        optional,        /* Dec18 */
    B6_Type                     flowIdentifier     optional
  } with {
    variant "FIELDORDER(msb)";
    variant (iel) "LENGTHTO (ruleOperationCode, dqrBit, numOfPacketFilters, packetFilterList, precedence, spare, segregation, flowIdentifier)";
    variant (iel) "BYTEORDER(last)";
    variant (numOfPacketFilters) "LENGTHTO(packetFilterList)";
    variant (numOfPacketFilters) "UNIT(elements)"
  };

  type union NG_PacketFilterList {
    NG_PacketFilterList_Type1   modify,
    NG_PacketFilterList_Type2   new
  type record QoS_Rule_Modify_and_replace_PF {
    B3_Type                     ruleOperationCode ('100'B),
    B1_Type                     dqrBit,
    B4_Type                     numOfPacketFilters,  /* >= 0 */
    NG_PacketFilterList_Type2   packetFilterList   optional,
    O1_Type                     precedence         optional,
    B1_Type                     spare              optional,
    B1_Type                     segregation        optional,        /* Dec18 */
    B6_Type                     flowIdentifier     optional
  } with {
    variant "";
    variant "FIELDORDER(msb)";
    variant (numOfPacketFilters) "LENGTHTO(packetFilterList)";
    variant (numOfPacketFilters) "UNIT(elements)"
  };

  type record QoS_Rule_Modify_and_delete_PF {
    B3_Type                     ruleOperationCode ('101'B),
    B1_Type                     dqrBit,
    B4_Type                     numOfPacketFilters,  /* > 0 */
    NG_PacketFilterList_Type1   packetFilterList,
    O1_Type                     precedence         optional,
    B1_Type                     spare              optional,
    B1_Type                     segregation        optional,        /* Dec18 */
    B6_Type                     flowIdentifier     optional
  } with {
    variant "FIELDORDER(msb)";
    variant (numOfPacketFilters) "LENGTHTO(packetFilterList)";
    variant (numOfPacketFilters) "UNIT(elements)"
  };

  type record QoS_Rule_Modify_no_PF {
    B3_Type                     ruleOperationCode ('110'B),
    B1_Type                     dqrBit,
/* For the "modify existing QoS rule without modifying packet filters"
 * operation, the number of packet filters shall be coded as 0. */
    B4_Type                     numOfPacketFilters ('0000'B),
    O1_Type                     precedence         optional,
    B1_Type                     spare              optional,
    B1_Type                     segregation        optional,        /* Dec18 */
    B6_Type                     flowIdentifier     optional
  } with {
    variant "FIELDORDER(msb)";
  };

  type record of NG_PacketFilter_Type1 NG_PacketFilterList_Type1;
@@ -2574,8 +2665,8 @@ module NG_NAS_TypeDefs {
    B2_Type                     spare,
    B2_Type                     direction,
    B4_Type                     packetFilterId,
    Type4Length_Type            len                   optional,
    octetstring                 contents  length (1..255) optional // @sic R5w190307 sic@
    Type4Length_Type            len,
    octetstring                 contents length (0..255) // @sic R5w190307 sic@
  } with {
    variant "FIELDORDER(msb)";
    variant (len) "LENGTHTO (contents)";