diff mbox

[1/2] libbsc: Abstract out SIs update/generation for a BTS into a separate function.

Message ID CABmJbFVvQSeQH1dm-rnX-VHt_OrcsQfQEfPMw8gFK5eVn4BB4A@mail.gmail.com
State Accepted
Headers show

Commit Message

Alexander Chemeris May 30, 2015, 7:42 p.m. UTC
The code to do that doesn't belong to the control interface, so abstract it
out
to a separate function gsm_bts_set_system_infos().

Comments

Holger Freyther June 2, 2015, 6:45 a.m. UTC | #1
> On 30 May 2015, at 21:42, Alexander Chemeris <Alexander.Chemeris@fairwaves.co> wrote:

Dear Alexander,

> The code to do that doesn't belong to the control interface, so abstract it out
> to a separate function gsm_bts_set_system_infos().

please send the patch inline so one can comment on it. I have applied it and fixed
the wrong curly braces. Please attempt to obey the coding-style.

thank you
	holger
Alexander Chemeris June 15, 2015, 7:01 p.m. UTC | #2
On Jun 2, 2015 8:45 AM, "Holger Freyther" <holger@freyther.de> wrote:
>
>
> > On 30 May 2015, at 21:42, Alexander Chemeris <
Alexander.Chemeris@fairwaves.co> wrote:
>
> Dear Alexander,
>
> > The code to do that doesn't belong to the control interface, so
abstract it out
> > to a separate function gsm_bts_set_system_infos().
>
> please send the patch inline so one can comment on it. I have applied it
and fixed
> the wrong curly braces. Please attempt to obey the coding-style.

Thank you. Will send in-line.
Sorry for the coding style. Having switch between a few, I sometimes lose
track of where I am.

--
Regards,
Alexander Chemeris
CEO Fairwaves, Inc.
https://fairwaves.co
diff mbox

Patch

From 235f557b502566e335cd5a71d1272014496d35a1 Mon Sep 17 00:00:00 2001
From: Alexander Chemeris <Alexander.Chemeris@gmail.com>
Date: Sat, 30 May 2015 14:40:54 -0400
Subject: [PATCH 1/2] libbsc: Abstract out SIs update/generation for a BTS into
 a separate function.

The code to do that doesn't belong to the control interface, so abstract it out
to a separate function gsm_bts_set_system_infos().
---
 openbsc/include/openbsc/gsm_data.h     |  1 +
 openbsc/src/libbsc/bsc_ctrl_commands.c | 18 +++++-------------
 openbsc/src/libbsc/bsc_init.c          | 23 ++++++++++++++++++++++-
 3 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index 30a397c..6f7c8dd 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -438,6 +438,7 @@  void gsm_trx_lock_rf(struct gsm_bts_trx *trx, int locked);
 int gsm_bts_has_feature(struct gsm_bts *bts, enum gsm_bts_features feat);
 struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr);
 int gsm_bts_trx_set_system_infos(struct gsm_bts_trx *trx);
+int gsm_bts_set_system_infos(struct gsm_bts *bts);
 
 /* generic E1 line operations for all ISDN-based BTS. */
 extern struct e1inp_line_ops bts_isdn_e1inp_line_ops;
diff --git a/openbsc/src/libbsc/bsc_ctrl_commands.c b/openbsc/src/libbsc/bsc_ctrl_commands.c
index 1d91c5f..b6b1c9a 100644
--- a/openbsc/src/libbsc/bsc_ctrl_commands.c
+++ b/openbsc/src/libbsc/bsc_ctrl_commands.c
@@ -202,20 +202,12 @@  static int get_bts_si(struct ctrl_cmd *cmd, void *data)
 static int set_bts_si(struct ctrl_cmd *cmd, void *data)
 {
 	struct gsm_bts *bts = cmd->node;
-	struct gsm_bts_trx *trx;
+	int rc;
 
-	/* Generate a new ID */
-	bts->bcch_change_mark += 1;
-	bts->bcch_change_mark %= 0x7;
-
-	llist_for_each_entry(trx, &bts->trx_list, list) {
-		int rc;
-
-		rc = gsm_bts_trx_set_system_infos(trx);
-		if (rc != 0) {
-			cmd->reply = "Failed to generate SI";
-			return CTRL_CMD_ERROR;
-		}
+	rc = gsm_bts_set_system_infos(bts);
+	if (rc != 0) {
+		cmd->reply = "Failed to generate SI";
+		return CTRL_CMD_ERROR;
 	}
 
 	cmd->reply = "Generated new System Information";
diff --git a/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c
index a59ab3d..fbfec17 100644
--- a/openbsc/src/libbsc/bsc_init.c
+++ b/openbsc/src/libbsc/bsc_init.c
@@ -120,7 +120,7 @@  static int rsl_si(struct gsm_bts_trx *trx, enum osmo_sysinfo_type i, int si_len)
 	return rc;
 }
 
-/* set all system information types */
+/* set all system information types for a TRX */
 int gsm_bts_trx_set_system_infos(struct gsm_bts_trx *trx)
 {
 	int i, rc;
@@ -197,6 +197,27 @@  err_out:
 	return rc;
 }
 
+/* set all system information types for a BTS */
+int gsm_bts_set_system_infos(struct gsm_bts *bts)
+{
+	struct gsm_bts_trx *trx;
+
+	/* Generate a new ID */
+	bts->bcch_change_mark += 1;
+	bts->bcch_change_mark %= 0x7;
+
+	llist_for_each_entry(trx, &bts->trx_list, list) {
+		int rc;
+
+		rc = gsm_bts_trx_set_system_infos(trx);
+		if (rc != 0) {
+			return rc;
+		}
+	}
+
+	return 0;
+}
+
 /* Produce a MA as specified in 10.5.2.21 */
 static int generate_ma_for_ts(struct gsm_bts_trx_ts *ts)
 {
-- 
1.9.1