[PATCH] osmo-iuh[master]: add /debian package support

2017-08-12 Thread lynxis lazus
Hello Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/3506

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

add /debian package support

Change-Id: I985805aea0e48fe70619de8b81206098e4e37613
---
A debian/changelog
A debian/compat
A debian/control
A debian/copyright
A debian/libosmo-ranap-dev.install
A debian/libosmo-ranap0.install
A debian/osmo-hnbgw.install
A debian/rules
A debian/source/format
9 files changed, 139 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/06/3506/2

diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 000..91bd155
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+osmo-iuh (0.1.0) UNRELEASED; urgency=low
+
+  * Initial release.
+
+ -- Alexander Couzens   Tue, 08 Aug 2017 04:13:19 +
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 000..ec63514
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+9
diff --git a/debian/control b/debian/control
new file mode 100644
index 000..56a7667
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,60 @@
+Source: osmo-iuh
+Section: libs
+Priority: extra
+Maintainer: Alexander Couzens 
+Build-Depends: debhelper (>=9),
+   dh-autoreconf,
+   pkg-config,
+   autoconf,
+   automake,
+   libtool,
+   git,
+   libasn1c-dev,
+   libsctp-dev,
+   libosmo-netif-dev,
+   libosmocore-dev,
+   libosmo-netif-dev,
+   libosmo-sccp-dev,
+   python (>= 2.7)
+Standards-Version: 3.9.8
+Vcs-Git: git://git.osmocom.org/osmo-iuh.git
+Vcs-Browser: https://git.osmocom.org/osmo-iuh/
+Homepage: https://projects.osmocom.org/projects/osmohnbgw
+
+Package: osmo-hnbgw
+Section: net
+Architecture: any
+Multi-Arch: no
+Pre-Depends: ${misc:Pre-Depends}
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Description: osmocom Home Node B Gateway
+
+Package: osmo-hnbgw-dbg
+Section: debug
+Architecture: any
+Multi-Arch: no
+Pre-Depends: ${misc:Pre-Depends}
+Depends: osmo-hnbgw (= ${binary:Version}), ${misc:Depends}
+Description: osmocom Home Node B Gateway
+
+Package: libosmo-ranap0
+Section: libs
+Architecture: any
+Multi-Arch: same
+Pre-Depends: ${misc:Pre-Depends}
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Description: Osmocom code for the Iuh interface (HNBAP, RUA, RANAP)
+
+Package: libosmo-ranap-dbg
+Section: debug
+Architecture: any
+Multi-Arch: same
+Depends: libosmo-ranap0 (= ${binary:Version}), ${misc:Depends}
+Description: Osmocom code for the Iuh interface (HNBAP, RUA, RANAP)
+
+Package: libosmo-ranap-dev
+Section: libdevel
+Architecture: any
+Multi-Arch: same
+Depends: libosmo-ranap0 (= ${binary:Version}), ${misc:Depends}
+Description: Osmocom code for the Iuh interface (HNBAP, RUA, RANAP)
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 000..5cb4a3a
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,48 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: osmo-iuh
+Source: git://git.osmocom.org/
+
+Files: *
+Copyright: 2015 Daniel Willmann 
+   2015 Harald Welte 
+   2015-2017 sysmocom s.f.m.c. GmbH 
+License:   AGPL-3.0+
+ 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 .
+
+Files: asn1/rua/eurecom/rua_decoder.c
+   asn1/rua/eurecom/rua_encoder.c
+   asn1/rua/eurecom/rua_ies_defs.h
+Copyright: 1999-2012 Eurecom
+License:   GPL-2.0
+ This program is free software; you can redistribute it and/or modify it
+ under the terms and conditions of the GNU General Public License,
+ version 2, as published by the Free Software Foundation.
+ .
+ This program is distributed in the hope it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ more details.
+ .
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ .
+ The full GNU General Public License is included in this distribution in
+ the file called 

osmo-iuh[master]: add /debian package support

2017-08-12 Thread Neels Hofmeyr

Patch Set 1: Code-Review-1

(2 comments)

https://gerrit.osmocom.org/#/c/3506/1/debian/copyright
File debian/copyright:

Line 11:2016-2017 sysmocom s.f.m.c. GmbH 
interesting list of copyrights :)


https://gerrit.osmocom.org/#/c/3506/1/debian/rules
File debian/rules:

Line 9: dh $@ --with autoreconf 
(whitespace?)


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I985805aea0e48fe70619de8b81206098e4e37613
Gerrit-PatchSet: 1
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: lynxis lazus 
Gerrit-HasComments: Yes


[PATCH] osmo-iuh[master]: add /debian package support

2017-08-12 Thread Neels Hofmeyr

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

add /debian package support

Change-Id: I985805aea0e48fe70619de8b81206098e4e37613
---
A debian/changelog
A debian/compat
A debian/control
A debian/copyright
A debian/libosmo-ranap-dev.install
A debian/libosmo-ranap0.install
A debian/osmo-hnbgw.install
A debian/rules
A debian/source/format
9 files changed, 142 insertions(+), 0 deletions(-)


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

diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 000..91bd155
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+osmo-iuh (0.1.0) UNRELEASED; urgency=low
+
+  * Initial release.
+
+ -- Alexander Couzens   Tue, 08 Aug 2017 04:13:19 +
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 000..ec63514
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+9
diff --git a/debian/control b/debian/control
new file mode 100644
index 000..56a7667
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,60 @@
+Source: osmo-iuh
+Section: libs
+Priority: extra
+Maintainer: Alexander Couzens 
+Build-Depends: debhelper (>=9),
+   dh-autoreconf,
+   pkg-config,
+   autoconf,
+   automake,
+   libtool,
+   git,
+   libasn1c-dev,
+   libsctp-dev,
+   libosmo-netif-dev,
+   libosmocore-dev,
+   libosmo-netif-dev,
+   libosmo-sccp-dev,
+   python (>= 2.7)
+Standards-Version: 3.9.8
+Vcs-Git: git://git.osmocom.org/osmo-iuh.git
+Vcs-Browser: https://git.osmocom.org/osmo-iuh/
+Homepage: https://projects.osmocom.org/projects/osmohnbgw
+
+Package: osmo-hnbgw
+Section: net
+Architecture: any
+Multi-Arch: no
+Pre-Depends: ${misc:Pre-Depends}
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Description: osmocom Home Node B Gateway
+
+Package: osmo-hnbgw-dbg
+Section: debug
+Architecture: any
+Multi-Arch: no
+Pre-Depends: ${misc:Pre-Depends}
+Depends: osmo-hnbgw (= ${binary:Version}), ${misc:Depends}
+Description: osmocom Home Node B Gateway
+
+Package: libosmo-ranap0
+Section: libs
+Architecture: any
+Multi-Arch: same
+Pre-Depends: ${misc:Pre-Depends}
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Description: Osmocom code for the Iuh interface (HNBAP, RUA, RANAP)
+
+Package: libosmo-ranap-dbg
+Section: debug
+Architecture: any
+Multi-Arch: same
+Depends: libosmo-ranap0 (= ${binary:Version}), ${misc:Depends}
+Description: Osmocom code for the Iuh interface (HNBAP, RUA, RANAP)
+
+Package: libosmo-ranap-dev
+Section: libdevel
+Architecture: any
+Multi-Arch: same
+Depends: libosmo-ranap0 (= ${binary:Version}), ${misc:Depends}
+Description: Osmocom code for the Iuh interface (HNBAP, RUA, RANAP)
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 000..601e3c5
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,51 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: osmo-iuh
+Source: git://git.osmocom.org/
+
+Files: *
+Copyright: 2015 Daniel Willmann 
+   2015 Harald Welte 
+   2015 Sysmocom s.f.m.c. GmbH
+   2015 sysmocom s.f.m.c GmbH
+   2016 sysmocom s.m.f.c. GmbH 
+   2016-2017 sysmocom s.f.m.c. GmbH 
+License:   AGPL-3.0+
+ 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 .
+
+Files: asn1/rua/eurecom/rua_decoder.c
+   asn1/rua/eurecom/rua_encoder.c
+   asn1/rua/eurecom/rua_ies_defs.h
+Copyright: 1999-2012 Eurecom
+License:   GPL-2.0
+ This program is free software; you can redistribute it and/or modify it
+ under the terms and conditions of the GNU General Public License,
+ version 2, as published by the Free Software Foundation.
+ .
+ This program is distributed in the hope it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ more details.
+ .
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ .
+ The full GNU General Public License is included in this distribution in
+ the 

[PATCH] osmo-iuh[master]: iu_client: derive local SCCP addr from sccp instance

2017-08-12 Thread Neels Hofmeyr

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

iu_client: derive local SCCP addr from sccp instance

ranap_iu_init() is passed an sccp instance that has a local primary point code.
Use this primary PC by default as the local address for IuCS and IuPS clients.

Remove the current vty command 'iu local-address point-code PC':
- It is possible that we would like to configure a differing local point code
  at some point; this should then happen via sccp address book entries, not
  parsing PC directly.
- Obtaining the local PC from the SCCP instance makes this command obsolete for
  all setups we're currently aiming at: one local PC per SCCP instance.
- There are vty doc failures in this vty command, which cause osmo-msc and
  osmo-bsc vty test failures; rather than fixing this, let's drop it entirely
  until we see a need for it (and then do it properly with the address book).

Cosmetic: prefix the local static variable with g_* like g_sccp and g_scu and
define it in the same place. No default values are needed anymore, it gets
overwritten in ranap_iu_init().

Change-Id: I3bb7fc1cd5261d214c6ba0cccfe95f637e6db087
---
M src/iu_client.c
M src/iu_client_vty.c
2 files changed, 3 insertions(+), 27 deletions(-)


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

diff --git a/src/iu_client.c b/src/iu_client.c
index 83ed276..17d955d 100644
--- a/src/iu_client.c
+++ b/src/iu_client.c
@@ -83,6 +83,7 @@
 
 static struct osmo_sccp_instance *g_sccp;
 static struct osmo_sccp_user *g_scu;
+static struct osmo_sccp_addr g_local_sccp_addr;
 
 const struct value_string ranap_iu_event_type_names[] = {
OSMO_VALUE_STRING(RANAP_IU_EVENT_RAB_ASSIGN),
@@ -584,13 +585,6 @@
  * Paging
  ***/
 
-struct osmo_sccp_addr local_sccp_addr = {
-   .presence = OSMO_SCCP_ADDR_T_SSN | OSMO_SCCP_ADDR_T_PC,
-   .ri = OSMO_SCCP_RI_SSN_PC,
-   .ssn = OSMO_SCCP_SSN_RANAP,
-   .pc = 1,
-};
-
 /* Send a paging command down a given SCCP User. tmsi and paging_cause are
  * optional and may be passed NULL and 0, respectively, to disable their use.
  * See enum RANAP_PagingCause.
@@ -604,7 +598,7 @@
struct msgb *msg;
msg = ranap_new_msg_paging_cmd(imsi, tmsi, is_ps? 1 : 0, paging_cause);
msg->l2h = msg->data;
-   osmo_sccp_tx_unitdata_msg(g_scu, _sccp_addr, called_addr, msg);
+   osmo_sccp_tx_unitdata_msg(g_scu, _local_sccp_addr, called_addr, msg);
return 0;
 }
 
@@ -776,6 +770,7 @@
global_iu_recv_cb = iu_recv_cb;
global_iu_event_cb = iu_event_cb;
g_sccp = sccp;
+   osmo_sccp_local_addr_by_instance(_local_sccp_addr, sccp, 
OSMO_SCCP_SSN_RANAP);
g_scu = osmo_sccp_user_bind(g_sccp, sccp_user_name, sccp_sap_up, 
OSMO_SCCP_SSN_RANAP);
 
return 0;
diff --git a/src/iu_client_vty.c b/src/iu_client_vty.c
index b809b2a..a99facd 100644
--- a/src/iu_client_vty.c
+++ b/src/iu_client_vty.c
@@ -75,21 +75,6 @@
return CMD_SUCCESS;
 }
 
-extern struct osmo_sccp_addr local_sccp_addr;
-
-DEFUN(cfg_iu_local_addr_pc, cfg_iu_local_addr_pc_cmd,
-   "iu local-address point-code PC",
-   IU_STR "Local SCCP Address\n")
-{
-   local_sccp_addr.presence = OSMO_SCCP_ADDR_T_PC | OSMO_SCCP_ADDR_T_SSN;
-   local_sccp_addr.ri = OSMO_SCCP_RI_SSN_PC;
-   local_sccp_addr.pc = osmo_ss7_pointcode_parse(NULL, argv[0]);
-
-   return CMD_SUCCESS;
-}
-
-/* TODO: GT address configuration, in line with 4.5.1.1.1 of TS 25.410 */
-
 int ranap_iu_vty_config_write(struct vty *vty, const char *indent)
 {
if (!g_rab_assign_addr_enc) {
@@ -113,9 +98,6 @@
return CMD_WARNING;
}
 
-   vty_out(vty, "%siu local-address point-code %s%s", indent,
-   osmo_ss7_pointcode_print(NULL, local_sccp_addr.pc), 
VTY_NEWLINE);
-
if (asn_debug)
vty_out(vty, "%sasn1 debug 1%s", indent, VTY_NEWLINE);
 
@@ -130,7 +112,6 @@
g_rab_assign_addr_enc = rab_assign_addr_enc;
 
install_element(iu_parent_node, _iu_rab_assign_addr_enc_cmd);
-   install_element(iu_parent_node, _iu_local_addr_pc_cmd);
 
/* Technically, these are global ASN.1 settings and not necessarily 
limited to the Iu interface.
 * Practically, only Iu users will use ASN.1 in Osmocom programs -- at 
least so far. So it is

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

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


openbsc[master]: libmsc: use smpp34_tlv_for_each() to avoid suboptimal TLV ha...

2017-08-12 Thread Harald Welte

Patch Set 3: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I53a65164a6cc4abc6bf57d9a8dc275cf21c90222
Gerrit-PatchSet: 3
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Pablo Neira Ayuso 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pablo Neira Ayuso 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


[MERGED] openbsc[master]: libmsc: use smpp34_tlv_for_each() to avoid suboptimal TLV ha...

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

Change subject: libmsc: use smpp34_tlv_for_each() to avoid suboptimal TLV 
handling
..


libmsc: use smpp34_tlv_for_each() to avoid suboptimal TLV handling

submit_to_sms() now handles two TLVs, so find_tlv() is suboptiomal and
it can be removed, since it would result in two passes on the TLV list.
Use new smpp34_tlv_for_each() helper to iterate over the list of TLVs
that is available since I446929feed049d0411e1629ca263e2bc41f714cc.

Change-Id: I53a65164a6cc4abc6bf57d9a8dc275cf21c90222
---
M openbsc/src/libmsc/smpp_openbsc.c
1 file changed, 41 insertions(+), 31 deletions(-)

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



diff --git a/openbsc/src/libmsc/smpp_openbsc.c 
b/openbsc/src/libmsc/smpp_openbsc.c
index 85de040..7e23abd 100644
--- a/openbsc/src/libmsc/smpp_openbsc.c
+++ b/openbsc/src/libmsc/smpp_openbsc.c
@@ -72,26 +72,31 @@
return subscr;
 }
 
-/*! \brief find a TLV with given tag in list of libsmpp34 TLVs */
-static struct tlv_t *find_tlv(struct tlv_t *head, uint16_t tag)
+static int smpp34_submit_tlv_msg_payload(const struct tlv_t *t,
+const struct submit_sm_t *submit,
+const uint8_t **sms_msg,
+unsigned int *sms_msg_len)
 {
-   struct tlv_t *t;
-
-   for (t = head; t != NULL; t = t->next) {
-   if (t->tag == tag)
-   return t;
+   if (submit->sm_length) {
+   LOGP(DLSMS, LOGL_ERROR,
+"SMPP cannot have payload in TLV _and_ in the header\n");
+   return -1;
}
-   return NULL;
+   *sms_msg = t->value.octet;
+   *sms_msg_len = t->length;
+
+   return 0;
 }
 
 /*! \brief convert from submit_sm_t to gsm_sms */
 static int submit_to_sms(struct gsm_sms **psms, struct gsm_network *net,
 const struct submit_sm_t *submit)
 {
+   const uint8_t *sms_msg = NULL;
struct gsm_subscriber *dest;
+   uint16_t msg_ref = 0;
struct gsm_sms *sms;
struct tlv_t *t;
-   const uint8_t *sms_msg;
unsigned int sms_msg_len;
int mode;
 
@@ -105,31 +110,40 @@
return ESME_RINVDSTADR;
}
 
-   t = find_tlv(submit->tlv, TLVID_message_payload);
-   if (t) {
-   if (submit->sm_length) {
-   /* ERROR: we cannot have both! */
-   LOGP(DLSMS, LOGL_ERROR, "SMPP Cannot have payload in "
-   "TLV _and_ in the header\n");
-   subscr_put(dest);
-   return ESME_ROPTPARNOTALLWD;
+   smpp34_tlv_for_each(t, submit->tlv) {
+   switch (t->tag) {
+   case TLVID_message_payload:
+   if (smpp34_submit_tlv_msg_payload(t, submit, _msg,
+ _msg_len) < 0) {
+   subscr_put(dest);
+   return ESME_ROPTPARNOTALLWD;
+   }
+   break;
+   case TLVID_user_message_reference:
+   msg_ref = ntohs(t->value.val16);
+   break;
+   default:
+   break;
}
-   sms_msg = t->value.octet;
-   sms_msg_len = t->length;
-   } else if (submit->sm_length > 0 && submit->sm_length < 255) {
-   sms_msg = submit->short_message;
-   sms_msg_len = submit->sm_length;
-   } else {
-   LOGP(DLSMS, LOGL_ERROR,
-   "SMPP neither message payload nor valid sm_length.\n");
-   subscr_put(dest);
-   return ESME_RINVPARLEN;
+   }
+
+   if (!sms_msg) {
+   if (submit->sm_length > 0 && submit->sm_length < 255) {
+   sms_msg = submit->short_message;
+   sms_msg_len = submit->sm_length;
+   } else {
+   LOGP(DLSMS, LOGL_ERROR,
+"SMPP neither message payload nor valid 
sm_length.\n");
+   subscr_put(dest);
+   return ESME_RINVPARLEN;
+   }
}
 
sms = sms_alloc();
sms->source = SMS_SOURCE_SMPP;
sms->smpp.sequence_nr = submit->sequence_number;
sms->status_rep_req = submit->registered_delivery;
+   sms->msg_ref = msg_ref;
 
/* fill in the destination address */
sms->receiver = dest;
@@ -203,10 +217,6 @@
memcpy(sms->user_data, sms_msg, sms_msg_len);
sms->user_data_len = sms_msg_len;
}
-
-   t = find_tlv(submit->tlv, TLVID_user_message_reference);
-   if (t)
-   sms->msg_ref = 

[MERGED] libosmocore[master]: add osmo_fd_setup() convenience function to fill-in osmo_fd

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

Change subject: add osmo_fd_setup() convenience function to fill-in osmo_fd
..


add osmo_fd_setup() convenience function to fill-in osmo_fd

This basically follows the concept of osmo_timer_setup() and allows
the caller to fill-in all configurable fields of osmo_fd in one
line of code, rather than open-coding it in 5 lines everywhere.

Change-Id: I6dbf19ea22fd65302bfc5424c10418d1b7939094
---
M include/osmocom/core/select.h
M src/select.c
2 files changed, 22 insertions(+), 0 deletions(-)

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



diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h
index 2abda2d..b6fed3c 100644
--- a/include/osmocom/core/select.h
+++ b/include/osmocom/core/select.h
@@ -36,6 +36,10 @@
unsigned int priv_nr;
 };
 
+void osmo_fd_setup(struct osmo_fd *ofd, int fd, unsigned int when,
+  int (*cb)(struct osmo_fd *fd, unsigned int what),
+  void *data, unsigned int priv_nr);
+
 bool osmo_fd_is_registered(struct osmo_fd *fd);
 int osmo_fd_register(struct osmo_fd *fd);
 void osmo_fd_unregister(struct osmo_fd *fd);
diff --git a/src/select.c b/src/select.c
index 0ba8bc6..4b98b62 100644
--- a/src/select.c
+++ b/src/select.c
@@ -47,6 +47,24 @@
 static LLIST_HEAD(osmo_fds);
 static int unregistered_count;
 
+/*! Set up an osmo-fd. Will not register it.
+ *  \param[inout] ofd Osmo FD to be set-up
+ *  \param[in] fd OS-level file descriptor number
+ *  \param[in] when bit-mask of BSC_FD_{READ,WRITE,EXECEPT}
+ *  \param[in] cb Call-back function to be called
+ *  \param[in] data Private context pointer
+ *  \param[in] priv_nr Private number
+ */
+void osmo_fd_setup(struct osmo_fd *ofd, int fd, unsigned int when,
+  int (*cb)(struct osmo_fd *fd, unsigned int what),
+  void *data, unsigned int priv_nr)
+{
+   ofd->fd = fd;
+   ofd->when = when;
+   ofd->cb = cb;
+   ofd->data = data;
+   ofd->priv_nr = priv_nr;
+}
 
 /*! Check if a file descriptor is already registered
  *  \param[in] fd osmocom file descriptor to be checked

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

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


[MERGED] libsmpp34[master]: add esm_class definitions

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

Change subject: add esm_class definitions
..


add esm_class definitions

Add special message attributes definitions that are associated with the
short message. Thus, we can get rid of magic numbers in our codebase.

Change-Id: I91afd8b462b8fd3b2c4c5b54f4eeb7ec5b730b65
---
M src/smpp34.h
1 file changed, 8 insertions(+), 0 deletions(-)

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



diff --git a/src/smpp34.h b/src/smpp34.h
index 5fb6395..9d51a4a 100644
--- a/src/smpp34.h
+++ b/src/smpp34.h
@@ -204,4 +204,12 @@
 #define TLVID_its_reply_type  0x1380 /* CDMA */
 #define TLVID_its_session_info0x1383 /* CDMA */
 
+/* As defined by SMPP 3.4, Sect. 5.2.12 Parameter Definition esm_class. */
+#define SMPP34_DATAGRAM_MODE   0x01
+#define SMPP34_MSG_MODE_MASK   0x03
+#define SMPP34_DELIVERY_RECEIPT0x04
+#define SMPP34_DELIVERY_ACK0x08
+#define SMPP34_UDHI_IND0x40
+#define SMPP34_REPLY_PATH  0x80
+
 #endif

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I91afd8b462b8fd3b2c4c5b54f4eeb7ec5b730b65
Gerrit-PatchSet: 2
Gerrit-Project: libsmpp34
Gerrit-Branch: master
Gerrit-Owner: Pablo Neira Ayuso 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pablo Neira Ayuso 


libsmpp34[master]: add esm_class definitions

2017-08-12 Thread Harald Welte

Patch Set 2: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I91afd8b462b8fd3b2c4c5b54f4eeb7ec5b730b65
Gerrit-PatchSet: 2
Gerrit-Project: libsmpp34
Gerrit-Branch: master
Gerrit-Owner: Pablo Neira Ayuso 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pablo Neira Ayuso 
Gerrit-HasComments: No


libosmocore[master]: add osmo_fd_setup() convenience function to fill-in osmo_fd

2017-08-12 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


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

2017-08-12 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ia3184877f9709db65f5f93a98403f2ef5b04a8ca
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-HasComments: No


[MERGED] openggsn[master]: libgtp: Delete PDP context on receiving GTPv1 Error Indication

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

Change subject: libgtp: Delete PDP context on receiving GTPv1 Error Indication
..


libgtp: Delete PDP context on receiving GTPv1 Error Indication

When a peer GSN receives a GPDU for an unknown PDP context, it sends
a GTP Error Indication.  This Error Indication should be used to
delete the offending PDP context locally.

In GTPv1, the Error Indication contains some mandatory IEs using
which we can look up the PDP context and delete it.

The existing code only dealt with GTPv0 Error Indications which lack
those IEs and use the TEI in the header instead.

Change-Id: I3e843f9ef1d6fd7868cc992e083c0891d16b6da9
Closes: OS#2426
---
M gtp/gtp.c
M gtp/pdp.c
M gtp/pdp.h
3 files changed, 53 insertions(+), 6 deletions(-)

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



diff --git a/gtp/gtp.c b/gtp/gtp.c
index a4e8e2b..012aa79 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -2581,17 +2581,44 @@
 int gtp_error_ind_conf(struct gsn_t *gsn, int version,
   struct sockaddr_in *peer, void *pack, unsigned len)
 {
+   union gtpie_member *ie[GTPIE_SIZE];
struct pdp_t *pdp;
 
/* Find the context in question */
-   if (pdp_tidget(, be64toh(((union gtp_packet *)pack)->gtp0.h.tid))) {
-   gsn->err_unknownpdp++;
-   GTP_LOGPKG(LOGL_ERROR, peer, pack, len,
-   "Unknown PDP context\n");
-   return EOF;
+   if (version == 0) {
+   if (pdp_tidget(, be64toh(((union gtp_packet 
*)pack)->gtp0.h.tid))) {
+   gsn->err_unknownpdp++;
+   GTP_LOGPKG(LOGL_ERROR, peer, pack, len,
+   "Unknown PDP context\n");
+   return EOF;
+   }
+   } else if (version == 1) {
+   /* we have to look-up based on the *peer* TEID */
+   int hlen = get_hlen(pack);
+   uint32_t teid_gn;
+
+   /* Decode information elements */
+   if (gtpie_decaps(ie, version, pack + hlen, len - hlen)) {
+   gsn->invalid++;
+   GTP_LOGPKG(LOGL_ERROR, peer, pack, len,
+   "Invalid message format\n");
+   return EOF;
+   }
+
+   if (gtpie_gettv4(ie, GTPIE_TEI_DI, 0, _gn)) {
+   gsn->missing++;
+   GTP_LOGPKG(LOGL_ERROR, peer, pack, len,
+   "Missing mandatory information field\n");
+   return EOF;
+   }
+
+   if (pdp_getgtp1_peer_d(, peer, teid_gn)) {
+   gsn->err_unknownpdp++;
+   GTP_LOGPKG(LOGL_ERROR, peer, pack, len, "Unknown PDP 
context\n");
+   return EOF;
+   }
}
 
-   gsn->err_unknownpdp++;  /* TODO: Change counter */
GTP_LOGPKG(LOGL_ERROR, peer, pack, len,
"Received Error Indication\n");
 
diff --git a/gtp/pdp.c b/gtp/pdp.c
index f297af9..c576a4e 100644
--- a/gtp/pdp.c
+++ b/gtp/pdp.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include "pdp.h"
+#include "gtp.h"
 #include "lookupa.h"
 
 /* ***
@@ -202,6 +203,24 @@
}
 }
 
+/* get a PDP based on the *peer* address + TEI-Data.  Used for matching 
inbound Error Ind */
+int pdp_getgtp1_peer_d(struct pdp_t **pdp, const struct sockaddr_in *peer, 
uint32_t teid_gn)
+{
+   unsigned int i;
+
+   /* this is O(n) but we don't have (nor want) another hash... */
+   for (i = 0; i < PDP_MAX; i++) {
+   struct pdp_t *candidate = [i];
+   if (candidate->inuse && candidate->teid_gn == teid_gn &&
+   candidate->gsnru.l == sizeof(peer->sin_addr) &&
+   !memcmp(>sin_addr, candidate->gsnru.v, 
sizeof(peer->sin_addr))) {
+   *pdp = [i];
+   return 0;
+   }
+   }
+   return EOF;
+}
+
 int pdp_tidhash(uint64_t tid)
 {
return (lookup(, sizeof(tid), 0) % PDP_MAX);
diff --git a/gtp/pdp.h b/gtp/pdp.h
index 217b1d6..432f1df 100644
--- a/gtp/pdp.h
+++ b/gtp/pdp.h
@@ -232,6 +232,7 @@
 
 int pdp_getgtp0(struct pdp_t **pdp, uint16_t fl);
 int pdp_getgtp1(struct pdp_t **pdp, uint32_t tei);
+int pdp_getgtp1_peer_d(struct pdp_t **pdp, const struct sockaddr_in *peer, 
uint32_t teid_gn);
 
 int pdp_getimsi(struct pdp_t **pdp, uint64_t imsi, uint8_t nsapi);
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3e843f9ef1d6fd7868cc992e083c0891d16b6da9
Gerrit-PatchSet: 1
Gerrit-Project: openggsn
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald 

[PATCH] openbsc[master]: Migrate from gprs_apn_to_str() to libosmocore osmo_apn_to_str()

2017-08-12 Thread Harald Welte

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

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 openbsc/include/openbsc/gprs_utils.h
M openbsc/src/gprs/gb_proxy_patch.c
M openbsc/src/gprs/gb_proxy_vty.c
M openbsc/src/gprs/gprs_sgsn.c
M openbsc/src/gprs/gprs_subscriber.c
M openbsc/src/gprs/gprs_utils.c
M openbsc/src/gprs/gtphub.c
M openbsc/src/gprs/sgsn_cdr.c
M openbsc/src/gprs/sgsn_vty.c
9 files changed, 17 insertions(+), 52 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/04/3504/1

diff --git a/openbsc/include/openbsc/gprs_utils.h 
b/openbsc/include/openbsc/gprs_utils.h
index 603605c..574f5c5 100644
--- a/openbsc/include/openbsc/gprs_utils.h
+++ b/openbsc/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/openbsc/src/gprs/gb_proxy_patch.c 
b/openbsc/src/gprs/gb_proxy_patch.c
index 7bddc44..210fb2b 100644
--- a/openbsc/src/gprs/gb_proxy_patch.c
+++ b/openbsc/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/openbsc/src/gprs/gb_proxy_vty.c b/openbsc/src/gprs/gb_proxy_vty.c
index 933b6b0..86d65a8 100644
--- a/openbsc/src/gprs/gb_proxy_vty.c
+++ b/openbsc/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/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c
index 3c363bc..acaf781 100644
--- a/openbsc/src/gprs/gprs_sgsn.c
+++ b/openbsc/src/gprs/gprs_sgsn.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -757,7 +758,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/openbsc/src/gprs/gprs_subscriber.c 
b/openbsc/src/gprs/gprs_subscriber.c
index c90ba70..d13bd83 100644
--- a/openbsc/src/gprs/gprs_subscriber.c
+++ b/openbsc/src/gprs/gprs_subscriber.c
@@ -22,6 +22,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -370,7 +371,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/openbsc/src/gprs/gprs_utils.c b/openbsc/src/gprs/gprs_utils.c
index 64ed978..91a09d2 100644
--- a/openbsc/src/gprs/gprs_utils.c
+++ b/openbsc/src/gprs/gprs_utils.c
@@ -114,34 +114,6 @@
return 0;
 }
 
-/* TODO: 

openggsn[master]: libgtp: Delete PDP context on receiving GTPv1 Error Indication

2017-08-12 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


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

2017-08-12 Thread Harald Welte

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

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


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/05/3505/1

diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c
index b5d2eae..d4447e1 100644
--- a/openbsc/src/gprs/sgsn_vty.c
+++ b/openbsc/src/gprs/sgsn_vty.c
@@ -445,20 +445,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/3505
To unsubscribe, visit https://gerrit.osmocom.org/settings

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


[PATCH] openggsn[master]: libgtp: Delete PDP context on receiving GTPv1 Error Indication

2017-08-12 Thread Harald Welte

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

libgtp: Delete PDP context on receiving GTPv1 Error Indication

When a peer GSN receives a GPDU for an unknown PDP context, it sends
a GTP Error Indication.  This Error Indication should be used to
delete the offending PDP context locally.

In GTPv1, the Error Indication contains some mandatory IEs using
which we can look up the PDP context and delete it.

The existing code only dealt with GTPv0 Error Indications which lack
those IEs and use the TEI in the header instead.

Change-Id: I3e843f9ef1d6fd7868cc992e083c0891d16b6da9
Closes: OS#2426
---
M gtp/gtp.c
M gtp/pdp.c
M gtp/pdp.h
3 files changed, 53 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/03/3503/1

diff --git a/gtp/gtp.c b/gtp/gtp.c
index a4e8e2b..012aa79 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -2581,17 +2581,44 @@
 int gtp_error_ind_conf(struct gsn_t *gsn, int version,
   struct sockaddr_in *peer, void *pack, unsigned len)
 {
+   union gtpie_member *ie[GTPIE_SIZE];
struct pdp_t *pdp;
 
/* Find the context in question */
-   if (pdp_tidget(, be64toh(((union gtp_packet *)pack)->gtp0.h.tid))) {
-   gsn->err_unknownpdp++;
-   GTP_LOGPKG(LOGL_ERROR, peer, pack, len,
-   "Unknown PDP context\n");
-   return EOF;
+   if (version == 0) {
+   if (pdp_tidget(, be64toh(((union gtp_packet 
*)pack)->gtp0.h.tid))) {
+   gsn->err_unknownpdp++;
+   GTP_LOGPKG(LOGL_ERROR, peer, pack, len,
+   "Unknown PDP context\n");
+   return EOF;
+   }
+   } else if (version == 1) {
+   /* we have to look-up based on the *peer* TEID */
+   int hlen = get_hlen(pack);
+   uint32_t teid_gn;
+
+   /* Decode information elements */
+   if (gtpie_decaps(ie, version, pack + hlen, len - hlen)) {
+   gsn->invalid++;
+   GTP_LOGPKG(LOGL_ERROR, peer, pack, len,
+   "Invalid message format\n");
+   return EOF;
+   }
+
+   if (gtpie_gettv4(ie, GTPIE_TEI_DI, 0, _gn)) {
+   gsn->missing++;
+   GTP_LOGPKG(LOGL_ERROR, peer, pack, len,
+   "Missing mandatory information field\n");
+   return EOF;
+   }
+
+   if (pdp_getgtp1_peer_d(, peer, teid_gn)) {
+   gsn->err_unknownpdp++;
+   GTP_LOGPKG(LOGL_ERROR, peer, pack, len, "Unknown PDP 
context\n");
+   return EOF;
+   }
}
 
-   gsn->err_unknownpdp++;  /* TODO: Change counter */
GTP_LOGPKG(LOGL_ERROR, peer, pack, len,
"Received Error Indication\n");
 
diff --git a/gtp/pdp.c b/gtp/pdp.c
index f297af9..c576a4e 100644
--- a/gtp/pdp.c
+++ b/gtp/pdp.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include "pdp.h"
+#include "gtp.h"
 #include "lookupa.h"
 
 /* ***
@@ -202,6 +203,24 @@
}
 }
 
+/* get a PDP based on the *peer* address + TEI-Data.  Used for matching 
inbound Error Ind */
+int pdp_getgtp1_peer_d(struct pdp_t **pdp, const struct sockaddr_in *peer, 
uint32_t teid_gn)
+{
+   unsigned int i;
+
+   /* this is O(n) but we don't have (nor want) another hash... */
+   for (i = 0; i < PDP_MAX; i++) {
+   struct pdp_t *candidate = [i];
+   if (candidate->inuse && candidate->teid_gn == teid_gn &&
+   candidate->gsnru.l == sizeof(peer->sin_addr) &&
+   !memcmp(>sin_addr, candidate->gsnru.v, 
sizeof(peer->sin_addr))) {
+   *pdp = [i];
+   return 0;
+   }
+   }
+   return EOF;
+}
+
 int pdp_tidhash(uint64_t tid)
 {
return (lookup(, sizeof(tid), 0) % PDP_MAX);
diff --git a/gtp/pdp.h b/gtp/pdp.h
index 217b1d6..432f1df 100644
--- a/gtp/pdp.h
+++ b/gtp/pdp.h
@@ -232,6 +232,7 @@
 
 int pdp_getgtp0(struct pdp_t **pdp, uint16_t fl);
 int pdp_getgtp1(struct pdp_t **pdp, uint32_t tei);
+int pdp_getgtp1_peer_d(struct pdp_t **pdp, const struct sockaddr_in *peer, 
uint32_t teid_gn);
 
 int pdp_getimsi(struct pdp_t **pdp, uint64_t imsi, uint8_t nsapi);
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3e843f9ef1d6fd7868cc992e083c0891d16b6da9
Gerrit-PatchSet: 1
Gerrit-Project: openggsn
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[MERGED] openggsn[master]: libgtp: Add missing mandatory IEs in GTP Error Indication

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

Change subject: libgtp: Add missing mandatory IEs in GTP Error Indication
..


libgtp: Add missing mandatory IEs in GTP Error Indication

Change-Id: Iadd1fe3de7c476576a4409f22f5e84e9eade6b6e
---
M gtp/gtp.c
1 file changed, 11 insertions(+), 1 deletion(-)

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



diff --git a/gtp/gtp.c b/gtp/gtp.c
index 4aa6eb1..a4e8e2b 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -2555,7 +2555,7 @@
return 0;
 }
 
-/* Send Error Indication (response to a GPDU message */
+/* Send Error Indication (response to a GPDU message) - 3GPP TS 29.060 7.3.7 */
 int gtp_error_ind_resp(struct gsn_t *gsn, int version,
   struct sockaddr_in *peer, int fd,
   void *pack, unsigned len)
@@ -2563,6 +2563,16 @@
union gtp_packet packet;
unsigned int length = get_default_gtp(version, GTP_ERROR, );
 
+   if (version == 1) {
+   /* Mandatory 7.7.13 TEI Data I */
+   gtpie_tv4(, , GTP_MAX, GTPIE_TEI_DI,
+ ntoh32(((union gtp_packet *)pack)->gtp1l.h.tei));
+
+   /* Mandatory 7.7.32 GSN Address */
+   gtpie_tlv(, , GTP_MAX, GTPIE_GSN_ADDR,
+ sizeof(gsn->gsnu), >gsnu);
+   }
+
return gtp_resp(version, gsn, NULL, , length, peer, fd,
get_seq(pack), get_tid(pack));
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iadd1fe3de7c476576a4409f22f5e84e9eade6b6e
Gerrit-PatchSet: 1
Gerrit-Project: openggsn
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


openggsn[master]: libgtp: Add missing mandatory IEs in GTP Error Indication

2017-08-12 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


openggsn[master]: Properly format IMSI before using it in trap

2017-08-12 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


[MERGED] openggsn[master]: Properly format IMSI before using it in trap

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

Change subject: Properly format IMSI before using it in trap
..


Properly format IMSI before using it in trap

For some reason Max' commits introducing the CTRL/trap interface
about one year ago didn't convert the IMSI to its actual textual
representation before usign it in the CTRL interface.

Let's clean that up by properly interpreting the IMSI.

Change-Id: I8b20d2e47a29de266d93a7ddd5e6877f7e346a63
---
M ggsn/ggsn.c
M gtp/gtp.c
M gtp/gtp.h
3 files changed, 30 insertions(+), 1 deletion(-)

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



diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 05a56ae..c6a6dac 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -146,7 +146,7 @@
 
const char *addrstr = in46a_ntop(>addr, addrbuf, 
sizeof(addrbuf));
 
-   snprintf(val, sizeof(val), "%" PRIu64 ",%s", pdp->imsi, addrstr);
+   snprintf(val, sizeof(val), "%s,%s", imsi_gtp2str(>imsi), addrstr);
 
if (ctrl_cmd_send_trap(gsn->ctrl, var, val) < 0) {
LOGP(DGGSN, LOGL_ERROR, "Failed to create and send TRAP for 
IMSI %" PRIu64 " [%s].\n", pdp->imsi, var);
diff --git a/gtp/gtp.c b/gtp/gtp.c
index 801664d..4aa6eb1 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -3244,3 +3244,31 @@
memcpy(gsna->v, src, gsna->l);
return 0;
 }
+
+/* TS 29.060 has yet again a different encoding for IMSIs than
+ * what we have in other places, so we cannot use the gsm48
+ * decoding functions.  Also, libgtp uses an uint64_t in
+ * _network byte order_ to contain BCD digits ?!? */
+const char *imsi_gtp2str(const uint64_t *imsi)
+{
+   static char buf[sizeof(*imsi)+1];
+   const uint8_t *imsi8 = (const uint8_t *) imsi;
+   unsigned int i, j = 0;
+
+   for (i = 0; i < sizeof(*imsi); i++) {
+   uint8_t nibble;
+
+   nibble = imsi8[i] & 0xf;
+   if (nibble == 0xf)
+   break;
+   buf[j++] = osmo_bcd2char(nibble);
+
+   nibble = imsi8[i] >> 4;
+   if (nibble == 0xf)
+   break;
+   buf[j++] = osmo_bcd2char(nibble);
+   }
+
+   buf[j++] = '\0';
+   return buf;
+}
diff --git a/gtp/gtp.h b/gtp/gtp.h
index fd138cc..8f13ed2 100644
--- a/gtp/gtp.h
+++ b/gtp/gtp.h
@@ -402,5 +402,6 @@
 extern int eua2ipv4(struct in_addr *dst, struct ul66_t *eua);
 extern int gsna2in_addr(struct in_addr *dst, struct ul16_t *gsna);
 extern int in_addr2gsna(struct ul16_t *gsna, struct in_addr *src);
+extern const char *imsi_gtp2str(const uint64_t *imsi);
 
 #endif /* !_GTP_H */

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

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


[PATCH] openggsn[master]: libgtp: Add missing mandatory IEs in GTP Error Indication

2017-08-12 Thread Harald Welte

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

libgtp: Add missing mandatory IEs in GTP Error Indication

Change-Id: Iadd1fe3de7c476576a4409f22f5e84e9eade6b6e
---
M gtp/gtp.c
1 file changed, 11 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/02/3502/1

diff --git a/gtp/gtp.c b/gtp/gtp.c
index 4aa6eb1..a4e8e2b 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -2555,7 +2555,7 @@
return 0;
 }
 
-/* Send Error Indication (response to a GPDU message */
+/* Send Error Indication (response to a GPDU message) - 3GPP TS 29.060 7.3.7 */
 int gtp_error_ind_resp(struct gsn_t *gsn, int version,
   struct sockaddr_in *peer, int fd,
   void *pack, unsigned len)
@@ -2563,6 +2563,16 @@
union gtp_packet packet;
unsigned int length = get_default_gtp(version, GTP_ERROR, );
 
+   if (version == 1) {
+   /* Mandatory 7.7.13 TEI Data I */
+   gtpie_tv4(, , GTP_MAX, GTPIE_TEI_DI,
+ ntoh32(((union gtp_packet *)pack)->gtp1l.h.tei));
+
+   /* Mandatory 7.7.32 GSN Address */
+   gtpie_tlv(, , GTP_MAX, GTPIE_GSN_ADDR,
+ sizeof(gsn->gsnu), >gsnu);
+   }
+
return gtp_resp(version, gsn, NULL, , length, peer, fd,
get_seq(pack), get_tid(pack));
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iadd1fe3de7c476576a4409f22f5e84e9eade6b6e
Gerrit-PatchSet: 1
Gerrit-Project: openggsn
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] openggsn[master]: Properly format IMSI before using it in trap

2017-08-12 Thread Harald Welte

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

Properly format IMSI before using it in trap

For some reason Max' commits introducing the CTRL/trap interface
about one year ago didn't convert the IMSI to its actual textual
representation before usign it in the CTRL interface.

Let's clean that up by properly interpreting the IMSI.

Change-Id: I8b20d2e47a29de266d93a7ddd5e6877f7e346a63
---
M ggsn/ggsn.c
M gtp/gtp.c
M gtp/gtp.h
3 files changed, 30 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/01/3501/1

diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 05a56ae..c6a6dac 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -146,7 +146,7 @@
 
const char *addrstr = in46a_ntop(>addr, addrbuf, 
sizeof(addrbuf));
 
-   snprintf(val, sizeof(val), "%" PRIu64 ",%s", pdp->imsi, addrstr);
+   snprintf(val, sizeof(val), "%s,%s", imsi_gtp2str(>imsi), addrstr);
 
if (ctrl_cmd_send_trap(gsn->ctrl, var, val) < 0) {
LOGP(DGGSN, LOGL_ERROR, "Failed to create and send TRAP for 
IMSI %" PRIu64 " [%s].\n", pdp->imsi, var);
diff --git a/gtp/gtp.c b/gtp/gtp.c
index 801664d..4aa6eb1 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -3244,3 +3244,31 @@
memcpy(gsna->v, src, gsna->l);
return 0;
 }
+
+/* TS 29.060 has yet again a different encoding for IMSIs than
+ * what we have in other places, so we cannot use the gsm48
+ * decoding functions.  Also, libgtp uses an uint64_t in
+ * _network byte order_ to contain BCD digits ?!? */
+const char *imsi_gtp2str(const uint64_t *imsi)
+{
+   static char buf[sizeof(*imsi)+1];
+   const uint8_t *imsi8 = (const uint8_t *) imsi;
+   unsigned int i, j = 0;
+
+   for (i = 0; i < sizeof(*imsi); i++) {
+   uint8_t nibble;
+
+   nibble = imsi8[i] & 0xf;
+   if (nibble == 0xf)
+   break;
+   buf[j++] = osmo_bcd2char(nibble);
+
+   nibble = imsi8[i] >> 4;
+   if (nibble == 0xf)
+   break;
+   buf[j++] = osmo_bcd2char(nibble);
+   }
+
+   buf[j++] = '\0';
+   return buf;
+}
diff --git a/gtp/gtp.h b/gtp/gtp.h
index fd138cc..8f13ed2 100644
--- a/gtp/gtp.h
+++ b/gtp/gtp.h
@@ -402,5 +402,6 @@
 extern int eua2ipv4(struct in_addr *dst, struct ul66_t *eua);
 extern int gsna2in_addr(struct in_addr *dst, struct ul16_t *gsna);
 extern int in_addr2gsna(struct ul16_t *gsna, struct in_addr *src);
+extern const char *imsi_gtp2str(const uint64_t *imsi);
 
 #endif /* !_GTP_H */

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8b20d2e47a29de266d93a7ddd5e6877f7e346a63
Gerrit-PatchSet: 1
Gerrit-Project: openggsn
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


Build failure of network:osmocom:nightly/openbsc in Debian_9.0/i586

2017-08-12 Thread OBS Notification
Visit 
https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openbsc/Debian_9.0/i586

Package network:osmocom:nightly/openbsc failed to build in Debian_9.0/i586

Check out the package for editing:
  osc checkout network:osmocom:nightly openbsc

Last lines of build log:
[  180s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  180s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  180s] make[3]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  180s] make[4]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  180s] make[4]: Nothing to be done for 'install-exec-am'.
[  180s]  /bin/mkdir -p 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/i386-linux-gnu/pkgconfig'
[  180s]  /usr/bin/install -c -m 644 openbsc.pc 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/i386-linux-gnu/pkgconfig'
[  180s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  180s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  180s] make[2]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  180s] make[1]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  180s]dh_install -O--sourcedirectory=openbsc
[  180s] dh_install: Cannot find (any matches for) "/usr/bin/osmo-sgsn" (tried 
in "." and "debian/tmp")
[  180s] dh_install: osmocom-sgsn missing files: /usr/bin/osmo-sgsn
[  180s] dh_install: Cannot find (any matches for) "/usr/bin/osmo-gtphub" 
(tried in "." and "debian/tmp")
[  180s] dh_install: osmo-gtphub missing files: /usr/bin/osmo-gtphub
[  180s] dh_install: missing files, aborting
[  180s] debian/rules:13: recipe for target 'binary' failed
[  180s] make: *** [binary] Error 2
[  180s] dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit 
status 2
[  180s] 
[  180s] lamb21 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:05:49 UTC 2017.
[  180s] 
[  180s] ### VM INTERACTION START ###
[  183s] [  171.033914] reboot: Power down
[  183s] ### VM INTERACTION END ###
[  183s] 
[  183s] lamb21 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:05:52 UTC 2017.
[  183s] 

-- 
Configure notifications at https://build.opensuse.org/user/notifications
openSUSE Build Service (https://build.opensuse.org/)


Build failure of network:osmocom:nightly/openbsc in Debian_9.0/x86_64

2017-08-12 Thread OBS Notification
Visit 
https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openbsc/Debian_9.0/x86_64

Package network:osmocom:nightly/openbsc failed to build in Debian_9.0/x86_64

Check out the package for editing:
  osc checkout network:osmocom:nightly openbsc

Last lines of build log:
[  206s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  206s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  206s] make[3]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  206s] make[4]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  206s] make[4]: Nothing to be done for 'install-exec-am'.
[  206s]  /bin/mkdir -p 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/x86_64-linux-gnu/pkgconfig'
[  206s]  /usr/bin/install -c -m 644 openbsc.pc 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/x86_64-linux-gnu/pkgconfig'
[  206s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  206s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  206s] make[2]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  206s] make[1]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  206s]dh_install -O--sourcedirectory=openbsc
[  206s] dh_install: Cannot find (any matches for) "/usr/bin/osmo-sgsn" (tried 
in "." and "debian/tmp")
[  206s] dh_install: osmocom-sgsn missing files: /usr/bin/osmo-sgsn
[  206s] dh_install: Cannot find (any matches for) "/usr/bin/osmo-gtphub" 
(tried in "." and "debian/tmp")
[  206s] dh_install: osmo-gtphub missing files: /usr/bin/osmo-gtphub
[  206s] dh_install: missing files, aborting
[  206s] debian/rules:13: recipe for target 'binary' failed
[  206s] make: *** [binary] Error 2
[  206s] dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit 
status 2
[  206s] 
[  206s] cloud120 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:05:37 UTC 2017.
[  206s] 
[  206s] ### VM INTERACTION START ###
[  210s] [  183.781802] reboot: Power down
[  214s] ### VM INTERACTION END ###
[  214s] 
[  214s] cloud120 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:05:44 UTC 2017.
[  214s] 

-- 
Configure notifications at https://build.opensuse.org/user/notifications
openSUSE Build Service (https://build.opensuse.org/)


Build failure of network:osmocom:nightly/openbsc in xUbuntu_16.04/x86_64

2017-08-12 Thread OBS Notification
Visit 
https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openbsc/xUbuntu_16.04/x86_64

Package network:osmocom:nightly/openbsc failed to build in xUbuntu_16.04/x86_64

Check out the package for editing:
  osc checkout network:osmocom:nightly openbsc

Last lines of build log:
[  167s] make[5]: Nothing to be done for 'install-data-am'.
[  167s] make[5]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  167s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  167s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  167s] make[3]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  167s] make[4]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  167s] make[4]: Nothing to be done for 'install-exec-am'.
[  167s]  /bin/mkdir -p 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/x86_64-linux-gnu/pkgconfig'
[  167s]  /usr/bin/install -c -m 644 openbsc.pc 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/x86_64-linux-gnu/pkgconfig'
[  167s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  167s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  167s] make[2]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  167s] make[1]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  167s]dh_install -O--sourcedirectory=openbsc
[  167s] dh_install: osmocom-sgsn missing files: /usr/bin/osmo-sgsn
[  167s] dh_install: osmo-gtphub missing files: /usr/bin/osmo-gtphub
[  167s] dh_install: missing files, aborting
[  167s] debian/rules:13: recipe for target 'binary' failed
[  167s] make: *** [binary] Error 2
[  167s] dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit 
status 2
[  167s] 
[  167s] lamb68 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:04:37 UTC 2017.
[  167s] 
[  167s] ### VM INTERACTION START ###
[  171s] [  160.677164] reboot: Power down
[  171s] ### VM INTERACTION END ###
[  171s] 
[  171s] lamb68 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:04:40 UTC 2017.
[  171s] 

