osmo-msc[master]: libmsc: Fix VTY output for handover counters.

2017-08-24 Thread Alexander Chemeris

Patch Set 1:

I've received a ping about this patch, but I don't think I need to do anything 
here. Please let me know if you need anything

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9512330f2e91d2f526751c5228e6e8e0fe17d579
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


libosmo-sccp[master]: sccp: again fix handling of default IP addresses in osmo_scc...

2017-08-24 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ic8563ab272d5256a1b8ceefd5fee37da61e1bd26
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


[MERGED] osmo-bts[master]: osmo-bts-trx: remove global variables from loops

2017-08-24 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: osmo-bts-trx: remove global variables from loops
..


osmo-bts-trx: remove global variables from loops

* move TA related globals into phy_link
* move power loop related globals into phy_link
* prefix corresponding vty vars with osmotrx

Change-Id: I01d7c1abad67e51b886a4ecf2de072929d67da27
Related: OS#1848
---
M include/osmo-bts/phy_link.h
M src/osmo-bts-trx/loops.c
M src/osmo-bts-trx/loops.h
M src/osmo-bts-trx/main.c
M src/osmo-bts-trx/trx_vty.c
5 files changed, 47 insertions(+), 42 deletions(-)

Approvals:
  Alexander Chemeris: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h
index 7011622..0ffc58e 100644
--- a/include/osmo-bts/phy_link.h
+++ b/include/osmo-bts/phy_link.h
@@ -44,7 +44,9 @@
uint16_t base_port_local;
uint16_t base_port_remote;
struct osmo_fd trx_ofd_clk;
-
+   bool trx_ta_loop;
+   bool trx_ms_power_loop;
+   int8_t trx_target_rssi;
uint32_t clock_advance;
uint32_t rts_advance;
bool use_legacy_setbsic;
diff --git a/src/osmo-bts-trx/loops.c b/src/osmo-bts-trx/loops.c
index 3da805c..6f87cd1 100644
--- a/src/osmo-bts-trx/loops.c
+++ b/src/osmo-bts-trx/loops.c
@@ -39,9 +39,6 @@
  * MS Power loop
  */
 
-int trx_ms_power_loop = 0;
-int8_t trx_target_rssi = -10;
-
 static int ms_power_diff(struct gsm_lchan *lchan, uint8_t chan_nr, int8_t diff)
 {
struct gsm_bts_trx *trx = lchan->ts->trx;
@@ -118,6 +115,7 @@
uint8_t chan_nr, struct l1sched_chan_state *chan_state)
 {
struct gsm_bts_trx *trx = lchan->ts->trx;
+   struct phy_instance *pinst = trx_phy_instance(trx);
int rssi;
int i;
 
@@ -159,10 +157,10 @@
/* change RSSI */
LOGP(DLOOP, LOGL_DEBUG, "Lowest RSSI: %d Target RSSI: %d Current "
"MS power: %d (%d dBm) of trx=%u chan_nr=0x%02x\n", rssi,
-   trx_target_rssi, lchan->ms_power_ctrl.current,
+   pinst->phy_link->u.osmotrx.trx_target_rssi, 
lchan->ms_power_ctrl.current,
MS_PWR_DBM(trx->arfcn, lchan->ms_power_ctrl.current),
trx->nr, chan_nr);
-   ms_power_diff(lchan, chan_nr, trx_target_rssi - rssi);
+   ms_power_diff(lchan, chan_nr, 
pinst->phy_link->u.osmotrx.trx_target_rssi - rssi);
 
return 0;
 }
@@ -171,8 +169,6 @@
 /*
  * Timing Advance loop
  */
-
-int trx_ta_loop = 1;
 
 int ta_val(struct gsm_lchan *lchan, uint8_t chan_nr,
struct l1sched_chan_state *chan_state, float toa)
@@ -220,11 +216,12 @@
 {
struct gsm_lchan *lchan = >trx->ts[L1SAP_CHAN2TS(chan_nr)]
.lchan[l1sap_chan2ss(chan_nr)];
+   struct phy_instance *pinst = trx_phy_instance(l1t->trx);
 
-   if (trx_ms_power_loop)
+   if (pinst->phy_link->u.osmotrx.trx_ms_power_loop)
ms_power_val(chan_state, rssi);
 
-   if (trx_ta_loop)
+   if (pinst->phy_link->u.osmotrx.trx_ta_loop)
ta_val(lchan, chan_nr, chan_state, toa);
 
return 0;
@@ -235,8 +232,9 @@
 {
struct gsm_lchan *lchan = >trx->ts[L1SAP_CHAN2TS(chan_nr)]
.lchan[l1sap_chan2ss(chan_nr)];
+   struct phy_instance *pinst = trx_phy_instance(l1t->trx);
 
-   if (trx_ms_power_loop)
+   if (pinst->phy_link->u.osmotrx.trx_ms_power_loop)
ms_power_clock(lchan, chan_nr, chan_state);
 
/* count the number of SACCH clocks */
diff --git a/src/osmo-bts-trx/loops.h b/src/osmo-bts-trx/loops.h
index c0458c5..230cd4f 100644
--- a/src/osmo-bts-trx/loops.h
+++ b/src/osmo-bts-trx/loops.h
@@ -13,10 +13,6 @@
  * loops api
  */
 
-extern int trx_ms_power_loop;
-extern int8_t trx_target_rssi;
-extern int trx_ta_loop;
-
 int trx_loop_sacch_input(struct l1sched_trx *l1t, uint8_t chan_nr,
struct l1sched_chan_state *chan_state, int8_t rssi, float toa);
 
diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c
index 283e549..a1eb686 100644
--- a/src/osmo-bts-trx/main.c
+++ b/src/osmo-bts-trx/main.c
@@ -122,6 +122,9 @@
plink->u.osmotrx.base_port_remote = 5700;
plink->u.osmotrx.clock_advance = 20;
plink->u.osmotrx.rts_advance = 5;
+   plink->u.osmotrx.trx_ta_loop = true;
+   plink->u.osmotrx.trx_ms_power_loop = false;
+   plink->u.osmotrx.trx_target_rssi = -10;
 }
 
 void bts_model_phy_instance_set_defaults(struct phy_instance *pinst)
diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c
index 36d75c1..a7a433b 100644
--- a/src/osmo-bts-trx/trx_vty.c
+++ b/src/osmo-bts-trx/trx_vty.c
@@ -160,39 +160,47 @@
return 

osmo-bts[master]: osmo-bts-trx: remove global variables from loops

2017-08-24 Thread Harald Welte

Patch Set 2: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I01d7c1abad67e51b886a4ecf2de072929d67da27
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-HasComments: No


[MERGED] osmo-bts[master]: osmo-bts-trx: fix 'osmotrx legacy-setbsic'

2017-08-24 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: osmo-bts-trx: fix 'osmotrx legacy-setbsic'
..


osmo-bts-trx: fix 'osmotrx legacy-setbsic'

It was introduced in fe6c75d24a1751341bcee91cb45c7ac7f5d07da3:

* fix typo in config write
* add missing vty help string

Change-Id: Id42359dfbb8ad02f34dd2540db66f3ed69ad5181
---
M src/osmo-bts-trx/trx_vty.c
1 file changed, 3 insertions(+), 3 deletions(-)

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



diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c
index 482248c..36d75c1 100644
--- a/src/osmo-bts-trx/trx_vty.c
+++ b/src/osmo-bts-trx/trx_vty.c
@@ -458,7 +458,7 @@
 }
 
 DEFUN(cfg_phy_setbsic, cfg_phy_setbsic_cmd,
-   "osmotrx legacy-setbsic",
+   "osmotrx legacy-setbsic", OSMOTRX_STR
"Use SETBSIC to configure transceiver (use ONLY with OpenBTS 
Transceiver!)\n")
 {
struct phy_link *plink = vty->index;
@@ -473,7 +473,7 @@
 
 DEFUN(cfg_phy_no_setbsic, cfg_phy_no_setbsic_cmd,
"no osmotrx legacy-setbsic",
-   NO_STR "Disable Legacy SETBSIC to configure transceiver\n")
+   NO_STR OSMOTRX_STR "Disable Legacy SETBSIC to configure transceiver\n")
 {
struct phy_link *plink = vty->index;
plink->u.osmotrx.use_legacy_setbsic = false;
@@ -503,7 +503,7 @@
plink->u.osmotrx.rts_advance, VTY_NEWLINE);
 
if (plink->u.osmotrx.use_legacy_setbsic)
-   vty_out(vty, " osmotrx leyacy-setbsic%s", VTY_NEWLINE);
+   vty_out(vty, " osmotrx legacy-setbsic%s", VTY_NEWLINE);
 }
 
 void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance 
*pinst)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id42359dfbb8ad02f34dd2540db66f3ed69ad5181
Gerrit-PatchSet: 4
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmo-bts[master]: OML: use fom_hdr while handling attr. request

2017-08-24 Thread Harald Welte

Patch Set 4: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I8b5a5ab8bd07daf2500b66dec428b89b7f8cd852
Gerrit-PatchSet: 4
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-HasComments: No


[MERGED] osmo-pcu[master]: Use value string check from osmo-ci

2017-08-24 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Use value string check from osmo-ci
..


Use value string check from osmo-ci

Change-Id: Ib9c595ef80cb6b0d126d4da8244f6435e0526095
---
M contrib/jenkins.sh
1 file changed, 2 insertions(+), 2 deletions(-)

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



diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 75f28f3..b815ddd 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -58,10 +58,10 @@
   exit 1
 fi
 
+verify_value_string_arrays_are_terminated.py $(find . -name "*.[hc]")
+
 # Build deps
 osmo-build-dep.sh libosmocore
-
-"$deps"/libosmocore/contrib/verify_value_string_arrays_are_terminated.py 
$(find . -name "*.[hc]")
 
 export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
 export LD_LIBRARY_PATH="$inst/lib"

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib9c595ef80cb6b0d126d4da8244f6435e0526095
Gerrit-PatchSet: 2
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


osmo-pcu[master]: Use value string check from osmo-ci

2017-08-24 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib9c595ef80cb6b0d126d4da8244f6435e0526095
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


osmo-pcu[master]: Facilitate future releases

2017-08-24 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie0a7f5977550bd0a1ba8b03bdb7e2d619a398e4e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-bts[master]: Bump version: 0.5.0 → 0.6.0

2017-08-24 Thread Harald Welte

Patch Set 1: Code-Review+1

(1 comment)

https://gerrit.osmocom.org/#/c/3598/1/debian/changelog
File debian/changelog:

Line 4:   * New upstream version
I think this should be more verbose, suhc as the addition of osmo-bts-virtual 
or other major changes since April 2016?


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I613d09ae0f9f0aa67be1dc6015da1fb9314110fd
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: Yes


openbsc[master]: SGSN: log IMSI on PDP context creation/deletion

2017-08-24 Thread Harald Welte

Patch Set 3: Code-Review+1

(1 comment)

https://gerrit.osmocom.org/#/c/3575/3/openbsc/src/gprs/sgsn_libgtp.c
File openbsc/src/gprs/sgsn_libgtp.c:

Line 148:   LOGP(DGPRS, LOGL_ERROR, "Create PDP Context for %s\n", 
mmctx->imsi);
I think if you want to do this, it would make sense to also print the NSAPI, as 
only the tuple of IMSI:NSAPI uniquely identifies a PDP context.  Same for the 
deletion callback below.  I've introduced recent changes in OpenGGSN by having 
some logging wrapper macros like LOGPPDP() or the like.  Could make sense here, 
too


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I5ada9f85af2098f9acc8a277b9026eed226b9ac2
Gerrit-PatchSet: 3
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 
Gerrit-HasComments: Yes


libosmocore[master]: Relax branch restriction while making release

2017-08-24 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie89b79a45033bee422e4ff898069ea6ac2c2f524
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] libosmocore[master]: Relax branch restriction while making release

2017-08-24 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Relax branch restriction while making release
..


Relax branch restriction while making release

Previously making release of non-library project from non-master branch
would fail. Relax this check to facilitate submission to gerrit via
topic branches.

Change-Id: Ie89b79a45033bee422e4ff898069ea6ac2c2f524
Related: OS#1861
---
M osmo-release.mk
1 file changed, 1 insertion(+), 1 deletion(-)

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



diff --git a/osmo-release.mk b/osmo-release.mk
index 4407c86..3fe6803 100644
--- a/osmo-release.mk
+++ b/osmo-release.mk
@@ -10,7 +10,7 @@
 endif
@echo "Releasing" $(VERSION) "->" $(NEW_VERSION)"..."
 ifeq ($(LIBVERS),)
-   @gbp dch --debian-tag='%(version)s' --auto --meta --git-author 
--multimaint-merge
+   @gbp dch --debian-tag='%(version)s' --auto --meta --git-author 
--multimaint-merge --ignore-branch
 else
@echo "You should NOT be doing this unless you've read and understood 
following article:"
@echo 
"https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html#Updating-version-info;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie89b79a45033bee422e4ff898069ea6ac2c2f524
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-pcap[master]: Add gitreview config

2017-08-24 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Add gitreview config
..


Add gitreview config

Change-Id: I35b3aaa3f8af4127d8a1b00c77ab02ae6a182714
---
A .gitreview
1 file changed, 3 insertions(+), 0 deletions(-)

Approvals:
  lynxis lazus: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/.gitreview b/.gitreview
new file mode 100644
index 000..e218434
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,3 @@
+[gerrit]
+host=gerrit.osmocom.org
+project=osmo-pcap

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I35b3aaa3f8af4127d8a1b00c77ab02ae6a182714
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: lynxis lazus 


openbsc[master]: Revert "factor out & introduce struct gsm_encr, in common_cs.h"

2017-08-24 Thread Harald Welte

Patch Set 1: Code-Review+2

I agree with max' comments but I think this is a simple "revert" of an existing 
commit.  So the issues should be resolved separately, and not in the same 
commit as the revert, right?

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I15d60441c6c6f053486c0482258a8759bdd92df1
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-HasComments: No


osmo-pcap[master]: Add gitreview config

2017-08-24 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I35b3aaa3f8af4127d8a1b00c77ab02ae6a182714
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: lynxis lazus 
Gerrit-HasComments: No


osmo-bts[master]: osmo-bts-trx: Relax validation to allow TRX data bursts with...

2017-08-24 Thread Harald Welte

Patch Set 1: Code-Review+2

I think a one-line comment in the code would make sense in addition to the 
commit log message.  Nobody will understand the code otherwise.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I94c3cb160bfed0ba9c41ed7ef5f8d8a65b81ad07
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


openggsn[master]: libgtp: expand logging

2017-08-24 Thread Harald Welte

Patch Set 3: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I0f8ad8687acb7f6f0eeeb962f007e87cca0c4c27
Gerrit-PatchSet: 3
Gerrit-Project: openggsn
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 
Gerrit-HasComments: No


[MERGED] openggsn[master]: libgtp: expand logging

2017-08-24 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: libgtp: expand logging
..


libgtp: expand logging

* print destination address on sendto error
* print address length on conversion error
* log listening address
* log GTP version on PDP context errors
* fix incorrect logging message for unknown GSN peer

Related: SYS#3610
Change-Id: I0f8ad8687acb7f6f0eeeb962f007e87cca0c4c27
---
M gtp/gtp.c
1 file changed, 7 insertions(+), 10 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/gtp/gtp.c b/gtp/gtp.c
index 012aa79..a3f6eb2 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -394,9 +394,8 @@
if (sendto(fd, packet, len, 0,
   (struct sockaddr *), sizeof(addr)) < 0) {
gsn->err_sendto++;
-   LOGP(DLGTP, LOGL_ERROR,
-   "Sendto(fd=%d, msg=%lx, len=%d) failed: Error = %s\n", 
fd,
-   (unsigned long), len, strerror(errno));
+   LOGP(DLGTP, LOGL_ERROR, "Sendto(fd=%d, msg=%lx, len=%d, dst=%s) 
failed: Error = %s\n", fd,
+(unsigned long), len, inet_ntoa(addr.sin_addr), 
strerror(errno));
return -1;
}
 
@@ -697,7 +696,7 @@
 {
struct sockaddr_in addr;
 
-   LOGP(DLGTP, LOGL_NOTICE, "GTP: gtp_newgsn() started\n");
+   LOGP(DLGTP, LOGL_NOTICE, "GTP: gtp_newgsn() started at %s\n", 
inet_ntoa(*listen));
 
*gsn = calloc(sizeof(struct gsn_t), 1); /* TODO */
 
@@ -2293,8 +2292,7 @@
 
if (gsna2in_addr(, >gsnrc)) {
gsn->err_address++;
-   LOGP(DLGTP, LOGL_ERROR,
-   "GSN address conversion failed\n");
+   LOGP(DLGTP, LOGL_ERROR, "GSN address (len=%u) conversion 
failed\n", pdp->gsnrc.l);
return EOF;
}
 
@@ -2642,7 +2640,7 @@
(, ntoh16(((union gtp_packet *)pack)->gtp0.h.flow))) {
gsn->err_unknownpdp++;
GTP_LOGPKG(LOGL_ERROR, peer, pack,
-   len, "Unknown PDP context\n");
+   len, "Unknown PDP context, GTPv0\n");
return gtp_error_ind_resp(gsn, version, peer, fd, pack,
  len);
}
@@ -2652,7 +2650,7 @@
(, ntoh32(((union gtp_packet *)pack)->gtp1l.h.tei))) {
gsn->err_unknownpdp++;
GTP_LOGPKG(LOGL_ERROR, peer, pack,
-   len, "Unknown PDP context\n");
+   len, "Unknown PDP context, GTPv1\n");
return gtp_error_ind_resp(gsn, version, peer, fd, pack,
  len);
}
@@ -2670,8 +2668,7 @@
/* If the GPDU was not from the peer GSN tell him to delete context */
if (memcmp(>sin_addr, pdp->gsnru.v, pdp->gsnru.l)) {  /* TODO 
Range? */
gsn->err_unknownpdp++;
-   GTP_LOGPKG(LOGL_ERROR, peer, pack, len,
-   "Unknown PDP context\n");
+   GTP_LOGPKG(LOGL_ERROR, peer, pack, len, "Unknown GSN peer 
%s\n", inet_ntoa(peer->sin_addr));
return gtp_error_ind_resp(gsn, version, peer, fd, pack, len);
}
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I0f8ad8687acb7f6f0eeeb962f007e87cca0c4c27
Gerrit-PatchSet: 3
Gerrit-Project: openggsn
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 


osmo-ci[master]: scripts: add requirements.txt to list jenkins-job-builder

2017-08-24 Thread Harald Welte

Patch Set 1: Code-Review+2 Verified+1

setting "verified" as we simply have no process to verify such changes for now.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: If25ce84593bbf6a393928a8f4e1670f320c48ca4
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Max 
Gerrit-HasComments: No


osmo-ci[master]: osmocom-nightly-nitb-split.yml: schedule the job to be run a...

2017-08-24 Thread Harald Welte

Patch Set 1: Code-Review+2 Verified+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I0d80e7d260f9092f44d4d80471a4dd67b7acc839
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Max 
Gerrit-HasComments: No


libosmo-abis[master]: Bump version: 0.3.2 → 0.4.0

2017-08-24 Thread Harald Welte

Patch Set 1: Code-Review+1

(1 comment)

https://gerrit.osmocom.org/#/c/3596/1/TODO-RELEASE
File TODO-RELEASE:

Line 4
maybe simply squash the two commits? Why have one commit to introduce the 
LIBVERSION change and another that removes the lines from todo-release?


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I6f0ac8377adeccd4c56555cdc16768973c1f0876
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: neels 
Gerrit-HasComments: Yes


libosmo-abis[master]: Prepare for next release

2017-08-24 Thread Harald Welte

Patch Set 1: Code-Review+1

(1 comment)

https://gerrit.osmocom.org/#/c/3595/1//COMMIT_MSG
Commit Message:

Line 11:   libosmotrau due to API changes
would be good to indicate roguhtly which API changes (commit[s]) and also 
remove the related part from TODO-RELEASE  ?


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ibefe53a7f5b06fb8a9294574af41dacac68bdbe9
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: Yes


osmo-gsm-tester[master]: default-suites.conf: Add suites to explicitly test with sysm...

2017-08-24 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I6ff08a281c0c32148ca2c59f731d6550bf7b1c90
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


[MERGED] libosmo-sccp[master]: osmo_ss7_vty: fix 'as' / 'routing-key' command

2017-08-24 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: osmo_ss7_vty: fix 'as' / 'routing-key' command
..


osmo_ss7_vty: fix 'as' / 'routing-key' command

The VTY definition for this command is flawed and breaks osmo-msc VTY tests.

The small problem is a stray '}' in the definition, the bigger problem is that
square brackets indicating optional arguments must not enclose more than one
argument.

Split up the command in several separate definitions with si arg, with ssn arg,
with both, and with neither.

If si and/or ssn are not passed, set them to zero.

See https://lists.osmocom.org/pipermail/openbsc/2017-August/011026.html
"optional vty items are stricter than expected"

Change-Id: Idc68bfae5457960a9eae5d9648586d6ce719ad68
---
M src/osmo_ss7_vty.c
1 file changed, 58 insertions(+), 31 deletions(-)

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



diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 8d2ec96..5731326 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -778,51 +778,75 @@
{ 0, NULL }
 };
 
-DEFUN(as_rout_key, as_rout_key_cmd,
-   "routing-key RCONTEXT DPC [si 
(aal2|bicc|b-isup|h248|isup|sat-isup|sccp|tup)] [ssn SSN]}",
-   "Define a routing key\n"
-   "Routing context number\n"
+#define ROUTING_KEY_CMD "routing-key RCONTEXT DPC"
+#define ROUTING_KEY_CMD_STRS \
+   "Define a routing key\n" \
+   "Routing context number\n" \
"Destination Point Code\n"
-   "Optional Match on Service Indicator\n"
-   "ATM Adaption Layer 2\n"
-   "Bearer Independent Call Control\n"
-   "Broadband ISDN User Part\n"
-   "H.248\n"
-   "ISDN User Part\n"
-   "Sattelite ISDN User Part\n"
-   "Signalling Connection Control Part\n"
+#define ROUTING_KEY_SI_ARG " si (aal2|bicc|b-isup|h248|isup|sat-isup|sccp|tup)"
+#define ROUTING_KEY_SI_ARG_STRS \
+   "Match on Service Indicator\n" \
+   "ATM Adaption Layer 2\n" \
+   "Bearer Independent Call Control\n" \
+   "Broadband ISDN User Part\n" \
+   "H.248\n" \
+   "ISDN User Part\n" \
+   "Sattelite ISDN User Part\n" \
+   "Signalling Connection Control Part\n" \
"Telephony User Part\n"
-   "Optional Match on Sub-System Number\n"
-   "Sub-System Number to match on\n")
+#define ROUTING_KEY_SSN_ARG " ssn SSN"
+#define ROUTING_KEY_SSN_ARG_STRS \
+   "Match on Sub-System Number\n" \
+   "Sub-System Number to match on\n"
+
+static int _rout_key(struct vty *vty,
+const char *rcontext, const char *dpc,
+const char *si, const char *ssn)
 {
struct osmo_ss7_as *as = vty->index;
struct osmo_ss7_routing_key *rkey = >cfg.routing_key;
-   int argind;
int pc;
 
-   pc = osmo_ss7_pointcode_parse(as->inst, argv[1]);
+   pc = osmo_ss7_pointcode_parse(as->inst, dpc);
if (pc < 0) {
-   vty_out(vty, "Invalid point code (%s)%s", argv[1], VTY_NEWLINE);
+   vty_out(vty, "Invalid point code (%s)%s", dpc, VTY_NEWLINE);
return CMD_WARNING;
}
-
rkey->pc = pc;
-   rkey->context = atoi(argv[0]);
-   argind = 2;
 
-   if (argind < argc && !strcmp(argv[argind], "si")) {
-   const char *si_str;
-   argind++;
-   si_str = argv[argind++];
-   /* parse numeric SI from string */
-   rkey->si = get_string_value(mtp_si_vals, si_str);
-   }
-   if (argind < argc && !strcmp(argv[argind], "ssn")) {
-   argind++;
-   rkey->ssn = atoi(argv[argind]);
-   }
+   rkey->context = atoi(rcontext); /* FIXME: input 
validation */
+   rkey->si = si ? get_string_value(mtp_si_vals, si) : 0;  /* FIXME: input 
validation */
+   rkey->ssn = ssn ? atoi(ssn) : 0;/* FIXME: input 
validation */
 
return CMD_SUCCESS;
+}
+
+DEFUN(as_rout_key, as_rout_key_cmd,
+  ROUTING_KEY_CMD,
+  ROUTING_KEY_CMD_STRS)
+{
+   return _rout_key(vty, argv[0], argv[1], NULL, NULL);
+}
+
+DEFUN(as_rout_key_si, as_rout_key_si_cmd,
+  ROUTING_KEY_CMD  ROUTING_KEY_SI_ARG,
+  ROUTING_KEY_CMD_STRS ROUTING_KEY_SI_ARG_STRS)
+{
+   return _rout_key(vty, argv[0], argv[1], argv[2], NULL);
+}
+
+DEFUN(as_rout_key_ssn, as_rout_key_ssn_cmd,
+  ROUTING_KEY_CMD  ROUTING_KEY_SSN_ARG,
+  ROUTING_KEY_CMD_STRS ROUTING_KEY_SSN_ARG_STRS)
+{
+   return _rout_key(vty, argv[0], argv[1], NULL, argv[2]);
+}
+
+DEFUN(as_rout_key_si_ssn, as_rout_key_si_ssn_cmd,
+  ROUTING_KEY_CMD  ROUTING_KEY_SI_ARG  ROUTING_KEY_SSN_ARG,
+  ROUTING_KEY_CMD_STRS ROUTING_KEY_SI_ARG_STRS ROUTING_KEY_SSN_ARG_STRS)
+{
+   return _rout_key(vty, argv[0], argv[1], argv[2], argv[3]);
 }
 
 DEFUN(as_pc_override, as_pc_override_cmd,
@@ -1718,6 +1742,9 @@

libosmo-sccp[master]: osmo_ss7_vty: fix 'as' / 'routing-key' command

2017-08-24 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Idc68bfae5457960a9eae5d9648586d6ce719ad68
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmo-msc[master]: contrib: Change systemd requirements so the services connect...

2017-08-24 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: contrib: Change systemd requirements so the services connect 
properly
..


contrib: Change systemd requirements so the services connect properly

Change-Id: Ib1b3c640ddd81927a60ee307c4b0cb90fd83eebe
---
M contrib/systemd/osmo-msc.service
M contrib/systemd/osmo-sgsn.service
2 files changed, 6 insertions(+), 2 deletions(-)

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



diff --git a/contrib/systemd/osmo-msc.service b/contrib/systemd/osmo-msc.service
index 2c81eba..7cebb14 100644
--- a/contrib/systemd/osmo-msc.service
+++ b/contrib/systemd/osmo-msc.service
@@ -1,7 +1,8 @@
 [Unit]
 Description=Osmocom Mobile Switching Center (MSC)
-Wants=osmo-hlr
-After=osmo-hlr
+Wants=osmo-hlr.service
+After=osmo-hlr.service
+After=osmo-hnbgw.service
 
 [Service]
 Type=simple
diff --git a/contrib/systemd/osmo-sgsn.service 
b/contrib/systemd/osmo-sgsn.service
index 674d786..bf6a8e0 100644
--- a/contrib/systemd/osmo-sgsn.service
+++ b/contrib/systemd/osmo-sgsn.service
@@ -1,5 +1,8 @@
 [Unit]
 Description=OpenBSC SGSN
+Wants=osmo-hlr.service
+After=osmo-hlr.service
+After=osmo-hnbgw.service
 
 [Service]
 Type=simple

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib1b3c640ddd81927a60ee307c4b0cb90fd83eebe
Gerrit-PatchSet: 3
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 


[MERGED] osmo-msc[master]: contrib: Add osmo-msc service file

2017-08-24 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: contrib: Add osmo-msc service file
..


contrib: Add osmo-msc service file

Change-Id: Ifdaf4107167c84af8a616f4ee792d5a34495564b
---
A contrib/systemd/osmo-msc.service
1 file changed, 13 insertions(+), 0 deletions(-)

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



diff --git a/contrib/systemd/osmo-msc.service b/contrib/systemd/osmo-msc.service
new file mode 100644
index 000..2c81eba
--- /dev/null
+++ b/contrib/systemd/osmo-msc.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Osmocom Mobile Switching Center (MSC)
+Wants=osmo-hlr
+After=osmo-hlr
+
+[Service]
+Type=simple
+Restart=always
+ExecStart=/usr/bin/osmo-msc -c /etc/osmocom/osmo-msc.cfg
+RestartSec=2
+
+[Install]
+WantedBy=multi-user.target

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifdaf4107167c84af8a616f4ee792d5a34495564b
Gerrit-PatchSet: 3
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 


[MERGED] osmo-msc[master]: examples/sgsn: Use osmo-hlr with auth-policy remote by default

2017-08-24 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: examples/sgsn: Use osmo-hlr with auth-policy remote by default
..


examples/sgsn: Use osmo-hlr with auth-policy remote by default

For the vty tests, add osmo-sgsn-accept-all.cfg (that does not need an HLR) and
use in vty_test_runner.py, otherwise the 'show sgsn' command will reply that it
could not connect to the HLR, failing the vty test which expects empty.

Change-Id: Ie3b2013198d3e2b780a4e31c36b89b58129dcacd
---
A doc/examples/osmo-sgsn/osmo-sgsn-accept-all.cfg
M doc/examples/osmo-sgsn/osmo-sgsn.cfg
M tests/vty_test_runner.py
3 files changed, 31 insertions(+), 1 deletion(-)

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



diff --git a/doc/examples/osmo-sgsn/osmo-sgsn-accept-all.cfg 
b/doc/examples/osmo-sgsn/osmo-sgsn-accept-all.cfg
new file mode 100644
index 000..5e64342
--- /dev/null
+++ b/doc/examples/osmo-sgsn/osmo-sgsn-accept-all.cfg
@@ -0,0 +1,27 @@
+!
+! Osmocom SGSN configuration
+!
+!
+line vty
+ no login
+!
+sgsn
+ gtp local-ip 127.0.0.1
+ ggsn 0 remote-ip 127.0.0.2
+ ggsn 0 gtp-version 1
+ auth-policy accept-all
+!
+ns
+ timer tns-block 3
+ timer tns-block-retries 3
+ timer tns-reset 3
+ timer tns-reset-retries 3
+ timer tns-test 30
+ timer tns-alive 3
+ timer tns-alive-retries 10
+ encapsulation udp local-ip 127.0.0.1
+ encapsulation udp local-port 23000
+ encapsulation framerelay-gre enabled 0
+!
+bssgp
+!
diff --git a/doc/examples/osmo-sgsn/osmo-sgsn.cfg 
b/doc/examples/osmo-sgsn/osmo-sgsn.cfg
index 3f39397..9703c23 100644
--- a/doc/examples/osmo-sgsn/osmo-sgsn.cfg
+++ b/doc/examples/osmo-sgsn/osmo-sgsn.cfg
@@ -9,6 +9,9 @@
  gtp local-ip 127.0.0.1
  ggsn 0 remote-ip 127.0.0.2
  ggsn 0 gtp-version 1
+ auth-policy remote
+ gsup remote-ip 127.0.0.1
+ gsup remote-port 
 !
 ns
  timer tns-block 3
diff --git a/tests/vty_test_runner.py b/tests/vty_test_runner.py
index fe4d3f0..7d4e121 100644
--- a/tests/vty_test_runner.py
+++ b/tests/vty_test_runner.py
@@ -829,7 +829,7 @@
 
 def vty_command(self):
 return ["./src/gprs/osmo-sgsn", "-c",
-"doc/examples/osmo-sgsn/osmo-sgsn.cfg"]
+"doc/examples/osmo-sgsn/osmo-sgsn-accept-all.cfg"]
 
 def vty_app(self):
 return (4245, "./src/gprs/osmo-sgsn", "OsmoSGSN", "sgsn")

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie3b2013198d3e2b780a4e31c36b89b58129dcacd
Gerrit-PatchSet: 4
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 


[MERGED] osmo-msc[master]: mgcp: hack RAB success from nano3G: patch first RTP payload

2017-08-24 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: mgcp: hack RAB success from nano3G: patch first RTP payload
..


mgcp: hack RAB success from nano3G: patch first RTP payload

The ip.access nano3G needs the first RTP payload's first two bytes to read hex
'e400', or it will reject the RAB assignment. Add flag
patched_first_rtp_payload to mgcp_rtp_state to detect the first RTP payload on
a stream, and overwrite its first bytes with e400. This should probably be
configurable, but seems to not harm other femto cells (as long as we patch only
the first RTP payload in each stream). Only do this when sending to the BTS
side.

Related: OS#2459
Change-Id: I5eff04dcb0936e21690e427ae5e49228cd459bd4
---
M include/openbsc/mgcp_internal.h
M src/libmgcp/mgcp_network.c
2 files changed, 14 insertions(+), 0 deletions(-)

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



diff --git a/include/openbsc/mgcp_internal.h b/include/openbsc/mgcp_internal.h
index b58eb9b..b2c2408 100644
--- a/include/openbsc/mgcp_internal.h
+++ b/include/openbsc/mgcp_internal.h
@@ -64,6 +64,7 @@
uint32_t stats_jitter;
int32_t stats_transit;
int stats_cycles;
+   bool patched_first_rtp_payload; /* FIXME: drop this, see OS#2459 */
 };
 
 struct mgcp_rtp_codec {
diff --git a/src/libmgcp/mgcp_network.c b/src/libmgcp/mgcp_network.c
index c9fe179..399dc8f 100644
--- a/src/libmgcp/mgcp_network.c
+++ b/src/libmgcp/mgcp_network.c
@@ -667,6 +667,19 @@
forward_data(rtp_end->rtp.fd, >taps[tap_idx],
 buf, len);
 
+   /* FIXME: HACK HACK HACK. See OS#2459.
+* The ip.access nano3G needs the first RTP payload's 
first two bytes to read hex
+* 'e400', or it will reject the RAB assignment. It 
seems to not harm other femto
+* cells (as long as we patch only the first RTP 
payload in each stream).
+*/
+   if (tap_idx == MGCP_TAP_BTS_OUT
+   && !rtp_state->patched_first_rtp_payload) {
+   uint8_t *data = (uint8_t*)[12];
+   data[0] = 0xe4;
+   data[1] = 0x00;
+   rtp_state->patched_first_rtp_payload = true;
+   }
+
rc = mgcp_udp_send(rtp_end->rtp.fd,
   _end->addr,
   rtp_end->rtp_port, buf, len);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5eff04dcb0936e21690e427ae5e49228cd459bd4
Gerrit-PatchSet: 7
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-msc[master]: examples: Change IP address of config files

2017-08-24 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: examples: Change IP address of config files
..


examples: Change IP address of config files

This helps in providing 3G software packages for the sysmoNITB hardware, which
uses 10.23.24.1 for SGSN and 10.23.24.2 for GGSN.

However, in order to not break the python tests, the osmo-sgsn.cfg example
still uses 127.0.0.1 as local address.

Change the GGSN address to 127.0.0.2, because SGSN and GGSN cannot co-exist on
the same address (the GTP port number is fixed by spec: no IE to communicate a
differing port, so it has to be the standard GTP port for both).

Change-Id: Ie3a25f6771ed6e620cb2b315638c622a9a24e530
---
M doc/examples/osmo-bsc_mgcp/mgcp.cfg
M doc/examples/osmo-msc/osmo-msc.cfg
M doc/examples/osmo-sgsn/osmo-sgsn.cfg
3 files changed, 5 insertions(+), 5 deletions(-)

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



diff --git a/doc/examples/osmo-bsc_mgcp/mgcp.cfg 
b/doc/examples/osmo-bsc_mgcp/mgcp.cfg
index 2622d23..3c43f1f 100644
--- a/doc/examples/osmo-bsc_mgcp/mgcp.cfg
+++ b/doc/examples/osmo-bsc_mgcp/mgcp.cfg
@@ -7,9 +7,9 @@
  no login
 !
 mgcp
-  !local ip 192.168.0.132
-  !bts ip 192.168.0.124
-  !bind ip 192.168.0.132
+  !local ip 10.23.24.2
+  !bts ip 10.24.24.1
+  !bind ip 10.23.24.1
   bind port 2427
   rtp base 4000
   rtp force-ptime 20
diff --git a/doc/examples/osmo-msc/osmo-msc.cfg 
b/doc/examples/osmo-msc/osmo-msc.cfg
index 6cb9e4e..1b1d192 100644
--- a/doc/examples/osmo-msc/osmo-msc.cfg
+++ b/doc/examples/osmo-msc/osmo-msc.cfg
@@ -15,5 +15,5 @@
  rrlp mode none
  mm info 1
 msc
- mgcpgw remote-ip 192.168.0.132
+ mgcpgw remote-ip 10.23.24.1
  assign-tmsi
diff --git a/doc/examples/osmo-sgsn/osmo-sgsn.cfg 
b/doc/examples/osmo-sgsn/osmo-sgsn.cfg
index 4955983..3f39397 100644
--- a/doc/examples/osmo-sgsn/osmo-sgsn.cfg
+++ b/doc/examples/osmo-sgsn/osmo-sgsn.cfg
@@ -7,7 +7,7 @@
 !
 sgsn
  gtp local-ip 127.0.0.1
- ggsn 0 remote-ip 127.0.0.1
+ ggsn 0 remote-ip 127.0.0.2
  ggsn 0 gtp-version 1
 !
 ns

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie3a25f6771ed6e620cb2b315638c622a9a24e530
Gerrit-PatchSet: 3
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: daniel 


osmo-msc[master]: examples/sgsn: Use osmo-hlr with auth-policy remote by default

2017-08-24 Thread Harald Welte

Patch Set 4: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie3b2013198d3e2b780a4e31c36b89b58129dcacd
Gerrit-PatchSet: 4
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 
Gerrit-HasComments: No


osmo-msc[master]: examples: Change IP address of config files

2017-08-24 Thread Harald Welte

Patch Set 3: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie3a25f6771ed6e620cb2b315638c622a9a24e530
Gerrit-PatchSet: 3
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: daniel 
Gerrit-HasComments: No


osmo-msc[master]: mgcp: hack RAB success from nano3G: patch first RTP payload

2017-08-24 Thread Harald Welte

Patch Set 7: Code-Review+2

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

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


[PATCH] osmo-msc[master]: mgcp: Fix uplink activation of Osmux stream

2017-08-24 Thread Neels Hofmeyr

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

mgcp: Fix uplink activation of Osmux stream

Commit 575420637981828b64c1292ada015d7170b89390 introduced
OSMUX_STATE_NEGOTIATING to fix a race condition present in osmo-bsc_nat.
However, after this change osmo-bsc_mgcp cannot switch to
OSMUX_STATE_ACTIVATING anymore, which means during osmux_send_dummy time
it won't call osmux_enable_endpoint(), which in turn won't set endp type
to MGCP_OSMUX_BSC.

If MGCP_OSMUX_BSC is not set, uplink streams are sent using regular RTP
instead of Osmux not matter it is enabled in config or not.

Change-Id: Ibcb59aa1ca25408f82cc88c2d5b81177b5f276dc
---
M src/libmgcp/mgcp_protocol.c
1 file changed, 4 insertions(+), 2 deletions(-)


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

diff --git a/src/libmgcp/mgcp_protocol.c b/src/libmgcp/mgcp_protocol.c
index 78e41f1..96542c5 100644
--- a/src/libmgcp/mgcp_protocol.c
+++ b/src/libmgcp/mgcp_protocol.c
@@ -277,10 +277,12 @@
if (!addr)
addr = mgcp_net_src_addr(endp);
 
-   if (endp->osmux.state == OSMUX_STATE_NEGOTIATING)
+   if (endp->osmux.state == OSMUX_STATE_NEGOTIATING) {
sprintf(osmux_extension, "\nX-Osmux: %u", endp->osmux.cid);
-   else
+   endp->osmux.state = OSMUX_STATE_ACTIVATING;
+   } else {
osmux_extension[0] = '\0';
+   }
 
len = snprintf(sdp_record, sizeof(sdp_record),
   "I: %u%s\n\n", endp->ci, osmux_extension);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibcb59aa1ca25408f82cc88c2d5b81177b5f276dc
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


[PATCH] osmo-msc[master]: sgsn_test: Fix wrong definition of wrap func

2017-08-24 Thread Neels Hofmeyr

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

sgsn_test: Fix wrong definition of wrap func

Commit 058cd573d8 added 2 new pointer parameters to
gprs_subscr_request_auth_info, but forgot to update wraps of the
function in sgsn_test.

I catched this today because openbsc build test sgsn_test was failing.
Closed look up to the logs showed:
Assert failed (auts != NULL) == (auts_rand != NULL) 
openbsc/openbsc/src/gprs/gprs_subscriber.c:791

Change-Id: Ie9e4af6da0339536fb20ca0b7bbcf6f485bd522c
---
M tests/sgsn/sgsn_test.c
1 file changed, 5 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/67/3667/1

diff --git a/tests/sgsn/sgsn_test.c b/tests/sgsn/sgsn_test.c
index 2f1513a..d66c5dd 100644
--- a/tests/sgsn/sgsn_test.c
+++ b/tests/sgsn/sgsn_test.c
@@ -139,12 +139,12 @@
 };
 
 /* override, requires '-Wl,--wrap=gprs_subscr_request_auth_info' */
-int __real_gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx);
-int (*subscr_request_auth_info_cb)(struct sgsn_mm_ctx *mmctx) =
+int __real_gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx, const 
uint8_t *auts, const uint8_t *auts_rand);
+int (*subscr_request_auth_info_cb)(struct sgsn_mm_ctx *mmctx, const uint8_t 
*auts, const uint8_t *auts_rand) =
&__real_gprs_subscr_request_auth_info;
 
-int __wrap_gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx) {
-   return (*subscr_request_auth_info_cb)(mmctx);
+int __wrap_gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx, const 
uint8_t *auts, const uint8_t *auts_rand) {
+   return (*subscr_request_auth_info_cb)(mmctx, auts, auts_rand);
 };
 
 /* override, requires '-Wl,--wrap=gsup_client_send' */
@@ -1160,7 +1160,7 @@
cleanup_test();
 }
 
-int my_subscr_request_auth_info_real_auth(struct sgsn_mm_ctx *mmctx)
+int my_subscr_request_auth_info_real_auth(struct sgsn_mm_ctx *mmctx, const 
uint8_t *auts, const uint8_t *auts_rand)
 {
struct gsm_auth_tuple at = {
.vec.sres = {0x51, 0xe5, 0x51, 0xe5},

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie9e4af6da0339536fb20ca0b7bbcf6f485bd522c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


[PATCH] osmo-msc[master]: smpp: Fix compilation warning

2017-08-24 Thread Neels Hofmeyr

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

smpp: Fix compilation warning

I already stumbled into 2 compilation environments which had Werror
enabled for -Wmaybe-uninitialized and the build failed, so let's
workaround this warning.

| smpp_openbsc.c: In function 'handle_smpp_submit':
| smpp_openbsc.c:216:9: error: 'sms_msg_len' may be used uninitialized in this 
function [-Werror=maybe-uninitialized]
|memcpy(sms->user_data, sms_msg, sms_msg_len);
|  ^
| smpp_openbsc.c:100:15: note: 'sms_msg_len' was declared here
|   unsigned int sms_msg_len;
|^
| cc1: some warnings being treated as errors

Change-Id: I0901ddadb5f72e1585cb1797ac22c8ab95e83146
---
M src/libmsc/smpp_openbsc.c
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/68/3668/1

diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c
index c2f2f3b..ec14898 100644
--- a/src/libmsc/smpp_openbsc.c
+++ b/src/libmsc/smpp_openbsc.c
@@ -94,11 +94,11 @@
 const struct submit_sm_t *submit)
 {
const uint8_t *sms_msg = NULL;
+   unsigned int sms_msg_len = 0;
struct vlr_subscr *dest;
uint16_t msg_ref = 0;
struct gsm_sms *sms;
struct tlv_t *t;
-   unsigned int sms_msg_len;
int mode;
 
dest = subscr_by_dst(net, submit->dest_addr_npi,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0901ddadb5f72e1585cb1797ac22c8ab95e83146
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


[PATCH] osmo-msc[master]: NITB: remove 'help' output about '-a' option that is removed...

2017-08-24 Thread Neels Hofmeyr

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

NITB: remove 'help' output about '-a' option that is removed for ages

This option was present in very early versions of the NITB, but
at least since 2011 it is no longer supported.  It's still listed
in --help output, which is wrong.

Change-Id: I1d2cceb588ec5fb34ec5e2c05a7d8c93310bee88
---
M src/osmo-msc/msc_main.c
1 file changed, 0 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/73/3673/1

diff --git a/src/osmo-msc/msc_main.c b/src/osmo-msc/msc_main.c
index 4166159..6c62db3 100644
--- a/src/osmo-msc/msc_main.c
+++ b/src/osmo-msc/msc_main.c
@@ -140,7 +140,6 @@
printf("  -c --config-file filename  The config file to use.\n");
printf("  -s --disable-color\n");
printf("  -l --database db-name  The database to use.\n");
-   printf("  -a --authorize-everyoneAuthorize every new subscriber. 
Dangerous!\n");
printf("  -T --timestamp Prefix every log line with a 
timestamp.\n");
printf("  -V --version   Print the version of OpenBSC.\n");
printf("  -P --rtp-proxy Enable the RTP Proxy code inside 
OpenBSC.\n");
@@ -163,7 +162,6 @@
{"config-file", 1, 0, 'c'},
{"disable-color", 0, 0, 's'},
{"database", 1, 0, 'l'},
-   {"authorize-everyone", 0, 0, 'a'},
{"pcap", 1, 0, 'p'},
{"timestamp", 0, 0, 'T'},
{"version", 0, 0, 'V' },

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

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


[PATCH] osmo-msc[master]: LIBMSC: Use sms->text, not sms->user_data to construct repor...

2017-08-24 Thread Neels Hofmeyr

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

LIBMSC: Use sms->text, not sms->user_data to construct report body

gsm_04_11.c sms_report_alloc()

Use the sms->text, not the sms->user_data to construct the report body.
This also prevents the potential output of non printable characters to
the log and or vty.

Change-Id: Id51bc9483ad6f52d6da74135605cfd12434c7c96
---
M src/libmsc/gsm_04_11.c
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/66/3666/1

diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index f87acea..55642aa 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -667,7 +667,7 @@
len = snprintf((char *)sms_report->user_data,
   sizeof(sms_report->user_data),
   "id:%.08llu sub:000 dlvrd:000 submit date:YYMMDDhhmm 
done date:YYMMDDhhmm stat:DELIVRD err:000 text:%.20s",
-  sms->id, sms->user_data);
+  sms->id, sms->text);
sms_report->user_data_len = len;
LOGP(DLSMS, LOGL_NOTICE, "%s\n", sms_report->user_data);
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id51bc9483ad6f52d6da74135605cfd12434c7c96
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Keith Whyte 


[PATCH] osmo-msc[master]: libmsc: Use actual delivery time in delivery reports.

2017-08-24 Thread Neels Hofmeyr

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

libmsc: Use actual delivery time in delivery reports.

Set the time on the status report to the time the message was delivered, as
this may not be the same as the time when we are delivering the report to the
originating MS.

Change-Id: I9056429d40bf02731f004b7833f1de45a0d1add8
---
M include/openbsc/gsm_data.h
M src/libmsc/db.c
M src/libmsc/gsm_04_11.c
3 files changed, 4 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/72/3672/1

diff --git a/include/openbsc/gsm_data.h b/include/openbsc/gsm_data.h
index 51cf6dc..f4de381 100644
--- a/include/openbsc/gsm_data.h
+++ b/include/openbsc/gsm_data.h
@@ -511,6 +511,7 @@
} smpp;
 
unsigned long validity_minutes;
+   time_t created;
bool is_report;
uint8_t reply_path_req;
uint8_t status_rep_req;
diff --git a/src/libmsc/db.c b/src/libmsc/db.c
index 3495806..ae7e287 100644
--- a/src/libmsc/db.c
+++ b/src/libmsc/db.c
@@ -742,6 +742,7 @@
 
/* FIXME: validity */
/* FIXME: those should all be get_uchar, but sqlite3 is braindead */
+   sms->created = dbi_result_get_datetime(result, "created");
sms->reply_path_req = dbi_result_get_ulonglong(result, 
"reply_path_req");
sms->status_rep_req = dbi_result_get_ulonglong(result, 
"status_rep_req");
sms->is_report = dbi_result_get_ulonglong(result, "is_report");
diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index 55642aa..c5bcce7 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -312,11 +312,11 @@
 
/* generate TP-SCTS (Service centre timestamp) */
smsp = msgb_put(msg, 7);
-   gsm340_gen_scts(smsp, time(NULL));
+   gsm340_gen_scts(smsp, sms->created);
 
/* generate TP-DT (Discharge time, in TP-SCTS format). */
smsp = msgb_put(msg, 7);
-   gsm340_gen_scts(smsp, time(NULL));
+   gsm340_gen_scts(smsp, sms->created);
 
/* TP-ST (status) */
smsp = msgb_put(msg, 1);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9056429d40bf02731f004b7833f1de45a0d1add8
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Keith Whyte 


[PATCH] osmo-msc[master]: Migrate from gprs_apn_to_str() to libosmocore osmo_apn_to_str()

2017-08-24 Thread Neels Hofmeyr

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

Migrate from gprs_apn_to_str() to libosmocore osmo_apn_to_str()

In 2015, Jacob moved/copied related functions to libosmocore, but
for some reason didn't remove the copies here.  Let's follow-up on
that and remove duplicated code.

The libosmocore commit introducing osmo_apn_to_str() was
8114294bf29ac6e44822c0ae43d4b0819f11b022

Change-Id: I7315ffcbed8a54cca2056f313bb7783ad82d0ee9
---
M include/openbsc/gprs_utils.h
M src/gprs/gb_proxy_patch.c
M src/gprs/gb_proxy_vty.c
M src/gprs/gprs_sgsn.c
M src/gprs/gprs_subscriber.c
M src/gprs/gprs_utils.c
M src/gprs/gtphub.c
M src/gprs/sgsn_cdr.c
M src/gprs/sgsn_vty.c
M tests/gprs/gprs_test.c
M tests/gtphub/Makefile.am
11 files changed, 19 insertions(+), 148 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/62/3662/1

diff --git a/include/openbsc/gprs_utils.h b/include/openbsc/gprs_utils.h
index 603605c..574f5c5 100644
--- a/include/openbsc/gprs_utils.h
+++ b/include/openbsc/gprs_utils.h
@@ -30,7 +30,6 @@
 struct msgb *gprs_msgb_copy(const struct msgb *msg, const char *name);
 int gprs_msgb_resize_area(struct msgb *msg, uint8_t *area,
size_t old_size, size_t new_size);
-char *gprs_apn_to_str(char *out_str, const uint8_t *apn_enc, size_t 
rest_chars);
 int gprs_str_to_apn(uint8_t *apn_enc, size_t max_len, const char *str);
 
 /* GSM 04.08, 10.5.7.3 GPRS Timer */
diff --git a/src/gprs/gb_proxy_patch.c b/src/gprs/gb_proxy_patch.c
index 7bddc44..210fb2b 100644
--- a/src/gprs/gb_proxy_patch.c
+++ b/src/gprs/gb_proxy_patch.c
@@ -28,6 +28,7 @@
 
 #include 
 #include 
+#include 
 
 /* patch RA identifier in place */
 static void gbproxy_patch_raid(uint8_t *raid_enc, struct gbproxy_peer *peer,
@@ -101,7 +102,7 @@
LOGP(DGPRS, LOGL_DEBUG,
 "Patching %s to SGSN: Removing APN '%s'\n",
 log_text,
-gprs_apn_to_str(str1, apn, apn_len));
+osmo_apn_to_str(str1, apn, apn_len));
 
*new_apn_ie_len = 0;
gprs_msgb_resize_area(msg, apn_ie, apn_ie_len, 0);
@@ -116,8 +117,8 @@
 "Patching %s to SGSN: "
 "Replacing APN '%s' -> '%s'\n",
 log_text,
-gprs_apn_to_str(str1, apn, apn_len),
-gprs_apn_to_str(str2, peer->cfg->core_apn,
+osmo_apn_to_str(str1, apn, apn_len),
+osmo_apn_to_str(str2, peer->cfg->core_apn,
   peer->cfg->core_apn_size));
 
*new_apn_ie_len = peer->cfg->core_apn_size + 2;
diff --git a/src/gprs/gb_proxy_vty.c b/src/gprs/gb_proxy_vty.c
index 933b6b0..86d65a8 100644
--- a/src/gprs/gb_proxy_vty.c
+++ b/src/gprs/gb_proxy_vty.c
@@ -29,6 +29,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -107,7 +108,7 @@
   if (g_cfg->core_apn_size > 0) {
   char str[500] = {0};
   vty_out(vty, " core-access-point-name %s%s",
-  gprs_apn_to_str(str, g_cfg->core_apn,
+  osmo_apn_to_str(str, g_cfg->core_apn,
 g_cfg->core_apn_size),
   VTY_NEWLINE);
   } else {
diff --git a/src/gprs/gprs_sgsn.c b/src/gprs/gprs_sgsn.c
index 93b133f..43eeaaa 100644
--- a/src/gprs/gprs_sgsn.c
+++ b/src/gprs/gprs_sgsn.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -758,7 +759,7 @@
return NULL;
}
 
-   gprs_apn_to_str(req_apn_str,
+   osmo_apn_to_str(req_apn_str,
TLVP_VAL(tp, GSM48_IE_GSM_APN),
TLVP_LEN(tp, GSM48_IE_GSM_APN));
 
diff --git a/src/gprs/gprs_subscriber.c b/src/gprs/gprs_subscriber.c
index aa03509..94297d0 100644
--- a/src/gprs/gprs_subscriber.c
+++ b/src/gprs/gprs_subscriber.c
@@ -22,6 +22,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -371,7 +372,7 @@
 
OSMO_ASSERT(pdp_data != NULL);
pdp_data->pdp_type = pdp_info->pdp_type;
-   gprs_apn_to_str(pdp_data->apn_str,
+   osmo_apn_to_str(pdp_data->apn_str,
pdp_info->apn_enc, pdp_info->apn_enc_len);
memcpy(pdp_data->qos_subscribed, pdp_info->qos_enc, 
pdp_info->qos_enc_len);
pdp_data->qos_subscribed_len = pdp_info->qos_enc_len;
diff --git a/src/gprs/gprs_utils.c b/src/gprs/gprs_utils.c
index 64ed978..91a09d2 100644
--- a/src/gprs/gprs_utils.c
+++ b/src/gprs/gprs_utils.c
@@ -114,34 +114,6 @@
return 0;
 }
 
-/* TODO: Move these conversion functions to a utils file. */
-/* TODO: consolidate with gprs_apn2str(). */
-/** memmove apn_enc to out_str, replacing the length octets in apn_enc with '.'
- * (omitting the first one) and 

[PATCH] osmo-msc[master]: libmsc: Fix wrong handling of user_message_reference parameter

2017-08-24 Thread Neels Hofmeyr

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

libmsc: Fix wrong handling of user_message_reference parameter

libsmpp34 already converts received TLV integer values to native
endianess in libsmpp34_(un)pack.

Converting them again at receive time swaps the 2 bytes of
user_message_reference, then using a wrong value. As GSM03.40 spec
uses only 1 byte for the id, then only the high byte of the initial
value is used and eventually sent back to the ESME. Again, at that time,
htons() is not needed because libsmpp34 already handles that part.

See OS-#2429 for more details.

Change-Id: If748548a4a223e529a1110c89e483b599b406e8b
---
M src/libmsc/smpp_openbsc.c
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/69/3669/1

diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c
index ec14898..431cb4d 100644
--- a/src/libmsc/smpp_openbsc.c
+++ b/src/libmsc/smpp_openbsc.c
@@ -121,7 +121,7 @@
}
break;
case TLVID_user_message_reference:
-   msg_ref = ntohs(t->value.val16);
+   msg_ref = t->value.val16;
break;
default:
break;
@@ -437,7 +437,7 @@
memset(, 0, sizeof(tlv));
tlv.tag = tag;
tlv.length = 2;
-   tlv.value.val16 = htons(val);
+   tlv.value.val16 = val;
build_tlv(req_tlv, );
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If748548a4a223e529a1110c89e483b599b406e8b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


[PATCH] osmo-msc[master]: utils: smpp_mirror: set registered_delivery field in SMPP SU...

2017-08-24 Thread Neels Hofmeyr

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

utils: smpp_mirror: set registered_delivery field in SMPP SUBMIT_SM

To test delivery reports using this utility.

Change-Id: I0e477407531fdd4d906e53c9b5a48a79a239966f
---
M src/utils/smpp_mirror.c
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/43/3643/1

diff --git a/src/utils/smpp_mirror.c b/src/utils/smpp_mirror.c
index 95df5f2..ec28f0a 100644
--- a/src/utils/smpp_mirror.c
+++ b/src/utils/smpp_mirror.c
@@ -130,6 +130,7 @@
 sizeof(deliver.destination_addr)));
 
submit.esm_class = deliver.esm_class;
+   submit.registered_delivery = deliver.registered_delivery;
submit.protocol_id = deliver.protocol_id;
submit.priority_flag = deliver.priority_flag;
memcpy(submit.schedule_delivery_time, deliver.schedule_delivery_time,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0e477407531fdd4d906e53c9b5a48a79a239966f
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: Treat SIGTERM just like SIGINT in our programs

2017-08-24 Thread Neels Hofmeyr

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

Treat SIGTERM just like SIGINT in our programs

When somebody kills the process, it's best to handle the signal
and to use the opportunity for some cleanup.  We always did this
in the NITB on SIGINT, but never on SIGTERM. Let's change it.

Change-Id: Iea6804325a6575ceab5edfd28dd20249462f143b
---
M src/gprs/gb_proxy_main.c
M src/gprs/gtphub_main.c
M src/gprs/sgsn_main.c
M src/osmo-bsc/osmo_bsc_main.c
M src/osmo-msc/msc_main.c
5 files changed, 10 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/74/3674/1

diff --git a/src/gprs/gb_proxy_main.c b/src/gprs/gb_proxy_main.c
index 69a93b6..caff27f 100644
--- a/src/gprs/gb_proxy_main.c
+++ b/src/gprs/gb_proxy_main.c
@@ -98,6 +98,7 @@
 
switch (signal) {
case SIGINT:
+   case SIGTERM:
osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
sleep(1);
exit(0);
@@ -232,6 +233,7 @@
msgb_talloc_ctx_init(tall_bsc_ctx, 0);
 
signal(SIGINT, _handler);
+   signal(SIGTERM, _handler);
signal(SIGABRT, _handler);
signal(SIGUSR1, _handler);
signal(SIGUSR2, _handler);
diff --git a/src/gprs/gtphub_main.c b/src/gprs/gtphub_main.c
index 73a122c..2b87d19 100644
--- a/src/gprs/gtphub_main.c
+++ b/src/gprs/gtphub_main.c
@@ -96,6 +96,7 @@
 
switch (signal) {
case SIGINT:
+   case SIGTERM:
osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
sleep(1);
exit(0);
@@ -302,6 +303,7 @@
msgb_talloc_ctx_init(osmo_gtphub_ctx, 0);
 
signal(SIGINT, _handler);
+   signal(SIGTERM, _handler);
signal(SIGABRT, _handler);
signal(SIGUSR1, _handler);
signal(SIGUSR2, _handler);
diff --git a/src/gprs/sgsn_main.c b/src/gprs/sgsn_main.c
index 71cb18c..d5d43ad 100644
--- a/src/gprs/sgsn_main.c
+++ b/src/gprs/sgsn_main.c
@@ -145,6 +145,7 @@
 
switch (signal) {
case SIGINT:
+   case SIGTERM:
osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
sleep(1);
exit(0);
@@ -332,6 +333,7 @@
msgb_talloc_ctx_init(tall_bsc_ctx, 0);
 
signal(SIGINT, _handler);
+   signal(SIGTERM, _handler);
signal(SIGABRT, _handler);
signal(SIGUSR1, _handler);
signal(SIGUSR2, _handler);
diff --git a/src/osmo-bsc/osmo_bsc_main.c b/src/osmo-bsc/osmo_bsc_main.c
index ee094d6..90651b9 100644
--- a/src/osmo-bsc/osmo_bsc_main.c
+++ b/src/osmo-bsc/osmo_bsc_main.c
@@ -162,6 +162,7 @@
 
switch (signal) {
case SIGINT:
+   case SIGTERM:
bsc_shutdown_net(bsc_gsmnet);
osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
sleep(3);
@@ -280,6 +281,7 @@
}
 
signal(SIGINT, _handler);
+   signal(SIGTERM, _handler);
signal(SIGABRT, _handler);
signal(SIGUSR1, _handler);
signal(SIGUSR2, _handler);
diff --git a/src/osmo-msc/msc_main.c b/src/osmo-msc/msc_main.c
index 6c62db3..723c0e6 100644
--- a/src/osmo-msc/msc_main.c
+++ b/src/osmo-msc/msc_main.c
@@ -266,6 +266,7 @@
 
switch (signal) {
case SIGINT:
+   case SIGTERM:
msc_network_shutdown(msc_network);
osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
sleep(3);
@@ -472,6 +473,7 @@
osmo_timer_schedule(_sync_timer, DB_SYNC_INTERVAL);
 
signal(SIGINT, _handler);
+   signal(SIGTERM, _handler);
signal(SIGABRT, _handler);
signal(SIGUSR1, _handler);
signal(SIGUSR2, _handler);

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

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


[PATCH] osmo-msc[master]: SGSN: Fix RAN information exposed on GTP during PDP CTX CREATE

2017-08-24 Thread Neels Hofmeyr

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

SGSN: Fix RAN information exposed on GTP during PDP CTX CREATE

In the PDP Context Create from SGSN to GGSN, we include information
about the RAN type (GERAN/UTRAN) and the Cell of the MS. This was
all hard-coded to GERAN, and wasn't updated when we added UTRAN
support to the SGSN.

Change-Id: I6c79e42c5e08b28fe8182555302a5505fbbaa313
---
M src/gprs/sgsn_libgtp.c
1 file changed, 18 insertions(+), 7 deletions(-)


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

diff --git a/src/gprs/sgsn_libgtp.c b/src/gprs/sgsn_libgtp.c
index bc2fcd1..7ff8ece 100644
--- a/src/gprs/sgsn_libgtp.c
+++ b/src/gprs/sgsn_libgtp.c
@@ -251,18 +251,28 @@
memcpy(pdp->gsnlu.v, >cfg.gtp_listenaddr.sin_addr,
sizeof(sgsn->cfg.gtp_listenaddr.sin_addr));
 
-   /* Routing Area Identifier with LAC and RAC fixed values, as
-* requested in 29.006 7.3.1 */
+   /* Encode RAT Type according to TS 29.060 7.7.50 */
+   pdp->rattype.l = 1;
+   if (mmctx->ran_type == MM_CTX_T_UTRAN_Iu)
+   pdp->rattype.v[0] = 1;
+   else
+   pdp->rattype.v[0] = 2;
+   pdp->rattype_given = 1;
+
+   /* Include RAI and ULI all the time */
pdp->rai_given = 1;
pdp->rai.l = 6;
+
+   /* Routing Area Identifier with LAC and RAC fixed values, as
+* requested in 29.006 7.3.1 */
raid = mmctx->ra;
raid.lac = 0xFFFE;
raid.rac = 0xFF;
gsm48_construct_ra(pdp->rai.v, );
 
-   pdp->rattype.l = 1;
-   pdp->rattype_given = 1;
-
+   /* Encode User Location Information accordint to TS 29.060 7.7.51 */
+   pdp->userloc_given = 1;
+   pdp->userloc.l = 8;
switch (mmctx->ran_type) {
case MM_CTX_T_GERAN_Gb:
case MM_CTX_T_GERAN_Iu:
@@ -274,8 +284,9 @@
bssgp_create_cell_id(>userloc.v[1], >ra, 
mmctx->gb.cell_id);
break;
case MM_CTX_T_UTRAN_Iu:
-   pdp->rattype.v[0] = 1;
-   /* FIXME: Optional User Location Information with SAI */
+   pdp->userloc.v[0] = 1; /* SAI for UTRAN */
+   /* SAI is like CGI but with SAC instead of CID, so we can abuse 
this function */
+   bssgp_create_cell_id(>userloc.v[1], >ra, 
mmctx->iu.sac);
break;
}
 

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

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


[PATCH] osmo-msc[master]: libmsc: use SMPP34_DELIVERY_RECEIPT_* in libsmpp34

2017-08-24 Thread Neels Hofmeyr

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

libmsc: use SMPP34_DELIVERY_RECEIPT_* in libsmpp34

Use new definitions in libsmpp34 to set the registered_delivery field
accordingly, as provided by I5b3afff1b3b77cccd949e0606914c7ac3ba6114c.

Moreover, do not set this header field to zero if status reports are
off, the deliver_t structure has been already zeroed so this not
required.

Change-Id: Ie78e17323796120f576b9c0e1bc5ccc32da8ee12
---
M src/libmsc/smpp_openbsc.c
1 file changed, 1 insertion(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/64/3664/1

diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c
index abf3b3c..c2f2f3b 100644
--- a/src/libmsc/smpp_openbsc.c
+++ b/src/libmsc/smpp_openbsc.c
@@ -631,10 +631,6 @@
return NULL;
 }
 
-/* See SMPP 3.4, Section 5.2.17. registered_delivery (1 byte field). */
-#define SMPP34_NO_DELIVERY_RECEIPT 0x0
-#define SMPP34_DELIVERY_RECEIPT_REQ0x1
-
 static int deliver_to_esme(struct osmo_esme *esme, struct gsm_sms *sms,
   struct gsm_subscriber_connection *conn)
 {
@@ -680,9 +676,7 @@
deliver.protocol_id = sms->protocol_id;
deliver.priority_flag   = 0;
if (sms->status_rep_req)
-   deliver.registered_delivery = SMPP34_DELIVERY_RECEIPT_REQ;
-   else
-   deliver.registered_delivery = SMPP34_NO_DELIVERY_RECEIPT;
+   deliver.registered_delivery = SMPP34_DELIVERY_RECEIPT_ON;
 
/* Figure out SMPP DCS from TP-DCS */
dcs = sms->data_coding_scheme;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie78e17323796120f576b9c0e1bc5ccc32da8ee12
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: gbproxy: log unhandled BSSGP PDU as text

2017-08-24 Thread Neels Hofmeyr

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

gbproxy: log unhandled BSSGP PDU as text

Change-Id: Ibe3c8bd353b3a178e26b0936f25b2e1959f9990c
---
M src/gprs/gb_proxy.c
1 file changed, 1 insertion(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/70/3670/1

diff --git a/src/gprs/gb_proxy.c b/src/gprs/gb_proxy.c
index 3603e14..b98a9a5 100644
--- a/src/gprs/gb_proxy.c
+++ b/src/gprs/gb_proxy.c
@@ -1266,8 +1266,7 @@
rc = bssgp_tx_status(BSSGP_CAUSE_PDU_INCOMP_FEAT, NULL, 
orig_msg);
break;
default:
-   LOGP(DGPRS, LOGL_NOTICE, "BSSGP PDU type 0x%02x unknown\n",
-   pdu_type);
+   LOGP(DGPRS, LOGL_NOTICE, "BSSGP PDU type %s not supported\n", 
bssgp_pdu_str(pdu_type));
rate_ctr_inc(>ctrg->
 ctr[GBPROX_GLOB_CTR_PROTO_ERR_SGSN]);
rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, 
orig_msg);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibe3c8bd353b3a178e26b0936f25b2e1959f9990c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Max 


[PATCH] osmo-msc[master]: sgsn_vty: Don't assume pdp->lib is always valid

2017-08-24 Thread Neels Hofmeyr

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

sgsn_vty: Don't assume pdp->lib is always valid

We can only print libgtp pdp information if a library context is
attached to this pdp context.  This is not always the case,
particuarly during some teardown scenarios.

Change-Id: Ia3184877f9709db65f5f93a98403f2ef5b04a8ca
---
M src/gprs/sgsn_vty.c
1 file changed, 16 insertions(+), 14 deletions(-)


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

diff --git a/src/gprs/sgsn_vty.c b/src/gprs/sgsn_vty.c
index 888f53a..cc8d6c3 100644
--- a/src/gprs/sgsn_vty.c
+++ b/src/gprs/sgsn_vty.c
@@ -468,20 +468,22 @@
const char *imsi = pdp->mm ? pdp->mm->imsi : "(detaching)";
vty_out(vty, "%sPDP Context IMSI: %s, SAPI: %u, NSAPI: %u, TI: %u%s",
pfx, imsi, pdp->sapi, pdp->nsapi, pdp->ti, VTY_NEWLINE);
-   vty_out(vty, "%s  APN: %s%s", pfx,
-   gprs_apn2str(pdp->lib->apn_use.v, pdp->lib->apn_use.l),
-   VTY_NEWLINE);
-   vty_out(vty, "%s  PDP Address: %s%s", pfx,
-   gprs_pdpaddr2str(pdp->lib->eua.v, pdp->lib->eua.l),
-   VTY_NEWLINE);
-   vty_out(vty, "%s  GTP Local Control(%s / TEIC: 0x%08x) ", pfx,
-   gtp_ntoa(>lib->gsnlc), pdp->lib->teic_own);
-   vty_out(vty, "Data(%s / TEID: 0x%08x)%s",
-   gtp_ntoa(>lib->gsnlu), pdp->lib->teid_own, VTY_NEWLINE);
-   vty_out(vty, "%s  GTP Remote Control(%s / TEIC: 0x%08x) ", pfx,
-   gtp_ntoa(>lib->gsnrc), pdp->lib->teic_gn);
-   vty_out(vty, "Data(%s / TEID: 0x%08x)%s",
-   gtp_ntoa(>lib->gsnru), pdp->lib->teid_gn, VTY_NEWLINE);
+   if (pdp->lib) {
+   vty_out(vty, "%s  APN: %s%s", pfx,
+   gprs_apn2str(pdp->lib->apn_use.v, pdp->lib->apn_use.l),
+   VTY_NEWLINE);
+   vty_out(vty, "%s  PDP Address: %s%s", pfx,
+   gprs_pdpaddr2str(pdp->lib->eua.v, pdp->lib->eua.l),
+   VTY_NEWLINE);
+   vty_out(vty, "%s  GTP Local Control(%s / TEIC: 0x%08x) ", pfx,
+   gtp_ntoa(>lib->gsnlc), pdp->lib->teic_own);
+   vty_out(vty, "Data(%s / TEID: 0x%08x)%s",
+   gtp_ntoa(>lib->gsnlu), pdp->lib->teid_own, 
VTY_NEWLINE);
+   vty_out(vty, "%s  GTP Remote Control(%s / TEIC: 0x%08x) ", pfx,
+   gtp_ntoa(>lib->gsnrc), pdp->lib->teic_gn);
+   vty_out(vty, "Data(%s / TEID: 0x%08x)%s",
+   gtp_ntoa(>lib->gsnru), pdp->lib->teid_gn, 
VTY_NEWLINE);
+   }
 
vty_out_rate_ctr_group(vty, " ", pdp->ctrg);
 }

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

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


[PATCH] osmo-msc[master]: gbproxy: log signal value as text

2017-08-24 Thread Neels Hofmeyr

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

gbproxy: log signal value as text

Change-Id: I6ed923f5c60a8d64305f4b8e90d1362d6510e1c5
---
M src/gprs/gb_proxy.c
1 file changed, 4 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/71/3671/1

diff --git a/src/gprs/gb_proxy.c b/src/gprs/gb_proxy.c
index b98a9a5..cd38d23 100644
--- a/src/gprs/gb_proxy.c
+++ b/src/gprs/gb_proxy.c
@@ -1369,9 +1369,8 @@
/* from BSS to SGSN */
peer = gbproxy_peer_by_nsei(cfg, nsvc->nsei);
if (!peer) {
-   LOGP(DGPRS, LOGL_NOTICE, "signal %u for unknown peer "
-"NSEI=%u/NSVCI=%u\n", signal, nsvc->nsei,
-nsvc->nsvci);
+   LOGP(DGPRS, LOGL_NOTICE, "signal '%s' for unknown peer 
NSEI=%u/NSVCI=%u\n",
+get_value_string(gprs_ns_signal_ns_names, signal), 
nsvc->nsei, nsvc->nsvci);
return 0;
}
switch (signal) {
@@ -1379,9 +1378,8 @@
case S_NS_BLOCK:
if (!peer->blocked)
break;
-   LOGP(DGPRS, LOGL_NOTICE, "Converting NS_RESET from "
-"NSEI=%u/NSVCI=%u into BSSGP_BVC_BLOCK to SGSN\n",
-nsvc->nsei, nsvc->nsvci);
+   LOGP(DGPRS, LOGL_NOTICE, "Converting '%s' from 
NSEI=%u/NSVCI=%u into BSSGP_BVC_BLOCK to SGSN\n",
+get_value_string(gprs_ns_signal_ns_names, signal), 
nsvc->nsei, nsvc->nsvci);
bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_BLOCK, nsvc->nsei,
 peer->bvci, 0);
break;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6ed923f5c60a8d64305f4b8e90d1362d6510e1c5
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Max 


[PATCH] osmo-msc[master]: increase libsmpp34 version requirement to 1.12

2017-08-24 Thread Neels Hofmeyr

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

increase libsmpp34 version requirement to 1.12

Only 1.12 contains some of the #defines that we're using with recent
commits.

Change-Id: I3743b10a1a5d2f1d42a61204273c1d00dc22b600
---
M configure.ac
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/63/3663/1

diff --git a/configure.ac b/configure.ac
index f184e78..871f7e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,7 +66,7 @@
 AC_ARG_ENABLE([smpp], [AS_HELP_STRING([--enable-smpp], [Build the SMPP 
interface])],
 [osmo_ac_build_smpp="$enableval"],[osmo_ac_build_smpp="no"])
 if test "$osmo_ac_build_smpp" = "yes" ; then
-PKG_CHECK_MODULES(LIBSMPP34, libsmpp34 >= 1.10)
+PKG_CHECK_MODULES(LIBSMPP34, libsmpp34 >= 1.12)
 AC_DEFINE(BUILD_SMPP, 1, [Define if we want to build SMPP])
 fi
 AM_CONDITIONAL(BUILD_SMPP, test "x$osmo_ac_build_smpp" = "xyes")

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

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


[PATCH] osmo-msc[master]: libmsc: gsm340_gen_oa_sub() may return negative value

2017-08-24 Thread Neels Hofmeyr

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

libmsc: gsm340_gen_oa_sub() may return negative value

gsm340_gen_oa() returns a negative value if the output buffer that the
caller passes is too small, so we have to check the return value of this
function.

Fixes: CID 174178
Fixes: CID 174179
Change-Id: I47215d7d89771730a7f84efa8aeeb187a0911fdb
---
M src/libmsc/gsm_04_11.c
1 file changed, 9 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/51/3651/1

diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index 261e5cd..eede74c 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -215,9 +215,9 @@
 {
uint8_t *smsp;
uint8_t oa[12]; /* max len per 03.40 */
-   uint8_t oa_len = 0;
uint8_t octet_len;
unsigned int old_msg_len = msg->len;
+   int oa_len;
 
/* generate first octet with masked bits */
smsp = msgb_put(msg, 1);
@@ -235,6 +235,9 @@
 
/* generate originator address */
oa_len = gsm340_gen_oa_sub(oa, sizeof(oa), >src);
+   if (oa_len < 0)
+   return -ENOSPC;
+
smsp = msgb_put(msg, oa_len);
memcpy(smsp, oa, oa_len);
 
@@ -284,9 +287,9 @@
 struct gsm_sms *sms)
 {
unsigned int old_msg_len = msg->len;
-   uint8_t oa_len = 0;
uint8_t oa[12]; /* max len per 03.40 */
uint8_t *smsp;
+   int oa_len;
 
/* generate first octet with masked bits */
smsp = msgb_put(msg, 1);
@@ -298,8 +301,12 @@
/* TP-MR (message reference) */
smsp = msgb_put(msg, 1);
*smsp = sms->msg_ref;
+
/* generate recipient address */
oa_len = gsm340_gen_oa_sub(oa, sizeof(oa), >dst);
+   if (oa_len < 0)
+   return -ENOSPC;
+
smsp = msgb_put(msg, oa_len);
memcpy(smsp, oa, oa_len);
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I47215d7d89771730a7f84efa8aeeb187a0911fdb
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: mgcp_osmux: Remove unused parameter

2017-08-24 Thread Neels Hofmeyr

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

mgcp_osmux: Remove unused parameter

Change-Id: Icb1e7cb15fe04642578f5292124ebc1eac9c9aa3
---
M include/openbsc/osmux.h
M src/libmgcp/mgcp_osmux.c
2 files changed, 4 insertions(+), 8 deletions(-)


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

diff --git a/include/openbsc/osmux.h b/include/openbsc/osmux.h
index 0b64a7f..f3ea72a 100644
--- a/include/openbsc/osmux.h
+++ b/include/openbsc/osmux.h
@@ -11,8 +11,7 @@
 };
 
 int osmux_init(int role, struct mgcp_config *cfg);
-int osmux_enable_endpoint(struct mgcp_endpoint *endp, int role,
- struct in_addr *addr, uint16_t port);
+int osmux_enable_endpoint(struct mgcp_endpoint *endp, struct in_addr *addr, 
uint16_t port);
 void osmux_disable_endpoint(struct mgcp_endpoint *endp);
 void osmux_allocate_cid(struct mgcp_endpoint *endp);
 void osmux_release_cid(struct mgcp_endpoint *endp);
diff --git a/src/libmgcp/mgcp_osmux.c b/src/libmgcp/mgcp_osmux.c
index b46a80e..c52984b 100644
--- a/src/libmgcp/mgcp_osmux.c
+++ b/src/libmgcp/mgcp_osmux.c
@@ -340,8 +340,7 @@
if (endp->osmux.state == OSMUX_STATE_ENABLED)
goto out;
 
-   if (osmux_enable_endpoint(endp, OSMUX_ROLE_BSC_NAT,
- >sin_addr, addr->sin_port) < 0 ){
+   if (osmux_enable_endpoint(endp, >sin_addr, addr->sin_port) < 0 ) {
LOGP(DMGCP, LOGL_ERROR,
 "Could not enable osmux in endpoint %d\n",
 ENDPOINT_NUMBER(endp));
@@ -433,8 +432,7 @@
return 0;
 }
 
-int osmux_enable_endpoint(struct mgcp_endpoint *endp, int role,
- struct in_addr *addr, uint16_t port)
+int osmux_enable_endpoint(struct mgcp_endpoint *endp, struct in_addr *addr, 
uint16_t port)
 {
/* If osmux is enabled, initialize the output handler. This handler is
 * used to reconstruct the RTP flow from osmux. The RTP SSRC is
@@ -522,8 +520,7 @@
return 0;
 
if (endp->osmux.state == OSMUX_STATE_ACTIVATING) {
-   if (osmux_enable_endpoint(endp, OSMUX_ROLE_BSC,
- >net_end.addr,
+   if (osmux_enable_endpoint(endp, >net_end.addr,
  htons(endp->cfg->osmux_port)) < 0) {
LOGP(DMGCP, LOGL_ERROR,
 "Could not activate osmux in endpoint %d\n",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icb1e7cb15fe04642578f5292124ebc1eac9c9aa3
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


[PATCH] osmo-msc[master]: utils: smpp_mirror: temporarily munch SMPP delivery receipts

2017-08-24 Thread Neels Hofmeyr

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

utils: smpp_mirror: temporarily munch SMPP delivery receipts

Just munch and log SMPP delivery receipts by now, don't mirror this, it
is going to break things in openbsc.

Follow up patch removes this and mirrors this SMPP message as a
SUBMIT_SM with esm_class = Delivery Acknowledgement.

Change-Id: I78e93bc4034679e238c8642ccf6a0e844b1d6d8b
---
M src/utils/smpp_mirror.c
1 file changed, 8 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/44/3644/1

diff --git a/src/utils/smpp_mirror.c b/src/utils/smpp_mirror.c
index ec28f0a..edb40b5 100644
--- a/src/utils/smpp_mirror.c
+++ b/src/utils/smpp_mirror.c
@@ -112,6 +112,14 @@
 
PACK_AND_SEND(esme, _r);
 
+   /* This is a delivery receipt, temporarily munch it until we teach
+* openbsc what to do with this.
+*/
+   if (deliver.esm_class == 0x04) {
+   LOGP(DSMPP, LOGL_NOTICE, "%s\n", deliver.short_message);
+   return 0;
+   }
+
memset(, 0, sizeof(submit));
submit.command_id = SUBMIT_SM;
submit.command_status = ESME_ROK;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I78e93bc4034679e238c8642ccf6a0e844b1d6d8b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: libmsc: update database to accomodate SMS status-report fields

2017-08-24 Thread Neels Hofmeyr

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

libmsc: update database to accomodate SMS status-report fields

SMPP DELIVER_SM messages with esm_class = Delivery Receipt need to send
this message reference (that the mobile phone allocates) to the ESME.
Thus, the ESME propagates it via SUBMIT_SM with esm_class = Delivery
Acknoledgment so that the SMSC sends the GSM 03.40 status-report to the
origin including this. Given this field is useful for status-reports, we
need to store it in the HLR database.

Moreover, we need a new field that specifies if the entry represents a
SMS status-report, to do the right handling from the gsm411_send_sms() -
such new handling comes in a follow up patch entitled "libmsc: handle
delivery ack via SMPP SUBMIT SM / send GSM 03.40 status report".

This patch includes the migration routines to the new database schema
revision 5, it's quite a bit of dbi boilerplate code - copied-pasted and
adapted.

Change-Id: I7276d356d805a83ebeec72b02c8563b7135ea0b6
---
M src/libmsc/db.c
M tests/db/db_test.err
2 files changed, 163 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/47/3647/1

diff --git a/src/libmsc/db.c b/src/libmsc/db.c
index 28e9782..78e022d 100644
--- a/src/libmsc/db.c
+++ b/src/libmsc/db.c
@@ -48,7 +48,7 @@
 static char *db_dirname = NULL;
 static dbi_conn conn;
 
-#define SCHEMA_REVISION "4"
+#define SCHEMA_REVISION "5"
 
 enum {
SCHEMA_META,
@@ -122,6 +122,8 @@
"valid_until TIMESTAMP, "
"reply_path_req INTEGER NOT NULL, "
"status_rep_req INTEGER NOT NULL, "
+   "is_report INTEGER NOT NULL, "
+   "msg_ref INTEGER NOT NULL, "
"protocol_id INTEGER NOT NULL, "
"data_coding_scheme INTEGER NOT NULL, "
"ud_hdr_ind INTEGER NOT NULL, "
@@ -378,6 +380,152 @@
return -EINVAL;
 }
 
+/* Just like v3, but there is a new message reference field for status reports,
+ * that is set to zero for existing entries since there is no way we can infer
+ * this.
+ */
+static struct gsm_sms *sms_from_result_v4(dbi_result result)
+{
+   struct gsm_sms *sms = sms_alloc();
+   const unsigned char *user_data;
+   const char *text, *addr;
+
+   if (!sms)
+   return NULL;
+
+   sms->id = dbi_result_get_ulonglong(result, "id");
+
+   sms->reply_path_req = dbi_result_get_ulonglong(result, 
"reply_path_req");
+   sms->status_rep_req = dbi_result_get_ulonglong(result, 
"status_rep_req");
+   sms->ud_hdr_ind = dbi_result_get_ulonglong(result, "ud_hdr_ind");
+   sms->protocol_id = dbi_result_get_ulonglong(result, "protocol_id");
+   sms->data_coding_scheme = dbi_result_get_ulonglong(result,
+ "data_coding_scheme");
+
+   addr = dbi_result_get_string(result, "src_addr");
+   osmo_strlcpy(sms->src.addr, addr, sizeof(sms->src.addr));
+   sms->src.ton = dbi_result_get_ulonglong(result, "src_ton");
+   sms->src.npi = dbi_result_get_ulonglong(result, "src_npi");
+
+   addr = dbi_result_get_string(result, "dest_addr");
+   osmo_strlcpy(sms->dst.addr, addr, sizeof(sms->dst.addr));
+   sms->dst.ton = dbi_result_get_ulonglong(result, "dest_ton");
+   sms->dst.npi = dbi_result_get_ulonglong(result, "dest_npi");
+
+   sms->user_data_len = dbi_result_get_field_length(result, "user_data");
+   user_data = dbi_result_get_binary(result, "user_data");
+   if (sms->user_data_len > sizeof(sms->user_data))
+   sms->user_data_len = (uint8_t) sizeof(sms->user_data);
+   memcpy(sms->user_data, user_data, sms->user_data_len);
+
+   text = dbi_result_get_string(result, "text");
+   if (text)
+   osmo_strlcpy(sms->text, text, sizeof(sms->text));
+   return sms;
+}
+
+static int update_db_revision_4(void)
+{
+   dbi_result result;
+   struct gsm_sms *sms;
+
+   LOGP(DDB, LOGL_NOTICE, "Going to migrate from revision 4\n");
+
+   result = dbi_conn_query(conn, "BEGIN EXCLUSIVE TRANSACTION");
+   if (!result) {
+   LOGP(DDB, LOGL_ERROR,
+   "Failed to begin transaction (upgrade from rev 4)\n");
+   return -EINVAL;
+   }
+   dbi_result_free(result);
+
+   /* Rename old SMS table to be able create a new one */
+   result = dbi_conn_query(conn, "ALTER TABLE SMS RENAME TO SMS_4");
+   if (!result) {
+   LOGP(DDB, LOGL_ERROR,
+"Failed to rename the old SMS table (upgrade from rev 
4).\n");
+   goto rollback;
+   }
+   dbi_result_free(result);
+
+   /* Create new SMS table with all the bells and whistles! */
+   result = dbi_conn_query(conn, create_stmts[SCHEMA_SMS]);
+   if (!result) {
+   LOGP(DDB, LOGL_ERROR,
+"Failed to create a new SMS table (upgrade from rev 
4).\n");
+   goto rollback;
+   }

[PATCH] osmo-msc[master]: Fix gsm_pchan2chan_nr() to use RSL_CHAN_OSMO_PDCH

2017-08-24 Thread Neels Hofmeyr

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

Fix gsm_pchan2chan_nr() to use RSL_CHAN_OSMO_PDCH

When converting from GSM_PCHAN_PDCH, we should generate
a RSL channel number IE with the osmocom extension
RSL_CHAN_OSMO_PDCH rather than claiming it is a regular
TCH/F channel.

This is important as this function is used by
osmo-bts, too - and it decides which channel number IE is
put in the GSMTAP header for both GSMTAP tracing as well
as the GSMTAP based osmo-bts-virtual.

In order to avoid any unintended effect on libbsc,
we make sure to modify rsl_ipacc_pdch_activate() to
always use GSM_PCHAN_TCH_F in related RSL message.

Change-Id: Ie34219e64a6d89da4a79f2db8ec73d1909fb8280
---
M src/libbsc/abis_rsl.c
M src/libcommon/gsm_data_shared.c
2 files changed, 5 insertions(+), 2 deletions(-)


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

diff --git a/src/libbsc/abis_rsl.c b/src/libbsc/abis_rsl.c
index 3337b90..4f687a0 100644
--- a/src/libbsc/abis_rsl.c
+++ b/src/libbsc/abis_rsl.c
@@ -2450,7 +2450,7 @@
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
init_dchan_hdr(dh, msg_type);
dh->c.msg_discr = ABIS_RSL_MDISC_DED_CHAN;
-   dh->chan_nr = gsm_pchan2chan_nr(GSM_PCHAN_PDCH, ts->nr, 0);
+   dh->chan_nr = gsm_pchan2chan_nr(GSM_PCHAN_TCH_F, ts->nr, 0);
 
DEBUGP(DRSL, "%s IPAC PDCH %sACT\n", gsm_ts_name(ts),
act ? "" : "DE");
diff --git a/src/libcommon/gsm_data_shared.c b/src/libcommon/gsm_data_shared.c
index d792f3b..2696273 100644
--- a/src/libcommon/gsm_data_shared.c
+++ b/src/libcommon/gsm_data_shared.c
@@ -644,11 +644,14 @@
 
switch (pchan) {
case GSM_PCHAN_TCH_F:
-   case GSM_PCHAN_PDCH:
case GSM_PCHAN_TCH_F_PDCH:
OSMO_ASSERT(lchan_nr == 0);
cbits = 0x01;
break;
+   case GSM_PCHAN_PDCH:
+   OSMO_ASSERT(lchan_nr == 0);
+   cbits = RSL_CHAN_OSMO_PDCH >> 3;
+   break;
case GSM_PCHAN_TCH_H:
OSMO_ASSERT(lchan_nr < 2);
cbits = 0x02;

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

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


[PATCH] osmo-msc[master]: utils: smpp_mirror: reflect message reference TLV

2017-08-24 Thread Neels Hofmeyr

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

utils: smpp_mirror: reflect message reference TLV

Useful to test the delivery receipt support. This TLV contains the
GSM03.40 message reference.

Change-Id: I1b0abaa7e06ffe1bd2242c70813d8b70e9fa954f
---
M src/utils/smpp_mirror.c
1 file changed, 23 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/45/3645/1

diff --git a/src/utils/smpp_mirror.c b/src/utils/smpp_mirror.c
index edb40b5..88545de 100644
--- a/src/utils/smpp_mirror.c
+++ b/src/utils/smpp_mirror.c
@@ -95,12 +95,23 @@
 }
 /* FIXME: merge with smpp_smsc.c */
 
+static struct tlv_t *find_tlv(struct tlv_t *head, uint16_t tag)
+{
+   struct tlv_t *t;
+
+   for (t = head; t != NULL; t = t->next) {
+   if (t->tag == tag)
+   return t;
+   }
+   return NULL;
+}
 
 static int smpp_handle_deliver(struct esme *esme, struct msgb *msg)
 {
struct deliver_sm_t deliver;
struct deliver_sm_resp_t deliver_r;
struct submit_sm_t submit;
+   tlv_t *t;
int rc;
 
memset(, 0, sizeof(deliver));
@@ -155,7 +166,18 @@
memcpy(submit.short_message, deliver.short_message,
OSMO_MIN(sizeof(submit.short_message),
 sizeof(deliver.short_message)));
-   /* FIXME: TLV? */
+
+   /* FIXME: More TLV? */
+   t = find_tlv(deliver.tlv, TLVID_user_message_reference);
+   if (t) {
+   tlv_t tlv;
+
+   memset(, 0, sizeof(tlv));
+   tlv.tag = TLVID_user_message_reference;
+   tlv.length = 2;
+   tlv.value.val16 = t->value.val16;
+   build_tlv(, );
+   }
 
return PACK_AND_SEND(esme, );
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1b0abaa7e06ffe1bd2242c70813d8b70e9fa954f
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: libmsc: missing bit shift in status report flag when stored ...

2017-08-24 Thread Neels Hofmeyr

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

libmsc: missing bit shift in status report flag when stored in sms object

So we just store 0 or 1 depending on what the mobile phone requests.

Change-Id: Idb7d5594219c0e458ccb561383a59604bc1a4201
---
M src/libmsc/gsm_04_11.c
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/42/3642/1

diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index ef2635b..cd23883 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -368,7 +368,7 @@
/* invert those fields where 0 means active/present */
sms_mti = *smsp & 0x03;
sms_vpf = (*smsp & 0x18) >> 3;
-   gsms->status_rep_req = (*smsp & 0x20);
+   gsms->status_rep_req = (*smsp & 0x20) >> 5;
gsms->ud_hdr_ind = (*smsp & 0x40);
/*
 * Not evaluating MMS (More Messages to Send) because the

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idb7d5594219c0e458ccb561383a59604bc1a4201
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: LIBMSC: Place correct dst address in status report

2017-08-24 Thread Neels Hofmeyr

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

LIBMSC: Place correct dst address in status report

gsm_04_11.c: gsm340_gen_sms_status_report_tpdu()

When we construct the status report PDU, use sms->src
instead of sms->dst as the destination address
This way we tell the MS that the message was delivered
to the destination and not to itself.
This is relevant for phones that display a textual
representation of the delivery report.

Change-Id: I2d4f87ac777465de9bfb5a775a789a2691755ee9
---
M src/libmsc/gsm_04_11.c
1 file changed, 1 insertion(+), 1 deletion(-)


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

diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index eede74c..f87acea 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -303,7 +303,7 @@
*smsp = sms->msg_ref;
 
/* generate recipient address */
-   oa_len = gsm340_gen_oa_sub(oa, sizeof(oa), >dst);
+   oa_len = gsm340_gen_oa_sub(oa, sizeof(oa), >src);
if (oa_len < 0)
return -ENOSPC;
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2d4f87ac777465de9bfb5a775a789a2691755ee9
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Keith Whyte 


[PATCH] osmo-msc[master]: utils: smpp_mirror: bounce Delivery Receipts as Delivery Ack...

2017-08-24 Thread Neels Hofmeyr

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

utils: smpp_mirror: bounce Delivery Receipts as Delivery Acknowledgments

Simple patch to test the new status-report support code, remove previous
code before Delivery Acknowledgement support was in place. Use
LOGL_DEBUG for logging messages here as suggested by Neels and Harald.

Change-Id: I877e228d8e174430f700631edbf9955972da7892
---
M src/utils/smpp_mirror.c
1 file changed, 8 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/48/3648/1

diff --git a/src/utils/smpp_mirror.c b/src/utils/smpp_mirror.c
index 88545de..c570505 100644
--- a/src/utils/smpp_mirror.c
+++ b/src/utils/smpp_mirror.c
@@ -123,14 +123,6 @@
 
PACK_AND_SEND(esme, _r);
 
-   /* This is a delivery receipt, temporarily munch it until we teach
-* openbsc what to do with this.
-*/
-   if (deliver.esm_class == 0x04) {
-   LOGP(DSMPP, LOGL_NOTICE, "%s\n", deliver.short_message);
-   return 0;
-   }
-
memset(, 0, sizeof(submit));
submit.command_id = SUBMIT_SM;
submit.command_status = ESME_ROK;
@@ -148,7 +140,14 @@
OSMO_MIN(sizeof(submit.source_addr),
 sizeof(deliver.destination_addr)));
 
-   submit.esm_class = deliver.esm_class;
+   /* Mirror delivery receipts as a delivery acknowledgements. */
+   if (deliver.esm_class == 0x04) {
+   LOGP(DSMPP, LOGL_DEBUG, "%s\n", deliver.short_message);
+   submit.esm_class = 0x08;
+   } else {
+   submit.esm_class = deliver.esm_class;
+   }
+
submit.registered_delivery = deliver.registered_delivery;
submit.protocol_id = deliver.protocol_id;
submit.priority_flag = deliver.priority_flag;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I877e228d8e174430f700631edbf9955972da7892
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: libcommon: Fix log output for bts>0.

2017-08-24 Thread Neels Hofmeyr

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

libcommon: Fix log output for bts>0.

Fixes regression probably introduced in c696cc28.

For bts>0 logging doesn't show bts number correctly when printing lchan
identification string - it will always show it as "bts=0". The reason for
this is that the identification string is cached before bts->nr value is
set to a proper value.

This patch sets bts->nr as part of the first step of the bts structure
initialization, before caching happens thus making sure the cached
identification string is cached with the correct values.

Change-Id: I61c18a7f021fcb1ec00d34a745f4e3ab03416c2d
---
M include/openbsc/gsm_data_shared.h
M src/libcommon/gsm_data.c
M src/libcommon/gsm_data_shared.c
M tests/channel/channel_test.c
M tests/channel/channel_test.ok
M tests/gsm0408/gsm0408_test.c
6 files changed, 42 insertions(+), 9 deletions(-)


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

diff --git a/include/openbsc/gsm_data_shared.h 
b/include/openbsc/gsm_data_shared.h
index 0790807..60da2e5 100644
--- a/include/openbsc/gsm_data_shared.h
+++ b/include/openbsc/gsm_data_shared.h
@@ -899,7 +899,7 @@
 };
 
 
-struct gsm_bts *gsm_bts_alloc(void *talloc_ctx);
+struct gsm_bts *gsm_bts_alloc(void *talloc_ctx, uint8_t bts_num);
 struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);
 
 struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
diff --git a/src/libcommon/gsm_data.c b/src/libcommon/gsm_data.c
index b5bf059..7be2240 100644
--- a/src/libcommon/gsm_data.c
+++ b/src/libcommon/gsm_data.c
@@ -254,12 +254,13 @@
if (!model && type != GSM_BTS_TYPE_UNKNOWN)
return NULL;
 
-   bts = gsm_bts_alloc(net);
+   bts = gsm_bts_alloc(net, net->num_bts);
if (!bts)
return NULL;
 
+   net->num_bts++;
+
bts->network = net;
-   bts->nr = net->num_bts++;
bts->type = type;
bts->model = model;
bts->bsic = bsic;
diff --git a/src/libcommon/gsm_data_shared.c b/src/libcommon/gsm_data_shared.c
index 8992636..d792f3b 100644
--- a/src/libcommon/gsm_data_shared.c
+++ b/src/libcommon/gsm_data_shared.c
@@ -312,7 +312,7 @@
.initial_mcs = 6,
 };
 
-struct gsm_bts *gsm_bts_alloc(void *ctx)
+struct gsm_bts *gsm_bts_alloc(void *ctx, uint8_t bts_num)
 {
struct gsm_bts *bts = talloc_zero(ctx, struct gsm_bts);
int i;
@@ -320,6 +320,7 @@
if (!bts)
return NULL;
 
+   bts->nr = bts_num;
bts->num_trx = 0;
INIT_LLIST_HEAD(>trx_list);
bts->ms_max_power = 15; /* dBm */
diff --git a/tests/channel/channel_test.c b/tests/channel/channel_test.c
index f686969..beae658 100644
--- a/tests/channel/channel_test.c
+++ b/tests/channel/channel_test.c
@@ -31,6 +31,35 @@
 #include 
 #include 
 
+void test_bts_debug_print(void)
+{
+   struct gsm_network *network;
+   struct gsm_bts *bts;
+   struct gsm_bts_trx *trx;
+
+   printf("Testing the lchan printing:");
+
+   /* Create a dummy network */
+   network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
+   if (!network)
+   exit(1);
+   /* Add a BTS with some reasonanbly non-zero id */
+   bts = gsm_bts_alloc(network, 45);
+   /* Add a second TRX to test on multiple TRXs */
+   gsm_bts_trx_alloc(bts);
+
+   llist_for_each_entry(trx, >trx_list, list) {
+   char *name = gsm_lchan_name(>ts[3].lchan[4]);
+
+   if (name)
+   printf(" %s", name);
+   else
+   printf("NULL name");
+   }
+   printf("\n");
+}
+
+
 void test_dyn_ts_subslots(void)
 {
struct gsm_bts_trx_ts ts;
@@ -66,6 +95,7 @@
osmo_init_logging(_info);
 
test_dyn_ts_subslots();
+   test_bts_debug_print();
 
return EXIT_SUCCESS;
 }
diff --git a/tests/channel/channel_test.ok b/tests/channel/channel_test.ok
index e4d625a..81d6569 100644
--- a/tests/channel/channel_test.ok
+++ b/tests/channel/channel_test.ok
@@ -1 +1,2 @@
 Testing subslot numbers for pchan types
+Testing the lchan printing: (bts=45,trx=0,ts=3,ss=4) (bts=45,trx=1,ts=3,ss=4)
diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index 1b326ee..fcdc8f8 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -153,7 +153,7 @@
 
if (!network)
exit(1);
-   bts = gsm_bts_alloc(network);
+   bts = gsm_bts_alloc(network, 0);
 
_bts_uarfcn_add(bts, 10564, 319, 0);
_bts_uarfcn_add(bts, 10612, 319, 0);
@@ -168,7 +168,7 @@
 
if (!network)
exit(1);
-   bts = gsm_bts_alloc(network);
+   bts = gsm_bts_alloc(network, 0);
 
_bts_uarfcn_add(bts, 10564, 318, 0);
_bts_uarfcn_add(bts, 10612, 319, 0);
@@ -188,7 +188,7 @@
if (!network)
exit(1);
 
-   bts = gsm_bts_alloc(network);
+   bts = gsm_bts_alloc(network, 0);
 
/* first generate invalid SI 

[PATCH] osmo-msc[master]: handover_logic: set correct link to bts for subscriber_conne...

2017-08-24 Thread Neels Hofmeyr

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

handover_logic: set correct link to bts for subscriber_connection in case of 
moving this connection to another bts

In case of successful completion of handover gsm_subscriber_connection could be 
moved from one bts to another,
so connection link to bts should be replaced by link to bts, which owns 
new_lchan.
This bug was detected, because conn->bts->nr is used in call control log 
messages
and wrong number of bts was observed in these messages after handover.

Change-Id: Idc7dd412b7580c451e716b73ef7549826c60b0d9
---
M src/libbsc/handover_logic.c
1 file changed, 1 insertion(+), 0 deletions(-)


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

diff --git a/src/libbsc/handover_logic.c b/src/libbsc/handover_logic.c
index c03563f..57d1dcd 100644
--- a/src/libbsc/handover_logic.c
+++ b/src/libbsc/handover_logic.c
@@ -282,6 +282,7 @@
 
new_lchan->conn->ho_lchan = NULL;
new_lchan->conn->lchan = new_lchan;
+   new_lchan->conn->bts = new_lchan->ts->trx->bts;
ho->old_lchan->conn = NULL;
 
lchan_release(ho->old_lchan, 0, RSL_REL_LOCAL_END);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idc7dd412b7580c451e716b73ef7549826c60b0d9
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Ivan Kluchnikov 


[PATCH] osmo-msc[master]: libmsc: use new smpp34 esm_class definitions

2017-08-24 Thread Neels Hofmeyr

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

libmsc: use new smpp34 esm_class definitions

Replace magic numbers by esm_class definitions, which
have been added to latest libsmpp34 in Change-Id
I91afd8b462b8fd3b2c4c5b54f4eeb7ec5b730b65

Change-Id: I6c458690da60c8f3637680efbd718f6e8c6feb4c
---
M src/libmsc/smpp_openbsc.c
1 file changed, 8 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/54/3654/1

diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c
index 1ffb0cd..abf3b3c 100644
--- a/src/libmsc/smpp_openbsc.c
+++ b/src/libmsc/smpp_openbsc.c
@@ -158,14 +158,13 @@
osmo_strlcpy(sms->src.addr, (char *)submit->source_addr,
 sizeof(sms->src.addr));
 
-   /* This is a Delivery Acknowledgment. */
-   if (submit->esm_class == 0x08)
+   if (submit->esm_class == SMPP34_DELIVERY_ACK)
sms->is_report = true;
 
-   if (submit->esm_class & 0x40)
+   if (submit->esm_class & SMPP34_UDHI_IND)
sms->ud_hdr_ind = 1;
 
-   if (submit->esm_class & 0x80) {
+   if (submit->esm_class & SMPP34_REPLY_PATH) {
sms->reply_path_req = 1;
 #warning Implement reply path
}
@@ -241,7 +240,7 @@
sms->smpp.esme = esme;
sms->protocol_id = submit->protocol_id;
 
-   switch (submit->esm_class & 3) {
+   switch (submit->esm_class & SMPP34_MSG_MODE_MASK) {
case 0: /* default */
case 1: /* datagram */
case 3: /* store-and-forward */
@@ -668,16 +667,15 @@
memcpy(deliver.destination_addr, sms->dst.addr,
sizeof(deliver.destination_addr));
 
-   /* Short message contains a delivery receipt? Sect. 5.2.12. */
if (sms->is_report)
-   deliver.esm_class = 0x04;
+   deliver.esm_class = SMPP34_DELIVERY_RECEIPT;
else
-   deliver.esm_class = 1;  /* datagram mode */
+   deliver.esm_class = SMPP34_DATAGRAM_MODE;
 
if (sms->ud_hdr_ind)
-   deliver.esm_class |= 0x40;
+   deliver.esm_class |= SMPP34_UDHI_IND;
if (sms->reply_path_req)
-   deliver.esm_class |= 0x80;
+   deliver.esm_class |= SMPP34_REPLY_PATH;
 
deliver.protocol_id = sms->protocol_id;
deliver.priority_flag   = 0;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c458690da60c8f3637680efbd718f6e8c6feb4c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: libmsc: Remove comment not applying anymore

2017-08-24 Thread Neels Hofmeyr

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

libmsc: Remove comment not applying anymore

The change-id I7276d356d805a83ebeec72b02c8563b7135ea0b6 added msg_ref to
the databse but forgot to remove the comment stating it's not being
stored.

Change-Id: I204f098c8f2a480405446113e2181b2c53700cf3
---
M src/libmsc/db.c
1 file changed, 0 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/52/3652/1

diff --git a/src/libmsc/db.c b/src/libmsc/db.c
index 78e022d..3495806 100644
--- a/src/libmsc/db.c
+++ b/src/libmsc/db.c
@@ -750,7 +750,6 @@
sms->protocol_id = dbi_result_get_ulonglong(result, "protocol_id");
sms->data_coding_scheme = dbi_result_get_ulonglong(result,
  "data_coding_scheme");
-   /* sms->msg_ref is temporary and not stored in DB */
 
sms->dst.npi = dbi_result_get_ulonglong(result, "dest_npi");
sms->dst.ton = dbi_result_get_ulonglong(result, "dest_ton");

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I204f098c8f2a480405446113e2181b2c53700cf3
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


[PATCH] osmo-msc[master]: libmsc: support GSM 03.40 status report for nitb

2017-08-24 Thread Neels Hofmeyr

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

libmsc: support GSM 03.40 status report for nitb

This patch adds support for GSM 03.40 in nitb mode.

  MS GSM 03.40  SMSC
   ||
   | SMS-SUBMIT |
   |--->|
   | GSM 04.11 RP-ACK   |
   |<---|
   | SMS-DELIVER|
   |<---|
   | GSM 04.11 RP-ACK   |
   |--->|
   | SMS-STATUS-REPORT  |
   |<---|
   | GSM 04.11 RP-ACK   |
   |--->|
   ||

Change-Id: I5cc7bb4ebadde0940f44d10c3df34707b0615160
---
M src/libmsc/gsm_04_11.c
1 file changed, 5 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/50/3650/1

diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index 0a1348d..261e5cd 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -683,6 +683,11 @@
LOGP(DLSMS, LOGL_ERROR,
 "Failed to send status report! err=%d\n", rc);
}
+
+   /* No route via SMPP, send the GSM 03.40 status-report now. */
+   if (gsms->receiver)
+   gsm340_rx_sms_submit(sms_report);
+
LOGP(DLSMS, LOGL_NOTICE, "Status report has been sent\n");
 
sms_free(sms_report);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5cc7bb4ebadde0940f44d10c3df34707b0615160
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: libmsc: set registered_delivery field in SMPP 3.4 DELIVER_SM...

2017-08-24 Thread Neels Hofmeyr

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

libmsc: set registered_delivery field in SMPP 3.4 DELIVER_SM messages

Propagate the status report request field to the SMPP message through
the registered_delivery field, so the ESME knows that the mobile phone
is asking for explicit delivery acknowledgment is required. See SMPP 3.4
specs section 5.2.17.

Change-Id: I59af60fa89cd10ae973c5e122789e3e03e3728ee
---
M src/libmsc/smpp_openbsc.c
1 file changed, 8 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/40/3640/1

diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c
index bf63f6b..8a1a7da 100644
--- a/src/libmsc/smpp_openbsc.c
+++ b/src/libmsc/smpp_openbsc.c
@@ -606,6 +606,10 @@
return NULL;
 }
 
+/* See SMPP 3.4, Section 5.2.17. registered_delivery (1 byte field). */
+#define SMPP34_NO_DELIVERY_RECEIPT 0x0
+#define SMPP34_DELIVERY_RECEIPT_REQ0x1
+
 static int deliver_to_esme(struct osmo_esme *esme, struct gsm_sms *sms,
   struct gsm_subscriber_connection *conn)
 {
@@ -646,7 +650,10 @@
 
deliver.protocol_id = sms->protocol_id;
deliver.priority_flag   = 0;
-   deliver.registered_delivery = 0;
+   if (sms->status_rep_req)
+   deliver.registered_delivery = SMPP34_DELIVERY_RECEIPT_REQ;
+   else
+   deliver.registered_delivery = SMPP34_NO_DELIVERY_RECEIPT;
 
/* Figure out SMPP DCS from TP-DCS */
dcs = sms->data_coding_scheme;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I59af60fa89cd10ae973c5e122789e3e03e3728ee
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: libmsc: handle delivery ack via SMPP SUBMIT SM / send GSM 03...

2017-08-24 Thread Neels Hofmeyr

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

libmsc: handle delivery ack via SMPP SUBMIT SM / send GSM 03.40 status report

This patch adds gsm340_sms_send_status_report_tpdu() to build a
status-report. Moreover, set sms->report field if we see a SMPP
SUBMIT_SM with Delivery Acknowledgment esm_class, so this identifies
that this is a delivery report.

MSGSM 03.40   SMSC   SMPP 3.4   ESME
 | ||
 | |   SUBMIT-SM|
 | |esm_class = Delivery Ack|
 | |<---|
 | | SUBMIT-SM-RESP |
 | |--->|
 | ||
 | SMS-STATUS-REPORT   ||
 |<||
 | GSM 04.11 RP-ACK||
 |>||
 | ||

There is a FIXME message in this patch, that I just copied from
gsm340_gen_sms_deliver_tpdu() since TP-MMS is not supported by OpenBSC.

Change-Id: Ib70e534840308ed315f7add440351e649de3f907
---
M src/libmsc/gsm_04_11.c
M src/libmsc/smpp_openbsc.c
2 files changed, 54 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/49/3649/1

diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index b4fa3df..0a1348d 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -279,6 +279,49 @@
return msg->len - old_msg_len;
 }
 
+/* As defined by GSM 03.40, Section 9.2.2.3. */
+static int gsm340_gen_sms_status_report_tpdu(struct msgb *msg,
+struct gsm_sms *sms)
+{
+   unsigned int old_msg_len = msg->len;
+   uint8_t oa_len = 0;
+   uint8_t oa[12]; /* max len per 03.40 */
+   uint8_t *smsp;
+
+   /* generate first octet with masked bits */
+   smsp = msgb_put(msg, 1);
+   /* TP-MTI (message type indicator) */
+   *smsp = GSM340_SMS_STATUS_REP_SC2MS;
+   /* TP-MMS (more messages to send) */
+   if (0 /* FIXME */)
+   *smsp |= 0x04;
+   /* TP-MR (message reference) */
+   smsp = msgb_put(msg, 1);
+   *smsp = sms->msg_ref;
+   /* generate recipient address */
+   oa_len = gsm340_gen_oa_sub(oa, sizeof(oa), >dst);
+   smsp = msgb_put(msg, oa_len);
+   memcpy(smsp, oa, oa_len);
+
+   /* generate TP-SCTS (Service centre timestamp) */
+   smsp = msgb_put(msg, 7);
+   gsm340_gen_scts(smsp, time(NULL));
+
+   /* generate TP-DT (Discharge time, in TP-SCTS format). */
+   smsp = msgb_put(msg, 7);
+   gsm340_gen_scts(smsp, time(NULL));
+
+   /* TP-ST (status) */
+   smsp = msgb_put(msg, 1);
+   /* From GSM 03.40, Section 9.2.3.15, 0x00 means OK. */
+   *smsp = 0x00;
+
+   LOGP(DLSMS, LOGL_INFO, "sending status report for SMS reference %x\n",
+sms->msg_ref);
+
+   return msg->len - old_msg_len;
+}
+
 static int sms_route_mt_sms(struct gsm_subscriber_connection *conn,
struct gsm_sms *gsms)
 {
@@ -993,8 +1036,13 @@
/* obtain a pointer for the rp_ud_len, so we can fill it later */
rp_ud_len = (uint8_t *)msgb_put(msg, 1);
 
-   /* generate the 03.40 SMS-DELIVER TPDU */
-   rc = gsm340_gen_sms_deliver_tpdu(msg, sms);
+   if (sms->is_report) {
+   /* generate the 03.40 SMS-STATUS-REPORT TPDU */
+   rc = gsm340_gen_sms_status_report_tpdu(msg, sms);
+   } else {
+   /* generate the 03.40 SMS-DELIVER TPDU */
+   rc = gsm340_gen_sms_deliver_tpdu(msg, sms);
+   }
if (rc < 0) {
send_signal(S_SMS_UNKNOWN_ERROR, trans, sms, 0);
sms_free(sms);
diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c
index 03482be..09012d0 100644
--- a/src/libmsc/smpp_openbsc.c
+++ b/src/libmsc/smpp_openbsc.c
@@ -144,6 +144,10 @@
osmo_strlcpy(sms->src.addr, (char *)submit->source_addr,
 sizeof(sms->src.addr));
 
+   /* This is a Delivery Acknowledgment. */
+   if (submit->esm_class == 0x08)
+   sms->is_report = true;
+
if (submit->esm_class & 0x40)
sms->ud_hdr_ind = 1;
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib70e534840308ed315f7add440351e649de3f907
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: libmsc: add support for SMPP delivery receipts

2017-08-24 Thread Neels Hofmeyr

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

libmsc: add support for SMPP delivery receipts

If the mobile phone requests a status report via SMS, send a DELIVER_SM
with esm_class = Delivery Receipt to ESME to indicate that the SMS has
been already delivered to its destination.

MSGSM 03.40   SMSC   SMPP 3.4   ESME
 | ||
 |   SMS-DELIVER   ||
 |<||
 | GSM 04.11 RP-ACK||
 |>||
 | |   DELIVER-SM   |
 | |  esm_class = Delivery Receipt  |
 | |--->|
 | | DELIVER-SM-RESP|
 | |<---|
 | ||

This patch implements "Appendix B. Delivery Receipt Format" as specified
in the SMPP 3.4 specs. This string is conveyed in the SMS message as
data, and it is only meaningful to the ESME, for logging purposes. The
"submit date" and "done date" are not yet set, and other fields are just
sent with dummy values, so they are left to be finished as future work.

The new SMPP TLV tag TLVID_user_message_reference is added to the SMPP
messages inconditionally now since this information is required by
delivery-reports to associate the status-report with the original SMS.

Change-Id: Ic1a9023074bfa938099377980b6aff9b262fab2a
---
M include/openbsc/gsm_data.h
M src/libmsc/gsm_04_11.c
M src/libmsc/smpp_openbsc.c
M src/libmsc/smpp_smsc.h
4 files changed, 76 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/46/3646/1

diff --git a/include/openbsc/gsm_data.h b/include/openbsc/gsm_data.h
index 02823c9..51cf6dc 100644
--- a/include/openbsc/gsm_data.h
+++ b/include/openbsc/gsm_data.h
@@ -511,6 +511,7 @@
} smpp;
 
unsigned long validity_minutes;
+   bool is_report;
uint8_t reply_path_req;
uint8_t status_rep_req;
uint8_t ud_hdr_ind;
diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index cd23883..b4fa3df 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -594,6 +594,57 @@
rpud_len, rp_ud);
 }
 
+static struct gsm_sms *sms_report_alloc(struct gsm_sms *sms)
+{
+   struct gsm_sms *sms_report;
+   int len;
+
+   sms_report = sms_alloc();
+   OSMO_ASSERT(sms_report);
+
+   sms_report->msg_ref = sms->msg_ref;
+   sms_report->protocol_id = sms->protocol_id;
+   sms_report->data_coding_scheme = GSM338_DCS__8BIT_DATA;
+
+   /* Invert address to send status report back to origin. */
+   sms_report->src = sms->dst;
+   sms_report->dst = sms->src;
+
+   /* As specified by Appendix B. Delivery Receipt Format.
+* TODO: Many fields in this string are just set with dummy values,
+*   revisit this.
+*/
+   len = snprintf((char *)sms_report->user_data,
+  sizeof(sms_report->user_data),
+  "id:%.08llu sub:000 dlvrd:000 submit date:YYMMDDhhmm 
done date:YYMMDDhhmm stat:DELIVRD err:000 text:%.20s",
+  sms->id, sms->user_data);
+   sms_report->user_data_len = len;
+   LOGP(DLSMS, LOGL_NOTICE, "%s\n", sms_report->user_data);
+
+   /* This represents a sms report. */
+   sms_report->is_report = true;
+
+   return sms_report;
+}
+
+static void sms_status_report(struct gsm_sms *gsms,
+ struct gsm_subscriber_connection *conn)
+{
+   struct gsm_sms *sms_report;
+   int rc;
+
+   sms_report = sms_report_alloc(gsms);
+
+   rc = sms_route_mt_sms(conn, sms_report);
+   if (rc < 0) {
+   LOGP(DLSMS, LOGL_ERROR,
+"Failed to send status report! err=%d\n", rc);
+   }
+   LOGP(DLSMS, LOGL_NOTICE, "Status report has been sent\n");
+
+   sms_free(sms_report);
+}
+
 /* Receive a 04.11 RP-ACK message (response to RP-DATA from us) */
 static int gsm411_rx_rp_ack(struct msgb *msg, struct gsm_trans *trans,
struct gsm411_rp_hdr *rph)
@@ -615,6 +666,9 @@
 
send_signal(S_SMS_DELIVERED, trans, sms, 0);
 
+   if (sms->status_rep_req)
+   sms_status_report(sms, trans->conn);
+
sms_free(sms);
trans->sms.sms = NULL;
 
diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c
index 5de1368..03482be 100644
--- a/src/libmsc/smpp_openbsc.c
+++ b/src/libmsc/smpp_openbsc.c
@@ -201,6 +201,10 @@
sms->user_data_len = sms_msg_len;
}
 
+   t = find_tlv(submit->tlv, 

[PATCH] osmo-msc[master]: cosmetic: vty for timers: remove obsolete range check

2017-08-24 Thread Neels Hofmeyr

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

cosmetic: vty for timers: remove obsolete range check

The VTY parsing already ensures the parameter range being 1..65535, no need to
check the range again.

Change-Id: I1cffa5b01cd5c589f1e42998e32135f1da8c960b
---
M src/libbsc/bsc_vty.c
1 file changed, 0 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/37/3637/1

diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index bf7c3ca..da406e0 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -1550,12 +1550,6 @@
struct gsm_network *gsmnet = gsmnet_from_vty(vty);  \
int value = atoi(argv[0]);  \
\
-   if (value < 1 || value > 65535) {   \
-   vty_out(vty, "Timer value %s out of range.%s",  \
-   argv[0], VTY_NEWLINE);  \
-   return CMD_WARNING; \
-   }   \
-   \
gsmnet->T##number = value;  \
return CMD_SUCCESS; \
 }

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

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


[PATCH] osmo-msc[master]: libmsc: report status report request flag from SMPP SUBMIT_SM

2017-08-24 Thread Neels Hofmeyr

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

libmsc: report status report request flag from SMPP SUBMIT_SM

Restore the sms status report request flag from SUBMIT_SM.

Change-Id: Iac05252253f8933a3875b4904599b7a225191a4b
---
M src/libmsc/smpp_openbsc.c
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/41/3641/1

diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c
index 8a1a7da..5de1368 100644
--- a/src/libmsc/smpp_openbsc.c
+++ b/src/libmsc/smpp_openbsc.c
@@ -130,6 +130,7 @@
sms = sms_alloc();
sms->source = SMS_SOURCE_SMPP;
sms->smpp.sequence_nr = submit->sequence_number;
+   sms->status_rep_req = submit->registered_delivery;
 
/* fill in the destination address */
sms->receiver = dest;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iac05252253f8933a3875b4904599b7a225191a4b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: libmsc: move gsm340_rx_sms_submit() to sms_route_mt_sms()

2017-08-24 Thread Neels Hofmeyr

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

libmsc: move gsm340_rx_sms_submit() to sms_route_mt_sms()

Move the sms message-type-identifier (mti) handling away from the
routing logic. This patch allows us to reuse the sms_route_mt_sms()
function in a follow up patch for sms reports send through SMPP
DELIVER_SM with esm_class = Delivery Receipt whose Change-Id is
Ic1a9023074bfa938099377980b6aff9b262fab2a.

Change-Id: I3f3d30e0762b91e2099243b0be1a4b67cbb5e9c0
---
M src/libmsc/gsm_04_11.c
1 file changed, 22 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/36/3636/1

diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index 88a6685..ef2635b 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -280,7 +280,7 @@
 }
 
 static int sms_route_mt_sms(struct gsm_subscriber_connection *conn,
-   struct gsm_sms *gsms, uint8_t sms_mti)
+   struct gsm_sms *gsms)
 {
int rc;
 
@@ -338,23 +338,6 @@
rc = GSM411_RP_CAUSE_MO_NUM_UNASSIGNED;

rate_ctr_inc(>network->msc_ctrs->ctr[MSC_CTR_SMS_NO_RECEIVER]);
 #endif
-   return rc;
-   }
-
-   switch (sms_mti) {
-   case GSM340_SMS_SUBMIT_MS2SC:
-   /* MS is submitting a SMS */
-   rc = gsm340_rx_sms_submit(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;
}
 
return rc;
@@ -485,7 +468,27 @@
/* FIXME: This looks very wrong */
send_signal(0, NULL, gsms, 0);
 
-   rc = sms_route_mt_sms(conn, gsms, sms_mti);
+   rc = sms_route_mt_sms(conn, gsms);
+
+   /* This SMS got routed through SMPP or no receiver exists. */
+   if (!gsms->receiver)
+   return rc;
+
+   switch (sms_mti) {
+   case GSM340_SMS_SUBMIT_MS2SC:
+   /* MS is submitting a SMS */
+   rc = gsm340_rx_sms_submit(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;
+   }
 out:
sms_free(gsms);
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3f3d30e0762b91e2099243b0be1a4b67cbb5e9c0
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: timer vty: also print the default value in cmd doc

2017-08-24 Thread Neels Hofmeyr

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

timer vty: also print the default value in cmd doc

Rationale: allows seeing all timer defaults at once by doing

  OsmoBSC(config-net)# timer ?

Before, defaults are visible only by doing on each timer:

  OsmoBSC(config-net)# timer t1234 

Change-Id: I8259234e5c62e058dde56d531071440bbab11462
---
M src/libbsc/bsc_vty.c
1 file changed, 13 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/39/3639/1

diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index 9991e58..bd363ae 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -1549,7 +1549,7 @@
   cfg_net_T##number##_cmd, \
   "timer t" #number  " (default|<1-65535>)",   \
   "Configure GSM Timers\n" \
-  doc  \
+  doc " (default: " EXPAND_AND_STRINGIFY(DEFAULT_TIMER(number)) " 
seconds)\n" \
   "Set to default timer value" \
  " (" EXPAND_AND_STRINGIFY(DEFAULT_TIMER(number)) " seconds)\n" \
   "Timer Value in seconds\n")  \
@@ -1565,18 +1565,18 @@
return CMD_SUCCESS; \
 }
 
-DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.\n")
-DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.\n")
-DECLARE_TIMER(3105, "Set the timer for repetition of PHYSICAL INFORMATION.\n")
-DECLARE_TIMER(3107, "Currently not used.\n")
-DECLARE_TIMER(3109, "Set the RSL SACCH deactivation timeout.\n")
-DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF 
Channel.\n")
-DECLARE_TIMER(3113, "Set the time to try paging a subscriber.\n")
-DECLARE_TIMER(3115, "Currently not used.\n")
-DECLARE_TIMER(3117, "Currently not used.\n")
-DECLARE_TIMER(3119, "Currently not used.\n")
-DECLARE_TIMER(3122, "Waiting time (seconds) after IMM ASS REJECT\n")
-DECLARE_TIMER(3141, "Currently not used.\n")
+DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT")
+DECLARE_TIMER(3103, "Set the timeout value for HANDOVER")
+DECLARE_TIMER(3105, "Set the timer for repetition of PHYSICAL INFORMATION")
+DECLARE_TIMER(3107, "Currently not used")
+DECLARE_TIMER(3109, "Set the RSL SACCH deactivation timeout")
+DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF 
Channel")
+DECLARE_TIMER(3113, "Set the time to try paging a subscriber")
+DECLARE_TIMER(3115, "Currently not used")
+DECLARE_TIMER(3117, "Currently not used")
+DECLARE_TIMER(3119, "Currently not used")
+DECLARE_TIMER(3122, "Waiting time (seconds) after IMM ASS REJECT")
+DECLARE_TIMER(3141, "Currently not used")
 
 DEFUN_DEPRECATED(cfg_net_dtx,
 cfg_net_dtx_cmd,

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

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


[PATCH] osmo-msc[master]: vty: add 'default' keyword to timer config

2017-08-24 Thread Neels Hofmeyr

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

vty: add 'default' keyword to timer config

Change-Id: I4e837e8bedfad7ac4fd50048ecb016ddb37c2397
---
M src/libbsc/bsc_vty.c
1 file changed, 14 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/38/3638/1

diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index da406e0..9991e58 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -1540,15 +1540,26 @@
return CMD_SUCCESS;
 }
 
+#define DEFAULT_TIMER(number) GSM_T##number##_DEFAULT
+/* Add another expansion so that DEFAULT_TIMER() becomes its value */
+#define EXPAND_AND_STRINGIFY(x) OSMO_STRINGIFY(x)
+
 #define DECLARE_TIMER(number, doc) \
 DEFUN(cfg_net_T##number,   \
   cfg_net_T##number##_cmd, \
-  "timer t" #number  " <1-65535>", \
+  "timer t" #number  " (default|<1-65535>)",   \
   "Configure GSM Timers\n" \
-  doc "Timer Value in seconds\n")  \
+  doc  \
+  "Set to default timer value" \
+ " (" EXPAND_AND_STRINGIFY(DEFAULT_TIMER(number)) " seconds)\n" \
+  "Timer Value in seconds\n")  \
 {  \
struct gsm_network *gsmnet = gsmnet_from_vty(vty);  \
-   int value = atoi(argv[0]);  \
+   int value;  \
+   if (strcmp(argv[0], "default") == 0)\
+   value = DEFAULT_TIMER(number);  \
+   else\
+   value = atoi(argv[0]);  \
\
gsmnet->T##number = value;  \
return CMD_SUCCESS; \

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

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


[PATCH] osmo-msc[master]: libmsc: remove dead code in sms_route_mt_sms()

2017-08-24 Thread Neels Hofmeyr

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

libmsc: remove dead code in sms_route_mt_sms()

The following branch:

if (!rc && !gsms->receiver)
rc = GSM411_RP_CAUSE_MO_NUM_UNASSIGNED;

at the end of sms_route_mt_sms() always evaluates false.

Just a bit before, in such function, we have this:

if (!gsms->receiver) {
...
 #ifdef BUILD_SMPP
...
 #else
...
 #endif
return rc;
}

So, if there is no receiver, we just stop running code and return the RP
cause via the rc variable. Same applies to the smpp_first check under
the BUILD_SMPP ifdef (that I have removed in this snippet to keep this
commit message small).

Change-Id: Ic3502b5b169bc7a73a67fd6ff53d8b6c0dc045c8
---
M src/libmsc/gsm_04_11.c
1 file changed, 0 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/33/3633/1

diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index 3153610..0cd1b65 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -358,9 +358,6 @@
break;
}
 
-   if (!rc && !gsms->receiver)
-   rc = GSM411_RP_CAUSE_MO_NUM_UNASSIGNED;
-
return rc;
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic3502b5b169bc7a73a67fd6ff53d8b6c0dc045c8
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: libmsc: remove 'deferred' parameter in sms_route_mt_sms()

2017-08-24 Thread Neels Hofmeyr

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

libmsc: remove 'deferred' parameter in sms_route_mt_sms()

No need to cache the sms object, just cache what we need into the
smpp_cmd structure. This simplifies what that I introduced in
93ffbd0029d1 ("libmsc: send RP-ACK to MS after ESME sends SMPP
DELIVER-SM-RESP").

Change-Id: Iba5f864f9bb963baff95969e306b1b7cff00c1e3
---
M src/libmsc/gsm_04_11.c
M src/libmsc/smpp_openbsc.c
M src/libmsc/smpp_smsc.h
3 files changed, 24 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/35/3635/1

diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index 0cd1b65..88a6685 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -280,8 +280,7 @@
 }
 
 static int sms_route_mt_sms(struct gsm_subscriber_connection *conn,
-   struct gsm_sms *gsms, uint8_t sms_mti,
-   bool *deferred)
+   struct gsm_sms *gsms, uint8_t sms_mti)
 {
int rc;
 
@@ -295,7 +294,7 @@
 * delivery of the SMS.
 */
if (smpp_first) {
-   rc = smpp_try_deliver(gsms, conn, deferred);
+   rc = smpp_try_deliver(gsms, conn);
if (rc == GSM411_RP_CAUSE_MO_NUM_UNASSIGNED)
/* unknown subscriber, try local */
goto try_local;
@@ -324,7 +323,7 @@
return GSM411_RP_CAUSE_MO_NUM_UNASSIGNED;
}
 
-   rc = smpp_try_deliver(gsms, conn, deferred);
+   rc = smpp_try_deliver(gsms, conn);
if (rc == GSM411_RP_CAUSE_MO_NUM_UNASSIGNED) {

rate_ctr_inc(>network->msc_ctrs->ctr[MSC_CTR_SMS_NO_RECEIVER]);
} else if (rc < 0) {
@@ -365,7 +364,7 @@
 /* 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_trans *trans, struct msgb *msg,
- uint32_t gsm411_msg_ref, bool *deferred)
+ uint32_t gsm411_msg_ref)
 {
struct gsm_subscriber_connection *conn = trans->conn;
uint8_t *smsp = msgb_sms(msg);
@@ -486,10 +485,9 @@
/* FIXME: This looks very wrong */
send_signal(0, NULL, gsms, 0);
 
-   rc = sms_route_mt_sms(conn, gsms, sms_mti, deferred);
+   rc = sms_route_mt_sms(conn, gsms, sms_mti);
 out:
-   if (!deferred)
-   sms_free(gsms);
+   sms_free(gsms);
 
return rc;
 }
@@ -542,7 +540,6 @@
  uint8_t dst_len, uint8_t *dst,
  uint8_t tpdu_len, uint8_t *tpdu)
 {
-   bool deferred = false;
int rc = 0;
 
if (src_len && src)
@@ -559,8 +556,8 @@
 
DEBUGP(DLSMS, "DST(%u,%s)\n", dst_len, osmo_hexdump(dst, dst_len));
 
-   rc = gsm340_rx_tpdu(trans, msg, rph->msg_ref, );
-   if (rc == 0 && !deferred)
+   rc = gsm340_rx_tpdu(trans, msg, rph->msg_ref);
+   if (rc == 0)
return gsm411_send_rp_ack(trans, rph->msg_ref);
else if (rc > 0)
return gsm411_send_rp_error(trans, rph->msg_ref, rc);
diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c
index 67e6638..bf63f6b 100644
--- a/src/libmsc/smpp_openbsc.c
+++ b/src/libmsc/smpp_openbsc.c
@@ -501,7 +501,6 @@
osmo_timer_del(>response_timer);
llist_del(>list);
vlr_subscr_put(cmd->vsub);
-   sms_free(cmd->sms);
talloc_free(cmd);
 }
 
@@ -524,15 +523,14 @@
goto out;
}
 
-   trans = trans_find_by_id(conn, GSM48_PDISC_SMS,
-cmd->sms->gsm411.transaction_id);
+   trans = trans_find_by_id(conn, GSM48_PDISC_SMS, cmd->gsm411_trans_id);
if (!trans) {
LOGP(DSMPP, LOGL_ERROR, "GSM transaction %u is gone\n",
-cmd->sms->gsm411.transaction_id);
+cmd->gsm411_trans_id);
goto out;
}
 
