aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bsc/smscb.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2022-05-13 08:39:17 +0200
committerHarald Welte <laforge@osmocom.org>2022-05-15 10:11:28 +0200
commit35cac4dba8749fcb21e449e61ff1458744e4812b (patch)
treef78fe179ab3749be847464075d0f2e4fa379a249 /src/osmo-bsc/smscb.c
parent7111e00ee511fb4a47951758fa003c286b590ef8 (diff)
smscb: "Warning Security Information is always present in ETWS
As per TS 48.049 Table 8.1.3.1.1 the WRITE-REPLACE message always has a Warning Security Information IE if it relates to ETWS. This is also implemented in the libosmocore CBSP parser. As the previous Change Id369bb3676ba279bafc234378fbe21dbc7b0614b has pointed out, the CBSP parser structure doesn't even permit any way of handing a decoded message to us without the warning_sec_info static struct member. So as a result, there's also no need to dynamically allocate bts_etws_state.input.sec_info via talloc. We can have it in-line as a static struct member and reduce code complexity and runtime memory allocations. Change-Id: Ib1b8e4af37b1f9f9398b81dad29942e82218c70b
Diffstat (limited to 'src/osmo-bsc/smscb.c')
-rw-r--r--src/osmo-bsc/smscb.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/osmo-bsc/smscb.c b/src/osmo-bsc/smscb.c
index 3a06697cf..8e2eb0c05 100644
--- a/src/osmo-bsc/smscb.c
+++ b/src/osmo-bsc/smscb.c
@@ -70,9 +70,7 @@ static int gen_etws_primary_notification(uint8_t *out, uint16_t serial_nr, uint1
osmo_store16be(serial_nr, out);
etws->msg_id = osmo_htons(msg_id);
etws->warning_type = osmo_htons(warn_type);
-
- if (sec_info)
- memcpy(etws->data, sec_info, ETWS_PRIM_NOTIF_SIZE - sizeof(*etws));
+ memcpy(etws->data, sec_info, ETWS_PRIM_NOTIF_SIZE - sizeof(*etws));
return ETWS_PRIM_NOTIF_SIZE;
}
@@ -557,18 +555,11 @@ static int etws_primary_to_bts(struct gsm_bts *bts, const struct osmo_cbsp_write
}
}
- if (bes->input.sec_info) {
- talloc_free(bes->input.sec_info);
- bes->input.sec_info = NULL;
- }
-
/* copy over all the data to per-BTS private state */
bes->input.msg_id = wrepl->msg_id;
bes->input.serial_nr = wrepl->new_serial_nr;
bes->input.warn_type = wrepl->u.emergency.warning_type;
- bes->input.sec_info = talloc_named_const(bts, ETWS_SEC_INFO_SIZE, "etws_sec_info");
- if (bes->input.sec_info)
- memcpy(bes->input.sec_info, wrepl->u.emergency.warning_sec_info, ETWS_SEC_INFO_SIZE);
+ memcpy(bes->input.sec_info, wrepl->u.emergency.warning_sec_info, sizeof(bes->input.sec_info));
/* generate the encoded ETWS PN */
gen_etws_primary_notification(bes->primary, bes->input.serial_nr, bes->input.msg_id,