aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-06-15 02:51:22 +0700
committerlaforge <laforge@gnumonks.org>2019-06-14 21:49:57 +0000
commit6c9fafcead2f0e70f87b014cb9a2d2ee4b407418 (patch)
tree1d749cc4598e1e423adb09e70f9913390865294e /library
parent74f25ae2c358a9ec798c5a0b8fb7c49cf9787d1f (diff)
library/GSUP_Types.ttcn: refactor PROC_SS IEs generation
Both ts_GSUP_PROC_SS_ERR() and tr_GSUP_PROC_SS_ERR() templates used to compose the set of GSUP IEs manually, while similar ones were using both f_gen_ts_ss_ies() and f_gen_tr_ss_ies(). This led to the following problems: - tr_GSUP_PROC_SS_ERR was not tolerant to omitted message class IE, which was recently introduced; - code duplication. Let's modify the both functions in order to accept an optional Cause IE value, which is omitted by default, and use them in the both templates. Change-Id: I5cd6d2bc754bcedd1e721b3bd95ada9cdd44bcf0
Diffstat (limited to 'library')
-rw-r--r--library/GSUP_Types.ttcn68
1 files changed, 39 insertions, 29 deletions
diff --git a/library/GSUP_Types.ttcn b/library/GSUP_Types.ttcn
index 80813471..e6275388 100644
--- a/library/GSUP_Types.ttcn
+++ b/library/GSUP_Types.ttcn
@@ -1089,18 +1089,26 @@ private function f_gen_ts_ss_ies(
hexstring imsi,
OCT4 sid,
GSUP_SessionState state,
- template (omit) octetstring ss
+ template (omit) octetstring ss := omit,
+ template (omit) integer cause := omit
) return GSUP_IEs {
/* Mandatory IEs */
var GSUP_IEs ies := {
- valueof(ts_GSUP_IE_IMSI(imsi)),
- valueof(ts_GSUP_IE_SessionId(sid)),
- valueof(ts_GSUP_IE_SessionState(state))
+ valueof(ts_GSUP_IE_IMSI(imsi))
};
+ /* Cause IE is needed for PROC_SS_ERR */
+ if (isvalue(cause)) {
+ ies := ies & { valueof(ts_GSUP_IE_Cause(valueof(cause))) };
+ }
+
+ /* Mandatory session IEs */
+ ies := ies & { valueof(ts_GSUP_IE_SessionId(sid)) };
+ ies := ies & { valueof(ts_GSUP_IE_SessionState(state)) };
+
/* Optional SS payload */
if (isvalue(ss)) {
- ies[3] := valueof(ts_GSUP_IE_SSInfo(valueof(ss)));
+ ies := ies & { valueof(ts_GSUP_IE_SSInfo(valueof(ss))) };
}
return ies;
@@ -1109,29 +1117,42 @@ private function f_gen_tr_ss_ies(
template hexstring imsi,
template OCT4 sid := ?,
template GSUP_SessionState state := ?,
- template octetstring ss := ?
+ template octetstring ss := omit,
+ template integer cause := omit
) return template GSUP_IEs {
/* Mandatory IEs */
var template GSUP_IEs ies := {
- tr_GSUP_IE_IMSI(imsi),
- tr_GSUP_IE_SessionId(sid),
- tr_GSUP_IE_SessionState(state)
+ tr_GSUP_IE_IMSI(imsi)
};
- var integer last_idx := 3;
+ var integer idx := 1;
+
+ /* Cause IE is needed for PROC_SS_ERR */
+ if (istemplatekind(cause, "*")) {
+ ies[idx] := *;
+ idx := idx + 1;
+ } else if (not istemplatekind(cause, "omit")) {
+ ies[idx] := tr_GSUP_IE_Cause(cause);
+ idx := idx + 1;
+ }
+
+ /* Mandatory session IEs */
+ ies[idx] := tr_GSUP_IE_SessionId(sid);
+ ies[idx + 1] := tr_GSUP_IE_SessionState(state);
+ idx := idx + 2;
/* Optional SS payload */
if (istemplatekind(ss, "*")) {
- ies[3] := *;
- last_idx := last_idx + 1;
+ ies[idx] := *;
+ idx := idx + 1;
} else if (not istemplatekind(ss, "omit")) {
- ies[3] := tr_GSUP_IE_SSInfo(ss);
- last_idx := last_idx + 1;
+ ies[idx] := tr_GSUP_IE_SSInfo(ss);
+ idx := idx + 1;
}
/* the GSUP Message Class IE is optional, as old implementations don't have it yet */
var template GSUP_IEs ies2 := ies;
- ies2[last_idx] := tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_USSD);
- last_idx := last_idx + 1;
+ ies2[idx] := tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_USSD);
+ idx := idx + 1;
return (ies, ies2);
}
@@ -1181,12 +1202,7 @@ template (value) GSUP_PDU ts_GSUP_PROC_SS_ERR(
integer cause
) := ts_GSUP(
OSMO_GSUP_MSGT_PROC_SS_ERROR,
- {
- valueof(ts_GSUP_IE_IMSI(imsi)),
- valueof(ts_GSUP_IE_Cause(cause)),
- valueof(ts_GSUP_IE_SessionId(sid)),
- valueof(ts_GSUP_IE_SessionState(state))
- }
+ f_gen_ts_ss_ies(imsi, sid, state, cause := cause)
);
template GSUP_PDU tr_GSUP_PROC_SS_ERR(
template hexstring imsi,
@@ -1195,13 +1211,7 @@ template GSUP_PDU tr_GSUP_PROC_SS_ERR(
template integer cause := ?
) := tr_GSUP(
OSMO_GSUP_MSGT_PROC_SS_ERROR,
- {
- tr_GSUP_IE_IMSI(imsi),
- tr_GSUP_IE_Cause(cause),
- tr_GSUP_IE_SessionId(sid),
- tr_GSUP_IE_SessionState(state),
- tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_USSD)
- }
+ f_gen_tr_ss_ies(imsi, sid, state, cause := cause)
);
template (value) GSUP_PDU ts_GSUP_MO_FORWARD_SM_REQ(