[PATCH] osmo-bts[master]: implement support for 3-digit MNC with leading zeros

2018-03-10 Thread Neels Hofmeyr
Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6665

to look at the new patch set (#4).

implement support for 3-digit MNC with leading zeros

Record the mnc_3_digits flag from SI and pass on via the PCU interface.

Instead of changing to e.g. osmo_plmn_id, add the flag separately, and instead
of bool use a uint8_t, to not raise any struct packing issues and clarify the
flag's size beyond any doubt.

Bump the PCU interface version to 9.
This is one part of the three identical pcuif_proto.h patches:
- I49cd762c3c9d7ee6a82451bdf3ffa2a060767947 (osmo-bts)
- I787fed84a7b613158a5618dd5cffafe4e4927234 (osmo-pcu)
- I78f30aef7aa224b2e9db54c3a844d8f520b3aee0 (osmo-bsc)

Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore)
Change-Id: I49cd762c3c9d7ee6a82451bdf3ffa2a060767947
---
M include/osmo-bts/gsm_data.h
M include/osmo-bts/pcuif_proto.h
M src/common/pcu_sock.c
3 files changed, 11 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/65/6665/4

diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index 10c9d04..1652104 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -4,6 +4,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -29,7 +30,7 @@
 struct gsm_network {
struct llist_head bts_list;
unsigned int num_bts;
-   uint16_t mcc, mnc;
+   struct osmo_plmn_id plmn;
struct pcu_sock_state *pcu_state;
 };
 
diff --git a/include/osmo-bts/pcuif_proto.h b/include/osmo-bts/pcuif_proto.h
index 00b7bd5..b06077c 100644
--- a/include/osmo-bts/pcuif_proto.h
+++ b/include/osmo-bts/pcuif_proto.h
@@ -5,7 +5,7 @@
 
 #define PCU_SOCK_DEFAULT   "/tmp/pcu_bts"
 
-#define PCU_IF_VERSION 0x08
+#define PCU_IF_VERSION 0x09
 #define TXT_MAX_LEN128
 
 /* msg_type */
@@ -122,7 +122,9 @@
struct gsm_pcu_if_info_trx trx[8];  /* TRX infos per BTS */
uint8_t bsic;
/* RAI */
-   uint16_tmcc, mnc, lac, rac;
+   uint16_tmcc, mnc;
+   uint8_t mnc_3_digits;
+   uint16_tlac, rac;
/* NSE */
uint16_tnsei;
uint8_t nse_timer[7];
diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index 0f4c053..949a5fa 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -143,8 +144,9 @@
info_ind->flags |= PCU_IF_FLAG_SYSMO;
 
/* RAI */
-   info_ind->mcc = net->mcc;
-   info_ind->mnc = net->mnc;
+   info_ind->mcc = net->plmn.mcc;
+   info_ind->mnc = net->plmn.mnc;
+   info_ind->mnc_3_digits = net->plmn.mnc_3_digits;
info_ind->lac = bts->location_area_code;
info_ind->rac = bts->gprs.rac;
 
@@ -254,14 +256,7 @@
break;
si3 = (struct gsm48_system_information_type_3 *)
bts->si_buf[SYSINFO_TYPE_3];
-   net->mcc = ((si3->lai.digits[0] & 0x0f) << 8)
-   | (si3->lai.digits[0] & 0xf0)
-   | (si3->lai.digits[1] & 0x0f);
-   net->mnc = ((si3->lai.digits[2] & 0x0f) << 8)
-   | (si3->lai.digits[2] & 0xf0)
-   | ((si3->lai.digits[1] & 0xf0) >> 4);
-   if ((net->mnc & 0x00f) == 0x00f)
-   net->mnc >>= 4;
+   osmo_plmn_from_bcd(si3->lai.digits, >plmn);
bts->location_area_code = ntohs(si3->lai.lac);
bts->cell_identity = si3->cell_identity;
avail_lai = 1;

-- 
To view, visit https://gerrit.osmocom.org/6665
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I49cd762c3c9d7ee6a82451bdf3ffa2a060767947
Gerrit-PatchSet: 4
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


[PATCH] osmo-bts[master]: implement support for 3-digit MNC with leading zeros

2018-02-27 Thread Neels Hofmeyr
Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6665

to look at the new patch set (#2).

implement support for 3-digit MNC with leading zeros

Record the mnc_3_digits flag from SI and pass on via the PCU interface.

Bump the PCU interface version from 7 to 9, since osmo-bsc.git had a pcuif of
version 8 already, and its addition of the mnc_3_digits flag bumped to 9. I am
actually not sure whether this needs to match.
See I78f30aef7aa224b2e9db54c3a844d8f520b3aee0

Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore)
Change-Id: I49cd762c3c9d7ee6a82451bdf3ffa2a060767947
---
M include/osmo-bts/gsm_data.h
M include/osmo-bts/pcuif_proto.h
M src/common/pcu_sock.c
3 files changed, 11 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/65/6665/2

diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index f2574b1..62b9427 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -4,6 +4,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -29,7 +30,7 @@
 struct gsm_network {
struct llist_head bts_list;
unsigned int num_bts;
-   uint16_t mcc, mnc;
+   struct osmo_plmn_id plmn;
struct pcu_sock_state *pcu_state;
 };
 
diff --git a/include/osmo-bts/pcuif_proto.h b/include/osmo-bts/pcuif_proto.h
index 88dc09e..5eb5e20 100644
--- a/include/osmo-bts/pcuif_proto.h
+++ b/include/osmo-bts/pcuif_proto.h
@@ -3,7 +3,7 @@
 
 #include 
 
