libosmocore[master]: gsm0480: modify USSD structures to support external handling

2017-08-01 Thread Alexander Chemeris

Patch Set 2:

> in general, what is your strategy for forward/backward
 > compatibility here? you're changing the API and ABI while keeping
 > the symbol name identical, breaking existing applications

Should we just bump the lib version? Otherwise we'll have to maintain two 
similar structures and similar, but different set of functions to operate them, 
which looks like an overkill here given there is only one user of this code - 
*#100# in osmo-nitb.

As a general comment, these patches are supposed to pave the way to more 
patches to osmo-nitb to allow communicating un-parsed SS/USSD to an external 
application. Thus splitting structures and functions in a way when we can avoid 
parsing the whole SS/USSD request every time.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I5f8972b86cd4dcb54b643a24b5794a87c8758073
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


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

2017-08-01 Thread Harald Welte

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

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 openbsc/src/gprs/sgsn_libgtp.c
1 file changed, 14 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/00/3400/1

diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c
index 387b95f..e90b66d 100644
--- a/openbsc/src/gprs/sgsn_libgtp.c
+++ b/openbsc/src/gprs/sgsn_libgtp.c
@@ -251,9 +251,12 @@
memcpy(pdp->gsnlu.v, >cfg.gtp_listenaddr.sin_addr,
sizeof(sgsn->cfg.gtp_listenaddr.sin_addr));
 
-   /* Assume we are a GERAN system */
+   /* Encode RAT Type according to TS 29.060 7.7.50 */
pdp->rattype.l = 1;
-   pdp->rattype.v[0] = 2;
+   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 */
@@ -264,10 +267,17 @@
raid.rac = 0xFF;
gsm48_construct_ra(pdp->rai.v, );
 
+   /* Encode User Location Information accordint to TS 29.060 7.7.51 */
pdp->userloc_given = 1;
pdp->userloc.l = 8;
-   pdp->userloc.v[0] = 0; /* CGI for GERAN */
-   bssgp_create_cell_id(>userloc.v[1], >ra, mmctx->gb.cell_id);
+   if (mmctx->ran_type == MM_CTX_T_UTRAN_Iu) {
+   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);
+   } else {
+   pdp->userloc.v[0] = 0; /* CGI for GERAN */
+   bssgp_create_cell_id(>userloc.v[1], >ra, 
mmctx->gb.cell_id);
+   }
 
/* include the IMEI(SV) */
pdp->imeisv_given = 1;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c79e42c5e08b28fe8182555302a5505fbbaa313
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] openbsc[master]: Fix gsm_pchan2chan_nr() to use RSL_CHAN_OSMO_PDCH

2017-08-01 Thread Harald Welte

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

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.

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


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/99/3399/1

diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c
index f4fd6de..18a8072 100644
--- a/openbsc/src/libbsc/abis_rsl.c
+++ b/openbsc/src/libbsc/abis_rsl.c
@@ -2439,7 +2439,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_TCHF, ts->nr, 0);
 
DEBUGP(DRSL, "%s IPAC PDCH %sACT\n", gsm_ts_name(ts),
act ? "" : "DE");
diff --git a/openbsc/src/libcommon/gsm_data_shared.c 
b/openbsc/src/libcommon/gsm_data_shared.c
index 8992636..6302e05 100644
--- a/openbsc/src/libcommon/gsm_data_shared.c
+++ b/openbsc/src/libcommon/gsm_data_shared.c
@@ -643,11 +643,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/3399
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie34219e64a6d89da4a79f2db8ec73d1909fb8280
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] libosmo-sccp[master]: sccp: add function to check sccp addresses

2017-08-01 Thread dexter

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

sccp: add function to check sccp addresses

In order to catch invalid CS7 configurations, It is necessary
to check if sccp addresses contain plausible address data.

Change-Id: Ic6245288b0171eae10aa708403c1ddb584c92f38
---
M include/osmocom/sigtran/sccp_sap.h
M src/sccp_user.c
2 files changed, 44 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/98/3398/1

diff --git a/include/osmocom/sigtran/sccp_sap.h 
b/include/osmocom/sigtran/sccp_sap.h
index 732df2a..90da686 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -257,3 +257,5 @@
 void osmo_sccp_local_addr_by_instance(struct osmo_sccp_addr *dest_addr,
  const struct osmo_sccp_instance *inst,
  uint32_t ssn);