-- 
Configure notifications at https://build.opensuse.org/user/notifications
openSUSE Build Service (https://build.opensuse.org/)


Build failure of network:osmocom:nightly/openbsc in xUbuntu_16.10/i586

2017-08-12 Thread OBS Notification
Visit 
https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openbsc/xUbuntu_16.10/i586

Package network:osmocom:nightly/openbsc failed to build in xUbuntu_16.10/i586

Check out the package for editing:
  osc checkout network:osmocom:nightly openbsc

Last lines of build log:
[  191s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  191s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  191s] make[3]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  191s] make[4]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  191s] make[4]: Nothing to be done for 'install-exec-am'.
[  191s]  /bin/mkdir -p 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/i386-linux-gnu/pkgconfig'
[  191s]  /usr/bin/install -c -m 644 openbsc.pc 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/i386-linux-gnu/pkgconfig'
[  191s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  191s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  191s] make[2]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  191s] make[1]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  191s]dh_install -O--sourcedirectory=openbsc
[  191s] dh_install: Cannot find (any matches for) "/usr/bin/osmo-sgsn" (tried 
in "." and "debian/tmp")
[  191s] dh_install: osmocom-sgsn missing files: /usr/bin/osmo-sgsn
[  191s] dh_install: Cannot find (any matches for) "/usr/bin/osmo-gtphub" 
(tried in "." and "debian/tmp")
[  191s] dh_install: osmo-gtphub missing files: /usr/bin/osmo-gtphub
[  191s] dh_install: missing files, aborting
[  191s] debian/rules:13: recipe for target 'binary' failed
[  191s] make: *** [binary] Error 2
[  191s] dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit 
status 2
[  191s] 
[  191s] cloud123 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:04:31 UTC 2017.
[  191s] 
[  191s] ### VM INTERACTION START ###
[  195s] [  173.897557] reboot: Power down
[  197s] ### VM INTERACTION END ###
[  197s] 
[  197s] cloud123 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:04:38 UTC 2017.
[  197s] 

-- 
Configure notifications at https://build.opensuse.org/user/notifications
openSUSE Build Service (https://build.opensuse.org/)


Build failure of network:osmocom:nightly/openbsc in xUbuntu_16.04/x86_64

2017-08-12 Thread OBS Notification
Visit 
https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openbsc/xUbuntu_16.04/x86_64

Package network:osmocom:nightly/openbsc failed to build in xUbuntu_16.04/x86_64

Check out the package for editing:
  osc checkout network:osmocom:nightly openbsc

Last lines of build log:
[  167s] make[5]: Nothing to be done for 'install-data-am'.
[  167s] make[5]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  167s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  167s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  167s] make[3]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  167s] make[4]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  167s] make[4]: Nothing to be done for 'install-exec-am'.
[  167s]  /bin/mkdir -p 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/x86_64-linux-gnu/pkgconfig'
[  167s]  /usr/bin/install -c -m 644 openbsc.pc 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/x86_64-linux-gnu/pkgconfig'
[  167s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  167s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  167s] make[2]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  167s] make[1]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  167s]dh_install -O--sourcedirectory=openbsc
[  167s] dh_install: osmocom-sgsn missing files: /usr/bin/osmo-sgsn
[  167s] dh_install: osmo-gtphub missing files: /usr/bin/osmo-gtphub
[  167s] dh_install: missing files, aborting
[  167s] debian/rules:13: recipe for target 'binary' failed
[  167s] make: *** [binary] Error 2
[  167s] dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit 
status 2
[  167s] 
[  167s] lamb68 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:04:37 UTC 2017.
[  167s] 
[  167s] ### VM INTERACTION START ###
[  171s] [  160.677164] reboot: Power down
[  171s] ### VM INTERACTION END ###
[  171s] 
[  171s] lamb68 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:04:40 UTC 2017.
[  171s] 

-- 
Configure notifications at https://build.opensuse.org/user/notifications
openSUSE Build Service (https://build.opensuse.org/)


Build failure of network:osmocom:nightly/openbsc in xUbuntu_16.10/x86_64

2017-08-12 Thread OBS Notification
Visit 
https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openbsc/xUbuntu_16.10/x86_64

Package network:osmocom:nightly/openbsc failed to build in xUbuntu_16.10/x86_64

Check out the package for editing:
  osc checkout network:osmocom:nightly openbsc

Last lines of build log:
[  147s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  147s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  147s] make[3]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  147s] make[4]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  147s] make[4]: Nothing to be done for 'install-exec-am'.
[  147s]  /bin/mkdir -p 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/x86_64-linux-gnu/pkgconfig'
[  147s]  /usr/bin/install -c -m 644 openbsc.pc 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/x86_64-linux-gnu/pkgconfig'
[  147s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  147s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  147s] make[2]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  147s] make[1]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  147s]dh_install -O--sourcedirectory=openbsc
[  147s] dh_install: Cannot find (any matches for) "/usr/bin/osmo-sgsn" (tried 
in "." and "debian/tmp")
[  147s] dh_install: osmocom-sgsn missing files: /usr/bin/osmo-sgsn
[  147s] dh_install: Cannot find (any matches for) "/usr/bin/osmo-gtphub" 
(tried in "." and "debian/tmp")
[  147s] dh_install: osmo-gtphub missing files: /usr/bin/osmo-gtphub
[  147s] dh_install: missing files, aborting
[  147s] debian/rules:13: recipe for target 'binary' failed
[  147s] make: *** [binary] Error 2
[  147s] dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit 
status 2
[  147s] 
[  147s] lamb09 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:04:11 UTC 2017.
[  147s] 
[  147s] ### VM INTERACTION START ###
[  151s] [  140.194938] reboot: Power down
[  151s] ### VM INTERACTION END ###
[  151s] 
[  151s] lamb09 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:04:15 UTC 2017.
[  151s] 

