From axilirator at gmail.com Fri Jan 1 16:35:58 2016 From: axilirator at gmail.com (=?UTF-8?B?0JLQsNC00LjQvCDQr9C90LjRhtC60LjQuQ==?=) Date: Fri, 1 Jan 2016 22:35:58 +0600 Subject: [PATCH] mobile_app: fix some configuration r/w bugs Message-ID: Happy New Year to all lists members! This patch fixes two bugs in mobile app: 1) If SAP connection fails mobile app does not save the sap-socket param in mobile.cfg. 2) The write command saves two unreadable strings: gpsd host HOST gpsd port PORT instead of: gpsd host HOST:PORT Patch source: diff --git a/src/host/layer23/include/osmocom/bb/common/sap_interface.h b/src/host/layer23/include/osmocom/bb/common/sap_interface.h index bf19356..e4e64ce 100644 --- a/src/host/layer23/include/osmocom/bb/common/sap_interface.h +++ b/src/host/layer23/include/osmocom/bb/common/sap_interface.h @@ -11,6 +11,7 @@ int osmosap_sapsocket(struct osmocom_ms *ms, const char *path); int osmosap_init(struct osmocom_ms *ms); enum osmosap_state { + SAP_SOCKET_ERROR, SAP_NOT_CONNECTED, SAP_IDLE, SAP_CONNECTION_UNDER_NEGOTIATION, diff --git a/src/host/layer23/src/common/sap_interface.c b/src/host/layer23/src/common/sap_interface.c index a56f4f2..33bfa6c 100644 --- a/src/host/layer23/src/common/sap_interface.c +++ b/src/host/layer23/src/common/sap_interface.c @@ -515,7 +515,8 @@ int sap_open(struct osmocom_ms *ms, const char *socket_path) rc = connect(ms->sap_wq.bfd.fd, (struct sockaddr *) &local, sizeof(local)); if (rc < 0) { fprintf(stderr, "Failed to connect to '%s'\n", local.sun_path); - set->sap_socket_path[0] = 0; + // set->sap_socket_path[0] = 0; + ms->sap_entity.sap_state == SAP_SOCKET_ERROR; close(ms->sap_wq.bfd.fd); return rc; } diff --git a/src/host/layer23/src/common/sim.c b/src/host/layer23/src/common/sim.c index 8e8d7bf..df9fbd2 100644 --- a/src/host/layer23/src/common/sim.c +++ b/src/host/layer23/src/common/sim.c @@ -188,7 +188,7 @@ static int sim_apdu_send(struct osmocom_ms *ms, uint8_t *data, uint16_t length) /* adding SAP client support * it makes more sense to do it here then in L1CTL */ - if(ms->settings.sap_socket_path[0] == 0) { + if(ms->sap_entity.sap_state == SAP_SOCKET_ERROR) { LOGP(DSIM, LOGL_INFO, "Using built-in SIM reader\n"); l1ctl_tx_sim_req(ms, data, length); } else { diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c index 5782a17..9ac2221 100644 --- a/src/host/layer23/src/mobile/vty_interface.c +++ b/src/host/layer23/src/mobile/vty_interface.c @@ -1067,7 +1067,7 @@ DEFUN(cfg_no_gps_enable, cfg_no_gps_enable_cmd, "no gps enable", } #ifdef _HAVE_GPSD -DEFUN(cfg_gps_host, cfg_gps_host_cmd, "gps host HOST:PORT", +DEFUN(cfg_gps_host, cfg_gps_host_cmd, "gpsd host HOST:PORT", "GPS receiver\nSelect gpsd host and port\n" "IP and port (optional) of the host running gpsd") { @@ -1499,8 +1499,7 @@ static int config_write(struct vty *vty) struct osmocom_ms *ms; #ifdef _HAVE_GPSD - vty_out(vty, "gpsd host %s%s", g.gpsd_host, VTY_NEWLINE); - vty_out(vty, "gpsd port %s%s", g.gpsd_port, VTY_NEWLINE); + vty_out(vty, "gpsd host %s:%s%s", g.gpsd_host, g.gpsd_port, VTY_NEWLINE); #endif vty_out(vty, "gps device %s%s", g.device, VTY_NEWLINE); if (g.baud) -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: wmn.patch Type: text/x-patch Size: 2709 bytes Desc: not available URL: From axilirator at gmail.com Sat Jan 2 19:14:23 2016 From: axilirator at gmail.com (=?UTF-8?B?0JLQsNC00LjQvCDQr9C90LjRhtC60LjQuQ==?=) Date: Sun, 3 Jan 2016 01:14:23 +0600 Subject: [PATCH] mobile_app: fix some configuration r/w bugs In-Reply-To: References: Message-ID: Previous patch did not fixed one more bug: old code reads GPSD port with a colon. I have fixed it. Final patch version: diff --git a/src/host/layer23/include/osmocom/bb/common/sap_interface.h b/src/host/layer23/include/osmocom/bb/common/sap_interface.h index bf19356..e4e64ce 100644 --- a/src/host/layer23/include/osmocom/bb/common/sap_interface.h +++ b/src/host/layer23/include/osmocom/bb/common/sap_interface.h @@ -11,6 +11,7 @@ int osmosap_sapsocket(struct osmocom_ms *ms, const char *path); int osmosap_init(struct osmocom_ms *ms); enum osmosap_state { + SAP_SOCKET_ERROR, SAP_NOT_CONNECTED, SAP_IDLE, SAP_CONNECTION_UNDER_NEGOTIATION, diff --git a/src/host/layer23/src/common/sap_interface.c b/src/host/layer23/src/common/sap_interface.c index a56f4f2..33bfa6c 100644 --- a/src/host/layer23/src/common/sap_interface.c +++ b/src/host/layer23/src/common/sap_interface.c @@ -515,7 +515,8 @@ int sap_open(struct osmocom_ms *ms, const char *socket_path) rc = connect(ms->sap_wq.bfd.fd, (struct sockaddr *) &local, sizeof(local)); if (rc < 0) { fprintf(stderr, "Failed to connect to '%s'\n", local.sun_path); - set->sap_socket_path[0] = 0; + // set->sap_socket_path[0] = 0; + ms->sap_entity.sap_state == SAP_SOCKET_ERROR; close(ms->sap_wq.bfd.fd); return rc; } diff --git a/src/host/layer23/src/common/sim.c b/src/host/layer23/src/common/sim.c index 8e8d7bf..df9fbd2 100644 --- a/src/host/layer23/src/common/sim.c +++ b/src/host/layer23/src/common/sim.c @@ -188,7 +188,7 @@ static int sim_apdu_send(struct osmocom_ms *ms, uint8_t *data, uint16_t length) /* adding SAP client support * it makes more sense to do it here then in L1CTL */ - if(ms->settings.sap_socket_path[0] == 0) { + if(ms->sap_entity.sap_state == SAP_SOCKET_ERROR) { LOGP(DSIM, LOGL_INFO, "Using built-in SIM reader\n"); l1ctl_tx_sim_req(ms, data, length); } else { diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c index 5782a17..fd0fd0c 100644 --- a/src/host/layer23/src/mobile/vty_interface.c +++ b/src/host/layer23/src/mobile/vty_interface.c @@ -1067,7 +1067,7 @@ DEFUN(cfg_no_gps_enable, cfg_no_gps_enable_cmd, "no gps enable", } #ifdef _HAVE_GPSD -DEFUN(cfg_gps_host, cfg_gps_host_cmd, "gps host HOST:PORT", +DEFUN(cfg_gpsd_host, cfg_gpsd_host_cmd, "gpsd host HOST:PORT", "GPS receiver\nSelect gpsd host and port\n" "IP and port (optional) of the host running gpsd") { @@ -1075,7 +1075,7 @@ DEFUN(cfg_gps_host, cfg_gps_host_cmd, "gps host HOST:PORT", if (colon != NULL) { memcpy(g.gpsd_host, argv[0], colon - argv[0] - 1); g.gpsd_host[colon - argv[0]] = '\0'; - memcpy(g.gpsd_port, colon, strlen(colon)); + memcpy(g.gpsd_port, colon + 1, strlen(colon)); g.gpsd_port[strlen(colon)] = '\0'; } else { snprintf(g.gpsd_host, ARRAY_SIZE(g.gpsd_host), "%s", argv[0]); @@ -1499,8 +1499,7 @@ static int config_write(struct vty *vty) struct osmocom_ms *ms; #ifdef _HAVE_GPSD - vty_out(vty, "gpsd host %s%s", g.gpsd_host, VTY_NEWLINE); - vty_out(vty, "gpsd port %s%s", g.gpsd_port, VTY_NEWLINE); + vty_out(vty, "gpsd host %s:%s%s", g.gpsd_host, g.gpsd_port, VTY_NEWLINE); #endif vty_out(vty, "gps device %s%s", g.device, VTY_NEWLINE); if (g.baud) @@ -2822,7 +2821,7 @@ int ms_vty_init(void) install_element(ENABLE_NODE, &delete_forbidden_plmn_cmd); #ifdef _HAVE_GPSD - install_element(CONFIG_NODE, &cfg_gps_host_cmd); + install_element(CONFIG_NODE, &cfg_gpsd_host_cmd); #endif install_element(CONFIG_NODE, &cfg_gps_device_cmd); install_element(CONFIG_NODE, &cfg_gps_baud_cmd); 2016-01-01 22:35 GMT+06:00 ????? ??????? : > Happy New Year to all lists members! > > This patch fixes two bugs in mobile app: > 1) If SAP connection fails mobile app does not save the sap-socket param > in mobile.cfg. > 2) The write command saves two unreadable strings: > gpsd host HOST > gpsd port PORT > > instead of: > gpsd host HOST:PORT > > Patch source: > diff --git a/src/host/layer23/include/osmocom/bb/common/sap_interface.h > b/src/host/layer23/include/osmocom/bb/common/sap_interface.h > index bf19356..e4e64ce 100644 > --- a/src/host/layer23/include/osmocom/bb/common/sap_interface.h > +++ b/src/host/layer23/include/osmocom/bb/common/sap_interface.h > @@ -11,6 +11,7 @@ int osmosap_sapsocket(struct osmocom_ms *ms, const char > *path); > int osmosap_init(struct osmocom_ms *ms); > > enum osmosap_state { > + SAP_SOCKET_ERROR, > SAP_NOT_CONNECTED, > SAP_IDLE, > SAP_CONNECTION_UNDER_NEGOTIATION, > diff --git a/src/host/layer23/src/common/sap_interface.c > b/src/host/layer23/src/common/sap_interface.c > index a56f4f2..33bfa6c 100644 > --- a/src/host/layer23/src/common/sap_interface.c > +++ b/src/host/layer23/src/common/sap_interface.c > @@ -515,7 +515,8 @@ int sap_open(struct osmocom_ms *ms, const char > *socket_path) > rc = connect(ms->sap_wq.bfd.fd, (struct sockaddr *) &local, > sizeof(local)); > if (rc < 0) { > fprintf(stderr, "Failed to connect to '%s'\n", local.sun_path); > - set->sap_socket_path[0] = 0; > + // set->sap_socket_path[0] = 0; > + ms->sap_entity.sap_state == SAP_SOCKET_ERROR; > close(ms->sap_wq.bfd.fd); > return rc; > } > diff --git a/src/host/layer23/src/common/sim.c > b/src/host/layer23/src/common/sim.c > index 8e8d7bf..df9fbd2 100644 > --- a/src/host/layer23/src/common/sim.c > +++ b/src/host/layer23/src/common/sim.c > @@ -188,7 +188,7 @@ static int sim_apdu_send(struct osmocom_ms *ms, > uint8_t *data, uint16_t length) > > /* adding SAP client support > * it makes more sense to do it here then in L1CTL */ > - if(ms->settings.sap_socket_path[0] == 0) { > + if(ms->sap_entity.sap_state == SAP_SOCKET_ERROR) { > LOGP(DSIM, LOGL_INFO, "Using built-in SIM reader\n"); > l1ctl_tx_sim_req(ms, data, length); > } else { > diff --git a/src/host/layer23/src/mobile/vty_interface.c > b/src/host/layer23/src/mobile/vty_interface.c > index 5782a17..9ac2221 100644 > --- a/src/host/layer23/src/mobile/vty_interface.c > +++ b/src/host/layer23/src/mobile/vty_interface.c > @@ -1067,7 +1067,7 @@ DEFUN(cfg_no_gps_enable, cfg_no_gps_enable_cmd, "no > gps enable", > } > > #ifdef _HAVE_GPSD > -DEFUN(cfg_gps_host, cfg_gps_host_cmd, "gps host HOST:PORT", > +DEFUN(cfg_gps_host, cfg_gps_host_cmd, "gpsd host HOST:PORT", > "GPS receiver\nSelect gpsd host and port\n" > "IP and port (optional) of the host running gpsd") > { > @@ -1499,8 +1499,7 @@ static int config_write(struct vty *vty) > struct osmocom_ms *ms; > > #ifdef _HAVE_GPSD > - vty_out(vty, "gpsd host %s%s", g.gpsd_host, VTY_NEWLINE); > - vty_out(vty, "gpsd port %s%s", g.gpsd_port, VTY_NEWLINE); > + vty_out(vty, "gpsd host %s:%s%s", g.gpsd_host, g.gpsd_port, > VTY_NEWLINE); > #endif > vty_out(vty, "gps device %s%s", g.device, VTY_NEWLINE); > if (g.baud) > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From laforge at gnumonks.org Sat Jan 2 19:19:57 2016 From: laforge at gnumonks.org (Harald Welte) Date: Sat, 2 Jan 2016 20:19:57 +0100 Subject: [PATCH] mobile_app: fix some configuration r/w bugs In-Reply-To: References: Message-ID: <20160102191957.GB4704@nataraja> Hi Vadim, thanks for your patch, but.. On Sun, Jan 03, 2016 at 01:14:23AM +0600, ????? ??????? wrote: > - set->sap_socket_path[0] = 0; > + // set->sap_socket_path[0] = 0; > + ms->sap_entity.sap_state == SAP_SOCKET_ERROR; a) if you remove code, remove it for good, not just comment it out b) the double-equals will not cause an assignment. I don't think you tested this code... Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From axilirator at gmail.com Sat Jan 2 19:42:33 2016 From: axilirator at gmail.com (=?UTF-8?B?0JLQsNC00LjQvCDQr9C90LjRhtC60LjQuQ==?=) Date: Sun, 3 Jan 2016 01:42:33 +0600 Subject: [PATCH] mobile_app: fix some configuration r/w bugs In-Reply-To: References: <20160102191957.GB4704@nataraja> Message-ID: Sorry, it was a Copy/Paste style mistake. Fixed. diff --git a/src/host/layer23/include/osmocom/bb/common/sap_interface.h b/src/host/layer23/include/osmocom/bb/common/sap_interface.h index bf19356..e4e64ce 100644 --- a/src/host/layer23/include/osmocom/bb/common/sap_interface.h +++ b/src/host/layer23/include/osmocom/bb/common/sap_interface.h @@ -11,6 +11,7 @@ int osmosap_sapsocket(struct osmocom_ms *ms, const char *path); int osmosap_init(struct osmocom_ms *ms); enum osmosap_state { + SAP_SOCKET_ERROR, SAP_NOT_CONNECTED, SAP_IDLE, SAP_CONNECTION_UNDER_NEGOTIATION, diff --git a/src/host/layer23/src/common/sap_interface.c b/src/host/layer23/src/common/sap_interface.c index a56f4f2..d5e8d1d 100644 --- a/src/host/layer23/src/common/sap_interface.c +++ b/src/host/layer23/src/common/sap_interface.c @@ -515,7 +515,7 @@ int sap_open(struct osmocom_ms *ms, const char *socket_path) rc = connect(ms->sap_wq.bfd.fd, (struct sockaddr *) &local, sizeof(local)); if (rc < 0) { fprintf(stderr, "Failed to connect to '%s'\n", local.sun_path); - set->sap_socket_path[0] = 0; + ms->sap_entity.sap_state = SAP_SOCKET_ERROR; close(ms->sap_wq.bfd.fd); return rc; } diff --git a/src/host/layer23/src/common/sim.c b/src/host/layer23/src/common/sim.c index 8e8d7bf..df9fbd2 100644 --- a/src/host/layer23/src/common/sim.c +++ b/src/host/layer23/src/common/sim.c @@ -188,7 +188,7 @@ static int sim_apdu_send(struct osmocom_ms *ms, uint8_t *data, uint16_t length) /* adding SAP client support * it makes more sense to do it here then in L1CTL */ - if(ms->settings.sap_socket_path[0] == 0) { + if(ms->sap_entity.sap_state == SAP_SOCKET_ERROR) { LOGP(DSIM, LOGL_INFO, "Using built-in SIM reader\n"); l1ctl_tx_sim_req(ms, data, length); } else { diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c index 5782a17..fd0fd0c 100644 --- a/src/host/layer23/src/mobile/vty_interface.c +++ b/src/host/layer23/src/mobile/vty_interface.c @@ -1067,7 +1067,7 @@ DEFUN(cfg_no_gps_enable, cfg_no_gps_enable_cmd, "no gps enable", } #ifdef _HAVE_GPSD -DEFUN(cfg_gps_host, cfg_gps_host_cmd, "gps host HOST:PORT", +DEFUN(cfg_gpsd_host, cfg_gpsd_host_cmd, "gpsd host HOST:PORT", "GPS receiver\nSelect gpsd host and port\n" "IP and port (optional) of the host running gpsd") { @@ -1075,7 +1075,7 @@ DEFUN(cfg_gps_host, cfg_gps_host_cmd, "gps host HOST:PORT", if (colon != NULL) { memcpy(g.gpsd_host, argv[0], colon - argv[0] - 1); g.gpsd_host[colon - argv[0]] = '\0'; - memcpy(g.gpsd_port, colon, strlen(colon)); + memcpy(g.gpsd_port, colon + 1, strlen(colon)); g.gpsd_port[strlen(colon)] = '\0'; } else { snprintf(g.gpsd_host, ARRAY_SIZE(g.gpsd_host), "%s", argv[0]); @@ -1499,8 +1499,7 @@ static int config_write(struct vty *vty) struct osmocom_ms *ms; #ifdef _HAVE_GPSD - vty_out(vty, "gpsd host %s%s", g.gpsd_host, VTY_NEWLINE); - vty_out(vty, "gpsd port %s%s", g.gpsd_port, VTY_NEWLINE); + vty_out(vty, "gpsd host %s:%s%s", g.gpsd_host, g.gpsd_port, VTY_NEWLINE); #endif vty_out(vty, "gps device %s%s", g.device, VTY_NEWLINE); if (g.baud) @@ -2822,7 +2821,7 @@ int ms_vty_init(void) install_element(ENABLE_NODE, &delete_forbidden_plmn_cmd); #ifdef _HAVE_GPSD - install_element(CONFIG_NODE, &cfg_gps_host_cmd); + install_element(CONFIG_NODE, &cfg_gpsd_host_cmd); #endif install_element(CONFIG_NODE, &cfg_gps_device_cmd); install_element(CONFIG_NODE, &cfg_gps_baud_cmd); 2016-01-03 1:38 GMT+06:00 ????? ??????? : > Sorry, was a Copy/Paste mistake. Fixed. > > diff --git a/src/host/layer23/include/osmocom/bb/common/sap_interface.h > b/src/host/layer23/include/osmocom/bb/common/sap_interface.h > index bf19356..e4e64ce 100644 > --- a/src/host/layer23/include/osmocom/bb/common/sap_interface.h > +++ b/src/host/layer23/include/osmocom/bb/common/sap_interface.h > @@ -11,6 +11,7 @@ int osmosap_sapsocket(struct osmocom_ms *ms, const char > *path); > int osmosap_init(struct osmocom_ms *ms); > > enum osmosap_state { > + SAP_SOCKET_ERROR, > SAP_NOT_CONNECTED, > SAP_IDLE, > SAP_CONNECTION_UNDER_NEGOTIATION, > diff --git a/src/host/layer23/src/common/sap_interface.c > b/src/host/layer23/src/common/sap_interface.c > index a56f4f2..d5e8d1d 100644 > --- a/src/host/layer23/src/common/sap_interface.c > +++ b/src/host/layer23/src/common/sap_interface.c > @@ -515,7 +515,7 @@ int sap_open(struct osmocom_ms *ms, const char > *socket_path) > rc = connect(ms->sap_wq.bfd.fd, (struct sockaddr *) &local, > sizeof(local)); > if (rc < 0) { > fprintf(stderr, "Failed to connect to '%s'\n", local.sun_path); > - set->sap_socket_path[0] = 0; > + ms->sap_entity.sap_state = SAP_SOCKET_ERROR; > > close(ms->sap_wq.bfd.fd); > return rc; > } > diff --git a/src/host/layer23/src/common/sim.c > b/src/host/layer23/src/common/sim.c > index 8e8d7bf..df9fbd2 100644 > --- a/src/host/layer23/src/common/sim.c > +++ b/src/host/layer23/src/common/sim.c > @@ -188,7 +188,7 @@ static int sim_apdu_send(struct osmocom_ms *ms, > uint8_t *data, uint16_t length) > > /* adding SAP client support > * it makes more sense to do it here then in L1CTL */ > - if(ms->settings.sap_socket_path[0] == 0) { > + if(ms->sap_entity.sap_state == SAP_SOCKET_ERROR) { > LOGP(DSIM, LOGL_INFO, "Using built-in SIM reader\n"); > l1ctl_tx_sim_req(ms, data, length); > } else { > diff --git a/src/host/layer23/src/mobile/vty_interface.c > b/src/host/layer23/src/mobile/vty_interface.c > index 5782a17..fd0fd0c 100644 > --- a/src/host/layer23/src/mobile/vty_interface.c > +++ b/src/host/layer23/src/mobile/vty_interface.c > @@ -1067,7 +1067,7 @@ DEFUN(cfg_no_gps_enable, cfg_no_gps_enable_cmd, "no > gps enable", > } > > #ifdef _HAVE_GPSD > -DEFUN(cfg_gps_host, cfg_gps_host_cmd, "gps host HOST:PORT", > +DEFUN(cfg_gpsd_host, cfg_gpsd_host_cmd, "gpsd host HOST:PORT", > "GPS receiver\nSelect gpsd host and port\n" > "IP and port (optional) of the host running gpsd") > { > @@ -1075,7 +1075,7 @@ DEFUN(cfg_gps_host, cfg_gps_host_cmd, "gps host > HOST:PORT", > if (colon != NULL) { > memcpy(g.gpsd_host, argv[0], colon - argv[0] - 1); > g.gpsd_host[colon - argv[0]] = '\0'; > - memcpy(g.gpsd_port, colon, strlen(colon)); > + memcpy(g.gpsd_port, colon + 1, strlen(colon)); > g.gpsd_port[strlen(colon)] = '\0'; > } else { > snprintf(g.gpsd_host, ARRAY_SIZE(g.gpsd_host), "%s", argv[0]); > @@ -1499,8 +1499,7 @@ static int config_write(struct vty *vty) > struct osmocom_ms *ms; > > #ifdef _HAVE_GPSD > - vty_out(vty, "gpsd host %s%s", g.gpsd_host, VTY_NEWLINE); > - vty_out(vty, "gpsd port %s%s", g.gpsd_port, VTY_NEWLINE); > + vty_out(vty, "gpsd host %s:%s%s", g.gpsd_host, g.gpsd_port, > VTY_NEWLINE); > #endif > vty_out(vty, "gps device %s%s", g.device, VTY_NEWLINE); > if (g.baud) > @@ -2822,7 +2821,7 @@ int ms_vty_init(void) > install_element(ENABLE_NODE, &delete_forbidden_plmn_cmd); > > #ifdef _HAVE_GPSD > - install_element(CONFIG_NODE, &cfg_gps_host_cmd); > + install_element(CONFIG_NODE, &cfg_gpsd_host_cmd); > #endif > install_element(CONFIG_NODE, &cfg_gps_device_cmd); > install_element(CONFIG_NODE, &cfg_gps_baud_cmd); > > > 2016-01-03 1:19 GMT+06:00 Harald Welte : > >> Hi Vadim, >> >> thanks for your patch, but.. >> >> On Sun, Jan 03, 2016 at 01:14:23AM +0600, ????? ??????? wrote: >> > - set->sap_socket_path[0] = 0; >> > + // set->sap_socket_path[0] = 0; >> > + ms->sap_entity.sap_state == SAP_SOCKET_ERROR; >> >> a) if you remove code, remove it for good, not just comment it out >> >> b) the double-equals will not cause an assignment. I don't think you >> tested this code... >> >> Regards, >> Harald >> -- >> - Harald Welte >> http://laforge.gnumonks.org/ >> >> ============================================================================ >> "Privacy in residential applications is a desirable marketing option." >> (ETSI EN 300 175-7 Ch. >> A6) >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From axilirator at gmail.com Mon Jan 4 09:42:16 2016 From: axilirator at gmail.com (=?UTF-8?B?0JLQsNC00LjQvCDQr9C90LjRhtC60LjQuQ==?=) Date: Mon, 4 Jan 2016 15:42:16 +0600 Subject: [PATCH] Improved SAP interface integration Message-ID: This is final patch version. I did some tests and it seems works fine. One thing that I can't test is how SAP connection works because I have no working sap-server setup. If anyone have please test. Now the `sim sap MS_NAME` command just enables SAP connection and `sim remove MS_MANE` closes connection if it's active. What I have done: - Fixed GPSD configuration r/w errors; - Fixed sap_socket_path configuration r/w errors; - SAP interface starts only if it is configured as SIM source; - Now SAP interface is selectable as SIM source using the sim command in VTY. diff --git a/src/host/layer23/include/osmocom/bb/common/sap_interface.h b/src/host/layer23/include/osmocom/bb/common/sap_interface.h index bf19356..e4e64ce 100644 --- a/src/host/layer23/include/osmocom/bb/common/sap_interface.h +++ b/src/host/layer23/include/osmocom/bb/common/sap_interface.h @@ -11,6 +11,7 @@ int osmosap_sapsocket(struct osmocom_ms *ms, const char *path); int osmosap_init(struct osmocom_ms *ms); enum osmosap_state { + SAP_SOCKET_ERROR, SAP_NOT_CONNECTED, SAP_IDLE, SAP_CONNECTION_UNDER_NEGOTIATION, diff --git a/src/host/layer23/include/osmocom/bb/mobile/subscriber.h b/src/host/layer23/include/osmocom/bb/mobile/subscriber.h index 79a2ecc..ac785d4 100644 --- a/src/host/layer23/include/osmocom/bb/mobile/subscriber.h +++ b/src/host/layer23/include/osmocom/bb/mobile/subscriber.h @@ -23,7 +23,8 @@ struct gsm_sub_plmn_na { enum { GSM_SIM_TYPE_NONE = 0, GSM_SIM_TYPE_READER, - GSM_SIM_TYPE_TEST + GSM_SIM_TYPE_TEST, + GSM_SIM_TYPE_SAP }; struct gsm_subscriber { @@ -86,6 +87,8 @@ int gsm_subscr_init(struct osmocom_ms *ms); int gsm_subscr_exit(struct osmocom_ms *ms); int gsm_subscr_testcard(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc, uint16_t lac, uint32_t tmsi, uint8_t imsi_attached); +int gsm_subscr_sapcard(struct osmocom_ms *ms); +int gsm_subscr_remove_sapcard(struct osmocom_ms *ms); int gsm_subscr_simcard(struct osmocom_ms *ms); void gsm_subscr_sim_pin(struct osmocom_ms *ms, char *pin1, char *pin2, int8_t mode); diff --git a/src/host/layer23/src/common/sap_interface.c b/src/host/layer23/src/common/sap_interface.c index a56f4f2..052646a 100644 --- a/src/host/layer23/src/common/sap_interface.c +++ b/src/host/layer23/src/common/sap_interface.c @@ -515,7 +515,7 @@ int sap_open(struct osmocom_ms *ms, const char *socket_path) rc = connect(ms->sap_wq.bfd.fd, (struct sockaddr *) &local, sizeof(local)); if (rc < 0) { fprintf(stderr, "Failed to connect to '%s'\n", local.sun_path); - set->sap_socket_path[0] = 0; + ms->sap_entity.sap_state = SAP_SOCKET_ERROR; close(ms->sap_wq.bfd.fd); return rc; } @@ -582,22 +582,11 @@ int osmosap_sapsocket(struct osmocom_ms *ms, const char *path) int osmosap_init(struct osmocom_ms *ms) { struct osmosap_entity *sap = &ms->sap_entity; - int rc; + LOGP(DSAP, LOGL_INFO, "init SAP client\n"); sap->sap_state = SAP_NOT_CONNECTED; sap->max_msg_size = GSM_SAP_LENGTH; - LOGP(DSAP, LOGL_INFO, "init SAP client\n"); - - if(ms->settings.sap_socket_path){ - rc = sap_open(ms, ms->settings.sap_socket_path); - if (rc < 0) { - fprintf(stderr, "Failed during sap_open(), no SAP based SIM reader\n"); - ms->sap_wq.bfd.fd = -1; - return rc; - } - } - return 0; } diff --git a/src/host/layer23/src/common/sim.c b/src/host/layer23/src/common/sim.c index 8e8d7bf..9aad966 100644 --- a/src/host/layer23/src/common/sim.c +++ b/src/host/layer23/src/common/sim.c @@ -188,12 +188,12 @@ static int sim_apdu_send(struct osmocom_ms *ms, uint8_t *data, uint16_t length) /* adding SAP client support * it makes more sense to do it here then in L1CTL */ - if(ms->settings.sap_socket_path[0] == 0) { - LOGP(DSIM, LOGL_INFO, "Using built-in SIM reader\n"); - l1ctl_tx_sim_req(ms, data, length); - } else { + if (ms->subscr.sim_type == GSM_SIM_TYPE_SAP) { LOGP(DSIM, LOGL_INFO, "Using SAP backend\n"); osmosap_send_apdu(ms, data, length); + } else { + LOGP(DSIM, LOGL_INFO, "Using built-in SIM reader\n"); + l1ctl_tx_sim_req(ms, data, length); } return 0; diff --git a/src/host/layer23/src/mobile/app_mobile.c b/src/host/layer23/src/mobile/app_mobile.c index 3895ad6..e076741 100644 --- a/src/host/layer23/src/mobile/app_mobile.c +++ b/src/host/layer23/src/mobile/app_mobile.c @@ -115,6 +115,9 @@ int mobile_signal_cb(unsigned int subsys, unsigned int signal, set->test_rplmn_mnc, set->test_lac, set->test_tmsi, set->test_imsi_attached); break; + case GSM_SIM_TYPE_SAP: + gsm_subscr_sapcard(ms); + break; default: /* no SIM, trigger PLMN selection process */ nmsg = gsm322_msgb_alloc(GSM322_EVENT_SWITCH_ON); diff --git a/src/host/layer23/src/mobile/subscriber.c b/src/host/layer23/src/mobile/subscriber.c index ba3c328..455db50 100644 --- a/src/host/layer23/src/mobile/subscriber.c +++ b/src/host/layer23/src/mobile/subscriber.c @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -1256,3 +1257,55 @@ void gsm_subscr_dump(struct gsm_subscriber *subscr, } } +/* + * SAP interface integration + */ + +/* Attach SIM card over SAP */ +int gsm_subscr_sapcard(struct osmocom_ms *ms) +{ + struct gsm_subscriber *subscr = &ms->subscr; + struct msgb *nmsg; + int rc; + + if (subscr->sim_valid) { + LOGP(DMM, LOGL_ERROR, "Cannot insert card, until current card " + "is detached.\n"); + return -EBUSY; + } + + /* reset subscriber */ + gsm_subscr_exit(ms); + gsm_subscr_init(ms); + + subscr->sim_type = GSM_SIM_TYPE_SAP; + sprintf(subscr->sim_name, "sap"); + subscr->sim_valid = 1; + + /* Try to connect to the SAP interface */ + vty_notify(ms, NULL); + vty_notify(ms, "Connecting to the SAP interface...\n"); + rc = sap_open(ms, ms->settings.sap_socket_path); + if (rc < 0) { + LOGP(DSAP, LOGL_ERROR, "Failed during sap_open(), no SAP based SIM reader\n"); + vty_notify(ms, "SAP connection error!\n"); + ms->sap_wq.bfd.fd = -1; + + /* Detach SIM */ + subscr->sim_valid = 0; + nmsg = gsm48_mmr_msgb_alloc(GSM48_MMR_NREG_REQ); + if (!nmsg) + return -ENOMEM; + gsm48_mmr_downmsg(ms, nmsg); + + return rc; + } + + return 0; +} + +/* Deattach sapcard */ +int gsm_subscr_remove_sapcard(struct osmocom_ms *ms) +{ + return sap_close(ms); +} diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c index 5782a17..5a1414d 100644 --- a/src/host/layer23/src/mobile/vty_interface.c +++ b/src/host/layer23/src/mobile/vty_interface.c @@ -534,6 +534,29 @@ DEFUN(sim_test_att, sim_test_att_cmd, return _sim_test_cmd(vty, argc, argv, 1); } +DEFUN(sim_sap, sim_sap_cmd, "sim sap MS_NAME", + "SIM actions\nAttach SIM over SAP interface\n" + "Name of MS (see \"show ms\")\n") +{ + struct osmocom_ms *ms; + + ms = get_ms(argv[0], vty); + if (!ms) + return CMD_WARNING; + + if (ms->subscr.sim_valid) { + vty_out(vty, "SIM already attached, remove first!%s", + VTY_NEWLINE); + return CMD_WARNING; + } + + if (gsm_subscr_sapcard(ms) != 0) { + return CMD_WARNING; + } + + return CMD_SUCCESS; +} + DEFUN(sim_reader, sim_reader_cmd, "sim reader MS_NAME", "SIM actions\nAttach SIM from reader\nName of MS (see \"show ms\")") { @@ -568,8 +591,11 @@ DEFUN(sim_remove, sim_remove_cmd, "sim remove MS_NAME", return CMD_WARNING; } - gsm_subscr_remove(ms); + if (ms->subscr.sim_type == GSM_SIM_TYPE_SAP) { + gsm_subscr_remove_sapcard(ms); + } + gsm_subscr_remove(ms); return CMD_SUCCESS; } @@ -1067,7 +1093,7 @@ DEFUN(cfg_no_gps_enable, cfg_no_gps_enable_cmd, "no gps enable", } #ifdef _HAVE_GPSD -DEFUN(cfg_gps_host, cfg_gps_host_cmd, "gps host HOST:PORT", +DEFUN(cfg_gpsd_host, cfg_gpsd_host_cmd, "gpsd host HOST:PORT", "GPS receiver\nSelect gpsd host and port\n" "IP and port (optional) of the host running gpsd") { @@ -1075,7 +1101,7 @@ DEFUN(cfg_gps_host, cfg_gps_host_cmd, "gps host HOST:PORT", if (colon != NULL) { memcpy(g.gpsd_host, argv[0], colon - argv[0] - 1); g.gpsd_host[colon - argv[0]] = '\0'; - memcpy(g.gpsd_port, colon, strlen(colon)); + memcpy(g.gpsd_port, colon + 1, strlen(colon)); g.gpsd_port[strlen(colon)] = '\0'; } else { snprintf(g.gpsd_host, ARRAY_SIZE(g.gpsd_host), "%s", argv[0]); @@ -1295,6 +1321,9 @@ static void config_write_ms(struct vty *vty, struct osmocom_ms *ms) case GSM_SIM_TYPE_TEST: vty_out(vty, " sim test%s", VTY_NEWLINE); break; + case GSM_SIM_TYPE_SAP: + vty_out(vty, " sim sap%s", VTY_NEWLINE); + break; } vty_out(vty, " network-selection-mode %s%s", (set->plmn_mode == PLMN_MODE_AUTO) ? "auto" : "manual", VTY_NEWLINE); @@ -1499,8 +1528,7 @@ static int config_write(struct vty *vty) struct osmocom_ms *ms; #ifdef _HAVE_GPSD - vty_out(vty, "gpsd host %s%s", g.gpsd_host, VTY_NEWLINE); - vty_out(vty, "gpsd port %s%s", g.gpsd_port, VTY_NEWLINE); + vty_out(vty, "gpsd host %s:%s%s", g.gpsd_host, g.gpsd_port, VTY_NEWLINE); #endif vty_out(vty, "gps device %s%s", g.device, VTY_NEWLINE); if (g.baud) @@ -1558,9 +1586,10 @@ DEFUN(cfg_ms_sap, cfg_ms_sap_cmd, "sap-socket PATH", return CMD_SUCCESS; } -DEFUN(cfg_ms_sim, cfg_ms_sim_cmd, "sim (none|reader|test)", +DEFUN(cfg_ms_sim, cfg_ms_sim_cmd, "sim (none|reader|test|sap)", "Set SIM card to attach when powering on\nAttach no SIM\n" - "Attach SIM from reader\nAttach bulit in test SIM") + "Attach SIM from reader\nAttach bulit in test SIM\n" + "Attach SIM over SAP interface") { struct osmocom_ms *ms = vty->index; struct gsm_settings *set = &ms->settings; @@ -1575,6 +1604,9 @@ DEFUN(cfg_ms_sim, cfg_ms_sim_cmd, "sim (none|reader|test)", case 't': set->sim_type = GSM_SIM_TYPE_TEST; break; + case 's': + set->sim_type = GSM_SIM_TYPE_SAP; + break; default: vty_out(vty, "unknown SIM type%s", VTY_NEWLINE); return CMD_WARNING; @@ -2802,6 +2834,7 @@ int ms_vty_init(void) install_element(ENABLE_NODE, &sim_test_cmd); install_element(ENABLE_NODE, &sim_test_att_cmd); + install_element(ENABLE_NODE, &sim_sap_cmd); install_element(ENABLE_NODE, &sim_reader_cmd); install_element(ENABLE_NODE, &sim_remove_cmd); install_element(ENABLE_NODE, &sim_pin_cmd); @@ -2822,7 +2855,7 @@ int ms_vty_init(void) install_element(ENABLE_NODE, &delete_forbidden_plmn_cmd); #ifdef _HAVE_GPSD - install_element(CONFIG_NODE, &cfg_gps_host_cmd); + install_element(CONFIG_NODE, &cfg_gpsd_host_cmd); #endif install_element(CONFIG_NODE, &cfg_gps_device_cmd); install_element(CONFIG_NODE, &cfg_gps_baud_cmd); -------------- next part -------------- An HTML attachment was scrubbed... URL: From axilirator at gmail.com Sun Jan 10 13:14:17 2016 From: axilirator at gmail.com (Vadim Yanitskiy) Date: Sun, 10 Jan 2016 19:14:17 +0600 Subject: [PATCH 1/2] Fix for "Added runtime selection of gps device" Message-ID: <1452431658-13570-1-git-send-email-axilirator@gmail.com> From: ??????? ?? ??? The 'gps host HOST:PORT' line in the config file now is generated correctly. So that it is parsed correctly when loading the config on next startup. Also the gpsd port now is parsed as it should without a colon. --- src/host/layer23/src/mobile/vty_interface.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c index 5782a17..73aaa78 100644 --- a/src/host/layer23/src/mobile/vty_interface.c +++ b/src/host/layer23/src/mobile/vty_interface.c @@ -1075,7 +1075,7 @@ DEFUN(cfg_gps_host, cfg_gps_host_cmd, "gps host HOST:PORT", if (colon != NULL) { memcpy(g.gpsd_host, argv[0], colon - argv[0] - 1); g.gpsd_host[colon - argv[0]] = '\0'; - memcpy(g.gpsd_port, colon, strlen(colon)); + memcpy(g.gpsd_port, colon + 1, strlen(colon)); g.gpsd_port[strlen(colon)] = '\0'; } else { snprintf(g.gpsd_host, ARRAY_SIZE(g.gpsd_host), "%s", argv[0]); @@ -1499,8 +1499,7 @@ static int config_write(struct vty *vty) struct osmocom_ms *ms; #ifdef _HAVE_GPSD - vty_out(vty, "gpsd host %s%s", g.gpsd_host, VTY_NEWLINE); - vty_out(vty, "gpsd port %s%s", g.gpsd_port, VTY_NEWLINE); + vty_out(vty, "gps host %s:%s%s", g.gpsd_host, g.gpsd_port, VTY_NEWLINE); #endif vty_out(vty, "gps device %s%s", g.device, VTY_NEWLINE); if (g.baud) -- 1.9.1 From axilirator at gmail.com Sun Jan 10 13:14:18 2016 From: axilirator at gmail.com (Vadim Yanitskiy) Date: Sun, 10 Jan 2016 19:14:18 +0600 Subject: [PATCH 2/2] host/mobile: Improved SAP interface integration In-Reply-To: <1452431658-13570-1-git-send-email-axilirator@gmail.com> References: <1452431658-13570-1-git-send-email-axilirator@gmail.com> Message-ID: <1452431658-13570-2-git-send-email-axilirator@gmail.com> From: ??????? ?? ??? 1) Now the SAP interface is selectable as SIM source using the 'sim sap' command in VTY. 2) SAP connection starts only if it is configured as SIM source. 3) Fixed sap_socket_path configuration r/w errors. --- .../include/osmocom/bb/common/sap_interface.h | 1 + .../layer23/include/osmocom/bb/mobile/subscriber.h | 5 +- src/host/layer23/src/common/sap_interface.c | 15 +----- src/host/layer23/src/common/sim.c | 8 ++-- src/host/layer23/src/mobile/app_mobile.c | 3 ++ src/host/layer23/src/mobile/subscriber.c | 53 ++++++++++++++++++++++ src/host/layer23/src/mobile/vty_interface.c | 40 ++++++++++++++-- 7 files changed, 104 insertions(+), 21 deletions(-) diff --git a/src/host/layer23/include/osmocom/bb/common/sap_interface.h b/src/host/layer23/include/osmocom/bb/common/sap_interface.h index bf19356..e4e64ce 100644 --- a/src/host/layer23/include/osmocom/bb/common/sap_interface.h +++ b/src/host/layer23/include/osmocom/bb/common/sap_interface.h @@ -11,6 +11,7 @@ int osmosap_sapsocket(struct osmocom_ms *ms, const char *path); int osmosap_init(struct osmocom_ms *ms); enum osmosap_state { + SAP_SOCKET_ERROR, SAP_NOT_CONNECTED, SAP_IDLE, SAP_CONNECTION_UNDER_NEGOTIATION, diff --git a/src/host/layer23/include/osmocom/bb/mobile/subscriber.h b/src/host/layer23/include/osmocom/bb/mobile/subscriber.h index 79a2ecc..ac785d4 100644 --- a/src/host/layer23/include/osmocom/bb/mobile/subscriber.h +++ b/src/host/layer23/include/osmocom/bb/mobile/subscriber.h @@ -23,7 +23,8 @@ struct gsm_sub_plmn_na { enum { GSM_SIM_TYPE_NONE = 0, GSM_SIM_TYPE_READER, - GSM_SIM_TYPE_TEST + GSM_SIM_TYPE_TEST, + GSM_SIM_TYPE_SAP }; struct gsm_subscriber { @@ -86,6 +87,8 @@ int gsm_subscr_init(struct osmocom_ms *ms); int gsm_subscr_exit(struct osmocom_ms *ms); int gsm_subscr_testcard(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc, uint16_t lac, uint32_t tmsi, uint8_t imsi_attached); +int gsm_subscr_sapcard(struct osmocom_ms *ms); +int gsm_subscr_remove_sapcard(struct osmocom_ms *ms); int gsm_subscr_simcard(struct osmocom_ms *ms); void gsm_subscr_sim_pin(struct osmocom_ms *ms, char *pin1, char *pin2, int8_t mode); diff --git a/src/host/layer23/src/common/sap_interface.c b/src/host/layer23/src/common/sap_interface.c index a56f4f2..052646a 100644 --- a/src/host/layer23/src/common/sap_interface.c +++ b/src/host/layer23/src/common/sap_interface.c @@ -515,7 +515,7 @@ int sap_open(struct osmocom_ms *ms, const char *socket_path) rc = connect(ms->sap_wq.bfd.fd, (struct sockaddr *) &local, sizeof(local)); if (rc < 0) { fprintf(stderr, "Failed to connect to '%s'\n", local.sun_path); - set->sap_socket_path[0] = 0; + ms->sap_entity.sap_state = SAP_SOCKET_ERROR; close(ms->sap_wq.bfd.fd); return rc; } @@ -582,22 +582,11 @@ int osmosap_sapsocket(struct osmocom_ms *ms, const char *path) int osmosap_init(struct osmocom_ms *ms) { struct osmosap_entity *sap = &ms->sap_entity; - int rc; + LOGP(DSAP, LOGL_INFO, "init SAP client\n"); sap->sap_state = SAP_NOT_CONNECTED; sap->max_msg_size = GSM_SAP_LENGTH; - LOGP(DSAP, LOGL_INFO, "init SAP client\n"); - - if(ms->settings.sap_socket_path){ - rc = sap_open(ms, ms->settings.sap_socket_path); - if (rc < 0) { - fprintf(stderr, "Failed during sap_open(), no SAP based SIM reader\n"); - ms->sap_wq.bfd.fd = -1; - return rc; - } - } - return 0; } diff --git a/src/host/layer23/src/common/sim.c b/src/host/layer23/src/common/sim.c index 8e8d7bf..9aad966 100644 --- a/src/host/layer23/src/common/sim.c +++ b/src/host/layer23/src/common/sim.c @@ -188,12 +188,12 @@ static int sim_apdu_send(struct osmocom_ms *ms, uint8_t *data, uint16_t length) /* adding SAP client support * it makes more sense to do it here then in L1CTL */ - if(ms->settings.sap_socket_path[0] == 0) { - LOGP(DSIM, LOGL_INFO, "Using built-in SIM reader\n"); - l1ctl_tx_sim_req(ms, data, length); - } else { + if (ms->subscr.sim_type == GSM_SIM_TYPE_SAP) { LOGP(DSIM, LOGL_INFO, "Using SAP backend\n"); osmosap_send_apdu(ms, data, length); + } else { + LOGP(DSIM, LOGL_INFO, "Using built-in SIM reader\n"); + l1ctl_tx_sim_req(ms, data, length); } return 0; diff --git a/src/host/layer23/src/mobile/app_mobile.c b/src/host/layer23/src/mobile/app_mobile.c index 3895ad6..e076741 100644 --- a/src/host/layer23/src/mobile/app_mobile.c +++ b/src/host/layer23/src/mobile/app_mobile.c @@ -115,6 +115,9 @@ int mobile_signal_cb(unsigned int subsys, unsigned int signal, set->test_rplmn_mnc, set->test_lac, set->test_tmsi, set->test_imsi_attached); break; + case GSM_SIM_TYPE_SAP: + gsm_subscr_sapcard(ms); + break; default: /* no SIM, trigger PLMN selection process */ nmsg = gsm322_msgb_alloc(GSM322_EVENT_SWITCH_ON); diff --git a/src/host/layer23/src/mobile/subscriber.c b/src/host/layer23/src/mobile/subscriber.c index ba3c328..455db50 100644 --- a/src/host/layer23/src/mobile/subscriber.c +++ b/src/host/layer23/src/mobile/subscriber.c @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -1256,3 +1257,55 @@ void gsm_subscr_dump(struct gsm_subscriber *subscr, } } +/* + * SAP interface integration + */ + +/* Attach SIM card over SAP */ +int gsm_subscr_sapcard(struct osmocom_ms *ms) +{ + struct gsm_subscriber *subscr = &ms->subscr; + struct msgb *nmsg; + int rc; + + if (subscr->sim_valid) { + LOGP(DMM, LOGL_ERROR, "Cannot insert card, until current card " + "is detached.\n"); + return -EBUSY; + } + + /* reset subscriber */ + gsm_subscr_exit(ms); + gsm_subscr_init(ms); + + subscr->sim_type = GSM_SIM_TYPE_SAP; + sprintf(subscr->sim_name, "sap"); + subscr->sim_valid = 1; + + /* Try to connect to the SAP interface */ + vty_notify(ms, NULL); + vty_notify(ms, "Connecting to the SAP interface...\n"); + rc = sap_open(ms, ms->settings.sap_socket_path); + if (rc < 0) { + LOGP(DSAP, LOGL_ERROR, "Failed during sap_open(), no SAP based SIM reader\n"); + vty_notify(ms, "SAP connection error!\n"); + ms->sap_wq.bfd.fd = -1; + + /* Detach SIM */ + subscr->sim_valid = 0; + nmsg = gsm48_mmr_msgb_alloc(GSM48_MMR_NREG_REQ); + if (!nmsg) + return -ENOMEM; + gsm48_mmr_downmsg(ms, nmsg); + + return rc; + } + + return 0; +} + +/* Deattach sapcard */ +int gsm_subscr_remove_sapcard(struct osmocom_ms *ms) +{ + return sap_close(ms); +} diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c index 73aaa78..7cb2259 100644 --- a/src/host/layer23/src/mobile/vty_interface.c +++ b/src/host/layer23/src/mobile/vty_interface.c @@ -534,6 +534,29 @@ DEFUN(sim_test_att, sim_test_att_cmd, return _sim_test_cmd(vty, argc, argv, 1); } +DEFUN(sim_sap, sim_sap_cmd, "sim sap MS_NAME", + "SIM actions\nAttach SIM over SAP interface\n" + "Name of MS (see \"show ms\")\n") +{ + struct osmocom_ms *ms; + + ms = get_ms(argv[0], vty); + if (!ms) + return CMD_WARNING; + + if (ms->subscr.sim_valid) { + vty_out(vty, "SIM already attached, remove first!%s", + VTY_NEWLINE); + return CMD_WARNING; + } + + if (gsm_subscr_sapcard(ms) != 0) { + return CMD_WARNING; + } + + return CMD_SUCCESS; +} + DEFUN(sim_reader, sim_reader_cmd, "sim reader MS_NAME", "SIM actions\nAttach SIM from reader\nName of MS (see \"show ms\")") { @@ -568,8 +591,11 @@ DEFUN(sim_remove, sim_remove_cmd, "sim remove MS_NAME", return CMD_WARNING; } - gsm_subscr_remove(ms); + if (ms->subscr.sim_type == GSM_SIM_TYPE_SAP) { + gsm_subscr_remove_sapcard(ms); + } + gsm_subscr_remove(ms); return CMD_SUCCESS; } @@ -1295,6 +1321,9 @@ static void config_write_ms(struct vty *vty, struct osmocom_ms *ms) case GSM_SIM_TYPE_TEST: vty_out(vty, " sim test%s", VTY_NEWLINE); break; + case GSM_SIM_TYPE_SAP: + vty_out(vty, " sim sap%s", VTY_NEWLINE); + break; } vty_out(vty, " network-selection-mode %s%s", (set->plmn_mode == PLMN_MODE_AUTO) ? "auto" : "manual", VTY_NEWLINE); @@ -1557,9 +1586,10 @@ DEFUN(cfg_ms_sap, cfg_ms_sap_cmd, "sap-socket PATH", return CMD_SUCCESS; } -DEFUN(cfg_ms_sim, cfg_ms_sim_cmd, "sim (none|reader|test)", +DEFUN(cfg_ms_sim, cfg_ms_sim_cmd, "sim (none|reader|test|sap)", "Set SIM card to attach when powering on\nAttach no SIM\n" - "Attach SIM from reader\nAttach bulit in test SIM") + "Attach SIM from reader\nAttach bulit in test SIM\n" + "Attach SIM over SAP interface") { struct osmocom_ms *ms = vty->index; struct gsm_settings *set = &ms->settings; @@ -1574,6 +1604,9 @@ DEFUN(cfg_ms_sim, cfg_ms_sim_cmd, "sim (none|reader|test)", case 't': set->sim_type = GSM_SIM_TYPE_TEST; break; + case 's': + set->sim_type = GSM_SIM_TYPE_SAP; + break; default: vty_out(vty, "unknown SIM type%s", VTY_NEWLINE); return CMD_WARNING; @@ -2801,6 +2834,7 @@ int ms_vty_init(void) install_element(ENABLE_NODE, &sim_test_cmd); install_element(ENABLE_NODE, &sim_test_att_cmd); + install_element(ENABLE_NODE, &sim_sap_cmd); install_element(ENABLE_NODE, &sim_reader_cmd); install_element(ENABLE_NODE, &sim_remove_cmd); install_element(ENABLE_NODE, &sim_pin_cmd); -- 1.9.1 From etiennehelluy at gmail.com Sun Jan 10 16:36:41 2016 From: etiennehelluy at gmail.com (etienne .) Date: Sun, 10 Jan 2016 17:36:41 +0100 Subject: dsp_extcode Message-ID: Hello, In the sylvain/testing and jolly/testing branches of osmocom-bb, I don't see source code for dsp_extcode. Is a release planned ? Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From 246tnt at gmail.com Sun Jan 10 17:20:14 2016 From: 246tnt at gmail.com (Sylvain Munaut) Date: Sun, 10 Jan 2016 18:20:14 +0100 Subject: dsp_extcode In-Reply-To: References: Message-ID: > In the sylvain/testing and jolly/testing branches of osmocom-bb, I don't see > source code for dsp_extcode. Is a release planned ? No. It is however written in assembly originally so you can just decompile it, you'll just won't have the comments. Cheers, Sylvain PS: sorry for dupe, I fucked up the reply to all ... From laforge at gnumonks.org Tue Jan 12 15:12:00 2016 From: laforge at gnumonks.org (Harald Welte) Date: Tue, 12 Jan 2016 16:12:00 +0100 Subject: OsmoDevCon 2016 date poll Message-ID: <20160112151200.GP1762@nataraja> Dear all, IN-Berlin has confirmed the dates in April where we could book the venue. Can those eligible + interested in attending please quickly indicate their preference at http://doodle.com/poll/if263cpxieavsqiq ? Thanks! Disclaimer: OsmoDevCon is an invitation-only event for developers with proven history of contributing to any of the Osmocom projects. The fact that there is a public poll about the scheduling of the event and/or your participation in that poll does not mean a particular applicant is invited. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." From laforge at gnumonks.org Wed Jan 13 13:35:26 2016 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 13 Jan 2016 14:35:26 +0100 Subject: OsmoDevCon 2016 date poll In-Reply-To: <20160112151200.GP1762@nataraja> References: <20160112151200.GP1762@nataraja> Message-ID: <20160113133526.GO9964@nataraja> On Tue, Jan 12, 2016 at 04:12:00PM +0100, Harald Welte wrote: > Can those eligible + interested in attending please quickly indicate > their preference at http://doodle.com/poll/if263cpxieavsqiq ? Thanks for the quick feedback. I have now chosen April 21st through April 24th, as this was acceptable to everybody participating in the poll and it has least overlap/impact on the schedule of other groups meeting at the IN-Berlin venue. So feel free to mark that date in your calendar. Further planning will follow in the next weeks. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From suraev at alumni.ntnu.no Wed Jan 13 14:24:29 2016 From: suraev at alumni.ntnu.no (suraev at alumni.ntnu.no) Date: Wed, 13 Jan 2016 15:24:29 +0100 Subject: [PATCH] Fix and expand bitvec interface. Message-ID: <1452695069-22186-1-git-send-email-suraev@alumni.ntnu.no> From: Max Fix all bit counters to take unsigned value only. Add functions for shifting and run length detection. Add tests and pretty-print function. Sponsored-by: On-Waves ehf Signed-off-by: Max --- .gitignore | 1 + include/osmocom/core/bitvec.h | 11 ++++-- src/bitvec.c | 89 +++++++++++++++++++++++++++++++++++++++++-- tests/Makefile.am | 10 +++-- tests/bits/bitvec_test.c | 43 +++++++++++++++++++++ tests/bits/bitvec_test.ok | 14 +++++++ tests/testsuite.at | 6 +++ 7 files changed, 165 insertions(+), 9 deletions(-) create mode 100644 tests/bits/bitvec_test.c create mode 100644 tests/bits/bitvec_test.ok diff --git a/.gitignore b/.gitignore index 598f88a..25c9d97 100644 --- a/.gitignore +++ b/.gitignore @@ -64,6 +64,7 @@ tests/msgfile/msgfile_test tests/ussd/ussd_test tests/smscb/smscb_test tests/bits/bitrev_test +tests/bits/bitvec_test tests/a5/a5_test tests/comp128/comp128_test tests/auth/milenage_test diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h index 62e2e7b..3f7f166 100644 --- a/include/osmocom/core/bitvec.h +++ b/include/osmocom/core/bitvec.h @@ -31,6 +31,7 @@ */ #include +#include /*! \brief A single GSM bit * @@ -58,10 +59,14 @@ int bitvec_set_bit_pos(struct bitvec *bv, unsigned int bitnum, enum bit_value bit); int bitvec_set_bit(struct bitvec *bv, enum bit_value bit); int bitvec_get_bit_high(struct bitvec *bv); -int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, int count); -int bitvec_set_uint(struct bitvec *bv, unsigned int in, int count); -int bitvec_get_uint(struct bitvec *bv, int num_bits); +int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, unsigned count); +int bitvec_set_uint(struct bitvec *bv, unsigned int in, unsigned count); +int bitvec_get_uint(struct bitvec *bv, unsigned num_bits); int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n, enum bit_value val); int bitvec_spare_padding(struct bitvec *bv, unsigned int up_to_bit); +void bitvec_print(struct bitvec *bv); +void bitvec_zero(struct bitvec *bv); +unsigned bitvec_rl(struct bitvec *bv, bool b); +void bitvec_shiftl(struct bitvec *bv, unsigned n); /*! @} */ diff --git a/src/bitvec.c b/src/bitvec.c index 8da5a48..c791926 100644 --- a/src/bitvec.c +++ b/src/bitvec.c @@ -30,7 +30,11 @@ #include #include +#include +#include +#include +#include #include #define BITNUM_FROM_COMP(byte, bit) ((byte*8)+bit) @@ -188,7 +192,7 @@ int bitvec_get_bit_high(struct bitvec *bv) * \param[in] bits array of \ref bit_value * \param[in] count number of bits to set */ -int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, int count) +int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, unsigned count) { int i, rc; @@ -202,7 +206,7 @@ int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, int count) } /*! \brief set multiple bits (based on numeric value) at current pos */ -int bitvec_set_uint(struct bitvec *bv, unsigned int ui, int num_bits) +int bitvec_set_uint(struct bitvec *bv, unsigned int ui, unsigned num_bits) { int i, rc; @@ -219,7 +223,7 @@ int bitvec_set_uint(struct bitvec *bv, unsigned int ui, int num_bits) } /*! \brief get multiple bits (based on numeric value) from current pos */ -int bitvec_get_uint(struct bitvec *bv, int num_bits) +int bitvec_get_uint(struct bitvec *bv, unsigned num_bits) { int i; unsigned int ui = 0; @@ -261,4 +265,83 @@ int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n, return -1; } +/*! \brief prints bit vector to stdout */ +void bitvec_print(struct bitvec *bv) +{ + unsigned i; + for (i = 0; i < bv->cur_bit; i++) { + if (0 == i % 8) printf(" "); + switch (bitvec_get_bit_pos(bv, i)) { + case ZERO: printf("0"); break; + case ONE: printf("1"); break; + case L: printf("L"); break; + case H: printf("H"); break; + } + } +} + +/* we assume that x have at least 1 non-b bit */ +inline unsigned _leading_bits(uint8_t x, bool b) +{ + if (b) { + if (x < 0x80) return 0; + if (x < 0xC0) return 1; + if (x < 0xE0) return 2; + if (x < 0xF0) return 3; + if (x < 0xF8) return 4; + if (x < 0xFC) return 5; + if (x < 0xFE) return 6; + } else { + if (x > 0x7F) return 0; + if (x > 0x3F) return 1; + if (x > 0x1F) return 2; + if (x > 0xF) return 3; + if (x > 7) return 4; + if (x > 3) return 5; + if (x > 1) return 6; + } + return 7; +} + +/*! \brief Return number (bits) of uninterrupted run of \b in \bv starting from the MSB */ +unsigned bitvec_rl(struct bitvec *bv, bool b) +{ + unsigned i; + for (i = 0; i < bv->data_len; i++) { + if ( (b ? 0xFF : 0) != bv->data[i]) return i * 8 + _leading_bits(bv->data[i], b); + } + + return bv->cur_bit; +} + +/*! \brief Shifts bitvec to the left, n MSB bits lost */ +void bitvec_shiftl(struct bitvec *bv, unsigned n) +{ + if (0 == n) return; + if (n >= bv->cur_bit) { + bitvec_zero(bv); + return; + } + + memmove(bv->data, bv->data + n / 8, bv->data_len - n / 8); + + uint8_t tmp[2]; + unsigned i; + for (i = 0; i < bv->data_len - 2; i++) { + uint16_t t = osmo_load16be(bv->data + i); + osmo_store16be(t << (n % 8), &tmp); + bv->data[i] = tmp[0]; + } + + bv->data[bv->data_len - 1] <<= (n % 8); + bv->cur_bit -= n; +} + +/*! \brief force bit vector to all 0 and current bit to the beginnig of the vector */ +void bitvec_zero(struct bitvec *bv) +{ + bv->cur_bit = 0; + memset(bv->data, 0, bv->data_len); +} + /*! @} */ diff --git a/tests/Makefile.am b/tests/Makefile.am index 3dc9bd9..eaeda72 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,9 +3,9 @@ AM_CFLAGS = -Wall $(TALLOC_CFLAGS) AM_LDFLAGS = $(TALLOC_LIBS) check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test \ - smscb/smscb_test bits/bitrev_test a5/a5_test \ + smscb/smscb_test bits/bitrev_test bits/bitvec_test \ conv/conv_test auth/milenage_test lapd/lapd_test \ - gsm0808/gsm0808_test gsm0408/gsm0408_test \ + gsm0808/gsm0808_test gsm0408/gsm0408_test a5/a5_test \ gb/bssgp_fc_test gb/gprs_bssgp_test gb/gprs_ns_test \ kasumi/kasumi_test logging/logging_test fr/fr_test \ loggingrb/loggingrb_test strrb/strrb_test \ @@ -37,6 +37,9 @@ auth_milenage_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/sr bits_bitrev_test_SOURCES = bits/bitrev_test.c bits_bitrev_test_LDADD = $(top_builddir)/src/libosmocore.la +bits_bitvec_test_SOURCES = bits/bitvec_test.c +bits_bitvec_test_LDADD = $(top_builddir)/src/libosmocore.la + conv_conv_test_SOURCES = conv/conv_test.c conv_conv_test_LDADD = $(top_builddir)/src/libosmocore.la @@ -112,7 +115,8 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE) \ timer/timer_test.ok sms/sms_test.ok ussd/ussd_test.ok \ - smscb/smscb_test.ok bits/bitrev_test.ok a5/a5_test.ok \ + bits/bitrev_test.ok bits/bitvec_test.ok \ + smscb/smscb_test.ok a5/a5_test.ok \ conv/conv_test.ok auth/milenage_test.ok \ lapd/lapd_test.ok gsm0408/gsm0408_test.ok \ gsm0808/gsm0808_test.ok gb/bssgp_fc_tests.err \ diff --git a/tests/bits/bitvec_test.c b/tests/bits/bitvec_test.c new file mode 100644 index 0000000..c53e011 --- /dev/null +++ b/tests/bits/bitvec_test.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +int main(int argc, char **argv) +{ + srand(time(NULL)); + + struct bitvec bv; + uint8_t i = 8, test[i]; + + memset(test, 0, i); + bv.data_len = i; + bv.data = test; + bv.cur_bit = 0; + + printf("checking RL functions...\n"); + + bitvec_zero(&bv); bitvec_print(&bv); printf(" RL0=%d, RL1=%d\n", bitvec_rl(&bv, false), bitvec_rl(&bv, true)); + bitvec_set_uint(&bv, 0x000F, 32); bitvec_print(&bv); printf(" RL0=%d, RL1=%d\n", bitvec_rl(&bv, false), bitvec_rl(&bv, true)); + bitvec_shiftl(&bv, 18); bitvec_print(&bv); printf(" RL0=%d, RL1=%d\n", bitvec_rl(&bv, false), bitvec_rl(&bv, true)); + bitvec_set_uint(&bv, 0x0F, 8); bitvec_print(&bv); printf(" RL0=%d, RL1=%d\n", bitvec_rl(&bv, false), bitvec_rl(&bv, true)); + bitvec_zero(&bv); + bitvec_set_uint(&bv, 0xFF, 8); bitvec_print(&bv); printf(" RL0=%d, RL1=%d\n", bitvec_rl(&bv, false), bitvec_rl(&bv, true)); + bitvec_set_uint(&bv, 0xFE, 7); bitvec_print(&bv); printf(" RL0=%d, RL1=%d\n", bitvec_rl(&bv, false), bitvec_rl(&bv, true)); + + printf("test shifting...\n"); + + bitvec_set_uint(&bv, 0x0E, 7); bitvec_print(&bv); printf(" << 3:\n"); bitvec_shiftl(&bv, 3); bitvec_print(&bv); printf("\n"); + bitvec_print(&bv); printf(" << 17:\n"); bitvec_shiftl(&bv, 17); bitvec_print(&bv); printf("\n"); + bitvec_set_uint(&bv, 0, 32); bitvec_set_uint(&bv, 0x0A, 7); + bitvec_print(&bv); printf(" << 24:\n"); bitvec_shiftl(&bv, 24); bitvec_print(&bv); printf("\n"); + + return 0; +} diff --git a/tests/bits/bitvec_test.ok b/tests/bits/bitvec_test.ok new file mode 100644 index 0000000..e72ae34 --- /dev/null +++ b/tests/bits/bitvec_test.ok @@ -0,0 +1,14 @@ +checking RL functions... + RL0=0, RL1=0 + 00000000 00000000 00000000 00001111 RL0=28, RL1=0 + 00000000 001111 RL0=10, RL1=0 + 00000000 00111100 001111 RL0=10, RL1=0 + 11111111 RL0=0, RL1=8 + 11111111 1111110 RL0=0, RL1=14 +test shifting... + 11111111 11111100 001110 << 3: + 11111111 11100001 110 + 11111111 11100001 110 << 17: + 10 + 10000000 00000000 00000000 00000000 00000101 0 << 24: + 00000000 00000101 0 diff --git a/tests/testsuite.at b/tests/testsuite.at index a542798..84ae2c9 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -21,6 +21,12 @@ cat $abs_srcdir/bits/bitrev_test.ok > expout AT_CHECK([$abs_top_builddir/tests/bits/bitrev_test], [0], [expout]) AT_CLEANUP +AT_SETUP([bitvec]) +AT_KEYWORDS([bitvec]) +cat $abs_srcdir/bits/bitvec_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/bits/bitvec_test], [0], [expout]) +AT_CLEANUP + AT_SETUP([conv]) AT_KEYWORDS([conv]) cat $abs_srcdir/conv/conv_test.ok > expout -- 2.5.0 From suraev at alumni.ntnu.no Wed Jan 13 14:35:24 2016 From: suraev at alumni.ntnu.no (=?UTF-8?B?4pit?=) Date: Wed, 13 Jan 2016 15:35:24 +0100 Subject: [PATCH] Fix and expand bitvec interface. In-Reply-To: <1452695069-22186-1-git-send-email-suraev@alumni.ntnu.no> References: <1452695069-22186-1-git-send-email-suraev@alumni.ntnu.no> Message-ID: <569660AC.6080306@alumni.ntnu.no> This patch lays out ground work for implementing compressed bitmap support. cheers, Max. From laforge at gnumonks.org Thu Jan 14 10:23:41 2016 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 14 Jan 2016 11:23:41 +0100 Subject: [PATCH] Fix and expand bitvec interface. In-Reply-To: <1452695069-22186-1-git-send-email-suraev@alumni.ntnu.no> References: <1452695069-22186-1-git-send-email-suraev@alumni.ntnu.no> Message-ID: <20160114102341.GW9964@nataraja> Hi Max, On Wed, Jan 13, 2016 at 03:24:29PM +0100, suraev at alumni.ntnu.no wrote: > +int bitvec_set_uint(struct bitvec *bv, unsigned int in, unsigned count); we generally don't use 'unsigned' in the code so far, but 'unsigned int'. So it's a bit odd to see 'unsigned' without int here. In general, I probably wouldn't care too much. However, given that it is a single function that has one 'unsigned int' and one 'unsigned' argument, it seems a bit odd. > + if (0 == i % 8) printf(" "); > + switch (bitvec_get_bit_pos(bv, i)) { > + case ZERO: printf("0"); break; > + case ONE: printf("1"); break; > + case L: printf("L"); break; > + case H: printf("H"); break; If you're printing a single character only, using fputc() should be much more efficient. I'm not sure if gcc is good to detect that and replace it by itself. If yes, no need to change the code. If not, better use fputc. Also, the library should generally not just printf. For the majority of the programs running as daemons this doesn't make sense. The general way to deal with this is to offer a function that generates the string, i.e. 'char *bitvec_to_string(bitvec *bv)'. Since we assume single-threaded useres only, having a static buffer and always returning that buffer has so far been the the generally accepted form. If you don't like that, offer a bitvec_to_string_r() using a caller-allocated string, or maybe even better, something that take a talloc context as first argument, form where the output-string is then allocated. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From suraev at alumni.ntnu.no Thu Jan 14 13:10:30 2016 From: suraev at alumni.ntnu.no (=?UTF-8?B?4pit?=) Date: Thu, 14 Jan 2016 14:10:30 +0100 Subject: [PATCH] Fix and expand bitvec interface. In-Reply-To: <20160114102341.GW9964@nataraja> References: <1452695069-22186-1-git-send-email-suraev@alumni.ntnu.no> <20160114102341.GW9964@nataraja> Message-ID: <56979E46.8040200@alumni.ntnu.no> 14.01.2016 11:23, Harald Welte ?????: > we generally don't use 'unsigned' in the code so far, but 'unsigned > int'. So it's a bit odd to see 'unsigned' without int here. In > general, I probably wouldn't care too much. However, given that it is a > single function that has one 'unsigned int' and one 'unsigned' argument, > it seems a bit odd. I prefer 'unsigned' because it's less to type and neither provides any guarantees with regards to size of the type. I think size_t and uintXX_t would be better technically. On a related note, what's the status of https://patchwork.ozlabs.org/patch/559571/ ? Cause merging it would result in conflict with this patch so I'd prefer to rebase mine earlier if possible. cheers, Max. From holger at freyther.de Mon Jan 18 12:13:57 2016 From: holger at freyther.de (Holger Freyther) Date: Mon, 18 Jan 2016 13:13:57 +0100 Subject: [PATCH] fix failed .deb build due to failing bssgp test In-Reply-To: <1436199406-32583-1-git-send-email-max.suraev@fairwaves.co> References: <1436199406-32583-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <48B9FECC-02A5-4F31-A255-D7940E2604FA@freyther.de> > On 06 Jul 2015, at 18:16, Max wrote: Dear Max, > gb_gprs_bssgp_test_SOURCES = gb/gprs_bssgp_test.c > gb_gprs_bssgp_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(LIBRARY_DL) > +gb_gprs_bssgp_test_LDFLAGS = -static -Wl,--wrap=gprs_ns_sendmsg we still run into this issue when building for Ubuntu and the answer is that they pass -Bsymbolic-functions and this means that the internal calls to gprs_ns_sendmsg are linked directly so we can not interpose. Your change forces static linking so the gprs_ns_sendmsg is resolved differently and allows us to interpose one way or another. The issue with -static is that we now have an optional static build. I am tempted to just put LDFLAGS := $(LDFLAGS:-Wl,-Bsymbolic-functions=) into the debian/rules. The library will not perform worse than on other platforms. The other architectural change is to be able to "plug" transport so we can provide our own send functions. From suraev at alumni.ntnu.no Mon Jan 18 14:14:54 2016 From: suraev at alumni.ntnu.no (=?UTF-8?B?TWF4ICjimK0p?=) Date: Mon, 18 Jan 2016 15:14:54 +0100 Subject: [PATCH] fix failed .deb build due to failing bssgp test In-Reply-To: <48B9FECC-02A5-4F31-A255-D7940E2604FA@freyther.de> References: <1436199406-32583-1-git-send-email-max.suraev@fairwaves.co> <48B9FECC-02A5-4F31-A255-D7940E2604FA@freyther.de> Message-ID: <569CF35E.8010104@alumni.ntnu.no> While we're at it we might also enable link-time optimization (LTO) globally by adding -flto to gcc/linker flags. See https://gcc.gnu.org/wiki/LinkTimeOptimization for details. This should offset whatever potential benefits direct linking had and might improve performance in general. 18.01.2016 13:13, Holger Freyther ?????: > I am tempted to just put LDFLAGS := $(LDFLAGS:-Wl,-Bsymbolic-functions=) into the debian/rules. The library will not perform worse than on other platforms. > cheers, Max. From suraev at alumni.ntnu.no Tue Jan 19 16:04:48 2016 From: suraev at alumni.ntnu.no (suraev at alumni.ntnu.no) Date: Tue, 19 Jan 2016 17:04:48 +0100 Subject: [PATCH] Extend bitvec. Message-ID: <1453219488-20958-1-git-send-email-suraev@alumni.ntnu.no> From: Max Add functions for shifting, filling, printing. Add corresponding tests. Fix interface to use unsigned int where appropriate. Add missing gitignore entries. Sponsored-by: On-Waves ehf --- .gitignore | 3 + include/osmocom/core/bitvec.h | 19 ++++-- src/bitvec.c | 140 +++++++++++++++++++++++++++++++++++++---- tests/bitvec/bitvec_test.c | 143 +++++++++++++++++++++++++++++++++++++++++- tests/bitvec/bitvec_test.ok | 119 +++++++++++++++++++++++++++++++++++ 5 files changed, 406 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 598f88a..955634e 100644 --- a/.gitignore +++ b/.gitignore @@ -81,6 +81,9 @@ tests/strrb/strrb_test tests/vty/vty_test tests/gb/gprs_bssgp_test tests/smscb/gsm0341_test +tests/bitvec/bitvec_test +tests/gprs/gprs_test +tests/msgb/msgb_test utils/osmo-arfcn utils/osmo-auc-gen diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h index 89eb784..9808671 100644 --- a/include/osmocom/core/bitvec.h +++ b/include/osmocom/core/bitvec.h @@ -3,6 +3,7 @@ /* bit vector utility routines */ /* (C) 2009 by Harald Welte + * (C) 2015 by Sysmocom s.f.m.c. GmbH * * All Rights Reserved * @@ -39,6 +40,7 @@ */ #include +#include /*! \brief A single GSM bit * @@ -66,12 +68,19 @@ int bitvec_set_bit_pos(struct bitvec *bv, unsigned int bitnum, enum bit_value bit); int bitvec_set_bit(struct bitvec *bv, enum bit_value bit); int bitvec_get_bit_high(struct bitvec *bv); -int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, int count); -int bitvec_set_uint(struct bitvec *bv, unsigned int in, int count); -int bitvec_get_uint(struct bitvec *bv, int num_bits); +int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, unsigned int count); +int bitvec_set_uint(struct bitvec *bv, uint32_t in, unsigned int count); +int bitvec_get_uint(struct bitvec *bv, unsigned int num_bits); int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n, enum bit_value val); int bitvec_spare_padding(struct bitvec *bv, unsigned int up_to_bit); -int bitvec_get_bytes(struct bitvec *bv, uint8_t *bytes, int count); -int bitvec_set_bytes(struct bitvec *bv, const uint8_t *bytes, int count); +int bitvec_get_bytes(struct bitvec *bv, uint8_t *bytes, unsigned int count); +int bitvec_set_bytes(struct bitvec *bv, const uint8_t *bytes, unsigned int count); +int bitvec_fill(struct bitvec *bv, unsigned int num_bits, enum bit_value fill); +char bit_value_to_char(enum bit_value v); +void bitvec_to_string_r(const struct bitvec *bv, char *str); +void bitvec_zero(struct bitvec *bv); +unsigned bitvec_rl(const struct bitvec *bv, bool b); +void bitvec_shiftl(struct bitvec *bv, unsigned int n); +int16_t bitvec_get_int16_msb(const struct bitvec *bv, unsigned int num_bits); /*! @} */ diff --git a/src/bitvec.c b/src/bitvec.c index 726a768..df868c8 100644 --- a/src/bitvec.c +++ b/src/bitvec.c @@ -31,8 +31,11 @@ #include #include +#include #include +#include +#include #include #define BITNUM_FROM_COMP(byte, bit) ((byte*8)+bit) @@ -190,7 +193,7 @@ int bitvec_get_bit_high(struct bitvec *bv) * \param[in] bits array of \ref bit_value * \param[in] count number of bits to set */ -int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, int count) +int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, unsigned int count) { int i, rc; @@ -204,7 +207,7 @@ int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, int count) } /*! \brief set multiple bits (based on numeric value) at current pos */ -int bitvec_set_uint(struct bitvec *bv, unsigned int ui, int num_bits) +int bitvec_set_uint(struct bitvec *bv, unsigned int ui, unsigned int num_bits) { int i, rc; @@ -220,8 +223,23 @@ int bitvec_set_uint(struct bitvec *bv, unsigned int ui, int num_bits) return 0; } +/*! \brief get multiple bits (num_bits) from beginning of vector (MSB side) */ +int16_t bitvec_get_int16_msb(const struct bitvec *bv, unsigned int num_bits) +{ + if (num_bits > 15 || bv->cur_bit < num_bits) return -EINVAL; + + if (num_bits < 9) { + return bv->data[0] >> (8 - num_bits); + } + + uint8_t tmp[2]; + memcpy(tmp, bv->data, 2); + uint16_t t = osmo_load16be(tmp); + return t >> (16 - num_bits); +} + /*! \brief get multiple bits (based on numeric value) from current pos */ -int bitvec_get_uint(struct bitvec *bv, int num_bits) +int bitvec_get_uint(struct bitvec *bv, unsigned int num_bits) { int i; unsigned int ui = 0; @@ -238,17 +256,26 @@ int bitvec_get_uint(struct bitvec *bv, int num_bits) return ui; } -/*! \brief pad all remaining bits up to num_bits */ -int bitvec_spare_padding(struct bitvec *bv, unsigned int up_to_bit) +/*! \brief fill num_bits with \fill starting from the current position + * returns 0 on success, negative otherwise (out of vector boundary) + */ +int bitvec_fill(struct bitvec *bv, unsigned int num_bits, enum bit_value fill) { - unsigned int i; - - for (i = bv->cur_bit; i <= up_to_bit; i++) - bitvec_set_bit(bv, L); + unsigned i, stop = bv->cur_bit + num_bits; + for (i = bv->cur_bit; i < stop; i++) + if (bitvec_set_bit(bv, fill) < 0) return -EINVAL; return 0; } +/*! \brief pad all remaining bits up to num_bits */ +int bitvec_spare_padding(struct bitvec *bv, unsigned int up_to_bit) +{ + int n = up_to_bit - bv->cur_bit + 1; + if (n < 1) return 0; + return bitvec_fill(bv, n, L); +} + /*! \brief find first bit set in bit vector */ int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n, enum bit_value val) @@ -269,7 +296,7 @@ int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n, * \param[in] bytes array * \param[in] count number of bytes to copy */ -int bitvec_get_bytes(struct bitvec *bv, uint8_t *bytes, int count) +int bitvec_get_bytes(struct bitvec *bv, uint8_t *bytes, unsigned int count) { int byte_offs = bytenum_from_bitnum(bv->cur_bit); int bit_offs = bv->cur_bit % 8; @@ -304,7 +331,7 @@ int bitvec_get_bytes(struct bitvec *bv, uint8_t *bytes, int count) * \param[in] bytes array * \param[in] count number of bytes to copy */ -int bitvec_set_bytes(struct bitvec *bv, const uint8_t *bytes, int count) +int bitvec_set_bytes(struct bitvec *bv, const uint8_t *bytes, unsigned int count) { int byte_offs = bytenum_from_bitnum(bv->cur_bit); int bit_offs = bv->cur_bit % 8; @@ -336,4 +363,95 @@ int bitvec_set_bytes(struct bitvec *bv, const uint8_t *bytes, int count) bv->cur_bit += count * 8; return 0; } + +/*! \brief convert enum to corresponding character */ +char bit_value_to_char(enum bit_value v) +{ + switch (v) { + case ZERO: return '0'; + case ONE: return '1'; + case L: return 'L'; + case H: return 'H'; + } + return 'X'; // make compiler happy +} + +/*! \brief prints bit vector to provided string + * It's caller's responcibility to ensure that we won't shoot him in the foot. + */ +void bitvec_to_string_r(const struct bitvec *bv, char *str) +{ + unsigned i, pos = 0; + char *cur = str; + for (i = 0; i < bv->cur_bit; i++) { + if (0 == i % 8) *cur++ = ' '; + *cur++ = bit_value_to_char(bitvec_get_bit_pos(bv, i)); + pos++; + } + *cur = 0; +} + +/* we assume that x have at least 1 non-b bit */ +inline unsigned _leading_bits(uint8_t x, bool b) +{ + if (b) { + if (x < 0x80) return 0; + if (x < 0xC0) return 1; + if (x < 0xE0) return 2; + if (x < 0xF0) return 3; + if (x < 0xF8) return 4; + if (x < 0xFC) return 5; + if (x < 0xFE) return 6; + } else { + if (x > 0x7F) return 0; + if (x > 0x3F) return 1; + if (x > 0x1F) return 2; + if (x > 0xF) return 3; + if (x > 7) return 4; + if (x > 3) return 5; + if (x > 1) return 6; + } + return 7; +} +/*! \brief force bit vector to all 0 and current bit to the beginnig of the vector */ +void bitvec_zero(struct bitvec *bv) +{ + bv->cur_bit = 0; + memset(bv->data, 0, bv->data_len); +} + +/*! \brief Return number (bits) of uninterrupted run of \b in \bv starting from the MSB */ +unsigned bitvec_rl(const struct bitvec *bv, bool b) +{ + unsigned i; + for (i = 0; i < (bv->cur_bit % 8 ? bv->cur_bit / 8 + 1 : bv->cur_bit / 8); i++) { + if ( (b ? 0xFF : 0) != bv->data[i]) return i * 8 + _leading_bits(bv->data[i], b); + } + + return bv->cur_bit; +} + +/*! \brief Shifts bitvec to the left, n MSB bits lost */ +void bitvec_shiftl(struct bitvec *bv, unsigned n) +{ + if (0 == n) return; + if (n >= bv->cur_bit) { + bitvec_zero(bv); + return; + } + + memmove(bv->data, bv->data + n / 8, bv->data_len - n / 8); + + uint8_t tmp[2]; + unsigned i; + for (i = 0; i < bv->data_len - 2; i++) { + uint16_t t = osmo_load16be(bv->data + i); + osmo_store16be(t << (n % 8), &tmp); + bv->data[i] = tmp[0]; + } + + bv->data[bv->data_len - 1] <<= (n % 8); + bv->cur_bit -= n; +} + /*! @} */ diff --git a/tests/bitvec/bitvec_test.c b/tests/bitvec/bitvec_test.c index 624e334..c31e5df 100644 --- a/tests/bitvec/bitvec_test.c +++ b/tests/bitvec/bitvec_test.c @@ -3,9 +3,82 @@ #include #include #include +#include +#include +#include #include #include +#include + +#define BIN_PATTERN "%d%d%d%d%d%d%d%d" +#define BIN(byte) \ + (byte & 0x80 ? 1 : 0), \ + (byte & 0x40 ? 1 : 0), \ + (byte & 0x20 ? 1 : 0), \ + (byte & 0x10 ? 1 : 0), \ + (byte & 0x08 ? 1 : 0), \ + (byte & 0x04 ? 1 : 0), \ + (byte & 0x02 ? 1 : 0), \ + (byte & 0x01 ? 1 : 0) + +static char lol[1024]; // we pollute this with printed vectors +static inline void test_rl(const struct bitvec *bv) +{ + bitvec_to_string_r(bv, lol); + printf("%s [%d] RL0=%d, RL1=%d\n", lol, bv->cur_bit, bitvec_rl(bv, false), bitvec_rl(bv, true)); +} + +static inline void test_shift(struct bitvec *bv, unsigned n) +{ + bitvec_to_string_r(bv, lol); + printf("%s << %d:\n", lol, n); + bitvec_shiftl(bv, n); + bitvec_to_string_r(bv, lol); + printf("%s\n", lol); +} + +static inline void test_get(struct bitvec *bv, unsigned n) +{ + bitvec_to_string_r(bv, lol); + printf("%s [%d]", lol, bv->cur_bit); + int16_t x = bitvec_get_int16_msb(bv, n); + uint8_t tmp[2]; + osmo_store16be(x, &tmp); + printf(" -> %d (%u bit) ["BIN_PATTERN" "BIN_PATTERN"]:\n", x, n, BIN(tmp[0]), BIN(tmp[1])); + bitvec_to_string_r(bv, lol); + printf("%s [%d]\n", lol, bv->cur_bit); +} + +static inline void test_fill(struct bitvec *bv, unsigned n, enum bit_value val) +{ + bitvec_to_string_r(bv, lol); + unsigned bvlen = bv->cur_bit; + int fi = bitvec_fill(bv, n, val); + printf("%c> FILL %s [%d] -%d-> [%d]:\n", bit_value_to_char(val), lol, bvlen, n, fi); + bitvec_to_string_r(bv, lol); + printf(" %s [%d]\n\n", lol, bv->cur_bit); +} + +static inline void test_spare(struct bitvec *bv, unsigned n) +{ + bitvec_to_string_r(bv, lol); + unsigned bvlen = bv->cur_bit; + int sp = bitvec_spare_padding(bv, n); + printf("%c> SPARE %s [%d] -%d-> [%d]:\n", bit_value_to_char(L), lol, bvlen, n, sp); + bitvec_to_string_r(bv, lol); + printf(" %s [%d]\n\n", lol, bv->cur_bit); +} + +static inline void test_set(struct bitvec *bv, enum bit_value bit) +{ + bitvec_to_string_r(bv, lol); + unsigned bvlen = bv->cur_bit; + int set = bitvec_set_bit(bv, bit); + printf("%c> SET %s [%d] ++> [%d]:\n", bit_value_to_char(bit), lol, bvlen, set); + bitvec_to_string_r(bv, lol); + printf(" %s [%d]\n\n", lol, bv->cur_bit); +} static void test_byte_ops() { @@ -33,7 +106,7 @@ static void test_byte_ops() rc = bitvec_set_uint(&bv, 0x7e, 8); OSMO_ASSERT(rc >= 0); - fprintf(stderr, "bitvec: %s\n", osmo_hexdump(bv.data, bv.data_len)); + printf("bitvec: %s\n", osmo_hexdump(bv.data, bv.data_len)); /* Read from bitvec */ memset(out, 0xff, sizeof(out)); @@ -45,7 +118,7 @@ static void test_byte_ops() rc = bitvec_get_uint(&bv, 8); OSMO_ASSERT(rc == 0x7e); - fprintf(stderr, "out: %s\n", osmo_hexdump(out, sizeof(out))); + printf("out: %s\n", osmo_hexdump(out, sizeof(out))); OSMO_ASSERT(out[0] == 0xff); OSMO_ASSERT(out[in_size+1] == 0xff); @@ -57,6 +130,72 @@ static void test_byte_ops() int main(int argc, char **argv) { + srand(time(NULL)); + + struct bitvec bv; + uint8_t i = 8, test[i]; + + memset(test, 0, i); + bv.data_len = i; + bv.data = test; + bv.cur_bit = 0; + + printf("test shifting...\n"); + + bitvec_set_uint(&bv, 0x0E, 7); + test_shift(&bv, 3); + test_shift(&bv, 17); + bitvec_set_uint(&bv, 0, 32); + bitvec_set_uint(&bv, 0x0A, 7); + test_shift(&bv, 24); + + printf("checking RL functions...\n"); + + bitvec_zero(&bv); + test_rl(&bv); + bitvec_set_uint(&bv, 0x000F, 32); + test_rl(&bv); + bitvec_shiftl(&bv, 18); + test_rl(&bv); + bitvec_set_uint(&bv, 0x0F, 8); + test_rl(&bv); + bitvec_zero(&bv); + bitvec_set_uint(&bv, 0xFF, 8); + test_rl(&bv); + bitvec_set_uint(&bv, 0xFE, 7); + test_rl(&bv); + bitvec_set_uint(&bv, 0, 17); + test_rl(&bv); + bitvec_shiftl(&bv, 18); + test_rl(&bv); + + printf("probing bit access...\n"); + + bitvec_zero(&bv); + bitvec_set_uint(&bv, 0x3747817, 32); + bitvec_shiftl(&bv, 10); + + test_get(&bv, 2); + test_get(&bv, 7); + test_get(&bv, 9); + test_get(&bv, 13); + test_get(&bv, 16); + test_get(&bv, 42); + + printf("feeling bit fills...\n"); + + test_set(&bv, ONE); + test_fill(&bv, 3, ZERO); + test_spare(&bv, 38); + test_spare(&bv, 43); + test_spare(&bv, 1); + test_spare(&bv, 7); + test_fill(&bv, 5, ONE); + test_fill(&bv, 3, L); + + printf("byte me...\n"); + test_byte_ops(); + return 0; } diff --git a/tests/bitvec/bitvec_test.ok b/tests/bitvec/bitvec_test.ok index 1f329af..38575f7 100644 --- a/tests/bitvec/bitvec_test.ok +++ b/tests/bitvec/bitvec_test.ok @@ -1,2 +1,121 @@ +test shifting... + 0001110 << 3: + 1110 + 1110 << 17: + + 00000000 00000000 00000000 00000000 0001010 << 24: + 00000000 0001010 +checking RL functions... + [0] RL0=0, RL1=0 + 00000000 00000000 00000000 00001111 [32] RL0=28, RL1=0 + 00000000 001111 [14] RL0=10, RL1=0 + 00000000 00111100 001111 [22] RL0=10, RL1=0 + 11111111 [8] RL0=0, RL1=8 + 11111111 1111110 [15] RL0=0, RL1=14 + 11111111 11111100 00000000 00000000 [32] RL0=0, RL1=14 + 00000000 000000 [14] RL0=14, RL1=0 +probing bit access... + 11010001 11100000 010111 [22] -> 3 (2 bit) [00000000 00000011]: + 11010001 11100000 010111 [22] + 11010001 11100000 010111 [22] -> 104 (7 bit) [00000000 01101000]: + 11010001 11100000 010111 [22] + 11010001 11100000 010111 [22] -> 419 (9 bit) [00000001 10100011]: + 11010001 11100000 010111 [22] + 11010001 11100000 010111 [22] -> 6716 (13 bit) [00011010 00111100]: + 11010001 11100000 010111 [22] + 11010001 11100000 010111 [22] -> -22 (16 bit) [11111111 11101010]: + 11010001 11100000 010111 [22] + 11010001 11100000 010111 [22] -> -22 (42 bit) [11111111 11101010]: + 11010001 11100000 010111 [22] +feeling bit fills... +1> SET 11010001 11100000 010111 [22] ++> [0]: + 11010001 11100000 0101111 [23] + +0> FILL 11010001 11100000 0101111 [23] -3-> [0]: + 11010001 11100000 01011110 00 [26] + +L> SPARE 11010001 11100000 01011110 00 [26] -38-> [0]: + 11010001 11100000 01011110 00101011 0010101 [39] + +L> SPARE 11010001 11100000 01011110 00101011 0010101 [39] -43-> [0]: + 11010001 11100000 01011110 00101011 00101011 0010 [44] + +L> SPARE 11010001 11100000 01011110 00101011 00101011 0010 [44] -1-> [0]: + 11010001 11100000 01011110 00101011 00101011 0010 [44] + +L> SPARE 11010001 11100000 01011110 00101011 00101011 0010 [44] -7-> [0]: + 11010001 11100000 01011110 00101011 00101011 0010 [44] + +1> FILL 11010001 11100000 01011110 00101011 00101011 0010 [44] -5-> [0]: + 11010001 11100000 01011110 00101011 00101011 00101111 1 [49] + +L> FILL 11010001 11100000 01011110 00101011 00101011 00101111 1 [49] -3-> [0]: + 11010001 11100000 01011110 00101011 00101011 00101111 1010 [52] + +byte me... === start test_byte_ops === +bitvec: 7e 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 7e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 3f 20 a1 21 a2 22 a3 23 a4 24 a5 25 a6 26 a7 27 a8 28 a9 29 aa 2a ab 2b ac 2c ad 3f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 1f 90 50 90 d1 11 51 91 d2 12 52 92 d3 13 53 93 d4 14 54 94 d5 15 55 95 d6 16 56 9f 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 0f c8 28 48 68 88 a8 c8 e9 09 29 49 69 89 a9 c9 ea 0a 2a 4a 6a 8a aa ca eb 0b 2b 4f c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 07 e4 14 24 34 44 54 64 74 84 94 a4 b4 c4 d4 e4 f5 05 15 25 35 45 55 65 75 85 95 a7 e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 03 f2 0a 12 1a 22 2a 32 3a 42 4a 52 5a 62 6a 72 7a 82 8a 92 9a a2 aa b2 ba c2 ca d3 f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 01 f9 05 09 0d 11 15 19 1d 21 25 29 2d 31 35 39 3d 41 45 49 4d 51 55 59 5d 61 65 69 f8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 fc 82 84 86 88 8a 8c 8e 90 92 94 96 98 9a 9c 9e a0 a2 a4 a6 a8 aa ac ae b0 b2 b4 fc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 7e 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 7e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 3f 20 a1 21 a2 22 a3 23 a4 24 a5 25 a6 26 a7 27 a8 28 a9 29 aa 2a ab 2b ac 2c ad 3f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 1f 90 50 90 d1 11 51 91 d2 12 52 92 d3 13 53 93 d4 14 54 94 d5 15 55 95 d6 16 56 9f 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 0f c8 28 48 68 88 a8 c8 e9 09 29 49 69 89 a9 c9 ea 0a 2a 4a 6a 8a aa ca eb 0b 2b 4f c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 07 e4 14 24 34 44 54 64 74 84 94 a4 b4 c4 d4 e4 f5 05 15 25 35 45 55 65 75 85 95 a7 e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 03 f2 0a 12 1a 22 2a 32 3a 42 4a 52 5a 62 6a 72 7a 82 8a 92 9a a2 aa b2 ba c2 ca d3 f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 01 f9 05 09 0d 11 15 19 1d 21 25 29 2d 31 35 39 3d 41 45 49 4d 51 55 59 5d 61 65 69 f8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 fc 82 84 86 88 8a 8c 8e 90 92 94 96 98 9a 9c 9e a0 a2 a4 a6 a8 aa ac ae b0 b2 b4 fc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 7e 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 7e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 3f 20 a1 21 a2 22 a3 23 a4 24 a5 25 a6 26 a7 27 a8 28 a9 29 aa 2a ab 2b ac 2c ad 3f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 1f 90 50 90 d1 11 51 91 d2 12 52 92 d3 13 53 93 d4 14 54 94 d5 15 55 95 d6 16 56 9f 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 0f c8 28 48 68 88 a8 c8 e9 09 29 49 69 89 a9 c9 ea 0a 2a 4a 6a 8a aa ca eb 0b 2b 4f c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 07 e4 14 24 34 44 54 64 74 84 94 a4 b4 c4 d4 e4 f5 05 15 25 35 45 55 65 75 85 95 a7 e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 03 f2 0a 12 1a 22 2a 32 3a 42 4a 52 5a 62 6a 72 7a 82 8a 92 9a a2 aa b2 ba c2 ca d3 f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 01 f9 05 09 0d 11 15 19 1d 21 25 29 2d 31 35 39 3d 41 45 49 4d 51 55 59 5d 61 65 69 f8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 00 fc 82 84 86 88 8a 8c 8e 90 92 94 96 98 9a 9c 9e a0 a2 a4 a6 a8 aa ac ae b0 b2 b4 fc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 00 7e 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 7e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 00 3f 20 a1 21 a2 22 a3 23 a4 24 a5 25 a6 26 a7 27 a8 28 a9 29 aa 2a ab 2b ac 2c ad 3f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 00 1f 90 50 90 d1 11 51 91 d2 12 52 92 d3 13 53 93 d4 14 54 94 d5 15 55 95 d6 16 56 9f 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 00 0f c8 28 48 68 88 a8 c8 e9 09 29 49 69 89 a9 c9 ea 0a 2a 4a 6a 8a aa ca eb 0b 2b 4f c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 00 07 e4 14 24 34 44 54 64 74 84 94 a4 b4 c4 d4 e4 f5 05 15 25 35 45 55 65 75 85 95 a7 e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 00 03 f2 0a 12 1a 22 2a 32 3a 42 4a 52 5a 62 6a 72 7a 82 8a 92 9a a2 aa b2 ba c2 ca d3 f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 00 01 f9 05 09 0d 11 15 19 1d 21 25 29 2d 31 35 39 3d 41 45 49 4d 51 55 59 5d 61 65 69 f8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff +bitvec: 00 00 00 00 fc 82 84 86 88 8a 8c 8e 90 92 94 96 98 9a 9c 9e a0 a2 a4 a6 a8 aa ac ae b0 b2 b4 fc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +out: ff 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a ff === end test_byte_ops === -- 2.5.0 From suraev at alumni.ntnu.no Tue Jan 19 16:10:06 2016 From: suraev at alumni.ntnu.no (=?UTF-8?B?TWF4ICjimK0p?=) Date: Tue, 19 Jan 2016 17:10:06 +0100 Subject: [PATCH] Extend bitvec. In-Reply-To: <1453219488-20958-1-git-send-email-suraev@alumni.ntnu.no> References: <1453219488-20958-1-git-send-email-suraev@alumni.ntnu.no> Message-ID: <569E5FDE.2010402@alumni.ntnu.no> This is 2nd version of bitvec extension patches necessary for T4 bit map compression support. It incorporates previous fedback and includes additional functions and tests. Please review, Max. From suraev at alumni.ntnu.no Wed Jan 20 15:57:44 2016 From: suraev at alumni.ntnu.no (suraev at alumni.ntnu.no) Date: Wed, 20 Jan 2016 16:57:44 +0100 Subject: [PATCH] Enable address sanitizer for tests. Message-ID: <1453305464-21916-1-git-send-email-suraev@alumni.ntnu.no> From: Max Some tests are leaky which is ok since it's one-shot programs anyway. For them mem. leak sanitizer is explicitly disabled via env. variables. Sponsored-by: On-Waves ehf --- tests/Makefile.am | 4 ++-- tests/testsuite.at | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index a4a6b2e..082f449 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -AM_CFLAGS = -Wall $(TALLOC_CFLAGS) -AM_LDFLAGS = $(TALLOC_LIBS) +AM_CFLAGS = -Wall $(TALLOC_CFLAGS) -ggdb3 -Og -fsanitize=address -fno-omit-frame-pointer +AM_LDFLAGS = $(TALLOC_LIBS) -fsanitize=address check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test \ smscb/smscb_test bits/bitrev_test a5/a5_test \ diff --git a/tests/testsuite.at b/tests/testsuite.at index 9cda1de..32defa3 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -1,6 +1,6 @@ AT_INIT AT_BANNER([Regression tests.]) - +AT_COLOR_TESTS # todo.. create one macro for it AT_SETUP([a5]) @@ -44,7 +44,7 @@ AT_SETUP([msgfile]) AT_KEYWORDS([msgfile]) cp $abs_srcdir/msgfile/msgconfig.cfg . cat $abs_srcdir/msgfile/msgfile_test.ok > expout -AT_CHECK([$abs_top_builddir/tests/msgfile/msgfile_test], [0], [expout]) +AT_CHECK([ASAN_OPTIONS="detect_leaks=0" $abs_top_builddir/tests/msgfile/msgfile_test], [0], [expout]) AT_CLEANUP endif @@ -81,13 +81,13 @@ AT_CLEANUP AT_SETUP([lapd]) AT_KEYWORDS([lapd]) cat $abs_srcdir/lapd/lapd_test.ok > expout -AT_CHECK([$abs_top_builddir/tests/lapd/lapd_test], [0], [expout], [ignore]) +AT_CHECK([ASAN_OPTIONS="detect_leaks=0" $abs_top_builddir/tests/lapd/lapd_test], [0], [expout], [ignore]) AT_CLEANUP AT_SETUP([gsm0808]) AT_KEYWORDS([gsm0808]) cat $abs_srcdir/gsm0808/gsm0808_test.ok > expout -AT_CHECK([$abs_top_builddir/tests/gsm0808/gsm0808_test], [0], [expout], [ignore]) +AT_CHECK([ASAN_OPTIONS="detect_leaks=0" $abs_top_builddir/tests/gsm0808/gsm0808_test], [0], [expout], [ignore]) AT_CLEANUP AT_SETUP([gsm0408]) @@ -164,7 +164,7 @@ AT_SETUP([bssgp-fc]) AT_KEYWORDS([bssgp-fc]) cat $abs_srcdir/gb/bssgp_fc_tests.ok > expout cat $abs_srcdir/gb/bssgp_fc_tests.err > experr -AT_CHECK([$abs_top_srcdir/tests/gb/bssgp_fc_tests.sh $abs_top_builddir/tests/gb], [0], [expout], [experr]) +AT_CHECK([ASAN_OPTIONS="detect_leaks=0" $abs_top_srcdir/tests/gb/bssgp_fc_tests.sh $abs_top_builddir/tests/gb], [0], [expout], [experr]) AT_CLEANUP AT_SETUP([timer]) -- 2.5.0 From robert.steve07 at gmail.com Tue Jan 26 16:24:07 2016 From: robert.steve07 at gmail.com (robert steve) Date: Tue, 26 Jan 2016 18:24:07 +0200 Subject: omsocombb not receiving calls Message-ID: Hi, I would first like to thank all those who participated in this nice project. I recently started working with osmocombb and was able to have it working fine on a motorola c118. However, I noticed that some sim cards can connect normally to the BTS, can make calls and send SMS but can?t receive anything. They simply don't get paged. While for some other sim cards everything seems to be working fine. Does anyone know what might be causing this issue ? thanks, Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From domi at tomcsanyi.net Tue Jan 26 16:30:09 2016 From: domi at tomcsanyi.net (=?utf-8?Q?Tomcs=C3=A1nyi_Domonkos?=) Date: Tue, 26 Jan 2016 17:30:09 +0100 Subject: omsocombb not receiving calls In-Reply-To: References: Message-ID: Hi Robert, I think it would help us out a lot if you could provide at least one complete log file from the output of the mobile app, so we can start having some ideas. Cheers, Domi > 2016. jan. 26. d?tummal, 17:24 id?pontban robert steve ?rta: > > Hi, > I would first like to thank all those who participated in this nice project. > I recently started working with osmocombb and was able to have it working fine on a motorola c118. > However, I noticed that some sim cards can connect normally to the BTS, can make calls and send SMS but can?t receive anything. They simply don't get paged. While for some other sim cards everything seems to be working fine. > > Does anyone know what might be causing this issue ? > > thanks, > Robert From axilirator at gmail.com Sat Jan 30 14:36:22 2016 From: axilirator at gmail.com (Vadim Yanitskiy) Date: Sat, 30 Jan 2016 20:36:22 +0600 Subject: [PATCH] layer23/cell_log: Set default logfile to /dev/null Message-ID: <1454164582-10485-1-git-send-email-axilirator@gmail.com> When '/var/log/osmocom.log' does not exist the cell_log app can not start normally because it has no permissions to create a new file. Furthermore, logfile is optional now. --- src/host/layer23/src/misc/app_cell_log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/host/layer23/src/misc/app_cell_log.c b/src/host/layer23/src/misc/app_cell_log.c index a7f42c3..5b7f7b4 100644 --- a/src/host/layer23/src/misc/app_cell_log.c +++ b/src/host/layer23/src/misc/app_cell_log.c @@ -43,7 +43,7 @@ extern void *l23_ctx; extern uint16_t basic_band_range[][2]; extern uint16_t (*band_range)[][2]; -char *logname = "/var/log/osmocom.log"; +char *logname = "/dev/null"; int RACH_MAX = 2; int _scan_work(struct osmocom_ms *ms) -- 1.9.1