+
+bool osmo_sccp_check_addr(struct osmo_sccp_addr *addr, uint32_t presence);
diff --git a/src/sccp_user.c b/src/sccp_user.c
index 495b6dc..3724eb1 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -253,6 +253,48 @@
osmo_sccp_make_addr_pc_ssn(dest_addr, ss7->cfg.primary_pc, ssn);
 }
 
+/*! \brief check if a given SCCP-Address is consistant.
+ *  \param[in] addr SCCP address to check
+ *  \param[in] presence mask with minimum required address components
+ *  \returns true when address data seems plausible */
+bool osmo_sccp_check_addr(struct osmo_sccp_addr *addr, uint32_t presence)
+{
+   /* Minimum requirements do not match */
+   if ((addr->presence & presence) != presence)
+   return false;
+
+   /* GT ranges */
+   if (addr->presence & OSMO_SCCP_ADDR_T_GT) {
+   if (addr->gt.gti > 15)
+   return false;
+   if (addr->gt.npi > 15)
+   return false;
+   if (addr->gt.nai > 127)
+   return false;
+   }
+
+   /* Routing by GT, but no GT present */
+   if (addr->ri == OSMO_SCCP_RI_GT
+   && !(addr->presence & OSMO_SCCP_ADDR_T_GT))
+   return false;
+
+   /* Routing by PC/SSN, but no PC/SSN present */
+   if (addr->ri == OSMO_SCCP_RI_SSN_PC) {
+   if ((addr->presence & OSMO_SCCP_ADDR_T_PC) == 0)
+   return false;
+   if ((addr->presence & OSMO_SCCP_ADDR_T_SSN) == 0)
+   return false;
+   }
+
+   if (addr->ri == OSMO_SCCP_RI_SSN_IP) {
+   if ((addr->presence & OSMO_SCCP_ADDR_T_IPv4) == 0 &&
+   (addr->presence & OSMO_SCCP_ADDR_T_IPv6) == 0)
+   return false;
+   }
+
+   return true;
+}
+
 /***
  * Convenience function for CLIENT
  ***/

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic6245288b0171eae10aa708403c1ddb584c92f38
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter 


libosmocore[master]: gsm0480: refactor the parse_process_uss_req()

2017-08-01 Thread Harald Welte

Patch Set 3:

rather than improving the manually-generated code for USSD/SS parsing, 
shouldn't we simply move to using asn1c for generaging C code for the SS 
related ASN.1?

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I467f75794c5ac9df75c001245b18bbdfcfaadd88
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


libosmocore[master]: gsm0480: modify USSD structures to support external handling

2017-08-01 Thread Harald Welte

Patch Set 2: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I5f8972b86cd4dcb54b643a24b5794a87c8758073
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


libosmo-sccp[master]: sccp: derive local address from given sccp instance

2017-08-01 Thread Harald Welte

Patch Set 3: Code-Review+2

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

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


[MERGED] libosmo-sccp[master]: sccp: derive local address from given sccp instance

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

Change subject: sccp: derive local address from given sccp instance
..


sccp: derive local address from given sccp instance

The most important parts of an SCCP address are the routing
indicator and the pointcode. The latter one is always available
via the SS7 instance, so a basic local address can be derived
from there.

Add function osmo_sccp_local_addr_by_instance() to derive a basic
local SCCP address from a given SCCP instance

Change-Id: I371dc9132871aad3d8321ea13cf9fd69d76eff8f
---
M include/osmocom/sigtran/sccp_sap.h
M src/sccp_user.c
2 files changed, 26 insertions(+), 0 deletions(-)

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



diff --git a/include/osmocom/sigtran/sccp_sap.h 
b/include/osmocom/sigtran/sccp_sap.h
index 24d64d9..732df2a 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -253,3 +253,7 @@
   const char *name);
 
 const char *osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr);
+
+void osmo_sccp_local_addr_by_instance(struct osmo_sccp_addr *dest_addr,
+ const struct osmo_sccp_instance *inst,
+ uint32_t ssn);
diff --git a/src/sccp_user.c b/src/sccp_user.c
index 89a0320..495b6dc 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -22,6 +22,7 @@
  */
 
 #include 
+#include 
 
 #include 
 #include 
@@ -30,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "sccp_internal.h"
 #include "xua_internal.h"
@@ -231,6 +233,26 @@
talloc_free(inst);
 }
 