-   gsm411_send_rp_ack(trans, cmd->sms->gsm411.msg_ref);
+   gsm411_send_rp_ack(trans, cmd->gsm411_msg_ref);
 out:
smpp_cmd_free(cmd);
 }
@@ -549,18 +547,17 @@
goto out;
}
 
-   trans = trans_find_by_id(conn, GSM48_PDISC_SMS,
-cmd->sms->gsm411.transaction_id);
+   trans = trans_find_by_id(conn, GSM48_PDISC_SMS, cmd->gsm411_trans_id);
if (!trans) {
LOGP(DSMPP, LOGL_ERROR, "GSM transaction %u is gone\n",
-cmd->sms->gsm411.transaction_id);
+cmd->gsm411_trans_id);
goto out;
}
 
if (smpp_to_gsm411_err(status, _cause) < 0)
gsm411_cause = GSM411_RP_CAUSE_MO_NET_OUT_OF_ORDER;
 
-   gsm411_send_rp_error(trans, cmd->sms->gsm411.msg_ref, gsm411_cause);
+   gsm411_send_rp_error(trans, cmd->gsm411_msg_ref, gsm411_cause);
 out:
smpp_cmd_free(cmd);
 }
@@ 

[PATCH] osmo-msc[master]: libmsc: remove duplicate lines in deliver_to_esme()

2017-08-24 Thread Neels Hofmeyr

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

libmsc: remove duplicate lines in deliver_to_esme()

This code is accidentally doing the same thing twice, remove it.

Change-Id: I68087a850399e22951d2407e4d8a09c671a775c9
---
M src/libmsc/smpp_openbsc.c
1 file changed, 0 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/34/3634/1

diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c
index 394827b..67e6638 100644
--- a/src/libmsc/smpp_openbsc.c
+++ b/src/libmsc/smpp_openbsc.c
@@ -680,8 +680,6 @@
} else {
deliver.sm_length = sms->user_data_len;
memcpy(deliver.short_message, sms->user_data, 
deliver.sm_length);
-   deliver.sm_length = sms->user_data_len;
-   memcpy(deliver.short_message, sms->user_data, 
deliver.sm_length);
}
 
 #if BEFORE_MSCSPLIT

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I68087a850399e22951d2407e4d8a09c671a775c9
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: libmsc: do not leak pending SMPP command object on error path

2017-08-24 Thread Neels Hofmeyr

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

libmsc: do not leak pending SMPP command object on error path

Make sure the SMPP command object is released on errors.

Change-Id: I474584425d23fb379a9d71b33e29ac0e24f01e61
---
M src/libmsc/smpp_openbsc.c
1 file changed, 6 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/32/3632/1

diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c
index b3f9bbb..394827b 100644
--- a/src/libmsc/smpp_openbsc.c
+++ b/src/libmsc/smpp_openbsc.c
@@ -521,7 +521,7 @@
conn = connection_for_subscr(cmd->vsub);
if (!conn) {
LOGP(DSMPP, LOGL_ERROR, "No connection to subscriber 
anymore\n");
-   return;
+   goto out;
}
 
trans = trans_find_by_id(conn, GSM48_PDISC_SMS,
@@ -529,10 +529,11 @@
if (!trans) {
LOGP(DSMPP, LOGL_ERROR, "GSM transaction %u is gone\n",
 cmd->sms->gsm411.transaction_id);
-   return;
+   goto out;
}
 
gsm411_send_rp_ack(trans, cmd->sms->gsm411.msg_ref);
+out:
smpp_cmd_free(cmd);
 }
 
@@ -545,7 +546,7 @@
conn = connection_for_subscr(cmd->vsub);
if (!conn) {
LOGP(DSMPP, LOGL_ERROR, "No connection to subscriber 
anymore\n");
-   return;
+   goto out;
}
 
trans = trans_find_by_id(conn, GSM48_PDISC_SMS,
@@ -553,14 +554,14 @@
if (!trans) {
LOGP(DSMPP, LOGL_ERROR, "GSM transaction %u is gone\n",
 cmd->sms->gsm411.transaction_id);
-   return;
+   goto out;
}
 
if (smpp_to_gsm411_err(status, _cause) < 0)
gsm411_cause = GSM411_RP_CAUSE_MO_NET_OUT_OF_ORDER;
 
gsm411_send_rp_error(trans, cmd->sms->gsm411.msg_ref, gsm411_cause);
-
+out:
smpp_cmd_free(cmd);
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I474584425d23fb379a9d71b33e29ac0e24f01e61
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: gtphob: check for missing result of rate_ctr_group_alloc()

2017-08-24 Thread Neels Hofmeyr

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

gtphob: check for missing result of rate_ctr_group_alloc()

In case the counter group allocation fails, we must handle this
gracefully and fail the allocation of the parent object, too.

The recent change (Id I7dad4a4d52fe05f6b990359841b4408df5990e21) seems
to have missed one instance, so let's follow-up.

Change-Id: I1ee9e3d26dcc18e7f979fd9a786162cbcc50942c
Related: OS#2361
---
M src/gprs/gtphub.c
1 file changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/25/3625/1

diff --git a/src/gprs/gtphub.c b/src/gprs/gtphub.c
index 211018b..5e7520e 100644
--- a/src/gprs/gtphub.c
+++ b/src/gprs/gtphub.c
@@ -2708,6 +2708,10 @@
 
pp->counters_io = rate_ctr_group_alloc(osmo_gtphub_ctx,
   _ctrg_io_desc, 0);
+   if (!pp->counters_io) {
+   talloc_free(pp);
+   return NULL;
+   }
 
llist_add(>entry, >ports);
 

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

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


[PATCH] osmo-msc[master]: bsc_vty: Don't allow timers of zero (0)

2017-08-24 Thread Neels Hofmeyr

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

bsc_vty: Don't allow timers of zero (0)

It typically doesn't make sense to configure any of the GSM RR timer
to 0 (Seconds).  In fact, accidentially configuring any of the timers
to zero might have severe side effects, such as "stuck channels"
described in https://osmocom.org/issues/2380

Change-Id: I517828f2f0c80ec01cb63648db2626f17a67fe57
---
M src/libbsc/bsc_vty.c
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/28/3628/1

diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index 1e78b08..bf7c3ca 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -1543,14 +1543,14 @@
 #define DECLARE_TIMER(number, doc) \
 DEFUN(cfg_net_T##number,   \
   cfg_net_T##number##_cmd, \
-  "timer t" #number  " <0-65535>", \
+  "timer t" #number  " <1-65535>", \
   "Configure GSM Timers\n" \
   doc "Timer Value in seconds\n")  \
 {  \
struct gsm_network *gsmnet = gsmnet_from_vty(vty);  \
int value = atoi(argv[0]);  \
\
-   if (value < 0 || value > 65535) {   \
+   if (value < 1 || value > 65535) {   \
vty_out(vty, "Timer value %s out of range.%s",  \
argv[0], VTY_NEWLINE);  \
return CMD_WARNING; \

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

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


[PATCH] osmo-msc[master]: bsc_vty: Add VTY command to test CTRL TRAP feature

2017-08-24 Thread Neels Hofmeyr

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

bsc_vty: Add VTY command to test CTRL TRAP feature

Using this new command (introduced in OsmoBSC + OsmoNITB), you can
simulate the generation of TRAP events for testin purposes.

start the control interface monitor as an example client program:
./openbsc/contrib/bsc_control.py -m -d localhost -p 4249

then start OsmoBSC or OsmoNITB, telnet to the VTY and enter 'enable'
mode and issue the following (example) command:
ctrl-interface generate-trap my.foo.var 2342

As a result, on the bsc_control.py you will see:
Got message: TRAP 0 my.foo.var 2342

Change-Id: Ib1d2ec38290dc94797c1b365d9b733e5215ab7d1
---
M src/libbsc/bsc_vty.c
1 file changed, 16 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/26/3626/1

diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index 09c443c..f3ab35f 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -4093,6 +4094,20 @@
rsl_ipacc_mdcx(lchan, ntohl(ia.s_addr), port, 0);
return CMD_SUCCESS;
 }
+
+DEFUN(ctrl_trap, ctrl_trap_cmd,
+   "ctrl-interface generate-trap TRAP VALUE",
+   "Commands related to the CTRL Interface\n"
+   "Generate a TRAP for test purpose\n"
+   "Identity/Name of the TRAP variable\n"
+   "Value of the TRAP variable\n")
+{
+   struct gsm_network *net = gsmnet_from_vty(vty);
+
+   ctrl_cmd_send_trap(net->ctrl, argv[0], (char *) argv[1]);
+   return CMD_SUCCESS;
+}
+
 extern int bsc_vty_init_extra(void);
 
 int bsc_vty_init(struct gsm_network *network)
@@ -4293,6 +4308,7 @@
install_element(ENABLE_NODE, _act_cmd);
install_element(ENABLE_NODE, _mdcx_cmd);
install_element(ENABLE_NODE, _cmd_cmd);
+   install_element(ENABLE_NODE, _trap_cmd);
 
abis_nm_vty_init();
abis_om2k_vty_init();

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

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


[PATCH] osmo-msc[master]: sgsn: Convert cch_pdp to host order for libgtp

2017-08-24 Thread Neels Hofmeyr

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

sgsn: Convert cch_pdp to host order for libgtp

libgtp is calling gtpie_tv2 which will convert this uint16_t from host
to network order. So far libosmogsm and the sgsn treated the charging
characteristics as opaque data. So when moving from byte array to the
uint16_t do the swapping.

Change-Id: I977aec2e2f8d57802e45f591754e5733562d5c2a
---
M src/gprs/sgsn_libgtp.c
1 file changed, 2 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/30/3630/1

diff --git a/src/gprs/sgsn_libgtp.c b/src/gprs/sgsn_libgtp.c
index 0a0de08..bc2fcd1 100644
--- a/src/gprs/sgsn_libgtp.c
+++ b/src/gprs/sgsn_libgtp.c
@@ -235,11 +235,8 @@
}
 
/* charging characteristics if present */
-   if (TLVP_LEN(tp, OSMO_IE_GSM_CHARG_CHAR) > 0) {
-   OSMO_ASSERT(TLVP_LEN(tp, OSMO_IE_GSM_CHARG_CHAR) <= 
sizeof(pdp->cch_pdp));
-   memcpy(>cch_pdp, TLVP_VAL(tp, OSMO_IE_GSM_CHARG_CHAR),
-   TLVP_LEN(tp, OSMO_IE_GSM_CHARG_CHAR));
-   }
+   if (TLVP_LEN(tp, OSMO_IE_GSM_CHARG_CHAR) >= sizeof(pdp->cch_pdp))
+   pdp->cch_pdp = tlvp_val16be(tp, OSMO_IE_GSM_CHARG_CHAR);
 
/* SGSN address for control plane */
pdp->gsnlc.l = sizeof(sgsn->cfg.gtp_listenaddr.sin_addr);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I977aec2e2f8d57802e45f591754e5733562d5c2a
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Holger Freyther 


[PATCH] osmo-msc[master]: remove code disabling T3109 if configured to 0

2017-08-24 Thread Neels Hofmeyr

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

remove code disabling T3109 if configured to 0

We no longer permit timers with a 0 value, so this case can never
happen.  Also, if it should happen, I'd rather have a timter expiring
immediately (and breaking something) than not being started in the
first place.

Change-Id: Ibfcdd3ddc0155caee89c501498329bde247621a0
---
M src/libbsc/abis_rsl.c
1 file changed, 0 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/29/3629/1

diff --git a/src/libbsc/abis_rsl.c b/src/libbsc/abis_rsl.c
index 9e36f79..3337b90 100644
--- a/src/libbsc/abis_rsl.c
+++ b/src/libbsc/abis_rsl.c
@@ -2910,10 +2910,6 @@
 {
struct gsm_bts *bts = lchan->ts->trx->bts;
 
-   /* Disabled, mostly legacy code */
-   if (bts->network->T3109 == 0)
-   return -1;
-
osmo_timer_setup(>T3109, t3109_expired, lchan);
osmo_timer_schedule(>T3109, bts->network->T3109, 0);
return 0;

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

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


[PATCH] osmo-msc[master]: Fix BTS attribute requests

2017-08-24 Thread Neels Hofmeyr

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

Fix BTS attribute requests

* fix BTS numbers: use 0 to indicate given BTS and 0xFF to indicate all
  BTS' as it's explained in 3GPP TS 52.021 §9.3.
* only request attributes from supported (OsmoBTS) types

Change-Id: I8f43055c38000248033a8ff9ddaf0910d68d794b
Related: OS#2317
---
M src/libbsc/abis_nm.c
M src/libbsc/bsc_init.c
2 files changed, 10 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/17/3617/1

diff --git a/src/libbsc/abis_nm.c b/src/libbsc/abis_nm.c
index 019d039..cf20d7c 100644
--- a/src/libbsc/abis_nm.c
+++ b/src/libbsc/abis_nm.c
@@ -1590,10 +1590,17 @@
 const uint8_t *attr, uint8_t attr_len)
 {
struct abis_om_hdr *oh;
-   struct msgb *msg = nm_msgb_alloc();
+   struct msgb *msg;
+
+   if (bts->type != GSM_BTS_TYPE_OSMOBTS) {
+   LOGPC(DNM, LOGL_NOTICE, "Getting attributes from BTS%d type %s 
is not supported.\n",
+ bts->nr, btstype2str(bts->type));
+   return -EINVAL;
+   }
 
DEBUGP(DNM, "Get Attr (bts=%d)\n", bts->nr);
 
+   msg = nm_msgb_alloc();
oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE);
fill_om_fom_hdr(oh, attr_len, NM_MT_GET_ATTR, obj_class,
bts_nr, trx_nr, ts_nr);
diff --git a/src/libbsc/bsc_init.c b/src/libbsc/bsc_init.c
index 64dcd15..6f80958 100644
--- a/src/libbsc/bsc_init.c
+++ b/src/libbsc/bsc_init.c
@@ -350,12 +350,12 @@
generate_cell_chan_list(ca, trx->bts);
 
/* Request generic BTS-level attributes */
-   abis_nm_get_attr(trx->bts, NM_OC_BTS, trx->bts->nr, 
trx->nr, 0xFF, bts_attr, sizeof(bts_attr));
+   abis_nm_get_attr(trx->bts, NM_OC_BTS, 0xFF, 0xFF, 0xFF, 
bts_attr, sizeof(bts_attr));
 
llist_for_each_entry(cur_trx, >bts->trx_list, 
list) {
int i;
/* Request TRX-level attributes */
-   abis_nm_get_attr(cur_trx->bts, 
NM_OC_BASEB_TRANSC, cur_trx->bts->nr, cur_trx->nr, 0xFF,
+   abis_nm_get_attr(cur_trx->bts, 
NM_OC_BASEB_TRANSC, 0, cur_trx->nr, 0xFF,
 trx_attr, sizeof(trx_attr));
for (i = 0; i < ARRAY_SIZE(cur_trx->ts); i++)
generate_ma_for_ts(_trx->ts[i]);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f43055c38000248033a8ff9ddaf0910d68d794b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Max 


[PATCH] osmo-msc[master]: smpp_smsc.c: Log on sending deliver_sm message

2017-08-24 Thread Neels Hofmeyr

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

smpp_smsc.c: Log on sending deliver_sm message

Change-Id: Ie16294df6d5bc0065f8d2b49320ead61f535f271
---
M src/libmsc/smpp_smsc.c
1 file changed, 3 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/09/3609/1

diff --git a/src/libmsc/smpp_smsc.c b/src/libmsc/smpp_smsc.c
index 48a1192..4c2e4aa 100644
--- a/src/libmsc/smpp_smsc.c
+++ b/src/libmsc/smpp_smsc.c
@@ -654,6 +654,9 @@
 {
deliver->sequence_number = esme_inc_seq_nr(esme);
 
+   LOGP(DSMPP, LOGL_DEBUG, "[%s] Tx DELIVER-SM (from %s)\n",
+   esme->system_id, deliver->source_addr);
+
return PACK_AND_SEND(esme, deliver);
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie16294df6d5bc0065f8d2b49320ead61f535f271
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


[PATCH] osmo-msc[master]: transaction: reject calls from unidentified subscribers

2017-08-24 Thread Neels Hofmeyr

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

transaction: reject calls from unidentified subscribers

A valid subscriber is indespensible when allocating a new
transaction. Return NULL if no subscriber is supplied. This
will cause unidentified subscribers to be rejected.

Note: Under normal conditions, the problem does not occour,
but it is still possible that a misbehaving MS might trigger
the problem by sending a SETUP command before authenticating
the subscriber. (unencrypted networks)

Change-Id: Ia8739b6e329ab02c0064270d02ad1d6ee245520d
---
M src/libmsc/transaction.c
1 file changed, 7 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/18/3618/1

diff --git a/src/libmsc/transaction.c b/src/libmsc/transaction.c
index 7289a8f..28e0914 100644
--- a/src/libmsc/transaction.c
+++ b/src/libmsc/transaction.c
@@ -88,6 +88,13 @@
 
DEBUGP(DCC, "subscr=%p, net=%p\n", vsub, net);
 
+   /* a valid subscriber is indispensable */
+   if (vsub == NULL) {
+   LOGP(DCC, LOGL_NOTICE,
+"unable to alloc transaction, invalid subscriber 
(NULL)\n");
+   return NULL;
+   }
+
trans = talloc_zero(tall_trans_ctx, struct gsm_trans);
if (!trans)
return NULL;

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

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


[PATCH] osmo-msc[master]: libbsc: Add VTY command to re-send the SYSTEM INFORMATION to...

2017-08-24 Thread Neels Hofmeyr

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

libbsc: Add VTY command to re-send the SYSTEM INFORMATION to BTS

This is useful if you are updating some configuration parameters which
affect the content of the SYSTEM INFORMATION messages.  Currently, we
only send them at the time the RSL connection is established (i.e. when
the BTS is initialized), so if you change something, you need to bring
down and re-start the BTS.

Using the newly-introduced "bts <0-255> resend-system-information"
command, you can re-generate + re-send SYSTEM INFORMATION without
bringing the BTS down, i.e. without any radio carrier downtime.

Change-Id: I326df47de98f6d36c9a4d2d5475225d1e62bafb5
---
M src/libbsc/bsc_vty.c
1 file changed, 33 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/20/3620/1

diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index 722753a..09c443c 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -3801,6 +3801,38 @@
return CMD_SUCCESS;
 }
 
+DEFUN(bts_resend, bts_resend_cmd,
+  "bts <0-255> resend-system-information",
+  "BTS Specific Commands\n" "BTS Number\n"
+  "Re-generate + re-send BCCH SYSTEM INFORMATION\n")
+{
+   struct gsm_network *gsmnet;
+   struct gsm_bts_trx *trx;
+   struct gsm_bts *bts;
+   unsigned int bts_nr;
+
+   gsmnet = gsmnet_from_vty(vty);
+
+   bts_nr = atoi(argv[0]);
+   if (bts_nr >= gsmnet->num_bts) {
+   vty_out(vty, "BTS number must be between 0 and %d. It was 
%d.%s",
+   gsmnet->num_bts, bts_nr, VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   bts = gsm_bts_num(gsmnet, bts_nr);
+   if (!bts) {
+   vty_out(vty, "BTS Nr. %d could not be found.%s", bts_nr, 
VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   llist_for_each_entry_reverse(trx, >trx_list, list)
+   gsm_bts_trx_set_system_infos(trx);
+
+   return CMD_SUCCESS;
+}
+
+
 DEFUN(smscb_cmd, smscb_cmd_cmd,
"bts <0-255> smscb-command <1-4> HEXSTRING",
"BTS related commands\n" "BTS Number\n"
@@ -4256,6 +4288,7 @@
 
install_element(ENABLE_NODE, _bts_cmd);
install_element(ENABLE_NODE, _bts_cmd);
+   install_element(ENABLE_NODE, _resend_cmd);
install_element(ENABLE_NODE, _act_cmd);
install_element(ENABLE_NODE, _act_cmd);
install_element(ENABLE_NODE, _mdcx_cmd);

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

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


[PATCH] osmo-msc[master]: RSL: Allow disabling of BCCH/SACCH filling for given SI type

2017-08-24 Thread Neels Hofmeyr

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

RSL: Allow disabling of BCCH/SACCH filling for given SI type

If we want to instruct the BTS to stop sending a given SI, we must be
able to send the respective BCCH INFO / SACCH FILLING with a header but
without any L3 data IE.  This patch enables the related functions to do
this whenever their data argument points to NULL.

Change-Id: I88b85614951a108574f05db3b706884afe7e87a9
---
M src/libbsc/abis_rsl.c
1 file changed, 8 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/23/3623/1

diff --git a/src/libbsc/abis_rsl.c b/src/libbsc/abis_rsl.c
index 441b386..9e36f79 100644
--- a/src/libbsc/abis_rsl.c
+++ b/src/libbsc/abis_rsl.c
@@ -245,12 +245,14 @@
&& type == RSL_SYSTEM_INFO_13) {
/* Ericsson proprietary encoding of SI13 */
msgb_tv_put(msg, RSL_IE_SYSINFO_TYPE, RSL_ERIC_SYSTEM_INFO_13);
-   msgb_tlv_put(msg, RSL_IE_FULL_BCCH_INFO, len, data);
+   if (data)
+   msgb_tlv_put(msg, RSL_IE_FULL_BCCH_INFO, len, data);
msgb_tv_put(msg, RSL_IE_ERIC_BCCH_MAPPING, 0x00);
} else {
/* Normal encoding */
msgb_tv_put(msg, RSL_IE_SYSINFO_TYPE, type);
-   msgb_tlv_put(msg, RSL_IE_FULL_BCCH_INFO, len, data);
+   if (data)
+   msgb_tlv_put(msg, RSL_IE_FULL_BCCH_INFO, len, data);
}
 
msg->dst = trx->rsl_link;
@@ -269,7 +271,8 @@
ch->msg_type = RSL_MT_SACCH_FILL;
 
msgb_tv_put(msg, RSL_IE_SYSINFO_TYPE, type);
-   msgb_tl16v_put(msg, RSL_IE_L3_INFO, len, data);
+   if (data)
+   msgb_tl16v_put(msg, RSL_IE_L3_INFO, len, data);
 
msg->dst = trx->rsl_link;
 
@@ -288,7 +291,8 @@
dh->chan_nr = chan_nr;
 
msgb_tv_put(msg, RSL_IE_SYSINFO_TYPE, type);
-   msgb_tl16v_put(msg, RSL_IE_L3_INFO, len, data);
+   if (data)
+   msgb_tl16v_put(msg, RSL_IE_L3_INFO, len, data);
 
msg->dst = lchan->ts->trx->rsl_link;
 

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

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


[PATCH] osmo-msc[master]: gsm_04_11: get rid of unused parameter in sms_route_mt_sms()

2017-08-24 Thread Neels Hofmeyr

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

gsm_04_11: get rid of unused parameter in sms_route_mt_sms()

This parameter is unused, remove it.

Change-Id: I797abce3f91447e8f397c7cf726db7425479fe0e
---
M src/libmsc/gsm_04_11.c
1 file changed, 6 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/31/3631/1

diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index 6c6a1fb..3153610 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -189,7 +189,7 @@
return gsm411_smc_send(>sms.smc_inst, msg_type, msg);
 }
 
-static int gsm340_rx_sms_submit(struct msgb *msg, struct gsm_sms *gsms)
+static int gsm340_rx_sms_submit(struct gsm_sms *gsms)
 {
if (db_sms_store(gsms) != 0) {
LOGP(DLSMS, LOGL_ERROR, "Failed to store SMS in Database\n");
@@ -279,8 +279,9 @@
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, bool *deferred)
+static int sms_route_mt_sms(struct gsm_subscriber_connection *conn,
+   struct gsm_sms *gsms, uint8_t sms_mti,
+   bool *deferred)
 {
int rc;
 
@@ -344,7 +345,7 @@
switch (sms_mti) {
case GSM340_SMS_SUBMIT_MS2SC:
/* MS is submitting a SMS */
-   rc = gsm340_rx_sms_submit(msg, gsms);
+   rc = gsm340_rx_sms_submit(gsms);
break;
case GSM340_SMS_COMMAND_MS2SC:
case GSM340_SMS_DELIVER_REP_MS2SC:
@@ -488,7 +489,7 @@
/* FIXME: This looks very wrong */
send_signal(0, NULL, gsms, 0);
 
-   rc = sms_route_mt_sms(conn, msg, gsms, sms_mti, deferred);
+   rc = sms_route_mt_sms(conn, gsms, sms_mti, deferred);
 out:
if (!deferred)
sms_free(gsms);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I797abce3f91447e8f397c7cf726db7425479fe0e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Pablo Neira Ayuso 


[PATCH] osmo-msc[master]: GSM timers: User reasonable defaults; don't save if equal de...

2017-08-24 Thread Neels Hofmeyr

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

GSM timers: User reasonable defaults; don't save if equal default

A number of the GSM timers (including T3109) had no reasonable
default values if not specified in the VTY / config file.  Together
with unconditional writing to the config file, this created
config files with a persistent setting for important timers as '0'.

To make things worse, many of our example cofig files suffered from the
same problem.

Let's avoid this from happening by
* having reasonable defaults if nothing specified in the config file
* conditionally savingg timers only if they differ from default
* reject any timer values that state zero during start-up (see previous
  commit)

Change-Id: Iaac0bfca423852b61d8b9eb1438157ef00d0d8c8
Closes: OS#2380
---
M doc/examples/osmo-bsc/osmo-bsc.cfg
M include/openbsc/gsm_data.h
M src/libbsc/bsc_vty.c
M src/libbsc/net_init.c
4 files changed, 35 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/27/3627/1

diff --git a/doc/examples/osmo-bsc/osmo-bsc.cfg 
b/doc/examples/osmo-bsc/osmo-bsc.cfg
index b974b76..534605a 100644
--- a/doc/examples/osmo-bsc/osmo-bsc.cfg
+++ b/doc/examples/osmo-bsc/osmo-bsc.cfg
@@ -28,18 +28,6 @@
  handover power budget interval 6
  handover power budget hysteresis 3
  handover maximum distance 
- timer t3101 10
- timer t3103 0
- timer t3105 0
- timer t3107 0
- timer t3109 0
- timer t3111 0
- timer t3113 60
- timer t3115 0
- timer t3117 0
- timer t3119 0
- timer t3122 0
- timer t3141 0
  bts 0
   type nanobts
   band DCS1800
diff --git a/include/openbsc/gsm_data.h b/include/openbsc/gsm_data.h
index c307fee..02823c9 100644
--- a/include/openbsc/gsm_data.h
+++ b/include/openbsc/gsm_data.h
@@ -323,10 +323,18 @@
GSM_AUTH_POLICY_REGEXP, /* accept IMSIs matching given regexp */
 };
 
-#define GSM_T3101_DEFAULT 10
-#define GSM_T3105_DEFAULT 40
+#define GSM_T3101_DEFAULT 10   /* s */
+#define GSM_T3103_DEFAULT 5/* s */
+#define GSM_T3105_DEFAULT 100  /* ms */
+#define GSM_T3107_DEFAULT 5/* s */
+#define GSM_T3109_DEFAULT 19   /* s, must be 2s + radio_link_timeout*0.48 */
+#define GSM_T3111_DEFAULT 2/* s */
 #define GSM_T3113_DEFAULT 60
+#define GSM_T3115_DEFAULT 10
+#define GSM_T3117_DEFAULT 10
+#define GSM_T3119_DEFAULT 10
 #define GSM_T3122_DEFAULT 10
+#define GSM_T3141_DEFAULT 10
 
 struct gsm_tz {
int override; /* if 0, use system's time zone instead. */
diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index f3ab35f..1e78b08 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -777,6 +777,11 @@
return CMD_SUCCESS;
 }
 
+/* small helper macro for conditional dumping of timer */
+#define VTY_OUT_TIMER(number)  \
+   if (gsmnet->T##number != GSM_T##number##_DEFAULT)   \
+   vty_out(vty, " timer t"#number" %u%s", gsmnet->T##number, 
VTY_NEWLINE)
+
 static int config_write_net(struct vty *vty)
 {
struct gsm_network *gsmnet = gsmnet_from_vty(vty);
@@ -813,18 +818,18 @@
gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
vty_out(vty, " handover maximum distance %u%s",
gsmnet->handover.max_distance, VTY_NEWLINE);
-   vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
-   vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
-   vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
-   vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
-   vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
-   vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
-   vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
-   vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
-   vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
-   vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
-   vty_out(vty, " timer t3122 %u%s", gsmnet->T3122, VTY_NEWLINE);
-   vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
+   VTY_OUT_TIMER(3101);
+   VTY_OUT_TIMER(3103);
+   VTY_OUT_TIMER(3105);
+   VTY_OUT_TIMER(3107);
+   VTY_OUT_TIMER(3109);
+   VTY_OUT_TIMER(3111);
+   VTY_OUT_TIMER(3113);
+   VTY_OUT_TIMER(3115);
+   VTY_OUT_TIMER(3117);
+   VTY_OUT_TIMER(3119);
+   VTY_OUT_TIMER(3122);
+   VTY_OUT_TIMER(3141);
vty_out(vty, " dyn_ts_allow_tch_f %d%s",
gsmnet->dyn_ts_allow_tch_f ? 1 : 0, VTY_NEWLINE);
if (gsmnet->tz.override != 0) {
diff --git a/src/libbsc/net_init.c b/src/libbsc/net_init.c
index 4dfc258..9d54319 100644
--- a/src/libbsc/net_init.c
+++ b/src/libbsc/net_init.c
@@ -44,10 +44,17 @@
net->num_bts = 0;
net->reject_cause = GSM48_REJECT_ROAMING_NOT_ALLOWED;
net->T3101 = GSM_T3101_DEFAULT;
+   net->T3103 = GSM_T3103_DEFAULT;
net->T3105 = GSM_T3105_DEFAULT;
+   net->T3107 = GSM_T3107_DEFAULT;
+   net->T3109 = 

[PATCH] osmo-msc[master]: gsm_bts_trx_set_system_infos(): Disable non-existing SI

2017-08-24 Thread Neels Hofmeyr

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

gsm_bts_trx_set_system_infos(): Disable non-existing SI

If we previously had a given SI present/active, we must send a
zero-length BCCH FILLING for that SI type to the BTS to stop it from
further transmitting this SI.

Change-Id: I33e356e2fa3a69efac9080813e3e9ef4e6438ed1
Closes: OS#2368
---
M src/libbsc/bsc_init.c
1 file changed, 17 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/24/3624/1

diff --git a/src/libbsc/bsc_init.c b/src/libbsc/bsc_init.c
index 5f41a27..78ca2ab 100644
--- a/src/libbsc/bsc_init.c
+++ b/src/libbsc/bsc_init.c
@@ -104,8 +104,11 @@
struct gsm_bts *bts = trx->bts;
int rc, j;
 
-   DEBUGP(DRR, "SI%s: %s\n", get_value_string(osmo_sitype_strs, i),
-   osmo_hexdump(GSM_BTS_SI(bts, i), GSM_MACBLOCK_LEN));
+   if (si_len) {
+   DEBUGP(DRR, "SI%s: %s\n", get_value_string(osmo_sitype_strs, i),
+   osmo_hexdump(GSM_BTS_SI(bts, i), GSM_MACBLOCK_LEN));
+   } else
+   DEBUGP(DRR, "SI%s: OFF\n", get_value_string(osmo_sitype_strs, 
i));
 
switch (i) {
case SYSINFO_TYPE_5:
@@ -113,14 +116,18 @@
case SYSINFO_TYPE_5ter:
case SYSINFO_TYPE_6:
rc = rsl_sacch_filling(trx, osmo_sitype2rsl(i),
-  GSM_BTS_SI(bts, i), si_len);
+  si_len ? GSM_BTS_SI(bts, i) : NULL, 
si_len);
break;
case SYSINFO_TYPE_2quater:
+   if (si_len == 0) {
+   rc = rsl_bcch_info(trx, i, NULL, 0);
+   break;
+   }
for (j = 0; j <= bts->si2q_count; j++)
rc = rsl_bcch_info(trx, i, (const uint8_t 
*)GSM_BTS_SI2Q(bts, j), GSM_MACBLOCK_LEN);
break;
default:
-   rc = rsl_bcch_info(trx, i, GSM_BTS_SI(bts, i), si_len);
+   rc = rsl_bcch_info(trx, i, si_len ? GSM_BTS_SI(bts, i) : NULL, 
si_len);
break;
}
 
@@ -193,9 +200,13 @@
 
for (n = 0; n < n_si; n++) {
i = gen_si[n];
+   /* if we don't currently have this SI, we send a zero-length
+* RSL BCCH FILLING / SACCH FILLING * in order to deactivate
+* the SI, in case it might have previously been active */
if (!GSM_BTS_HAS_SI(bts, i))
-   continue;
-   rc = rsl_si(trx, i, si_len[i]);
+   rc = rsl_si(trx, i, 0);
+   else
+   rc = rsl_si(trx, i, si_len[i]);
if (rc < 0)
return rc;
}

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

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


[PATCH] osmo-msc[master]: jenkins.sh: Proper error message if local environment isn't ...

2017-08-24 Thread Neels Hofmeyr

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

jenkins.sh: Proper error message if local environment isn't set up

Change-Id: I79c2302365824d9c8783dadfa378c8eaa07e2ee7
---
M contrib/jenkins.sh
1 file changed, 7 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/11/3611/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 5903429..30c86b4 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -1,4 +1,11 @@
 #!/usr/bin/env bash
+# jenkins build helper script for openbsc.  This is how we build on 
jenkins.osmocom.org
+
+if ! [ -x "$(command -v osmo-build-dep.sh)" ]; then
+   echo "Error: We need to have scripts/osmo-deps.sh from 
http://git.osmocom.org/osmo-ci/ in PATH !"
+   exit 2
+fi
+
 
 set -ex
 

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

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


[PATCH] osmo-msc[master]: check for missing result of rate_ctr_group_alloc()

2017-08-24 Thread Neels Hofmeyr

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

check for missing result of rate_ctr_group_alloc()

In case the counter group allocation fails, we must handle this
gracefully and fail the allocation of the parent object, too.

RelateD: OS#2361
Change-Id: I7dad4a4d52fe05f6b990359841b4408df5990e21
---
M src/gprs/gb_proxy.c
M src/gprs/gb_proxy_peer.c
M src/gprs/gprs_sgsn.c
M src/libbsc/net_init.c
M src/libcommon-cs/common_cs.c
5 files changed, 32 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/21/3621/1

diff --git a/src/gprs/gb_proxy.c b/src/gprs/gb_proxy.c
index d95139f..3603e14 100644
--- a/src/gprs/gb_proxy.c
+++ b/src/gprs/gb_proxy.c
@@ -1431,6 +1431,10 @@
 
INIT_LLIST_HEAD(>bts_peers);
cfg->ctrg = rate_ctr_group_alloc(tall_bsc_ctx, _ctrg_desc, 0);
+   if (!cfg->ctrg) {
+   LOGP(DGPRS, LOGL_ERROR, "Cannot allocate global counter 
group!\n");
+   return -1;
+   }
clock_gettime(CLOCK_REALTIME, );
 
return 0;
diff --git a/src/gprs/gb_proxy_peer.c b/src/gprs/gb_proxy_peer.c
index 5365ff0..8909687 100644
--- a/src/gprs/gb_proxy_peer.c
+++ b/src/gprs/gb_proxy_peer.c
@@ -177,6 +177,10 @@
 
peer->bvci = bvci;
peer->ctrg = rate_ctr_group_alloc(peer, _ctrg_desc, bvci);
+   if (!peer->ctrg) {
+   talloc_free(peer);
+   return NULL;
+   }
peer->cfg = cfg;
 
llist_add(>list, >bts_peers);
diff --git a/src/gprs/gprs_sgsn.c b/src/gprs/gprs_sgsn.c
index 11225dd..93b133f 100644
--- a/src/gprs/gprs_sgsn.c
+++ b/src/gprs/gprs_sgsn.c
@@ -129,6 +129,7 @@
 
 void sgsn_rate_ctr_init() {
sgsn->rate_ctrs = rate_ctr_group_alloc(tall_bsc_ctx, _ctrg_desc, 
0);
+   OSMO_ASSERT(sgsn->rate_ctrs);
 }
 
 /* look-up an SGSN MM context based on Iu UE context (struct ue_conn_ctx)*/
@@ -229,6 +230,11 @@
LOGMMCTXP(LOGL_DEBUG, ctx, "Allocated with %s cipher.\n",
  get_value_string(gprs_cipher_names, ctx->ciph_algo));
ctx->ctrg = rate_ctr_group_alloc(ctx, _ctrg_desc, tlli);
+   if (!ctx->ctrg) {
+   LOGMMCTXP(LOGL_ERROR, ctx, "Cannot allocate counter group\n");
+   talloc_free(ctx);
+   return NULL;
+   }
INIT_LLIST_HEAD(>pdp_list);
 
llist_add(>list, _mm_ctxts);
@@ -253,6 +259,11 @@
ctx->pmm_state = PMM_DETACHED;
ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL;
ctx->ctrg = rate_ctr_group_alloc(ctx, _ctrg_desc, 0);
+   if (!ctx->ctrg) {
+   LOGMMCTXP(LOGL_ERROR, ctx, "Cannot allocate counter group\n");
+   talloc_free(ctx);
+   return NULL;
+   }
 
/* Need to get RAID from IU conn */
ctx->ra = ctx->iu.ue_ctx->ra_id;
@@ -380,6 +391,11 @@
pdp->mm = mm;
pdp->nsapi = nsapi;
pdp->ctrg = rate_ctr_group_alloc(pdp, _ctrg_desc, nsapi);
+   if (!pdp->ctrg) {
+   LOGPDPCTXP(LOGL_ERROR, pdp, "Error allocation counter group\n");
+   talloc_free(pdp);
+   return NULL;
+   }
llist_add(>list, >pdp_list);
llist_add(>g_list, _pdp_ctxts);
 
diff --git a/src/libbsc/net_init.c b/src/libbsc/net_init.c
index bc5ed35..4dfc258 100644
--- a/src/libbsc/net_init.c
+++ b/src/libbsc/net_init.c
@@ -61,6 +61,10 @@
 
/* init statistics */
net->bsc_ctrs = rate_ctr_group_alloc(net, _ctrg_desc, 0);
+   if (!net->bsc_ctrs) {
+   talloc_free(net);
+   return NULL;
+   }
 
gsm_net_update_ctype(net);
 
diff --git a/src/libcommon-cs/common_cs.c b/src/libcommon-cs/common_cs.c
index 8e19bb2..99206c8 100644
--- a/src/libcommon-cs/common_cs.c
+++ b/src/libcommon-cs/common_cs.c
@@ -68,6 +68,10 @@
 
/* init statistics */
net->msc_ctrs = rate_ctr_group_alloc(net, _ctrg_desc, 0);
+   if (!net->msc_ctrs) {
+   talloc_free(net);
+   return NULL;
+   }
net->active_calls = osmo_counter_alloc("msc.active_calls");
 
net->mncc_recv = mncc_recv;

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

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


[PATCH] osmo-msc[master]: bsc_api: Fix copy+paste error in printing name of RR STATUS PDU

2017-08-24 Thread Neels Hofmeyr

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

bsc_api: Fix copy+paste error in printing name of RR STATUS PDU

Change-Id: I0ef78ef046e4850346569f750693e12938b50ab5
---
M src/libbsc/bsc_api.c
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/19/3619/1

diff --git a/src/libbsc/bsc_api.c b/src/libbsc/bsc_api.c
index c2828e3..c60f818 100644
--- a/src/libbsc/bsc_api.c
+++ b/src/libbsc/bsc_api.c
@@ -607,7 +607,7 @@
break;
case GSM48_MT_RR_STATUS:
LOGP(DRR, LOGL_NOTICE, "%s (cause: %s)\n",
-gsm48_rr_msg_name(GSM48_MT_RR_GPRS_SUSP_REQ),
+gsm48_rr_msg_name(GSM48_MT_RR_STATUS),
 rr_cause_name(gh->data[0]));
break;
case GSM48_MT_RR_MEAS_REP:

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

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


[PATCH] osmo-msc[master]: Add VTY commands for experimentation with TS 04.14 commands

2017-08-24 Thread Neels Hofmeyr

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

Add VTY commands for experimentation with TS 04.14 commands

TS 04.14 (TS 44.014) specifies a series of commands specific to
conformance testing.  Let's add some VTY commands to play (at least
initially) with closing and opening voice loops in the MS.

Change-Id: I38b1ee9dbf26f5689c38cb83b1b3c5e9eaad7678
---
M src/libmsc/vty_interface_layer3.c
1 file changed, 94 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/16/3616/1

diff --git a/src/libmsc/vty_interface_layer3.c 
b/src/libmsc/vty_interface_layer3.c
index 1761ebc..864597d 100644
--- a/src/libmsc/vty_interface_layer3.c
+++ b/src/libmsc/vty_interface_layer3.c
@@ -46,6 +46,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -473,6 +474,97 @@
return CMD_SUCCESS;
 }
 
+static int loop_by_char(uint8_t ch)
+{
+   switch (ch) {
+   case 'a':
+   return GSM414_LOOP_A;
+   case 'b':
+   return GSM414_LOOP_B;
+   case 'c':
+   return GSM414_LOOP_C;
+   case 'd':
+   return GSM414_LOOP_D;
+   case 'e':
+   return GSM414_LOOP_E;
+   case 'f':
+   return GSM414_LOOP_F;
+   case 'i':
+   return GSM414_LOOP_I;
+   }
+   return -1;
+}
+
+DEFUN(subscriber_mstest_close,
+  subscriber_mstest_close_cmd,
+  "subscriber " SUBSCR_TYPES " ID ms-test close-loop (a|b|c|d|e|f|i)",
+  SUBSCR_HELP "Send a TS 04.14 MS Test Command to subscriber\n"
+  "Close a TCH Loop inside the MS\n"
+  "Loop Type A\n"
+  "Loop Type B\n"
+  "Loop Type C\n"
+  "Loop Type D\n"
+  "Loop Type E\n"
+  "Loop Type F\n"
+  "Loop Type I\n")
+{
+   struct gsm_subscriber_connection *conn;
+   struct gsm_network *gsmnet = gsmnet_from_vty(vty);
+   struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]);
+   const char *loop_str;
+   int loop_mode;
+
+   if (!vsub) {
+   vty_out(vty, "%% No subscriber found for %s %s%s",
+   argv[0], argv[1], VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   loop_str = argv[2];
+   loop_mode = loop_by_char(loop_str[0]);
+
+   conn = connection_for_subscr(vsub);
+   if (!conn) {
+   vty_out(vty, "%% An active connection is required for %s %s%s",
+   argv[0], argv[1], VTY_NEWLINE);
+   vlr_subscr_put(vsub);
+   return CMD_WARNING;
+   }
+
+   gsm0414_tx_close_tch_loop_cmd(conn, loop_mode);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(subscriber_mstest_open,
+  subscriber_mstest_open_cmd,
+  "subscriber " SUBSCR_TYPES " ID ms-test open-loop",
+  SUBSCR_HELP "Send a TS 04.14 MS Test Command to subscriber\n"
+  "Open a TCH Loop inside the MS\n")
+{
+   struct gsm_subscriber_connection *conn;
+   struct gsm_network *gsmnet = gsmnet_from_vty(vty);
+   struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]);
+
+   if (!vsub) {
+   vty_out(vty, "%% No subscriber found for %s %s%s",
+   argv[0], argv[1], VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   conn = connection_for_subscr(vsub);
+   if (!conn) {
+   vty_out(vty, "%% An active connection is required for %s %s%s",
+   argv[0], argv[1], VTY_NEWLINE);
+   vlr_subscr_put(vsub);
+   return CMD_WARNING;
+   }
+
+   gsm0414_tx_open_loop_cmd(conn);
+
+   return CMD_SUCCESS;
+}
+
 DEFUN(ena_subscr_expire,
   ena_subscr_expire_cmd,
   "subscriber " SUBSCR_TYPES " ID expire",
@@ -851,6 +943,8 @@
install_element_ve(_silent_call_start_cmd);
install_element_ve(_silent_call_stop_cmd);
install_element_ve(_ussd_notify_cmd);
+   install_element_ve(_mstest_close_cmd);
+   install_element_ve(_mstest_open_cmd);
install_element_ve(_update_cmd);
install_element_ve(_stats_cmd);
install_element_ve(_smsqueue_cmd);

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

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


[PATCH] osmo-msc[master]: libmsc: Fix VTY output for handover counters.

2017-08-24 Thread Neels Hofmeyr

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

libmsc: Fix VTY output for handover counters.

Handover countrs belong to BSC, but we mistakenly take values from MSC counters.

Change-Id: I9512330f2e91d2f526751c5228e6e8e0fe17d579
---
M src/libmsc/vty_interface_layer3.c
1 file changed, 5 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/14/3614/1

diff --git a/src/libmsc/vty_interface_layer3.c 
b/src/libmsc/vty_interface_layer3.c
index d1bf6b3..1761ebc 100644
--- a/src/libmsc/vty_interface_layer3.c
+++ b/src/libmsc/vty_interface_layer3.c
@@ -570,11 +570,11 @@
VTY_NEWLINE);
vty_out(vty, "Handover: %lu attempted, %lu no_channel, 
%lu timeout, "
"%lu completed, %lu failed%s",
-   net->msc_ctrs->ctr[BSC_CTR_HANDOVER_ATTEMPTED].current,
-   net->msc_ctrs->ctr[BSC_CTR_HANDOVER_NO_CHANNEL].current,
-   net->msc_ctrs->ctr[BSC_CTR_HANDOVER_TIMEOUT].current,
-   net->msc_ctrs->ctr[BSC_CTR_HANDOVER_COMPLETED].current,
-   net->msc_ctrs->ctr[BSC_CTR_HANDOVER_FAILED].current,
+   net->bsc_ctrs->ctr[BSC_CTR_HANDOVER_ATTEMPTED].current,
+   net->bsc_ctrs->ctr[BSC_CTR_HANDOVER_NO_CHANNEL].current,
+   net->bsc_ctrs->ctr[BSC_CTR_HANDOVER_TIMEOUT].current,
+   net->bsc_ctrs->ctr[BSC_CTR_HANDOVER_COMPLETED].current,
+   net->bsc_ctrs->ctr[BSC_CTR_HANDOVER_FAILED].current,
VTY_NEWLINE);
vty_out(vty, "SMS MO  : %lu submitted, %lu no 
receiver%s",
net->msc_ctrs->ctr[MSC_CTR_SMS_SUBMITTED].current,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9512330f2e91d2f526751c5228e6e8e0fe17d579
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Alexander Chemeris 


[PATCH] osmo-msc[master]: Support for TS 04.14 conformance test commands

2017-08-24 Thread Neels Hofmeyr

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

Support for TS 04.14 conformance test commands

Change-Id: Ib27edbfc8ccdedf00589ec715ced7bed435fa94c
---
M include/openbsc/Makefile.am
A include/openbsc/gsm_04_14.h
M src/libmsc/Makefile.am
M src/libmsc/gsm_04_08.c
A src/libmsc/gsm_04_14.c
5 files changed, 154 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/15/3615/1

diff --git a/include/openbsc/Makefile.am b/include/openbsc/Makefile.am
index 2558d7c..995f02d 100644
--- a/include/openbsc/Makefile.am
+++ b/include/openbsc/Makefile.am
@@ -37,6 +37,7 @@
gprs_utils.h \
gsm_04_08.h \
gsm_04_11.h \
+   gsm_04_14.h \
gsm_04_80.h \
gsm_data.h \
gsm_data_shared.h \
diff --git a/include/openbsc/gsm_04_14.h b/include/openbsc/gsm_04_14.h
new file mode 100644
index 000..3cdbe04
--- /dev/null
+++ b/include/openbsc/gsm_04_14.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include 
+
+int gsm0414_tx_close_tch_loop_cmd(struct gsm_subscriber_connection *conn,
+ enum gsm414_tch_loop_mode loop_mode);
+int gsm0414_tx_open_loop_cmd(struct gsm_subscriber_connection *conn);
+int gsm0414_tx_act_emmi_cmd(struct gsm_subscriber_connection *conn);
+int gsm0414_tx_test_interface(struct gsm_subscriber_connection *conn,
+ uint8_t tested_devs);
+int gsm0414_tx_reset_ms_pos_store(struct gsm_subscriber_connection *conn,
+ uint8_t technology);
+
+int gsm0414_rcv_test(struct gsm_subscriber_connection *conn,
+struct msgb *msg);
diff --git a/src/libmsc/Makefile.am b/src/libmsc/Makefile.am
index 16154ff..4726bbe 100644
--- a/src/libmsc/Makefile.am
+++ b/src/libmsc/Makefile.am
@@ -30,6 +30,7 @@
db.c \
gsm_04_08.c \
gsm_04_11.c \
+   gsm_04_14.c \
gsm_04_80.c \
gsm_subscriber.c \
iucs.c \
diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c
index a4e16fb..07efb32 100644
--- a/src/libmsc/gsm_04_08.c
+++ b/src/libmsc/gsm_04_08.c
@@ -43,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3077,6 +3078,9 @@
case GSM48_PDISC_NC_SS:
rc = handle_rcv_ussd(conn, msg);
break;
+   case GSM48_PDISC_TEST:
+   rc = gsm0414_rcv_test(conn, msg);
+   break;
default:
LOGP(DRLL, LOGL_NOTICE, "Unknown "
"GSM 04.08 discriminator 0x%02x\n", pdisc);
diff --git a/src/libmsc/gsm_04_14.c b/src/libmsc/gsm_04_14.c
new file mode 100644
index 000..b529f4c
--- /dev/null
+++ b/src/libmsc/gsm_04_14.c
@@ -0,0 +1,133 @@
+/* GSM MS Testing  Layer 3 messages
+ * 3GPP TS 44.014 / GSM TS 04.14 */
+
+/* (C) 2017 by Harald Welte 
+ *
+ * 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 .
+ *
+ */
+
+#include 
+#include 
+#include 
+
+#include "bscconfig.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static struct msgb *create_gsm0414_msg(uint8_t msg_type)
+{
+   struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.14");
+   struct gsm48_hdr *gh;
+
+   gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
+   gh->proto_discr = GSM48_PDISC_TEST;
+   gh->msg_type = msg_type;
+   return msg;
+}
+
+static int gsm0414_conn_sendmsg(struct gsm_subscriber_connection *conn, struct 
msgb *msg)
+{
+   return msc_tx_dtap(conn, msg);
+}
+
+static int gsm0414_tx_simple(struct gsm_subscriber_connection *conn, uint8_t 
msg_type)
+{
+   struct msgb *msg = create_gsm0414_msg(msg_type);
+
+   return gsm0414_conn_sendmsg(conn, msg);
+}
+
+
+/* Send a CLOSE_TCH_LOOOP_CMD according to Section 8.1 */
+int gsm0414_tx_close_tch_loop_cmd(struct gsm_subscriber_connection *conn,
+ enum gsm414_tch_loop_mode loop_mode)
+{
+   struct msgb *msg = create_gsm0414_msg(GSM414_MT_CLOSE_TCH_LOOP_CMD);
+   uint8_t subch;
+
+   subch = (loop_mode << 1);
+   msgb_put_u8(msg, subch);
+
+   msg->lchan = conn->lchan;
+   return gsm0414_conn_sendmsg(conn, msg);
+}
+
+/* Send a OPEN_LOOP_CMD according to Section 8.3 */
+int gsm0414_tx_open_loop_cmd(struct 

[PATCH] osmo-msc[master]: smpp: fix return cause

2017-08-24 Thread Neels Hofmeyr

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

smpp: fix return cause

Return cause 38 when default SMPP route is unavailable. This
is better than cause 1.

Change-Id: If3241d50a78fa611981e55fef6ae4c72b0a2a167
---
M src/libmsc/gsm_04_11.c
M src/libmsc/smpp_openbsc.c
M src/libmsc/smpp_smsc.c
M src/libmsc/smpp_smsc.h
4 files changed, 17 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/10/3610/1

diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index bdf2ad7..6c6a1fb 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -296,6 +296,7 @@
if (smpp_first) {
rc = smpp_try_deliver(gsms, conn, deferred);
if (rc == GSM411_RP_CAUSE_MO_NUM_UNASSIGNED)
+   /* unknown subscriber, try local */
goto try_local;
if (rc < 0) {
LOGP(DLSMS, LOGL_ERROR, "%s: SMS delivery error: %d.",
diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c
index 24a4653..b3f9bbb 100644
--- a/src/libmsc/smpp_openbsc.c
+++ b/src/libmsc/smpp_openbsc.c
@@ -709,17 +709,18 @@
 {
struct osmo_esme *esme;
struct osmo_smpp_addr dst;
+   int rc;
 
memset(, 0, sizeof(dst));
dst.ton = sms->dst.ton;
dst.npi = sms->dst.npi;
memcpy(dst.addr, sms->dst.addr, sizeof(dst.addr));
 
-   esme = smpp_route(g_smsc, );
-   if (!esme)
-   return GSM411_RP_CAUSE_MO_NUM_UNASSIGNED;
+   rc = smpp_route(g_smsc, , );
+   if (!rc)
+   rc = deliver_to_esme(esme, sms, conn, deferred);
 
-   return deliver_to_esme(esme, sms, conn, deferred);
+   return rc;
 }
 
 struct smsc *smsc_from_vty(struct vty *v)
diff --git a/src/libmsc/smpp_smsc.c b/src/libmsc/smpp_smsc.c
index 4c2e4aa..04afc49 100644
--- a/src/libmsc/smpp_smsc.c
+++ b/src/libmsc/smpp_smsc.c
@@ -270,8 +270,7 @@
 }
 
 /*! \brief try to find a SMPP route (ESME) for given destination */
-struct osmo_esme *
-smpp_route(const struct smsc *smsc, const struct osmo_smpp_addr *dest)
+int smpp_route(const struct smsc *smsc, const struct osmo_smpp_addr *dest, 
struct osmo_esme **pesme)
 {
struct osmo_smpp_route *r;
struct osmo_smpp_acl *acl = NULL;
@@ -314,15 +313,20 @@
struct osmo_esme *esme;
DEBUGP(DSMPP, "ACL even has ESME, we can route to it!\n");
esme = acl->esme;
-   if (esme->bind_flags & ESME_BIND_RX)
-   return esme;
-   else
+   if (esme->bind_flags & ESME_BIND_RX) {
+   *pesme = esme;
+   return 0;
+   } else
LOGP(DSMPP, LOGL_NOTICE, "[%s] is matching route, "
 "but not bound for Rx, discarding MO SMS\n",
 esme->system_id);
}
 
-   return NULL;
+   *pesme = NULL;
+   if (acl)
+   return GSM48_CC_CAUSE_NETWORK_OOO;
+   else
+   return GSM48_CC_CAUSE_UNASSIGNED_NR;
 }
 
 
diff --git a/src/libmsc/smpp_smsc.h b/src/libmsc/smpp_smsc.h
index 4bee59b..fded236 100644
--- a/src/libmsc/smpp_smsc.h
+++ b/src/libmsc/smpp_smsc.h
@@ -126,8 +126,7 @@
 void smpp_esme_get(struct osmo_esme *esme);
 void smpp_esme_put(struct osmo_esme *esme);
 
-struct osmo_esme *
-smpp_route(const struct smsc *smsc, const struct osmo_smpp_addr *dest);
+int smpp_route(const struct smsc *smsc, const struct osmo_smpp_addr *dest, 
struct osmo_esme **emse);
 
 struct osmo_smpp_acl *smpp_acl_alloc(struct smsc *smsc, const char *sys_id);
 struct osmo_smpp_acl *smpp_acl_by_system_id(struct smsc *smsc,

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

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


[PATCH] osmo-msc[master]: 04.08: find a portable way to obtain the timezone offset

2017-08-24 Thread Neels Hofmeyr

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

04.08: find a portable way to obtain the timezone offset

Portable GMT offset calculation to display correct
time on GSM.

Change-Id: I673f17af2550c9708c4771e4ea4eafbbfafbb824
---
M src/libmsc/gsm_04_08.c
1 file changed, 10 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/12/3612/1

diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c
index 3f3f905..a4e16fb 100644
--- a/src/libmsc/gsm_04_08.c
+++ b/src/libmsc/gsm_04_08.c
@@ -496,12 +496,19 @@
else {
/* Need to get GSM offset and convert into 15 min units */
/* This probably breaks if gmtoff returns a value not evenly 
divisible by 15? */
-   local_time = localtime(_t);
 #ifdef HAVE_TM_GMTOFF_IN_TM
+   local_time = localtime(_t);
tzunits = (local_time->tm_gmtoff/60)/15;
 #else
-#warning find a portable way to obtain the timezone offset
-   tzunits = 0;
+   /* find timezone offset */
+   time_t utc;
+   double offsetFromUTC;
+   utc = mktime(gmt_time);
+   local_time = localtime(_t);
+   offsetFromUTC = difftime(cur_t, utc);
+   if (local_time->tm_isdst)
+   offsetFromUTC += 3600.0;
+   tzunits = ((int)offsetFromUTC) / 60 / 15;
 #endif
if (tzunits < 0) {
tzunits = tzunits/-1;

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

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


sandbox[master]: add .gitreview

2017-08-24 Thread Neels Hofmeyr

Patch Set 1: Code-Review+2 Verified+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie7cdf16232181d4b8093e61f2d8a3faed9010d4f
Gerrit-PatchSet: 1
Gerrit-Project: sandbox
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


[MERGED] sandbox[master]: add .gitreview

2017-08-24 Thread Neels Hofmeyr
Neels Hofmeyr has submitted this change and it was merged.

Change subject: add .gitreview
..


add .gitreview

A .gitreview file is required to use git review.
More information about git review
https://www.mediawiki.org/wiki/Gerrit/git-review

Change-Id: Ie7cdf16232181d4b8093e61f2d8a3faed9010d4f
---
A .gitreview
1 file changed, 3 insertions(+), 0 deletions(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved; Verified



diff --git a/.gitreview b/.gitreview
new file mode 100644
index 000..e7058f4
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,3 @@
+[gerrit]
+host=gerrit.osmocom.org
+project=sandbox

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie7cdf16232181d4b8093e61f2d8a3faed9010d4f
Gerrit-PatchSet: 1
Gerrit-Project: sandbox
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Neels Hofmeyr 


[PATCH] sandbox[master]: add .gitreview

2017-08-24 Thread Neels Hofmeyr

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

add .gitreview

A .gitreview file is required to use git review.
More information about git review
https://www.mediawiki.org/wiki/Gerrit/git-review

Change-Id: Ie7cdf16232181d4b8093e61f2d8a3faed9010d4f
---
A .gitreview
1 file changed, 3 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/sandbox refs/changes/08/3608/1

diff --git a/.gitreview b/.gitreview
new file mode 100644
index 000..e7058f4
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,3 @@
+[gerrit]
+host=gerrit.osmocom.org
+project=sandbox

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie7cdf16232181d4b8093e61f2d8a3faed9010d4f
Gerrit-PatchSet: 1
Gerrit-Project: sandbox
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 


  1   2   >