[MERGED] libosmocore[master]: implement support for 3-digit MNC with leading zeros

2018-02-28 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: implement support for 3-digit MNC with leading zeros
..


implement support for 3-digit MNC with leading zeros

Enable representing three-digit MNC with leading zeros. The MNCs 23 and 023 are
actually different; so far we treated both as 23. Re-encode an incoming BCD or
string of 023 as it were, i.e. not dropping the leading zero as 23.

Break ABI compatibility by changing the size and ordering of structs
gprs_ra_id, osmo_plmn_id, osmo_cell_global_id, ... by adding an mnc_3_digits
flag.

Change ordering in gprs_ra_id because the canonical oder is {Mobile Country
Code, Mobile Network Code}, so have the mcc member first.

ABI compatibility cannot be maintained for struct gprs_ra_id, since it is a
direct member of structs bssgp_bvc_ctx and bssgp_paging_info, and even just
adding a flag to the end would cause ABI changes of those structs. Similarly,
osmo_plmn_id is a direct member of osmo_location_area_id, and so forth.

Add new API to set and read this additional flag to preserve leading zeros:
- osmo_plmn_to_bcd(), osmo_plmn_from_bcd() after
  gsm48_mcc_mnc_to_bcd() and gsm48_mcc_mnc_from_bcd().
- gsm48_decode_lai2(), gsm48_generate_lai2() after
  gsm48_decode_lai(), gsm48_generate_lai().
- gsm0808_create_layer3_2() after gsm0808_create_layer3() and 
gsm0808_create_layer3_aoip().
- various osmo_*_name() functions in gsm23003.h (osmo_rai_name() still in
  gsm48.h close to struct gprs_ra_id definition). The amount and duplication of
  these may seem a bit overboard, but IMO they do make sense in this way.
  Though most code will soon see patches unifying the data structures used, in
  some cases (vty, ctrl) they are required singled out. Without these
  functions, the formatting ("%0*u", mnc_3_digits ?  3 : 2, mnc) would be
  duplicated all over our diverse repositories.

In various log output, include the leading MNC zeros.

Mark one TODO in card_fs_sim.c, I am not sure how to communicate a leading zero
to/from a SIM card FS. The focus here is on the core network / BSS.

To indicate ABI incompatibility, bump libosmogsm and libosmogb LIBVERSIONs;
adjust debian files accordingly.

Implementation choices:

- The default behavior upon zero-initialization will be the mnc_3_digits flag
  set to false, which yields exactly the previous behavior.

- I decided against packing the mnc with the mnc_3_digits field into a
  sub-struct because it would immediately break all builds of dependent
  projects: it would require immediate merging of numerous patches in other
  repositories, and it would make compiling older code against a newer
  libosmocore unneccessarily hard.

Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
---
M debian/control
R debian/libosmogb6.install
R debian/libosmogsm9.install
M include/osmocom/gsm/gsm0808.h
M include/osmocom/gsm/gsm23003.h
M include/osmocom/gsm/gsm48.h
M src/gb/Makefile.am
M src/gb/gprs_bssgp.c
M src/gb/gprs_bssgp_vty.c
M src/gsm/Makefile.am
M src/gsm/gsm0808.c
M src/gsm/gsm23003.c
M src/gsm/gsm48.c
M src/gsm/libosmogsm.map
M src/sim/card_fs_sim.c
15 files changed, 277 insertions(+), 75 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/debian/control b/debian/control
index 596c3f1..d911f32 100644
--- a/debian/control
+++ b/debian/control
@@ -28,8 +28,8 @@
 Depends: libosmocodec0 (= ${binary:Version}),
  libosmocoding0 (= ${binary:Version}),
  libosmocore9 (= ${binary:Version}),
- libosmogb5 (= ${binary:Version}),
- libosmogsm8 (= ${binary:Version}),
+ libosmogb6 (= ${binary:Version}),
+ libosmogsm9 (= ${binary:Version}),
  libosmovty4 (= ${binary:Version}),
  libosmoctrl1 (= ${binary:Version}),
  libosmosim0 (= ${binary:Version}),
@@ -146,7 +146,7 @@
  .
  This package contains the documentation for the libosmocore library.
 
-Package: libosmogb5
+Package: libosmogb6
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -167,7 +167,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogb5,
+ libosmogb6,
  libjs-jquery
 Description: Documentation for the Osmo GPRS Gb library
  This is part of the libosmocore "meta"-library. The libosmocore library
@@ -178,7 +178,7 @@
  .
  This package contains the documentation for the libosmogb library.
 
-Package: libosmogsm8
+Package: libosmogsm9
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -202,7 +202,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogsm8,
+ libosmogsm9,
  libjs-jquery
 Description: Documentation for the Osmo GSM utility library
  This is part of the libosmocore "meta"-library. The libosmocore library
diff --git a/debian/libosmogb5.install b/debian/libosmogb6.install
similarity index 100%
rename from debian/libosmogb5.install
rename to 

libosmocore[master]: implement support for 3-digit MNC with leading zeros

2018-02-28 Thread Harald Welte

Patch Set 7: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
Gerrit-PatchSet: 7
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


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

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

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

https://gerrit.osmocom.org/6659

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

implement support for 3-digit MNC with leading zeros

Enable representing three-digit MNC with leading zeros. The MNCs 23 and 023 are
actually different; so far we treated both as 23. Re-encode an incoming BCD or
string of 023 as it were, i.e. not dropping the leading zero as 23.

Break ABI compatibility by changing the size and ordering of structs
gprs_ra_id, osmo_plmn_id, osmo_cell_global_id, ... by adding an mnc_3_digits
flag.

Change ordering in gprs_ra_id because the canonical oder is {Mobile Country
Code, Mobile Network Code}, so have the mcc member first.

ABI compatibility cannot be maintained for struct gprs_ra_id, since it is a
direct member of structs bssgp_bvc_ctx and bssgp_paging_info, and even just
adding a flag to the end would cause ABI changes of those structs. Similarly,
osmo_plmn_id is a direct member of osmo_location_area_id, and so forth.

Add new API to set and read this additional flag to preserve leading zeros:
- osmo_plmn_to_bcd(), osmo_plmn_from_bcd() after
  gsm48_mcc_mnc_to_bcd() and gsm48_mcc_mnc_from_bcd().
- gsm48_decode_lai2(), gsm48_generate_lai2() after
  gsm48_decode_lai(), gsm48_generate_lai().
- gsm0808_create_layer3_2() after gsm0808_create_layer3() and 
gsm0808_create_layer3_aoip().
- various osmo_*_name() functions in gsm23003.h (osmo_rai_name() still in
  gsm48.h close to struct gprs_ra_id definition). The amount and duplication of
  these may seem a bit overboard, but IMO they do make sense in this way.
  Though most code will soon see patches unifying the data structures used, in
  some cases (vty, ctrl) they are required singled out. Without these
  functions, the formatting ("%0*u", mnc_3_digits ?  3 : 2, mnc) would be
  duplicated all over our diverse repositories.

In various log output, include the leading MNC zeros.

Mark one TODO in card_fs_sim.c, I am not sure how to communicate a leading zero
to/from a SIM card FS. The focus here is on the core network / BSS.

To indicate ABI incompatibility, bump libosmogsm and libosmogb LIBVERSIONs;
adjust debian files accordingly.

Implementation choices:

- The default behavior upon zero-initialization will be the mnc_3_digits flag
  set to false, which yields exactly the previous behavior.

- I decided against packing the mnc with the mnc_3_digits field into a
  sub-struct because it would immediately break all builds of dependent
  projects: it would require immediate merging of numerous patches in other
  repositories, and it would make compiling older code against a newer
  libosmocore unneccessarily hard.

Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
---
M debian/control
R debian/libosmogb6.install
R debian/libosmogsm9.install
M include/osmocom/gsm/gsm0808.h
M include/osmocom/gsm/gsm23003.h
M include/osmocom/gsm/gsm48.h
M src/gb/Makefile.am
M src/gb/gprs_bssgp.c
M src/gb/gprs_bssgp_vty.c
M src/gsm/Makefile.am
M src/gsm/gsm0808.c
M src/gsm/gsm23003.c
M src/gsm/gsm48.c
M src/gsm/libosmogsm.map
M src/sim/card_fs_sim.c
15 files changed, 277 insertions(+), 75 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/59/6659/7

diff --git a/debian/control b/debian/control
index 596c3f1..d911f32 100644
--- a/debian/control
+++ b/debian/control
@@ -28,8 +28,8 @@
 Depends: libosmocodec0 (= ${binary:Version}),
  libosmocoding0 (= ${binary:Version}),
  libosmocore9 (= ${binary:Version}),
- libosmogb5 (= ${binary:Version}),
- libosmogsm8 (= ${binary:Version}),
+ libosmogb6 (= ${binary:Version}),
+ libosmogsm9 (= ${binary:Version}),
  libosmovty4 (= ${binary:Version}),
  libosmoctrl1 (= ${binary:Version}),
  libosmosim0 (= ${binary:Version}),
@@ -146,7 +146,7 @@
  .
  This package contains the documentation for the libosmocore library.
 
-Package: libosmogb5
+Package: libosmogb6
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -167,7 +167,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogb5,
+ libosmogb6,
  libjs-jquery
 Description: Documentation for the Osmo GPRS Gb library
  This is part of the libosmocore "meta"-library. The libosmocore library
@@ -178,7 +178,7 @@
  .
  This package contains the documentation for the libosmogb library.
 
-Package: libosmogsm8
+Package: libosmogsm9
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -202,7 +202,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogsm8,
+ libosmogsm9,
  libjs-jquery
 Description: Documentation for the Osmo GSM utility library
  This is part of the libosmocore "meta"-library. The libosmocore library
diff --git a/debian/libosmogb5.install b/debian/libosmogb6.install
similarity index 100%
rename from debian/libosmogb5.install
rename to debian/libosmogb6.install
diff --git 

libosmocore[master]: implement support for 3-digit MNC with leading zeros

2018-02-27 Thread Neels Hofmeyr

Patch Set 6:

(1 comment)

https://gerrit.osmocom.org/#/c/6659/6/include/osmocom/gsm/gsm48.h
File include/osmocom/gsm/gsm48.h:

Line 37: void osmo_decode_lai(const struct gsm48_loc_area_id *lai, struct 
osmo_location_area_id *decoded);
> now here we have functions specific to the encoding/decoding of GSM04.08 bu
going back to gsm48_{generate,decode}_lai2() then ... I kinda liked the osmo_ 
prefix, "into the future", but ok


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
Gerrit-PatchSet: 6
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: Yes


libosmocore[master]: implement support for 3-digit MNC with leading zeros

2018-02-27 Thread Harald Welte

Patch Set 6: Code-Review-1

(1 comment)

https://gerrit.osmocom.org/#/c/6659/6/include/osmocom/gsm/gsm48.h
File include/osmocom/gsm/gsm48.h:

Line 37: void osmo_decode_lai(const struct gsm48_loc_area_id *lai, struct 
osmo_location_area_id *decoded);
now here we have functions specific to the encoding/decoding of GSM04.08 but 
there is no gsm48 in the name.  This is wrong.  A *generic* function not 
related to any spcecific encoding can just have an osmo_ prefix.  But a 
function for gsm04.08 should have osmo_gsm48 or (better, to align with existing 
API) simply gsm48_ prefix.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
Gerrit-PatchSet: 6
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: Yes


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

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

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

https://gerrit.osmocom.org/6659

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

implement support for 3-digit MNC with leading zeros

Enable representing three-digit MNC with leading zeros. The MNCs 23 and 023 are
actually different; so far we treated both as 23. Re-encode an incoming BCD or
string of 023 as it were, i.e. not dropping the leading zero as 23.

Break ABI compatibility by changing the size and ordering of structs
gprs_ra_id, osmo_plmn_id, osmo_cell_global_id, ... by adding an mnc_3_digits
flag.

Change ordering in gprs_ra_id because the canonical oder is {Mobile Country
Code, Mobile Network Code}, so have the mcc member first.

ABI compatibility cannot be maintained for struct gprs_ra_id, since it is a
direct member of structs bssgp_bvc_ctx and bssgp_paging_info, and even just
adding a flag to the end would cause ABI changes of those structs. Similarly,
osmo_plmn_id is a direct member of osmo_location_area_id, and so forth.

Add new API to set and read this additional flag to preserve leading zeros:
- osmo_plmn_to_bcd(), osmo_plmn_from_bcd() after
  gsm48_mcc_mnc_to_bcd() and gsm48_mcc_mnc_from_bcd().
- osmo_decode_lai(), osmo_generate_lai() after
  gsm48_decode_lai(), gsm48_generate_lai().
- gsm0808_create_layer3_2() after gsm0808_create_layer3() and 
gsm0808_create_layer3_aoip().
- various osmo_*_name() functions in gsm23003.h (osmo_rai_name() still in
  gsm48.h close to struct gprs_ra_id definition). The amount and duplication of
  these may seem a bit overboard, but IMO they do make sense in this way.
  Though most code will soon see patches unifying the data structures used, in
  some cases (vty, ctrl) they are required singled out. Without these
  functions, the formatting ("%0*u", mnc_3_digits ?  3 : 2, mnc) would be
  duplicated all over our diverse repositories.

