Change in osmo-iuh[master]: tests: Missing return statement

2020-02-15 Thread fixeria
fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-iuh/+/17161 )

Change subject: tests: Missing return statement
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-iuh/+/17161
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Change-Id: I4fae9f84a83af280846b07eaa139ff4a05784a2e
Gerrit-Change-Number: 17161
Gerrit-PatchSet: 1
Gerrit-Owner: roox 
Gerrit-Reviewer: fixeria 
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Sat, 15 Feb 2020 22:14:09 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-iuh[master]: tests: Missing return statement

2020-02-15 Thread roox
roox has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-iuh/+/17161 )


Change subject: tests: Missing return statement
..

tests: Missing return statement

Change-Id: I4fae9f84a83af280846b07eaa139ff4a05784a2e
---
M src/tests/hnb-test.c
M src/tests/test_common.c
2 files changed, 2 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/61/17161/1

diff --git a/src/tests/hnb-test.c b/src/tests/hnb-test.c
index 446a14a..27959ec 100644
--- a/src/tests/hnb-test.c
+++ b/src/tests/hnb-test.c
@@ -326,7 +326,7 @@

if (len < sizeof(*ar)) {
printf("GSM48 Auth Req does not fit.\n");
-   return;
+   return -1;
}

printf(" :) Authentication Request :)\n");
diff --git a/src/tests/test_common.c b/src/tests/test_common.c
index eeb0bec..701d581 100644
--- a/src/tests/test_common.c
+++ b/src/tests/test_common.c
@@ -88,6 +88,7 @@

log_set_print_filename(osmo_stderr_target, 0);
log_set_use_color(osmo_stderr_target, 0);
+   return rc;
 }

 void test_common_cleanup(void)

--
To view, visit https://gerrit.osmocom.org/c/osmo-iuh/+/17161
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Change-Id: I4fae9f84a83af280846b07eaa139ff4a05784a2e
Gerrit-Change-Number: 17161
Gerrit-PatchSet: 1
Gerrit-Owner: roox 
Gerrit-MessageType: newchange


Change in osmo-remsim[master]: remsim-client: Move client_config from .c to .h file

2020-02-15 Thread laforge
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/c/osmo-remsim/+/16626

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

Change subject: remsim-client: Move client_config from .c to .h file
..

remsim-client: Move client_config from .c to .h file

Change-Id: I158fe0f2791c164adc74cf851d5a139990bce852
---
M src/client/client.h
M src/client/simtrace2-remsim_client.c
2 files changed, 31 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/26/16626/7
--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/16626
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I158fe0f2791c164adc74cf851d5a139990bce852
Gerrit-Change-Number: 16626
Gerrit-PatchSet: 7
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in osmo-remsim[master]: client: Split into remsim_client.c and remsim_client_main.c

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/17159 )

Change subject: client: Split into remsim_client.c and remsim_client_main.c
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/17159
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: Ie1d21c2cd84756d5c8aa2c41bcc37f5951a3a285
Gerrit-Change-Number: 17159
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:16:26 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-remsim[master]: client: Remove g_client completely; separate 'main' code

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/17158 )

Change subject: client: Remove g_client completely; separate 'main' code
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/17158
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I6456317c3968551cd69ba379c746e4dd9690d02d
Gerrit-Change-Number: 17158
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:16:15 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-remsim[master]: client: Remove g_client completely; separate 'main' code

2020-02-15 Thread laforge
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/c/osmo-remsim/+/17158

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

Change subject: client: Remove g_client completely; separate 'main' code
..

client: Remove g_client completely; separate 'main' code

We may want to use the entire client code independent of the current
'main' portion, so let's introduce separation via API.

Change-Id: I6456317c3968551cd69ba379c746e4dd9690d02d
---
M src/client/client.h
M src/client/remsim_client.c
2 files changed, 92 insertions(+), 60 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/58/17158/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/17158
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I6456317c3968551cd69ba379c746e4dd9690d02d
Gerrit-Change-Number: 17158
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in osmo-remsim[master]: client: Work without global g_client variable

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/17157 )

Change subject: client: Work without global g_client variable
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/17157
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I456fb633561b88912be2f78c3e0264794d921255
Gerrit-Change-Number: 17157
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:15:25 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-remsim[master]: client: Add new osmo-remsim-client-shell binary

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/17156 )

Change subject: client: Add new osmo-remsim-client-shell binary
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/17156
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I636505fd9741833ccf5cbd1bcac30f7b9aa94425
Gerrit-Change-Number: 17156
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:15:11 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-remsim[master]: client: Enable talloc NULL context tracking

2020-02-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/16592 )

Change subject: client: Enable talloc NULL context tracking
..

client: Enable talloc NULL context tracking

Change-Id: I41ac5437e9262cf9e5a6e92db9b733902c91755b
---
M src/simtrace2-remsim_client.c
1 file changed, 3 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/simtrace2-remsim_client.c b/src/simtrace2-remsim_client.c
index 79eb32b..077275a 100644
--- a/src/simtrace2-remsim_client.c
+++ b/src/simtrace2-remsim_client.c
@@ -809,6 +809,8 @@
 {
OSMO_ASSERT(signal == SIGUSR1);
talloc_report_full(g_tall_ctx, stderr);
+   printf("= NULL\n");
+   talloc_report_full(NULL, stderr);
 }

 static void print_welcome(void)
@@ -1000,6 +1002,7 @@

print_welcome();

+   talloc_enable_null_tracking();
g_tall_ctx = talloc_named_const(NULL, 0, "global");
talloc_asn1_ctx = talloc_named_const(g_tall_ctx, 0, "asn1");
msgb_talloc_ctx_init(g_tall_ctx, 0);

--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/16592
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I41ac5437e9262cf9e5a6e92db9b733902c91755b
Gerrit-Change-Number: 16592
Gerrit-PatchSet: 6
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in osmo-remsim[master]: remsim-client: Query + Store the USB device path

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/16628 )

Change subject: remsim-client: Query + Store the USB device path
..


Patch Set 6: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/16628
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I7e707c74647f4c5db06d495d369b2e69e2fc7c97
Gerrit-Change-Number: 16628
Gerrit-PatchSet: 6
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:14:30 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-remsim[master]: remsim_client: Move body of main() loop to separate function

2020-02-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/16622 )

Change subject: remsim_client: Move body of main() loop to separate function
..

remsim_client: Move body of main() loop to separate function

I rally don't like the existing spaghetti-style code.

Change-Id: I85c166e8aa95bb3f2e5d60d14f60caa94f3116fb
---
M src/simtrace2-remsim_client.c
1 file changed, 115 insertions(+), 109 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/simtrace2-remsim_client.c b/src/simtrace2-remsim_client.c
index 077275a..ac78dd4 100644
--- a/src/simtrace2-remsim_client.c
+++ b/src/simtrace2-remsim_client.c
@@ -992,10 +992,120 @@
 }


+static void main_body(struct client_config *cfg)
+{
+   struct st_transport *transp = ci->slot->transp;
+   struct usb_interface_match _ifm, *ifm = &_ifm;
+   int rc;
+
+   ifm->vendor = cfg->usb.vendor_id;
+   ifm->product = cfg->usb.product_id;
+   ifm->configuration = cfg->usb.config_id;
+   ifm->interface = cfg->usb.if_num;
+   ifm->altsetting = cfg->usb.altsetting;
+   ifm->addr = cfg->usb.addr;
+   if (cfg->usb.path)
+   osmo_strlcpy(ifm->path, cfg->usb.path, sizeof(ifm->path));
+   transp->usb_devh = osmo_libusb_open_claim_interface(NULL, NULL, ifm);
+   if (!transp->usb_devh) {
+   fprintf(stderr, "can't open USB device\n");
+   return;
+   }
+
+   rc = libusb_claim_interface(transp->usb_devh, cfg->usb.if_num);
+   if (rc < 0) {
+   fprintf(stderr, "can't claim interface %d; rc=%d\n", 
cfg->usb.if_num, rc);
+   goto close_exit;
+   }
+
+   rc = osmo_libusb_get_ep_addrs(transp->usb_devh, cfg->usb.if_num, 
>usb_ep.out,
+   >usb_ep.in, 
>usb_ep.irq_in);
+   if (rc < 0) {
+   fprintf(stderr, "can't obtain EP addrs; rc=%d\n", rc);
+   goto close_exit;
+   }
+
+   // switch modem SIM port to emulated SIM on OWHW
+   if (USB_VENDOR_OPENMOKO == ifm->vendor && USB_PRODUCT_OWHW_SAM3 == 
ifm->product) { // we are on the OWHW
+   int modem = -1;
+   switch (ifm->interface) { // the USB interface indicates for 
which modem we want to emulate the SIM
+   case 0:
+   modem = 1;
+   break;
+   case 1:
+   modem = 2;
+   break;
+   default:
+   fprintf(stderr, "unknown GPIO for SIMtrace interface 
%d\n", ifm->interface);
+   goto close_exit;
+   }
+   //
+   char gpio_path[PATH_MAX];
+   snprintf(gpio_path, sizeof(gpio_path), 
"/dev/gpio/connect_st_usim%d/value", modem);
+   int connec_st_usim = open(gpio_path, O_WRONLY);
+   if (-1 == connec_st_usim) {
+   fprintf(stderr, "can't open GPIO %s to switch modem %d 
to emulated USIM\n", gpio_path, modem);
+   goto close_exit;
+   }
+   if (1 != write(connec_st_usim, "1", 1)) {
+   fprintf(stderr, "can't write GPIO %s to switch modem %d 
to emulated USIM\n", gpio_path, modem);
+   goto close_exit;
+   }
+   printf("switched modem %d to emulated USIM\n", modem);
+
+   snprintf(gpio_path, sizeof(gpio_path), 
"/dev/gpio/mdm%d_rst/value", modem);
+   int mdm_rst = open(gpio_path, O_WRONLY);
+   if (-1 == mdm_rst) {
+   fprintf(stderr, "can't open GPIO %s to reset modem 
%d\n", gpio_path, modem);
+   goto close_exit;
+   }
+   if (1 != write(mdm_rst, "1", 1)) {
+   fprintf(stderr, "can't write GPIO %s to reset modem 
%d\n", gpio_path, modem);
+   goto close_exit;
+   }
+   sleep(1); // wait a bit to ensure reset is effective
+   if (1 != write(mdm_rst, "0", 1)) {
+   fprintf(stderr, "can't write GPIO %s to reset modem 
%d\n", gpio_path, modem);
+   goto close_exit;
+   }
+   printf("modem %d reset\n", modem);
+   }
+
+   /* request firmware to generate STATUS on IRQ endpoint */
+   cardem_request_config(ci, CEMU_FEAT_F_STATUS_IRQ);
+
+   /* simulate card-insert to modem (owhw, not qmod) */
+   cardem_request_card_insert(ci, true);
+
+   /* select remote (forwarded) SIM */
+   st_modem_sim_select_remote(ci->slot);
+
+   /* set the ATR */
+   //atr_update_csum(real_atr, sizeof(real_atr));
+   cardem_request_set_atr(ci, cfg->atr.data, cfg->atr.len);
+
+   /* select remote (forwarded) SIM */
+   st_modem_reset_pulse(ci->slot, 300);
+
+   

Change in osmo-remsim[master]: client: Adjust to API changes; enable build of remsim-client again

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/17155 )

Change subject: client: Adjust to API changes; enable build of remsim-client 
again
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/17155
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I0b3733f6851a951ee24ae87aa5db0ee8daa7a841
Gerrit-Change-Number: 17155
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:14:26 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-remsim[master]: remsim-client: Introduce 'struct client_config'

2020-02-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/16621 )

Change subject: remsim-client: Introduce 'struct client_config'
..

remsim-client: Introduce 'struct client_config'

Introduce a dedicated structure for the parsed command line options
converted into the configuration for the client.  This reduces the
amount of spaghetti code and paves the way for a later VTY / config
file.

Change-Id: I59980a78f0344602f9fa5b2277c99dfbf0b7815c
---
M src/simtrace2-remsim_client.c
1 file changed, 142 insertions(+), 79 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/simtrace2-remsim_client.c b/src/simtrace2-remsim_client.c
index 1798df9..79eb32b 100644
--- a/src/simtrace2-remsim_client.c
+++ b/src/simtrace2-remsim_client.c
@@ -840,44 +840,83 @@
);
 }

-static const struct option opts[] = {
-   { "server-host", 1, 0, 's' },
-   { "server-port", 1, 0, 'p' },
-   { "client-id", 1, 0, 'c' },
-   { "client-slot", 1, 0, 'n' },
-   { "help", 0, 0, 'h' },
-   { "version", 0, 0, 'v' },
-   { "gsmtap-ip", 1, 0, 'i' },
-   { "keep-running", 0, 0, 'k' },
-   { "usb-vendor", 1, 0, 'V' },
-   { "usb-product", 1, 0, 'P' },
-   { "usb-config", 1, 0, 'C' },
-   { "usb-interface", 1, 0, 'I' },
-   { "usb-altsetting", 1, 0, 'S' },
-   { "usb-address", 1, 0, 'A' },
-   { "usb-path", 1, 0, 'H' },
-   { "atr", 1, 0, 'a' },
-   { NULL, 0, 0, 0 }
+#define ATR_SIZE_MAX55
+struct client_config {
+   char *server_host;
+   int server_port;
+
+   int client_id;
+   int client_slot;
+
+   char *gsmtap_host;
+   bool keep_running;
+
+   struct {
+   uint8_t data[ATR_SIZE_MAX];
+   uint8_t len;
+   } atr;
+
+   struct {
+   int vendor_id;
+   int product_id;
+   int config_id;
+   int if_num;
+   int altsetting;
+   int addr;
+   char *path;
+   } usb;
 };
 
-int main(int argc, char **argv)
+static struct client_config *client_config_init(void *ctx)
 {
-   struct rspro_server_conn *srvc, *bankdc;
-   struct st_transport *transp = ci->slot->transp;
-   char *gsmtap_host = "127.0.0.1";
-   int rc;
-   int c, ret = 1;
-   int keep_running = 0;
-   int server_port = 9998;
-   int if_num = 0, vendor_id = -1, product_id = -1;
-   int config_id = -1, altsetting = 0, addr = -1;
-   int client_id = -1, client_slot = -1;
-   char *server_host = "127.0.0.1";
-   char *path = NULL;
-   uint8_t atr_data[33] = { 0x3B, 0x00 }; // the shortest simplest ATR 
possible
-   uint8_t atr_len = 2;
+   struct client_config *cfg = talloc_zero(ctx, struct client_config);
+   if (!cfg)
+   return NULL;

-   print_welcome();
+   cfg->server_host = talloc_strdup(cfg, "127.0.0.1");
+   cfg->server_port = 9998;
+   cfg->client_id = -1;
+   cfg->client_slot = -1;
+   cfg->gsmtap_host = talloc_strdup(cfg, "127.0.0.1");
+   cfg->keep_running = false;
+
+   cfg->usb.vendor_id = -1;
+   cfg->usb.product_id = -1;
+   cfg->usb.config_id = -1;
+   cfg->usb.if_num = -1;
+   cfg->usb.altsetting = 0;
+   cfg->usb.addr = -1;
+   cfg->usb.path = NULL;
+
+   cfg->atr.data[0] = 0x3B;
+   cfg->atr.data[1] = 0x00; // the shortest simplest ATR possible
+   cfg->atr.len = 2;
+
+   return cfg;
+};
+
+static void handle_options(struct client_config *cfg, int argc, char **argv)
+{
+   const struct option opts[] = {
+   { "server-host", 1, 0, 's' },
+   { "server-port", 1, 0, 'p' },
+   { "client-id", 1, 0, 'c' },
+   { "client-slot", 1, 0, 'n' },
+   { "help", 0, 0, 'h' },
+   { "version", 0, 0, 'v' },
+   { "gsmtap-ip", 1, 0, 'i' },
+   { "keep-running", 0, 0, 'k' },
+   { "usb-vendor", 1, 0, 'V' },
+   { "usb-product", 1, 0, 'P' },
+   { "usb-config", 1, 0, 'C' },
+   { "usb-interface", 1, 0, 'I' },
+   { "usb-altsetting", 1, 0, 'S' },
+   { "usb-address", 1, 0, 'A' },
+   { "usb-path", 1, 0, 'H' },
+   { "atr", 1, 0, 'a' },
+   { NULL, 0, 0, 0 }
+   };
+   int c, rc;

while (1) {
int option_index = 0;
@@ -887,16 +926,16 @@
break;
switch (c) {
case 's':
-   server_host = optarg;
+   osmo_talloc_replace_string(cfg, >server_host, 
optarg);
break;
case 'p':
-   server_port = atoi(optarg);
+   cfg->server_port = atoi(optarg);

Change in osmo-remsim[master]: remsim-client: Fix the -k/ --keep-running option

2020-02-15 Thread laforge
laforge has removed a vote from this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/16623 )


Change subject: remsim-client: Fix the -k/ --keep-running option
..


Removed Code-Review+2 by laforge 
--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/16623
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I67a3a5941434f09f7099c2cdb19c126cea305a73
Gerrit-Change-Number: 16623
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: deleteVote


Change in osmo-remsim[master]: client: Enable talloc NULL context tracking

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/16592 )

Change subject: client: Enable talloc NULL context tracking
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/16592
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I41ac5437e9262cf9e5a6e92db9b733902c91755b
Gerrit-Change-Number: 16592
Gerrit-PatchSet: 6
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:13:45 +
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in osmo-remsim[master]: remsim-client: Call an external script in specific situations

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/16629 )

Change subject: remsim-client: Call an external script in specific situations
..


Patch Set 6: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/16629
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I61cf4d93c669db137de801f8b147dcffaa6f3abd
Gerrit-Change-Number: 16629
Gerrit-PatchSet: 6
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:14:34 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-remsim[master]: remsim_client: Move body of main() loop to separate function

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/16622 )

Change subject: remsim_client: Move body of main() loop to separate function
..


Patch Set 5: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/16622
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I85c166e8aa95bb3f2e5d60d14f60caa94f3116fb
Gerrit-Change-Number: 16622
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:12:43 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-remsim[master]: remsim-client: Fix the -k/ --keep-running option

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/16623 )

Change subject: remsim-client: Fix the -k/ --keep-running option
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/16623
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I67a3a5941434f09f7099c2cdb19c126cea305a73
Gerrit-Change-Number: 16623
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:12:52 +
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in pysim[master]: Py2 -> Py3: use the floor division operator // where possible

2020-02-15 Thread laforge
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/17152 
)

Change subject: Py2 -> Py3: use the floor division operator // where possible
..

Py2 -> Py3: use the floor division operator // where possible

In Python 3, traditional division operator returns a float,
while we need a floor integer in the most cases.

Change-Id: I5565eb64a1ddea7075cbb142eaacaa5d494c87bb
---
M pySim/cards.py
M pySim/commands.py
M pySim/transport/serial.py
3 files changed, 12 insertions(+), 12 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/pySim/cards.py b/pySim/cards.py
index b4b5fdf..053ea98 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -89,7 +89,7 @@
"""
# get size and write EF.OPLMNwAcT
data = self._scc.read_binary(EF['OPLMNwAcT'], length=None, 
offset=0)
-   size = len(data[0])/2
+   size = len(data[0]) // 2
hplmn = enc_plmn(mcc, mnc)
content = hplmn + access_tech
data, sw = self._scc.update_binary(EF['OPLMNwAcT'], content + 
'ff' * (size/5-1))
@@ -101,7 +101,7 @@
"""
# get size and write EF.PLMNwAcT
data = self._scc.read_binary(EF['PLMNwAcT'], length=None, 
offset=0)
-   size = len(data[0])/2
+   size = len(data[0]) // 2
hplmn = enc_plmn(mcc, mnc)
content = hplmn + access_tech
data, sw = self._scc.update_binary(EF['PLMNwAcT'], content + 
'ff' * (size/5-1))
@@ -109,7 +109,7 @@

def update_plmnsel(self, mcc, mnc):
data = self._scc.read_binary(EF['PLMNsel'], length=None, 
offset=0)
-   size = len(data[0])/2
+   size = len(data[0]) // 2
hplmn = enc_plmn(mcc, mnc)
data, sw = self._scc.update_binary(EF['PLMNsel'], hplmn + 'ff' 
* (size-3))
return sw
@@ -127,7 +127,7 @@
raise RuntimeError('unable to calculate proper mnclen')

data = self._scc.read_binary(EF['AD'], length=None, offset=0)
-   size = len(data[0])/2
+   size = len(data[0]) // 2
content = data[0][0:6] + "%02X" % mnclen
data, sw = self._scc.update_binary(EF['AD'], content)
return sw
diff --git a/pySim/commands.py b/pySim/commands.py
index 385cacf..ff64ed2 100644
--- a/pySim/commands.py
+++ b/pySim/commands.py
@@ -49,11 +49,11 @@
# what we get in the length field.
# See also ETSI TS 102 221, chapter 11.1.1.3.0 Base coding.
exp_tlv_len = int(fcp[2:4], 16)
-   if len(fcp[4:])/2 == exp_tlv_len:
+   if len(fcp[4:]) // 2 == exp_tlv_len:
skip = 4
else:
exp_tlv_len = int(fcp[2:6], 16)
-   if len(fcp[4:])/2 == exp_tlv_len:
+   if len(fcp[4:]) // 2 == exp_tlv_len:
skip = 6

# Skip FCP tag and length
@@ -108,7 +108,7 @@
return rv

def select_adf(self, aid):
-   aidlen = ("0" + format(len(aid)/2, 'x'))[-2:]
+   aidlen = ("0" + format(len(aid) // 2, 'x'))[-2:]
return self._tp.send_apdu_checksw(self.cla_byte + "a4" + "0404" 
+ aidlen + aid)

def read_binary(self, ef, length=None, offset=0):
@@ -126,7 +126,7 @@
if not hasattr(type(ef), '__iter__'):
ef = [ef]
self.select_file(ef)
-   pdu = self.cla_byte + 'd6%04x%02x' % (offset, len(data)/2) + 
data
+   pdu = self.cla_byte + 'd6%04x%02x' % (offset, len(data) // 2) + 
data
return self._tp.send_apdu_checksw(pdu)

def read_record(self, ef, rec_no):
@@ -143,10 +143,10 @@
r = self.select_file(ef)
if not force_len:
rec_length = self.__record_len(r)
-   if (len(data)/2 != rec_length):
-   raise ValueError('Invalid data length (expected 
%d, got %d)' % (rec_length, len(data)/2))
+   if (len(data) // 2 != rec_length):
+   raise ValueError('Invalid data length (expected 
%d, got %d)' % (rec_length, len(data) // 2))
else:
-   rec_length = len(data)/2
+   rec_length = len(data) // 2
pdu = (self.cla_byte + 'dc%02x04%02x' % (rec_no, rec_length)) + 
data
return self._tp.send_apdu_checksw(pdu)

diff --git a/pySim/transport/serial.py b/pySim/transport/serial.py
index f672be2..11fcd6a 100644
--- a/pySim/transport/serial.py
+++ b/pySim/transport/serial.py
@@ -213,7 +213,7 @@

Change in pysim[master]: pySim-read.py: do not import json, it is not needed

2020-02-15 Thread laforge
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/17151 
)

Change subject: pySim-read.py: do not import json, it is not needed
..

pySim-read.py: do not import json, it is not needed

Change-Id: I4ae1d71c5695c9cd8ddebea514847b0be6a24c6c
---
M pySim-read.py
1 file changed, 0 insertions(+), 6 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/pySim-read.py b/pySim-read.py
index ce5f8a5..8c137e7 100755
--- a/pySim-read.py
+++ b/pySim-read.py
@@ -30,12 +30,6 @@
 import sys
 from pySim.ts_51_011 import EF, DF

-try:
-   import json
-except ImportError:
-   # Python < 2.5
-   import simplejson as json
-
 from pySim.commands import SimCardCommands
 from pySim.utils import h2b, swap_nibbles, rpad, dec_imsi, dec_iccid, 
dec_msisdn, format_xplmn_w_act, dec_spn


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/17151
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I4ae1d71c5695c9cd8ddebea514847b0be6a24c6c
Gerrit-Change-Number: 17151
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in pysim[master]: pySim-prog.py: add presence/length checks for user-provided SPN

2020-02-15 Thread laforge
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/16977 
)

Change subject: pySim-prog.py: add presence/length checks for user-provided SPN
..

pySim-prog.py: add presence/length checks for user-provided SPN

Change-Id: I35fab9a85efda2b83f221a460d31c7d41db582b0
---
M pySim-prog.py
M pySim/cards.py
2 files changed, 7 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/pySim-prog.py b/pySim-prog.py
index bfb40b2..09a5d70 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -274,6 +274,10 @@
# Digitize MCC/MNC (5 or 6 digits)
plmn_digits = _mcc_mnc_digits(mcc, mnc)

+   if opts.name is not None:
+   if len(opts.name) > 16:
+   raise ValueError('Service Provider Name must max 16 
characters!');
+
# ICCID (19 digits, E.118), though some phase1 vendors use 20 :(
if opts.iccid is not None:
iccid = opts.iccid
diff --git a/pySim/cards.py b/pySim/cards.py
index faaeca3..022182c 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -613,8 +613,9 @@
data, sw = self._scc.update_binary('00F7', content)

# set Service Provider Name
-   content = enc_spn(p['name'], True, True)
-   data, sw = self._scc.update_binary('6F46', rpad(content, 32))
+   if p.get('name') is not None:
+   content = enc_spn(p['name'], True, True)
+   data, sw = self._scc.update_binary('6F46', 
rpad(content, 32))

# write EF.IMSI
data, sw = self._scc.update_binary('6f07', enc_imsi(p['imsi']))

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/16977
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I35fab9a85efda2b83f221a460d31c7d41db582b0
Gerrit-Change-Number: 16977
Gerrit-PatchSet: 6
Gerrit-Owner: herlesupreeth 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in pysim[master]: Fix MCC and MCC representation in the output of pySim-read

2020-02-15 Thread laforge
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/16944 
)

Change subject: Fix MCC and MCC representation in the output of pySim-read
..

Fix MCC and MCC representation in the output of pySim-read

Change-Id: Ie699c0a38d5ae90e4d6109e4574ce860e4044096
---
M pySim/utils.py
M pysim-testdata/Fairwaves-SIM.ok
M pysim-testdata/Wavemobile-SIM.ok
M pysim-testdata/sysmoISIM-SJA2.ok
M pysim-testdata/sysmoUSIM-SJS1.ok
5 files changed, 48 insertions(+), 23 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/pySim/utils.py b/pySim/utils.py
index e8dd531..af4a491 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -124,10 +124,7 @@
digit3 = ia[1] & 0x0F   # 2nd byte, LSB
if digit3 == 0xF and digit2 == 0xF and digit1 == 0xF:
return 0xFFF # 4095
-   mcc = digit1 * 100
-   mcc += digit2 * 10
-   mcc += digit3
-   return mcc
+   return derive_mcc(digit1, digit2, digit3)

 def dec_mnc_from_plmn(plmn):
ia = h2i(plmn)
@@ -136,16 +133,7 @@
digit3 = (ia[1] & 0xF0) >> 4# 2nd byte, MSB
if digit3 == 0xF and digit2 == 0xF and digit1 == 0xF:
return 0xFFF # 4095
-   mnc = 0
-   # signifies two digit MNC
-   if digit3 == 0xF:
-   mnc += digit1 * 10
-   mnc += digit2
-   else:
-   mnc += digit1 * 100
-   mnc += digit2 * 10
-   mnc += digit3
-   return mnc
+   return derive_mnc(digit1, digit2, digit3)
 
 def dec_act(twohexbytes):
act_list = [
@@ -182,7 +170,7 @@
if rec_info['mcc'] == 0xFFF and rec_info['mnc'] == 0xFFF:
rec_str = "unused"
else:
-   rec_str = "MCC: %3s MNC: %3s AcT: %s" % 
(rec_info['mcc'], rec_info['mnc'], ", ".join(rec_info['act']))
+   rec_str = "MCC: %03d MNC: %03d AcT: %s" % 
(rec_info['mcc'], rec_info['mnc'], ", ".join(rec_info['act']))
s += "\t%s # %s\n" % (rec_data, rec_str)
return s
 
@@ -233,3 +221,40 @@
return imsi[3:5]
else:
return None
+
+def derive_mcc(digit1, digit2, digit3):
+   """
+   Derive decimal representation of the MCC (Mobile Country Code)
+   from three given digits.
+   """
+
+   mcc = 0
+
+   if digit1 != 0x0f:
+   mcc += digit1 * 100
+   if digit2 != 0x0f:
+   mcc += digit2 * 10
+   if digit3 != 0x0f:
+   mcc += digit3
+
+   return mcc
+
+def derive_mnc(digit1, digit2, digit3=0x0f):
+   """
+   Derive decimal representation of the MNC (Mobile Network Code)
+   from two or (optionally) three given digits.
+   """
+
+   mnc = 0
+
+   # 3-rd digit is optional for the MNC. If present
+   # the algorythm is the same as for the MCC.
+   if digit3 != 0x0f:
+   return derive_mcc(digit1, digit2, digit3)
+
+   if digit1 != 0x0f:
+   mnc += digit1 * 10
+   if digit2 != 0x0f:
+   mnc += digit2
+
+   return mnc
diff --git a/pysim-testdata/Fairwaves-SIM.ok b/pysim-testdata/Fairwaves-SIM.ok
index 94df376..cd6e33b 100644
--- a/pysim-testdata/Fairwaves-SIM.ok
+++ b/pysim-testdata/Fairwaves-SIM.ok
@@ -28,7 +28,7 @@
ff # unused

 HPLMNAcT:
-   fff11f # MCC: 1651 MNC: 151 AcT: UTRAN, E-UTRAN, GSM, GSM COMPACT, 
cdma2000 HRPD, cdma2000 1xRTT
+   fff11f # MCC: 001 MNC: 001 AcT: UTRAN, E-UTRAN, GSM, GSM COMPACT, 
cdma2000 HRPD, cdma2000 1xRTT
ff # unused
ff # unused
ff # unused
diff --git a/pysim-testdata/Wavemobile-SIM.ok b/pysim-testdata/Wavemobile-SIM.ok
index 8b14a30..30aeed8 100644
--- a/pysim-testdata/Wavemobile-SIM.ok
+++ b/pysim-testdata/Wavemobile-SIM.ok
@@ -8,7 +8,7 @@
 Display OPLMN: False
 PLMNsel: 
fff11fff
 PLMNwAcT:
-   fff11f # MCC: 1651 MNC: 151 AcT: UTRAN, E-UTRAN, GSM, GSM COMPACT, 
cdma2000 HRPD, cdma2000 1xRTT
+   fff11f # MCC: 001 MNC: 001 AcT: UTRAN, E-UTRAN, GSM, GSM COMPACT, 
cdma2000 HRPD, cdma2000 1xRTT
ff # unused
ff # unused
ff # unused
@@ -26,7 +26,7 @@
ff # unused

 OPLMNwAcT:
-   fff11f # MCC: 1651 MNC: 151 AcT: UTRAN, E-UTRAN, GSM, GSM COMPACT, 
cdma2000 HRPD, cdma2000 1xRTT
+   fff11f # MCC: 001 MNC: 001 AcT: UTRAN, E-UTRAN, GSM, GSM COMPACT, 
cdma2000 HRPD, cdma2000 1xRTT
ff # unused
ff # unused
ff # unused
diff --git a/pysim-testdata/sysmoISIM-SJA2.ok b/pysim-testdata/sysmoISIM-SJA2.ok
index 77c4878..a64aa8b 100644
--- a/pysim-testdata/sysmoISIM-SJA2.ok
+++ b/pysim-testdata/sysmoISIM-SJA2.ok
@@ -8,7 +8,7 @@
 Display OPLMN: 

Change in pysim[master]: cards/sysmoUSIM-SJS1: support programming of ACC bits

2020-02-15 Thread laforge
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/16950 
)

Change subject: cards/sysmoUSIM-SJS1: support programming of ACC bits
..

cards/sysmoUSIM-SJS1: support programming of ACC bits

Change-Id: Id0ed9e5654dc0a70a4732bbe5787f1900789d580
---
M pySim/cards.py
1 file changed, 3 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/pySim/cards.py b/pySim/cards.py
index 1552ff1..bc1ebf7 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -617,6 +617,9 @@
content = enc_spn(p['name'], True, True)
data, sw = self._scc.update_binary('6F46', 
rpad(content, 32))

+   if p.get('acc') is not None:
+   self.update_acc(p['acc'])
+
# write EF.IMSI
data, sw = self._scc.update_binary('6f07', enc_imsi(p['imsi']))


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/16950
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Id0ed9e5654dc0a70a4732bbe5787f1900789d580
Gerrit-Change-Number: 16950
Gerrit-PatchSet: 8
Gerrit-Owner: herlesupreeth 
Gerrit-Assignee: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-CC: dexter 
Gerrit-MessageType: merged


Change in pysim[master]: cards: cosmetic/indentation fix: use tabs, not spaces

2020-02-15 Thread laforge
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/17149 
)

Change subject: cards: cosmetic/indentation fix: use tabs, not spaces
..

cards: cosmetic/indentation fix: use tabs, not spaces

Change-Id: I5d9cbdb0ecbee783729d0a208d12f8e59ca957ff
---
M pySim/cards.py
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/pySim/cards.py b/pySim/cards.py
index 022182c..a49fe43 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -175,7 +175,7 @@
each possible provider uses a specific record number in each EF. The
indexes used are ( where N is the number of providers supported ) :
 - [2 .. N+1] for the operator name
- - [1 .. N] for the programable EFs
+- [1 .. N] for the programable EFs

* 3f00/7f4d/8f0c : Operator Name


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/17149
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I5d9cbdb0ecbee783729d0a208d12f8e59ca957ff
Gerrit-Change-Number: 17149
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: herlesupreeth 
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in pysim[master]: cards/sysmoUSIM-SJS1: support programming of EF.HPLMNwAcT

2020-02-15 Thread laforge
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/16972 
)

Change subject: cards/sysmoUSIM-SJS1: support programming of EF.HPLMNwAcT
..

cards/sysmoUSIM-SJS1: support programming of EF.HPLMNwAcT

Change-Id: Ida93f4a00fe3b1d0f05d6eeda0e7873ce16d4c17
---
M pySim/cards.py
1 file changed, 6 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/pySim/cards.py b/pySim/cards.py
index bc1ebf7..802ad69 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -641,6 +641,12 @@
if sw != '9000':
print("Programming OPLMNwAcT failed with code 
%s"%sw)

+   # EF.HPLMNwAcT
+   if p.get('mcc') and p.get('mnc'):
+   sw = self.update_hplmn_act(p['mcc'], p['mnc'])
+   if sw != '9000':
+   print("Programming HPLMNwAcT failed with code 
%s"%sw)
+
# EF.AD
if p.get('mcc') and p.get('mnc'):
sw = self.update_ad(p['mnc'])

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/16972
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ida93f4a00fe3b1d0f05d6eeda0e7873ce16d4c17
Gerrit-Change-Number: 16972
Gerrit-PatchSet: 8
Gerrit-Owner: herlesupreeth 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in pysim[master]: pySim-read.py: fix reading and parsing of EF.MSISDN

2020-02-15 Thread laforge
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/16947 
)

Change subject: pySim-read.py: fix reading and parsing of EF.MSISDN
..

pySim-read.py: fix reading and parsing of EF.MSISDN

This change implements parsing of EF.MSISDN (and thus EF.ADN)
as per 3GPP TS 31.102, sections 4.2.26 and 4.4.2.3.

Example (commercial SIM card from 401/02):

  EF.MSISDN: 07917787028982f7
  Decoded (NPI=1 ToN=1): +77782098287

Note that sysmoUSIM-SJS1 in the test setup has malformed
EF.MSISDN, so that's why the test output is changed.

Change-Id: Ie914ae83d787e3f1a90f9f305bffd45053b8c863
---
M pySim-read.py
M pySim/utils.py
M pysim-testdata/sysmoISIM-SJA2.ok
M pysim-testdata/sysmoUSIM-SJS1.ok
4 files changed, 48 insertions(+), 5 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/pySim-read.py b/pySim-read.py
index d753c8b..ce5f8a5 100755
--- a/pySim-read.py
+++ b/pySim-read.py
@@ -37,7 +37,7 @@
import simplejson as json

 from pySim.commands import SimCardCommands
-from pySim.utils import h2b, swap_nibbles, rpad, dec_imsi, dec_iccid, 
format_xplmn_w_act, dec_spn
+from pySim.utils import h2b, swap_nibbles, rpad, dec_imsi, dec_iccid, 
dec_msisdn, format_xplmn_w_act, dec_spn


 def parse_options():
@@ -186,8 +186,10 @@
#   print(scc.record_size(['3f00', '7f10', '6f40']))
(res, sw) = scc.read_record(['3f00', '7f10', '6f40'], 1)
if sw == '9000':
-   if res[1] != 'f':
-   print("MSISDN: %s" % (res,))
+   res_dec = dec_msisdn(res)
+   if res_dec is not None:
+   # (npi, ton, msisdn) = res_dec
+   print("MSISDN (NPI=%d ToN=%d): %s" % res_dec)
else:
print("MSISDN: Not available")
else:
diff --git a/pySim/utils.py b/pySim/utils.py
index af4a491..12f66b9 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -258,3 +258,44 @@
mnc += digit2

return mnc
+
+def dec_msisdn(ef_msisdn):
+   """
+   Decode MSISDN from EF.MSISDN or EF.ADN (same structure).
+   See 3GPP TS 31.102, section 4.2.26 and 4.4.2.3.
+   """
+
+   # Convert from str to (kind of) 'bytes'
+   ef_msisdn = h2b(ef_msisdn)
+
+   # Make sure mandatory fields are present
+   if len(ef_msisdn) < 14:
+   raise ValueError("EF.MSISDN is too short")
+
+   # Skip optional Alpha Identifier
+   xlen = len(ef_msisdn) - 14
+   msisdn_lhv = ef_msisdn[xlen:]
+
+   # Parse the length (in bytes) of the BCD encoded number
+   bcd_len = ord(msisdn_lhv[0])
+   # BCD length = length of dial num (max. 10 bytes) + 1 byte ToN and NPI
+   if bcd_len == 0xff:
+   return None
+   elif bcd_len > 11 or bcd_len < 1:
+   raise ValueError("Length of MSISDN (%d bytes) is out of range" 
% bcd_len)
+
+   # Parse ToN / NPI
+   ton = (ord(msisdn_lhv[1]) >> 4) & 0x07
+   npi = ord(msisdn_lhv[1]) & 0x0f
+   bcd_len -= 1
+
+   # No MSISDN?
+   if not bcd_len:
+   return (npi, ton, None)
+
+   msisdn = swap_nibbles(b2h(msisdn_lhv[2:][:bcd_len])).rstrip('f')
+   # International number 10.5.118/3GPP TS 24.008
+   if (ton & 0x01) == 0x01:
+   msisdn = '+' + msisdn
+
+   return (npi, ton, msisdn)
diff --git a/pysim-testdata/sysmoISIM-SJA2.ok b/pysim-testdata/sysmoISIM-SJA2.ok
index a64aa8b..bfef882 100644
--- a/pysim-testdata/sysmoISIM-SJA2.ok
+++ b/pysim-testdata/sysmoISIM-SJA2.ok
@@ -50,7 +50,7 @@
ff # unused

 ACC: 0001
-MSISDN: Not available
+MSISDN (NPI=1 ToN=1): +1234
 AD: 0002
 Done !

diff --git a/pysim-testdata/sysmoUSIM-SJS1.ok b/pysim-testdata/sysmoUSIM-SJS1.ok
index 8def4e3..6d85f38 100644
--- a/pysim-testdata/sysmoUSIM-SJS1.ok
+++ b/pysim-testdata/sysmoUSIM-SJS1.ok
@@ -50,7 +50,7 @@
ff # unused

 ACC: 0008
-MSISDN: Not available
+MSISDN: Can't read file -- Length of MSISDN (136 bytes) is out of range
 AD: 0002
 Done !


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/16947
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie914ae83d787e3f1a90f9f305bffd45053b8c863
Gerrit-Change-Number: 16947
Gerrit-PatchSet: 19
Gerrit-Owner: herlesupreeth 
Gerrit-Assignee: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: herlesupreeth 
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: neels 
Gerrit-CC: dexter 
Gerrit-MessageType: merged


Change in osmo-remsim[master]: remsim-client: Introduce 'struct client_config'

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/16621 )

Change subject: remsim-client: Introduce 'struct client_config'
..


Patch Set 5: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/16621
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I59980a78f0344602f9fa5b2277c99dfbf0b7815c
Gerrit-Change-Number: 16621
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:12:33 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in pysim[master]: pySim-prog.py: add support for MSISDN programming

2020-02-15 Thread laforge
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/16946 
)

Change subject: pySim-prog.py: add support for MSISDN programming
..

pySim-prog.py: add support for MSISDN programming

This change implements programming of EF.MSISDN as per 3GPP TS 31.102,
sections 4.2.26 and 4.4.2.3, excluding the following fields:

  - Alpha Identifier (currently 'FF'O * 20),
  - Capability/Configuration1 Record Identifier ('FF'O),
  - Extension1 Record Identifier ('FF'O).

This feature is introduced exclusively for sysmoUSIM-SJS1.
Othere SIM card types need to be tested.

Change-Id: Ie033a0ffc3697ae562eaa7a241a0f6af6c2b0594
---
M pySim-prog.py
M pySim/cards.py
M pySim/utils.py
M pysim-testdata/sysmoUSIM-SJS1.data
M pysim-testdata/sysmoUSIM-SJS1.ok
M tests/pysim-test.sh
M tests/sysmoUSIM-SJS1.data.example
7 files changed, 57 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/pySim-prog.py b/pySim-prog.py
index 09a5d70..a7081ff 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -119,6 +119,9 @@
parser.add_option("-i", "--imsi", dest="imsi",
help="International Mobile Subscriber Identity",
)
+   parser.add_option("--msisdn", dest="msisdn",
+   help="Mobile Subscriber Integrated Services Digital 
Number",
+   )
parser.add_option("-k", "--ki", dest="ki",
help="Ki (default is to randomize)",
)
@@ -165,7 +168,6 @@
parser.add_option("--dry-run", dest="dry_run",
help="Perform a 'dry run', don't actually program the 
card",
default=False, action="store_true")
-
parser.add_option("--card_handler", dest="card_handler", metavar="FILE",
help="Use automatic card handling machine")