+/*! \brief derive a basic local SCCP-Address from a given SCCP instance.
+ *  \param[out] dest_addr pointer to output address memory
+ *  \param[in] inst SCCP instance
+ *  \param[in] ssn Subsystem Number */
+void osmo_sccp_local_addr_by_instance(struct osmo_sccp_addr *dest_addr,
+ const struct osmo_sccp_instance *inst,
+ uint32_t ssn)
+{
+   struct osmo_ss7_instance *ss7;
+
+   OSMO_ASSERT(dest_addr);
+   OSMO_ASSERT(inst);
+   ss7 = inst->ss7;
+   OSMO_ASSERT(ss7);
+
+   *dest_addr = (struct osmo_sccp_addr){};
+
+   osmo_sccp_make_addr_pc_ssn(dest_addr, ss7->cfg.primary_pc, ssn);
+}
+
 /***
  * Convenience function for CLIENT
  ***/

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I371dc9132871aad3d8321ea13cf9fd69d76eff8f
Gerrit-PatchSet: 4
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


[MERGED] libosmo-sccp[master]: sccp: fix possible nullpointer deref

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

Change subject: sccp: fix possible nullpointer deref
..


sccp: fix possible nullpointer deref

check input parameters local_ip and remote_ip of the function
osmo_sccp_simple_client_on_ss7_id() before using them with
talloc_strdup()

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

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



diff --git a/src/sccp_user.c b/src/sccp_user.c
index c9443a2..89a0320 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -331,8 +331,10 @@
goto out_rt;
asp_created = true;
 
-   asp->cfg.local.host = talloc_strdup(asp, local_ip);
-   asp->cfg.remote.host = talloc_strdup(asp, remote_ip);
+   local_ip ? asp->cfg.local.host =
+   talloc_strdup(asp, local_ip) : NULL;
+   remote_ip ? asp->cfg.remote.host =
+   talloc_strdup(asp, remote_ip) : NULL;
 
osmo_ss7_as_add_asp(as, asp->cfg.name);
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1a5dd1ea3167513bf9e7ae153f83e1ae3136c905
Gerrit-PatchSet: 3
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


[MERGED] osmo-bts[master]: lc-15, sysmo: l1_if: print name on PH-DATA.ind unknwon sapi

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

Change subject: lc-15, sysmo: l1_if: print name on PH-DATA.ind unknwon sapi
..


lc-15, sysmo: l1_if: print name on PH-DATA.ind unknwon sapi

Change-Id: I007e5f0ce9709026331817e55148749e21d8b015
---
M src/osmo-bts-litecell15/l1_if.c
M src/osmo-bts-sysmo/l1_if.c
2 files changed, 4 insertions(+), 4 deletions(-)

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



diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c
index cb3efab..a3b9556 100644
--- a/src/osmo-bts-litecell15/l1_if.c
+++ b/src/osmo-bts-litecell15/l1_if.c
@@ -934,8 +934,8 @@
chan_nr = chan_nr_by_sapi(>ts[data_ind->u8Tn], data_ind->sapi,
data_ind->subCh, data_ind->u8Tn, data_ind->u32Fn);
if (!chan_nr) {
-   LOGP(DL1C, LOGL_ERROR, "PH-DATA-INDICATION for unknown sapi "
-   "%d\n", data_ind->sapi);
+   LOGP(DL1C, LOGL_ERROR, "PH-DATA-INDICATION for unknown sapi %s 
(%d)\n",
+get_value_string(lc15bts_l1sapi_names, data_ind->sapi), 
data_ind->sapi);
msgb_free(l1p_msg);
return ENOTSUP;
}
diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c
index a4bfffb..781900e 100644
--- a/src/osmo-bts-sysmo/l1_if.c
+++ b/src/osmo-bts-sysmo/l1_if.c
@@ -929,8 +929,8 @@
chan_nr = chan_nr_by_sapi(>ts[data_ind->u8Tn], data_ind->sapi,
data_ind->subCh, data_ind->u8Tn, data_ind->u32Fn);
if (!chan_nr) {
-   LOGP(DL1C, LOGL_ERROR, "PH-DATA-INDICATION for unknown sapi "
-   "%d\n", data_ind->sapi);
+   LOGP(DL1C, LOGL_ERROR, "PH-DATA-INDICATION for unknown sapi %s 
(%d)\n",
+get_value_string(femtobts_l1sapi_names, data_ind->sapi), 
data_ind->sapi);
msgb_free(l1p_msg);
return ENOTSUP;
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I007e5f0ce9709026331817e55148749e21d8b015
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder