NS_Emulation: Avoid g_unblocked_nsvcs_* overflowing
Sometimes we run into situations where the g_unblocked_nsvcs_* is
exceeding the number of NSVCs we have in g_nsvcs. This can only happen
as we blindly append integers to the ro_integer fields, rather than
checking if they are already contained.
Let's factor out the add_unique and del functions (in Osmocom_Types)
and use them from NS_Emulation.
Change-Id: Ib3273d6ce9b80f700c964d578fdb0f268eac6a14
diff --git a/library/NS_Emulation.ttcnpp b/library/NS_Emulation.ttcnpp
index ca44a02..6d8113c 100644
--- a/library/NS_Emulation.ttcnpp
+++ b/library/NS_Emulation.ttcnpp
@@ -310,30 +310,16 @@
/* add index to list of unblocked NSVCs */
if (not ischosen(g_nsvcs[i].cfg.provider.ip) or
g_nsvcs[i].cfg.provider.ip.signalling_weight > 0) {
- g_unblocked_nsvcs_sig := g_unblocked_nsvcs_sig & {i};
+ ro_integer_add_unique(g_unblocked_nsvcs_sig, i);
}
if (not ischosen(g_nsvcs[i].cfg.provider.ip) or
g_nsvcs[i].cfg.provider.ip.data_weight > 0) {
- g_unblocked_nsvcs_data := g_unblocked_nsvcs_data & {i};
+ ro_integer_add_unique(g_unblocked_nsvcs_data, i);
}
} else if (g_nsvcs[i].state == NSVC_S_ALIVE_UNBLOCKED and state != NSVC_S_ALIVE_UNBLOCKED) {
/* remove index to list of unblocked NSVCs */
- var Osmocom_Types.ro_integer new_unblocked_nsvcs_sig := {};
- for (var integer j := 0; j < lengthof(g_unblocked_nsvcs_sig); j := j+1) {
- if (g_unblocked_nsvcs_sig[j] != i) {
- new_unblocked_nsvcs_sig := new_unblocked_nsvcs_sig & {j};
- }
- }
- g_unblocked_nsvcs_sig := new_unblocked_nsvcs_sig;
-
- var Osmocom_Types.ro_integer new_unblocked_nsvcs_data := {};
- for (var integer j := 0; j < lengthof(g_unblocked_nsvcs_data); j := j+1) {
- if (g_unblocked_nsvcs_data[j] != i) {
- new_unblocked_nsvcs_data := new_unblocked_nsvcs_data & {j};
- }
- }
- g_unblocked_nsvcs_data := new_unblocked_nsvcs_data;
-
+ ro_integer_del(g_unblocked_nsvcs_sig, i);
+ ro_integer_del(g_unblocked_nsvcs_data, i);
}
g_nsvcs[i].state := state;
}