In various log output, include the leading MNC zeros.

Mark one TODO in card_fs_sim.c, I am not sure how to communicate a leading zero
to/from a SIM card FS. The focus here is on the core network / BSS.

To indicate ABI incompatibility, bump libosmogsm and libosmogb LIBVERSIONs;
adjust debian files accordingly.

Implementation choices:

- The default behavior upon zero-initialization will be the mnc_3_digits flag
  set to false, which yields exactly the previous behavior.

- I decided against packing the mnc with the mnc_3_digits field into a
  sub-struct because it would immediately break all builds of dependent
  projects: it would require immediate merging of numerous patches in other
  repositories, and it would make compiling older code against a newer
  libosmocore unneccessarily hard.

Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
---
M debian/control
R debian/libosmogb6.install
R debian/libosmogsm9.install
M include/osmocom/gsm/gsm0808.h
M include/osmocom/gsm/gsm23003.h
M include/osmocom/gsm/gsm48.h
M src/gb/Makefile.am
M src/gb/gprs_bssgp.c
M src/gb/gprs_bssgp_vty.c
M src/gsm/Makefile.am
M src/gsm/gsm0808.c
M src/gsm/gsm23003.c
M src/gsm/gsm48.c
M src/gsm/libosmogsm.map
M src/sim/card_fs_sim.c
15 files changed, 277 insertions(+), 75 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/59/6659/6

diff --git a/debian/control b/debian/control
index 596c3f1..d911f32 100644
--- a/debian/control
+++ b/debian/control
@@ -28,8 +28,8 @@
 Depends: libosmocodec0 (= ${binary:Version}),
  libosmocoding0 (= ${binary:Version}),
  libosmocore9 (= ${binary:Version}),
- libosmogb5 (= ${binary:Version}),
- libosmogsm8 (= ${binary:Version}),
+ libosmogb6 (= ${binary:Version}),
+ libosmogsm9 (= ${binary:Version}),
  libosmovty4 (= ${binary:Version}),
  libosmoctrl1 (= ${binary:Version}),
  libosmosim0 (= ${binary:Version}),
@@ -146,7 +146,7 @@
  .
  This package contains the documentation for the libosmocore library.
 
-Package: libosmogb5
+Package: libosmogb6
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -167,7 +167,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogb5,
+ libosmogb6,
  libjs-jquery
 Description: Documentation for the Osmo GPRS Gb library
  This is part of the libosmocore "meta"-library. The libosmocore library
@@ -178,7 +178,7 @@
  .
  This package contains the documentation for the libosmogb library.
 
-Package: libosmogsm8
+Package: libosmogsm9
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -202,7 +202,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogsm8,
+ libosmogsm9,
  libjs-jquery
 Description: Documentation for the Osmo GSM utility library
  This is part of the libosmocore "meta"-library. The libosmocore library
diff --git a/debian/libosmogb5.install b/debian/libosmogb6.install
similarity index 100%
rename from debian/libosmogb5.install
rename to debian/libosmogb6.install
diff --git a/debian/libosmogsm8.install 

libosmocore[master]: implement support for 3-digit MNC with leading zeros

2018-02-26 Thread Harald Welte

Patch Set 5:

I think all (new) functions not dealing with a ts 04.08 encoding should go to 
the 23.003 source file

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
Gerrit-PatchSet: 5
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


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

2018-02-26 Thread Neels Hofmeyr
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/6659

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

implement support for 3-digit MNC with leading zeros

Enable representing three-digit MNC with leading zeros. The MNCs 23 and 023 are
actually different; so far we treated both as 23. Re-encode an incoming BCD or
string of 023 as it were, i.e. not dropping the leading zero as 23.

Break ABI compatibility by changing the size and ordering of structs
gprs_ra_id, osmo_plmn_id, osmo_cell_global_id, ... by adding an mnc_3_digits
flag.

Change ordering in gprs_ra_id because the canonical oder is {Mobile Country
Code, Mobile Network Code}, so have the mcc member first.

ABI compatibility cannot be maintained for struct gprs_ra_id, since it is a
direct member of structs bssgp_bvc_ctx and bssgp_paging_info, and even just
adding a flag to the end would cause ABI changes of those structs. Similarly,
osmo_plmn_id is a direct member of osmo_location_area_id, and so forth.

Add new API to set and read this additional flag to preserve leading zeros:
- osmo_plmn_to_bcd(), osmo_plmn_from_bcd() after
  gsm48_mcc_mnc_to_bcd() and gsm48_mcc_mnc_from_bcd().
- gsm0808_create_layer3_aoip2() after gsm0808_create_layer3_aoip().
- osmo_decode_lai(), osmo_generate_lai() after
  gsm48_decode_lai(), gsm48_generate_lai().
- gsm0808_create_layer3_2() after gsm0808_create_layer3() and 
gsm0808_create_layer3_aoip().
- various osmo_*_name() functions. The amount and duplication of these may seem
  a bit overboard, but IMO they do make sense in this way. The root reason is
  that the use of MCC and MNC is quite diverse throughout the osmocom code
  base: in certain code, they are single uint16_t, in others they are embedded
  in structs along with lac and rac; sometimes, all should be printed in one go
  (repeatedly), in other cases (vty, ctrl) they are required singled out.
  Without these functions, the formatting ("%0*u", mnc_3_digits ? 3 : 2, mnc)
  would be duplicated all over our diverse repositories, or printing
  MCC-MNC or RAI would otherwise end up to be more code.

In various log output, include the leading MNC zeros.

Mark one TODO in card_fs_sim.c, I am not sure how to communicate a leading zero
to/from a SIM card FS. The focus here is on the core network / BSS.

To indicate ABI incompatibility, bump libosmogsm and libosmogb LIBVERSIONs;
adjust debian files accordingly.

Implementation choices:

- The default behavior upon zero-initialization will be the mnc_3_digits flag
  set to false, which yields exactly the previous behavior.

- I decided against packing the mnc with the mnc_3_digits field into a
  sub-struct because it would immediately break all builds of dependent
  projects: it would require immediate merging of numerous patches in other
  repositories, and it would make compiling older code against a newer
  libosmocore unneccessarily hard.

Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
---
M debian/control
R debian/libosmogb6.install
R debian/libosmogsm9.install
M include/osmocom/gsm/gsm0808.h
M include/osmocom/gsm/gsm23003.h
M include/osmocom/gsm/gsm48.h
M src/gb/Makefile.am
M src/gb/gprs_bssgp.c
M src/gb/gprs_bssgp_vty.c
M src/gsm/Makefile.am
M src/gsm/gsm0808.c
M src/gsm/gsm48.c
M src/gsm/libosmogsm.map
M src/sim/card_fs_sim.c
14 files changed, 246 insertions(+), 45 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/59/6659/5

diff --git a/debian/control b/debian/control
index 596c3f1..d911f32 100644
--- a/debian/control
+++ b/debian/control
@@ -28,8 +28,8 @@
 Depends: libosmocodec0 (= ${binary:Version}),
  libosmocoding0 (= ${binary:Version}),
  libosmocore9 (= ${binary:Version}),
- libosmogb5 (= ${binary:Version}),
- libosmogsm8 (= ${binary:Version}),
+ libosmogb6 (= ${binary:Version}),
+ libosmogsm9 (= ${binary:Version}),
  libosmovty4 (= ${binary:Version}),
  libosmoctrl1 (= ${binary:Version}),
  libosmosim0 (= ${binary:Version}),
@@ -146,7 +146,7 @@
  .
  This package contains the documentation for the libosmocore library.
 
-Package: libosmogb5
+Package: libosmogb6
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -167,7 +167,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogb5,
+ libosmogb6,
  libjs-jquery
 Description: Documentation for the Osmo GPRS Gb library
  This is part of the libosmocore "meta"-library. The libosmocore library
@@ -178,7 +178,7 @@
  .
  This package contains the documentation for the libosmogb library.
 
-Package: libosmogsm8
+Package: libosmogsm9
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -202,7 +202,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogsm8,
+ libosmogsm9,
  libjs-jquery
 Description: Documentation for the Osmo GSM utility library
  This is part of the libosmocore "meta"-library. The libosmocore library

libosmocore[master]: implement support for 3-digit MNC with leading zeros

2018-02-26 Thread Neels Hofmeyr

Patch Set 4:

> Ok, agreed.  However, for new API functions introduced, like
 > gsm0808_create_layer3_aoip2 in your patch, I would like to see them
 > take an aggregate structure as input, rather than an endless list
 > of function arguments.  If we create a new function/symbol, we
 > don't have to hand mcc/mnc/lac/ci/... as individual arguments
 > anymore.  Does that make sense?