-- 
Configure notifications at https://build.opensuse.org/user/notifications
openSUSE Build Service (https://build.opensuse.org/)


Build failure of network:osmocom:nightly/openbsc in xUbuntu_16.10/x86_64

2017-08-12 Thread OBS Notification
Visit 
https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openbsc/xUbuntu_16.10/x86_64

Package network:osmocom:nightly/openbsc failed to build in xUbuntu_16.10/x86_64

Check out the package for editing:
  osc checkout network:osmocom:nightly openbsc

Last lines of build log:
[  147s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  147s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  147s] make[3]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  147s] make[4]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  147s] make[4]: Nothing to be done for 'install-exec-am'.
[  147s]  /bin/mkdir -p 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/x86_64-linux-gnu/pkgconfig'
[  147s]  /usr/bin/install -c -m 644 openbsc.pc 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/x86_64-linux-gnu/pkgconfig'
[  147s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  147s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  147s] make[2]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  147s] make[1]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  147s]dh_install -O--sourcedirectory=openbsc
[  147s] dh_install: Cannot find (any matches for) "/usr/bin/osmo-sgsn" (tried 
in "." and "debian/tmp")
[  147s] dh_install: osmocom-sgsn missing files: /usr/bin/osmo-sgsn
[  147s] dh_install: Cannot find (any matches for) "/usr/bin/osmo-gtphub" 
(tried in "." and "debian/tmp")
[  147s] dh_install: osmo-gtphub missing files: /usr/bin/osmo-gtphub
[  147s] dh_install: missing files, aborting
[  147s] debian/rules:13: recipe for target 'binary' failed
[  147s] make: *** [binary] Error 2
[  147s] dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit 
status 2
[  147s] 
[  147s] lamb09 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:04:11 UTC 2017.
[  147s] 
[  147s] ### VM INTERACTION START ###
[  151s] [  140.194938] reboot: Power down
[  151s] ### VM INTERACTION END ###
[  151s] 
[  151s] lamb09 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:04:15 UTC 2017.
[  151s] 