-#define PCU_IF_VERSION 0x07
+#define PCU_IF_VERSION 0x09
 #define TXT_MAX_LEN128
 
 /* msg_type */
@@ -103,7 +103,9 @@
struct gsm_pcu_if_info_trx trx[8];  /* TRX infos per BTS */
uint8_t bsic;
/* RAI */
-   uint16_tmcc, mnc, lac, rac;
+   uint16_tmcc, mnc;
+   uint8_t mnc_3_digits;
+   uint16_tlac, rac;
/* NSE */
uint16_tnsei;
uint8_t nse_timer[7];
diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index fa13f24..e56b275 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -143,8 +144,9 @@
info_ind->flags |= PCU_IF_FLAG_SYSMO;
 
/* RAI */
-   info_ind->mcc = net->mcc;
-   info_ind->mnc = net->mnc;
+   info_ind->mcc = net->plmn.mcc;
+   info_ind->mnc = net->plmn.mnc;
+   info_ind->mnc_3_digits = net->plmn.mnc_3_digits;
info_ind->lac = bts->location_area_code;
info_ind->rac = bts->gprs.rac;
 
@@ -254,14 +256,7 @@
break;
si3 = (struct gsm48_system_information_type_3 *)
bts->si_buf[SYSINFO_TYPE_3];
-   net->mcc = ((si3->lai.digits[0] & 0x0f) << 8)
-   | (si3->lai.digits[0] & 0xf0)
-   | (si3->lai.digits[1] & 0x0f);
-   net->mnc = ((si3->lai.digits[2] & 0x0f) << 8)
-   | (si3->lai.digits[2] & 0xf0)
-   | ((si3->lai.digits[1] & 0xf0) >> 4);
-   if ((net->mnc & 0x00f) == 0x00f)
-   net->mnc >>= 4;
+   osmo_plmn_from_bcd(si3->lai.digits, >plmn);
bts->location_area_code = ntohs(si3->lai.lac);
bts->cell_identity = si3->cell_identity;
avail_lai = 1;

-- 
To view, visit https://gerrit.osmocom.org/6665
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I49cd762c3c9d7ee6a82451bdf3ffa2a060767947
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bts[master]: implement support for 3-digit MNC with leading zeros

2018-02-21 Thread Neels Hofmeyr

Review at  https://gerrit.osmocom.org/6665

implement support for 3-digit MNC with leading zeros

Record the mnc_3_digits flag from SI and pass on via the PCU interface.

Bump the PCU interface version from 7 to 9, since osmo-bsc.git had a pcuif of
version 8 already, and its addition of the mnc_3_digits flag bumped to 9. I am
actually not sure whether this needs to match.
See I78f30aef7aa224b2e9db54c3a844d8f520b3aee0

Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore)
Change-Id: I49cd762c3c9d7ee6a82451bdf3ffa2a060767947
---
M include/osmo-bts/gsm_data.h
M include/osmo-bts/pcuif_proto.h
M src/common/pcu_sock.c
3 files changed, 7 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/65/6665/1

diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index 853b445..0f2f75a 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -30,6 +30,7 @@
struct llist_head bts_list;
unsigned int num_bts;
uint16_t mcc, mnc;
+   bool mnc_3_digits;
struct pcu_sock_state *pcu_state;
 };
 
diff --git a/include/osmo-bts/pcuif_proto.h b/include/osmo-bts/pcuif_proto.h
index 88dc09e..5eb5e20 100644
--- a/include/osmo-bts/pcuif_proto.h
+++ b/include/osmo-bts/pcuif_proto.h
@@ -3,7 +3,7 @@
 
 #include 
 
-#define PCU_IF_VERSION 0x07
+#define PCU_IF_VERSION 0x09
 #define TXT_MAX_LEN128
 
 /* msg_type */
@@ -103,7 +103,9 @@
struct gsm_pcu_if_info_trx trx[8];  /* TRX infos per BTS */
uint8_t bsic;
/* RAI */
-   uint16_tmcc, mnc, lac, rac;
+   uint16_tmcc, mnc;
+   uint8_t mnc_3_digits;
+   uint16_tlac, rac;
/* NSE */
uint16_tnsei;
uint8_t nse_timer[7];
diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index fa13f24..9e84170 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -145,6 +145,7 @@
/* RAI */
info_ind->mcc = net->mcc;
info_ind->mnc = net->mnc;
+   info_ind->mnc_3_digits = net->mnc_3_digits;
info_ind->lac = bts->location_area_code;
info_ind->rac = bts->gprs.rac;
 
@@ -254,14 +255,7 @@
break;
si3 = (struct gsm48_system_information_type_3 *)
bts->si_buf[SYSINFO_TYPE_3];
-   net->mcc = ((si3->lai.digits[0] & 0x0f) << 8)
-   | (si3->lai.digits[0] & 0xf0)
-   | (si3->lai.digits[1] & 0x0f);
-   net->mnc = ((si3->lai.digits[2] & 0x0f) << 8)
-   | (si3->lai.digits[2] & 0xf0)
-   | ((si3->lai.digits[1] & 0xf0) >> 4);
-   if ((net->mnc & 0x00f) == 0x00f)
-   net->mnc >>= 4;
+   gsm48_mcc_mnc_from_bcd2(si3->lai.digits, >mcc, >mnc, 
>mnc_3_digits);
bts->location_area_code = ntohs(si3->lai.lac);
bts->cell_identity = si3->cell_identity;
avail_lai = 1;

-- 
To view, visit https://gerrit.osmocom.org/6665
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I49cd762c3c9d7ee6a82451bdf3ffa2a060767947
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr