aboutsummaryrefslogtreecommitdiffstats
path: root/src/xua_asp_fsm.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2019-11-30 22:54:14 +0100
committerlaforge <laforge@osmocom.org>2019-12-02 10:19:31 +0000
commitac2e715fbd11931c8039c5ca9d62526c98d9e755 (patch)
tree161bacee1f7f0afa91f693725fcc7f1977a82b17 /src/xua_asp_fsm.c
parenta4555c34304aee9b825be3879c54cedcb5a7dbae (diff)
xua_asp_fsm: Ensure xUA client includes traffic-mode if configured
When a client (ASP) sends an ASPAC to the server (SG), it should include the traffic-mode configured for it's ASs, if any. Change-Id: Ia850df22df529dab74959e8666f85976002c482c Related: OS#4285
Diffstat (limited to 'src/xua_asp_fsm.c')
-rw-r--r--src/xua_asp_fsm.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c
index e09c46c..ff81edd 100644
--- a/src/xua_asp_fsm.c
+++ b/src/xua_asp_fsm.c
@@ -141,6 +141,33 @@ static void send_xlm_prim_simple(struct osmo_fsm_inst *fi,
xua_asp_send_xlm_prim_simple(asp, prim_type, op);
}
+/* determine the osmo_ss7_as_traffic_mode to be used by this ASP; will
+ * iterate over all AS configured for this ASP. If they're compatible,
+ * a single traffic mode is returned as enum osmo_ss7_as_traffic_mode.
+ * If they're incompatible, -EINVAL is returned. If there is none
+ * configured, -1 is returned */
+static int determine_traf_mode(struct osmo_ss7_asp *asp)
+{
+ struct osmo_ss7_as *as;
+ int tmode = -1;
+
+ llist_for_each_entry(as, &asp->inst->as_list, list) {
+ if (!osmo_ss7_as_has_asp(as, asp))
+ continue;
+ /* we only care about traffic modes explicitly set */
+ if (!as->cfg.mode_set_by_vty)
+ continue;
+ if (tmode == -1) {
+ /* this is the first AS; we use this traffic mode */
+ tmode = as->cfg.mode;
+ } else {
+ if (tmode != as->cfg.mode)
+ return -EINVAL;
+ }
+ }
+ return tmode;
+}
+
/* ask the xUA implementation to transmit a specific message */
static int peer_send(struct osmo_fsm_inst *fi, int out_event, struct xua_msg *in)
{
@@ -148,6 +175,7 @@ static int peer_send(struct osmo_fsm_inst *fi, int out_event, struct xua_msg *in
struct osmo_ss7_asp *asp = xafp->asp;
struct xua_msg *xua = xua_msg_alloc();
struct msgb *msg;
+ int rc;
switch (out_event) {
case XUA_ASP_E_ASPSM_ASPUP:
@@ -188,6 +216,9 @@ static int peer_send(struct osmo_fsm_inst *fi, int out_event, struct xua_msg *in
/* RFC3868 Ch. 3.6.1 */
xua->hdr = XUA_HDR(SUA_MSGC_ASPTM, SUA_ASPTM_ACTIVE);
/* Optional: Traffic Mode Type */
+ rc = determine_traf_mode(asp);
+ if (rc >= 0)
+ xua_msg_add_u32(xua, M3UA_IEI_TRAF_MODE_TYP, osmo_ss7_tmode_to_xua(rc));
/* Optional: Routing Context */
/* Optional: TID Label */
/* Optional: DRN Label */