laforge has uploaded this change for review.
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
---
M include/osmocom/bsc/gsm_data.h
M src/osmo-bsc/smscb.c
2 files changed, 4 insertions(+), 12 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/94/28094/1
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index cb20b9e..6df7c61 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -29,6 +29,7 @@
#include <osmocom/gsm/rxlev_stat.h>
#include <osmocom/gsm/protocol/gsm_08_58.h>
#include <osmocom/gsm/protocol/gsm_12_21.h>
+#include <osmocom/gsm/protocol/gsm_03_41.h>
#include <osmocom/abis/e1_input.h>
#include <osmocom/bsc/meas_rep.h>
#include <osmocom/bsc/acc.h>
@@ -1098,7 +1099,7 @@
uint16_t msg_id;
uint16_t serial_nr;
uint16_t warn_type;
- uint8_t *sec_info;
+ uint8_t sec_info[ETWS_SEC_INFO_SIZE];
} input;
/* encoded ETWS primary notification */
uint8_t primary[ETWS_PRIM_NOTIF_SIZE];
diff --git a/src/osmo-bsc/smscb.c b/src/osmo-bsc/smscb.c
index 3a06697..8e2eb0c 100644
--- a/src/osmo-bsc/smscb.c
+++ b/src/osmo-bsc/smscb.c
@@ -70,9 +70,7 @@
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 @@
}
}
- 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,
To view, visit change 28094. To unsubscribe, or for help writing mail filters, visit settings.