Yes ok, makes sense. And btw, how about dropping the _aoip? If it's going to be 
a general function for AoIP and non-AoIP depending on arg being NULL or not, I 
guess I'll rather not call it _aoip.

Also osmo_cell_global_id is a good pick, I was just reminded of it looking at 
stsp's cell identifier list patch. We seem to have some separate ecosystems for 
all of the PLMN/LAC/RAC/CI things :) osmo_cell_global_id and its siblings seem 
the most sensible ones...

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


libosmocore[master]: implement support for 3-digit MNC with leading zeros

2018-02-26 Thread Harald Welte

Patch Set 4:

(1 comment)

https://gerrit.osmocom.org/#/c/6659/4/include/osmocom/gsm/gsm0808.h
File include/osmocom/gsm/gsm0808.h:

Line 40: uint16_t mcc, int lac, 
uint16_t _ci,
in this example, struct osmo_cell_global_id seems a good alternative. It 
appears to contain all of mnc/mnc_3_digits, mcc, lac, ci.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: Yes


libosmocore[master]: implement support for 3-digit MNC with leading zeros

2018-02-26 Thread Harald Welte

Patch Set 4:

Ok, agreed.  However, for new API functions introduced, like 
gsm0808_create_layer3_aoip2 in your patch, I would like to see them take an 
aggregate structure as input, rather than an endless list of function 
arguments.  If we create a new function/symbol, we don't have to hand 
mcc/mnc/lac/ci/... as individual arguments anymore.  Does that make sense?

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


libosmocore[master]: implement support for 3-digit MNC with leading zeros

2018-02-25 Thread Neels Hofmeyr

Patch Set 4:

This is breaking ABI, but not API. In the commit log, I wrote:

  - I decided against packing the mnc with the mnc_3_digits field into a 
sub-struct because it would enlarge this patch; plus, with a separate flag, 
current code can decide when to start heeding leading zeros. 

Maybe that wasn't clear enough, let me strengthen that case:

If we pack mnc+flag into a sub-struct, as soon as we merge that patch to 
libosmocore master, all of our projects flare up red and stop building. Keeping 
the 'mnc' member as it were and just adding a flag alongside allows us to 
tackle each code base when we're ready to use the flag. It would be quite a 
stunt to have all of the patches ready in gerrit before merging the libosmocore 
one; and we're making compiling old code against new libosmocore hard, 
unnecessarily so.

If we decide to indeed go for a new struct packing the mnc+flag or a string as 
it were, I'd also go the extra mile and actually "bump" the names of all the 
structs using it, i.e. introducing struct gprs_ra_id2, struct bssgp_bvc_ctx2, 
struct bssgp_paging_info2 etc. In that case we would be both API *and* ABI 
compatible (-- I'd have gone that way, the only reason I'm not doing it is 
because you said to rather bump ABI instead).

Either way, I would discourage changing the current structs in ways that the 
current dependent code cannot compile as-is.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


libosmocore[master]: implement support for 3-digit MNC with leading zeros

2018-02-25 Thread Harald Welte

Patch Set 4:

I think it would make sense to introuce a new 'struct gsm_mcc' or the like to 
encapsulate the uint16_t + bool flag and then use that as function argument 
rather than always having a mnc _and_ a 'bool thre_digits' argument.

Or even start to treat the MNC as a string in the libosmo* API? The [NUL 
terminated] string carries length information with it implicitly. Or something 
like a 'char[4]' which has space for 2/3-digit MNC plus terminating NUL?

I mean, as we're breaking the API/ABI anyway, we can mals ake it comfortable 
for the API user, not harder.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


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

2018-02-24 Thread Neels Hofmeyr
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/6659

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

implement support for 3-digit MNC with leading zeros

Enable representing three-digit MNC with leading zeros. The MNCs 23 and 023 are
actually different; so far we treated both as 23. Re-encode an incoming BCD or
string of 023 as it were, i.e. not dropping the leading zero as 23.

Break ABI compatibility by changing the size and ordering of struct gprs_ra_id.
Ordering is changed because the canonical oder is {Mobile Country Code, Mobile
Network Code}, so have the mcc member first. Change size (and ordering) by
inserting a flag to indicate a three-digit MNC after the mnc member. ABI
compatibility cannot be maintained, since struct gprs_ra_id is a direct member
of structs bssgp_bvc_ctx and bssgp_paging_info, and even just adding a flag to
the end would cause ABI changes of those structs.

Add new API to set and read this additional flag to preserve leading zeros:
- gsm48_mcc_mnc_to_bcd2(), gsm48_mcc_mnc_from_bcd2() after
  gsm48_mcc_mnc_to_bcd() and gsm48_mcc_mnc_from_bcd().
- gsm0808_create_layer3_aoip2() after gsm0808_create_layer3_aoip().
- gsm48_decode_lai2(), gsm48_generate_lai2() after
  gsm48_decode_lai(), gsm48_generate_lai().
- The equivalent of gsm0808_create_layer3() for preserving leading zeros is
  gsm0808_create_layer3_aoip2() with the scl argument passed as NULL; instead
  of introducing a new shim function like gsm0808_create_layer3_2(), indicate
  such in the API docs, only.
- gsm48_mnc_from_str() to encode leading zeros from string, useful for VTY
  config parsing.
- gsm48_mnc_cmp() to compare MNC values including leading zeros.
- various osmo_*_name() functions. The amount and seeming duplication of these
  may seem a bit overboard, but IMO they do make sense in this way. The root
  reason is that the use of MCC and MNC is quite diverse throughout the osmocom
  code base: in certain code, they are single uint16_t, in others they are
  embedded in structs along with lac and rac; sometimes, all should be printed
  in one go (repeatedly), in other cases (vty, ctrl) they are required singled
  out. Without these functions, the formatting kind of ("%0*u", mnc_3_digits ?
  3 : 2, mnc) would be duplicated all over our diverse repositories, or
  printing MCC-MNC or RAI would otherwise end up to be more code.

In various log output, include the leading MNC zeros.

Mark one TODO in card_fs_sim.c, I am not sure how to communicate a leading zero
to/from a SIM card FS. The focus here is on the core network / BSS.

To indicate ABI incompatibility, bump libosmogsm and libosmogb LIBVERSIONs;
adjust debian files accordingly.

Implementation choices:

- The default behavior upon zero-initialization will be the mnc_3_digits flag
  set to false, which yields exactly the previous behavior.

- I decided against packing the mnc with the mnc_3_digits field into a
  sub-struct because it would enlarge this patch; plus, with a separate flag,
  current code can decide when to start heeding leading zeros.

Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
---
M debian/control
R debian/libosmogb6.install
R debian/libosmogsm9.install
M include/osmocom/gsm/gsm0808.h
M include/osmocom/gsm/gsm23003.h
M include/osmocom/gsm/gsm48.h
M src/gb/Makefile.am
M src/gb/gprs_bssgp.c
M src/gb/gprs_bssgp_vty.c
M src/gsm/Makefile.am
M src/gsm/gsm0808.c
M src/gsm/gsm48.c
M src/gsm/libosmogsm.map
M src/sim/card_fs_sim.c
14 files changed, 234 insertions(+), 40 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/59/6659/4

diff --git a/debian/control b/debian/control
index 596c3f1..d911f32 100644
--- a/debian/control
+++ b/debian/control
@@ -28,8 +28,8 @@
 Depends: libosmocodec0 (= ${binary:Version}),
  libosmocoding0 (= ${binary:Version}),
  libosmocore9 (= ${binary:Version}),
- libosmogb5 (= ${binary:Version}),
- libosmogsm8 (= ${binary:Version}),
+ libosmogb6 (= ${binary:Version}),
+ libosmogsm9 (= ${binary:Version}),
  libosmovty4 (= ${binary:Version}),
  libosmoctrl1 (= ${binary:Version}),
  libosmosim0 (= ${binary:Version}),
@@ -146,7 +146,7 @@
  .
  This package contains the documentation for the libosmocore library.
 
-Package: libosmogb5
+Package: libosmogb6
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -167,7 +167,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogb5,
+ libosmogb6,
  libjs-jquery
 Description: Documentation for the Osmo GPRS Gb library
  This is part of the libosmocore "meta"-library. The libosmocore library
@@ -178,7 +178,7 @@
  .
  This package contains the documentation for the libosmogb library.
 
-Package: libosmogsm8
+Package: libosmogsm9
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -202,7 +202,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogsm8,
+ 

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

2018-02-21 Thread Neels Hofmeyr

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

implement support for 3-digit MNC with leading zeros

Enable representing three-digit MNC with leading zeros. The MNCs 23 and 023 are
actually different; so far we treated both as 23. Re-encode an incoming BCD or
string of 023 as it were, i.e. not dropping the leading zero as 23.

Break ABI compatibility by changing the size and ordering of struct gprs_ra_id.
Ordering is changed because the canonical oder is {Mobile Country Code, Mobile
Network Code}, so have the mcc member first. Change size (and ordering) by
inserting a flag to indicate a three-digit MNC after the mnc member. ABI
compatibility cannot be maintained, since struct gprs_ra_id is a direct member
of structs bssgp_bvc_ctx and bssgp_paging_info, and even just adding a flag to
the end would cause ABI changes of those structs.

Add new API to set and read this additional flag to preserve leading zeros:
- gsm48_mcc_mnc_to_bcd2(), gsm48_mcc_mnc_from_bcd2() after
  gsm48_mcc_mnc_to_bcd() and gsm48_mcc_mnc_from_bcd().
- gsm0808_create_layer3_aoip2() after gsm0808_create_layer3_aoip().
- gsm48_decode_lai2(), gsm48_generate_lai2() after
  gsm48_decode_lai(), gsm48_generate_lai().
- The equivalent of gsm0808_create_layer3() for preserving leading zeros is
  gsm0808_create_layer3_aoip2() with the scl argument passed as NULL; instead
  of introducing a new shim function like gsm0808_create_layer3_2(), indicate
  such in the API docs, only.
- gsm48_mnc_from_str() to encode leading zeros from string, useful for VTY
  config parsing.
- gsm48_mnc_cmp() to compare MNC values including leading zeros.

In various log output, include the leading MNC zeros.

Mark one TODO in card_fs_sim.c, I am not sure how to communicate a leading zero
to/from a SIM card FS. The focus here is on the core network / BSS.

To indicate ABI incompatibility, bump libosmogsm and libosmogb LIBVERSIONs;
adjust debian files accordingly.

Implementation choices:

- The default behavior upon zero-initialization will be the mnc_3_digits flag
  set to false, which yields exactly the previous behavior.

- I decided against packing the mnc with the mnc_3_digits field into a
  sub-struct because it would enlarge this patch; plus, with a separate flag,
  current code can decide when to start heeding leading zeros.

Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
---
M debian/control
R debian/libosmogb6.install
R debian/libosmogsm9.install
M include/osmocom/gsm/gsm0808.h
M include/osmocom/gsm/gsm23003.h
M include/osmocom/gsm/gsm48.h
M src/gb/Makefile.am
M src/gb/gprs_bssgp.c
M src/gb/gprs_bssgp_vty.c
M src/gsm/Makefile.am
M src/gsm/gsm0808.c
M src/gsm/gsm48.c
M src/gsm/libosmogsm.map
M src/sim/card_fs_sim.c
14 files changed, 234 insertions(+), 40 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/59/6659/1

diff --git a/debian/control b/debian/control
index 596c3f1..d911f32 100644
--- a/debian/control
+++ b/debian/control
@@ -28,8 +28,8 @@
 Depends: libosmocodec0 (= ${binary:Version}),
  libosmocoding0 (= ${binary:Version}),
  libosmocore9 (= ${binary:Version}),
- libosmogb5 (= ${binary:Version}),
- libosmogsm8 (= ${binary:Version}),
+ libosmogb6 (= ${binary:Version}),
+ libosmogsm9 (= ${binary:Version}),
  libosmovty4 (= ${binary:Version}),
  libosmoctrl1 (= ${binary:Version}),
  libosmosim0 (= ${binary:Version}),
@@ -146,7 +146,7 @@
  .
  This package contains the documentation for the libosmocore library.
 
-Package: libosmogb5
+Package: libosmogb6
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -167,7 +167,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogb5,
+ libosmogb6,
  libjs-jquery
 Description: Documentation for the Osmo GPRS Gb library
  This is part of the libosmocore "meta"-library. The libosmocore library
@@ -178,7 +178,7 @@
  .
  This package contains the documentation for the libosmogb library.
 
-Package: libosmogsm8
+Package: libosmogsm9
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -202,7 +202,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogsm8,
+ libosmogsm9,
  libjs-jquery
 Description: Documentation for the Osmo GSM utility library
  This is part of the libosmocore "meta"-library. The libosmocore library
diff --git a/debian/libosmogb5.install b/debian/libosmogb6.install
similarity index 100%
rename from debian/libosmogb5.install
rename to debian/libosmogb6.install
diff --git a/debian/libosmogsm8.install b/debian/libosmogsm9.install
similarity index 100%
rename from debian/libosmogsm8.install
rename to debian/libosmogsm9.install
diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index 3deee70..f0f8a38 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -35,6 +35,10 @@
uint16_t cc, int lac, uint16_t _ci,