@@ -278,6 +280,17 @@
if len(opts.name) > 16:
raise ValueError('Service Provider Name must max 16 
characters!');

+   if opts.msisdn is not None:
+   msisdn = opts.msisdn
+   if msisdn[0] == '+':
+   msisdn = msisdn[1:]
+   if not msisdn.isdigit():
+   raise ValueError('MSISDN must be digits only! '
+'Start with \'+\' for international 
numbers.')
+   if len(msisdn) > 10 * 2:
+   # TODO: Support MSISDN of length > 20 (10 Bytes)
+   raise ValueError('MSISDNs longer than 20 digits are not 
(yet) supported.')
+
# ICCID (19 digits, E.118), though some phase1 vendors use 20 :(
if opts.iccid is not None:
iccid = opts.iccid
@@ -426,6 +439,7 @@
'opc'   : opc,
'acc'   : acc,
'pin_adm' : pin_adm,
+   'msisdn' : opts.msisdn,
}


diff --git a/pySim/cards.py b/pySim/cards.py
index 802ad69..b4b5fdf 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -658,6 +658,17 @@
r = self._scc.select_file(['3f00', '7f10'])
data, sw = self._scc.update_record('6f42', 1, 
lpad(p['smsp'], 104), force_len=True)

+   # EF.MSISDN
+   # TODO: Alpha Identifier (currently 'ff'O * 20)
+   # TODO: Capability/Configuration1 Record Identifier
+   # TODO: Extension1 Record Identifier
+   if p.get('msisdn') is not None:
+   msisdn = enc_msisdn(p['msisdn'])
+   data = 'ff' * 20 + msisdn + 'ff' * 2
+
+   r = self._scc.select_file(['3f00', '7f10'])
+   data, sw = self._scc.update_record('6F40', 1, data, 
force_len=True)
+
def erase(self):
return

diff --git a/pySim/utils.py b/pySim/utils.py
index 12f66b9..8420b23 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -299,3 +299,29 @@
msisdn = '+' + msisdn

return (npi, ton, msisdn)
+
+def enc_msisdn(msisdn, npi=0x01, ton=0x03):
+   """
+   Encode MSISDN as LHV so it can be stored to EF.MSISDN.
+   See 3GPP TS 31.102, section 4.2.26 and 4.4.2.3.
+
+   Default NPI / ToN values:
+ - NPI: ISDN / telephony numbering plan (E.164 / E.163),
+ - ToN: network specific or international number (if starts with '+').
+   """
+
+   # Leading '+' indicates International Number
+   if msisdn[0] == '+':
+   msisdn = msisdn[1:]
+   ton = 0x01
+
+   # Append 'f' padding if number of digits is odd
+   if len(msisdn) % 2 > 0:
+   msisdn += 'f'
+
+   # BCD length also includes NPI/ToN header
+   bcd_len = len(msisdn) // 2 + 1
+   npi_ton = (npi & 0x0f) | ((ton & 0x07) << 4) | 0x80
+   bcd = rpad(swap_nibbles(msisdn), 10 * 2) # pad to 10 octets
+
+   return 

Change in pysim[master]: cards: fix reading of EF.HPLMNwAcT in Card.update_hplmn_act()

2020-02-15 Thread laforge
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/16945 
)

Change subject: cards: fix reading of EF.HPLMNwAcT in Card.update_hplmn_act()
..

cards: fix reading of EF.HPLMNwAcT in Card.update_hplmn_act()

Change-Id: I35848059d6082c379246c8d695cb094c20780d15
---
M pySim/cards.py
1 file changed, 2 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/pySim/cards.py b/pySim/cards.py
index a49fe43..1552ff1 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -76,8 +76,8 @@
access_tech = '' # All technologues selected, even Reserved 
for Future Use ones
"""
# get size and write EF.HPLMNwAcT
-   r = self._scc.select_file(EF['HPLMNwAcT'])
-   size = int(r[-1][4:8], 16)
+   data = self._scc.read_binary(EF['HPLMNwAcT'], length=None, 
offset=0)
+   size = len(data[0])/2
hplmn = enc_plmn(mcc, mnc)
content = hplmn + access_tech
data, sw = self._scc.update_binary(EF['HPLMNwAcT'], content + 
'ff' * (size/5-1))

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/16945
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I35848059d6082c379246c8d695cb094c20780d15
Gerrit-Change-Number: 16945
Gerrit-PatchSet: 10
Gerrit-Owner: herlesupreeth 
Gerrit-Assignee: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: herlesupreeth 
Gerrit-Reviewer: laforge 
Gerrit-CC: dexter 
Gerrit-MessageType: merged


Change in pysim[master]: Py2 -> Py3: use the floor division operator // where possible

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/17152 )

Change subject: Py2 -> Py3: use the floor division operator // where possible
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/17152
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I5565eb64a1ddea7075cbb142eaacaa5d494c87bb
Gerrit-Change-Number: 17152
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:11:46 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in pysim[master]: pySim-read.py: fix reading and parsing of EF.MSISDN

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/16947 )

Change subject: pySim-read.py: fix reading and parsing of EF.MSISDN
..


Patch Set 19: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/16947
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie914ae83d787e3f1a90f9f305bffd45053b8c863
Gerrit-Change-Number: 16947
Gerrit-PatchSet: 19
Gerrit-Owner: herlesupreeth 
Gerrit-Assignee: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: herlesupreeth 
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: neels 
Gerrit-CC: dexter 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:11:31 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in pysim[master]: pySim-prog.py: add support for MSISDN programming

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/16946 )

Change subject: pySim-prog.py: add support for MSISDN programming
..


Patch Set 11: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/16946
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie033a0ffc3697ae562eaa7a241a0f6af6c2b0594
Gerrit-Change-Number: 16946
Gerrit-PatchSet: 11
Gerrit-Owner: herlesupreeth 
Gerrit-Assignee: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-CC: dexter 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:11:34 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in pysim[master]: Fix MCC and MCC representation in the output of pySim-read

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/16944 )

Change subject: Fix MCC and MCC representation in the output of pySim-read
..


Patch Set 9: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/16944
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie699c0a38d5ae90e4d6109e4574ce860e4044096
Gerrit-Change-Number: 16944
Gerrit-PatchSet: 9
Gerrit-Owner: herlesupreeth 
Gerrit-Assignee: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: herlesupreeth 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:11:28 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in pysim[master]: pySim-prog.py: add presence/length checks for user-provided SPN

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/16977 )

Change subject: pySim-prog.py: add presence/length checks for user-provided SPN
..


Patch Set 6: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/16977
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I35fab9a85efda2b83f221a460d31c7d41db582b0
Gerrit-Change-Number: 16977
Gerrit-PatchSet: 6
Gerrit-Owner: herlesupreeth 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:11:18 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in pysim[master]: pySim-read.py: print meaningful message when SPN is not set

2020-02-15 Thread laforge
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/16981 
)

Change subject: pySim-read.py: print meaningful message when SPN is not set
..

pySim-read.py: print meaningful message when SPN is not set

Change-Id: I1d98520f33a8564c7d69f50a0811204f138f9dca
---
M pySim-read.py
M pysim-testdata/sysmoISIM-SJA2.ok
M pysim-testdata/sysmosim-gr1.ok
3 files changed, 5 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/pySim-read.py b/pySim-read.py
index 853e924..d753c8b 100755
--- a/pySim-read.py
+++ b/pySim-read.py
@@ -126,7 +126,9 @@
(res, sw) = scc.read_binary(EF['SPN'])
if sw == '9000':
spn_res = dec_spn(res)
-   print("SPN: %s\nDisplay HPLMN: %s\nDisplay OPLMN: %s" % 
(spn_res[0], spn_res[1], spn_res[2],))
+   print("SPN: %s" % (spn_res[0] or "Not available"))
+   print("Display HPLMN: %s" % (spn_res[1],))
+   print("Display OPLMN: %s" % (spn_res[2],))
else:
print("SPN: Can't read, response code = %s" % (sw,))
except Exception as e:
diff --git a/pysim-testdata/sysmoISIM-SJA2.ok b/pysim-testdata/sysmoISIM-SJA2.ok
index 7346134..77c4878 100644
--- a/pysim-testdata/sysmoISIM-SJA2.ok
+++ b/pysim-testdata/sysmoISIM-SJA2.ok
@@ -3,7 +3,7 @@
 ICCID: 89882119004
 IMSI: 00101000102
 SMSP: 
e10581005155f500
-SPN:
+SPN: Not available
 Display HPLMN: False
 Display OPLMN: False
 PLMNsel: 
fff11fff
diff --git a/pysim-testdata/sysmosim-gr1.ok b/pysim-testdata/sysmosim-gr1.ok
index b306f4d..f7df5cf 100644
--- a/pysim-testdata/sysmosim-gr1.ok
+++ b/pysim-testdata/sysmosim-gr1.ok
@@ -3,7 +3,7 @@
 ICCID: 1122334455667788990
 IMSI: 00101000102
 SMSP: 
e10581005155f500
-SPN:
+SPN: Not available
 Display HPLMN: False
 Display OPLMN: False
 PLMNsel: 
fff11fff

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/16981
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I1d98520f33a8564c7d69f50a0811204f138f9dca
Gerrit-Change-Number: 16981
Gerrit-PatchSet: 5
Gerrit-Owner: herlesupreeth 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-CC: fixeria 
Gerrit-MessageType: merged


Change in pysim[master]: pySim-read.py: print meaningful message when SPN is not set

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/16981 )

Change subject: pySim-read.py: print meaningful message when SPN is not set
..


Patch Set 5: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/16981
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I1d98520f33a8564c7d69f50a0811204f138f9dca
Gerrit-Change-Number: 16981
Gerrit-PatchSet: 5
Gerrit-Owner: herlesupreeth 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-CC: fixeria 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:11:15 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in pysim[master]: cards: fix reading of EF.HPLMNwAcT in Card.update_hplmn_act()

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/16945 )

Change subject: cards: fix reading of EF.HPLMNwAcT in Card.update_hplmn_act()
..


Patch Set 10: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/16945
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I35848059d6082c379246c8d695cb094c20780d15
Gerrit-Change-Number: 16945
Gerrit-PatchSet: 10
Gerrit-Owner: herlesupreeth 
Gerrit-Assignee: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: herlesupreeth 
Gerrit-Reviewer: laforge 
Gerrit-CC: dexter 
Gerrit-Comment-Date: Sat, 15 Feb 2020 19:11:22 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-remsim[master]: client: Split into remsim_client.c and remsim_client_main.c

2020-02-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/17159 )


Change subject: client: Split into remsim_client.c and remsim_client_main.c
..

client: Split into remsim_client.c and remsim_client_main.c

Change-Id: Ie1d21c2cd84756d5c8aa2c41bcc37f5951a3a285
---
M src/client/Makefile.am
M src/client/remsim_client.c
A src/client/remsim_client_main.c
3 files changed, 99 insertions(+), 99 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/59/17159/1

diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index ec99818..ac0d707 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -6,7 +6,7 @@

 bin_PROGRAMS = osmo-remsim-client-st2 osmo-remsim-client-shell

-osmo_remsim_client_shell_SOURCES = user_shell.c \
+osmo_remsim_client_shell_SOURCES = user_shell.c remsim_client_main.c \
   remsim_client.c ../rspro_client_fsm.c 
../debug.c
 osmo_remsim_client_shell_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) 
$(OSMOABIS_LIBS) \
  $(top_builddir)/src/libosmo-rspro.la
diff --git a/src/client/remsim_client.c b/src/client/remsim_client.c
index 7ff8f37..07ffbde 100644
--- a/src/client/remsim_client.c
+++ b/src/client/remsim_client.c
@@ -159,101 +159,3 @@
bc->bankd_conn.clslot->slotNr = slot_nr;
}
 }
-
-
-
-#include 
-#include 
-#define _GNU_SOURCE
-#include 
-
-#include 
-#include 
-
-static void *g_tall_ctx;
-void __thread *talloc_asn1_ctx;
-int asn_debug;
-
-static void handle_sig_usr1(int signal)
-{
-   OSMO_ASSERT(signal == SIGUSR1);
-   talloc_report_full(g_tall_ctx, stderr);
-}
-
-static void printf_help()
-{
-   printf(
-   "  -h --help  Print this help message\n"
-   "  -i --server-ip A.B.C.D remsim-server IP address\n"
-   "  -p --server-port 13245 remsim-server TCP port\n"
-   "  -i --client-id <0-65535>   RSPRO ClientId of this client\n"
-   "  -n --client-slot <0-65535> RSPRO SlotNr of this client\n"
- );
-}
-
-static void handle_options(struct bankd_client *bc, int argc, char **argv)
-{
-   while (1) {
-   int option_index = 0, c;
-   static const struct option long_options[] = {
-   { "help", 0, 0, 'h' },
-   { "server-ip", 1, 0, 'i' },
-   { "server-port", 1, 0, 'p' },
-   { "client-id", 1, 0, 'c' },
-   { "client-slot", 1, 0, 'n' },
-   { 0, 0, 0, 0 }
-   };
-
-   c = getopt_long(argc, argv, "hi:p:c:n:",
-   long_options, _index);
-   if (c == -1)
-   break;
-
-   switch (c) {
-   case 'h':
-   printf_help();
-   exit(0);
-   break;
-   case 'i':
-   bc->srv_conn.server_host = optarg;
-   break;
-   case 'p':
-   bc->srv_conn.server_port = atoi(optarg);
-   break;
-   case 'c':
-   remsim_client_set_clslot(bc, atoi(optarg), -1);
-   break;
-   case 'n':
-   remsim_client_set_clslot(bc, -1, atoi(optarg));
-   break;
-   default:
-   break;
-   }
-   }
-}
-
-int main(int argc, char **argv)
-{
-   struct bankd_client *g_client;
-   char hostname[256];
-
-   gethostname(hostname, sizeof(hostname));
-
-   g_tall_ctx = talloc_named_const(NULL, 0, "global");
-   talloc_asn1_ctx = talloc_named_const(g_tall_ctx, 0, "asn1");
-   msgb_talloc_ctx_init(g_tall_ctx, 0);
-
-   osmo_init_logging2(g_tall_ctx, _info);
-
-   g_client = remsim_client_create(g_tall_ctx, hostname, "remsim-client");
-
-   handle_options(g_client, argc, argv);
-
-   osmo_fsm_inst_dispatch(g_client->srv_conn.fi, SRVC_E_ESTABLISH, NULL);
-
-   signal(SIGUSR1, handle_sig_usr1);
-
-   asn_debug = 0;
-
-   client_user_main(g_client);
-}
diff --git a/src/client/remsim_client_main.c b/src/client/remsim_client_main.c
new file mode 100644
index 000..95eb089
--- /dev/null
+++ b/src/client/remsim_client_main.c
@@ -0,0 +1,98 @@
+
+#include 
+#include 
+#define _GNU_SOURCE
+#include 
+
+#include 
+#include 
+
+#include "client.h"
+
+static void *g_tall_ctx;
+void __thread *talloc_asn1_ctx;
+int asn_debug;
+
+static void handle_sig_usr1(int signal)
+{
+   OSMO_ASSERT(signal == SIGUSR1);
+   talloc_report_full(g_tall_ctx, stderr);
+}
+
+static void printf_help()
+{
+   printf(
+   "  -h --help  Print this help message\n"
+   "  -i --server-ip A.B.C.D 

Change in osmo-remsim[master]: client: Remove g_client comopletely; separate 'main' code

2020-02-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/17158 )


Change subject: client: Remove g_client comopletely; separate 'main' code
..

client: Remove g_client comopletely; separate 'main' code

We may want to use the entire client code independent of the current
'main' portion, so let's introduce separation via API.

Change-Id: I6456317c3968551cd69ba379c746e4dd9690d02d
---
M src/client/client.h
M src/client/remsim_client.c
2 files changed, 92 insertions(+), 60 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/58/17158/1

diff --git a/src/client/client.h b/src/client/client.h
index 0239b55..80381fa 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -61,6 +61,9 @@
 #define srvc2bankd_client(srvc)container_of(srvc, struct 
bankd_client, srv_conn)
 #define bankdc2bankd_client(bdc)   container_of(bdc, struct bankd_client, 
bankd_conn)

+struct bankd_client *remsim_client_create(void *ctx, const char *name, const 
char *software);
+void remsim_client_set_clslot(struct bankd_client *bc, int client_id, int 
slot_nr);
+

 extern int client_user_bankd_handle_rx(struct rspro_server_conn *bankdc, const 
RsproPDU_t *pdu);

diff --git a/src/client/remsim_client.c b/src/client/remsim_client.c
index 496e1f4..7ff8f37 100644
--- a/src/client/remsim_client.c
+++ b/src/client/remsim_client.c
@@ -1,4 +1,4 @@
-/* (C) 2018-2019 by Harald Welte 
+/* (C) 2018-2020 by Harald Welte 
  *
  * All Rights Reserved
  *
@@ -22,21 +22,12 @@

 #include 
 #include 
-#include 
-
-#define _GNU_SOURCE
-#include 

 #include 

-#include 
 #include 
 #include 
 #include 
-#include 
-
-#include 
-#include 

 #include "rspro_util.h"
 #include "client.h"
@@ -62,11 +53,6 @@
return 0;
 }

-static struct bankd_client *g_client;
-static void *g_tall_ctx;
-void __thread *talloc_asn1_ctx;
-int asn_debug;
-
 /* handle incoming messages from server */
 static int srvc_handle_rx(struct rspro_server_conn *srvc, const RsproPDU_t 
*pdu)
 {
@@ -112,6 +98,82 @@
return 0;
 }

+struct bankd_client *remsim_client_create(void *ctx, const char *name, const 
char *software)
+{
+   struct bankd_client *bc = talloc_zero(ctx, struct bankd_client);
+   struct rspro_server_conn *srvc, *bankdc;
+   int rc;
+
+   if (!bc)
+   return NULL;
+
+   /* create and [attempt to] establish connection to remsim-server */
+   srvc = >srv_conn;
+   srvc->server_host = "localhost";
+   srvc->server_port = 9998;
+   srvc->handle_rx = srvc_handle_rx;
+   srvc->own_comp_id.type = ComponentType_remsimClient;
+   OSMO_STRLCPY_ARRAY(srvc->own_comp_id.name, name);
+   OSMO_STRLCPY_ARRAY(srvc->own_comp_id.software, software);
+   OSMO_STRLCPY_ARRAY(srvc->own_comp_id.sw_version, PACKAGE_VERSION);
+
+   rc = server_conn_fsm_alloc(bc, srvc);
+   if (rc < 0) {
+   fprintf(stderr, "Unable to create Server conn FSM: %s\n", 
strerror(errno));
+   exit(1);
+   }
+
+   bankdc = >bankd_conn;
+   /* server_host / server_port are configured from remsim-server */
+   bankdc->handle_rx = bankd_handle_rx;
+   memcpy(>own_comp_id, >own_comp_id, 
sizeof(bankdc->own_comp_id));
+   rc = server_conn_fsm_alloc(bc, bankdc);
+   if (rc < 0) {
+   fprintf(stderr, "Unable to connect bankd conn FSM: %s\n", 
strerror(errno));
+   exit(1);
+   }
+   osmo_fsm_inst_update_id(bankdc->fi, "bankd");
+
+   return bc;
+}
+
+void remsim_client_set_clslot(struct bankd_client *bc, int client_id, int 
slot_nr)
+{
+   if (!bc->srv_conn.clslot) {
+   bc->srv_conn.clslot = talloc_zero(bc, ClientSlot_t);
+   OSMO_ASSERT(bc->srv_conn.clslot);
+   }
+
+   if (!bc->bankd_conn.clslot) {
+   bc->bankd_conn.clslot = talloc_zero(bc, ClientSlot_t);
+   OSMO_ASSERT(bc->bankd_conn.clslot);
+   }
+
+   if (client_id >= 0) {
+   bc->srv_conn.clslot->clientId = client_id;
+   bc->bankd_conn.clslot->clientId = client_id;
+   }
+
+   if (slot_nr >= 0) {
+   bc->srv_conn.clslot->slotNr = slot_nr;
+   bc->bankd_conn.clslot->slotNr = slot_nr;
+   }
+}
+
+
+
+#include 
+#include 
+#define _GNU_SOURCE
+#include 
+
+#include 
+#include 
+
+static void *g_tall_ctx;
+void __thread *talloc_asn1_ctx;
+int asn_debug;
+
 static void handle_sig_usr1(int signal)
 {
OSMO_ASSERT(signal == SIGUSR1);
@@ -129,7 +191,7 @@
  );
 }

-static void handle_options(int argc, char **argv)
+static void handle_options(struct bankd_client *bc, int argc, char **argv)
 {
while (1) {
int option_index = 0, c;
@@ -153,20 +215,16 @@
exit(0);
break;
case 'i':
-   g_client->srv_conn.server_host 

Change in osmo-remsim[master]: client: ifd_handler (PC/SC reader driver) as remsim-client

2020-02-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/17160 )


Change subject: client: ifd_handler (PC/SC reader driver) as remsim-client
..

client: ifd_handler (PC/SC reader driver) as remsim-client

This adds a "libifd_remsim_client.so" PC/SC driver that can be
used to make normal PC/SC client programs (like pySim, sysmo-usim-tool,
osmo-sim-test, osmo-usim-auth, ...) talk to a remote SIM bank.

Change-Id: Ib8707c6e0e46407ab39a693adfec2fa71892f6ee
---
M src/client/Makefile.am
M src/client/client.h
A src/client/user_ifdhandler.c
3 files changed, 948 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/60/17160/1

diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index ac0d707..5b88c50 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -6,13 +6,24 @@

 bin_PROGRAMS = osmo-remsim-client-st2 osmo-remsim-client-shell

+lib_LTLIBRARIES = libifd_remsim_client.la
+
 osmo_remsim_client_shell_SOURCES = user_shell.c remsim_client_main.c \
   remsim_client.c ../rspro_client_fsm.c 
../debug.c
+osmo_remsim_client_shell_CFLAGS = $(AM_CFLAGS)
 osmo_remsim_client_shell_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) 
$(OSMOABIS_LIBS) \
  $(top_builddir)/src/libosmo-rspro.la

+libifd_remsim_client_la_SOURCES = user_ifdhandler.c \
+  remsim_client.c ../rspro_client_fsm.c 
../debug.c
+libifd_remsim_client_la_LDFLAGS = -no-undefined
+libifd_remsim_client_la_CPPFLAGS = $(PCSC_CFLAGS)
+libifd_remsim_client_la_LIBADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) 
$(OSMOABIS_LIBS) \
+ $(top_builddir)/src/libosmo-rspro.la
+
 osmo_remsim_client_st2_SOURCES = simtrace2-remsim_client.c \
 ../rspro_client_fsm.c ../debug.c
+osmo_remsim_client_st2_CFLAGS = $(AM_CFLAGS)
 osmo_remsim_client_st2_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) 
$(OSMOABIS_LIBS) \
   $(OSMOUSB_LIBS) $(OSMOSIMTRACE2_LIBS) \
   $(USB_LIBS) $(OSMOSIM_LIBS) \
diff --git a/src/client/client.h b/src/client/client.h
index 80381fa..0761255 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -56,6 +56,7 @@

struct client_config *cfg;
struct cardem_inst *cardem;
+   void *data;
 };

 #define srvc2bankd_client(srvc)container_of(srvc, struct 
bankd_client, srv_conn)
diff --git a/src/client/user_ifdhandler.c b/src/client/user_ifdhandler.c
new file mode 100644
index 000..677b781
--- /dev/null
+++ b/src/client/user_ifdhandler.c
@@ -0,0 +1,936 @@
+/* (C) 2020 by Harald Welte 
+ *
+ * All Rights Reserved
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+/* This is a remsim-client that provides an IFD_Handler (reader driver)
+ * towards the PC/SC services.  This effectively allows any local PC/SC client
+ * application to use a remote smartcard via osmo-remsim.
+ *
+ * In order to use this, you will need an /etc/reader.conf.d/osmo-remsim-client
+ * file with the following content:
+ *
+ * FRIENDLYNAME "osmo-remsim-client"
+ * DEVICENAME   0:0:192.168.11.10:9998
+ * LIBPATH  /usr/lib/pcsc/drivers/serial/libifd_remsim_client.so
+ *
+ * Where  DEVICENAME has the following format:
+ * [ClientID:[SlotNr:[ServerIp:[ServerPort
+ *
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+extern int osmo_ctx_init(const char *id);
+
+#include "client.h"
+
+/* ensure this current thread has an osmo_ctx and hence can use OTC_GLOBAL and 
friends */
+static void ensure_osmo_ctx(void)
+{
+   if (!osmo_ctx)
+   osmo_ctx_init("");
+}
+
+/* inter-thread messages between IFD thread and remsim-client thread */
+enum itmsg_type {
+   ITMSG_TYPE_NONE,
+
+   /* card present? */
+   ITMSG_TYPE_CARD_PRES_REQ,
+   ITMSG_TYPE_CARD_PRES_RESP,
+
+   /* obtain ATR */
+   ITMSG_TYPE_ATR_REQ,
+   ITMSG_TYPE_ATR_RESP,
+
+   /* transceive APDU: Send C-APDU, receive R-APDU */
+   ITMSG_TYPE_C_APDU_REQ,
+   ITMSG_TYPE_R_APDU_IND,
+
+   /* power off the card */
+   ITMSG_TYPE_POWER_OFF_REQ,
+   

Change in osmo-remsim[master]: client: Adjust to API changes; enable build of remsim-client again

2020-02-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/17155 )


Change subject: client: Adjust to API changes; enable build of remsim-client 
again
..

client: Adjust to API changes; enable build of remsim-client again

There were quite a bit of API changes that hadn't yet been applied
to remsim_client.c (which was disabled and hence not compiled for
quite some time).

Change-Id: I0b3733f6851a951ee24ae87aa5db0ee8daa7a841
---
M src/client/Makefile.am
M src/client/remsim_client.c
2 files changed, 22 insertions(+), 69 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/55/17155/1

diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index 106bc5e..3d4f355 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -4,7 +4,7 @@
$(OSMOSIMTRACE2_CFLAGS) \
-I$(top_srcdir)/include/osmocom/rspro

-bin_PROGRAMS = osmo-remsim-client-st2
+bin_PROGRAMS = osmo-remsim-client-st2 remsim-client

 remsim_client_SOURCES = remsim_client.c ../rspro_client_fsm.c ../debug.c
 remsim_client_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOABIS_LIBS) \
diff --git a/src/client/remsim_client.c b/src/client/remsim_client.c
index ca6143e..41361c0 100644
--- a/src/client/remsim_client.c
+++ b/src/client/remsim_client.c
@@ -42,80 +42,25 @@
 #include "client.h"
 #include "debug.h"

-static int bankd_handle_msg(struct bankd_client *bc, struct msgb *msg)
+static int bankd_handle_rx(struct rspro_server_conn *bankdc, const RsproPDU_t 
*pdu)
 {
-   RsproPDU_t *pdu = rspro_dec_msg(msg);
-   if (!pdu) {
-   LOGPFSML(bc->bankd_fi, LOGL_ERROR, "Error decoding PDU\n");
-   return -1;
-   }
-
-   LOGPFSM(bc->bankd_fi, "Rx RSPRO %s\n", rspro_msgt_name(pdu));
-
switch (pdu->msg.present) {
case RsproPDUchoice_PR_connectClientRes:
/* Store 'identity' of bankd to in peer_comp_id */
-   rspro_comp_id_retrieve(>peer_comp_id, 
>msg.choice.connectClientRes.identity);
-   osmo_fsm_inst_dispatch(bc->bankd_fi, BDC_E_CLIENT_CONN_RES, 
pdu);
+   rspro_comp_id_retrieve(>peer_comp_id, 
>msg.choice.connectClientRes.identity);
+   osmo_fsm_inst_dispatch(bankdc->fi, SRVC_E_CLIENT_CONN_RES, 
(void *) pdu);
break;
+   case RsproPDUchoice_PR_tpduCardToModem:
+   case RsproPDUchoice_PR_setAtrReq:
default:
-   LOGPFSML(bc->bankd_fi, LOGL_ERROR, "Unknown/Unsuppoerted RSPRO 
PDU %s: %s\n",
-rspro_msgt_name(pdu), msgb_hexdump(msg));
+   LOGPFSML(bankdc->fi, LOGL_ERROR, "Unknown/Unsupported RSPRO PDU 
%s\n",
+rspro_msgt_name(pdu));
return -1;
}

return 0;
 }

-int bankd_read_cb(struct ipa_client_conn *conn, struct msgb *msg)
-{
-   struct ipaccess_head *hh = (struct ipaccess_head *) msg->data;
-   struct ipaccess_head_ext *he = (struct ipaccess_head_ext *) 
msgb_l2(msg);
-   struct bankd_client *bc = conn->data;
-   int rc;
-
-   if (msgb_length(msg) < sizeof(*hh))
-   goto invalid;
-   msg->l2h = >data[0];
-   switch (hh->proto) {
-   case IPAC_PROTO_IPACCESS:
-   rc = ipaccess_bts_handle_ccm(conn, >srv_conn.ipa_dev, msg);
-   if (rc < 0)
-   break;
-   switch (hh->data[0]) {
-   case IPAC_MSGT_PONG:
-   
ipa_keepalive_fsm_pong_received(bc->srv_conn.keepalive_fi);
-   rc = 0;
-   break;
-   default:
-   break;
-   }
-   break;
-   case IPAC_PROTO_OSMO:
-   if (!he || msgb_l2len(msg) < sizeof(*he))
-   goto invalid;
-   msg->l2h = >data[0];
-   switch (he->proto) {
-   case IPAC_PROTO_EXT_RSPRO:
-   LOGPFSML(bc->bankd_fi, LOGL_DEBUG, "Received RSPRO 
%s\n", msgb_hexdump(msg));
-   rc = bankd_handle_msg(bc, msg);
-   break;
-   default:
-   goto invalid;
-   }
-   break;
-   default:
-   goto invalid;
-   }
-
-   msgb_free(msg);
-   return rc;
-
-invalid:
-   msgb_free(msg);
-   return -1;
-}
-
 static struct bankd_client *g_client;
 static void *g_tall_ctx;
 void __thread *talloc_asn1_ctx;
@@ -137,18 +82,21 @@
if (!g_client->srv_conn.clslot)
g_client->srv_conn.clslot = talloc_zero(g_client, 
ClientSlot_t);
*g_client->srv_conn.clslot = 
pdu->msg.choice.configClientIdReq.clientSlot;
+   if (!g_client->bankd_conn.clslot)
+   g_client->bankd_conn.clslot = talloc_zero(g_client, 
ClientSlot_t);
+   

Change in osmo-remsim[master]: client: Add new osmo-remsim-client-shell binary

2020-02-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/17156 )


Change subject: client: Add new osmo-remsim-client-shell binary
..

client: Add new osmo-remsim-client-shell binary

This is a remsim-client with an interactive 'shell', where the user
can type in C-APDUs in hex formats, which will be sent to the bankd /
SIM-card.  Responses received from SIM Card via bankd will be printed
in return.

Change-Id: I636505fd9741833ccf5cbd1bcac30f7b9aa94425
---
M src/client/Makefile.am
M src/client/client.h
M src/client/remsim_client.c
M src/client/simtrace2-remsim_client.c
A src/client/user_shell.c
5 files changed, 182 insertions(+), 9 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/56/17156/1

diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index 3d4f355..ec99818 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -4,10 +4,11 @@
$(OSMOSIMTRACE2_CFLAGS) \
-I$(top_srcdir)/include/osmocom/rspro

-bin_PROGRAMS = osmo-remsim-client-st2 remsim-client
+bin_PROGRAMS = osmo-remsim-client-st2 osmo-remsim-client-shell

-remsim_client_SOURCES = remsim_client.c ../rspro_client_fsm.c ../debug.c
-remsim_client_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOABIS_LIBS) \
+osmo_remsim_client_shell_SOURCES = user_shell.c \
+  remsim_client.c ../rspro_client_fsm.c 
../debug.c
+osmo_remsim_client_shell_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) 
$(OSMOABIS_LIBS) \
  $(top_builddir)/src/libosmo-rspro.la

 osmo_remsim_client_st2_SOURCES = simtrace2-remsim_client.c \
diff --git a/src/client/client.h b/src/client/client.h
index 7cc7ec1..b3001ee 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -56,3 +56,10 @@
struct client_config *cfg;
struct cardem_inst *cardem;
 };
+
+
+extern struct bankd_client *g_client;
+
+extern int client_user_bankd_handle_rx(struct rspro_server_conn *bankdc, const 
RsproPDU_t *pdu);
+
+extern int client_user_main(struct bankd_client *g_client);
diff --git a/src/client/remsim_client.c b/src/client/remsim_client.c
index 41361c0..dbe983b 100644
--- a/src/client/remsim_client.c
+++ b/src/client/remsim_client.c
@@ -52,6 +52,7 @@
break;
case RsproPDUchoice_PR_tpduCardToModem:
case RsproPDUchoice_PR_setAtrReq:
+   return client_user_bankd_handle_rx(bankdc, pdu);
default:
LOGPFSML(bankdc->fi, LOGL_ERROR, "Unknown/Unsupported RSPRO PDU 
%s\n",
 rspro_msgt_name(pdu));
@@ -61,7 +62,7 @@
return 0;
 }

-static struct bankd_client *g_client;
+struct bankd_client *g_client;
 static void *g_tall_ctx;
 void __thread *talloc_asn1_ctx;
 int asn_debug;
@@ -161,7 +162,7 @@
g_client->srv_conn.clslot = 
talloc_zero(g_client, ClientSlot_t);
g_client->srv_conn.clslot->clientId = atoi(optarg);
break;
-   case 's':
+   case 'n':
if (!g_client->srv_conn.clslot)
g_client->srv_conn.clslot = 
talloc_zero(g_client, ClientSlot_t);
g_client->srv_conn.clslot->slotNr = atoi(optarg);
@@ -185,6 +186,7 @@

g_client = talloc_zero(g_tall_ctx, struct bankd_client);

+   /* create and [attempt to] establish connection to remsim-server */
srvc = _client->srv_conn;
srvc->server_host = "localhost";
srvc->server_port = 9998;
@@ -208,6 +210,11 @@
asn_debug = 0;

bankdc = _client->bankd_conn;
+   if (srvc->clslot) {
+   bankdc->clslot = talloc_zero(g_client, ClientSlot_t);
+   *bankdc->clslot = *srvc->clslot;
+   }
+
/* server_host / server_port are configured from remsim-server */
bankdc->handle_rx = bankd_handle_rx;
memcpy(>own_comp_id, >own_comp_id, 
sizeof(bankdc->own_comp_id));
@@ -216,8 +223,7 @@
fprintf(stderr, "Unable to connect bankd conn FSM: %s\n", 
strerror(errno));
exit(1);
}
+   osmo_fsm_inst_update_id(bankdc->fi, "bankd");

-   while (1) {
-   osmo_select_main(0);
-   }
+   client_user_main(g_client);
 }
diff --git a/src/client/simtrace2-remsim_client.c 
b/src/client/simtrace2-remsim_client.c
index ce8ea1d..bee8fc9 100644
--- a/src/client/simtrace2-remsim_client.c
+++ b/src/client/simtrace2-remsim_client.c
@@ -94,7 +94,7 @@
 /* global GSMTAP instance */
 static struct gsmtap_inst *g_gti;

-static struct bankd_client *g_client;
+struct bankd_client *g_client;
 static void *g_tall_ctx;
 void __thread *talloc_asn1_ctx;
 int asn_debug;
diff --git a/src/client/user_shell.c b/src/client/user_shell.c
new file mode 100644
index 000..db36aab
--- /dev/null
+++ b/src/client/user_shell.c
@@ -0,0 +1,159 @@
+#include 
+#include 
+

Change in osmo-remsim[master]: client: Work without global g_client variable

2020-02-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-remsim/+/17157 )


Change subject: client: Work without global g_client variable
..

client: Work without global g_client variable

We may want to develop programs that include multiple instances of
a remsim_client.  Let's remove the global variable 'g_client' and
instead de-reference the bankd_client using container_of() macros

Change-Id: I456fb633561b88912be2f78c3e0264794d921255
---
M src/client/client.h
M src/client/remsim_client.c
M src/client/user_shell.c
3 files changed, 28 insertions(+), 21 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/57/17157/1

diff --git a/src/client/client.h b/src/client/client.h
index b3001ee..0239b55 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -1,5 +1,6 @@
 #pragma once

+#include 
 #include 
 #include 
 #include 
@@ -57,8 +58,9 @@
struct cardem_inst *cardem;
 };

+#define srvc2bankd_client(srvc)container_of(srvc, struct 
bankd_client, srv_conn)
+#define bankdc2bankd_client(bdc)   container_of(bdc, struct bankd_client, 
bankd_conn)

-extern struct bankd_client *g_client;

 extern int client_user_bankd_handle_rx(struct rspro_server_conn *bankdc, const 
RsproPDU_t *pdu);

diff --git a/src/client/remsim_client.c b/src/client/remsim_client.c
index dbe983b..496e1f4 100644
--- a/src/client/remsim_client.c
+++ b/src/client/remsim_client.c
@@ -62,7 +62,7 @@
return 0;
 }

-struct bankd_client *g_client;
+static struct bankd_client *g_client;
 static void *g_tall_ctx;
 void __thread *talloc_asn1_ctx;
 int asn_debug;
@@ -70,6 +70,7 @@
 /* handle incoming messages from server */
 static int srvc_handle_rx(struct rspro_server_conn *srvc, const RsproPDU_t 
*pdu)
 {
+   struct bankd_client *bc = srvc2bankd_client(srvc);
RsproPDU_t  *resp;

switch (pdu->msg.present) {
@@ -80,24 +81,24 @@
break;
case RsproPDUchoice_PR_configClientIdReq:
/* store/set the clientID as instructed by the server */
-   if (!g_client->srv_conn.clslot)
-   g_client->srv_conn.clslot = talloc_zero(g_client, 
ClientSlot_t);
-   *g_client->srv_conn.clslot = 
pdu->msg.choice.configClientIdReq.clientSlot;
-   if (!g_client->bankd_conn.clslot)
-   g_client->bankd_conn.clslot = talloc_zero(g_client, 
ClientSlot_t);
-   *g_client->bankd_conn.clslot = *g_client->srv_conn.clslot;
+   if (!srvc->clslot)
+   srvc->clslot = talloc_zero(srvc, ClientSlot_t);
+   *srvc->clslot = pdu->msg.choice.configClientIdReq.clientSlot;
+   if (!bc->bankd_conn.clslot)
+   bc->bankd_conn.clslot = talloc_zero(bc, ClientSlot_t);
+   *bc->bankd_conn.clslot = *bc->srv_conn.clslot;
/* send response to server */
resp = rspro_gen_ConfigClientIdRes(ResultCode_ok);
server_conn_send_rspro(srvc, resp);
break;
case RsproPDUchoice_PR_configClientBankReq:
/* store/set the bankd ip/port as instructed by the server */
-   osmo_talloc_replace_string(g_client, 
_client->bankd_conn.server_host,
+   osmo_talloc_replace_string(bc, >bankd_conn.server_host,
   
rspro_IpAddr2str(>msg.choice.configClientBankReq.bankd.ip));
-   rspro2bank_slot(_client->bankd_slot, 
>msg.choice.configClientBankReq.bankSlot);
-   g_client->bankd_conn.server_port = 
pdu->msg.choice.configClientBankReq.bankd.port;
+   rspro2bank_slot(>bankd_slot, 
>msg.choice.configClientBankReq.bankSlot);
+   bc->bankd_conn.server_port = 
pdu->msg.choice.configClientBankReq.bankd.port;
/* instruct bankd FSM to connect */
-   osmo_fsm_inst_dispatch(g_client->bankd_conn.fi, 
SRVC_E_ESTABLISH, NULL);
+   osmo_fsm_inst_dispatch(bc->bankd_conn.fi, SRVC_E_ESTABLISH, 
NULL);
/* send response to server */
resp = rspro_gen_ConfigClientBankRes(ResultCode_ok);
server_conn_send_rspro(srvc, resp);
diff --git a/src/client/user_shell.c b/src/client/user_shell.c
index db36aab..d5cad7b 100644
--- a/src/client/user_shell.c
+++ b/src/client/user_shell.c
@@ -48,12 +48,13 @@

 int client_user_bankd_handle_rx(struct rspro_server_conn *bankdc, const 
RsproPDU_t *pdu)
 {
+   struct bankd_client *client = bankdc2bankd_client(bankdc);
switch (pdu->msg.present) {
case RsproPDUchoice_PR_tpduCardToModem:
-   bankd_handle_tpduCardToModem(g_client, pdu);
+   bankd_handle_tpduCardToModem(client, pdu);
break;
case RsproPDUchoice_PR_setAtrReq:
-   bankd_handle_setAtrReq(g_client, pdu);
+   

Change in osmo-remsim[master]: remsim-client: Call an external script in specific situations

2020-02-15 Thread laforge
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/c/osmo-remsim/+/16629

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

Change subject: remsim-client: Call an external script in specific situations
..

remsim-client: Call an external script in specific situations

There are some situations where remsim-client would want to make its
surrounding system aware of, e.g. to take specific action.

This is particularly important on platforms where the simtrace2 firmware
doesn't have direct control over modem reset/poweron or the like.

Change-Id: I61cf4d93c669db137de801f8b147dcffaa6f3abd
Depends: libosmocore.git Ib24ac8a083db32e55402ce496a5eabd8749cc888
Closes: OS#4332
---
M doc/manuals/chapters/remsim-client.adoc
M src/client/simtrace2-remsim_client.c
2 files changed, 141 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/29/16629/6
--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/16629
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I61cf4d93c669db137de801f8b147dcffaa6f3abd
Gerrit-Change-Number: 16629
Gerrit-PatchSet: 6
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: osmo-sim-test: Fall-back to classic SIM

2020-02-15 Thread laforge
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/c/libosmocore/+/17154

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

Change subject: osmo-sim-test: Fall-back to classic SIM
..

osmo-sim-test: Fall-back to classic SIM

If selection of ADF_USIM fails, let's fall-back to reading/dumping
a classic TS 11.11 (51.011) SIM card.

Change-Id: I5a986fc65de76c24c5af52ce7e8c699cf302fda9
---
M include/osmocom/sim/sim.h
M utils/osmo-sim-test.c
2 files changed, 106 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/54/17154/2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17154
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I5a986fc65de76c24c5af52ce7e8c699cf302fda9
Gerrit-Change-Number: 17154
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: osmo-sim-test: Fall-back to classic SIM

2020-02-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17154 )


Change subject: osmo-sim-test: Fall-back to classic SIM
..

osmo-sim-test: Fall-back to classic SIM

If selection of ADF_USIM fails, let's fall-back to reading/dumping
a classic TS 11.11 (51.011) SIM card.

Change-Id: I5a986fc65de76c24c5af52ce7e8c699cf302fda9
---
M include/osmocom/sim/sim.h
M utils/osmo-sim-test.c
2 files changed, 101 insertions(+), 22 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/54/17154/1

diff --git a/include/osmocom/sim/sim.h b/include/osmocom/sim/sim.h
index 2bc4715..8eb3f11 100644
--- a/include/osmocom/sim/sim.h
+++ b/include/osmocom/sim/sim.h
@@ -135,6 +135,7 @@
TYPE_ADF,   /*!< Application Dedicated File */
TYPE_EF,/*!< Entry File */
TYPE_EF_INT,/*!< Internal Entry File */
+   TYPE_MF,/*!< Master File */
 };

 enum osim_ef_type {
diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c
index ea3ce2a..3cb1c59 100644
--- a/utils/osmo-sim-test.c
+++ b/utils/osmo-sim-test.c
@@ -33,6 +33,8 @@

 /* FIXME: this needs to be moved to card_fs_uicc.c */

+static uint8_t g_class = 0x00; /* UICC/USIM */
+
 /* 11.1.1 */
 static struct msgb *_select_file(struct osim_chan_hdl *st, uint8_t p1, uint8_t 
p2,
const uint8_t *data, uint8_t data_len)
@@ -40,7 +42,7 @@
struct msgb *msg;
uint8_t *dst;

-   msg = osim_new_apdumsg(0x00, 0xA4, p1, p2, data_len, 256);
+   msg = osim_new_apdumsg(g_class, 0xA4, p1, p2, data_len, 256);
dst = msgb_put(msg, data_len);
memcpy(dst, data, data_len);

@@ -60,7 +62,7 @@
 {
uint16_t cfid = htons(fid);

-   return _select_file(st, 0x00, 0x04, (uint8_t *), 2);
+   return _select_file(st, 0x00, 0x00, (uint8_t *), 2);
 }

 /* 11.1.9 */
@@ -72,7 +74,7 @@
if (strlen(pin) > 8)
return -EINVAL;
 
-   msg = osim_new_apdumsg(0x00, 0x20, 0x00, pin_nr, 8, 0);
+   msg = osim_new_apdumsg(g_class, 0x20, 0x00, pin_nr, 8, 0);
pindst = (char *) msgb_put(msg, 8);
memset(pindst, 0xFF, 8);
/* Do not copy the terminating \0 */
@@ -86,7 +88,7 @@
 {
struct msgb *msg;

-   msg = osim_new_apdumsg(0x00, 0xB2, rec_nr, 0x04, 0, rec_size);
+   msg = osim_new_apdumsg(g_class, 0xB2, rec_nr, 0x04, 0, rec_size);

osim_transceive_apdu(st, msg);

@@ -101,7 +103,7 @@
if (offset > 0x7fff || len > 256)
return NULL;

-   msg = osim_new_apdumsg(0x00, 0xB0, offset >> 8, offset & 0xff, 0, len & 
0xff);
+   msg = osim_new_apdumsg(g_class, 0xB0, offset >> 8, offset & 0xff, 0, 
len & 0xff);

osim_transceive_apdu(st, msg);

@@ -175,7 +177,61 @@
return 0;
 }

+/* TS 51.011 Section 9.3 Type of File */
+static const enum osim_file_type sim2ftype[8] = {
+   [1] = TYPE_MF,
+   [2] = TYPE_DF,
+   [4] = TYPE_EF,
+};
+
+/* TS 51.011 Section 9.3 Structure of File */
+static const enum osim_ef_type sim2eftype[8] = {
+   [0] = EF_TYPE_TRANSP,
+   [1] = EF_TYPE_RECORD_FIXED,
+   [3] = EF_TYPE_RECORD_CYCLIC,
+};
+
+/* TS 51.011 Section 9.2.1 */
+static int osim_fcp_fd_decode_sim(struct osim_fcp_fd_decoded *ofd, const 
uint8_t *fcp, int fcp_len)
+{
+   memset(ofd, 0, sizeof(*ofd));
+
+   if (fcp_len < 14)
+   return -EINVAL;
+
+   ofd->type = sim2ftype[fcp[6] & 7];
+   switch (ofd->type) {
+   case TYPE_EF:
+   ofd->ef_type = sim2eftype[fcp[13] & 7];
+   if (fcp_len < 13 + fcp[12])
+   return -EINVAL;
+   switch (ofd->ef_type) {
+   case EF_TYPE_RECORD_FIXED:
+   case EF_TYPE_RECORD_CYCLIC:
+   if (fcp_len < 15)
+   return -EINVAL;
+   ofd->rec_len = fcp[14];
+   ofd->num_rec = ntohs(*(uint16_t *)(fcp+2)) / 
ofd->rec_len;
+   break;
+   default:
+   break;
+   }
+   break;
+   case TYPE_MF:
+   case TYPE_DF:
+   if (fcp_len < 22)
+   return -EINVAL;
+   break;
+   default:
+   break;
+   }
+
+   return 0;
+}
+
+extern struct osim_card_profile *osim_cprof_sim(void *ctx);
 extern struct osim_card_profile *osim_cprof_usim(void *ctx);
+extern struct osim_card_profile *osim_cprof_isim(void *ctx);

 static struct msgb *try_select_adf_usim(struct osim_chan_hdl *st)
 {
@@ -186,9 +242,17 @@
int rc, i;

msg = select_file(st, 0x2f00);
-   rc = tlv_parse(, _fcp_tlv_def, msgb_apdu_de(msg)+2, 
msgb_apdu_le(msg)-2, 0, 0);
-   if (rc < 0)
+   if (!msg)
return NULL;
+   /* return status word in case of error */
+   if (msgb_apdu_sw(msg) != 0x9000)
+   

Change in libosmocore[master]: osmo-sim-test: Recurse through subdirectories

2020-02-15 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17153 )


Change subject: osmo-sim-test: Recurse through subdirectories
..

osmo-sim-test: Recurse through subdirectories

Don't just iterate over all files in the current working
directory (cwd), but also recurse through all sub-directories.

Change-Id: I737b01d9a845e37d8be9d4709ef0de04e749daec
---
M utils/osmo-sim-test.c
1 file changed, 39 insertions(+), 13 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/53/17153/1

diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c
index cd98397..ea3ce2a 100644
--- a/utils/osmo-sim-test.c
+++ b/utils/osmo-sim-test.c
@@ -374,6 +374,44 @@
}
 }

+
+static void iterate_fs(struct osim_chan_hdl *chan)
+{
+   const struct osim_file_desc *prev_cwd;
+   struct osim_file_desc *ofd;
+
+   /* iterate over all files in current working directory */
+   llist_for_each_entry(ofd, >cwd->child_list, list) {
+   struct msgb *m;
+   printf("\n\n %s (%s) ==\n",
+   ofd->short_name, ofd->long_name);
+
+   m = select_file(chan, ofd->fid);
+   if (msgb_apdu_sw(m) != 0x9000) {
+   msgb_free(m);
+   continue;
+   }
+   dump_fcp_template_msg(m);
+   msgb_free(m);
+
+   /* If this is a DF, recurse into it */
+   switch (ofd->type) {
+   case TYPE_DF:
+   /* the select above has just changed into this 
directory */
+   prev_cwd = chan->cwd;
+   chan->cwd = ofd;
+   iterate_fs(chan);
+   /* "pop" the directory from the stack */
+   chan->cwd = prev_cwd;
+   break;
+   default:
+   dump_file(chan, ofd->fid);
+   break;
+   }
+   }
+}
+
+
 int main(int argc, char **argv)
 {
struct osim_reader_hdl *reader;
@@ -410,19 +448,7 @@
dump_fcp_template_msg(msg);
msgb_free(msg);

-   {
-   struct osim_file_desc *ofd;
-   llist_for_each_entry(ofd, >cwd->child_list, list) {
-   struct msgb *m;
-   printf("\n\n %s (%s) 
==\n",
-   ofd->short_name, ofd->long_name);
-
-   m = select_file(chan, ofd->fid);
-   dump_fcp_template_msg(m);
-   msgb_free(m);
-   dump_file(chan, ofd->fid);
-   }
-   }
+   iterate_fs(chan);

exit(0);
 }

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17153
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I737b01d9a845e37d8be9d4709ef0de04e749daec
Gerrit-Change-Number: 17153
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in pysim[master]: pySim-prog.py: add support for MSISDN programming

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/16946 )

Change subject: pySim-prog.py: add support for MSISDN programming
..


Patch Set 11: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/16946
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie033a0ffc3697ae562eaa7a241a0f6af6c2b0594
Gerrit-Change-Number: 16946
Gerrit-PatchSet: 11
Gerrit-Owner: herlesupreeth 
Gerrit-Assignee: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-CC: dexter 
Gerrit-Comment-Date: Sat, 15 Feb 2020 09:31:17 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in pysim[master]: pySim-read.py: print meaningful message when SPN is not set

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/16981 )

Change subject: pySim-read.py: print meaningful message when SPN is not set
..


Patch Set 5: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/16981
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I1d98520f33a8564c7d69f50a0811204f138f9dca
Gerrit-Change-Number: 16981
Gerrit-PatchSet: 5
Gerrit-Owner: herlesupreeth 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-CC: fixeria 
Gerrit-Comment-Date: Sat, 15 Feb 2020 09:29:47 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in pysim[master]: pySim-read.py: fix reading and parsing of EF.MSISDN

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/16947 )

Change subject: pySim-read.py: fix reading and parsing of EF.MSISDN
..


Patch Set 19: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/16947
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie914ae83d787e3f1a90f9f305bffd45053b8c863
Gerrit-Change-Number: 16947
Gerrit-PatchSet: 19
Gerrit-Owner: herlesupreeth 
Gerrit-Assignee: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: herlesupreeth 
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: neels 
Gerrit-CC: dexter 
Gerrit-Comment-Date: Sat, 15 Feb 2020 09:30:03 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in pysim[master]: pySim-read.py: do not import json, it is not needed

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/17151 )

Change subject: pySim-read.py: do not import json, it is not needed
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/17151
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I4ae1d71c5695c9cd8ddebea514847b0be6a24c6c
Gerrit-Change-Number: 17151
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 09:29:17 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in pysim[master]: Py2 -> Py3: use the floor division operator // where possible

2020-02-15 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/17152 )

Change subject: Py2 -> Py3: use the floor division operator // where possible
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/17152
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I5565eb64a1ddea7075cbb142eaacaa5d494c87bb
Gerrit-Change-Number: 17152
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 15 Feb 2020 09:29:07 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-pcu[master]: gsm_rlcmac.cpp: fix another global-buffer-overflow error reported by ...

2020-02-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/17053 )

Change subject: gsm_rlcmac.cpp: fix another global-buffer-overflow error 
reported by ASAN
..

gsm_rlcmac.cpp: fix another global-buffer-overflow error reported by ASAN

Port from wireshark.git aa3bbe5aebdc180172e7956719b26199e4784fcc.

Ported-by: Pau Espin Pedrol 
Change-Id: I808ec66011cdfe8e1193298f7fb7e92d25b45be4
---
M src/gsm_rlcmac.cpp
1 file changed, 4 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/gsm_rlcmac.cpp b/src/gsm_rlcmac.cpp
index 546e7fb..839bfbb 100644
--- a/src/gsm_rlcmac.cpp
+++ b/src/gsm_rlcmac.cpp
@@ -1130,7 +1130,10 @@
   M_NEXT_EXIST (Ext_Channel_Request_desc_t, Exist_LCC_PDU, 1),
   M_UINT   (Ext_Channel_Request_desc_t,  LCC_PDU,  1),

-  M_NEXT_EXIST (Ext_Channel_Request_desc_t, Exist_Ext_Channel_Request_desc, 
1), /* Don't use M_REC_TARRAY as we don't support multiple TBFs */
+ /* Don't use M_REC_TARRAY as we don't support multiple TBFs
+  M_NEXT_EXIST (Ext_Channel_Request_desc_t, Exist_Ext_Channel_Request_desc, 1),
+  M_TYPE   (Ext_Channel_Request_desc_t, Ext_Channel_Request_desc, 
Ext_Channel_Request_desc_t),*/
+  M_UINT   (Ext_Channel_Request_desc_t, Exist_Ext_Channel_Request_desc, 1),

 CSN_DESCR_END  (Ext_Channel_Request_desc_t)


--
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/17053
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I808ec66011cdfe8e1193298f7fb7e92d25b45be4
Gerrit-Change-Number: 17053
Gerrit-PatchSet: 3
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in osmo-pcu[master]: gsm_rlcmac.cpp: fix global-buffer-overflow error reported by ASAN

2020-02-15 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/17052 )

Change subject: gsm_rlcmac.cpp: fix global-buffer-overflow error reported by 
ASAN
..

gsm_rlcmac.cpp: fix global-buffer-overflow error reported by ASAN

Port from wireshark.git f751918476bdde65f2289b86245a3c30dace6730.

Ported-by: Pau Espin Pedrol 
Change-Id: I70d4ff3e137b5fd13d367bd4ea6ab501e81e7a87
---
M src/gsm_rlcmac.cpp
1 file changed, 4 insertions(+), 1 deletion(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/gsm_rlcmac.cpp b/src/gsm_rlcmac.cpp
index 839bfbb..403b65e 100644
--- a/src/gsm_rlcmac.cpp
+++ b/src/gsm_rlcmac.cpp
@@ -1105,7 +1105,10 @@
   M_NEXT_EXIST (IU_Mode_Channel_Request_Desk_t, Exist_RLC_BLOCK_COUNT, 1),
   M_UINT   (IU_Mode_Channel_Request_Desk_t,  RLC_BLOCK_COUNT,  8),

-  M_NEXT_EXIST (IU_Mode_Channel_Request_Desk_t, Exist_Iu_Mode_ChRequestDesk, 
1), /* Don't use M_REC_TARRAY as we don't support multiple TBFs */
+  /* Don't use M_REC_TARRAY as we don't support multiple TBFs
+  M_NEXT_EXIST (IU_Mode_Channel_Request_Desk_t, Exist_Iu_Mode_ChRequestDesk, 
1),
+  M_TYPE   (IU_Mode_Channel_Request_Desk1, 
IU_Mode_Channel_Request_Desk_t),*/
+  M_UINT   (IU_Mode_Channel_Request_Desk_t, Exist_Iu_Mode_ChRequestDesk, 
1),

 CSN_DESCR_END  (IU_Mode_Channel_Request_Desk_t)


--
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/17052
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I70d4ff3e137b5fd13d367bd4ea6ab501e81e7a87
Gerrit-Change-Number: 17052
Gerrit-PatchSet: 4
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged