From holger at freyther.de Mon Jul 6 14:52:27 2015 From: holger at freyther.de (Holger Hans Peyer Freyther) Date: Mon, 6 Jul 2015 16:52:27 +0200 Subject: [PATCH 1/4] sms: Move the routing of the sms to a separate function Message-ID: <1436194350-12094-1-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther The "default-route" for SMPP will be used after a local subscriber look-up. Sometimes we want to route everything to SMPP. Make this possible by changing this routine. --- openbsc/src/libmsc/gsm_04_11.c | 89 ++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 39 deletions(-) diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c index 1b2a42c..0150de6 100644 --- a/openbsc/src/libmsc/gsm_04_11.c +++ b/openbsc/src/libmsc/gsm_04_11.c @@ -277,6 +277,55 @@ static int gsm340_gen_sms_deliver_tpdu(struct msgb *msg, struct gsm_sms *sms) return msg->len - old_msg_len; } +int sms_route_mt_sms(struct gsm_subscriber_connection *conn, struct msgb *msg, + struct gsm_sms *gsms, uint8_t sms_mti) +{ + int rc; + + /* determine gsms->receiver based on dialled number */ + gsms->receiver = subscr_get_by_extension(conn->bts->network->subscr_group, + gsms->dst.addr); + if (!gsms->receiver) { +#ifdef BUILD_SMPP + rc = smpp_try_deliver(gsms, conn); + if (rc == 1) { + rc = 1; /* cause 1: unknown subscriber */ + osmo_counter_inc(conn->bts->network->stats.sms.no_receiver); + } else if (rc < 0) { + rc = 21; /* cause 21: short message transfer rejected */ + /* FIXME: handle the error somehow? */ + } +#else + rc = 1; /* cause 1: unknown subscriber */ + osmo_counter_inc(conn->bts->network->stats.sms.no_receiver); +#endif + goto out; + } + + switch (sms_mti) { + case GSM340_SMS_SUBMIT_MS2SC: + /* MS is submitting a SMS */ + rc = gsm340_rx_sms_submit(msg, gsms); + break; + case GSM340_SMS_COMMAND_MS2SC: + case GSM340_SMS_DELIVER_REP_MS2SC: + LOGP(DLSMS, LOGL_NOTICE, "Unimplemented MTI 0x%02x\n", sms_mti); + rc = GSM411_RP_CAUSE_IE_NOTEXIST; + break; + default: + LOGP(DLSMS, LOGL_NOTICE, "Undefined MTI 0x%02x\n", sms_mti); + rc = GSM411_RP_CAUSE_IE_NOTEXIST; + break; + } + + if (!rc && !gsms->receiver) + rc = GSM411_RP_CAUSE_MO_NUM_UNASSIGNED; + +out: + return rc; +} + + /* process an incoming TPDU (called from RP-DATA) * return value > 0: RP CAUSE for ERROR; < 0: silent error; 0 = success */ static int gsm340_rx_tpdu(struct gsm_subscriber_connection *conn, struct msgb *msg) @@ -392,45 +441,7 @@ static int gsm340_rx_tpdu(struct gsm_subscriber_connection *conn, struct msgb *m /* FIXME: This looks very wrong */ send_signal(0, NULL, gsms, 0); - /* determine gsms->receiver based on dialled number */ - gsms->receiver = subscr_get_by_extension(conn->bts->network->subscr_group, - gsms->dst.addr); - if (!gsms->receiver) { -#ifdef BUILD_SMPP - rc = smpp_try_deliver(gsms, conn); - if (rc == 1) { - rc = 1; /* cause 1: unknown subscriber */ - osmo_counter_inc(conn->bts->network->stats.sms.no_receiver); - } else if (rc < 0) { - rc = 21; /* cause 21: short message transfer rejected */ - /* FIXME: handle the error somehow? */ - } -#else - rc = 1; /* cause 1: unknown subscriber */ - osmo_counter_inc(conn->bts->network->stats.sms.no_receiver); -#endif - goto out; - } - - switch (sms_mti) { - case GSM340_SMS_SUBMIT_MS2SC: - /* MS is submitting a SMS */ - rc = gsm340_rx_sms_submit(msg, gsms); - break; - case GSM340_SMS_COMMAND_MS2SC: - case GSM340_SMS_DELIVER_REP_MS2SC: - LOGP(DLSMS, LOGL_NOTICE, "Unimplemented MTI 0x%02x\n", sms_mti); - rc = GSM411_RP_CAUSE_IE_NOTEXIST; - break; - default: - LOGP(DLSMS, LOGL_NOTICE, "Undefined MTI 0x%02x\n", sms_mti); - rc = GSM411_RP_CAUSE_IE_NOTEXIST; - break; - } - - if (!rc && !gsms->receiver) - rc = GSM411_RP_CAUSE_MO_NUM_UNASSIGNED; - + rc = sms_route_mt_sms(conn, msg, gsms, sms_mti); out: sms_free(gsms); -- 2.3.5 From holger at freyther.de Mon Jul 6 14:52:28 2015 From: holger at freyther.de (Holger Hans Peyer Freyther) Date: Mon, 6 Jul 2015 16:52:28 +0200 Subject: [PATCH 2/4] sms: Put the try_deliver into the header file In-Reply-To: <1436194350-12094-1-git-send-email-holger@freyther.de> References: <1436194350-12094-1-git-send-email-holger@freyther.de> Message-ID: <1436194350-12094-2-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther Even if it is using BSC/NITB types let's put it in the header file than just declaring it at a place that could bitrot in a way that doesn't lead a warning. --- openbsc/src/libmsc/gsm_04_11.c | 2 -- openbsc/src/libmsc/smpp_smsc.h | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c index 0150de6..82e9fae 100644 --- a/openbsc/src/libmsc/gsm_04_11.c +++ b/openbsc/src/libmsc/gsm_04_11.c @@ -57,8 +57,6 @@ #ifdef BUILD_SMPP #include "smpp_smsc.h" -extern int smpp_try_deliver(struct gsm_sms *sms, - struct gsm_subscriber_connection *conn); #endif void *tall_gsms_ctx; diff --git a/openbsc/src/libmsc/smpp_smsc.h b/openbsc/src/libmsc/smpp_smsc.h index 21d28dd..8d31b2b 100644 --- a/openbsc/src/libmsc/smpp_smsc.h +++ b/openbsc/src/libmsc/smpp_smsc.h @@ -131,4 +131,12 @@ int smpp_route_pfx_del(struct osmo_smpp_acl *acl, int smpp_vty_init(void); int smpp_determine_scheme(uint8_t dcs, uint8_t *data_coding, int *mode); + + + +struct gsm_sms; +struct gsm_subscriber_connection; + +int smpp_try_deliver(struct gsm_sms *sms, + struct gsm_subscriber_connection *conn); #endif -- 2.3.5 From holger at freyther.de Mon Jul 6 14:52:30 2015 From: holger at freyther.de (Holger Hans Peyer Freyther) Date: Mon, 6 Jul 2015 16:52:30 +0200 Subject: [PATCH 4/4] sms: Add a way to always route SMS through SMPP systems In-Reply-To: <1436194350-12094-1-git-send-email-holger@freyther.de> References: <1436194350-12094-1-git-send-email-holger@freyther.de> Message-ID: <1436194350-12094-4-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther default-route would only be looked at after there has been no subscriber in the local database. Depending on the setup this is not what one wants. This has been discussed at the OsmoDevCon and there have been hacks in some branches. Let's introduce a VTY command to select if SMPP should be consulted first and then fallback to the current behavior. --- openbsc/src/libmsc/gsm_04_11.c | 21 +++++++++++++++++++++ openbsc/src/libmsc/smpp_openbsc.c | 5 +++++ openbsc/src/libmsc/smpp_smsc.h | 3 +++ openbsc/src/libmsc/smpp_vty.c | 22 ++++++++++++++++++++++ openbsc/tests/vty_test_runner.py | 22 ++++++++++++++++++++++ 5 files changed, 73 insertions(+) diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c index 2b6966d..b316d62 100644 --- a/openbsc/src/libmsc/gsm_04_11.c +++ b/openbsc/src/libmsc/gsm_04_11.c @@ -280,6 +280,27 @@ int sms_route_mt_sms(struct gsm_subscriber_connection *conn, struct msgb *msg, { int rc; +#ifdef BUILD_SMPP + /* + * Route through SMPP first before going to the local database. In case + * of a unroutable message and no local subscriber, SMPP will be tried + * twice. In case of an unknown subscriber continue with the normal + * delivery of the SMS. + */ + if (smpp_route_smpp_first(gsms, conn)) { + rc = smpp_try_deliver(gsms, conn); + if (rc == 1) + goto try_local; + if (rc < 0) { + rc = 21; /* cause 21: short message transfer rejected */ + /* FIXME: handle the error somehow? */ + } + return rc; + } + +try_local: +#endif + /* determine gsms->receiver based on dialled number */ gsms->receiver = subscr_get_by_extension(conn->bts->network->subscr_group, gsms->dst.addr); diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c index b17222f..057a9d0 100644 --- a/openbsc/src/libmsc/smpp_openbsc.c +++ b/openbsc/src/libmsc/smpp_openbsc.c @@ -539,6 +539,11 @@ static int deliver_to_esme(struct osmo_esme *esme, struct gsm_sms *sms, static struct smsc *g_smsc; +int smpp_route_smpp_first(struct gsm_sms *sms, struct gsm_subscriber_connection *conn) +{ + return g_smsc->smpp_first; +} + int smpp_try_deliver(struct gsm_sms *sms, struct gsm_subscriber_connection *conn) { struct osmo_esme *esme; diff --git a/openbsc/src/libmsc/smpp_smsc.h b/openbsc/src/libmsc/smpp_smsc.h index 8d31b2b..3dd6562 100644 --- a/openbsc/src/libmsc/smpp_smsc.h +++ b/openbsc/src/libmsc/smpp_smsc.h @@ -92,6 +92,7 @@ struct smsc { uint16_t listen_port; char system_id[SMPP_SYS_ID_LEN+1]; int accept_all; + int smpp_first; struct osmo_smpp_acl *def_route; void *priv; }; @@ -137,6 +138,8 @@ int smpp_determine_scheme(uint8_t dcs, uint8_t *data_coding, int *mode); struct gsm_sms; struct gsm_subscriber_connection; +int smpp_route_smpp_first(struct gsm_sms *sms, + struct gsm_subscriber_connection *conn); int smpp_try_deliver(struct gsm_sms *sms, struct gsm_subscriber_connection *conn); #endif diff --git a/openbsc/src/libmsc/smpp_vty.c b/openbsc/src/libmsc/smpp_vty.c index 75427a9..c0695fe 100644 --- a/openbsc/src/libmsc/smpp_vty.c +++ b/openbsc/src/libmsc/smpp_vty.c @@ -58,6 +58,24 @@ DEFUN(cfg_smpp, cfg_smpp_cmd, return CMD_SUCCESS; } +DEFUN(cfg_smpp_first, cfg_smpp_first_cmd, + "smpp-first", + "Try SMPP routes before the subscriber DB\n") +{ + struct smsc *smsc = smsc_from_vty(vty); + smsc->smpp_first = 1; + return CMD_SUCCESS; +} + +DEFUN(cfg_no_smpp_first, cfg_no_smpp_first_cmd, + "no smpp-first", + NO_STR "Try SMPP before routes before the subscriber DB\n") +{ + struct smsc *smsc = smsc_from_vty(vty); + smsc->smpp_first = 0; + return CMD_SUCCESS; +} + DEFUN(cfg_smpp_port, cfg_smpp_port_cmd, "local-tcp-port <1-65535>", "Set the local TCP port on which we listen for SMPP\n" @@ -125,6 +143,8 @@ static int config_write_smpp(struct vty *vty) vty_out(vty, " system-id %s%s", smsc->system_id, VTY_NEWLINE); vty_out(vty, " policy %s%s", smsc->accept_all ? "accept-all" : "closed", VTY_NEWLINE); + vty_out(vty, " %ssmpp-first%s", + smsc->smpp_first ? "" : "no ", VTY_NEWLINE); return CMD_SUCCESS; } @@ -512,6 +532,8 @@ int smpp_vty_init(void) vty_install_default(SMPP_NODE); install_element(CONFIG_NODE, &cfg_smpp_cmd); + install_element(SMPP_NODE, &cfg_smpp_first_cmd); + install_element(SMPP_NODE, &cfg_no_smpp_first_cmd); install_element(SMPP_NODE, &cfg_smpp_port_cmd); install_element(SMPP_NODE, &cfg_smpp_sys_id_cmd); install_element(SMPP_NODE, &cfg_smpp_policy_cmd); diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 4cd4665..1aedcf2 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -154,6 +154,28 @@ class TestVTYNITB(TestVTYGenericBSC): res = self.vty.command("list") return "smpp" in res + def testSmppFirst(self): + if not self.checkForSmpp(): + return + + # enable the configuration + self.vty.enable() + self.vty.command("configure terminal") + self.vty.command("smpp") + + # check the default + res = self.vty.command("write terminal") + self.assert_(res.find(' no smpp-first') > 0) + + self.vty.verify("smpp-first", ['']) + res = self.vty.command("write terminal") + self.assert_(res.find(' smpp-first') > 0) + self.assertEquals(res.find('no smpp-first'), -1) + + self.vty.verify("no smpp-first", ['']) + res = self.vty.command("write terminal") + self.assert_(res.find('no smpp-first') > 0) + def testVtyTree(self): self.vty.enable() self.assertTrue(self.vty.verify("configure terminal", [''])) -- 2.3.5 From holger at freyther.de Mon Jul 6 14:52:29 2015 From: holger at freyther.de (Holger Hans Peyer Freyther) Date: Mon, 6 Jul 2015 16:52:29 +0200 Subject: [PATCH 3/4] sms: Simplify the return handling for SMPP routes/unroutable In-Reply-To: <1436194350-12094-1-git-send-email-holger@freyther.de> References: <1436194350-12094-1-git-send-email-holger@freyther.de> Message-ID: <1436194350-12094-3-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther --- openbsc/src/libmsc/gsm_04_11.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c index 82e9fae..2b6966d 100644 --- a/openbsc/src/libmsc/gsm_04_11.c +++ b/openbsc/src/libmsc/gsm_04_11.c @@ -297,7 +297,7 @@ int sms_route_mt_sms(struct gsm_subscriber_connection *conn, struct msgb *msg, rc = 1; /* cause 1: unknown subscriber */ osmo_counter_inc(conn->bts->network->stats.sms.no_receiver); #endif - goto out; + return rc; } switch (sms_mti) { @@ -319,7 +319,6 @@ int sms_route_mt_sms(struct gsm_subscriber_connection *conn, struct msgb *msg, if (!rc && !gsms->receiver) rc = GSM411_RP_CAUSE_MO_NUM_UNASSIGNED; -out: return rc; } -- 2.3.5 From Max.Suraev at fairwaves.co Mon Jul 6 14:54:43 2015 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Mon, 06 Jul 2015 16:54:43 +0200 Subject: segfault on bssgp test In-Reply-To: References: <555F3139.4080206@fairwaves.co> <556C64F3.9040301@fairwaves.co> <55719F24.3050000@fairwaves.co> <5571C8CA.4030408@fairwaves.co> Message-ID: <559A96B3.10208@fairwaves.co> After some further digging I've found that "make check" do not see this error but "dpkg-buildpackage -tc -uc -us" does. So apparently .deb build invoke different linker or same linker with different options which in turn triggers this bug. No idea how to track down this difference. 05.06.2015 18:19, Holger Freyther ?????: > >> On 05 Jun 2015, at 18:05, ? wrote: >>> >> >> Hmm.. so it works on Debian but not on Ubuntu? How do I check if gold is used as linker? > > it is not only gold. My first suspicion would be to put a break point in sendto and > see which is executed (the system one or the overload) > -- best regards, Max, http://fairwaves.co From holger at freyther.de Mon Jul 6 14:57:02 2015 From: holger at freyther.de (Holger Freyther) Date: Mon, 6 Jul 2015 16:57:02 +0200 Subject: segfault on bssgp test In-Reply-To: <559A96B3.10208@fairwaves.co> References: <555F3139.4080206@fairwaves.co> <556C64F3.9040301@fairwaves.co> <55719F24.3050000@fairwaves.co> <5571C8CA.4030408@fairwaves.co> <559A96B3.10208@fairwaves.co> Message-ID: <84463E2B-5598-4E8F-A2BC-612543164974@freyther.de> > On 06 Jul 2015, at 16:54, ? wrote: > > After some further digging I've found that "make check" do not see this error but > "dpkg-buildpackage -tc -uc -us" does. So apparently .deb build invoke different > linker or same linker with different options which in turn triggers this bug. > > No idea how to track down this difference. export DEB_BUILD_HARDENING=1 will enable extra flags. E.g. -fPIE -pie might be a candidate? From Max.Suraev at fairwaves.co Tue Jul 7 18:30:01 2015 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 07 Jul 2015 20:30:01 +0200 Subject: bssgp test In-Reply-To: <55753EEE.4010906@sysmocom.de> References: <5571A0F9.7010404@fairwaves.co> <55753EEE.4010906@sysmocom.de> Message-ID: <559C1AA9.2030308@fairwaves.co> Hey. A little heads-up on this - I've converted libosmocore test to use --wrap linker feature (see http://patchwork.ozlabs.org/patch/491690/ for patch) but attempts to do the same with gbproxy test of OpenBSC fails exactly the same way as before: Assert failed expect_msg() gbproxy_test.c:1922 backtrace() returned 5 addresses ./gbproxy_test() [0x40aa12] ./gbproxy_test() [0x40291a] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7efd2814da40] ./gbproxy_test() [0x408009] The test is compiled as follows: gcc -Wall -ggdb3 -I/usr/include/ -I/usr/include/ -I/usr/include/ -g -O2 -Wl,-static,--wrap=gprs_ns_sendmsg,--wrap=sendto,-Bdynamic -o gbproxy_test gbproxy_test.o ../../src/gprs/gb_proxy.o ../../src/gprs/gb_proxy_patch.o ../../src/gprs/gb_proxy_peer.o ../../src/gprs/gb_proxy_tlli.o ../../src/gprs/gprs_gb_parse.o ../../src/gprs/gprs_llc_parse.o ../../src/gprs/crc24.o ../../src/gprs/gprs_utils.o ../../src/libcommon/libcommon.a ../../src/libbsc/libbsc.a ../../src/libtrau/libtrau.a -losmocore -losmogb -losmovty -losmogsm -losmovty -losmoabis -ldl -lrt Does it mean that the wrappers are not applied properly? Or it's because of mysterious "msgb_bssgph" patch mentioned in the comments next to assert? -- best regards, Max, http://fairwaves.co From holger at freyther.de Wed Jul 8 13:42:34 2015 From: holger at freyther.de (Holger Freyther) Date: Wed, 8 Jul 2015 15:42:34 +0200 Subject: bssgp test In-Reply-To: <559C1AA9.2030308@fairwaves.co> References: <5571A0F9.7010404@fairwaves.co> <55753EEE.4010906@sysmocom.de> <559C1AA9.2030308@fairwaves.co> Message-ID: <01587C46-F0F4-4CC4-8296-D51C44BA0A0B@freyther.de> > On 07 Jul 2015, at 20:30, ? wrote: > > Hey. > > A little heads-up on this - I've converted libosmocore test to use --wrap linker > feature (see http://patchwork.ozlabs.org/patch/491690/ for patch) but attempts to do > the same with gbproxy test of OpenBSC fails exactly the same way as before: let?s finish the libosmocore change first. You need to write a decent commit message and I am happy to include it. holger PS: Google seems to bounce my mails I send to you, could you not use gmail? From Max.Suraev at fairwaves.co Thu Jul 9 09:41:51 2015 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Thu, 09 Jul 2015 11:41:51 +0200 Subject: MNCC and LCR Message-ID: <559E41DF.1050503@fairwaves.co> Hi all. One of the options for call routing for OpenBSC is LCR. They talk to each other over MNCC which is nice versioned protocol. What puzzles me most is the version difference: OpenBSC: openbsc/include/openbsc/mncc.h:166:#define MNCC_SOCK_VERSION 4 LCR: mncc.h:333:#define MNCC_SOCK_VERSION 5 The OpenBSC is latest from git://git.osmocom.org/openbsc master branch, the LCR is latest from git://git.misdn.eu/lcr.git, master branch as well. So, what am I missing? Where does this version difference comes from? On a related note - the MNCC code in OpenBSC is part of libbsc but there's no such package or library when I'm building .deb for example. If we could split off MNCC implementation into separate library (libmncc? libosmocore?) and use it from both LCR, OpenBSC (and whatever else we might want to use in future) than it would solve such versioning and compatibility issues once and for all. What do you think? -- best regards, Max, http://fairwaves.co From Max.Suraev at fairwaves.co Thu Jul 9 19:09:02 2015 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Thu, 09 Jul 2015 21:09:02 +0200 Subject: Supplementary Services Message-ID: <559EC6CE.5000206@fairwaves.co> Hi. I've just sent 4 patches to ML - that's cosmetic adaptation of work by Tobias Engel (tobias/supplementary_services branch) from few years back to current master. Not sure if I should put sign-off in the commits but I certainly don't claim to be author of the code. Anyway, I'd like to see this pushed forward cause I think it's useful functionality better suited for master branch - would be shame to let it bitrot :) Comments and suggestions are appreciated as usual. -- best regards, Max, http://fairwaves.co From max.suraev at fairwaves.co Thu Jul 9 19:02:23 2015 From: max.suraev at fairwaves.co (Max) Date: Thu, 9 Jul 2015 21:02:23 +0200 Subject: [PATCH 3/4] SS: add Return Error component In-Reply-To: <1436468544-20989-1-git-send-email-max.suraev@fairwaves.co> References: <1436468544-20989-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <1436468544-20989-3-git-send-email-max.suraev@fairwaves.co> Signed-off-by: Max --- openbsc/include/openbsc/gsm_04_80.h | 4 ++++ openbsc/src/libmsc/gsm_04_80.c | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/openbsc/include/openbsc/gsm_04_80.h b/openbsc/include/openbsc/gsm_04_80.h index 7139f95..20ec3ab 100644 --- a/openbsc/include/openbsc/gsm_04_80.h +++ b/openbsc/include/openbsc/gsm_04_80.h @@ -39,6 +39,10 @@ int gsm0480_send_ss_reject(struct gsm_subscriber_connection *conn, const struct ss_request *request, uint8_t problem_category, uint8_t problem_code); +int gsm0480_send_ss_return_error(struct gsm_subscriber_connection *conn, + const struct ss_request *req, + uint8_t error_code, + struct msgb *parameters); int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, int level, const char *text); int gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn); diff --git a/openbsc/src/libmsc/gsm_04_80.c b/openbsc/src/libmsc/gsm_04_80.c index b20521a..82b5623 100644 --- a/openbsc/src/libmsc/gsm_04_80.c +++ b/openbsc/src/libmsc/gsm_04_80.c @@ -91,8 +91,8 @@ int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn, /* Send response to a mobile-originated Invoke */ int gsm0480_send_ss_return_result(struct gsm_subscriber_connection *conn, - const struct ss_request *req, - struct msgb *msg) + const struct ss_request *req, + struct msgb *msg) { struct gsm48_hdr *gh; @@ -149,6 +149,38 @@ int gsm0480_send_ss_reject(struct gsm_subscriber_connection *conn, return gsm0808_submit_dtap(conn, msg, 0, 0); } +int gsm0480_send_ss_return_error(struct gsm_subscriber_connection *conn, + const struct ss_request *req, + uint8_t error_code, + struct msgb *parameters) +{ + struct msgb *msg = parameters; + struct gsm48_hdr *gh; + + if(!msg) + msg = gsm48_msgb_alloc(); + + /* Pre-pend the error code */ + msgb_push_TLV1(msg, GSM_0480_ERROR_CODE_TAG, error_code); + + /* Before it insert the invoke ID */ + msgb_push_TLV1(msg, GSM0480_COMPIDTAG_INVOKE_ID, req->invoke_id); + + /* Wrap this up as a Reject component */ + msgb_wrap_with_TL(msg, GSM0480_CTYPE_RETURN_ERROR); + + /* Wrap the component in a Facility message */ + msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY); + + /* And finally pre-pend the L3 header */ + gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh)); + gh->proto_discr = GSM48_PDISC_NC_SS; + gh->proto_discr |= req->transaction_id | (1<<7); /* TI direction = 1 */ + gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE; + + return gsm0808_submit_dtap(conn, msg, 0, 0); +} + int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, int level, const char *text) { struct gsm48_hdr *gh; -- 2.1.4 From max.suraev at fairwaves.co Thu Jul 9 19:02:22 2015 From: max.suraev at fairwaves.co (Max) Date: Thu, 9 Jul 2015 21:02:22 +0200 Subject: [PATCH 2/4] SS: Call Waiting In-Reply-To: <1436468544-20989-1-git-send-email-max.suraev@fairwaves.co> References: <1436468544-20989-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <1436468544-20989-2-git-send-email-max.suraev@fairwaves.co> Signed-off-by: Max --- openbsc/include/openbsc/gsm_subscriber.h | 1 + openbsc/src/libmsc/gsm_04_08.c | 39 +++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/openbsc/include/openbsc/gsm_subscriber.h b/openbsc/include/openbsc/gsm_subscriber.h index 7d6c776..6b2a88a 100644 --- a/openbsc/include/openbsc/gsm_subscriber.h +++ b/openbsc/include/openbsc/gsm_subscriber.h @@ -65,6 +65,7 @@ struct gsm_subscriber { /* for internal management */ int use_count; + int active_cc_transactions; struct llist_head entry; /* pending requests */ diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 01f8f32..127d5f4 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1261,9 +1261,19 @@ static void new_cc_state(struct gsm_trans *trans, int state) if (state > 31 || state < 0) return; - DEBUGP(DCC, "new state %s -> %s\n", - gsm48_cc_state_name(trans->cc.state), - gsm48_cc_state_name(state)); + if (trans->subscr) { + if (state != GSM_CSTATE_NULL && + trans->cc.state == GSM_CSTATE_NULL) + trans->subscr->active_cc_transactions++; + else if(state == GSM_CSTATE_NULL && + trans->cc.state != GSM_CSTATE_NULL) + trans->subscr->active_cc_transactions--; + } + + DEBUGP(DCC, "new state %s -> %s, %d active transactions\n", + gsm48_cc_state_name(trans->cc.state), + gsm48_cc_state_name(state), + trans->subscr->active_cc_transactions); trans->cc.state = state; } @@ -3063,6 +3073,29 @@ int mncc_tx_to_cc(struct gsm_network *net, int msg_type, void *arg) GSM48_CAUSE_LOC_PRN_S_LU, GSM48_CC_CAUSE_DEST_OOO); } + /* If subscriber is "busy" */ + if (subscr->active_cc_transactions) { + int rc; + uint8_t ss_status = 0; + rc = db_ss_interrogate_status(subscr, + GSM0902_SS_CODE_CW, + GSM0902_TS_CODE_TELEPHONY, + &ss_status); + DEBUGP(DCC, "(bts - trx - ts - ti -- sub %s) " + "Received '%s' from MNCC with " + "busy subscriber %s, cw ss_status: %X\n", + data->called.number, get_mncc_name(msg_type), + data->called.number, ss_status); + if(rc < 0 || (ss_status != (GSM0902_SS_STATUS_P_BIT | + GSM0902_SS_STATUS_A_BIT))) { + subscr_put(subscr); + /* User busy */ + return mncc_release_ind(net, NULL, + data->callref, + GSM48_CAUSE_LOC_USER, + GSM48_CC_CAUSE_USER_BUSY); + } + } /* Create transaction */ trans = trans_alloc(net, subscr, GSM48_PDISC_CC, 0xff, data->callref); if (!trans) { -- 2.1.4 From max.suraev at fairwaves.co Thu Jul 9 19:02:21 2015 From: max.suraev at fairwaves.co (Max) Date: Thu, 9 Jul 2015 21:02:21 +0200 Subject: [PATCH 1/4] Supplementary Services (de)activation and interrogation Message-ID: <1436468544-20989-1-git-send-email-max.suraev@fairwaves.co> Signed-off-by: Max --- openbsc/include/openbsc/Makefile.am | 2 +- openbsc/include/openbsc/db.h | 4 + openbsc/include/openbsc/gsm_04_80.h | 36 ++++++-- openbsc/include/openbsc/ss.h | 10 +++ openbsc/include/openbsc/ussd.h | 10 --- openbsc/src/libmsc/Makefile.am | 2 +- openbsc/src/libmsc/db.c | 89 +++++++++++++++++++ openbsc/src/libmsc/gsm_04_08.c | 4 +- openbsc/src/libmsc/gsm_04_80.c | 65 ++++++++------ openbsc/src/libmsc/ss.c | 173 ++++++++++++++++++++++++++++++++++++ openbsc/src/libmsc/ussd.c | 87 ------------------ 11 files changed, 349 insertions(+), 133 deletions(-) create mode 100644 openbsc/include/openbsc/ss.h delete mode 100644 openbsc/include/openbsc/ussd.h create mode 100644 openbsc/src/libmsc/ss.c delete mode 100644 openbsc/src/libmsc/ussd.c diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index 254f43d..b19c413 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -2,7 +2,7 @@ noinst_HEADERS = abis_nm.h abis_rsl.h db.h gsm_04_08.h gsm_data.h \ gsm_subscriber.h gsm_04_11.h debug.h signal.h \ misdn.h chan_alloc.h paging.h ctrl.h \ trau_mux.h rs232.h openbscdefines.h rtp_proxy.h \ - bsc_rll.h mncc.h transaction.h ussd.h gsm_04_80.h \ + bsc_rll.h mncc.h transaction.h ss.h gsm_04_80.h \ silent_call.h mgcp.h meas_rep.h rest_octets.h \ system_information.h handover.h mgcp_internal.h \ vty.h socket.h e1_config.h trau_upqueue.h token_auth.h \ diff --git a/openbsc/include/openbsc/db.h b/openbsc/include/openbsc/db.h index 6699a86..73c061b 100644 --- a/openbsc/include/openbsc/db.h +++ b/openbsc/include/openbsc/db.h @@ -79,4 +79,8 @@ int db_store_counter(struct osmo_counter *ctr); struct rate_ctr_group; int db_store_rate_ctr_group(struct rate_ctr_group *ctrg); +/* Supplementary Services */ +int db_ss_interrogate_status(struct gsm_subscriber *subscr, uint8_t ss_code, uint8_t bs_code, uint8_t *ss_status); +int db_ss_set_status(struct gsm_subscriber *subscr, uint8_t ss_code, uint8_t bs_code, uint8_t ss_status); + #endif /* _DB_H */ diff --git a/openbsc/include/openbsc/gsm_04_80.h b/openbsc/include/openbsc/gsm_04_80.h index 0a60652..7139f95 100644 --- a/openbsc/include/openbsc/gsm_04_80.h +++ b/openbsc/include/openbsc/gsm_04_80.h @@ -3,16 +3,42 @@ #include #include +#include #include struct gsm_subscriber_connection; +/* FIXME: replace with libosmocore functions */ +static inline unsigned char *msgb_wrap_with_TL(struct msgb *msgb, uint8_t tag) +{ + uint8_t *data = msgb_push(msgb, 2); + + data[0] = tag; + data[1] = msgb->len - 2; + return data; +} + +static inline unsigned char *msgb_push_TLV1(struct msgb *msgb, uint8_t tag, + uint8_t value) +{ + uint8_t *data = msgb_push(msgb, 3); + + data[0] = tag; + data[1] = 1; + data[2] = value; + return data; +} + int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn, - const struct msgb *in_msg, const char* response_text, - const struct ussd_request *req); -int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn, - const struct msgb *msg, - const struct ussd_request *request); + const char* response_text, + const struct ss_request *req); +int gsm0480_send_ss_return_result(struct gsm_subscriber_connection *conn, + const struct ss_request *req, + struct msgb *msg); +int gsm0480_send_ss_reject(struct gsm_subscriber_connection *conn, + const struct ss_request *request, + uint8_t problem_category, + uint8_t problem_code); int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, int level, const char *text); int gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn); diff --git a/openbsc/include/openbsc/ss.h b/openbsc/include/openbsc/ss.h new file mode 100644 index 0000000..92ce913 --- /dev/null +++ b/openbsc/include/openbsc/ss.h @@ -0,0 +1,10 @@ +#ifndef _SS_H +#define _SS_H + +/* Handler function for mobile-originated SS messages */ + +#include + +int handle_rcv_ss(struct gsm_subscriber_connection *conn, struct msgb *msg); + +#endif diff --git a/openbsc/include/openbsc/ussd.h b/openbsc/include/openbsc/ussd.h deleted file mode 100644 index 2665468..0000000 --- a/openbsc/include/openbsc/ussd.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _USSD_H -#define _USSD_H - -/* Handler function for mobile-originated USSD messages */ - -#include - -int handle_rcv_ussd(struct gsm_subscriber_connection *conn, struct msgb *msg); - -#endif diff --git a/openbsc/src/libmsc/Makefile.am b/openbsc/src/libmsc/Makefile.am index aa7d8ae..de0ce66 100644 --- a/openbsc/src/libmsc/Makefile.am +++ b/openbsc/src/libmsc/Makefile.am @@ -16,7 +16,7 @@ libmsc_a_SOURCES = auth.c \ silent_call.c \ sms_queue.c \ token_auth.c \ - ussd.c \ + ss.c \ vty_interface_layer3.c \ transaction.c \ osmo_msc.c ctrl_commands.c meas_feed.c diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 428f99b..25dd00e 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -41,6 +41,8 @@ /* Semi-Private-Interface (SPI) for the subscriber code */ void subscr_direct_free(struct gsm_subscriber *subscr); +#include + static char *db_basename = NULL; static char *db_dirname = NULL; static dbi_conn conn; @@ -174,6 +176,15 @@ static const char *create_stmts[] = { "sres BLOB NOT NULL, " "kc BLOB NOT NULL " ")", + "CREATE TABLE IF NOT EXISTS SS_Status (" + "id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " + "subscriber INTEGER NOT NULL, " + "ss_code TINYINT UNSIGNED NOT NULL, " + "bs_code TINYINT UNSIGNED, " + "ss_status TINYINT UNSIGNED NOT NULL, " + "UNIQUE(subscriber, ss_code, bs_code), " + "FOREIGN KEY(subscriber) REFERENCES Subscriber (id) ON DELETE CASCADE ON UPDATE CASCADE " + ")", }; void db_error_func(dbi_conn conn, void *data) @@ -1724,3 +1735,81 @@ int db_store_rate_ctr_group(struct rate_ctr_group *ctrg) return 0; } + +int db_ss_interrogate_status(struct gsm_subscriber *subscr, uint8_t ss_code, uint8_t bs_code, uint8_t *ss_status) +{ + char buf[32]; + dbi_result result; + + /* Copy the id to a string as queryf with %llu is failing */ + sprintf(buf, "%llu", subscr->id); + result = dbi_conn_queryf(conn, + "SELECT ss_status FROM SS_Status " + "WHERE subscriber = %s " + "AND ss_code = %i AND bs_code = %i", + buf, ss_code, bs_code); + + if (!result) { + LOGP(DDB, + LOGL_ERROR, + "Failed to query ss_status for subscriber %llu, " + "ss code 0x%02X, bs code 0x%02X\n", + subscr->id, ss_code, bs_code); + return -EIO; + } + if (!dbi_result_next_row(result)) { + DEBUGP(DDB, + "Failed to find ss_status for subscriber %llu, " + "ss code 0x%02X, bs code 0x%02X\n", + subscr->id, ss_code, bs_code); + dbi_result_free(result); + return -ENOENT; + } + + *ss_status = dbi_result_get_uint(result, "ss_status"); + DEBUGP(DDB, + "Found ss_status for subscriber %llu, " + "ss code 0x%02X, bs code 0x%02X: P:%d R:%d A:%d Q:%d\n", + subscr->id, ss_code, bs_code, + (*ss_status & GSM0902_SS_STATUS_P_BIT) && 1, + (*ss_status & GSM0902_SS_STATUS_R_BIT) && 1, + (*ss_status & GSM0902_SS_STATUS_A_BIT) && 1, + (*ss_status & GSM0902_SS_STATUS_Q_BIT) && 1); + + dbi_result_free(result); + return 0; +} + +int db_ss_set_status(struct gsm_subscriber *subscr, uint8_t ss_code, uint8_t bs_code, uint8_t ss_status) +{ + char buf[32]; + dbi_result result; + + /* Copy the id to a string as queryf with %llu is failing */ + sprintf(buf, "%llu", subscr->id); + + result = dbi_conn_queryf(conn, + "UPDATE SS_Status SET ss_status = %i " + "WHERE subscriber = %s AND " + "ss_code = %i AND bs_code = %i", + ss_status, buf, ss_code, bs_code); + + if (!result) { + LOGP(DDB, LOGL_ERROR, + "Failed to set ss_status for subscriber %llu\n", + subscr->id); + return -EIO; + } + + DEBUGP(DDB, + "Set ss_status for subscriber %llu, " + "ss code 0x%02X, bs code 0x%02X: P:%d R:%d A:%d Q:%d\n", + subscr->id, ss_code, bs_code, + (ss_status & GSM0902_SS_STATUS_P_BIT) && 1, + (ss_status & GSM0902_SS_STATUS_R_BIT) && 1, + (ss_status & GSM0902_SS_STATUS_A_BIT) && 1, + (ss_status & GSM0902_SS_STATUS_Q_BIT) && 1); + + dbi_result_free(result); + return 0; +} diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 29ab2ba..01f8f32 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include #include @@ -3340,7 +3340,7 @@ int gsm0408_dispatch(struct gsm_subscriber_connection *conn, struct msgb *msg) break; case GSM48_PDISC_NC_SS: release_anchor(conn); - rc = handle_rcv_ussd(conn, msg); + rc = handle_rcv_ss(conn, msg); break; default: LOGP(DRLL, LOGL_NOTICE, "Unknown " diff --git a/openbsc/src/libmsc/gsm_04_80.c b/openbsc/src/libmsc/gsm_04_80.c index b30f9ee..b20521a 100644 --- a/openbsc/src/libmsc/gsm_04_80.c +++ b/openbsc/src/libmsc/gsm_04_80.c @@ -39,31 +39,11 @@ #include #include -static inline unsigned char *msgb_wrap_with_TL(struct msgb *msgb, uint8_t tag) -{ - uint8_t *data = msgb_push(msgb, 2); - - data[0] = tag; - data[1] = msgb->len - 2; - return data; -} - -static inline unsigned char *msgb_push_TLV1(struct msgb *msgb, uint8_t tag, - uint8_t value) -{ - uint8_t *data = msgb_push(msgb, 3); - - data[0] = tag; - data[1] = 1; - data[2] = value; - return data; -} - /* Send response to a mobile-originated ProcessUnstructuredSS-Request */ int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn, - const struct msgb *in_msg, const char *response_text, - const struct ussd_request *req) + const char *response_text, + const struct ss_request *req) { struct msgb *msg = gsm48_msgb_alloc(); struct gsm48_hdr *gh; @@ -109,16 +89,47 @@ int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn, return gsm0808_submit_dtap(conn, msg, 0, 0); } -int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn, - const struct msgb *in_msg, - const struct ussd_request *req) +/* Send response to a mobile-originated Invoke */ +int gsm0480_send_ss_return_result(struct gsm_subscriber_connection *conn, + const struct ss_request *req, + struct msgb *msg) +{ + struct gsm48_hdr *gh; + + /* Pre-pend the operation code */ + msgb_push_TLV1(msg, GSM0480_OPERATION_CODE, req->opcode); + + /* Wrap the contents as a sequence */ + msgb_wrap_with_TL(msg, GSM_0480_SEQUENCE_TAG); + + /* Pre-pend the invoke ID */ + msgb_push_TLV1(msg, GSM0480_COMPIDTAG_INVOKE_ID, req->invoke_id); + + /* Wrap this up as a Return Result component */ + msgb_wrap_with_TL(msg, GSM0480_CTYPE_RETURN_RESULT); + + /* Wrap the component in a Facility message */ + msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY); + + /* And finally pre-pend the L3 header */ + gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh)); + gh->proto_discr = GSM48_PDISC_NC_SS | req->transaction_id + | (1<<7); /* TI direction = 1 */ + gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE; + + return gsm0808_submit_dtap(conn, msg, 0, 0); +} + +int gsm0480_send_ss_reject(struct gsm_subscriber_connection *conn, + const struct ss_request *req, + uint8_t problem_category, + uint8_t problem_code) { struct msgb *msg = gsm48_msgb_alloc(); struct gsm48_hdr *gh; /* First insert the problem code */ - msgb_push_TLV1(msg, GSM_0480_PROBLEM_CODE_TAG_GENERAL, - GSM_0480_GEN_PROB_CODE_UNRECOGNISED); + msgb_push_TLV1(msg, problem_category, problem_code); /* Before it insert the invoke ID */ msgb_push_TLV1(msg, GSM0480_COMPIDTAG_INVOKE_ID, req->invoke_id); diff --git a/openbsc/src/libmsc/ss.c b/openbsc/src/libmsc/ss.c new file mode 100644 index 0000000..44a01ec --- /dev/null +++ b/openbsc/src/libmsc/ss.c @@ -0,0 +1,173 @@ +/* Network-specific handling of mobile-originated SSs. */ + +/* (C) 2008-2009 by Harald Welte + * (C) 2008, 2009 by Holger Hans Peter Freyther + * (C) 2009 by Mike Haben + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +/* This module defines the network-specific handling of mobile-originated + SS messages. */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +/* Declarations of USSD strings to be recognised */ +const char USSD_TEXT_OWN_NUMBER[] = "*#100#"; + +/* Forward declarations of network-specific handler functions */ +static int send_own_number(struct gsm_subscriber_connection *conn, const struct msgb *msg, const struct ss_request *req); +static int change_ss_activation(struct gsm_subscriber_connection *conn, uint8_t activate, const struct ss_request *req); +static int interrogate_ss(struct gsm_subscriber_connection *conn, const struct ss_request *req); + +/* Entrypoint - handler function common to all mobile-originated SS */ +int handle_rcv_ss(struct gsm_subscriber_connection *conn, struct msgb *msg) +{ + int rc; + struct ss_request req; + struct gsm48_hdr *gh; + uint8_t activate; + + memset(&req, 0, sizeof(req)); + gh = msgb_l3(msg); + rc = gsm0480_decode_ss_request(gh, msgb_l3len(msg), &req); + + if (rc == 1) { + + switch (req.opcode) { + case GSM0480_OP_CODE_PROCESS_USS_REQ: + + if (req.ussd_text[0] == 0xFF) /* Release-Complete */ + return 0; + + if (!strcmp(USSD_TEXT_OWN_NUMBER, + (const char *)req.ussd_text)) { + DEBUGP(DMM, "USSD: Own number requested\n"); + rc = send_own_number(conn, msg, &req); + } else { + DEBUGP(DMM, "Unhandled USSD %s\n", req.ussd_text); + rc = gsm0480_send_ss_reject(conn, &req, + GSM_0480_PROBLEM_CODE_TAG_INVOKE, + GSM_0480_INVOKE_PROB_CODE_UNRECOGNISED_OPERATION); + } + + break; + + case GSM0480_OP_CODE_ACTIVATE_SS: + case GSM0480_OP_CODE_DEACTIVATE_SS: + activate = (req.opcode == GSM0480_OP_CODE_ACTIVATE_SS); + rc = change_ss_activation(conn, activate, &req); + break; + case GSM0480_OP_CODE_INTERROGATE_SS: + rc = interrogate_ss(conn, &req); + break; + default: + DEBUGP(DMM, "Unhandled SS opcode %d\n", req.opcode); + rc = gsm0480_send_ss_reject(conn, &req, + GSM_0480_PROBLEM_CODE_TAG_GENERAL, + GSM_0480_GEN_PROB_CODE_UNRECOGNISED); + break; + } + + } else { + rc = gsm0480_send_ss_reject(conn, &req, + GSM_0480_PROBLEM_CODE_TAG_GENERAL, + GSM_0480_GEN_PROB_CODE_BAD_STRUCTURE); + } + + /* check if we can release it */ + msc_release_connection(conn); + return rc; +} + +/* A network-specific handler function */ +static int send_own_number(struct gsm_subscriber_connection *conn, const struct msgb *msg, const struct ss_request *req) +{ + char *own_number = conn->subscr->extension; + char response_string[GSM_EXTENSION_LENGTH + 20]; + + /* Need trailing CR as EOT character */ + snprintf(response_string, sizeof(response_string), "Your extension is %s\r", own_number); + return gsm0480_send_ussd_response(conn, response_string, req); +} + +static int change_ss_activation(struct gsm_subscriber_connection *conn, uint8_t activate, const struct ss_request *req) +{ + struct msgb *msg; + uint8_t ss_status; + int rc = db_ss_interrogate_status(conn->subscr, + req->ss_code, + GSM0902_TS_CODE_TELEPHONY, + &ss_status); + + if(rc < 0 || !(ss_status & GSM0902_SS_STATUS_P_BIT)) { + DEBUGP(DMM, "SS 0x%02X not provisioned\n", req->ss_code); + return gsm0480_send_ss_reject(conn, req, + GSM_0480_PROBLEM_CODE_TAG_INVOKE, + GSM_0480_INVOKE_PROB_CODE_UNRECOGNISED_OPERATION); + } + + ss_status &= ~GSM0902_SS_STATUS_A_BIT; + ss_status |= (activate ? GSM0902_SS_STATUS_A_BIT : 0); + + rc = db_ss_set_status(conn->subscr, req->ss_code, + GSM0902_TS_CODE_TELEPHONY, ss_status); + if(rc < 0) + return gsm0480_send_ss_reject(conn, req, + GSM_0480_PROBLEM_CODE_TAG_INVOKE, + GSM_0480_INVOKE_PROB_CODE_RESOURCE_LIMITATION); + + msg = gsm48_msgb_alloc(); + /* First put the payload into the message */ + msgb_push_TLV1(msg, GSM0902_SS_DATA_SS_STATUS_TAG, ss_status); + /* Then wrap it as a Sequence of type SS-Data */ + msgb_wrap_with_TL(msg, GSM0902_SS_INFO_SS_DATA_TAG); + + return gsm0480_send_ss_return_result(conn, req, msg); +} + +static int interrogate_ss(struct gsm_subscriber_connection *conn, const struct ss_request *req) +{ + struct msgb *msg; + uint8_t ss_status; + int rc = db_ss_interrogate_status(conn->subscr, + req->ss_code, + GSM0902_TS_CODE_TELEPHONY, + &ss_status); + + if(rc < 0 || !(ss_status & GSM0902_SS_STATUS_P_BIT)) { + DEBUGP(DMM, "SS 0x%02X not provisioned\n", req->ss_code); + return gsm0480_send_ss_reject(conn, req, + GSM_0480_PROBLEM_CODE_TAG_INVOKE, + GSM_0480_INVOKE_PROB_CODE_UNRECOGNISED_OPERATION); + } + + msg = gsm48_msgb_alloc(); + /* Put the payload into the message */ + msgb_push_TLV1(msg, GSM0902_SS_INTERR_SS_RES_SS_STATUS_TAG, ss_status); + + return gsm0480_send_ss_return_result(conn, req, msg); +} diff --git a/openbsc/src/libmsc/ussd.c b/openbsc/src/libmsc/ussd.c deleted file mode 100644 index 7f01eae..0000000 --- a/openbsc/src/libmsc/ussd.c +++ /dev/null @@ -1,87 +0,0 @@ -/* Network-specific handling of mobile-originated USSDs. */ - -/* (C) 2008-2009 by Harald Welte - * (C) 2008, 2009 by Holger Hans Peter Freyther - * (C) 2009 by Mike Haben - * - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation; either version 3 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -/* This module defines the network-specific handling of mobile-originated - USSD messages. */ - -#include -#include -#include -#include - -#include -#include -#include -#include - -/* Declarations of USSD strings to be recognised */ -const char USSD_TEXT_OWN_NUMBER[] = "*#100#"; - -/* Forward declarations of network-specific handler functions */ -static int send_own_number(struct gsm_subscriber_connection *conn, const struct msgb *msg, const struct ussd_request *req); - - -/* Entrypoint - handler function common to all mobile-originated USSDs */ -int handle_rcv_ussd(struct gsm_subscriber_connection *conn, struct msgb *msg) -{ - int rc; - struct ussd_request req; - struct gsm48_hdr *gh; - - memset(&req, 0, sizeof(req)); - gh = msgb_l3(msg); - rc = gsm0480_decode_ussd_request(gh, msgb_l3len(msg), &req); - if (!rc) { - DEBUGP(DMM, "Unhandled SS\n"); - rc = gsm0480_send_ussd_reject(conn, msg, &req); - msc_release_connection(conn); - return rc; - } - - /* Release-Complete */ - if (req.text[0] == '\0') - return 0; - - if (!strcmp(USSD_TEXT_OWN_NUMBER, (const char *)req.text)) { - DEBUGP(DMM, "USSD: Own number requested\n"); - rc = send_own_number(conn, msg, &req); - } else { - DEBUGP(DMM, "Unhandled USSD %s\n", req.text); - rc = gsm0480_send_ussd_reject(conn, msg, &req); - } - - /* check if we can release it */ - msc_release_connection(conn); - return rc; -} - -/* A network-specific handler function */ -static int send_own_number(struct gsm_subscriber_connection *conn, const struct msgb *msg, const struct ussd_request *req) -{ - char *own_number = conn->subscr->extension; - char response_string[GSM_EXTENSION_LENGTH + 20]; - - /* Need trailing CR as EOT character */ - snprintf(response_string, sizeof(response_string), "Your extension is %s\r", own_number); - return gsm0480_send_ussd_response(conn, msg, response_string, req); -} -- 2.1.4 From max.suraev at fairwaves.co Thu Jul 9 19:02:24 2015 From: max.suraev at fairwaves.co (Max) Date: Thu, 9 Jul 2015 21:02:24 +0200 Subject: [PATCH 4/4] SS: Return Error instead of Reject for unprovisioned service In-Reply-To: <1436468544-20989-1-git-send-email-max.suraev@fairwaves.co> References: <1436468544-20989-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <1436468544-20989-4-git-send-email-max.suraev@fairwaves.co> Signed-off-by: Max --- openbsc/src/libmsc/ss.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openbsc/src/libmsc/ss.c b/openbsc/src/libmsc/ss.c index 44a01ec..4eabe1a 100644 --- a/openbsc/src/libmsc/ss.c +++ b/openbsc/src/libmsc/ss.c @@ -125,9 +125,9 @@ static int change_ss_activation(struct gsm_subscriber_connection *conn, uint8_t if(rc < 0 || !(ss_status & GSM0902_SS_STATUS_P_BIT)) { DEBUGP(DMM, "SS 0x%02X not provisioned\n", req->ss_code); - return gsm0480_send_ss_reject(conn, req, - GSM_0480_PROBLEM_CODE_TAG_INVOKE, - GSM_0480_INVOKE_PROB_CODE_UNRECOGNISED_OPERATION); + return gsm0480_send_ss_return_error(conn, req, + GSM0480_ERR_CODE_SS_SUBSCRIPTION_VIOLATION, + NULL); } ss_status &= ~GSM0902_SS_STATUS_A_BIT; @@ -160,9 +160,9 @@ static int interrogate_ss(struct gsm_subscriber_connection *conn, const struct s if(rc < 0 || !(ss_status & GSM0902_SS_STATUS_P_BIT)) { DEBUGP(DMM, "SS 0x%02X not provisioned\n", req->ss_code); - return gsm0480_send_ss_reject(conn, req, - GSM_0480_PROBLEM_CODE_TAG_INVOKE, - GSM_0480_INVOKE_PROB_CODE_UNRECOGNISED_OPERATION); + return gsm0480_send_ss_return_error(conn, req, + GSM0480_ERR_CODE_SS_SUBSCRIPTION_VIOLATION, + NULL); } msg = gsm48_msgb_alloc(); -- 2.1.4 From holger at freyther.de Mon Jul 13 09:37:00 2015 From: holger at freyther.de (Holger Freyther) Date: Mon, 13 Jul 2015 11:37:00 +0200 Subject: [PATCH 1/1] openbsc: Rename core_ncc to core_mnc In-Reply-To: References: Message-ID: <59A10A31-FA20-42EF-A108-23B2937536BA@freyther.de> > On 02 Jun 2015, at 15:48, Mike McTernan (wavemobile) wrote: Dear Mike, > > Hi Folks, > > Struct osmo_msc_data contains int core_ncc, which is actually the MNC part of the PLMN, not to be confused with the Network Colour Code. > > The following patch renames this field for clarity and consistency with the standards. Please consider it for inclusion. applied. thank you From holger at freyther.de Tue Jul 14 11:32:33 2015 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 14 Jul 2015 13:32:33 +0200 Subject: [PATCH 1/2] nitb: Be less strict about the reject cause Message-ID: <1436873554-12616-1-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther When we can't find the TMSI then the subscriber is not in our VLR. We have not consulted with the HLR and it is better to not use such a severe error code. --- openbsc/src/libmsc/gsm_04_08.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 29ab2ba..e380d94 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -968,7 +968,7 @@ static int gsm48_rx_mm_serv_req(struct gsm_subscriber_connection *conn, struct m /* FIXME: if we don't know the TMSI, inquire abit IMSI and allocate new TMSI */ if (!subscr) return gsm48_tx_mm_serv_rej(conn, - GSM48_REJECT_IMSI_UNKNOWN_IN_HLR); + GSM48_REJECT_IMSI_UNKNOWN_IN_VLR); if (!conn->subscr) conn->subscr = subscr; -- 2.3.5 From holger at freyther.de Tue Jul 14 11:32:34 2015 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 14 Jul 2015 13:32:34 +0200 Subject: [PATCH 2/2] nitb: Add a mode to not use TMSI for normal operation In-Reply-To: <1436873554-12616-1-git-send-email-holger@freyther.de> References: <1436873554-12616-1-git-send-email-holger@freyther.de> Message-ID: <1436873554-12616-2-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther In case foreign simcards are used we can not do authentication and ciphering. In case a TMSI is re-used too early and we do page using TMSI we can't know which of the two MS is responding to us. We could change the "secure channel" routine to ask for the IMSI and only then stop the paging. As we don't have ciphering there is not much use in using the TMSI. Add a mode "no assign-tmsi" that will not assign the TMSI during LU. Now CM Service Request and Paging Response will work using the IMSI. There can't be a clash with that. --- openbsc/include/openbsc/gsm_data.h | 3 + openbsc/src/libmsc/gsm_04_08.c | 94 +++++++++++++++++++++---------- openbsc/src/libmsc/vty_interface_layer3.c | 22 ++++++++ 3 files changed, 88 insertions(+), 31 deletions(-) diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 6f7c8dd..90f3c80 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -281,6 +281,9 @@ struct gsm_network { struct gsm_subscriber_group *subscr_group; struct gsm_sms_queue *sms_queue; + /* nitb related control */ + int avoid_tmsi; + /* control interface */ struct ctrl_handle *ctrl; }; diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index e380d94..02ffe58 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -67,7 +67,7 @@ void *tall_locop_ctx; void *tall_authciphop_ctx; -int gsm0408_loc_upd_acc(struct gsm_subscriber_connection *conn, uint32_t tmsi); +static int gsm0408_loc_upd_acc(struct gsm_subscriber_connection *conn); static int gsm48_tx_simple(struct gsm_subscriber_connection *conn, uint8_t pdisc, uint8_t msg_type); static void schedule_reject(struct gsm_subscriber_connection *conn); @@ -294,6 +294,42 @@ static void allocate_loc_updating_req(struct gsm_subscriber_connection *conn) struct gsm_loc_updating_operation); } +static int finish_lu(struct gsm_subscriber_connection *conn) +{ + int rc = 0; + int avoid_tmsi = conn->bts->network->avoid_tmsi; + + /* We're all good */ + if (avoid_tmsi) { + conn->subscr->tmsi = GSM_RESERVED_TMSI; + db_sync_subscriber(conn->subscr); + } else { + db_subscriber_alloc_tmsi(conn->subscr); + } + + rc = gsm0408_loc_upd_acc(conn); + if (conn->bts->network->send_mm_info) { + /* send MM INFO with network name */ + rc = gsm48_tx_mm_info(conn); + } + + /* call subscr_update after putting the loc_upd_acc + * in the transmit queue, since S_SUBSCR_ATTACHED might + * trigger further action like SMS delivery */ + subscr_update(conn->subscr, conn->bts, + GSM_SUBSCRIBER_UPDATE_ATTACHED); + + /* + * The gsm0408_loc_upd_acc sends a MI with the TMSI. The + * MS needs to respond with a TMSI REALLOCATION COMPLETE + * (even if the TMSI is the same). + */ + if (avoid_tmsi) + release_loc_updating_req(conn, 1); + + return rc; +} + static int _gsm0408_authorize_sec_cb(unsigned int hooknum, unsigned int event, struct msgb *msg, void *data, void *param) { @@ -312,25 +348,7 @@ static int _gsm0408_authorize_sec_cb(unsigned int hooknum, unsigned int event, case GSM_SECURITY_NOAVAIL: case GSM_SECURITY_SUCCEEDED: - /* We're all good */ - db_subscriber_alloc_tmsi(conn->subscr); - rc = gsm0408_loc_upd_acc(conn, conn->subscr->tmsi); - if (conn->bts->network->send_mm_info) { - /* send MM INFO with network name */ - rc = gsm48_tx_mm_info(conn); - } - - /* call subscr_update after putting the loc_upd_acc - * in the transmit queue, since S_SUBSCR_ATTACHED might - * trigger further action like SMS delivery */ - subscr_update(conn->subscr, conn->bts, - GSM_SUBSCRIBER_UPDATE_ATTACHED); - - /* - * The gsm0408_loc_upd_acc sends a MI with the TMSI. The - * MS needs to respond with a TMSI REALLOCATION COMPLETE - * (even if the TMSI is the same). - */ + rc = finish_lu(conn); break; default: @@ -434,7 +452,7 @@ int gsm0408_loc_upd_rej(struct gsm_subscriber_connection *conn, uint8_t cause) } /* Chapter 9.2.13 : Send LOCATION UPDATE ACCEPT */ -int gsm0408_loc_upd_acc(struct gsm_subscriber_connection *conn, uint32_t tmsi) +static int gsm0408_loc_upd_acc(struct gsm_subscriber_connection *conn) { struct gsm_bts *bts = conn->bts; struct msgb *msg = gsm48_msgb_alloc(); @@ -452,8 +470,16 @@ int gsm0408_loc_upd_acc(struct gsm_subscriber_connection *conn, uint32_t tmsi) gsm48_generate_lai(lai, bts->network->country_code, bts->network->network_code, bts->location_area_code); - mid = msgb_put(msg, GSM48_MID_TMSI_LEN); - gsm48_generate_mid_from_tmsi(mid, tmsi); + if (conn->subscr->tmsi == GSM_RESERVED_TMSI) { + uint8_t mi[10]; + int len; + len = gsm48_generate_mid_from_imsi(mi, conn->subscr->imsi); + mid = msgb_put(msg, len); + memcpy(mid, mi, len); + } else { + mid = msgb_put(msg, GSM48_MID_TMSI_LEN); + gsm48_generate_mid_from_tmsi(mid, conn->subscr->tmsi); + } DEBUGP(DMM, "-> LOCATION UPDATE ACCEPT\n"); @@ -946,24 +972,30 @@ static int gsm48_rx_mm_serv_req(struct gsm_subscriber_connection *conn, struct m GSM48_REJECT_INCORRECT_MESSAGE); } + gsm48_mi_to_string(mi_string, sizeof(mi_string), mi, mi_len); mi_type = mi[0] & GSM_MI_TYPE_MASK; - if (mi_type != GSM_MI_TYPE_TMSI) { - DEBUGPC(DMM, "mi_type is not TMSI: %d\n", mi_type); + + if (mi_type == GSM_MI_TYPE_IMSI) { + DEBUGPC(DMM, "serv_type=0x%02x mi_type=0x%02x M(%s)\n", + req->cm_service_type, mi_type, mi_string); + subscr = subscr_get_by_imsi(bts->network->subscr_group, + mi_string); + } else if (mi_type == GSM_MI_TYPE_TMSI) { + DEBUGPC(DMM, "serv_type=0x%02x mi_type=0x%02x M(%s)\n", + req->cm_service_type, mi_type, mi_string); + subscr = subscr_get_by_tmsi(bts->network->subscr_group, + tmsi_from_string(mi_string)); + } else { + DEBUGPC(DMM, "mi_type is not expected: %d\n", mi_type); return gsm48_tx_mm_serv_rej(conn, GSM48_REJECT_INCORRECT_MESSAGE); } - gsm48_mi_to_string(mi_string, sizeof(mi_string), mi, mi_len); - DEBUGPC(DMM, "serv_type=0x%02x mi_type=0x%02x M(%s)\n", - req->cm_service_type, mi_type, mi_string); - osmo_signal_dispatch(SS_SUBSCR, S_SUBSCR_IDENTITY, (classmark2 + classmark2_len)); if (is_siemens_bts(bts)) send_siemens_mrpci(msg->lchan, classmark2-1); - subscr = subscr_get_by_tmsi(bts->network->subscr_group, - tmsi_from_string(mi_string)); /* FIXME: if we don't know the TMSI, inquire abit IMSI and allocate new TMSI */ if (!subscr) diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index 6cf51a3..3c33ffc 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -1037,12 +1037,32 @@ DEFUN(cfg_nitb_no_subscr_create, cfg_nitb_no_subscr_create_cmd, return CMD_SUCCESS; } +DEFUN(cfg_nitb_assign_tmsi, cfg_nitb_assign_tmsi_cmd, + "assign-tmsi", + "Assign TMSI during Location Updating.\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + gsmnet->avoid_tmsi = 0; + return CMD_SUCCESS; +} + +DEFUN(cfg_nitb_no_assign_tmsi, cfg_nitb_no_assign_tmsi_cmd, + "no assign-tmsi", + NO_STR "Assign TMSI during Location Updating.\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + gsmnet->avoid_tmsi = 1; + return CMD_SUCCESS; +} + static int config_write_nitb(struct vty *vty) { struct gsm_network *gsmnet = gsmnet_from_vty(vty); vty_out(vty, "nitb%s", VTY_NEWLINE); vty_out(vty, " %ssubscriber-create-on-demand%s", gsmnet->create_subscriber ? "" : "no ", VTY_NEWLINE); + vty_out(vty, " %suse-tmsi%s", + gsmnet->avoid_tmsi ? "no" : "", VTY_NEWLINE); return CMD_SUCCESS; } @@ -1096,6 +1116,8 @@ int bsc_vty_init_extra(void) install_node(&nitb_node, config_write_nitb); install_element(NITB_NODE, &cfg_nitb_subscr_create_cmd); install_element(NITB_NODE, &cfg_nitb_no_subscr_create_cmd); + install_element(NITB_NODE, &cfg_nitb_assign_tmsi_cmd); + install_element(NITB_NODE, &cfg_nitb_no_assign_tmsi_cmd); return 0; } -- 2.3.5 From pablo at gnumonks.org Tue Jul 21 14:23:15 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:15 +0200 Subject: [PATCH libosmo-netif 00/18] add dummy padding support Message-ID: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso The following patchset, although it looks a bit large, it is composed of many small incremental changes to improve the existing osmux infrastructure and to add dummy padding support. The dummy padding consists of a osmux header and payload that looks like this: OSMUX seq=000 ccid=002 ft=2 ctr=3 amr_f=0 amr_q=0 amr_ft=03 amr_cmr=00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ] The frame type is OSMUX_FT_DUMMY (=2) in the batch that whose payload is padded with 0xff. Note that the message above is padding the circuit ID 2. This is used for early bandwidth preallocation in links that involve relatively slow dynamic bandwidth allocation such as Iridium/OpenPort. The osmux test infrastructure has been improved (to resolve some memleaks) and enhanced to cover this new dummy support. The OpenBSC changeset is composed of one very small patch that will come after this batch. If no major concerns, I'll push this initial batch soon into the repository. Thanks. Pablo Neira Ayuso (18): osmux: discard non voice osmux message osmux: add osmux_input_state structure osmux: add circuit helper functions osmux: rename struct batch_list_node to osmux_circuit osmux: rename circuit->list to circuit->rtp_list osmux: pass up struct osmux_batch osmux: count pending messages to be transformed in the batch osmux: introduce osmux_xfrm_input_close_circuit() osmux: introduce osmux_xfrm_input_open_circuit() tests: osmux: adapt it to use the new circuit API tests: osmux: factor out main test loop tests: osmux: test online deactivation of dummy padding tests: osmux: validate dummy padding with no voice data interaction tests: osmux: test circuit reopening after closure osmux: kill osmux_get_hdr() tests: osmux: fix msgb leaks tests: compile tests with debugging symbols, ie. -g tests: osmux: iterate 64 times in osmo_test_loop() include/osmocom/netif/osmux.h | 8 +- src/osmux.c | 374 ++++++++++++++++++++++++++--------------- tests/Makefile.am | 2 +- tests/osmux/osmux_test.c | 80 ++++++--- 4 files changed, 304 insertions(+), 160 deletions(-) -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:17 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:17 +0200 Subject: [PATCH libosmo-netif 02/18] osmux: add osmux_input_state structure In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-3-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso This new structure serves as container of the internal osmux state during transformation from RTP AMR to the compressed osmux format. This reduces the footprint of several functions and it makes them easier to extend if we need to pass new information between functions. --- src/osmux.c | 77 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/src/osmux.c b/src/osmux.c index a3eccaa..938b9a6 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -221,63 +221,65 @@ static void osmux_batch_dequeue(struct msgb *msg, struct batch_list_node *node) node->nmsgs--; } -static int -osmux_batch_put(struct osmux_in_handle *h, struct msgb *out_msg, - struct msgb *msg, struct rtp_hdr *rtph, - struct amr_hdr *amrh, uint32_t amr_payload_len, - int ccid, int add_osmux_header) +struct osmux_input_state { + struct msgb *out_msg; + struct msgb *msg; + struct rtp_hdr *rtph; + struct amr_hdr *amrh; + uint32_t amr_payload_len; + int ccid; + int add_osmux_hdr; +}; + +static int osmux_batch_put(struct osmux_in_handle *h, + struct osmux_input_state *state) { struct osmux_batch *batch = (struct osmux_batch *)h->internal_data; struct osmux_hdr *osmuxh; - if (add_osmux_header) { - osmuxh = (struct osmux_hdr *)out_msg->tail; + if (state->add_osmux_hdr) { + osmuxh = (struct osmux_hdr *)state->out_msg->tail; osmuxh->ft = OSMUX_FT_VOICE_AMR; osmuxh->ctr = 0; - osmuxh->amr_f = amrh->f; - osmuxh->amr_q= amrh->q; + osmuxh->amr_f = state->amrh->f; + osmuxh->amr_q= state->amrh->q; osmuxh->seq = batch->seq++; - osmuxh->circuit_id = ccid; - osmuxh->amr_cmr = amrh->cmr; - osmuxh->amr_ft = amrh->ft; - msgb_put(out_msg, sizeof(struct osmux_hdr)); + osmuxh->circuit_id = state->ccid; + osmuxh->amr_cmr = state->amrh->cmr; + osmuxh->amr_ft = state->amrh->ft; + msgb_put(state->out_msg, sizeof(struct osmux_hdr)); /* annotate current osmux header */ batch->osmuxh = osmuxh; } else { if (batch->osmuxh->ctr == 0x7) { LOGP(DLMIB, LOGL_ERROR, "cannot add msg=%p, " - "too many messages for this RTP ssrc=%u\n", - msg, rtph->ssrc); + "too many messages for this RTP ssrc=%u\n", + state->msg, state->rtph->ssrc); return 0; } batch->osmuxh->ctr++; } - memcpy(out_msg->tail, osmo_amr_get_payload(amrh), amr_payload_len); - msgb_put(out_msg, amr_payload_len); + memcpy(state->out_msg->tail, osmo_amr_get_payload(state->amrh), + state->amr_payload_len); + msgb_put(state->out_msg, state->amr_payload_len); return 0; } -static int -osmux_xfrm_encode_amr(struct osmux_in_handle *h, - struct msgb *out_msg, - struct rtp_hdr *rtph, struct msgb *msg, - int ccid, int add_osmux_header) +static int osmux_xfrm_encode_amr(struct osmux_in_handle *h, + struct osmux_input_state *state) { - struct amr_hdr *amrh; uint32_t amr_len; - uint32_t amr_payload_len; - amrh = osmo_rtp_get_payload(rtph, msg, &amr_len); - if (amrh == NULL) + state->amrh = osmo_rtp_get_payload(state->rtph, state->msg, &amr_len); + if (state->amrh == NULL) return -1; - amr_payload_len = amr_len - sizeof(struct amr_hdr); + state->amr_payload_len = amr_len - sizeof(struct amr_hdr); - if (osmux_batch_put(h, out_msg, msg, rtph, amrh, amr_payload_len, - ccid, add_osmux_header) < 0) + if (osmux_batch_put(h, state) < 0) return -1; return 0; @@ -304,9 +306,11 @@ static struct msgb *osmux_build_batch(struct osmux_in_handle *h) int ctr = 0; llist_for_each_entry_safe(cur, tmp, &node->list, list) { - struct rtp_hdr *rtph; - int add_osmux_hdr = 0; - + struct osmux_input_state state = { + .msg = cur, + .out_msg = batch_msg, + .ccid = node->ccid, + }; #ifdef DEBUG_MSG char buf[4096]; @@ -315,19 +319,18 @@ static struct msgb *osmux_build_batch(struct osmux_in_handle *h) LOGP(DLMIB, LOGL_DEBUG, "to BSC-NAT: %s\n", buf); #endif - rtph = osmo_rtp_get_hdr(cur); - if (rtph == NULL) + state.rtph = osmo_rtp_get_hdr(cur); + if (state.rtph == NULL) return NULL; if (ctr == 0) { #ifdef DEBUG_MSG LOGP(DLMIB, LOGL_DEBUG, "add osmux header\n"); #endif - add_osmux_hdr = 1; + state.add_osmux_hdr = 1; } - osmux_xfrm_encode_amr(h, batch_msg, rtph, cur, - node->ccid, add_osmux_hdr); + osmux_xfrm_encode_amr(h, &state); osmux_batch_dequeue(cur, node); msgb_free(cur); ctr++; -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:21 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:21 +0200 Subject: [PATCH libosmo-netif 06/18] osmux: pass up struct osmux_batch In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-7-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Instead of struct osmux_in_handle. This object contains the internal batching state information. --- src/osmux.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/osmux.c b/src/osmux.c index 187ca1c..bd400f6 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -231,10 +231,9 @@ struct osmux_input_state { int add_osmux_hdr; }; -static int osmux_batch_put(struct osmux_in_handle *h, +static int osmux_batch_put(struct osmux_batch *batch, struct osmux_input_state *state) { - struct osmux_batch *batch = (struct osmux_batch *)h->internal_data; struct osmux_hdr *osmuxh; if (state->add_osmux_hdr) { @@ -268,7 +267,7 @@ static int osmux_batch_put(struct osmux_in_handle *h, return 0; } -static int osmux_xfrm_encode_amr(struct osmux_in_handle *h, +static int osmux_xfrm_encode_amr(struct osmux_batch *batch, struct osmux_input_state *state) { uint32_t amr_len; @@ -279,23 +278,23 @@ static int osmux_xfrm_encode_amr(struct osmux_in_handle *h, state->amr_payload_len = amr_len - sizeof(struct amr_hdr); - if (osmux_batch_put(h, state) < 0) + if (osmux_batch_put(batch, state) < 0) return -1; return 0; } -static struct msgb *osmux_build_batch(struct osmux_in_handle *h) +static struct msgb *osmux_build_batch(struct osmux_batch *batch, + uint32_t batch_size) { struct msgb *batch_msg; struct osmux_circuit *circuit, *next; - struct osmux_batch *batch = (struct osmux_batch *)h->internal_data; #ifdef DEBUG_MSG LOGP(DLMIB, LOGL_DEBUG, "Now building batch\n"); #endif - batch_msg = msgb_alloc(h->batch_size, "osmux"); + batch_msg = msgb_alloc(batch_size, "osmux"); if (batch_msg == NULL) { LOGP(DLMIB, LOGL_ERROR, "Not enough memory\n"); return NULL; @@ -330,7 +329,7 @@ static struct msgb *osmux_build_batch(struct osmux_in_handle *h) state.add_osmux_hdr = 1; } - osmux_xfrm_encode_amr(h, &state); + osmux_xfrm_encode_amr(batch, &state); osmux_batch_dequeue(cur, circuit); msgb_free(cur); ctr++; @@ -349,7 +348,7 @@ void osmux_xfrm_input_deliver(struct osmux_in_handle *h) #ifdef DEBUG_MSG LOGP(DLMIB, LOGL_DEBUG, "invoking delivery function\n"); #endif - batch_msg = osmux_build_batch(h); + batch_msg = osmux_build_batch(batch, h->batch_size); h->stats.output_osmux_msgs++; h->stats.output_osmux_bytes += batch_msg->len; -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:22 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:22 +0200 Subject: [PATCH libosmo-netif 07/18] osmux: count pending messages to be transformed in the batch In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-8-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Add a new field to count the number of messages in the batch that are pending to be transformed to osmux. Use this new field to check when to enable the osmux timer. The follow up patch keeps circuit objects in the batch until they are closed, so we won't be able to rely on this to know when to enable the timer anymore. --- src/osmux.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/osmux.c b/src/osmux.c index bd400f6..82ec56e 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -184,6 +184,7 @@ struct osmux_batch { struct llist_head circuit_list; unsigned int remaining_bytes; uint8_t seq; + uint32_t nmsgs; }; struct osmux_circuit { @@ -333,6 +334,7 @@ static struct msgb *osmux_build_batch(struct osmux_batch *batch, osmux_batch_dequeue(cur, circuit); msgb_free(cur); ctr++; + batch->nmsgs--; } llist_del(&circuit->head); talloc_free(circuit); @@ -486,7 +488,7 @@ osmux_batch_add_circuit(struct osmux_batch *batch, int ccid) } static int -osmux_batch_add(struct osmux_batch *batch, struct msgb *msg, +osmux_batch_add(struct osmux_batch *batch, int batch_factor, struct msgb *msg, struct rtp_hdr *rtph, int ccid) { int bytes = 0, amr_payload_len; @@ -549,6 +551,15 @@ osmux_batch_add(struct osmux_batch *batch, struct msgb *msg, /* Update remaining room in this batch */ batch->remaining_bytes -= bytes; + if (batch->nmsgs == 0) { +#ifdef DEBUG_MSG + LOGP(DLMIB, LOGL_DEBUG, "osmux start timer batch\n"); +#endif + osmo_timer_schedule(&batch->timer, 0, + batch_factor * DELTA_RTP_MSG); + } + batch->nmsgs++; + return 0; } @@ -565,7 +576,7 @@ osmux_batch_add(struct osmux_batch *batch, struct msgb *msg, */ int osmux_xfrm_input(struct osmux_in_handle *h, struct msgb *msg, int ccid) { - int ret, first_rtp_msg; + int ret; struct rtp_hdr *rtph; struct osmux_batch *batch = (struct osmux_batch *)h->internal_data; @@ -593,13 +604,9 @@ int osmux_xfrm_input(struct osmux_in_handle *h, struct msgb *msg, int ccid) * receive AMR traffic. */ - /* This is the first message in the batch, start the - * batch timer to deliver it. - */ - first_rtp_msg = llist_empty(&batch->circuit_list) ? 1 : 0; - /* Add this RTP to the OSMUX batch */ - ret = osmux_batch_add(batch, msg, rtph, ccid); + ret = osmux_batch_add(batch, h->batch_factor, + msg, rtph, ccid); if (ret < 0) { /* Cannot put this message into the batch. * Malformed, duplicated, OOM. Drop it and tell @@ -611,15 +618,6 @@ int osmux_xfrm_input(struct osmux_in_handle *h, struct msgb *msg, int ccid) h->stats.input_rtp_msgs++; h->stats.input_rtp_bytes += msg->len; - - if (first_rtp_msg) { -#ifdef DEBUG_MSG - LOGP(DLMIB, LOGL_DEBUG, - "osmux start timer batch\n"); -#endif - osmo_timer_schedule(&batch->timer, 0, - h->batch_factor * DELTA_RTP_MSG); - } break; } return ret; -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:16 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:16 +0200 Subject: [PATCH libosmo-netif 01/18] osmux: discard non voice osmux message In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-2-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso We only support voice osmux messages by now. Discard unsupported types. --- src/osmux.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/osmux.c b/src/osmux.c index eb2c683..a3eccaa 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -65,6 +65,11 @@ struct osmux_hdr *osmux_xfrm_output_pull(struct msgb *msg) osmuxh = (struct osmux_hdr *)msg->data; + if (osmuxh->ft != OSMUX_FT_VOICE_AMR) { + LOGP(DLMIB, LOGL_ERROR, "Discarding unsupported Osmux FT %d\n", + osmuxh->ft); + return NULL; + } if (!osmo_amr_ft_valid(osmuxh->amr_ft)) { LOGP(DLMIB, LOGL_ERROR, "Discarding bad AMR FT %d\n", osmuxh->amr_ft); -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:18 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:18 +0200 Subject: [PATCH libosmo-netif 03/18] osmux: add circuit helper functions In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-4-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Add osmux_batch_add_circuit() and osmux_batch_find_circuit() helper functions. --- src/osmux.c | 65 ++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/src/osmux.c b/src/osmux.c index 938b9a6..c3e68a3 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -450,19 +450,50 @@ static void osmux_replay_lost_packets(struct batch_list_node *node, } } +static struct batch_list_node * +osmux_batch_find_circuit(struct osmux_batch *batch, int ccid) +{ + struct batch_list_node *circuit; + + llist_for_each_entry(circuit, &batch->node_list, head) { + if (circuit->ccid == ccid) + return circuit; + } + return NULL; +} + +static struct batch_list_node * +osmux_batch_add_circuit(struct osmux_batch *batch, int ccid) +{ + struct batch_list_node *circuit; + + circuit = osmux_batch_find_circuit(batch, ccid); + if (circuit != NULL) { + LOGP(DLMIB, LOGL_ERROR, "circuit %u already exists!\n", ccid); + return NULL; + } + + circuit = talloc_zero(osmux_ctx, struct batch_list_node); + if (circuit == NULL) { + LOGP(DLMIB, LOGL_ERROR, "OOM on circuit %u\n", ccid); + return NULL; + } + + circuit->ccid = ccid; + INIT_LLIST_HEAD(&circuit->list); + llist_add_tail(&circuit->head, &batch->node_list); + + return circuit; +} + static int osmux_batch_add(struct osmux_batch *batch, struct msgb *msg, struct rtp_hdr *rtph, int ccid) { - struct batch_list_node *node; - int found = 0, bytes = 0, amr_payload_len; + int bytes = 0, amr_payload_len; + struct batch_list_node *circuit; - llist_for_each_entry(node, &batch->node_list, head) { - if (node->ccid == ccid) { - found = 1; - break; - } - } + circuit = osmux_batch_find_circuit(batch, ccid); amr_payload_len = osmux_rtp_amr_payload_len(msg, rtph); if (amr_payload_len < 0) @@ -470,21 +501,21 @@ osmux_batch_add(struct osmux_batch *batch, struct msgb *msg, /* First check if there is room for this message in the batch */ bytes += amr_payload_len; - if (!found) + if (!circuit) bytes += sizeof(struct osmux_hdr); /* No room, sorry. You'll have to retry */ if (bytes > batch->remaining_bytes) return 1; - if (found) { + if (circuit) { struct msgb *cur; /* Extra validation: check if this message already exists, * should not happen but make sure we don't propagate * duplicated messages. */ - llist_for_each_entry(cur, &node->list, list) { + llist_for_each_entry(cur, &circuit->list, list) { struct rtp_hdr *rtph2 = osmo_rtp_get_hdr(cur); if (rtph2 == NULL) return -1; @@ -498,21 +529,17 @@ osmux_batch_add(struct osmux_batch *batch, struct msgb *msg, } } /* Handle RTP packet loss scenario */ - osmux_replay_lost_packets(node, rtph); + osmux_replay_lost_packets(circuit, rtph); } else { /* This is the first message with that ssrc we've seen */ - node = talloc_zero(osmux_ctx, struct batch_list_node); - if (node == NULL) + circuit = osmux_batch_add_circuit(batch, ccid); + if (!circuit) return -1; - - node->ccid = ccid; - INIT_LLIST_HEAD(&node->list); - llist_add_tail(&node->head, &batch->node_list); } /* This batch is full, force batch delivery */ - if (osmux_batch_enqueue(msg, node) < 0) + if (osmux_batch_enqueue(msg, circuit) < 0) return 1; #ifdef DEBUG_MSG -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:24 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:24 +0200 Subject: [PATCH libosmo-netif 09/18] osmux: introduce osmux_xfrm_input_open_circuit() In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-10-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso This new function allows you to create a circuit on an existing input handle. We don't create the circuit anymore from the first packet seen, instead the client application is in full control of opening and closing the circuit. This change includes a new feature to pad a circuit until we see the first packet that contains voice data. This is useful to preallocate bandwidth on satellite links such as Iridium/OpenPort. --- include/osmocom/netif/osmux.h | 4 +- src/osmux.c | 133 +++++++++++++++++++++++++++++++---------- 2 files changed, 103 insertions(+), 34 deletions(-) diff --git a/include/osmocom/netif/osmux.h b/include/osmocom/netif/osmux.h index 14c967f..c1f527a 100644 --- a/include/osmocom/netif/osmux.h +++ b/include/osmocom/netif/osmux.h @@ -5,7 +5,7 @@ /* OSmux header: * - * ft (3 bits): 0=signalling, 1=voice + * ft (3 bits): 0=signalling, 1=voice, 2=dummy * ctr (3 bits): Number of batched AMR payloads (starting 0) * amr_f (1 bit): AMR F field (RFC3267) * amr_q (1 bit): AMR Q field (RFC3267) @@ -17,6 +17,7 @@ #define OSMUX_FT_SIGNAL 0 #define OSMUX_FT_VOICE_AMR 1 +#define OSMUX_FT_DUMMY 2 struct osmux_hdr { #if OSMO_IS_BIG_ENDIAN @@ -84,6 +85,7 @@ int osmux_snprintf(char *buf, size_t size, struct msgb *msg); void osmux_xfrm_input_init(struct osmux_in_handle *h); void osmux_xfrm_input_fini(struct osmux_in_handle *h); +int osmux_xfrm_input_open_circuit(struct osmux_in_handle *h, int ccid, int dummy); void osmux_xfrm_input_close_circuit(struct osmux_in_handle *h, int ccid); int osmux_xfrm_input(struct osmux_in_handle *h, struct msgb *msg, int ccid); diff --git a/src/osmux.c b/src/osmux.c index 4451b5a..74883d9 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -56,16 +56,29 @@ static uint32_t osmux_get_payload_len(struct osmux_hdr *osmuxh) return osmo_amr_bytes(osmuxh->amr_ft) * (osmuxh->ctr+1); } -struct osmux_hdr *osmux_xfrm_output_pull(struct msgb *msg) +static uint32_t osmux_ft_dummy_size(uint8_t amr_ft, uint32_t batch_factor) { - struct osmux_hdr *osmuxh = NULL; + return sizeof(struct osmux_hdr) + (osmo_amr_bytes(amr_ft) * batch_factor); +} +struct osmux_hdr *osmux_xfrm_output_pull(struct msgb *msg) +{ + struct osmux_hdr *osmuxh; +next: + osmuxh = NULL; if (msg->len > sizeof(struct osmux_hdr)) { size_t len; osmuxh = (struct osmux_hdr *)msg->data; - if (osmuxh->ft != OSMUX_FT_VOICE_AMR) { + switch (osmuxh->ft) { + case OSMUX_FT_VOICE_AMR: + break; + case OSMUX_FT_DUMMY: + msgb_pull(msg, osmux_ft_dummy_size(osmuxh->amr_ft, + osmuxh->ctr + 1)); + goto next; + default: LOGP(DLMIB, LOGL_ERROR, "Discarding unsupported Osmux FT %d\n", osmuxh->ft); return NULL; @@ -185,6 +198,7 @@ struct osmux_batch { unsigned int remaining_bytes; uint8_t seq; uint32_t nmsgs; + int dummy; }; struct osmux_circuit { @@ -192,6 +206,7 @@ struct osmux_circuit { int ccid; struct llist_head msg_list; int nmsgs; + int dummy; }; static int osmux_batch_enqueue(struct msgb *msg, struct osmux_circuit *circuit) @@ -285,8 +300,31 @@ static int osmux_xfrm_encode_amr(struct osmux_batch *batch, return 0; } +static void osmux_encode_dummy(struct osmux_batch *batch, uint32_t batch_factor, + struct osmux_input_state *state) +{ + struct osmux_hdr *osmuxh; + /* TODO: This should be configurable at some point. */ + uint32_t payload_size = osmux_ft_dummy_size(AMR_FT_3, batch_factor) - + sizeof(struct osmux_hdr); + + osmuxh = (struct osmux_hdr *)state->out_msg->tail; + osmuxh->ft = OSMUX_FT_DUMMY; + osmuxh->ctr = batch_factor - 1; + osmuxh->amr_f = 0; + osmuxh->amr_q= 0; + osmuxh->seq = 0; + osmuxh->circuit_id = state->ccid; + osmuxh->amr_cmr = 0; + osmuxh->amr_ft = AMR_FT_3; + msgb_put(state->out_msg, sizeof(struct osmux_hdr)); + + memset(state->out_msg->tail, 0xff, payload_size); + msgb_put(state->out_msg, payload_size); +} + static struct msgb *osmux_build_batch(struct osmux_batch *batch, - uint32_t batch_size) + uint32_t batch_size, uint32_t batch_factor) { struct msgb *batch_msg; struct osmux_circuit *circuit; @@ -305,6 +343,15 @@ static struct msgb *osmux_build_batch(struct osmux_batch *batch, struct msgb *cur, *tmp; int ctr = 0; + if (circuit->dummy) { + struct osmux_input_state state = { + .out_msg = batch_msg, + .ccid = circuit->ccid, + }; + osmux_encode_dummy(batch, batch_factor, &state); + continue; + } + llist_for_each_entry_safe(cur, tmp, &circuit->msg_list, list) { struct osmux_input_state state = { .msg = cur, @@ -348,7 +395,7 @@ void osmux_xfrm_input_deliver(struct osmux_in_handle *h) #ifdef DEBUG_MSG LOGP(DLMIB, LOGL_DEBUG, "invoking delivery function\n"); #endif - batch_msg = osmux_build_batch(batch, h->batch_size); + batch_msg = osmux_build_batch(batch, h->batch_size, h->batch_factor); h->stats.output_osmux_msgs++; h->stats.output_osmux_bytes += batch_msg->len; @@ -356,6 +403,11 @@ void osmux_xfrm_input_deliver(struct osmux_in_handle *h) h->deliver(batch_msg, h->data); osmo_timer_del(&batch->timer); batch->remaining_bytes = h->batch_size; + + if (batch->dummy) { + osmo_timer_schedule(&batch->timer, 0, + h->batch_factor * DELTA_RTP_MSG); + } } static void osmux_batch_timer_expired(void *data) @@ -462,7 +514,8 @@ osmux_batch_find_circuit(struct osmux_batch *batch, int ccid) } static struct osmux_circuit * -osmux_batch_add_circuit(struct osmux_batch *batch, int ccid) +osmux_batch_add_circuit(struct osmux_batch *batch, int ccid, int dummy, + int batch_factor) { struct osmux_circuit *circuit; @@ -482,6 +535,13 @@ osmux_batch_add_circuit(struct osmux_batch *batch, int ccid) INIT_LLIST_HEAD(&circuit->msg_list); llist_add_tail(&circuit->head, &batch->circuit_list); + if (dummy) { + circuit->dummy = dummy; + batch->dummy++; + if (!osmo_timer_pending(&batch->timer)) + osmo_timer_schedule(&batch->timer, 0, + batch_factor * DELTA_RTP_MSG); + } return circuit; } @@ -493,6 +553,8 @@ static void osmux_batch_del_circuit(struct osmux_batch *batch, int ccid) if (circuit == NULL) return; + if (circuit->dummy) + batch->dummy--; llist_del(&circuit->head); talloc_free(circuit); } @@ -503,51 +565,48 @@ osmux_batch_add(struct osmux_batch *batch, int batch_factor, struct msgb *msg, { int bytes = 0, amr_payload_len; struct osmux_circuit *circuit; + struct msgb *cur; circuit = osmux_batch_find_circuit(batch, ccid); + if (!circuit) + return -1; + /* We've seen the first RTP message, disable dummy padding */ + if (circuit->dummy) { + circuit->dummy = 0; + batch->dummy--; + } amr_payload_len = osmux_rtp_amr_payload_len(msg, rtph); if (amr_payload_len < 0) return -1; /* First check if there is room for this message in the batch */ bytes += amr_payload_len; - if (!circuit || circuit->nmsgs == 0) + if (circuit->nmsgs == 0) bytes += sizeof(struct osmux_hdr); /* No room, sorry. You'll have to retry */ if (bytes > batch->remaining_bytes) return 1; - if (circuit) { - struct msgb *cur; - - /* Extra validation: check if this message already exists, - * should not happen but make sure we don't propagate - * duplicated messages. - */ - llist_for_each_entry(cur, &circuit->msg_list, list) { - struct rtp_hdr *rtph2 = osmo_rtp_get_hdr(cur); - if (rtph2 == NULL) - return -1; - - /* Already exists message with this sequence, skip */ - if (rtph2->sequence == rtph->sequence) { - LOGP(DLMIB, LOGL_ERROR, "already exists " - "message with seq=%u, skip it\n", - rtph->sequence); - return -1; - } - } - /* Handle RTP packet loss scenario */ - osmux_replay_lost_packets(circuit, rtph); + /* Extra validation: check if this message already exists, should not + * happen but make sure we don't propagate duplicated messages. + */ + llist_for_each_entry(cur, &circuit->msg_list, list) { + struct rtp_hdr *rtph2 = osmo_rtp_get_hdr(cur); + if (rtph2 == NULL) + return -1; - } else { - /* This is the first message with that ssrc we've seen */ - circuit = osmux_batch_add_circuit(batch, ccid); - if (!circuit) + /* Already exists message with this sequence, skip */ + if (rtph2->sequence == rtph->sequence) { + LOGP(DLMIB, LOGL_ERROR, "already exists " + "message with seq=%u, skip it\n", + rtph->sequence); return -1; + } } + /* Handle RTP packet loss scenario */ + osmux_replay_lost_packets(circuit, rtph); /* This batch is full, force batch delivery */ if (osmux_batch_enqueue(msg, circuit) < 0) @@ -655,6 +714,14 @@ void osmux_xfrm_input_init(struct osmux_in_handle *h) LOGP(DLMIB, LOGL_DEBUG, "initialized osmux input converter\n"); } +int osmux_xfrm_input_open_circuit(struct osmux_in_handle *h, int ccid, + int dummy) +{ + struct osmux_batch *batch = (struct osmux_batch *)h->internal_data; + + return osmux_batch_add_circuit(batch, ccid, dummy, h->batch_factor) ? 0 : -1; +} + void osmux_xfrm_input_close_circuit(struct osmux_in_handle *h, int ccid) { struct osmux_batch *batch = (struct osmux_batch *)h->internal_data; -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:19 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:19 +0200 Subject: [PATCH libosmo-netif 04/18] osmux: rename struct batch_list_node to osmux_circuit In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-5-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso I think this is a better name for this object. Basically, an input handle represents a batch that is composed of one or more circuit objects. Each circuit object contains a list of RTP messages that are pending to be converted to the osmux format in one single batch. --- src/osmux.c | 66 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/osmux.c b/src/osmux.c index c3e68a3..81ad9dc 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -181,24 +181,24 @@ int osmux_xfrm_output(struct osmux_hdr *osmuxh, struct osmux_out_handle *h, struct osmux_batch { struct osmo_timer_list timer; struct osmux_hdr *osmuxh; - struct llist_head node_list; + struct llist_head circuit_list; unsigned int remaining_bytes; uint8_t seq; }; -struct batch_list_node { +struct osmux_circuit { struct llist_head head; int ccid; struct llist_head list; int nmsgs; }; -static int osmux_batch_enqueue(struct msgb *msg, struct batch_list_node *node) +static int osmux_batch_enqueue(struct msgb *msg, struct osmux_circuit *circuit) { /* Too many messages per batch, discard it. The counter field of the * osmux header is just 3 bits long, so make sure it doesn't overflow. */ - if (node->nmsgs >= 8) { + if (circuit->nmsgs >= 8) { struct rtp_hdr *rtph; rtph = osmo_rtp_get_hdr(msg); @@ -210,15 +210,15 @@ static int osmux_batch_enqueue(struct msgb *msg, struct batch_list_node *node) return -1; } - llist_add_tail(&msg->list, &node->list); - node->nmsgs++; + llist_add_tail(&msg->list, &circuit->list); + circuit->nmsgs++; return 0; } -static void osmux_batch_dequeue(struct msgb *msg, struct batch_list_node *node) +static void osmux_batch_dequeue(struct msgb *msg, struct osmux_circuit *circuit) { llist_del(&msg->list); - node->nmsgs--; + circuit->nmsgs--; } struct osmux_input_state { @@ -288,7 +288,7 @@ static int osmux_xfrm_encode_amr(struct osmux_in_handle *h, static struct msgb *osmux_build_batch(struct osmux_in_handle *h) { struct msgb *batch_msg; - struct batch_list_node *node, *tnode; + struct osmux_circuit *circuit, *next; struct osmux_batch *batch = (struct osmux_batch *)h->internal_data; #ifdef DEBUG_MSG @@ -301,15 +301,15 @@ static struct msgb *osmux_build_batch(struct osmux_in_handle *h) return NULL; } - llist_for_each_entry_safe(node, tnode, &batch->node_list, head) { + llist_for_each_entry_safe(circuit, next, &batch->circuit_list, head) { struct msgb *cur, *tmp; int ctr = 0; - llist_for_each_entry_safe(cur, tmp, &node->list, list) { + llist_for_each_entry_safe(cur, tmp, &circuit->list, list) { struct osmux_input_state state = { .msg = cur, .out_msg = batch_msg, - .ccid = node->ccid, + .ccid = circuit->ccid, }; #ifdef DEBUG_MSG char buf[4096]; @@ -331,12 +331,12 @@ static struct msgb *osmux_build_batch(struct osmux_in_handle *h) } osmux_xfrm_encode_amr(h, &state); - osmux_batch_dequeue(cur, node); + osmux_batch_dequeue(cur, circuit); msgb_free(cur); ctr++; } - llist_del(&node->head); - talloc_free(node); + llist_del(&circuit->head); + talloc_free(circuit); } return batch_msg; } @@ -394,7 +394,7 @@ static int osmux_rtp_amr_payload_len(struct msgb *msg, struct rtp_hdr *rtph) return amr_payload_len; } -static void osmux_replay_lost_packets(struct batch_list_node *node, +static void osmux_replay_lost_packets(struct osmux_circuit *circuit, struct rtp_hdr *cur_rtph) { int16_t diff; @@ -403,11 +403,11 @@ static void osmux_replay_lost_packets(struct batch_list_node *node, int i; /* Have we see any RTP packet in this batch before? */ - if (llist_empty(&node->list)) + if (llist_empty(&circuit->list)) return; /* Get last RTP packet seen in this batch */ - last = llist_entry(node->list.prev, struct msgb, list); + last = llist_entry(circuit->list.prev, struct msgb, list); rtph = osmo_rtp_get_hdr(last); if (rtph == NULL) return; @@ -441,7 +441,7 @@ static void osmux_replay_lost_packets(struct batch_list_node *node, DELTA_RTP_TIMESTAMP); /* No more room in this batch, skip padding with more clones */ - if (osmux_batch_enqueue(clone, node) < 0) { + if (osmux_batch_enqueue(clone, circuit) < 0) { msgb_free(clone); break; } @@ -450,22 +450,22 @@ static void osmux_replay_lost_packets(struct batch_list_node *node, } } -static struct batch_list_node * +static struct osmux_circuit * osmux_batch_find_circuit(struct osmux_batch *batch, int ccid) { - struct batch_list_node *circuit; + struct osmux_circuit *circuit; - llist_for_each_entry(circuit, &batch->node_list, head) { + llist_for_each_entry(circuit, &batch->circuit_list, head) { if (circuit->ccid == ccid) return circuit; } return NULL; } -static struct batch_list_node * +static struct osmux_circuit * osmux_batch_add_circuit(struct osmux_batch *batch, int ccid) { - struct batch_list_node *circuit; + struct osmux_circuit *circuit; circuit = osmux_batch_find_circuit(batch, ccid); if (circuit != NULL) { @@ -473,7 +473,7 @@ osmux_batch_add_circuit(struct osmux_batch *batch, int ccid) return NULL; } - circuit = talloc_zero(osmux_ctx, struct batch_list_node); + circuit = talloc_zero(osmux_ctx, struct osmux_circuit); if (circuit == NULL) { LOGP(DLMIB, LOGL_ERROR, "OOM on circuit %u\n", ccid); return NULL; @@ -481,7 +481,7 @@ osmux_batch_add_circuit(struct osmux_batch *batch, int ccid) circuit->ccid = ccid; INIT_LLIST_HEAD(&circuit->list); - llist_add_tail(&circuit->head, &batch->node_list); + llist_add_tail(&circuit->head, &batch->circuit_list); return circuit; } @@ -491,7 +491,7 @@ osmux_batch_add(struct osmux_batch *batch, struct msgb *msg, struct rtp_hdr *rtph, int ccid) { int bytes = 0, amr_payload_len; - struct batch_list_node *circuit; + struct osmux_circuit *circuit; circuit = osmux_batch_find_circuit(batch, ccid); @@ -597,7 +597,7 @@ int osmux_xfrm_input(struct osmux_in_handle *h, struct msgb *msg, int ccid) /* This is the first message in the batch, start the * batch timer to deliver it. */ - first_rtp_msg = llist_empty(&batch->node_list) ? 1 : 0; + first_rtp_msg = llist_empty(&batch->circuit_list) ? 1 : 0; /* Add this RTP to the OSMUX batch */ ret = osmux_batch_add(batch, msg, rtph, ccid); @@ -638,7 +638,7 @@ void osmux_xfrm_input_init(struct osmux_in_handle *h) if (batch == NULL) return; - INIT_LLIST_HEAD(&batch->node_list); + INIT_LLIST_HEAD(&batch->circuit_list); batch->remaining_bytes = h->batch_size; batch->timer.cb = osmux_batch_timer_expired; batch->timer.data = h; @@ -651,11 +651,11 @@ void osmux_xfrm_input_init(struct osmux_in_handle *h) void osmux_xfrm_input_fini(struct osmux_in_handle *h) { struct osmux_batch *batch = (struct osmux_batch *)h->internal_data; - struct batch_list_node *node, *next; + struct osmux_circuit *circuit, *next; - llist_for_each_entry_safe(node, next, &batch->node_list, head) { - llist_del(&node->head); - talloc_free(node); + llist_for_each_entry_safe(circuit, next, &batch->circuit_list, head) { + llist_del(&circuit->head); + talloc_free(circuit); } osmo_timer_del(&batch->timer); talloc_free(batch); -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:20 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:20 +0200 Subject: [PATCH libosmo-netif 05/18] osmux: rename circuit->list to circuit->rtp_list In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-6-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso A circuit object contains a list of pending RTP messages to be converted to the osmux format. --- src/osmux.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/osmux.c b/src/osmux.c index 81ad9dc..187ca1c 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -189,7 +189,7 @@ struct osmux_batch { struct osmux_circuit { struct llist_head head; int ccid; - struct llist_head list; + struct llist_head msg_list; int nmsgs; }; @@ -210,7 +210,7 @@ static int osmux_batch_enqueue(struct msgb *msg, struct osmux_circuit *circuit) return -1; } - llist_add_tail(&msg->list, &circuit->list); + llist_add_tail(&msg->list, &circuit->msg_list); circuit->nmsgs++; return 0; } @@ -305,7 +305,7 @@ static struct msgb *osmux_build_batch(struct osmux_in_handle *h) struct msgb *cur, *tmp; int ctr = 0; - llist_for_each_entry_safe(cur, tmp, &circuit->list, list) { + llist_for_each_entry_safe(cur, tmp, &circuit->msg_list, list) { struct osmux_input_state state = { .msg = cur, .out_msg = batch_msg, @@ -403,11 +403,11 @@ static void osmux_replay_lost_packets(struct osmux_circuit *circuit, int i; /* Have we see any RTP packet in this batch before? */ - if (llist_empty(&circuit->list)) + if (llist_empty(&circuit->msg_list)) return; /* Get last RTP packet seen in this batch */ - last = llist_entry(circuit->list.prev, struct msgb, list); + last = llist_entry(circuit->msg_list.prev, struct msgb, list); rtph = osmo_rtp_get_hdr(last); if (rtph == NULL) return; @@ -480,7 +480,7 @@ osmux_batch_add_circuit(struct osmux_batch *batch, int ccid) } circuit->ccid = ccid; - INIT_LLIST_HEAD(&circuit->list); + INIT_LLIST_HEAD(&circuit->msg_list); llist_add_tail(&circuit->head, &batch->circuit_list); return circuit; @@ -515,7 +515,7 @@ osmux_batch_add(struct osmux_batch *batch, struct msgb *msg, * should not happen but make sure we don't propagate * duplicated messages. */ - llist_for_each_entry(cur, &circuit->list, list) { + llist_for_each_entry(cur, &circuit->msg_list, list) { struct rtp_hdr *rtph2 = osmo_rtp_get_hdr(cur); if (rtph2 == NULL) return -1; -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:25 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:25 +0200 Subject: [PATCH libosmo-netif 10/18] tests: osmux: adapt it to use the new circuit API In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-11-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso This also introduces a spare circuit that contains no voice data to test bandwidth preallocation through the new osmux dummy frame type. --- tests/osmux/osmux_test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/osmux/osmux_test.c b/tests/osmux/osmux_test.c index dae9aa2..1b87db7 100644 --- a/tests/osmux/osmux_test.c +++ b/tests/osmux/osmux_test.c @@ -135,6 +135,13 @@ int main(void) /* If the test takes longer than 10 seconds, abort it */ alarm(10); + for (i = 0; i < 2; i++) + osmux_xfrm_input_open_circuit(&h_input, i, 0); + + /* Add two circuits with dummy padding */ + osmux_xfrm_input_open_circuit(&h_input, 2, 1); + osmux_xfrm_input_open_circuit(&h_input, 3, 1); + for (i=1; i<64; i++) { msg = msgb_alloc(1500, "test"); if (!msg) @@ -178,6 +185,12 @@ int main(void) k = 0; } } + + for (i = 0; i < 4; i++) + osmux_xfrm_input_close_circuit(&h_input, i); + + osmux_xfrm_input_fini(&h_input); + fprintf(stdout, "OK: Test passed\n"); return EXIT_SUCCESS; } -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:23 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:23 +0200 Subject: [PATCH libosmo-netif 08/18] osmux: introduce osmux_xfrm_input_close_circuit() In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-9-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Add this new function to explicitly remove an existing circuit. Thus, the client application (openbsc) is in full control to release circuits. Before this patch, the circuit object was added when the first RTP messages was seen, and it was removed when transforming the list of pending RTP messages to the Osmux message (once the timer expired). Moreover, check circuit->nmsgs to account bytes that are consumed by the osmux header, given that !circuit doesn't mean "this is the first packet" anymore. --- include/osmocom/netif/osmux.h | 2 ++ src/osmux.c | 27 ++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/include/osmocom/netif/osmux.h b/include/osmocom/netif/osmux.h index 0f6f5c9..14c967f 100644 --- a/include/osmocom/netif/osmux.h +++ b/include/osmocom/netif/osmux.h @@ -84,6 +84,8 @@ int osmux_snprintf(char *buf, size_t size, struct msgb *msg); void osmux_xfrm_input_init(struct osmux_in_handle *h); void osmux_xfrm_input_fini(struct osmux_in_handle *h); +void osmux_xfrm_input_close_circuit(struct osmux_in_handle *h, int ccid); + int osmux_xfrm_input(struct osmux_in_handle *h, struct msgb *msg, int ccid); void osmux_xfrm_input_deliver(struct osmux_in_handle *h); diff --git a/src/osmux.c b/src/osmux.c index 82ec56e..4451b5a 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -289,7 +289,7 @@ static struct msgb *osmux_build_batch(struct osmux_batch *batch, uint32_t batch_size) { struct msgb *batch_msg; - struct osmux_circuit *circuit, *next; + struct osmux_circuit *circuit; #ifdef DEBUG_MSG LOGP(DLMIB, LOGL_DEBUG, "Now building batch\n"); @@ -301,7 +301,7 @@ static struct msgb *osmux_build_batch(struct osmux_batch *batch, return NULL; } - llist_for_each_entry_safe(circuit, next, &batch->circuit_list, head) { + llist_for_each_entry(circuit, &batch->circuit_list, head) { struct msgb *cur, *tmp; int ctr = 0; @@ -336,8 +336,6 @@ static struct msgb *osmux_build_batch(struct osmux_batch *batch, ctr++; batch->nmsgs--; } - llist_del(&circuit->head); - talloc_free(circuit); } return batch_msg; } @@ -487,6 +485,18 @@ osmux_batch_add_circuit(struct osmux_batch *batch, int ccid) return circuit; } +static void osmux_batch_del_circuit(struct osmux_batch *batch, int ccid) +{ + struct osmux_circuit *circuit; + + circuit = osmux_batch_find_circuit(batch, ccid); + if (circuit == NULL) + return; + + llist_del(&circuit->head); + talloc_free(circuit); +} + static int osmux_batch_add(struct osmux_batch *batch, int batch_factor, struct msgb *msg, struct rtp_hdr *rtph, int ccid) @@ -502,7 +512,7 @@ osmux_batch_add(struct osmux_batch *batch, int batch_factor, struct msgb *msg, /* First check if there is room for this message in the batch */ bytes += amr_payload_len; - if (!circuit) + if (!circuit || circuit->nmsgs == 0) bytes += sizeof(struct osmux_hdr); /* No room, sorry. You'll have to retry */ @@ -645,6 +655,13 @@ void osmux_xfrm_input_init(struct osmux_in_handle *h) LOGP(DLMIB, LOGL_DEBUG, "initialized osmux input converter\n"); } +void osmux_xfrm_input_close_circuit(struct osmux_in_handle *h, int ccid) +{ + struct osmux_batch *batch = (struct osmux_batch *)h->internal_data; + + osmux_batch_del_circuit(batch, ccid); +} + void osmux_xfrm_input_fini(struct osmux_in_handle *h) { struct osmux_batch *batch = (struct osmux_batch *)h->internal_data; -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:26 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:26 +0200 Subject: [PATCH libosmo-netif 11/18] tests: osmux: factor out main test loop In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-12-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Move main test loop routine to the new osmux_test_loop() function. --- tests/osmux/osmux_test.c | 64 ++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/tests/osmux/osmux_test.c b/tests/osmux/osmux_test.c index 1b87db7..51f026c 100644 --- a/tests/osmux/osmux_test.c +++ b/tests/osmux/osmux_test.c @@ -112,7 +112,7 @@ static void sigalarm_handler(int foo) exit(EXIT_FAILURE); } -int main(void) +static void osmux_test_loop(int ccid) { struct msgb *msg; char buf[1024]; @@ -120,32 +120,10 @@ int main(void) uint16_t seq; int i, j, k = 0; - if (signal(SIGALRM, sigalarm_handler) == SIG_ERR) { - perror("signal"); - exit(EXIT_FAILURE); - } - - /* This test doesn't use it, but osmux requires it internally. */ - osmo_init_logging(&osmux_test_log_info); - log_set_log_level(osmo_stderr_target, LOGL_DEBUG); - - osmux_xfrm_input_init(&h_input); - osmux_xfrm_output_init(&h_output, 0x7000000); - - /* If the test takes longer than 10 seconds, abort it */ - alarm(10); - - for (i = 0; i < 2; i++) - osmux_xfrm_input_open_circuit(&h_input, i, 0); - - /* Add two circuits with dummy padding */ - osmux_xfrm_input_open_circuit(&h_input, 2, 1); - osmux_xfrm_input_open_circuit(&h_input, 3, 1); - - for (i=1; i<64; i++) { + for (i = 1; i < 64; i++) { msg = msgb_alloc(1500, "test"); if (!msg) - return 0; + exit(EXIT_FAILURE); memcpy(msg->data, rtp_pkt, sizeof(rtp_pkt)); msgb_put(msg, sizeof(rtp_pkt)); @@ -155,7 +133,7 @@ int main(void) rtph->sequence = htons(seq); osmo_rtp_snprintf(buf, sizeof(buf), msg); - fprintf(stderr, "adding to ccid=%u %s\n", i % 2, buf); + fprintf(stderr, "adding to ccid=%u %s\n", (i % 2) + ccid, buf); rtp_pkts++; k++; @@ -164,7 +142,7 @@ int main(void) * gaps between two messages to test the osmux replaying * feature. */ - osmux_xfrm_input(&h_input, msg, i % 2); + osmux_xfrm_input(&h_input, msg, (i % 2) + ccid); if (i % 4 == 0) { gettimeofday(&last, NULL); @@ -179,12 +157,42 @@ int main(void) * messages that are extracted from OSMUX has been * delivered. */ - for (j=0; j References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-14-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Make sure that early dummy bandwitch preallocation works fine in the absence of any kind of voice traffic. --- tests/osmux/osmux_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/osmux/osmux_test.c b/tests/osmux/osmux_test.c index 09ef9fd..0ad02d3 100644 --- a/tests/osmux/osmux_test.c +++ b/tests/osmux/osmux_test.c @@ -191,6 +191,10 @@ int main(void) osmux_xfrm_input_open_circuit(&h_input, 2, 1); osmux_xfrm_input_open_circuit(&h_input, 3, 1); + /* Wait 10 times to make sure dummy padding timer works fine */ + for (i = 0; i < 10; i++) + osmo_select_main(0); + /* Start pushing voice data to circuits 0 and 1 */ osmux_test_loop(0); /* ... now start pushing voice data to circuits 2 and 3. This circuits -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:31 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:31 +0200 Subject: [PATCH libosmo-netif 16/18] tests: osmux: fix msgb leaks In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-17-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso --- tests/osmux/osmux_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/osmux/osmux_test.c b/tests/osmux/osmux_test.c index 7cc838d..9ceabcd 100644 --- a/tests/osmux/osmux_test.c +++ b/tests/osmux/osmux_test.c @@ -78,6 +78,7 @@ static void tx_cb(struct msgb *msg, void *data) } rtp_pkts--; + msgb_free(msg); } static struct osmux_out_handle h_output; @@ -98,6 +99,7 @@ static void osmux_deliver(struct msgb *batch_msg, void *data) osmux_xfrm_output(osmuxh, &h_output, &list); osmux_tx_sched(&list, tx_cb, NULL); } + msgb_free(batch_msg); } struct osmux_in_handle h_input = { -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:27 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:27 +0200 Subject: [PATCH libosmo-netif 12/18] tests: osmux: test online deactivation of dummy padding In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-13-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Add RTP packets to circuit with dummy padding enabled to test automatic deactivation once when start seeing real voice traffic. --- tests/osmux/osmux_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/osmux/osmux_test.c b/tests/osmux/osmux_test.c index 51f026c..09ef9fd 100644 --- a/tests/osmux/osmux_test.c +++ b/tests/osmux/osmux_test.c @@ -193,6 +193,10 @@ int main(void) /* Start pushing voice data to circuits 0 and 1 */ osmux_test_loop(0); + /* ... now start pushing voice data to circuits 2 and 3. This circuits + * comes with dummy padding enabled. + */ + osmux_test_loop(2); for (i = 0; i < 4; i++) osmux_xfrm_input_close_circuit(&h_input, i); -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:32 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:32 +0200 Subject: [PATCH libosmo-netif 17/18] tests: compile tests with debugging symbols, ie. -g In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-18-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Useful when debuggin via valgrind/gdb. --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index a986940..f99e276 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -AM_CFLAGS = -Wall -I$(top_srcdir)/include $(LIBOSMOCORE_CFLAGS) +AM_CFLAGS = -Wall -I$(top_srcdir)/include $(LIBOSMOCORE_CFLAGS) -g AM_LDFLAGS = $(LIBOSMOCORE_LDFLAGS) check_PROGRAMS = osmux/osmux_test -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:29 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:29 +0200 Subject: [PATCH libosmo-netif 14/18] tests: osmux: test circuit reopening after closure In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-15-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Make sure circuit routines works correctly. --- tests/osmux/osmux_test.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/osmux/osmux_test.c b/tests/osmux/osmux_test.c index 0ad02d3..7cc838d 100644 --- a/tests/osmux/osmux_test.c +++ b/tests/osmux/osmux_test.c @@ -205,6 +205,13 @@ int main(void) for (i = 0; i < 4; i++) osmux_xfrm_input_close_circuit(&h_input, i); + /* Reopen with two circuits and retest */ + osmux_xfrm_input_open_circuit(&h_input, 0, 0); + osmux_xfrm_input_open_circuit(&h_input, 1, 1); + osmux_test_loop(0); + osmux_xfrm_input_close_circuit(&h_input, 0); + osmux_xfrm_input_close_circuit(&h_input, 1); + osmux_xfrm_input_fini(&h_input); fprintf(stdout, "OK: Test passed\n"); -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:30 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:30 +0200 Subject: [PATCH libosmo-netif 15/18] osmux: kill osmux_get_hdr() In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-16-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Never used, so let's get rid of this function. We can recover it later on in case we need it. --- include/osmocom/netif/osmux.h | 2 -- src/osmux.c | 12 ------------ 2 files changed, 14 deletions(-) diff --git a/include/osmocom/netif/osmux.h b/include/osmocom/netif/osmux.h index c1f527a..83bb2e1 100644 --- a/include/osmocom/netif/osmux.h +++ b/include/osmocom/netif/osmux.h @@ -70,8 +70,6 @@ struct osmux_out_handle { uint32_t rtp_ssrc; }; -struct osmux_hdr *osmux_get_hdr(struct msgb *msg); - static inline uint8_t *osmux_get_payload(struct osmux_hdr *osmuxh) { return (uint8_t *)osmuxh + sizeof(struct osmux_hdr); diff --git a/src/osmux.c b/src/osmux.c index 74883d9..eedae69 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -39,18 +39,6 @@ static void *osmux_ctx; -struct osmux_hdr *osmux_get_hdr(struct msgb *msg) -{ - struct osmux_hdr *osmuxh = (struct osmux_hdr *)msg->data; - - if (msg->len < sizeof(struct osmux_hdr)) { - DEBUGPC(DLMUX, "received OSMUX frame too short (len = %d)\n", - msg->len); - return NULL; - } - return osmuxh; -} - static uint32_t osmux_get_payload_len(struct osmux_hdr *osmuxh) { return osmo_amr_bytes(osmuxh->amr_ft) * (osmuxh->ctr+1); -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:23:33 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:23:33 +0200 Subject: [PATCH libosmo-netif 18/18] tests: osmux: iterate 64 times in osmo_test_loop() In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <1437488613-3943-19-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Instead of 63, this resolves major "definitely lost" remaining leak that valgrind reports regarding msgb. --- tests/osmux/osmux_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/osmux/osmux_test.c b/tests/osmux/osmux_test.c index 9ceabcd..94b95de 100644 --- a/tests/osmux/osmux_test.c +++ b/tests/osmux/osmux_test.c @@ -122,7 +122,7 @@ static void osmux_test_loop(int ccid) uint16_t seq; int i, j, k = 0; - for (i = 1; i < 64; i++) { + for (i = 1; i < 65; i++) { msg = msgb_alloc(1500, "test"); if (!msg) exit(EXIT_FAILURE); -- 1.7.10.4 From pablo at gnumonks.org Tue Jul 21 14:26:23 2015 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 21 Jul 2015 16:26:23 +0200 Subject: [PATCH openbsc] osmux: add option to pad the circuit with dummy messages Message-ID: <1437488783-4213-1-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Iridium is a satellite network which operates a GPRS-like that allows you to get speeds up to 128kbit/s. However, it takes from 5 to 6 secs to get the bandwidth allocated, so the conversation is garbled during the time. This patch uses the new dummy padding support in libosmo-netif that is controlled through the osmux osmux_xfrm_input_open_circuit(). This includes a new VTY option for osmux. --- openbsc/include/openbsc/mgcp.h | 4 ++++ openbsc/src/libmgcp/mgcp_osmux.c | 7 +++++++ openbsc/src/libmgcp/mgcp_vty.c | 16 ++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h index f334ac8..1f63803 100644 --- a/openbsc/include/openbsc/mgcp.h +++ b/openbsc/include/openbsc/mgcp.h @@ -224,6 +224,10 @@ struct mgcp_config { int osmux_batch_size; /* osmux port */ uint16_t osmux_port; + /* Pad circuit with dummy messages until we see the first voice + * message. + */ + uint16_t osmux_dummy; }; /* config management */ diff --git a/openbsc/src/libmgcp/mgcp_osmux.c b/openbsc/src/libmgcp/mgcp_osmux.c index 7f61173..90b7368 100644 --- a/openbsc/src/libmgcp/mgcp_osmux.c +++ b/openbsc/src/libmgcp/mgcp_osmux.c @@ -462,6 +462,12 @@ int osmux_enable_endpoint(struct mgcp_endpoint *endp, int role, LOGP(DMGCP, LOGL_ERROR, "Cannot allocate input osmux handle\n"); return -1; } + if (!osmux_xfrm_input_open_circuit(endp->osmux.in, endp->osmux.cid, + endp->cfg->osmux_dummy)) { + LOGP(DMGCP, LOGL_ERROR, "Cannot open osmux circuit %u\n", + endp->osmux.cid); + return -1; + } switch (endp->cfg->role) { case MGCP_BSC_NAT: @@ -480,6 +486,7 @@ void osmux_disable_endpoint(struct mgcp_endpoint *endp) { LOGP(DMGCP, LOGL_INFO, "Releasing endpoint %u using Osmux CID %u\n", ENDPOINT_NUMBER(endp), endp->osmux.cid); + osmux_xfrm_input_close_circuit(endp->osmux.in, endp->osmux.cid); endp->osmux.state = OSMUX_STATE_DISABLED; endp->osmux.cid = -1; osmux_handle_put(endp->osmux.in); diff --git a/openbsc/src/libmgcp/mgcp_vty.c b/openbsc/src/libmgcp/mgcp_vty.c index dd21a15..8f6b10a 100644 --- a/openbsc/src/libmgcp/mgcp_vty.c +++ b/openbsc/src/libmgcp/mgcp_vty.c @@ -144,6 +144,8 @@ static int config_write_mgcp(struct vty *vty) g_cfg->osmux_batch_size, VTY_NEWLINE); vty_out(vty, " osmux port %u%s", g_cfg->osmux_port, VTY_NEWLINE); + vty_out(vty, " osmux dummy %s%s", + g_cfg->osmux_dummy ? "on" : "off", VTY_NEWLINE); } return CMD_SUCCESS; } @@ -1245,6 +1247,19 @@ DEFUN(cfg_mgcp_osmux_port, return CMD_SUCCESS; } +DEFUN(cfg_mgcp_osmux_dummy, + cfg_mgcp_osmux_dummy_cmd, + "osmux dummy (on|off)", + OSMUX_STR "Enable dummy padding\n" "Disable dummy padding\n") +{ + if (strcmp(argv[0], "on") == 0) + g_cfg->osmux_dummy = 1; + else if (strcmp(argv[0], "off") == 0) + g_cfg->osmux_dummy = 0; + + return CMD_SUCCESS; +} + int mgcp_vty_init(void) { install_element_ve(&show_mgcp_cmd); @@ -1304,6 +1319,7 @@ int mgcp_vty_init(void) install_element(MGCP_NODE, &cfg_mgcp_osmux_batch_factor_cmd); install_element(MGCP_NODE, &cfg_mgcp_osmux_batch_size_cmd); install_element(MGCP_NODE, &cfg_mgcp_osmux_port_cmd); + install_element(MGCP_NODE, &cfg_mgcp_osmux_dummy_cmd); install_element(MGCP_NODE, &cfg_mgcp_allow_transcoding_cmd); install_element(MGCP_NODE, &cfg_mgcp_no_allow_transcoding_cmd); -- 1.7.10.4 From holger at freyther.de Tue Jul 21 23:04:16 2015 From: holger at freyther.de (Holger Freyther) Date: Wed, 22 Jul 2015 01:04:16 +0200 Subject: [PATCH libosmo-netif 00/18] add dummy padding support In-Reply-To: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> References: <1437488613-3943-1-git-send-email-pablo@gnumonks.org> Message-ID: <318CA352-AACE-413C-8618-12423D0352DC@freyther.de> > On 21 Jul 2015, at 16:23, pablo at gnumonks.org wrote: Hi!, > If no major concerns, I'll push this initial batch soon into the repository. it is a bit late for me right now. The granularity of changes, comments, commit messages all look great. Please give me until tomorrow evening to have a second look. holger From omar.ramadan at berkeley.edu Fri Jul 24 18:12:28 2015 From: omar.ramadan at berkeley.edu (OMAR RAMADAN) Date: Fri, 24 Jul 2015 11:12:28 -0700 Subject: Using GPRS Message-ID: Hi list, I've installed omsocom for the first time on a USRP B200 and I'm interested in trying out the GPRS stack. I've followed a few pages on the wiki, namely http://openbsc.osmocom.org/trac/wiki/network_from_scratch and http://openbsc.osmocom.org/trac/wiki/OpenBSC_GPRS to get set up and I am not sure how up to date these tutorials are. I have calls working via the LCR, but I cannot get GPRS functioning. I see no activity on the BSC log when attempting GPRS attach using APN openbsc. I also see no traffic between the SGSN and the BSC (listening with tshark on 127.0.0.1:23000). Any help is appreciated. I am currently using osmo-trx/master, osmo-bsc/jolly/testing, libosmo-abis/jolly/multi-trx, omso-bts/jolly/trx, openggsn/master, and osmo-pcu/master. Best, Omar -------------- next part -------------- An HTML attachment was scrubbed... URL: From sipos.csaba at kvk.uni-obuda.hu Fri Jul 24 18:26:37 2015 From: sipos.csaba at kvk.uni-obuda.hu (Sipos Csaba) Date: Fri, 24 Jul 2015 20:26:37 +0200 (CEST) Subject: Using GPRS In-Reply-To: References: Message-ID: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> Hi Omar, I am trying to do the same thing for a while, but I am not succeeded yet. The hardest is to find the right branch of every piece of software. The wiki is quite outdated, and no USRP related man page was ever created. The jolly branches are also quite old, a lot of development happened, so I would not suggest to use them. Tom suggested to me that I should try fairwaves/master branch of OpenBSC, Osmo-BTS and Osmo-TRX (pretty much everything that has a fairwaves/master branch) to use with USRP devices. I also have a B200 by the way. With this at least I was able to build a fairly recent version that starts up and actually transmits, I think the PCU was not able to talk with the SGSN (which is part of OpenBSC), so probably I need some more fine tuning. There was a UHD driver problem a few months back, so the UHD driver version is also important. This problem affected OpenBTS, I don't know what is the recommended UHD version, maybe Tom will come in and advise us something. Just to notify the list, I am more than happy to create a new Wiki page in the minute I find a working configuration. At least I am not alone with this anymore :-) Regards, Csaba ----- Eredeti ?zenet ----- Felad?: "OMAR RAMADAN" C?mzett: openbsc at lists.osmocom.org Elk?ld?tt ?zenetek: P?ntek, 2015. J?lius 24. 20:12:28 T?rgy: Using GPRS Hi list, I've installed omsocom for the first time on a USRP B200 and I'm interested in trying out the GPRS stack. I've followed a few pages on the wiki, namely http://openbsc.osmocom.org/trac/wiki/network_from_scratch and http://openbsc.osmocom.org/trac/wiki/OpenBSC_GPRS to get set up and I am not sure how up to date these tutorials are. I have calls working via the LCR, but I cannot get GPRS functioning. I see no activity on the BSC log when attempting GPRS attach using APN openbsc. I also see no traffic between the SGSN and the BSC (listening with tshark on 127.0.0.1:23000). Any help is appreciated. I am currently using osmo-trx/master, osmo-bsc/jolly/testing, libosmo-abis/jolly/multi-trx, omso-bts/jolly/trx, openggsn/master, and osmo-pcu/master. Best, Omar From alexander.chemeris at gmail.com Fri Jul 24 20:02:26 2015 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Fri, 24 Jul 2015 16:02:26 -0400 Subject: Using GPRS In-Reply-To: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> References: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: Sipos, Omar, Yes, 'fariwaves/master' is almost always the best choice if you're using USRP or UmTRX. The wiki should be updated to reflect that - your help would be greatly appreciated here. You may also find documentation at umtrx.org useful, even though it's focused on UmTRX and not USRP. Regarding GPRS issues I hope Ivan will be able to comment. Please excuse typos. Written with a touchscreen keyboard. -- Regards, Alexander Chemeris CEO Fairwaves, Inc. https://fairwaves.co Hi Omar, I am trying to do the same thing for a while, but I am not succeeded yet. The hardest is to find the right branch of every piece of software. The wiki is quite outdated, and no USRP related man page was ever created. The jolly branches are also quite old, a lot of development happened, so I would not suggest to use them. Tom suggested to me that I should try fairwaves/master branch of OpenBSC, Osmo-BTS and Osmo-TRX (pretty much everything that has a fairwaves/master branch) to use with USRP devices. I also have a B200 by the way. With this at least I was able to build a fairly recent version that starts up and actually transmits, I think the PCU was not able to talk with the SGSN (which is part of OpenBSC), so probably I need some more fine tuning. There was a UHD driver problem a few months back, so the UHD driver version is also important. This problem affected OpenBTS, I don't know what is the recommended UHD version, maybe Tom will come in and advise us something. Just to notify the list, I am more than happy to create a new Wiki page in the minute I find a working configuration. At least I am not alone with this anymore :-) Regards, Csaba ----- Eredeti ?zenet ----- Felad?: "OMAR RAMADAN" C?mzett: openbsc at lists.osmocom.org Elk?ld?tt ?zenetek: P?ntek, 2015. J?lius 24. 20:12:28 T?rgy: Using GPRS Hi list, I've installed omsocom for the first time on a USRP B200 and I'm interested in trying out the GPRS stack. I've followed a few pages on the wiki, namely http://openbsc.osmocom.org/trac/wiki/network_from_scratch and http://openbsc.osmocom.org/trac/wiki/OpenBSC_GPRS to get set up and I am not sure how up to date these tutorials are. I have calls working via the LCR, but I cannot get GPRS functioning. I see no activity on the BSC log when attempting GPRS attach using APN openbsc. I also see no traffic between the SGSN and the BSC (listening with tshark on 127.0.0.1:23000). Any help is appreciated. I am currently using osmo-trx/master, osmo-bsc/jolly/testing, libosmo-abis/jolly/multi-trx, omso-bts/jolly/trx, openggsn/master, and osmo-pcu/master. Best, Omar -------------- next part -------------- An HTML attachment was scrubbed... URL: From sipos.csaba at kvk.uni-obuda.hu Fri Jul 24 22:30:29 2015 From: sipos.csaba at kvk.uni-obuda.hu (Sipos Csaba) Date: Sat, 25 Jul 2015 00:30:29 +0200 (CEST) Subject: Using GPRS In-Reply-To: References: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> Dear Alexander, Will do the wiki update as soon as I have (at least a more or less) working setup. A single question: can you comment on the non-connecting PCU socket? To my best understanding, this connection is a normal UNIX socket, and the PCU and the SGSN should find each other if they compiled in a given order to meet some dependency. Is there any specific flag we need to enable during compiling any of the related software? (Osmo-BTS, PCU, OpenBSC, etc.) Regards, Csaba ----- Eredeti ?zenet ----- Felad?: "Alexander Chemeris" C?mzett: "Sipos Csaba" M?solatot kap: "OpenBSC Mailing List" , "OMAR RAMADAN" Elk?ld?tt ?zenetek: P?ntek, 2015. J?lius 24. 22:02:26 T?rgy: Re: Using GPRS Sipos, Omar, Yes, 'fariwaves/master' is almost always the best choice if you're using USRP or UmTRX. The wiki should be updated to reflect that - your help would be greatly appreciated here. You may also find documentation at umtrx.org useful, even though it's focused on UmTRX and not USRP. Regarding GPRS issues I hope Ivan will be able to comment. Please excuse typos. Written with a touchscreen keyboard. -- Regards, Alexander Chemeris CEO Fairwaves, Inc. https://fairwaves.co Hi Omar, I am trying to do the same thing for a while, but I am not succeeded yet. The hardest is to find the right branch of every piece of software. The wiki is quite outdated, and no USRP related man page was ever created. The jolly branches are also quite old, a lot of development happened, so I would not suggest to use them. Tom suggested to me that I should try fairwaves/master branch of OpenBSC, Osmo-BTS and Osmo-TRX (pretty much everything that has a fairwaves/master branch) to use with USRP devices. I also have a B200 by the way. With this at least I was able to build a fairly recent version that starts up and actually transmits, I think the PCU was not able to talk with the SGSN (which is part of OpenBSC), so probably I need some more fine tuning. There was a UHD driver problem a few months back, so the UHD driver version is also important. This problem affected OpenBTS, I don't know what is the recommended UHD version, maybe Tom will come in and advise us something. Just to notify the list, I am more than happy to create a new Wiki page in the minute I find a working configuration. At least I am not alone with this anymore :-) Regards, Csaba ----- Eredeti ?zenet ----- Felad?: "OMAR RAMADAN" C?mzett: openbsc at lists.osmocom.org Elk?ld?tt ?zenetek: P?ntek, 2015. J?lius 24. 20:12:28 T?rgy: Using GPRS Hi list, I've installed omsocom for the first time on a USRP B200 and I'm interested in trying out the GPRS stack. I've followed a few pages on the wiki, namely http://openbsc.osmocom.org/trac/wiki/network_from_scratch and http://openbsc.osmocom.org/trac/wiki/OpenBSC_GPRS to get set up and I am not sure how up to date these tutorials are. I have calls working via the LCR, but I cannot get GPRS functioning. I see no activity on the BSC log when attempting GPRS attach using APN openbsc. I also see no traffic between the SGSN and the BSC (listening with tshark on 127.0.0.1:23000). Any help is appreciated. I am currently using osmo-trx/master, osmo-bsc/jolly/testing, libosmo-abis/jolly/multi-trx, omso-bts/jolly/trx, openggsn/master, and osmo-pcu/master. Best, Omar From Ivan.Kluchnikov at fairwaves.ru Sun Jul 26 08:56:51 2015 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Sun, 26 Jul 2015 11:56:51 +0300 Subject: Using GPRS In-Reply-To: <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> References: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: Hi Sipos, Omar, You should use the following branches: libosmocore branch master libosmo-abis branch master osmo-trx branch fairwaves/master osmo-bts branch fairwaves/master ( use ./configure --enable-trx) openbsc branch fairwaves/master osmo-pcu branch master (use ./configure --enable-sysmocom-bts ) openggsn branch master Also if you use the same machine for sgsn, bts and pcu, you should change openbsc.cfg, instead of: gprs nsvc 0 local udp port 23000 gprs nsvc 0 remote udp port 23000 use different ports, for example: gprs nsvc 0 local udp port 5948 gprs nsvc 0 remote udp port 23000 -- Regards, Ivan Kluchnikov. http://fairwaves.ru -------------- next part -------------- An HTML attachment was scrubbed... URL: From sipos.csaba at kvk.uni-obuda.hu Sun Jul 26 09:35:42 2015 From: sipos.csaba at kvk.uni-obuda.hu (Sipos Csaba) Date: Sun, 26 Jul 2015 11:35:42 +0200 (CEST) Subject: Using GPRS In-Reply-To: References: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: <2082705239.393803.1437903342655.JavaMail.zimbra@kvk.uni-obuda.hu> Thanks Ivan, Will try that and report back. Regards, Csaba ----- Eredeti ?zenet ----- Felad?: "Ivan Kluchnikov" C?mzett: "Sipos Csaba" M?solatot kap: "Alexander Chemeris" , "OpenBSC Mailing List" Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 10:56:51 T?rgy: Re: Using GPRS Hi Sipos, Omar, You should use the following branches: libosmocore branch master libosmo-abis branch master osmo-trx branch fairwaves/master osmo-bts branch fairwaves/master ( use ./configure --enable-trx) openbsc branch fairwaves/master osmo-pcu branch master (use ./configure --enable-sysmocom-bts ) openggsn branch master Also if you use the same machine for sgsn, bts and pcu, you should change openbsc.cfg, instead of: gprs nsvc 0 local udp port 23000 gprs nsvc 0 remote udp port 23000 use different ports, for example: gprs nsvc 0 local udp port 5948 gprs nsvc 0 remote udp port 23000 -- Regards, Ivan Kluchnikov. http://fairwaves.ru From sipos.csaba at kvk.uni-obuda.hu Sun Jul 26 10:30:50 2015 From: sipos.csaba at kvk.uni-obuda.hu (Sipos Csaba) Date: Sun, 26 Jul 2015 12:30:50 +0200 (CEST) Subject: Using GPRS In-Reply-To: <2082705239.393803.1437903342655.JavaMail.zimbra@kvk.uni-obuda.hu> References: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> <2082705239.393803.1437903342655.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> Dear Ivan, Alexander, I encountered the following issues: During compiling of OpenBSC (fairwaves/master), the pcap.h was missing. The configuration script was not detecting this missing file. "apt-get install libpcap-dev" solved this issue. The fairwaves/master branch of osmo-trx produces the following issue durign compilation: ================================ Making all in x86 make[3]: Entering directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' CC ../common/convolve_base.lo CC convert.lo In file included from convert.c:33:0: /usr/lib/gcc/x86_64-linux-gnu/4.8/include/smmintrin.h:31:3: error: #error "SSE4.1 instruction set not enabled" # error "SSE4.1 instruction set not enabled" ^ convert.c: In function '_sse_convert_si16_ps_16n': convert.c:49:3: warning: implicit declaration of function '_mm_cvtepi16_epi32' [-Wimplicit-function-declaration] m2 = _mm_cvtepi16_epi32(m0); ^ convert.c:49:6: error: incompatible types when assigning to type '__m128i' from type 'int' m2 = _mm_cvtepi16_epi32(m0); ^ convert.c:50:6: error: incompatible types when assigning to type '__m128i' from type 'int' m4 = _mm_cvtepi16_epi32(m1); ^ convert.c:53:6: error: incompatible types when assigning to type '__m128i' from type 'int' m3 = _mm_cvtepi16_epi32(m0); ^ convert.c:54:6: error: incompatible types when assigning to type '__m128i' from type 'int' m5 = _mm_cvtepi16_epi32(m1); ^ make[3]: *** [convert.lo] Error 1 make[3]: Leaving directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/root/new_openbsc/osmo-trx/Transceiver52M' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/root/new_openbsc/osmo-trx' make: *** [all] Error 2 ================================= Please note that the master branch of Osmo-TRX compiles just fine. Do any of you have an idea what could be the problem? Thanks! Csaba ----- Eredeti ?zenet ----- Felad?: "Sipos Csaba" C?mzett: "Ivan Kluchnikov" M?solatot kap: "OpenBSC Mailing List" Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 11:35:42 T?rgy: Re: Using GPRS Thanks Ivan, Will try that and report back. Regards, Csaba ----- Eredeti ?zenet ----- Felad?: "Ivan Kluchnikov" C?mzett: "Sipos Csaba" M?solatot kap: "Alexander Chemeris" , "OpenBSC Mailing List" Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 10:56:51 T?rgy: Re: Using GPRS Hi Sipos, Omar, You should use the following branches: libosmocore branch master libosmo-abis branch master osmo-trx branch fairwaves/master osmo-bts branch fairwaves/master ( use ./configure --enable-trx) openbsc branch fairwaves/master osmo-pcu branch master (use ./configure --enable-sysmocom-bts ) openggsn branch master Also if you use the same machine for sgsn, bts and pcu, you should change openbsc.cfg, instead of: gprs nsvc 0 local udp port 23000 gprs nsvc 0 remote udp port 23000 use different ports, for example: gprs nsvc 0 local udp port 5948 gprs nsvc 0 remote udp port 23000 -- Regards, Ivan Kluchnikov. http://fairwaves.ru From sipos.csaba at kvk.uni-obuda.hu Sun Jul 26 11:32:11 2015 From: sipos.csaba at kvk.uni-obuda.hu (Sipos Csaba) Date: Sun, 26 Jul 2015 13:32:11 +0200 (CEST) Subject: Using GPRS In-Reply-To: <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> References: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> <2082705239.393803.1437903342655.JavaMail.zimbra@kvk.uni-obuda.hu> <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: <576022131.398796.1437910331158.JavaMail.zimbra@kvk.uni-obuda.hu> One more thing: If I use the /configure --enable-sysmocom-bts parameter for the PCU, I will get the following message when I try to run it: Sun Jul 26 13:23:20 2015 DL1IF <0001> sysmo_sock.cpp:283 PCU-SYSMO socket has been connected Sun Jul 26 13:23:20 2015 DL1IF <0001> pcu_l1_if.cpp:318 Info indication received: Sun Jul 26 13:23:20 2015 DL1IF <0001> pcu_l1_if.cpp:321 BTS not available The fairwaves/master branch of Osmo-BTS is running fine with the master Osmo-TRX, Location updates are happening, but the PCU is not able to connect to the SGSN/BSC. Regards, Csaba ----- Eredeti ?zenet ----- Felad?: "Sipos Csaba" C?mzett: "Ivan Kluchnikov" , "Alexander Chemeris" M?solatot kap: "OpenBSC Mailing List" Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 12:30:50 T?rgy: Re: Using GPRS Dear Ivan, Alexander, I encountered the following issues: During compiling of OpenBSC (fairwaves/master), the pcap.h was missing. The configuration script was not detecting this missing file. "apt-get install libpcap-dev" solved this issue. The fairwaves/master branch of osmo-trx produces the following issue durign compilation: ================================ Making all in x86 make[3]: Entering directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' CC ../common/convolve_base.lo CC convert.lo In file included from convert.c:33:0: /usr/lib/gcc/x86_64-linux-gnu/4.8/include/smmintrin.h:31:3: error: #error "SSE4.1 instruction set not enabled" # error "SSE4.1 instruction set not enabled" ^ convert.c: In function '_sse_convert_si16_ps_16n': convert.c:49:3: warning: implicit declaration of function '_mm_cvtepi16_epi32' [-Wimplicit-function-declaration] m2 = _mm_cvtepi16_epi32(m0); ^ convert.c:49:6: error: incompatible types when assigning to type '__m128i' from type 'int' m2 = _mm_cvtepi16_epi32(m0); ^ convert.c:50:6: error: incompatible types when assigning to type '__m128i' from type 'int' m4 = _mm_cvtepi16_epi32(m1); ^ convert.c:53:6: error: incompatible types when assigning to type '__m128i' from type 'int' m3 = _mm_cvtepi16_epi32(m0); ^ convert.c:54:6: error: incompatible types when assigning to type '__m128i' from type 'int' m5 = _mm_cvtepi16_epi32(m1); ^ make[3]: *** [convert.lo] Error 1 make[3]: Leaving directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/root/new_openbsc/osmo-trx/Transceiver52M' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/root/new_openbsc/osmo-trx' make: *** [all] Error 2 ================================= Please note that the master branch of Osmo-TRX compiles just fine. Do any of you have an idea what could be the problem? Thanks! Csaba ----- Eredeti ?zenet ----- Felad?: "Sipos Csaba" C?mzett: "Ivan Kluchnikov" M?solatot kap: "OpenBSC Mailing List" Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 11:35:42 T?rgy: Re: Using GPRS Thanks Ivan, Will try that and report back. Regards, Csaba ----- Eredeti ?zenet ----- Felad?: "Ivan Kluchnikov" C?mzett: "Sipos Csaba" M?solatot kap: "Alexander Chemeris" , "OpenBSC Mailing List" Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 10:56:51 T?rgy: Re: Using GPRS Hi Sipos, Omar, You should use the following branches: libosmocore branch master libosmo-abis branch master osmo-trx branch fairwaves/master osmo-bts branch fairwaves/master ( use ./configure --enable-trx) openbsc branch fairwaves/master osmo-pcu branch master (use ./configure --enable-sysmocom-bts ) openggsn branch master Also if you use the same machine for sgsn, bts and pcu, you should change openbsc.cfg, instead of: gprs nsvc 0 local udp port 23000 gprs nsvc 0 remote udp port 23000 use different ports, for example: gprs nsvc 0 local udp port 5948 gprs nsvc 0 remote udp port 23000 -- Regards, Ivan Kluchnikov. http://fairwaves.ru From sipos.csaba at kvk.uni-obuda.hu Sun Jul 26 11:39:20 2015 From: sipos.csaba at kvk.uni-obuda.hu (Sipos Csaba) Date: Sun, 26 Jul 2015 13:39:20 +0200 (CEST) Subject: Using GPRS In-Reply-To: <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> References: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> <2082705239.393803.1437903342655.JavaMail.zimbra@kvk.uni-obuda.hu> <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: <146701592.398859.1437910760157.JavaMail.zimbra@kvk.uni-obuda.hu> Sorry for this last one, GPRS was not enabled in openbsc.conf. The PCU is now talking with the SGSN. But the compilation probem with Osmo-TRX fairwaves/master branch is still there. Regards, Csaba ----- Eredeti ?zenet ----- Felad?: "Sipos Csaba" C?mzett: "Ivan Kluchnikov" , "Alexander Chemeris" M?solatot kap: "OpenBSC Mailing List" Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 12:30:50 T?rgy: Re: Using GPRS Dear Ivan, Alexander, I encountered the following issues: During compiling of OpenBSC (fairwaves/master), the pcap.h was missing. The configuration script was not detecting this missing file. "apt-get install libpcap-dev" solved this issue. The fairwaves/master branch of osmo-trx produces the following issue durign compilation: ================================ Making all in x86 make[3]: Entering directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' CC ../common/convolve_base.lo CC convert.lo In file included from convert.c:33:0: /usr/lib/gcc/x86_64-linux-gnu/4.8/include/smmintrin.h:31:3: error: #error "SSE4.1 instruction set not enabled" # error "SSE4.1 instruction set not enabled" ^ convert.c: In function '_sse_convert_si16_ps_16n': convert.c:49:3: warning: implicit declaration of function '_mm_cvtepi16_epi32' [-Wimplicit-function-declaration] m2 = _mm_cvtepi16_epi32(m0); ^ convert.c:49:6: error: incompatible types when assigning to type '__m128i' from type 'int' m2 = _mm_cvtepi16_epi32(m0); ^ convert.c:50:6: error: incompatible types when assigning to type '__m128i' from type 'int' m4 = _mm_cvtepi16_epi32(m1); ^ convert.c:53:6: error: incompatible types when assigning to type '__m128i' from type 'int' m3 = _mm_cvtepi16_epi32(m0); ^ convert.c:54:6: error: incompatible types when assigning to type '__m128i' from type 'int' m5 = _mm_cvtepi16_epi32(m1); ^ make[3]: *** [convert.lo] Error 1 make[3]: Leaving directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/root/new_openbsc/osmo-trx/Transceiver52M' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/root/new_openbsc/osmo-trx' make: *** [all] Error 2 ================================= Please note that the master branch of Osmo-TRX compiles just fine. Do any of you have an idea what could be the problem? Thanks! Csaba ----- Eredeti ?zenet ----- Felad?: "Sipos Csaba" C?mzett: "Ivan Kluchnikov" M?solatot kap: "OpenBSC Mailing List" Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 11:35:42 T?rgy: Re: Using GPRS Thanks Ivan, Will try that and report back. Regards, Csaba ----- Eredeti ?zenet ----- Felad?: "Ivan Kluchnikov" C?mzett: "Sipos Csaba" M?solatot kap: "Alexander Chemeris" , "OpenBSC Mailing List" Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 10:56:51 T?rgy: Re: Using GPRS Hi Sipos, Omar, You should use the following branches: libosmocore branch master libosmo-abis branch master osmo-trx branch fairwaves/master osmo-bts branch fairwaves/master ( use ./configure --enable-trx) openbsc branch fairwaves/master osmo-pcu branch master (use ./configure --enable-sysmocom-bts ) openggsn branch master Also if you use the same machine for sgsn, bts and pcu, you should change openbsc.cfg, instead of: gprs nsvc 0 local udp port 23000 gprs nsvc 0 remote udp port 23000 use different ports, for example: gprs nsvc 0 local udp port 5948 gprs nsvc 0 remote udp port 23000 -- Regards, Ivan Kluchnikov. http://fairwaves.ru From Ivan.Kluchnikov at fairwaves.ru Sun Jul 26 12:00:28 2015 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Sun, 26 Jul 2015 15:00:28 +0300 Subject: Using GPRS In-Reply-To: <146701592.398859.1437910760157.JavaMail.zimbra@kvk.uni-obuda.hu> References: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> <2082705239.393803.1437903342655.JavaMail.zimbra@kvk.uni-obuda.hu> <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> <146701592.398859.1437910760157.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: Hi Sipos, Osmo-TRX master branch should be also fine for gprs, you can use it. Thank you for report, we will fix osmo-trx fairwaves/master branch soon. 2015-07-26 14:39 GMT+03:00 Sipos Csaba : > Sorry for this last one, GPRS was not enabled in openbsc.conf. > > The PCU is now talking with the SGSN. > > But the compilation probem with Osmo-TRX fairwaves/master branch is still > there. > > Regards, > Csaba > > ----- Eredeti ?zenet ----- > Felad?: "Sipos Csaba" > C?mzett: "Ivan Kluchnikov" , "Alexander > Chemeris" > M?solatot kap: "OpenBSC Mailing List" > Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 12:30:50 > T?rgy: Re: Using GPRS > > Dear Ivan, Alexander, > > I encountered the following issues: > > During compiling of OpenBSC (fairwaves/master), the pcap.h was missing. > The configuration script was not detecting this missing file. "apt-get > install libpcap-dev" solved this issue. > > The fairwaves/master branch of osmo-trx produces the following issue > durign compilation: > > ================================ > > Making all in x86 > make[3]: Entering directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' > CC ../common/convolve_base.lo > CC convert.lo > In file included from convert.c:33:0: > /usr/lib/gcc/x86_64-linux-gnu/4.8/include/smmintrin.h:31:3: error: #error > "SSE4.1 instruction set not enabled" > # error "SSE4.1 instruction set not enabled" > ^ > convert.c: In function '_sse_convert_si16_ps_16n': > convert.c:49:3: warning: implicit declaration of function > '_mm_cvtepi16_epi32' [-Wimplicit-function-declaration] > m2 = _mm_cvtepi16_epi32(m0); > ^ > convert.c:49:6: error: incompatible types when assigning to type '__m128i' > from type 'int' > m2 = _mm_cvtepi16_epi32(m0); > ^ > convert.c:50:6: error: incompatible types when assigning to type '__m128i' > from type 'int' > m4 = _mm_cvtepi16_epi32(m1); > ^ > convert.c:53:6: error: incompatible types when assigning to type '__m128i' > from type 'int' > m3 = _mm_cvtepi16_epi32(m0); > ^ > convert.c:54:6: error: incompatible types when assigning to type '__m128i' > from type 'int' > m5 = _mm_cvtepi16_epi32(m1); > ^ > make[3]: *** [convert.lo] Error 1 > make[3]: Leaving directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' > make[2]: *** [all-recursive] Error 1 > make[2]: Leaving directory `/root/new_openbsc/osmo-trx/Transceiver52M' > make[1]: *** [all-recursive] Error 1 > make[1]: Leaving directory `/root/new_openbsc/osmo-trx' > make: *** [all] Error 2 > > ================================= > > Please note that the master branch of Osmo-TRX compiles just fine. > > Do any of you have an idea what could be the problem? > > Thanks! > > Csaba > > ----- Eredeti ?zenet ----- > Felad?: "Sipos Csaba" > C?mzett: "Ivan Kluchnikov" > M?solatot kap: "OpenBSC Mailing List" > Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 11:35:42 > T?rgy: Re: Using GPRS > > Thanks Ivan, > > Will try that and report back. > > Regards, > Csaba > > ----- Eredeti ?zenet ----- > Felad?: "Ivan Kluchnikov" > C?mzett: "Sipos Csaba" > M?solatot kap: "Alexander Chemeris" , > "OpenBSC Mailing List" > Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 10:56:51 > T?rgy: Re: Using GPRS > > Hi Sipos, Omar, > > You should use the following branches: > > libosmocore branch master > > libosmo-abis branch master > > osmo-trx branch fairwaves/master > > osmo-bts branch fairwaves/master ( use ./configure --enable-trx) > > openbsc branch fairwaves/master > > osmo-pcu branch master (use ./configure --enable-sysmocom-bts ) > > openggsn branch master > > Also if you use the same machine for sgsn, bts and pcu, you should change > openbsc.cfg, instead of: > gprs nsvc 0 local udp port 23000 > gprs nsvc 0 remote udp port 23000 > use different ports, for example: > gprs nsvc 0 local udp port 5948 > gprs nsvc 0 remote udp port 23000 > > -- > Regards, > Ivan Kluchnikov. > http://fairwaves.ru > > -- Regards, Ivan Kluchnikov. http://fairwaves.ru -------------- next part -------------- An HTML attachment was scrubbed... URL: From sipos.csaba at kvk.uni-obuda.hu Sun Jul 26 18:02:24 2015 From: sipos.csaba at kvk.uni-obuda.hu (Sipos Csaba) Date: Sun, 26 Jul 2015 20:02:24 +0200 (CEST) Subject: Using GPRS In-Reply-To: References: <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> <2082705239.393803.1437903342655.JavaMail.zimbra@kvk.uni-obuda.hu> <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> <146701592.398859.1437910760157.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: <1181995749.412535.1437933744646.JavaMail.zimbra@kvk.uni-obuda.hu> I will try to give you as many feedback as possible. :-) I finally have a more or less working setup. At least there is no crash whatsoever, and the PS domain is working, the UE can attach, activate PDP, transfer data to some extent. For example when i tried to ping the TUN interface, I got 2500-2600ms latency. I tried with both the "A" and the "B" algorithm, it was pretty much the same. I seen a lot of PRACH happening, so I checked the radio parameters: With power=0 and rxgain=15 at ARFCN=885 I got -55dBm RSSI at the UE, and -40 -45dBm RSSI at the BTS. The freqency I use is completely clean, and I use a proper duplexer and an omni antenna. The UE is 2 meters a way, line of site. The SNR measured by the UE is around 20-22 dB in DL direction. The ms-power-loop was set to -15, the max MS power was 20dBm. So the RF part seems correct, and still I got these very high latencies. In comparison with OpenBTS and the same setup, I got around 350-500ms latency with multislot. Maybe the UE goes to IDLE too fast for a ping test? Regards, Csaba ----- Eredeti ?zenet ----- Felad?: "Ivan Kluchnikov" C?mzett: "Sipos Csaba" M?solatot kap: "Alexander Chemeris" , "OpenBSC Mailing List" Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 14:00:28 T?rgy: Re: Using GPRS Hi Sipos, Osmo-TRX master branch should be also fine for gprs, you can use it. Thank you for report, we will fix osmo-trx fairwaves/master branch soon. 2015-07-26 14:39 GMT+03:00 Sipos Csaba : > Sorry for this last one, GPRS was not enabled in openbsc.conf. > > The PCU is now talking with the SGSN. > > But the compilation probem with Osmo-TRX fairwaves/master branch is still > there. > > Regards, > Csaba > > ----- Eredeti ?zenet ----- > Felad?: "Sipos Csaba" > C?mzett: "Ivan Kluchnikov" , "Alexander > Chemeris" > M?solatot kap: "OpenBSC Mailing List" > Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 12:30:50 > T?rgy: Re: Using GPRS > > Dear Ivan, Alexander, > > I encountered the following issues: > > During compiling of OpenBSC (fairwaves/master), the pcap.h was missing. > The configuration script was not detecting this missing file. "apt-get > install libpcap-dev" solved this issue. > > The fairwaves/master branch of osmo-trx produces the following issue > durign compilation: > > ================================ > > Making all in x86 > make[3]: Entering directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' > CC ../common/convolve_base.lo > CC convert.lo > In file included from convert.c:33:0: > /usr/lib/gcc/x86_64-linux-gnu/4.8/include/smmintrin.h:31:3: error: #error > "SSE4.1 instruction set not enabled" > # error "SSE4.1 instruction set not enabled" > ^ > convert.c: In function '_sse_convert_si16_ps_16n': > convert.c:49:3: warning: implicit declaration of function > '_mm_cvtepi16_epi32' [-Wimplicit-function-declaration] > m2 = _mm_cvtepi16_epi32(m0); > ^ > convert.c:49:6: error: incompatible types when assigning to type '__m128i' > from type 'int' > m2 = _mm_cvtepi16_epi32(m0); > ^ > convert.c:50:6: error: incompatible types when assigning to type '__m128i' > from type 'int' > m4 = _mm_cvtepi16_epi32(m1); > ^ > convert.c:53:6: error: incompatible types when assigning to type '__m128i' > from type 'int' > m3 = _mm_cvtepi16_epi32(m0); > ^ > convert.c:54:6: error: incompatible types when assigning to type '__m128i' > from type 'int' > m5 = _mm_cvtepi16_epi32(m1); > ^ > make[3]: *** [convert.lo] Error 1 > make[3]: Leaving directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' > make[2]: *** [all-recursive] Error 1 > make[2]: Leaving directory `/root/new_openbsc/osmo-trx/Transceiver52M' > make[1]: *** [all-recursive] Error 1 > make[1]: Leaving directory `/root/new_openbsc/osmo-trx' > make: *** [all] Error 2 > > ================================= > > Please note that the master branch of Osmo-TRX compiles just fine. > > Do any of you have an idea what could be the problem? > > Thanks! > > Csaba > > ----- Eredeti ?zenet ----- > Felad?: "Sipos Csaba" > C?mzett: "Ivan Kluchnikov" > M?solatot kap: "OpenBSC Mailing List" > Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 11:35:42 > T?rgy: Re: Using GPRS > > Thanks Ivan, > > Will try that and report back. > > Regards, > Csaba > > ----- Eredeti ?zenet ----- > Felad?: "Ivan Kluchnikov" > C?mzett: "Sipos Csaba" > M?solatot kap: "Alexander Chemeris" , > "OpenBSC Mailing List" > Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 10:56:51 > T?rgy: Re: Using GPRS > > Hi Sipos, Omar, > > You should use the following branches: > > libosmocore branch master > > libosmo-abis branch master > > osmo-trx branch fairwaves/master > > osmo-bts branch fairwaves/master ( use ./configure --enable-trx) > > openbsc branch fairwaves/master > > osmo-pcu branch master (use ./configure --enable-sysmocom-bts ) > > openggsn branch master > > Also if you use the same machine for sgsn, bts and pcu, you should change > openbsc.cfg, instead of: > gprs nsvc 0 local udp port 23000 > gprs nsvc 0 remote udp port 23000 > use different ports, for example: > gprs nsvc 0 local udp port 5948 > gprs nsvc 0 remote udp port 23000 > > -- > Regards, > Ivan Kluchnikov. > http://fairwaves.ru > > -- Regards, Ivan Kluchnikov. http://fairwaves.ru From holger at freyther.de Sun Jul 26 19:13:07 2015 From: holger at freyther.de (Holger Freyther) Date: Sun, 26 Jul 2015 21:13:07 +0200 Subject: Using GPRS In-Reply-To: References: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> <2082705239.393803.1437903342655.JavaMail.zimbra@kvk.uni-obuda.hu> <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> <146701592.398859.1437910760157.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: > On 26 Jul 2015, at 14:00, Ivan Kluchnikov wrote: > > Hi Sipos, > > Osmo-TRX master branch should be also fine for gprs, you can use it. > Thank you for report, we will fix osmo-trx fairwaves/master branch soon. who is the maintainer of the osmo-trx branch? Why is there a need for a vendor branch? holger From tom at tsou.cc Mon Jul 27 17:35:52 2015 From: tom at tsou.cc (Tom Tsou) Date: Mon, 27 Jul 2015 10:35:52 -0700 Subject: Using GPRS In-Reply-To: References: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> <2082705239.393803.1437903342655.JavaMail.zimbra@kvk.uni-obuda.hu> <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> <146701592.398859.1437910760157.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: On Sun, Jul 26, 2015 at 12:13 PM, Holger Freyther wrote: > who is the maintainer of the osmo-trx branch? Why is there a need for a > vendor branch? I'm clearly behind on this, and the reason for many patches not being in master is lack of time for testing and patch review on my part. More generally, though, there is a vendor branch for Fairwaves specific changes that may or may not have been tested against other use cases (e.g. OpenBTS support). Similarly, are there reasons for vendor branches for osmo-bts and openbsc? I think the concept of vendor branches is ok so long as there is a path toward merging into master. -TT From tom at tsou.cc Mon Jul 27 17:39:31 2015 From: tom at tsou.cc (Tom Tsou) Date: Mon, 27 Jul 2015 10:39:31 -0700 Subject: Using GPRS In-Reply-To: <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> References: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> <2082705239.393803.1437903342655.JavaMail.zimbra@kvk.uni-obuda.hu> <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: On Sun, Jul 26, 2015 at 3:30 AM, Sipos Csaba wrote: > The fairwaves/master branch of osmo-trx produces the following issue durign compilation: > > ================================ > > Making all in x86 > make[3]: Entering directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' > CC ../common/convolve_base.lo > CC convert.lo > In file included from convert.c:33:0: > /usr/lib/gcc/x86_64-linux-gnu/4.8/include/smmintrin.h:31:3: error: #error "SSE4.1 instruction set not enabled" Try reverting this patch. e7c25a3677bbe4 "transceiver/x86: don?t use -march=native to build x86 specialized code" -TT From ciaby at autistici.org Tue Jul 28 13:19:04 2015 From: ciaby at autistici.org (Ciaby) Date: Tue, 28 Jul 2015 15:19:04 +0200 Subject: [PATCH 2/2] nitb: Add a mode to not use TMSI for normal operation In-Reply-To: <1436873554-12616-2-git-send-email-holger@freyther.de> References: <1436873554-12616-1-git-send-email-holger@freyther.de> <1436873554-12616-2-git-send-email-holger@freyther.de> Message-ID: <55B78148.4010608@autistici.org> On 07/14/2015 01:32 PM, Holger Hans Peter Freyther wrote: > From: Holger Hans Peter Freyther > > In case foreign simcards are used we can not do authentication > and ciphering. In case a TMSI is re-used too early and we do > page using TMSI we can't know which of the two MS is responding > to us. We could change the "secure channel" routine to ask for > the IMSI and only then stop the paging. > > As we don't have ciphering there is not much use in using the > TMSI. Add a mode "no assign-tmsi" that will not assign the TMSI > during LU. Now CM Service Request and Paging Response will > work using the IMSI. There can't be a clash with that. [...] > static int config_write_nitb(struct vty *vty) > { > struct gsm_network *gsmnet = gsmnet_from_vty(vty); > vty_out(vty, "nitb%s", VTY_NEWLINE); > vty_out(vty, " %ssubscriber-create-on-demand%s", > gsmnet->create_subscriber ? "" : "no ", VTY_NEWLINE); > + vty_out(vty, " %suse-tmsi%s", > + gsmnet->avoid_tmsi ? "no" : "", VTY_NEWLINE); > return CMD_SUCCESS; > } This part is broken. Whenever you try to set it it will put "use-tmsi" instead of "assign-tmsi". The moment you save it and restart, it barfs on the "use-tmsi" line. If you put a no in front, it will be saved as "nouse-tmsi". I fixed both problems with the attached patch. Cheers Ciaby -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-nitb-Rename-use-tmsi-into-assign-tmsi-add-a-missing-.patch Type: text/x-patch Size: 994 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: OpenPGP digital signature URL: From holger at freyther.de Tue Jul 28 14:51:47 2015 From: holger at freyther.de (Holger Freyther) Date: Tue, 28 Jul 2015 16:51:47 +0200 Subject: [PATCH 2/2] nitb: Add a mode to not use TMSI for normal operation In-Reply-To: <55B78148.4010608@autistici.org> References: <1436873554-12616-1-git-send-email-holger@freyther.de> <1436873554-12616-2-git-send-email-holger@freyther.de> <55B78148.4010608@autistici.org> Message-ID: <5E50B264-201D-4D45-8C1E-124F2EB1F404@freyther.de> > On 28 Jul 2015, at 15:19, Ciaby wrote: > > This part is broken. Whenever you try to set it it will put "use-tmsi" > instead of "assign-tmsi". The moment you save it and restart, it barfs > on the "use-tmsi" line. If you put a no in front, it will be saved as > "nouse-tmsi". I fixed both problems with the attached patch. oops and sorry, when trying to move quickly. The bigger question is why this passed on the CI. I always write the yes/no case so it should fail. Did your reports on wrongly connected calls go down? holger From alexander.chemeris at gmail.com Wed Jul 29 00:39:31 2015 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Tue, 28 Jul 2015 20:39:31 -0400 Subject: Using GPRS In-Reply-To: References: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> <2082705239.393803.1437903342655.JavaMail.zimbra@kvk.uni-obuda.hu> <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> <146701592.398859.1437910760157.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: Hi Holger, On Sun, Jul 26, 2015 at 3:13 PM, Holger Freyther wrote: >> On 26 Jul 2015, at 14:00, Ivan Kluchnikov wrote: >> Osmo-TRX master branch should be also fine for gprs, you can use it. >> Thank you for report, we will fix osmo-trx fairwaves/master branch soon. > > who is the maintainer of the osmo-trx branch? Why is there a need for a > vendor branch? Thomas is the maintainer of the 'master'. As he explained, most of the fairwaves/maser branch there are patches pending his review plus a couple patches specific to the way we package software for the use in UmSITEs. -- Regards, Alexander Chemeris. CEO, Fairwaves, Inc. https://fairwaves.co From alexander.chemeris at gmail.com Wed Jul 29 00:40:53 2015 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Tue, 28 Jul 2015 20:40:53 -0400 Subject: Using GPRS In-Reply-To: References: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> <2082705239.393803.1437903342655.JavaMail.zimbra@kvk.uni-obuda.hu> <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> <146701592.398859.1437910760157.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: On Mon, Jul 27, 2015 at 1:35 PM, Tom Tsou wrote: > On Sun, Jul 26, 2015 at 12:13 PM, Holger Freyther wrote: >> who is the maintainer of the osmo-trx branch? Why is there a need for a >> vendor branch? > > I'm clearly behind on this, and the reason for many patches not being > in master is lack of time for testing and patch review on my part. A kind reminder that we would appreciate if you could review/merge them. :) -- Regards, Alexander Chemeris. CEO, Fairwaves, Inc. https://fairwaves.co From alexander.chemeris at gmail.com Wed Jul 29 00:47:09 2015 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Tue, 28 Jul 2015 20:47:09 -0400 Subject: Using GPRS In-Reply-To: References: <637338649.324404.1437762397641.JavaMail.zimbra@kvk.uni-obuda.hu> <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> <2082705239.393803.1437903342655.JavaMail.zimbra@kvk.uni-obuda.hu> <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: Hi Thomas, On Mon, Jul 27, 2015 at 1:39 PM, Tom Tsou wrote: > On Sun, Jul 26, 2015 at 3:30 AM, Sipos Csaba > wrote: >> The fairwaves/master branch of osmo-trx produces the following issue durign compilation: >> >> ================================ >> >> Making all in x86 >> make[3]: Entering directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' >> CC ../common/convolve_base.lo >> CC convert.lo >> In file included from convert.c:33:0: >> /usr/lib/gcc/x86_64-linux-gnu/4.8/include/smmintrin.h:31:3: error: #error "SSE4.1 instruction set not enabled" > > Try reverting this patch. > > e7c25a3677bbe4 "transceiver/x86: don?t use -march=native to build x86 > specialized code" Btw, I wanted to discuss the best way to move this forward. We found that osmo-trx crashes with "illegal instruction" if we build on Core i7, but run on Atom even if we disable automatic CPU detection and manually specify HAVE_SSE3. We had to remove "-march=native" to make it work. But it seems that unconditionally removing it breaks the build with automatic CPU detection enabled. What do you think is the best way to get it working in both situations? -- Regards, Alexander Chemeris. CEO, Fairwaves, Inc. https://fairwaves.co From alexander.chemeris at gmail.com Wed Jul 29 01:25:55 2015 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Tue, 28 Jul 2015 21:25:55 -0400 Subject: Using GPRS In-Reply-To: <1181995749.412535.1437933744646.JavaMail.zimbra@kvk.uni-obuda.hu> References: <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> <2082705239.393803.1437903342655.JavaMail.zimbra@kvk.uni-obuda.hu> <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> <146701592.398859.1437910760157.JavaMail.zimbra@kvk.uni-obuda.hu> <1181995749.412535.1437933744646.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: Hi Sipos, A couple general notes with a remark that I haven't touched the GPRS code for a long while: Power control loop for GPRS is separate from the power loop for the CS domain. IIRC it should be done in PCU, but it's not implemented yet. So right now IIRC the MS should be in an open loop power control mode, deducing its Tx power from its Rx level. I can't comment on the dB values, because I've never used B200. But if you use fairwaves/master branch, it can detect clipping when the signal is of too high power (check the logs). You can also enable debug logging level for osmo-trx to assess demodulation quality visually (there should be few to none '-' in the demodulated bursts). If you see the demodulation is perfect, but the issue is still there - you have to dig the layers upwards. On Sun, Jul 26, 2015 at 2:02 PM, Sipos Csaba wrote: > I will try to give you as many feedback as possible. :-) > > I finally have a more or less working setup. At least there is no crash whatsoever, and the PS domain is working, the UE can attach, activate PDP, transfer data to some extent. > > For example when i tried to ping the TUN interface, I got 2500-2600ms latency. I tried with both the "A" and the "B" algorithm, it was pretty much the same. I seen a lot of PRACH happening, so I checked the radio parameters: > > With power=0 and rxgain=15 at ARFCN=885 I got -55dBm RSSI at the UE, and -40 -45dBm RSSI at the BTS. The freqency I use is completely clean, and I use a proper duplexer and an omni antenna. The UE is 2 meters a way, line of site. The SNR measured by the UE is around 20-22 dB in DL direction. The ms-power-loop was set to -15, the max MS power was 20dBm. > > So the RF part seems correct, and still I got these very high latencies. In comparison with OpenBTS and the same setup, I got around 350-500ms latency with multislot. > > Maybe the UE goes to IDLE too fast for a ping test? > > Regards, > Csaba > > ----- Eredeti ?zenet ----- > Felad?: "Ivan Kluchnikov" > C?mzett: "Sipos Csaba" > M?solatot kap: "Alexander Chemeris" , "OpenBSC Mailing List" > Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 14:00:28 > T?rgy: Re: Using GPRS > > Hi Sipos, > > Osmo-TRX master branch should be also fine for gprs, you can use it. > Thank you for report, we will fix osmo-trx fairwaves/master branch soon. > > 2015-07-26 14:39 GMT+03:00 Sipos Csaba : > >> Sorry for this last one, GPRS was not enabled in openbsc.conf. >> >> The PCU is now talking with the SGSN. >> >> But the compilation probem with Osmo-TRX fairwaves/master branch is still >> there. >> >> Regards, >> Csaba >> >> ----- Eredeti ?zenet ----- >> Felad?: "Sipos Csaba" >> C?mzett: "Ivan Kluchnikov" , "Alexander >> Chemeris" >> M?solatot kap: "OpenBSC Mailing List" >> Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 12:30:50 >> T?rgy: Re: Using GPRS >> >> Dear Ivan, Alexander, >> >> I encountered the following issues: >> >> During compiling of OpenBSC (fairwaves/master), the pcap.h was missing. >> The configuration script was not detecting this missing file. "apt-get >> install libpcap-dev" solved this issue. >> >> The fairwaves/master branch of osmo-trx produces the following issue >> durign compilation: >> >> ================================ >> >> Making all in x86 >> make[3]: Entering directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' >> CC ../common/convolve_base.lo >> CC convert.lo >> In file included from convert.c:33:0: >> /usr/lib/gcc/x86_64-linux-gnu/4.8/include/smmintrin.h:31:3: error: #error >> "SSE4.1 instruction set not enabled" >> # error "SSE4.1 instruction set not enabled" >> ^ >> convert.c: In function '_sse_convert_si16_ps_16n': >> convert.c:49:3: warning: implicit declaration of function >> '_mm_cvtepi16_epi32' [-Wimplicit-function-declaration] >> m2 = _mm_cvtepi16_epi32(m0); >> ^ >> convert.c:49:6: error: incompatible types when assigning to type '__m128i' >> from type 'int' >> m2 = _mm_cvtepi16_epi32(m0); >> ^ >> convert.c:50:6: error: incompatible types when assigning to type '__m128i' >> from type 'int' >> m4 = _mm_cvtepi16_epi32(m1); >> ^ >> convert.c:53:6: error: incompatible types when assigning to type '__m128i' >> from type 'int' >> m3 = _mm_cvtepi16_epi32(m0); >> ^ >> convert.c:54:6: error: incompatible types when assigning to type '__m128i' >> from type 'int' >> m5 = _mm_cvtepi16_epi32(m1); >> ^ >> make[3]: *** [convert.lo] Error 1 >> make[3]: Leaving directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' >> make[2]: *** [all-recursive] Error 1 >> make[2]: Leaving directory `/root/new_openbsc/osmo-trx/Transceiver52M' >> make[1]: *** [all-recursive] Error 1 >> make[1]: Leaving directory `/root/new_openbsc/osmo-trx' >> make: *** [all] Error 2 >> >> ================================= >> >> Please note that the master branch of Osmo-TRX compiles just fine. >> >> Do any of you have an idea what could be the problem? >> >> Thanks! >> >> Csaba >> >> ----- Eredeti ?zenet ----- >> Felad?: "Sipos Csaba" >> C?mzett: "Ivan Kluchnikov" >> M?solatot kap: "OpenBSC Mailing List" >> Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 11:35:42 >> T?rgy: Re: Using GPRS >> >> Thanks Ivan, >> >> Will try that and report back. >> >> Regards, >> Csaba >> >> ----- Eredeti ?zenet ----- >> Felad?: "Ivan Kluchnikov" >> C?mzett: "Sipos Csaba" >> M?solatot kap: "Alexander Chemeris" , >> "OpenBSC Mailing List" >> Elk?ld?tt ?zenetek: Vas?rnap, 2015. J?lius 26. 10:56:51 >> T?rgy: Re: Using GPRS >> >> Hi Sipos, Omar, >> >> You should use the following branches: >> >> libosmocore branch master >> >> libosmo-abis branch master >> >> osmo-trx branch fairwaves/master >> >> osmo-bts branch fairwaves/master ( use ./configure --enable-trx) >> >> openbsc branch fairwaves/master >> >> osmo-pcu branch master (use ./configure --enable-sysmocom-bts ) >> >> openggsn branch master >> >> Also if you use the same machine for sgsn, bts and pcu, you should change >> openbsc.cfg, instead of: >> gprs nsvc 0 local udp port 23000 >> gprs nsvc 0 remote udp port 23000 >> use different ports, for example: >> gprs nsvc 0 local udp port 5948 >> gprs nsvc 0 remote udp port 23000 >> >> -- >> Regards, >> Ivan Kluchnikov. >> http://fairwaves.ru >> >> > > > -- > Regards, > Ivan Kluchnikov. > http://fairwaves.ru -- Regards, Alexander Chemeris. CEO, Fairwaves, Inc. https://fairwaves.co From ralph at schmid.xxx Wed Jul 29 04:52:10 2015 From: ralph at schmid.xxx (Ralph A. Schmid, dk5ras) Date: Wed, 29 Jul 2015 06:52:10 +0200 Subject: Using GPRS In-Reply-To: References: <708982557.334479.1437777029114.JavaMail.zimbra@kvk.uni-obuda.hu> <2082705239.393803.1437903342655.JavaMail.zimbra@kvk.uni-obuda.hu> <696067074.395622.1437906650312.JavaMail.zimbra@kvk.uni-obuda.hu> <146701592.398859.1437910760157.JavaMail.zimbra@kvk.uni-obuda.hu> <1181995749.412535.1437933744646.JavaMail.zimbra@kvk.uni-obuda.hu> Message-ID: <000301d0c9ba$57c56a40$07503ec0$@schmid.xxx> Hi all, I have experienced this open power control loop a tedious beast when using OpenBTS - it is a PITA to find settings that work reliably. Ralph. -----Original Message----- From: OpenBSC [mailto:openbsc-bounces at lists.osmocom.org] On Behalf Of Alexander Chemeris Sent: Wednesday, July 29, 2015 03:26 To: Sipos Csaba Cc: Ivan Kluchnikov; OpenBSC Mailing List Subject: Re: Using GPRS Hi Sipos, A couple general notes with a remark that I haven't touched the GPRS code for a long while: Power control loop for GPRS is separate from the power loop for the CS domain. IIRC it should be done in PCU, but it's not implemented yet. So right now IIRC the MS should be in an open loop power control mode, deducing its Tx power from its Rx level. I can't comment on the dB values, because I've never used B200. But if you use fairwaves/master branch, it can detect clipping when the signal is of too high power (check the logs). You can also enable debug logging level for osmo-trx to assess demodulation quality visually (there should be few to none '-' in the demodulated bursts). If you see the demodulation is perfect, but the issue is still there - you have to dig the layers upwards. On Sun, Jul 26, 2015 at 2:02 PM, Sipos Csaba wrote: > I will try to give you as many feedback as possible. :-) > > I finally have a more or less working setup. At least there is no crash whatsoever, and the PS domain is working, the UE can attach, activate PDP, transfer data to some extent. > > For example when i tried to ping the TUN interface, I got 2500-2600ms latency. I tried with both the "A" and the "B" algorithm, it was pretty much the same. I seen a lot of PRACH happening, so I checked the radio parameters: > > With power=0 and rxgain=15 at ARFCN=885 I got -55dBm RSSI at the UE, and -40 -45dBm RSSI at the BTS. The freqency I use is completely clean, and I use a proper duplexer and an omni antenna. The UE is 2 meters a way, line of site. The SNR measured by the UE is around 20-22 dB in DL direction. The ms-power-loop was set to -15, the max MS power was 20dBm. > > So the RF part seems correct, and still I got these very high latencies. In comparison with OpenBTS and the same setup, I got around 350-500ms latency with multislot. > > Maybe the UE goes to IDLE too fast for a ping test? > > Regards, > Csaba > > ----- Eredeti ?zenet ----- > Felad?: "Ivan Kluchnikov" > C?mzett: "Sipos Csaba" M?solatot kap: > "Alexander Chemeris" , "OpenBSC Mailing > List" Elk?ld?tt ?zenetek: Vas?rnap, 2015. > J?lius 26. 14:00:28 > T?rgy: Re: Using GPRS > > Hi Sipos, > > Osmo-TRX master branch should be also fine for gprs, you can use it. > Thank you for report, we will fix osmo-trx fairwaves/master branch soon. > > 2015-07-26 14:39 GMT+03:00 Sipos Csaba : > >> Sorry for this last one, GPRS was not enabled in openbsc.conf. >> >> The PCU is now talking with the SGSN. >> >> But the compilation probem with Osmo-TRX fairwaves/master branch is >> still there. >> >> Regards, >> Csaba >> >> ----- Eredeti ?zenet ----- >> Felad?: "Sipos Csaba" >> C?mzett: "Ivan Kluchnikov" , "Alexander >> Chemeris" M?solatot kap: "OpenBSC >> Mailing List" Elk?ld?tt ?zenetek: >> Vas?rnap, 2015. J?lius 26. 12:30:50 >> T?rgy: Re: Using GPRS >> >> Dear Ivan, Alexander, >> >> I encountered the following issues: >> >> During compiling of OpenBSC (fairwaves/master), the pcap.h was missing. >> The configuration script was not detecting this missing file. >> "apt-get install libpcap-dev" solved this issue. >> >> The fairwaves/master branch of osmo-trx produces the following issue >> durign compilation: >> >> ================================ >> >> Making all in x86 >> make[3]: Entering directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' >> CC ../common/convolve_base.lo >> CC convert.lo >> In file included from convert.c:33:0: >> /usr/lib/gcc/x86_64-linux-gnu/4.8/include/smmintrin.h:31:3: error: >> #error >> "SSE4.1 instruction set not enabled" >> # error "SSE4.1 instruction set not enabled" >> ^ >> convert.c: In function '_sse_convert_si16_ps_16n': >> convert.c:49:3: warning: implicit declaration of function >> '_mm_cvtepi16_epi32' [-Wimplicit-function-declaration] >> m2 = _mm_cvtepi16_epi32(m0); >> ^ >> convert.c:49:6: error: incompatible types when assigning to type '__m128i' >> from type 'int' >> m2 = _mm_cvtepi16_epi32(m0); >> ^ >> convert.c:50:6: error: incompatible types when assigning to type '__m128i' >> from type 'int' >> m4 = _mm_cvtepi16_epi32(m1); >> ^ >> convert.c:53:6: error: incompatible types when assigning to type '__m128i' >> from type 'int' >> m3 = _mm_cvtepi16_epi32(m0); >> ^ >> convert.c:54:6: error: incompatible types when assigning to type '__m128i' >> from type 'int' >> m5 = _mm_cvtepi16_epi32(m1); >> ^ >> make[3]: *** [convert.lo] Error 1 >> make[3]: Leaving directory `/root/new_openbsc/osmo-trx/Transceiver52M/x86' >> make[2]: *** [all-recursive] Error 1 >> make[2]: Leaving directory `/root/new_openbsc/osmo-trx/Transceiver52M' >> make[1]: *** [all-recursive] Error 1 >> make[1]: Leaving directory `/root/new_openbsc/osmo-trx' >> make: *** [all] Error 2 >> >> ================================= >> >> Please note that the master branch of Osmo-TRX compiles just fine. >> >> Do any of you have an idea what could be the problem? >> >> Thanks! >> >> Csaba >> >> ----- Eredeti ?zenet ----- >> Felad?: "Sipos Csaba" >> C?mzett: "Ivan Kluchnikov" M?solatot >> kap: "OpenBSC Mailing List" Elk?ld?tt >> ?zenetek: Vas?rnap, 2015. J?lius 26. 11:35:42 >> T?rgy: Re: Using GPRS >> >> Thanks Ivan, >> >> Will try that and report back. >> >> Regards, >> Csaba >> >> ----- Eredeti ?zenet ----- >> Felad?: "Ivan Kluchnikov" >> C?mzett: "Sipos Csaba" M?solatot kap: >> "Alexander Chemeris" , "OpenBSC Mailing >> List" Elk?ld?tt ?zenetek: Vas?rnap, 2015. >> J?lius 26. 10:56:51 >> T?rgy: Re: Using GPRS >> >> Hi Sipos, Omar, >> >> You should use the following branches: >> >> libosmocore branch master >> >> libosmo-abis branch master >> >> osmo-trx branch fairwaves/master >> >> osmo-bts branch fairwaves/master ( use ./configure --enable-trx) >> >> openbsc branch fairwaves/master >> >> osmo-pcu branch master (use ./configure --enable-sysmocom-bts ) >> >> openggsn branch master >> >> Also if you use the same machine for sgsn, bts and pcu, you should >> change openbsc.cfg, instead of: >> gprs nsvc 0 local udp port 23000 >> gprs nsvc 0 remote udp port 23000 >> use different ports, for example: >> gprs nsvc 0 local udp port 5948 >> gprs nsvc 0 remote udp port 23000 >> >> -- >> Regards, >> Ivan Kluchnikov. >> http://fairwaves.ru >> >> > > > -- > Regards, > Ivan Kluchnikov. > http://fairwaves.ru -- Regards, Alexander Chemeris. CEO, Fairwaves, Inc. https://fairwaves.co From ciaby at autistici.org Wed Jul 29 15:44:04 2015 From: ciaby at autistici.org (Ciaby) Date: Wed, 29 Jul 2015 17:44:04 +0200 Subject: [PATCH 2/2] nitb: Add a mode to not use TMSI for normal operation In-Reply-To: <5E50B264-201D-4D45-8C1E-124F2EB1F404@freyther.de> References: <1436873554-12616-1-git-send-email-holger@freyther.de> <1436873554-12616-2-git-send-email-holger@freyther.de> <55B78148.4010608@autistici.org> <5E50B264-201D-4D45-8C1E-124F2EB1F404@freyther.de> Message-ID: <55B8F4C4.1010509@autistici.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On 07/28/2015 04:51 PM, Holger Freyther wrote: > >> On 28 Jul 2015, at 15:19, Ciaby wrote: >> >> This part is broken. Whenever you try to set it it will put >> "use-tmsi" instead of "assign-tmsi". The moment you save it and >> restart, it barfs on the "use-tmsi" line. If you put a no in >> front, it will be saved as "nouse-tmsi". I fixed both problems >> with the attached patch. > > oops and sorry, when trying to move quickly. The bigger question is > why this passed on the CI. I always write the yes/no case so it > should fail. > > Did your reports on wrongly connected calls go down? I just deployed a new version of OpenBSC with the latest fixes. I'll let you know soon the results :) Cheers Ciaby -----BEGIN PGP SIGNATURE----- iQIcBAEBCgAGBQJVuPTCAAoJEPU83OtbD4fQeGEP+gPlMW1aU48smkt/dQkIE55e ePxLuFf/gJXvWkX/I3KO2PtswAUUnHULByMofKtTrWO8TD1NDG6pOwYn8Gj0S/T+ sB8PuvzqCergUnoZHeio7Jz17esIha3uAtIjuWcbQcO18Vo9XIa6KXl1GENq/82t 4/KdvmDFBHl1O5UweABJgGVfPcHWr0cdZtj3cFlXGsLBDpBDfjQ8cGFtpNfPTW00 bOp68xxFuxLZAShb+uSPaNhcx62i/hOoTCi9818HqFbuBddj8z4nIoP6IB1u9dwh stk42DN1GGRn1Nb95N4A2yVZq/ehhcxGxcCHO3D+izgr5sYsLKgYHbe8ATw58GDx PNultYG8ejCxt4sBPNyeFjhA/QjNDm+Oq6bcBXG7JqWffAKix57myU6S9HdHxQDX b7Zj0oUFhHVBRTgqgPxbzYz7A9bM+nfp3a76pFOH2rOozflQLXa25Da6s/ImS0Ft kuoGn9VzTMIZkTfnsiPrHdJurINUDnzl1UJUi3GuvhUepMixRIWZk+9vqwAxsyu9 ddgHGOego4g0exHptmGr3FJ5zF1tDfkGFCZFrR+Sj/t89VTCrS0bGONguMfb2f8i Mt2XjQ/IkEQX4KqpiHURv75OmwcglqP+nEHi1sMS8nIL5PkoYJctouKqQ861snIP to5FgDM0hvpIqyzay/QT =bOWp -----END PGP SIGNATURE----- From max.suraev at fairwaves.co Wed Jul 29 18:20:28 2015 From: max.suraev at fairwaves.co (Max) Date: Wed, 29 Jul 2015 20:20:28 +0200 Subject: [PATCH 1/3] use non-vararg functions if possible Message-ID: <1438194030-6423-1-git-send-email-max.suraev@fairwaves.co> Signed-off-by: Max --- openbsc/src/libmsc/db.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 428f99b..035202d 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -301,7 +301,7 @@ static int update_db_revision_3(void) dbi_result_free(result); /* Cycle through old messages and convert them to the new format */ - result = dbi_conn_queryf(conn, "SELECT * FROM SMS_3"); + result = dbi_conn_query(conn, "SELECT * FROM SMS_3"); if (!result) { LOGP(DDB, LOGL_ERROR, "Failed fetch messages from the old SMS table (upgrade from rev 3).\n"); @@ -1095,8 +1095,8 @@ int db_subscriber_list_active(void (*cb)(struct gsm_subscriber*,void*), void *cl { dbi_result result; - result = dbi_conn_queryf(conn, - "SELECT * from Subscriber WHERE LAC != 0 AND authorized = 1"); + result = dbi_conn_query(conn, + "SELECT * from Subscriber WHERE LAC != 0 AND authorized = 1"); if (!result) { LOGP(DDB, LOGL_ERROR, "Failed to list active subscribers\n"); return -1; -- 2.1.4 From max.suraev at fairwaves.co Wed Jul 29 18:20:29 2015 From: max.suraev at fairwaves.co (Max) Date: Wed, 29 Jul 2015 20:20:29 +0200 Subject: [PATCH 2/3] use thread-safe DBI interface instead of deprecated one In-Reply-To: <1438194030-6423-1-git-send-email-max.suraev@fairwaves.co> References: <1438194030-6423-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <1438194030-6423-2-git-send-email-max.suraev@fairwaves.co> Signed-off-by: Max --- debian/control | 2 +- openbsc/configure.ac | 1 + openbsc/src/libmsc/db.c | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/debian/control b/debian/control index ad0cc89..af305f9 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: openbsc Section: net Priority: optional Maintainer: Harald Welte -Build-Depends: debhelper (>= 7.0.0~), autotools-dev, pkg-config, libgtp0-dev, libosmocore-dev, libosmo-sccp-dev, libdbi0-dev, dh-autoreconf, libosmo-abis-dev, libosmo-netif-dev, libdbd-sqlite3, libpcap-dev +Build-Depends: debhelper (>= 7.0.0~), autotools-dev, pkg-config, libgtp0-dev, libosmocore-dev, libosmo-sccp-dev, libdbi-dev (>= 0.9.0), dh-autoreconf, libosmo-abis-dev, libosmo-netif-dev, libdbd-sqlite3, libpcap-dev Standards-Version: 3.8.4 Homepage: http://openbsc.osmocom.org/ Vcs-Git: git://bs11-abis.gnumonks.org/openbsc.git diff --git a/openbsc/configure.ac b/openbsc/configure.ac index 0ebb041..c07467e 100644 --- a/openbsc/configure.ac +++ b/openbsc/configure.ac @@ -27,6 +27,7 @@ PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.7.0) PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.2.0) PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 0.6.4) PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.0.1) +PKG_CHECK_MODULES(LIBDBI, dbi >= 0.9.0) # Enabke/disable the NAT? AC_ARG_ENABLE([nat], [AS_HELP_STRING([--enable-nat], [Build the BSC NAT. Requires SCCP])], diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 035202d..9b0ce43 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -44,6 +44,7 @@ void subscr_direct_free(struct gsm_subscriber *subscr); static char *db_basename = NULL; static char *db_dirname = NULL; static dbi_conn conn; +static dbi_inst dbi_instance = 0; #define SCHEMA_REVISION "4" @@ -425,9 +426,9 @@ static int db_configure(void) int db_init(const char *name) { - dbi_initialize(NULL); + dbi_initialize_r(NULL, &dbi_instance); - conn = dbi_conn_new("sqlite3"); + conn = dbi_conn_new_r("sqlite3", dbi_instance); if (conn == NULL) { LOGP(DDB, LOGL_FATAL, "Failed to create connection.\n"); return 1; @@ -491,7 +492,7 @@ int db_prepare(void) int db_fini(void) { dbi_conn_close(conn); - dbi_shutdown(); + dbi_shutdown_r(dbi_instance); free(db_dirname); free(db_basename); -- 2.1.4 From max.suraev at fairwaves.co Wed Jul 29 18:20:30 2015 From: max.suraev at fairwaves.co (Max) Date: Wed, 29 Jul 2015 20:20:30 +0200 Subject: [PATCH 3/3] add SQL tracing debug facility In-Reply-To: <1438194030-6423-1-git-send-email-max.suraev@fairwaves.co> References: <1438194030-6423-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <1438194030-6423-3-git-send-email-max.suraev@fairwaves.co> Signed-off-by: Max --- openbsc/include/openbsc/debug.h | 1 + openbsc/src/libcommon/debug.c | 5 +++ openbsc/src/libmsc/db.c | 97 ++++++++++++++++++++++------------------- 3 files changed, 58 insertions(+), 45 deletions(-) diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h index 19d8fc2..658483a 100644 --- a/openbsc/include/openbsc/debug.h +++ b/openbsc/include/openbsc/debug.h @@ -23,6 +23,7 @@ enum { DMGCP, DHO, DDB, + DSQL, DREF, DGPRS, DNS, diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c index 7fb3ecb..00a9476 100644 --- a/openbsc/src/libcommon/debug.c +++ b/openbsc/src/libcommon/debug.c @@ -115,6 +115,11 @@ static const struct log_info_cat default_categories[] = { .description = "Database Layer", .enabled = 1, .loglevel = LOGL_NOTICE, }, + [DSQL] = { + .name = "DSQL", + .description = "SQL Queries Tracing", + .enabled = 0, .loglevel = LOGL_DEBUG, + }, [DREF] = { .name = "DREF", .description = "Reference Counting", diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 9b0ce43..d544ec4 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -185,6 +185,13 @@ void db_error_func(dbi_conn conn, void *data) osmo_log_backtrace(DDB, LOGL_ERROR); } +/* Use macro instead of vararg function because recursive vararg use is impossible. + ##__VA_ARGS__ extension is not used in order to catch useless calls to dbi_conn_queryf() + instead of dbi_conn_query() +*/ +#define trace_dbi_conn_queryf(c, f, ...) \ + dbi_conn_queryf(c, f, __VA_ARGS__); do { LOGP(DSQL, LOGL_DEBUG, f "\n", __VA_ARGS__); } while(0) + static int update_db_revision_2(void) { dbi_result result; @@ -507,7 +514,7 @@ struct gsm_subscriber *db_create_subscriber(const char *imsi) /* Is this subscriber known in the db? */ subscr = db_get_subscriber(GSM_SUBSCRIBER_IMSI, imsi); if (subscr) { - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "UPDATE Subscriber set updated = datetime('now') " "WHERE imsi = %s " , imsi); if (!result) @@ -521,7 +528,7 @@ struct gsm_subscriber *db_create_subscriber(const char *imsi) if (!subscr) return NULL; subscr->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "INSERT INTO Subscriber " "(imsi, created, updated) " "VALUES " @@ -548,7 +555,7 @@ static int get_equipment_by_subscr(struct gsm_subscriber *subscr) const unsigned char *cm2, *cm3; struct gsm_equipment *equip = &subscr->equipment; - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "SELECT Equipment.* " "FROM Equipment JOIN EquipmentWatch ON " "EquipmentWatch.equipment_id=Equipment.id " @@ -597,7 +604,7 @@ int db_get_authinfo_for_subscr(struct gsm_auth_info *ainfo, dbi_result result; const unsigned char *a3a8_ki; - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "SELECT * FROM AuthKeys WHERE subscriber_id=%llu", subscr->id); if (!result) @@ -630,7 +637,7 @@ int db_sync_authinfo_for_subscr(struct gsm_auth_info *ainfo, /* Deletion ? */ if (ainfo == NULL) { - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "DELETE FROM AuthKeys WHERE subscriber_id=%llu", subscr->id); @@ -653,13 +660,13 @@ int db_sync_authinfo_for_subscr(struct gsm_auth_info *ainfo, ainfo->a3a8_ki, ainfo->a3a8_ki_len, &ki_str); if (!upd) { - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "INSERT INTO AuthKeys " "(subscriber_id, algorithm_id, a3a8_ki) " "VALUES (%llu, %u, %s)", subscr->id, ainfo->auth_algo, ki_str); } else { - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "UPDATE AuthKeys " "SET algorithm_id=%u, a3a8_ki=%s " "WHERE subscriber_id=%llu", @@ -683,7 +690,7 @@ int db_get_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, int len; const unsigned char *blob; - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "SELECT * FROM AuthLastTuples WHERE subscriber_id=%llu", subscr->id); if (!result) @@ -739,7 +746,7 @@ int db_sync_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, /* Deletion ? */ if (atuple == NULL) { - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "DELETE FROM AuthLastTuples WHERE subscriber_id=%llu", subscr->id); @@ -766,7 +773,7 @@ int db_sync_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, atuple->kc, sizeof(atuple->kc), &kc_str); if (!upd) { - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "INSERT INTO AuthLastTuples " "(subscriber_id, issued, use_count, " "key_seq, rand, sres, kc) " @@ -777,7 +784,7 @@ int db_sync_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, } else { char *issued = atuple->key_seq == atuple_old.key_seq ? "issued" : "datetime('now')"; - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "UPDATE AuthLastTuples " "SET issued=%s, use_count=%u, " "key_seq=%u, rand=%s, sres=%s, kc=%s " @@ -839,7 +846,7 @@ struct gsm_subscriber *db_get_subscriber(enum gsm_subscriber_field field, switch (field) { case GSM_SUBSCRIBER_IMSI: dbi_conn_quote_string_copy(conn, id, "ed); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, BASE_QUERY "WHERE imsi = %s ", quoted @@ -848,7 +855,7 @@ struct gsm_subscriber *db_get_subscriber(enum gsm_subscriber_field field, break; case GSM_SUBSCRIBER_TMSI: dbi_conn_quote_string_copy(conn, id, "ed); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, BASE_QUERY "WHERE tmsi = %s ", quoted @@ -857,7 +864,7 @@ struct gsm_subscriber *db_get_subscriber(enum gsm_subscriber_field field, break; case GSM_SUBSCRIBER_EXTENSION: dbi_conn_quote_string_copy(conn, id, "ed); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, BASE_QUERY "WHERE extension = %s ", quoted @@ -866,7 +873,7 @@ struct gsm_subscriber *db_get_subscriber(enum gsm_subscriber_field field, break; case GSM_SUBSCRIBER_ID: dbi_conn_quote_string_copy(conn, id, "ed); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, BASE_QUERY "WHERE id = %s ", quoted); free(quoted); @@ -907,7 +914,7 @@ int db_subscriber_update(struct gsm_subscriber *subscr) /* Copy the id to a string as queryf with %llu is failing */ sprintf(buf, "%llu", subscr->id); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, BASE_QUERY "WHERE id = %s", buf); @@ -949,7 +956,7 @@ int db_sync_subscriber(struct gsm_subscriber *subscriber) q_tmsi = strdup("NULL"); if (subscriber->expire_lu == GSM_SUBSCRIBER_NO_EXPIRATION) { - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "UPDATE Subscriber " "SET updated = datetime('now'), " "name = %s, " @@ -966,7 +973,7 @@ int db_sync_subscriber(struct gsm_subscriber *subscriber) subscriber->lac, subscriber->imsi); } else { - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "UPDATE Subscriber " "SET updated = datetime('now'), " "name = %s, " @@ -1003,7 +1010,7 @@ int db_subscriber_delete(struct gsm_subscriber *subscr) { dbi_result result; - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "DELETE FROM AuthKeys WHERE subscriber_id=%llu", subscr->id); if (!result) { @@ -1013,7 +1020,7 @@ int db_subscriber_delete(struct gsm_subscriber *subscr) } dbi_result_free(result); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "DELETE FROM AuthLastTuples WHERE subscriber_id=%llu", subscr->id); if (!result) { @@ -1023,7 +1030,7 @@ int db_subscriber_delete(struct gsm_subscriber *subscr) } dbi_result_free(result); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "DELETE FROM AuthToken WHERE subscriber_id=%llu", subscr->id); if (!result) { @@ -1033,7 +1040,7 @@ int db_subscriber_delete(struct gsm_subscriber *subscr) } dbi_result_free(result); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "DELETE FROM EquipmentWatch WHERE subscriber_id=%llu", subscr->id); if (!result) { @@ -1043,7 +1050,7 @@ int db_subscriber_delete(struct gsm_subscriber *subscr) } dbi_result_free(result); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "DELETE FROM SMS WHERE src_addr=%s OR dest_addr=%s", subscr->extension, subscr->extension); if (!result) { @@ -1053,7 +1060,7 @@ int db_subscriber_delete(struct gsm_subscriber *subscr) } dbi_result_free(result); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "DELETE FROM VLR WHERE subscriber_id=%llu", subscr->id); if (!result) { @@ -1063,7 +1070,7 @@ int db_subscriber_delete(struct gsm_subscriber *subscr) } dbi_result_free(result); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "DELETE FROM ApduBlobs WHERE subscriber_id=%llu", subscr->id); if (!result) { @@ -1073,7 +1080,7 @@ int db_subscriber_delete(struct gsm_subscriber *subscr) } dbi_result_free(result); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "DELETE FROM Subscriber WHERE id=%llu", subscr->id); if (!result) { @@ -1143,7 +1150,7 @@ int db_sync_equipment(struct gsm_equipment *equip) equip->classmark3_len, &cm3); dbi_conn_quote_string_copy(conn, equip->imei, &q_imei); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "UPDATE Equipment SET " "updated = datetime('now'), " "classmark1 = %u, " @@ -1201,7 +1208,7 @@ int db_subscriber_alloc_tmsi(struct gsm_subscriber *subscriber) sprintf(tmsi, "%u", subscriber->tmsi); dbi_conn_quote_string_copy(conn, tmsi, &tmsi_quoted); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "SELECT * FROM Subscriber " "WHERE tmsi = %s ", tmsi_quoted); @@ -1235,7 +1242,7 @@ int db_subscriber_alloc_exten(struct gsm_subscriber *subscriber) for (;;) { try = (rand()%(GSM_MAX_EXTEN-GSM_MIN_EXTEN+1)+GSM_MIN_EXTEN); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "SELECT * FROM Subscriber " "WHERE extension = %i", try @@ -1274,7 +1281,7 @@ int db_subscriber_alloc_token(struct gsm_subscriber *subscriber, uint32_t *token try = rand(); if (!try) /* 0 is an invalid token */ continue; - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "SELECT * FROM AuthToken " "WHERE subscriber_id = %llu OR token = \"%08X\" ", subscriber->id, try); @@ -1293,7 +1300,7 @@ int db_subscriber_alloc_token(struct gsm_subscriber *subscriber, uint32_t *token } dbi_result_free(result); } - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "INSERT INTO AuthToken " "(subscriber_id, created, token) " "VALUES " @@ -1319,7 +1326,7 @@ int db_subscriber_assoc_imei(struct gsm_subscriber *subscriber, char imei[GSM_IM strncpy(subscriber->equipment.imei, imei, sizeof(subscriber->equipment.imei)-1); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "INSERT OR IGNORE INTO Equipment " "(imei, created, updated) " "VALUES " @@ -1339,7 +1346,7 @@ int db_subscriber_assoc_imei(struct gsm_subscriber *subscriber, char imei[GSM_IM if (equipment_id) DEBUGP(DDB, "New Equipment: ID %llu, IMEI %s\n", equipment_id, imei); else { - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "SELECT id FROM Equipment " "WHERE imei = %s ", imei @@ -1357,7 +1364,7 @@ int db_subscriber_assoc_imei(struct gsm_subscriber *subscriber, char imei[GSM_IM dbi_result_free(result); } - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "INSERT OR IGNORE INTO EquipmentWatch " "(subscriber_id, equipment_id, created, updated) " "VALUES " @@ -1377,7 +1384,7 @@ int db_subscriber_assoc_imei(struct gsm_subscriber *subscriber, char imei[GSM_IM DEBUGP(DDB, "New EquipmentWatch: ID %llu, IMSI %s, IMEI %s\n", equipment_id, subscriber->imsi, imei); else { - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "UPDATE EquipmentWatch " "SET updated = datetime('now') " "WHERE subscriber_id = %llu AND equipment_id = %llu ", @@ -1411,7 +1418,7 @@ int db_sms_store(struct gsm_sms *sms) &q_udata); /* FIXME: correct validity period */ - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "INSERT INTO SMS " "(created, valid_until, " "reply_path_req, status_rep_req, protocol_id, " @@ -1500,7 +1507,7 @@ struct gsm_sms *db_sms_get(struct gsm_network *net, unsigned long long id) dbi_result result; struct gsm_sms *sms; - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "SELECT * FROM SMS WHERE SMS.id = %llu", id); if (!result) return NULL; @@ -1523,7 +1530,7 @@ struct gsm_sms *db_sms_get_unsent(struct gsm_network *net, unsigned long long mi dbi_result result; struct gsm_sms *sms; - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "SELECT SMS.* " "FROM SMS JOIN Subscriber ON " "SMS.dest_addr = Subscriber.extension " @@ -1553,7 +1560,7 @@ struct gsm_sms *db_sms_get_unsent_by_subscr(struct gsm_network *net, dbi_result result; struct gsm_sms *sms; - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "SELECT SMS.* " "FROM SMS JOIN Subscriber ON " "SMS.dest_addr = Subscriber.extension " @@ -1582,7 +1589,7 @@ struct gsm_sms *db_sms_get_unsent_for_subscr(struct gsm_subscriber *subscr) dbi_result result; struct gsm_sms *sms; - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "SELECT SMS.* " "FROM SMS JOIN Subscriber ON " "SMS.dest_addr = Subscriber.extension " @@ -1610,7 +1617,7 @@ int db_sms_mark_delivered(struct gsm_sms *sms) { dbi_result result; - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "UPDATE SMS " "SET sent = datetime('now') " "WHERE id = %llu", sms->id); @@ -1628,7 +1635,7 @@ int db_sms_inc_deliver_attempts(struct gsm_sms *sms) { dbi_result result; - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "UPDATE SMS " "SET deliver_attempts = deliver_attempts + 1 " "WHERE id = %llu", sms->id); @@ -1651,7 +1658,7 @@ int db_apdu_blob_store(struct gsm_subscriber *subscr, dbi_conn_quote_binary_copy(conn, apdu, len, &q_apdu); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "INSERT INTO ApduBlobs " "(created,subscriber_id,apdu_id_flags,apdu) VALUES " "(datetime('now'),%llu,%u,%s)", @@ -1673,7 +1680,7 @@ int db_store_counter(struct osmo_counter *ctr) dbi_conn_quote_string_copy(conn, ctr->name, &q_name); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "INSERT INTO Counters " "(timestamp,name,value) VALUES " "(datetime('now'),%s,%lu)", q_name, ctr->value); @@ -1696,7 +1703,7 @@ static int db_store_rate_ctr(struct rate_ctr_group *ctrg, unsigned int num, dbi_conn_quote_string_copy(conn, ctrg->desc->ctr_desc[num].name, &q_name); - result = dbi_conn_queryf(conn, + result = trace_dbi_conn_queryf(conn, "Insert INTO RateCounters " "(timestamp,name,idx,value) VALUES " "(datetime('now'),%s.%s,%u,%"PRIu64")", -- 2.1.4 From Max.Suraev at fairwaves.co Wed Jul 29 18:25:57 2015 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Wed, 29 Jul 2015 20:25:57 +0200 Subject: [PATCH 1/3] use non-vararg functions if possible In-Reply-To: <1438194030-6423-1-git-send-email-max.suraev@fairwaves.co> References: <1438194030-6423-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <55B91AB5.2020204@fairwaves.co> This patch series switch to thread-safe interface of libdbi (correspondingly introducing version requirement for libdbi >= 0.9.0). In addition SQL-specific debug facility is added alongside with couple of inefficiencies catch. Essentially it's groundwork for possible future refactoring which allows for things like gprs authentication or prepared statements to be implemented. -- best regards, Max, http://fairwaves.co From holger at freyther.de Thu Jul 30 08:00:22 2015 From: holger at freyther.de (Holger Freyther) Date: Thu, 30 Jul 2015 10:00:22 +0200 Subject: [PATCH 1/3] use non-vararg functions if possible In-Reply-To: <55B91AB5.2020204@fairwaves.co> References: <1438194030-6423-1-git-send-email-max.suraev@fairwaves.co> <55B91AB5.2020204@fairwaves.co> Message-ID: <5686B33B-7AE5-49AD-A5D9-1325DADD331F@freyther.de> > On 29 Jul 2015, at 20:25, ? wrote: > > This patch series switch to thread-safe interface of libdbi (correspondingly > introducing version requirement for libdbi >= 0.9.0). In addition SQL-specific debug > facility is added alongside with couple of inefficiencies catch. libdbi >= 0.9.0 has severe memory corruptions[1] and they remain unfixed. We should just move away from it and not force the usage of a broken version. holger [1] http://sourceforge.net/p/libdbi/mailman/message/32607036/ From 246tnt at gmail.com Fri Jul 31 21:16:42 2015 From: 246tnt at gmail.com (Sylvain Munaut) Date: Fri, 31 Jul 2015 23:16:42 +0200 Subject: [PATCH 0/4] core/conv: Fast Viterbi decoding In-Reply-To: References: <20140429041352.GA5213@phenom.hsd1.va.comcast.net> <67121C8F-38EA-4835-AA8E-025DD0C024F4@freyther.de> Message-ID: Ok, so I finally took some time to re-read this. First a quick comment on each patch. Patch 1/4: See below Patch 2/4: Didn't really look deeply yet, but at first glance looks OK, I'd say let's focus on getting the infra of patch 1 merged first. Patch 3/4: I'm pretty sure -march=native will wreck cross-compiling Patch 4/4: Looks good For patch 1: * About the state persistence, let's just ignore it for now. It does cost some performance but there is no easy fix, the perf improvement even with this over head is still massive and we can deal with it internally later. * The symbol visibility and naming comments raised in the thread need to be dealt with. To sum up there is 3 kinds of symbols/names : - Global functions / structures: Those that either appear in the header or that are visible when doing an objdump on the resulting .so . Those all need the osmo_ prefix - Internal to the lib: Those that are accessed between several files in the lib. Those don't need an osmo_ prefix for brevity, but they need something less conflicted than 'gen_' ... include 'viterbi' or 'conv' or something to that effect in the name. They need to be hidden from the outside (so they shouldn't show up in the resulting .so), not sure about the current fvisibility situation in libosmocore (don't know if we explicitely mark exported function or if we explicitely mark non-exported one). - Internal to the file: Make sure they're static, naming is fairly irrelevant So I'd say re-submit patch 1 and 4 first, forward ported to apply cleanly and pass a make distcheck on current master. We'll get that merged first, then look at integrating the SSE stuff. Cheers, Sylvain From telenoobie at gmail.com Fri Jul 3 13:29:24 2015 From: telenoobie at gmail.com (Ma Ma) Date: Fri, 03 Jul 2015 13:29:24 -0000 Subject: Sending '?' SMS Through VTY and Silent-SMS Message-ID: Hi everyone, I was just wondering if it is possible to send '?' SMS through the VTY. I was also wondering if someone could provide an example on how to send a silent-sms, whenever I try to send one i get disconnected from the VTY. Regards, Mike -------------- next part -------------- An HTML attachment was scrubbed... URL: From nobody_su at chaostreff.ch Sat Jul 11 17:42:45 2015 From: nobody_su at chaostreff.ch (Miguel Elias) Date: Sat, 11 Jul 2015 17:42:45 -0000 Subject: GSM A-Bis Measurement Equipment Message-ID: <55A15388.1080109@chaostreff.ch> Hi there, I'm cleaning up my cellar and I found a EGM 35 GSM A-Bis field test equipment. Manufacture: GN Nettest ELMI Typ: EGM 35 It is meant to tap in a E1 line and decode messages and also the voice streams between BSC and BS. Comes with headset :) If any body has interest, I am happy to send pictures off-list. Regards Miguel