-- 
Configure notifications at https://build.opensuse.org/user/notifications
openSUSE Build Service (https://build.opensuse.org/)


Build failure of network:osmocom:nightly/openbsc in xUbuntu_17.04/i586

2017-08-12 Thread OBS Notification
Visit 
https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openbsc/xUbuntu_17.04/i586

Package network:osmocom:nightly/openbsc failed to build in xUbuntu_17.04/i586

Check out the package for editing:
  osc checkout network:osmocom:nightly openbsc

Last lines of build log:
[  166s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  166s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  166s] make[3]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  166s] make[4]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  166s] make[4]: Nothing to be done for 'install-exec-am'.
[  166s]  /bin/mkdir -p 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/i386-linux-gnu/pkgconfig'
[  166s]  /usr/bin/install -c -m 644 openbsc.pc 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/i386-linux-gnu/pkgconfig'
[  166s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  166s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  166s] make[2]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  166s] make[1]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  166s]dh_install -O--sourcedirectory=openbsc
[  166s] dh_install: Cannot find (any matches for) "/usr/bin/osmo-sgsn" (tried 
in "." and "debian/tmp")
[  166s] dh_install: osmocom-sgsn missing files: /usr/bin/osmo-sgsn
[  166s] dh_install: Cannot find (any matches for) "/usr/bin/osmo-gtphub" 
(tried in "." and "debian/tmp")
[  166s] dh_install: osmo-gtphub missing files: /usr/bin/osmo-gtphub
[  166s] dh_install: missing files, aborting
[  166s] debian/rules:13: recipe for target 'binary' failed
[  166s] make: *** [binary] Error 2
[  166s] dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit 
status 2
[  166s] 
[  166s] lamb53 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:02:36 UTC 2017.
[  166s] 
[  166s] ### VM INTERACTION START ###
[  169s] [  159.371774] reboot: Power down
[  169s] ### VM INTERACTION END ###
[  170s] 
[  170s] lamb53 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:02:40 UTC 2017.
[  170s] 

-- 
Configure notifications at https://build.opensuse.org/user/notifications
openSUSE Build Service (https://build.opensuse.org/)


Build failure of network:osmocom:nightly/openbsc in xUbuntu_17.04/x86_64

2017-08-12 Thread OBS Notification
Visit 
https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openbsc/xUbuntu_17.04/x86_64

Package network:osmocom:nightly/openbsc failed to build in xUbuntu_17.04/x86_64

Check out the package for editing:
  osc checkout network:osmocom:nightly openbsc

Last lines of build log:
[  150s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  150s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc/tests'
[  150s] make[3]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  150s] make[4]: Entering directory '/usr/src/packages/BUILD/openbsc'
[  150s] make[4]: Nothing to be done for 'install-exec-am'.
[  150s]  /bin/mkdir -p 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/x86_64-linux-gnu/pkgconfig'
[  150s]  /usr/bin/install -c -m 644 openbsc.pc 
'/usr/src/packages/BUILD/debian/tmp/usr/lib/x86_64-linux-gnu/pkgconfig'
[  150s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  150s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  150s] make[2]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  150s] make[1]: Leaving directory '/usr/src/packages/BUILD/openbsc'
[  150s]dh_install -O--sourcedirectory=openbsc
[  150s] dh_install: Cannot find (any matches for) "/usr/bin/osmo-sgsn" (tried 
in "." and "debian/tmp")
[  150s] dh_install: osmocom-sgsn missing files: /usr/bin/osmo-sgsn
[  150s] dh_install: Cannot find (any matches for) "/usr/bin/osmo-gtphub" 
(tried in "." and "debian/tmp")
[  150s] dh_install: osmo-gtphub missing files: /usr/bin/osmo-gtphub
[  150s] dh_install: missing files, aborting
[  150s] debian/rules:13: recipe for target 'binary' failed
[  150s] make: *** [binary] Error 2
[  150s] dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit 
status 2
[  150s] 
[  150s] lamb26 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:02:39 UTC 2017.
[  150s] 
[  150s] ### VM INTERACTION START ###
[  153s] [  142.808323] reboot: Power down
[  153s] ### VM INTERACTION END ###
[  153s] 
[  153s] lamb26 failed "build openbsc_0.15.1.20170812.dsc" at Sat Aug 12 
20:02:42 UTC 2017.
[  153s] 

-- 
Configure notifications at https://build.opensuse.org/user/notifications
openSUSE Build Service (https://build.opensuse.org/)


openbsc[master]: libcommon: Fix log output for bts>0.

2017-08-12 Thread Alexander Chemeris

Patch Set 3:

Harald - I've added a test. Hope it's enough.

It doesn't look like the build failure is due to my change.. Not sure if I need 
to do anything?

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I61c18a7f021fcb1ec00d34a745f4e3ab03416c2d
Gerrit-PatchSet: 3
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Alexander Chemeris 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-HasComments: No


[PATCH] openbsc[master]: libcommon: Fix log output for bts>0.

2017-08-12 Thread Alexander Chemeris
Hello Max, Jenkins Builder,

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

https://gerrit.osmocom.org/3185

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

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 openbsc/include/openbsc/gsm_data_shared.h
M openbsc/src/libcommon/gsm_data.c
M openbsc/src/libcommon/gsm_data_shared.c
M openbsc/tests/channel/channel_test.c
M openbsc/tests/channel/channel_test.ok
M openbsc/tests/gsm0408/gsm0408_test.c
6 files changed, 44 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/85/3185/3

diff --git a/openbsc/include/openbsc/gsm_data_shared.h 
b/openbsc/include/openbsc/gsm_data_shared.h
index 4c71a07..369668d 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -900,7 +900,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/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c
index db7de08..f1049e9 100644
--- a/openbsc/src/libcommon/gsm_data.c
+++ b/openbsc/src/libcommon/gsm_data.c
@@ -286,12 +286,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/openbsc/src/libcommon/gsm_data_shared.c 
b/openbsc/src/libcommon/gsm_data_shared.c
index 8992636..d792f3b 100644
--- a/openbsc/src/libcommon/gsm_data_shared.c
+++ b/openbsc/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/openbsc/tests/channel/channel_test.c 
b/openbsc/tests/channel/channel_test.c
index 88293d0..cf19aab 100644
--- a/openbsc/tests/channel/channel_test.c
+++ b/openbsc/tests/channel/channel_test.c
@@ -70,7 +70,7 @@
network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
if (!network)
exit(1);
-   bts = gsm_bts_alloc(network);
+   bts = gsm_bts_alloc(network, 0);
bts->location_area_code = 23;
s_conn.network = network;
 
@@ -91,6 +91,36 @@
 
OSMO_ASSERT(s_end);
 }
+
+
+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)
 {
@@ -128,6 +158,7 @@
 
test_request_chan();
test_dyn_ts_subslots();
+   test_bts_debug_print();
 
return EXIT_SUCCESS;
 }
diff --git a/openbsc/tests/channel/channel_test.ok 
b/openbsc/tests/channel/channel_test.ok
index 33c8193..e2e93ef 100644
--- a/openbsc/tests/channel/channel_test.ok
+++ b/openbsc/tests/channel/channel_test.ok
@@ -1,3 +1,4 @@
 Testing the gsm_subscriber chan logic
 Reached, didn't crash, test passed
 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/openbsc/tests/gsm0408/gsm0408_test.c 
b/openbsc/tests/gsm0408/gsm0408_test.c
index 5a8c6ca..63b5c7c 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.c
+++ 

[PATCH] libosmocore[master]: add osmo_fd_setup() convenience function to fill-in osmo_fd

2017-08-12 Thread Harald Welte

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

add osmo_fd_setup() convenience function to fill-in osmo_fd

This basically follows the concept of osmo_timer_setup() and allows
the caller to fill-in all configurable fields of osmo_fd in one
line of code, rather than open-coding it in 5 lines everywhere.

Change-Id: I6dbf19ea22fd65302bfc5424c10418d1b7939094
---
M include/osmocom/core/select.h
M src/select.c
2 files changed, 22 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/00/3500/1

diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h
index 2abda2d..b6fed3c 100644
--- a/include/osmocom/core/select.h
+++ b/include/osmocom/core/select.h
@@ -36,6 +36,10 @@
unsigned int priv_nr;
 };
 
+void osmo_fd_setup(struct osmo_fd *ofd, int fd, unsigned int when,
+  int (*cb)(struct osmo_fd *fd, unsigned int what),
+  void *data, unsigned int priv_nr);
+
 bool osmo_fd_is_registered(struct osmo_fd *fd);
 int osmo_fd_register(struct osmo_fd *fd);
 void osmo_fd_unregister(struct osmo_fd *fd);
diff --git a/src/select.c b/src/select.c
index 0ba8bc6..4b98b62 100644
--- a/src/select.c
+++ b/src/select.c
@@ -47,6 +47,24 @@
 static LLIST_HEAD(osmo_fds);
 static int unregistered_count;
 
+/*! Set up an osmo-fd. Will not register it.
+ *  \param[inout] ofd Osmo FD to be set-up
+ *  \param[in] fd OS-level file descriptor number
+ *  \param[in] when bit-mask of BSC_FD_{READ,WRITE,EXECEPT}
+ *  \param[in] cb Call-back function to be called
+ *  \param[in] data Private context pointer
+ *  \param[in] priv_nr Private number
+ */
+void osmo_fd_setup(struct osmo_fd *ofd, int fd, unsigned int when,
+  int (*cb)(struct osmo_fd *fd, unsigned int what),
+  void *data, unsigned int priv_nr)
+{
+   ofd->fd = fd;
+   ofd->when = when;
+   ofd->cb = cb;
+   ofd->data = data;
+   ofd->priv_nr = priv_nr;
+}
 
 /*! Check if a file descriptor is already registered
  *  \param[in] fd osmocom file descriptor to be checked

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6dbf19ea22fd65302bfc5424c10418d1b7939094
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte