pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37635?usp=email )
(
1 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: GTP1C_Templates,Osmocom_Gb_types: Use/move conversion functions at Osmocom_Types ......................................................................
GTP1C_Templates,Osmocom_Gb_types: Use/move conversion functions at Osmocom_Types
Change-Id: I29948bfcb2b344d5aca293fa60455fcc6de66c72 --- M library/GTPv1C_Templates.ttcn M library/Osmocom_Gb_Types.ttcn M library/Osmocom_Types.ttcn 3 files changed, 46 insertions(+), 70 deletions(-)
Approvals: fixeria: Looks good to me, approved laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified
diff --git a/library/GTPv1C_Templates.ttcn b/library/GTPv1C_Templates.ttcn index a632b47..33efb3a 100644 --- a/library/GTPv1C_Templates.ttcn +++ b/library/GTPv1C_Templates.ttcn @@ -108,28 +108,6 @@ } }
- private function f_oct_or_wc(template integer inp, integer len) return template octetstring { - if (istemplatekind(inp, "omit")) { - return omit; - } else if (istemplatekind(inp, "*")) { - return *; - } else if (istemplatekind(inp, "?")) { - return ?; - } - return int2oct(valueof(inp), len); - } - - private function f_hex_or_wc(template integer inp, integer len) return template hexstring { - if (istemplatekind(inp, "omit")) { - return omit; - } else if (istemplatekind(inp, "*")) { - return *; - } else if (istemplatekind(inp, "?")) { - return ?; - } - return int2hex(valueof(inp), len); - } - /* generalized GTP-C receive template */ template (present) PDU_GTPC tr_GTP1C_PDU(template (present) OCT1 msg_type, template (present) OCT4 teid, template (present) GTPC_PDUs pdu := ?) := { /* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an @@ -1520,14 +1498,14 @@ ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5]; } if (isvalue(cid.ra_id.lai.lac)) { - ret.lac := f_oct_or_wc(cid.ra_id.lai.lac, 2); + ret.lac := int2oct_tmpl(cid.ra_id.lai.lac, 2); } } if (isvalue(cid) and isvalue(cid.ra_id)) { - ret.rac := f_oct_or_wc(cid.ra_id.rac, 1); + ret.rac := int2oct_tmpl(cid.ra_id.rac, 1); } if (isvalue(cid)) { - ret.cI_value := f_oct_or_wc(cid.cell_id, 2); + ret.cI_value := int2oct_tmpl(cid.cell_id, 2); } return ret; } diff --git a/library/Osmocom_Gb_Types.ttcn b/library/Osmocom_Gb_Types.ttcn index 42866ff..c387ea3 100644 --- a/library/Osmocom_Gb_Types.ttcn +++ b/library/Osmocom_Gb_Types.ttcn @@ -161,28 +161,6 @@ return ret; }
- private function f_oct_or_wc(template integer inp, integer len) return template octetstring { - if (istemplatekind(inp, "omit")) { - return omit; - } else if (istemplatekind(inp, "*")) { - return *; - } else if (istemplatekind(inp, "?")) { - return ?; - } - return int2oct(valueof(inp), len); - } - - private function f_hex_or_wc(template integer inp, integer len) return template hexstring { - if (istemplatekind(inp, "omit")) { - return omit; - } else if (istemplatekind(inp, "*")) { - return *; - } else if (istemplatekind(inp, "?")) { - return ?; - } - return int2hex(valueof(inp), len); - } - template (value) NS_VCI ts_NS_IE_NSVCI(Nsvci nsvci) := { iEI := '01'O, ext := '1'B, @@ -197,7 +175,7 @@ lengthIndicator := { length1 := 2 }, - nS_VCI := f_oct_or_wc(nsvci, 2) + nS_VCI := int2oct_tmpl(nsvci, 2) }
template (value) NSEI_NS ts_NS_IE_NSEI(Nsei nsei) := { @@ -214,7 +192,7 @@ lengthIndicator := { length1 := 2 }, - nSEI := f_oct_or_wc(nsei, 2) + nSEI := int2oct_tmpl(nsei, 2) }
template (value) IP4_Element ts_SNS_IPv4(charstring ip, integer udp_port, @@ -414,7 +392,7 @@ pDU_NS_Unitdata := { nsPduType := '00'O, nS_SDU_ControlBits := bits, - bVCI := f_oct_or_wc(bvci, 2), + bVCI := int2oct_tmpl(bvci, 2), nS_SDU := sdu } } @@ -483,7 +461,7 @@ } template MaxNumberOfNSVCs tr_SNS_IE_MaxNumOfNSVCs(template uint16_t num) := { iEI := '07'O, - maxNumberOfNSVCs := f_oct_or_wc(num, 2) + maxNumberOfNSVCs := int2oct_tmpl(num, 2) }
template (value) PDU_NS ts_SNS_SIZE(Nsei nsei, boolean rst_flag := true, @@ -858,7 +836,7 @@ lengthIndicator := { length1 := 3 }, - number_of_octets_transfered_or_deleted := f_oct_or_wc(oct_aff, 3) + number_of_octets_transfered_or_deleted := int2oct_tmpl(oct_aff, 3) } return r; } @@ -886,7 +864,7 @@ lengthIndicator := { length1 := 1 }, - number_of_frames_discarded := f_hex_or_wc(frames_discarded, 2) + number_of_frames_discarded := int2hex_tmpl(frames_discarded, 2) } return r; } @@ -915,7 +893,7 @@ lengthIndicator := { length1 := 2 }, - unstructured_value := f_oct_or_wc(bvci, 2) + unstructured_value := int2oct_tmpl(bvci, 2) } return r; } @@ -951,7 +929,7 @@ lengthIndicator := { length1 := 2 }, - nSEI := f_oct_or_wc(nsei, 2) + nSEI := int2oct_tmpl(nsei, 2) } return r; } @@ -1170,14 +1148,14 @@ ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5]; } if (isvalue(cid.ra_id.lai.lac)) { - ret.lac := f_oct_or_wc(cid.ra_id.lai.lac, 2); + ret.lac := int2oct_tmpl(cid.ra_id.lai.lac, 2); } } if (isvalue(cid) and isvalue(cid.ra_id)) { - ret.rac := f_oct_or_wc(cid.ra_id.rac, 1); + ret.rac := int2oct_tmpl(cid.ra_id.rac, 1); } if (isvalue(cid)) { - ret.cI_value := f_oct_or_wc(cid.cell_id, 2); + ret.cI_value := int2oct_tmpl(cid.cell_id, 2); } return ret; } @@ -1415,7 +1393,7 @@ lengthIndicator := { length1 := 2 }, - bmax := f_oct_or_wc(bmax, 2) + bmax := int2oct_tmpl(bmax, 2) }, bucket_Leak_Rate := { iEI := '03'O, @@ -1423,7 +1401,7 @@ lengthIndicator := { length1 := 2 }, - r_Value := f_oct_or_wc(bucket_leak_rate, 2) + r_Value := int2oct_tmpl(bucket_leak_rate, 2) }, bmax_default_MS := { iEI := '01'O, @@ -1431,7 +1409,7 @@ lengthIndicator := { length1 := 2 }, - bmax := f_oct_or_wc(bmax_default_ms, 2) + bmax := int2oct_tmpl(bmax_default_ms, 2) }, r_default_MS := { iEI := '1C'O, @@ -1439,7 +1417,7 @@ lengthIndicator := { length1 := 2 }, - r_default_MS_value := f_oct_or_wc(r_default_ms, 2) + r_default_MS_value := int2oct_tmpl(r_default_ms, 2) }, bucket_Full_Ratio := *, bVC_Measurement := *, @@ -1530,7 +1508,7 @@ lengthIndicator := { length1 := 2 }, - bmax := f_oct_or_wc(bmax, 2) + bmax := int2oct_tmpl(bmax, 2) }, bucket_Leak_Rate := { iEI := '03'O, @@ -1538,7 +1516,7 @@ lengthIndicator := { length1 := 2 }, - r_Value := f_oct_or_wc(bucket_leak_rate, 2) + r_Value := int2oct_tmpl(bucket_leak_rate, 2) }, bucket_Full_Ratio := *, flow_Control_Granularity := * @@ -3195,7 +3173,7 @@ ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5]; } if (isvalue(cid.ra_id.lai.lac)) { - ret.lac := f_oct_or_wc(cid.ra_id.lai.lac, 2); + ret.lac := int2oct_tmpl(cid.ra_id.lai.lac, 2); } } return ret; @@ -3406,14 +3384,14 @@ ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5]; } if (isvalue(cid.ra_id.lai.lac)) { - ret.lac := f_oct_or_wc(cid.ra_id.lai.lac, 2); + ret.lac := int2oct_tmpl(cid.ra_id.lai.lac, 2); } } if (isvalue(cid) and isvalue(cid.ra_id)) { - ret.rac := f_oct_or_wc(cid.ra_id.rac, 1); + ret.rac := int2oct_tmpl(cid.ra_id.rac, 1); } if (isvalue(cid)) { - ret.cI_value := f_oct_or_wc(cid.cell_id, 2); + ret.cI_value := int2oct_tmpl(cid.cell_id, 2); } return ret; } @@ -3459,11 +3437,11 @@ ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5]; } if (isvalue(cid.ra_id.lai.lac)) { - ret.lac := f_oct_or_wc(cid.ra_id.lai.lac, 2); + ret.lac := int2oct_tmpl(cid.ra_id.lai.lac, 2); } } if (isvalue(cid) and isvalue(cid.ra_id)) { - ret.rac := f_oct_or_wc(cid.ra_id.rac, 1); + ret.rac := int2oct_tmpl(cid.ra_id.rac, 1); } if (isvalue(rnc_id)) { ret.spare := '0'H; diff --git a/library/Osmocom_Types.ttcn b/library/Osmocom_Types.ttcn index 6653408..57912de 100644 --- a/library/Osmocom_Types.ttcn +++ b/library/Osmocom_Types.ttcn @@ -153,6 +153,17 @@ } }
+function int2hex_tmpl(template integer inp, integer len) return template hexstring { + if (istemplatekind(inp, "omit")) { + return omit; + } else if (istemplatekind(inp, "*")) { + return *; + } else if (istemplatekind(inp, "?")) { + return ?; + } + return int2hex(valueof(inp), len); +} + function int2oct_tmpl(template integer inp, integer num_oct) return template octetstring { if (istemplatekind(inp, "omit")) {