[PATCH] osmo-ci[master]: jobs: master: also trigger once per day

2018-01-18 Thread Neels Hofmeyr

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

jobs: master: also trigger once per day

Recently we had changes to osmo-ci, and I noticed that although some master
builds were broken by that, the builds were still showing success -- of twenty
days ago.

Run each master build at least once a day to indicate odd side effect failure
sooner.

Change-Id: I126de2bab3db22cb693b0fa665f6579de9238fdf
---
M jobs/master-builds.yml
1 file changed, 1 insertion(+), 0 deletions(-)


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

diff --git a/jobs/master-builds.yml b/jobs/master-builds.yml
index 84a97a9..c05ba4a 100644
--- a/jobs/master-builds.yml
+++ b/jobs/master-builds.yml
@@ -299,6 +299,7 @@
   - pollscm:
   cron: "H/5 * * * *"
   ignore-post-commit-hooks: false
+  - timed: "H H * * *"
 
 builders:
   - shell: '{obj:cmd}'

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

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


[PATCH] osmo-bsc[master]: HO: Implement load based handover, as handover_decision_2.c

2018-01-18 Thread Neels Hofmeyr
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5921

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

HO: Implement load based handover, as handover_decision_2.c

Change-Id: Ice2d3ef5668564a9d3bc4d5118d59dfaa9af6978
---
M configure.ac
M include/osmocom/bsc/Makefile.am
M include/osmocom/bsc/gsm_data.h
M include/osmocom/bsc/gsm_data_shared.h
M include/osmocom/bsc/handover.h
M include/osmocom/bsc/handover_cfg.h
A include/osmocom/bsc/handover_decision_2.h
M include/osmocom/bsc/handover_vty.h
M include/osmocom/bsc/signal.h
M src/libbsc/Makefile.am
M src/libbsc/abis_rsl.c
M src/libbsc/bsc_api.c
M src/libbsc/bsc_vty.c
M src/libbsc/chan_alloc.c
A src/libbsc/handover_decision_2.c
M src/libbsc/handover_logic.c
M src/libbsc/handover_vty.c
M src/libbsc/net_init.c
M src/libcommon/gsm_data.c
M src/libcommon/handover_cfg.c
M src/osmo-bsc/osmo_bsc_bssap.c
M src/osmo-bsc/osmo_bsc_main.c
M tests/Makefile.am
A tests/handover/Makefile.am
A tests/handover/handover_test.c
A tests/handover/handover_test.ok
M tests/testsuite.at
27 files changed, 3,858 insertions(+), 73 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/21/5921/3

diff --git a/configure.ac b/configure.ac
index d756970..fc4678f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -166,6 +166,7 @@
 tests/subscr/Makefile
 tests/nanobts_omlattr/Makefile
 tests/bssap/Makefile
+tests/handover/Makefile
 doc/Makefile
 doc/examples/Makefile
 Makefile)
diff --git a/include/osmocom/bsc/Makefile.am b/include/osmocom/bsc/Makefile.am
index 699aeb3..a3d9adf 100644
--- a/include/osmocom/bsc/Makefile.am
+++ b/include/osmocom/bsc/Makefile.am
@@ -27,6 +27,7 @@
handover.h \
handover_cfg.h \
handover_decision.h \
+   handover_decision_2.h \
handover_vty.h \
ipaccess.h \
meas_feed.h \
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index d9dd2d4..c24e22a 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -74,8 +75,8 @@
 /* penalty timers for handover */
 struct ho_penalty_timer {
struct llist_head entry;
-   uint8_t bts;
-   time_t timeout;
+   uint8_t bts_nr;
+   unsigned int timeout;
 };
 
 /* active radio connection of a mobile subscriber */
@@ -112,8 +113,18 @@
struct llist_head ho_dtap_cache;
unsigned int ho_dtap_cache_len;
 
-   /* penalty timers for handover */
+   /* failure count and penalty timers for handover */
+   int ho_failure;
struct llist_head ho_penalty_timers;
+
+   /* "Codec List (MSC Preferred)" as received by the BSSAP Assignment 
Request. 3GPP 48.008
+* 3.2.2.103 says:
+* The "Codec List (MSC Preferred)" shall not include codecs
+* that are not supported by the MS.
+* i.e. by heeding the "Codec list (MSC Preferred)", we inherently heed 
the MS bearer
+* capabilities, which the MSC is required to translate into the codec 
list. */
+   struct gsm0808_speech_codec_list codec_list;
+   bool codec_list_present;
 };
 
 static inline struct gsm_bts *conn_get_bts(struct gsm_subscriber_connection 
*conn) {
@@ -243,7 +254,12 @@
uint16_t network_code;
int a5_encryption;
int neci;
+
struct handover_cfg *ho;
+   struct {
+   unsigned int congestion_check_interval_s;
+   struct osmo_timer_list congestion_check_timer;
+   } ho2;
 
struct rate_ctr_group *bsc_ctrs;
 
@@ -443,4 +459,11 @@
 
 bool classmark_is_r99(struct gsm_classmark *cm);
 
+void conn_penalty_timer_add(struct gsm_subscriber_connection *conn,
+   struct gsm_bts *bts, int timeout);
+unsigned int conn_penalty_timer_remaining(struct gsm_subscriber_connection 
*conn,
+ struct gsm_bts *bts);
+void conn_penalty_timer_clear(struct gsm_subscriber_connection *conn,
+ struct gsm_bts *bts);
+
 #endif /* _GSM_DATA_H */
diff --git a/include/osmocom/bsc/gsm_data_shared.h 
b/include/osmocom/bsc/gsm_data_shared.h
index 86c5ca9..776e047 100644
--- a/include/osmocom/bsc/gsm_data_shared.h
+++ b/include/osmocom/bsc/gsm_data_shared.h
@@ -269,6 +269,7 @@
struct gsm_meas_rep meas_rep[MAX_MEAS_REP];
int meas_rep_idx;
int meas_rep_count;
+   uint8_t meas_rep_last_seen_nr;
 
/* GSM Random Access data */
struct gsm48_req_ref *rqd_ref;
diff --git a/include/osmocom/bsc/handover.h b/include/osmocom/bsc/handover.h
index a9349ee..f764456 100644
--- a/include/osmocom/bsc/handover.h
+++ b/include/osmocom/bsc/handover.h
@@ -5,6 +5,8 @@
 struct gsm_subscriber_connection;
 
 int bsc_handover_start(struct gsm_lchan *old_lchan, struct gsm_bts *bts);
+int bsc_handover_start_lchan_change(struct gsm_lchan *old_lchan, struct 
gsm_bts *bts,
+   

[PATCH] osmo-bsc[master]: HO: Implement load based handover, as handover_decision_2.c

2018-01-18 Thread Neels Hofmeyr
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5921

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

HO: Implement load based handover, as handover_decision_2.c

Change-Id: Ice2d3ef5668564a9d3bc4d5118d59dfaa9af6978
---
M configure.ac
M include/osmocom/bsc/Makefile.am
M include/osmocom/bsc/gsm_data.h
M include/osmocom/bsc/gsm_data_shared.h
M include/osmocom/bsc/handover.h
M include/osmocom/bsc/handover_cfg.h
A include/osmocom/bsc/handover_decision_2.h
M include/osmocom/bsc/handover_vty.h
M include/osmocom/bsc/signal.h
M src/libbsc/Makefile.am
M src/libbsc/abis_rsl.c
M src/libbsc/bsc_api.c
M src/libbsc/bsc_vty.c
M src/libbsc/chan_alloc.c
A src/libbsc/handover_decision_2.c
M src/libbsc/handover_logic.c
M src/libbsc/handover_vty.c
M src/libbsc/net_init.c
M src/libcommon/gsm_data.c
M src/libcommon/handover_cfg.c
M src/osmo-bsc/osmo_bsc_bssap.c
M src/osmo-bsc/osmo_bsc_main.c
M tests/Makefile.am
A tests/handover/Makefile.am
A tests/handover/handover_test.c
A tests/handover/handover_test.ok
M tests/testsuite.at
27 files changed, 3,859 insertions(+), 73 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/21/5921/2

diff --git a/configure.ac b/configure.ac
index d756970..fc4678f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -166,6 +166,7 @@
 tests/subscr/Makefile
 tests/nanobts_omlattr/Makefile
 tests/bssap/Makefile
+tests/handover/Makefile
 doc/Makefile
 doc/examples/Makefile
 Makefile)
diff --git a/include/osmocom/bsc/Makefile.am b/include/osmocom/bsc/Makefile.am
index 699aeb3..a3d9adf 100644
--- a/include/osmocom/bsc/Makefile.am
+++ b/include/osmocom/bsc/Makefile.am
@@ -27,6 +27,7 @@
handover.h \
handover_cfg.h \
handover_decision.h \
+   handover_decision_2.h \
handover_vty.h \
ipaccess.h \
meas_feed.h \
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index d9dd2d4..c24e22a 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -74,8 +75,8 @@
 /* penalty timers for handover */
 struct ho_penalty_timer {
struct llist_head entry;
-   uint8_t bts;
-   time_t timeout;
+   uint8_t bts_nr;
+   unsigned int timeout;
 };
 
 /* active radio connection of a mobile subscriber */
@@ -112,8 +113,18 @@
struct llist_head ho_dtap_cache;
unsigned int ho_dtap_cache_len;
 
-   /* penalty timers for handover */
+   /* failure count and penalty timers for handover */
+   int ho_failure;
struct llist_head ho_penalty_timers;
+
+   /* "Codec List (MSC Preferred)" as received by the BSSAP Assignment 
Request. 3GPP 48.008
+* 3.2.2.103 says:
+* The "Codec List (MSC Preferred)" shall not include codecs
+* that are not supported by the MS.
+* i.e. by heeding the "Codec list (MSC Preferred)", we inherently heed 
the MS bearer
+* capabilities, which the MSC is required to translate into the codec 
list. */
+   struct gsm0808_speech_codec_list codec_list;
+   bool codec_list_present;
 };
 
 static inline struct gsm_bts *conn_get_bts(struct gsm_subscriber_connection 
*conn) {
@@ -243,7 +254,12 @@
uint16_t network_code;
int a5_encryption;
int neci;
+
struct handover_cfg *ho;
+   struct {
+   unsigned int congestion_check_interval_s;
+   struct osmo_timer_list congestion_check_timer;
+   } ho2;
 
struct rate_ctr_group *bsc_ctrs;
 
@@ -443,4 +459,11 @@
 
 bool classmark_is_r99(struct gsm_classmark *cm);
 
+void conn_penalty_timer_add(struct gsm_subscriber_connection *conn,
+   struct gsm_bts *bts, int timeout);
+unsigned int conn_penalty_timer_remaining(struct gsm_subscriber_connection 
*conn,
+ struct gsm_bts *bts);
+void conn_penalty_timer_clear(struct gsm_subscriber_connection *conn,
+ struct gsm_bts *bts);
+
 #endif /* _GSM_DATA_H */
diff --git a/include/osmocom/bsc/gsm_data_shared.h 
b/include/osmocom/bsc/gsm_data_shared.h
index 86c5ca9..776e047 100644
--- a/include/osmocom/bsc/gsm_data_shared.h
+++ b/include/osmocom/bsc/gsm_data_shared.h
@@ -269,6 +269,7 @@
struct gsm_meas_rep meas_rep[MAX_MEAS_REP];
int meas_rep_idx;
int meas_rep_count;
+   uint8_t meas_rep_last_seen_nr;
 
/* GSM Random Access data */
struct gsm48_req_ref *rqd_ref;
diff --git a/include/osmocom/bsc/handover.h b/include/osmocom/bsc/handover.h
index a9349ee..f764456 100644
--- a/include/osmocom/bsc/handover.h
+++ b/include/osmocom/bsc/handover.h
@@ -5,6 +5,8 @@
 struct gsm_subscriber_connection;
 
 int bsc_handover_start(struct gsm_lchan *old_lchan, struct gsm_bts *bts);
+int bsc_handover_start_lchan_change(struct gsm_lchan *old_lchan, struct 
gsm_bts *bts,
+   

[PATCH] osmo-bsc[master]: HO: rename gsm_bts_neighbor() to bts_by_arfcn_bsic()

2018-01-18 Thread Neels Hofmeyr
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5917

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

HO: rename gsm_bts_neighbor() to bts_by_arfcn_bsic()

The name sounds like it is looking up neighbors, instead it simply traverses
the global list of BTSes. Rename to reflect what it does.

Move FIXME comment to its logical place: at the invocation of
bts_by_arfcn_bsic().

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


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/17/5917/2

diff --git a/src/libbsc/handover_decision.c b/src/libbsc/handover_decision.c
index 0693613..93ca28b 100644
--- a/src/libbsc/handover_decision.c
+++ b/src/libbsc/handover_decision.c
@@ -35,21 +35,16 @@
 #include 
 #include 
 
-/* Get reference to a neighbor cell on a given BCCH ARFCN */
-static struct gsm_bts *gsm_bts_neighbor(const struct gsm_bts *bts,
-   uint16_t arfcn, uint8_t bsic)
+/* Find BTS by ARFCN and BSIC */
+static struct gsm_bts *bts_by_arfcn_bsic(const struct gsm_network *net,
+uint16_t arfcn, uint8_t bsic)
 {
-   struct gsm_bts *neigh;
-   /* FIXME: use some better heuristics here to determine which cell
-* using this ARFCN really is closest to the target cell.  For
-* now we simply assume that each ARFCN will only be used by one
-* cell */
+   struct gsm_bts *bts;
 
-   llist_for_each_entry(neigh, >network->bts_list, list) {
-   /* FIXME: this is probably returning the same bts again!? */
-   if (neigh->c0->arfcn == arfcn &&
-   neigh->bsic == bsic)
-   return neigh;
+   llist_for_each_entry(bts, >bts_list, list) {
+   if (bts->c0->arfcn == arfcn &&
+   bts->bsic == bsic)
+   return bts;
}
 
return NULL;
@@ -63,7 +58,11 @@
struct gsm_bts *new_bts;
 
/* resolve the gsm_bts structure for the best neighbor */
-   new_bts = gsm_bts_neighbor(lchan->ts->trx->bts, arfcn, bsic);
+   /* FIXME: use some better heuristics here to determine which cell
+* using this ARFCN really is closest to the target cell.  For
+* now we simply assume that each ARFCN will only be used by one
+* cell */
+   new_bts = bts_by_arfcn_bsic(lchan->ts->trx->bts->network, arfcn, bsic);
if (!new_bts) {
LOGP(DHODEC, LOGL_NOTICE, "unable to determine neighbor BTS "
 "for ARFCN %u BSIC %u ?!?\n", arfcn, bsic);

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I063870d09f782a4f18e85d87c7cd17fe660cb3fd
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: HO: add queue to cache DTAP messages during handover/assignment

2018-01-18 Thread Neels Hofmeyr
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5919

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

HO: add queue to cache DTAP messages during handover/assignment

Add ho_dtap_cache to gsm_subscriber_connection, a stock msgb queue to be used
with msgb_enqueue() and msgb_dequeue().

Keep a counter of queue length, to enforce a sane maximum counter for cached
messages. So far a hardcoded maximum of 23 messages will be cached.

Have balanced ho_dtap_cache_add() and ho_dtap_cache_flush() functions.

The original patch was by jolly, but I have basically completely replaced it
with the simpler msgb queue pattern.

Change-Id: I6e4d93628befb3d97e5cee0343cd9f8ba0b8620c
---
M include/osmocom/bsc/gsm_data.h
M src/libbsc/bsc_api.c
2 files changed, 77 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/19/5919/2

diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 6659b72..4e07f26 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -100,6 +100,10 @@
 
/* buffer/cache for classmark of the ME of the subscriber */
struct gsm_classmark classmark;
+
+   /* Cache DTAP messages during handover/assignment 
(msgb_enqueue()/msgb_dequeue())*/
+   struct llist_head ho_dtap_cache;
+   unsigned int ho_dtap_cache_len;
 };
 
 static inline struct gsm_bts *conn_get_bts(struct gsm_subscriber_connection 
*conn) {
diff --git a/src/libbsc/bsc_api.c b/src/libbsc/bsc_api.c
index 545cf36..2a0bf8f 100644
--- a/src/libbsc/bsc_api.c
+++ b/src/libbsc/bsc_api.c
@@ -39,6 +39,8 @@
 
 #define GSM0808_T10_VALUE6, 0
 
+#define HO_DTAP_CACHE_MSGB_CB_LINK_ID 0
+#define HO_DTAP_CACHE_MSGB_CB_ALLOW_SACCH 1
 
 static void rll_ind_cb(struct gsm_lchan *, uint8_t, void *, enum bsc_rllr_ind);
 static void send_sapi_reject(struct gsm_subscriber_connection *conn, int 
link_id);
@@ -270,8 +272,52 @@
conn->lchan = lchan;
conn->bts = lchan->ts->trx->bts;
lchan->conn = conn;
+   INIT_LLIST_HEAD(>ho_dtap_cache);
llist_add_tail(>entry, >subscr_conns);
return conn;
+}
+
+static void ho_dtap_cache_add(struct gsm_subscriber_connection *conn, struct 
msgb *msg,
+ int link_id, bool allow_sacch)
+{
+   if (conn->ho_dtap_cache_len >= 23) {
+   LOGP(DHO, LOGL_ERROR, "%s: Cannot cache more DTAP messages,"
+" already reached sane maximum of %u cached messages\n",
+bsc_subscr_name(conn->bsub), conn->ho_dtap_cache_len);
+   msgb_free(msg);
+   return;
+   }
+   conn->ho_dtap_cache_len ++;
+   LOGP(DHO, LOGL_DEBUG, "%s: Caching DTAP message during ho/ass (%u)\n",
+bsc_subscr_name(conn->bsub), conn->ho_dtap_cache_len);
+   msg->cb[HO_DTAP_CACHE_MSGB_CB_LINK_ID] = (unsigned long)link_id;
+   msg->cb[HO_DTAP_CACHE_MSGB_CB_ALLOW_SACCH] = allow_sacch ? 1 : 0;
+   msgb_enqueue(>ho_dtap_cache, msg);
+}
+
+static void ho_dtap_cache_flush(struct gsm_subscriber_connection *conn, int 
send)
+{
+   struct msgb *msg;
+   unsigned int flushed_count = 0;
+
+   if (conn->secondary_lchan || conn->ho_lchan) {
+   LOGP(DHO, LOGL_ERROR, "%s: Cannot send cached DTAP messages, 
handover/assignment is still ongoing\n",
+bsc_subscr_name(conn->bsub));
+   send = 0;
+   }
+
+   while ((msg = msgb_dequeue(>ho_dtap_cache))) {
+   conn->ho_dtap_cache_len --;
+   flushed_count ++;
+   if (send) {
+   int link_id = 
(int)msg->cb[HO_DTAP_CACHE_MSGB_CB_LINK_ID];
+   bool allow_sacch = 
!!msg->cb[HO_DTAP_CACHE_MSGB_CB_ALLOW_SACCH];
+   LOGP(DHO, LOGL_DEBUG, "%s: Sending cached DTAP message 
after handover/assignment (%u/%u)\n",
+bsc_subscr_name(conn->bsub), flushed_count, 
conn->ho_dtap_cache_len);
+   gsm0808_submit_dtap(conn, msg, link_id, allow_sacch);
+   } else
+   msgb_free(msg);
+   }
 }
 
 void bsc_subscr_con_free(struct gsm_subscriber_connection *conn)
@@ -297,6 +343,9 @@
conn->secondary_lchan->conn = NULL;
}
 
+   /* drop pending messages */
+   ho_dtap_cache_flush(conn, 0);
+
llist_del(>entry);
talloc_free(conn);
 }
@@ -319,6 +368,12 @@
 "Called submit dtap without an lchan.\n");
msgb_free(msg);
return -1;
+   }
+
+   /* buffer message during assignment / handover */
+   if (conn->secondary_lchan || conn->ho_lchan) {
+   ho_dtap_cache_add(conn, msg, link_id, !! allow_sacch);
+   return 0;
}
 
sapi = link_id & 0x7;
@@ -454,6 +509,9 @@
osmo_signal_dispatch(SS_LCHAN, S_LCHAN_ASSIGNMENT_COMPL, );
/* FIXME: release old 

[PATCH] osmo-bsc[master]: HO: Count number of free timeslot on a given BTS

2018-01-18 Thread Neels Hofmeyr
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5916

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

HO: Count number of free timeslot on a given BTS

This is needed for handover algorithm to balance free slots and to prevent
congestion of one cell, while other cells still have free capacities.

Change-Id: Ic8bee8a515ee8aa9a99af71756fe60b8dd8f868b
---
M include/osmocom/bsc/chan_alloc.h
M src/libbsc/chan_alloc.c
2 files changed, 67 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/16/5916/2

diff --git a/include/osmocom/bsc/chan_alloc.h b/include/osmocom/bsc/chan_alloc.h
index f2a75c5..748e9cd 100644
--- a/include/osmocom/bsc/chan_alloc.h
+++ b/include/osmocom/bsc/chan_alloc.h
@@ -24,6 +24,9 @@
 
 struct gsm_subscriber_connection;
 
+/* Count number of free TS of given pchan type */
+int bts_count_free_ts(struct gsm_bts *bts, enum gsm_phys_chan_config pchan);
+
 /* Allocate a logical channel (SDCCH, TCH, ...) */
 struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type, int 
allow_bigger);
 
diff --git a/src/libbsc/chan_alloc.c b/src/libbsc/chan_alloc.c
index 9946628..b3056da 100644
--- a/src/libbsc/chan_alloc.c
+++ b/src/libbsc/chan_alloc.c
@@ -68,6 +68,70 @@
return true;
 }
 
+static int trx_count_free_ts(struct gsm_bts_trx *trx, enum 
gsm_phys_chan_config pchan)
+{
+   struct gsm_bts_trx_ts *ts;
+   int j, ss;
+   int count = 0;
+
+   if (!trx_is_usable(trx))
+   return 0;
+
+   for (j = 0; j < 8; j++) {
+   enum gsm_phys_chan_config ts_pchan_is;
+   ts = >ts[j];
+   if (!ts_is_usable(ts))
+   continue;
+
+   ts_pchan_is = ts_pchan(ts);
+
+   if (ts_pchan_is == GSM_PCHAN_PDCH) {
+   /* Dynamic timeslots in PDCH mode will become TCH if 
needed. */
+   switch (ts->pchan) {
+   case GSM_PCHAN_TCH_F_PDCH:
+   if (pchan == GSM_PCHAN_TCH_F)
+   count++;
+   continue;
+
+   case GSM_PCHAN_TCH_F_TCH_H_PDCH:
+   if (pchan == GSM_PCHAN_TCH_F)
+   count++;
+   else if (pchan == GSM_PCHAN_TCH_H)
+   count += 2;
+   continue;
+
+   default:
+   /* Not dynamic, not applicable. */
+   continue;
+   }
+   }
+
+   if (ts_pchan_is != pchan)
+   continue;
+   /* check if all sub-slots are allocated yet */
+   for (ss = 0; ss < ts_subslots(ts); ss++) {
+   struct gsm_lchan *lc = >lchan[ss];
+   if (lc->type == GSM_LCHAN_NONE &&
+   lc->state == LCHAN_S_NONE)
+   count++;
+   }
+   }
+
+   return count;
+}
+
+/* Count number of free TS of given pchan type */
+int bts_count_free_ts(struct gsm_bts *bts, enum gsm_phys_chan_config pchan)
+{
+   struct gsm_bts_trx *trx;
+   int count = 0;
+
+   llist_for_each_entry(trx, >trx_list, list)
+   count += trx_count_free_ts(trx, pchan);
+
+   return count;
+}
+
 static struct gsm_lchan *
 _lc_find_trx(struct gsm_bts_trx *trx, enum gsm_phys_chan_config pchan,
 enum gsm_phys_chan_config dyn_as_pchan)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ic8bee8a515ee8aa9a99af71756fe60b8dd8f868b
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: HO: Change debug category at handover decision: DHO -> DHODEC

2018-01-18 Thread Neels Hofmeyr
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5915

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

HO: Change debug category at handover decision: DHO -> DHODEC

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


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/15/5915/2

diff --git a/src/libbsc/handover_decision.c b/src/libbsc/handover_decision.c
index 1e2e0d9..0693613 100644
--- a/src/libbsc/handover_decision.c
+++ b/src/libbsc/handover_decision.c
@@ -65,7 +65,7 @@
/* resolve the gsm_bts structure for the best neighbor */
new_bts = gsm_bts_neighbor(lchan->ts->trx->bts, arfcn, bsic);
if (!new_bts) {
-   LOGP(DHO, LOGL_NOTICE, "unable to determine neighbor BTS "
+   LOGP(DHODEC, LOGL_NOTICE, "unable to determine neighbor BTS "
 "for ARFCN %u BSIC %u ?!?\n", arfcn, bsic);
return -EINVAL;
}
@@ -104,7 +104,7 @@
window = nmp->rxlev_cnt;
/* this should never happen */
if (window <= 0) {
-   LOGP(DHO, LOGL_ERROR, "Requested Neighbor RxLev for invalid 
window size of %d\n", window);
+   LOGP(DHODEC, LOGL_ERROR, "Requested Neighbor RxLev for invalid 
window size of %d\n", window);
return 0;
}
 
@@ -232,26 +232,26 @@
if (!best_cell)
return 0;
 
-   LOGP(DHO, LOGL_INFO, "%s: Cell on ARFCN %u is better: ",
+   LOGP(DHODEC, LOGL_INFO, "%s: Cell on ARFCN %u is better: ",
gsm_ts_name(mr->lchan->ts), best_cell->arfcn);
if (!ho_get_ho_active(bts->ho)) {
-   LOGPC(DHO, LOGL_INFO, "Skipping, Handover disabled\n");
+   LOGPC(DHODEC, LOGL_INFO, "Skipping, Handover disabled\n");
return 0;
}
 
rc = handover_to_arfcn_bsic(mr->lchan, best_cell->arfcn, 
best_cell->bsic);
switch (rc) {
case 0:
-   LOGPC(DHO, LOGL_INFO, "Starting handover: meas report number %d 
\n", mr->nr);
+   LOGPC(DHODEC, LOGL_INFO, "Starting handover: meas report number 
%d \n", mr->nr);
break;
case -ENOSPC:
-   LOGPC(DHO, LOGL_INFO, "No channel available\n");
+   LOGPC(DHODEC, LOGL_INFO, "No channel available\n");
break;
case -EBUSY:
-   LOGPC(DHO, LOGL_INFO, "Handover already active\n");
+   LOGPC(DHODEC, LOGL_INFO, "Handover already active\n");
break;
default:
-   LOGPC(DHO, LOGL_ERROR, "Unknown error\n");
+   LOGPC(DHODEC, LOGL_ERROR, "Unknown error\n");
}
return rc;
 }

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I7322b790f647b681bfe3a9c95b04516fbc7cbf88
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: HO: make bts_by_arfcn_bsic() public

2018-01-18 Thread Neels Hofmeyr
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5918

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

HO: make bts_by_arfcn_bsic() public

Change-Id: Ie746f76433f6b46a71a91b7714cc034c4355d993
---
M include/osmocom/bsc/handover_decision.h
M src/libbsc/handover_decision.c
2 files changed, 4 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/18/5918/2

diff --git a/include/osmocom/bsc/handover_decision.h 
b/include/osmocom/bsc/handover_decision.h
index fe551ca..09430d8 100644
--- a/include/osmocom/bsc/handover_decision.h
+++ b/include/osmocom/bsc/handover_decision.h
@@ -1,3 +1,5 @@
 #pragma once
 
+struct gsm_bts *bts_by_arfcn_bsic(const struct gsm_network *net, uint16_t 
arfcn, uint8_t bsic);
+
 void handover_decision_1_init(void);
diff --git a/src/libbsc/handover_decision.c b/src/libbsc/handover_decision.c
index 93ca28b..19fb3ab 100644
--- a/src/libbsc/handover_decision.c
+++ b/src/libbsc/handover_decision.c
@@ -36,8 +36,8 @@
 #include 
 
 /* Find BTS by ARFCN and BSIC */
-static struct gsm_bts *bts_by_arfcn_bsic(const struct gsm_network *net,
-uint16_t arfcn, uint8_t bsic)
+struct gsm_bts *bts_by_arfcn_bsic(const struct gsm_network *net,
+ uint16_t arfcn, uint8_t bsic)
 {
struct gsm_bts *bts;
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie746f76433f6b46a71a91b7714cc034c4355d993
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[ABANDON] osmo-bsc[master]: HO: add algorithm cfg; skip HO 1 if HO 2 is configured

2018-01-18 Thread Neels Hofmeyr
Neels Hofmeyr has abandoned this change.

Change subject: HO: add algorithm cfg; skip HO 1 if HO 2 is configured
..


Abandoned

squashed into 'add handover algo 2 parameters...'

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

Gerrit-MessageType: abandon
Gerrit-Change-Id: If07c0a7b84937ab92948e9b71b2496a765946020
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: HO: add handover algo 2 parameters; skip HO 1 if HO 2 is con...

2018-01-18 Thread Neels Hofmeyr
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5914

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

HO: add handover algo 2 parameters; skip HO 1 if HO 2 is configured

Change-Id: I8811ee8a75be09048042b511ee4bd9bc1de63976
---
M include/osmocom/bsc/handover_cfg.h
M src/libbsc/handover_decision.c
M tests/handover_cfg.vty
3 files changed, 374 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/14/5914/2

diff --git a/include/osmocom/bsc/handover_cfg.h 
b/include/osmocom/bsc/handover_cfg.h
index 264cb1b..1b81235 100644
--- a/include/osmocom/bsc/handover_cfg.h
+++ b/include/osmocom/bsc/handover_cfg.h
@@ -1,6 +1,7 @@
 #pragma once
 
 #include 
+#include 
 
 struct vty;
 
@@ -17,6 +18,11 @@
 #define HO_CFG_STR_WIN_RXQUAL HO_CFG_STR_WIN "Received-Quality averaging\n"
 #define HO_CFG_STR_POWER_BUDGET HO_CFG_STR_HANDOVER "Neighbor cell power 
triggering\n" "Neighbor cell power triggering\n"
 #define HO_CFG_STR_AVG_COUNT "Number of values to average over\n"
+#define HO_CFG_STR_2 " (HO algo 2 only)\n"
+#define HO_CFG_STR_MIN "Minimum Level/Quality thresholds before triggering HO" 
HO_CFG_STR_2
+#define HO_CFG_STR_AFS_BIAS "Configure bias to prefer AFS (AMR on TCH/F) over 
other codecs" HO_CFG_STR_2
+#define HO_CFG_STR_MIN_TCH "Minimum free TCH timeslots before cell is 
considered congested" HO_CFG_STR_2
+#define HO_CFG_STR_PENALTY_TIME "Set penalty times to wait between repeated 
handovers" HO_CFG_STR_2
 
 #define as_is(x) (x)
 
@@ -30,6 +36,33 @@
return arg? 1 : 0;
 }
 
+static inline bool a2tdma(const char *arg)
+{
+   if (!strcmp(arg, "full"))
+   return true;
+   return false;
+}
+
+static inline const char *tdma2a(bool val)
+{
+   return val? "full" : "subset";
+}
+
+static inline const int a2congestion_check_interval(const char *arg)
+{
+   if (!strcmp(arg, "disabled"))
+   return 0;
+   return atoi(arg);
+}
+
+static inline const char *congestion_check_interval2a(int val)
+{
+   static char str[9];
+   if (val < 1
+   || snprintf(str, sizeof(str), "%d", val) >= sizeof(str))
+   return "disabled";
+   return str;
+}
 
 /* The HO_CFG_ONE_MEMBER macro gets redefined, depending on whether to define 
struct members,
  * function declarations or definitions... It is of the format
@@ -59,6 +92,15 @@
"Disable in-call handover\n" \
"Enable in-call handover\n" \
"Enable/disable handover: ") \
+   \
+   HO_CFG_ONE_MEMBER(int, algorithm, 1, \
+   "handover algorithm", "1|2", atoi, "%d", as_is, \
+   HO_CFG_STR_HANDOVER \
+   "Choose algorithm for handover decision\n" \
+   "Algorithm 1: trigger handover based on comparing current cell 
and neighbor RxLev and RxQual," \
+   " only.\n" \
+   "Algorithm 2: trigger handover on RxLev/RxQual, and also to 
balance the load across several" \
+   " cells. Consider available codecs. Prevent repeated handover 
by penalty timers.\n") \
\
HO_CFG_ONE_MEMBER(unsigned int, rxlev_avg_win, 10, \
"handover window rxlev averaging", "<1-10>", atoi, "%u", as_is, 
\
@@ -97,7 +139,104 @@
"Maximum Timing-Advance value (i.e. MS distance) before 
triggering HO\n" \
"Maximum Timing-Advance value (i.e. MS distance) before 
triggering HO\n" \
"Maximum Timing-Advance value (i.e. MS distance) before 
triggering HO\n") \
-
+   \
+   HO_CFG_ONE_MEMBER(bool, as_active, 0, \
+   "handover assignment", "0|1", a2bool, "%d", bool2i, \
+   HO_CFG_STR_HANDOVER \
+   "Enable or disable in-call channel re-assignment" HO_CFG_STR_2 \
+   "Disable in-call assignment\n" \
+   "Enable in-call assignment\n") \
+   \
+   HO_CFG_ONE_MEMBER(int, congestion_check_interval, 10, \
+   "handover congestion-check", "disabled|<1-60>", \
+   a2congestion_check_interval, "%s", congestion_check_interval2a, 
\
+   HO_CFG_STR_HANDOVER \
+   "Configure congestion check interval" HO_CFG_STR_2 \
+   "Disable congestion checking, do not handover based on cell 
overload\n" \
+   "Congestion check interval in seconds\n") \
+   \
+   HO_CFG_ONE_MEMBER(bool, full_tdma, subset, \
+   "handover tdma-measurement", "full|subset", a2tdma, "%s", 
tdma2a, \
+   HO_CFG_STR_HANDOVER \
+   "Define measurement set of TDMA frames" HO_CFG_STR_2 \
+   "Full set of 102/104 TDMA frames\n" \
+   "Sub set of 4 TDMA frames (SACCH)\n") \
+   \
+   HO_CFG_ONE_MEMBER(int, min_rxlev, -100, \
+   "handover min rxlev", "<-110--50>", atoi, "%d", as_is, \
+   HO_CFG_STR_HANDOVER \
+   HO_CFG_STR_MIN \
+   "How 

[PATCH] osmo-bsc[master]: HO: Add a penalty timer list to the subscriber connection en...

2018-01-18 Thread Neels Hofmeyr
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5920

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

HO: Add a penalty timer list to the subscriber connection entity

This penalty timer is used to temporarily block cells where handover
or assignment failed or where handover is not allowed. This is usefull
to prevent repeated handover attempts to broken cells or cells that have
limited allowed distance.

Change-Id: I95cb7e3211b2470b773965e7aa94d8eb6c8c1a3a
---
M include/osmocom/bsc/gsm_data.h
M src/libbsc/bsc_api.c
2 files changed, 20 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/20/5920/2

diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 4e07f26..d9dd2d4 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -71,6 +71,13 @@
uint8_t classmark3[14]; /* if cm3 gets extended by spec, it will be 
truncated */
 };
 
+/* penalty timers for handover */
+struct ho_penalty_timer {
+   struct llist_head entry;
+   uint8_t bts;
+   time_t timeout;
+};
+
 /* active radio connection of a mobile subscriber */
 struct gsm_subscriber_connection {
/* global linked list of subscriber_connections */
@@ -104,6 +111,9 @@
/* Cache DTAP messages during handover/assignment 
(msgb_enqueue()/msgb_dequeue())*/
struct llist_head ho_dtap_cache;
unsigned int ho_dtap_cache_len;
+
+   /* penalty timers for handover */
+   struct llist_head ho_penalty_timers;
 };
 
 static inline struct gsm_bts *conn_get_bts(struct gsm_subscriber_connection 
*conn) {
diff --git a/src/libbsc/bsc_api.c b/src/libbsc/bsc_api.c
index 2a0bf8f..a501db2 100644
--- a/src/libbsc/bsc_api.c
+++ b/src/libbsc/bsc_api.c
@@ -273,6 +273,7 @@
conn->bts = lchan->ts->trx->bts;
lchan->conn = conn;
INIT_LLIST_HEAD(>ho_dtap_cache);
+   INIT_LLIST_HEAD(>ho_penalty_timers);
llist_add_tail(>entry, >subscr_conns);
return conn;
 }
@@ -322,6 +323,8 @@
 
 void bsc_subscr_con_free(struct gsm_subscriber_connection *conn)
 {
+   struct ho_penalty_timer *penalty;
+
if (!conn)
return;
 
@@ -346,6 +349,13 @@
/* drop pending messages */
ho_dtap_cache_flush(conn, 0);
 
+   /* flush handover penalty timers */
+   while ((penalty = llist_first_entry_or_null(>ho_penalty_timers,
+   struct ho_penalty_timer, 
entry))) {
+   llist_del(>entry);
+   talloc_free(penalty);
+   }
+
llist_del(>entry);
talloc_free(conn);
 }

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I95cb7e3211b2470b773965e7aa94d8eb6c8c1a3a
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: HO: rename gsm_bts_neighbor() to bts_by_arfcn_bsic()

2018-01-18 Thread Neels Hofmeyr

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

HO: rename gsm_bts_neighbor() to bts_by_arfcn_bsic()

The name sounds like it is looking up neighbors, instead it simply traverses
the global list of BTSes. Rename to reflect what it does.

Move FIXME comment to its logical place: at the invocation of
bts_by_arfcn_bsic().

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


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

diff --git a/src/libbsc/handover_decision.c b/src/libbsc/handover_decision.c
index 0693613..93ca28b 100644
--- a/src/libbsc/handover_decision.c
+++ b/src/libbsc/handover_decision.c
@@ -35,21 +35,16 @@
 #include 
 #include 
 
-/* Get reference to a neighbor cell on a given BCCH ARFCN */
-static struct gsm_bts *gsm_bts_neighbor(const struct gsm_bts *bts,
-   uint16_t arfcn, uint8_t bsic)
+/* Find BTS by ARFCN and BSIC */
+static struct gsm_bts *bts_by_arfcn_bsic(const struct gsm_network *net,
+uint16_t arfcn, uint8_t bsic)
 {
-   struct gsm_bts *neigh;
-   /* FIXME: use some better heuristics here to determine which cell
-* using this ARFCN really is closest to the target cell.  For
-* now we simply assume that each ARFCN will only be used by one
-* cell */
+   struct gsm_bts *bts;
 
-   llist_for_each_entry(neigh, >network->bts_list, list) {
-   /* FIXME: this is probably returning the same bts again!? */
-   if (neigh->c0->arfcn == arfcn &&
-   neigh->bsic == bsic)
-   return neigh;
+   llist_for_each_entry(bts, >bts_list, list) {
+   if (bts->c0->arfcn == arfcn &&
+   bts->bsic == bsic)
+   return bts;
}
 
return NULL;
@@ -63,7 +58,11 @@
struct gsm_bts *new_bts;
 
/* resolve the gsm_bts structure for the best neighbor */
-   new_bts = gsm_bts_neighbor(lchan->ts->trx->bts, arfcn, bsic);
+   /* FIXME: use some better heuristics here to determine which cell
+* using this ARFCN really is closest to the target cell.  For
+* now we simply assume that each ARFCN will only be used by one
+* cell */
+   new_bts = bts_by_arfcn_bsic(lchan->ts->trx->bts->network, arfcn, bsic);
if (!new_bts) {
LOGP(DHODEC, LOGL_NOTICE, "unable to determine neighbor BTS "
 "for ARFCN %u BSIC %u ?!?\n", arfcn, bsic);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I063870d09f782a4f18e85d87c7cd17fe660cb3fd
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: HO: always use Handover Command, not Assignment

2018-01-18 Thread Neels Hofmeyr

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

HO: always use Handover Command, not Assignment

Change-Id: I5c1ec8c228a557ac59a31ea47e21fb856467742e
---
M src/libbsc/handover_logic.c
1 file changed, 4 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/22/5922/1

diff --git a/src/libbsc/handover_logic.c b/src/libbsc/handover_logic.c
index 0b44b2e..3523576 100644
--- a/src/libbsc/handover_logic.c
+++ b/src/libbsc/handover_logic.c
@@ -171,10 +171,8 @@
ho->old_lchan = old_lchan;
ho->new_lchan = new_lchan;
ho->ho_ref = ho_ref++;
-   if (!do_assignment) {
-   ho->inter_cell = true;
-   ho->async = true;
-   }
+   ho->inter_cell = !do_assignment;
+   ho->async = true;
 
LOGPHO(ho, LOGL_INFO, "Triggering %s\n", do_assignment? "Assignment" : 
"Handover");
 
@@ -199,9 +197,7 @@
new_lchan->conn->ho_lchan = new_lchan;
 
rc = rsl_chan_activate_lchan(new_lchan,
-ho->inter_cell
-  ? (ho->async ? RSL_ACT_INTER_ASYNC : 
RSL_ACT_INTER_SYNC)
-  : RSL_ACT_INTRA_IMM_ASS,
+ho->async ? RSL_ACT_INTER_ASYNC : 
RSL_ACT_INTER_SYNC,
 ho->ho_ref);
if (rc < 0) {
LOGPHO(ho, LOGL_INFO, "%s Failure: activate lchan rc = %d\n",
@@ -276,11 +272,7 @@
/* we can now send the 04.08 HANDOVER COMMAND to the MS
 * using the old lchan */
 
-   if (ho->inter_cell) {
-   gsm48_send_rr_ass_cmd(ho->old_lchan, new_lchan, 
new_lchan->ms_power);
-   } else {
-   gsm48_send_ho_cmd(ho->old_lchan, new_lchan, 
new_lchan->ms_power, ho->ho_ref);
-   }
+   gsm48_send_ho_cmd(ho->old_lchan, new_lchan, new_lchan->ms_power, 
ho->ho_ref);
 
/* start T3103.  We can continue either with T3103 expiration,
 * 04.08 HANDOVER COMPLETE or 04.08 HANDOVER FAIL */

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5c1ec8c228a557ac59a31ea47e21fb856467742e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: HO: Add a penalty timer list to the subscriber connection en...

2018-01-18 Thread Neels Hofmeyr

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

HO: Add a penalty timer list to the subscriber connection entity

This penalty timer is used to temporarily block cells where handover
or assignment failed or where handover is not allowed. This is usefull
to prevent repeated handover attempts to broken cells or cells that have
limited allowed distance.

Change-Id: I95cb7e3211b2470b773965e7aa94d8eb6c8c1a3a
---
M include/osmocom/bsc/gsm_data.h
M src/libbsc/bsc_api.c
2 files changed, 20 insertions(+), 0 deletions(-)


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

diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 4e07f26..d9dd2d4 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -71,6 +71,13 @@
uint8_t classmark3[14]; /* if cm3 gets extended by spec, it will be 
truncated */
 };
 
+/* penalty timers for handover */
+struct ho_penalty_timer {
+   struct llist_head entry;
+   uint8_t bts;
+   time_t timeout;
+};
+
 /* active radio connection of a mobile subscriber */
 struct gsm_subscriber_connection {
/* global linked list of subscriber_connections */
@@ -104,6 +111,9 @@
/* Cache DTAP messages during handover/assignment 
(msgb_enqueue()/msgb_dequeue())*/
struct llist_head ho_dtap_cache;
unsigned int ho_dtap_cache_len;
+
+   /* penalty timers for handover */
+   struct llist_head ho_penalty_timers;
 };
 
 static inline struct gsm_bts *conn_get_bts(struct gsm_subscriber_connection 
*conn) {
diff --git a/src/libbsc/bsc_api.c b/src/libbsc/bsc_api.c
index 2a0bf8f..a501db2 100644
--- a/src/libbsc/bsc_api.c
+++ b/src/libbsc/bsc_api.c
@@ -273,6 +273,7 @@
conn->bts = lchan->ts->trx->bts;
lchan->conn = conn;
INIT_LLIST_HEAD(>ho_dtap_cache);
+   INIT_LLIST_HEAD(>ho_penalty_timers);
llist_add_tail(>entry, >subscr_conns);
return conn;
 }
@@ -322,6 +323,8 @@
 
 void bsc_subscr_con_free(struct gsm_subscriber_connection *conn)
 {
+   struct ho_penalty_timer *penalty;
+
if (!conn)
return;
 
@@ -346,6 +349,13 @@
/* drop pending messages */
ho_dtap_cache_flush(conn, 0);
 
+   /* flush handover penalty timers */
+   while ((penalty = llist_first_entry_or_null(>ho_penalty_timers,
+   struct ho_penalty_timer, 
entry))) {
+   llist_del(>entry);
+   talloc_free(penalty);
+   }
+
llist_del(>entry);
talloc_free(conn);
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I95cb7e3211b2470b773965e7aa94d8eb6c8c1a3a
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: HO: add queue to cache DTAP messages during handover/assignment

2018-01-18 Thread Neels Hofmeyr

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

HO: add queue to cache DTAP messages during handover/assignment

Add ho_dtap_cache to gsm_subscriber_connection, a stock msgb queue to be used
with msgb_enqueue() and msgb_dequeue().

Keep a counter of queue length, to enforce a sane maximum counter for cached
messages. So far a hardcoded maximum of 23 messages will be cached.

Have balanced ho_dtap_cache_add() and ho_dtap_cache_flush() functions.

The original patch was by jolly, but I have basically completely replaced it
with the simpler msgb queue pattern.

Change-Id: I6e4d93628befb3d97e5cee0343cd9f8ba0b8620c
---
M include/osmocom/bsc/gsm_data.h
M src/libbsc/bsc_api.c
2 files changed, 77 insertions(+), 0 deletions(-)


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

diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 6659b72..4e07f26 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -100,6 +100,10 @@
 
/* buffer/cache for classmark of the ME of the subscriber */
struct gsm_classmark classmark;
+
+   /* Cache DTAP messages during handover/assignment 
(msgb_enqueue()/msgb_dequeue())*/
+   struct llist_head ho_dtap_cache;
+   unsigned int ho_dtap_cache_len;
 };
 
 static inline struct gsm_bts *conn_get_bts(struct gsm_subscriber_connection 
*conn) {
diff --git a/src/libbsc/bsc_api.c b/src/libbsc/bsc_api.c
index 545cf36..2a0bf8f 100644
--- a/src/libbsc/bsc_api.c
+++ b/src/libbsc/bsc_api.c
@@ -39,6 +39,8 @@
 
 #define GSM0808_T10_VALUE6, 0
 
+#define HO_DTAP_CACHE_MSGB_CB_LINK_ID 0
+#define HO_DTAP_CACHE_MSGB_CB_ALLOW_SACCH 1
 
 static void rll_ind_cb(struct gsm_lchan *, uint8_t, void *, enum bsc_rllr_ind);
 static void send_sapi_reject(struct gsm_subscriber_connection *conn, int 
link_id);
@@ -270,8 +272,52 @@
conn->lchan = lchan;
conn->bts = lchan->ts->trx->bts;
lchan->conn = conn;
+   INIT_LLIST_HEAD(>ho_dtap_cache);
llist_add_tail(>entry, >subscr_conns);
return conn;
+}
+
+static void ho_dtap_cache_add(struct gsm_subscriber_connection *conn, struct 
msgb *msg,
+ int link_id, bool allow_sacch)
+{
+   if (conn->ho_dtap_cache_len >= 23) {
+   LOGP(DHO, LOGL_ERROR, "%s: Cannot cache more DTAP messages,"
+" already reached sane maximum of %u cached messages\n",
+bsc_subscr_name(conn->bsub), conn->ho_dtap_cache_len);
+   msgb_free(msg);
+   return;
+   }
+   conn->ho_dtap_cache_len ++;
+   LOGP(DHO, LOGL_DEBUG, "%s: Caching DTAP message during ho/ass (%u)\n",
+bsc_subscr_name(conn->bsub), conn->ho_dtap_cache_len);
+   msg->cb[HO_DTAP_CACHE_MSGB_CB_LINK_ID] = (unsigned long)link_id;
+   msg->cb[HO_DTAP_CACHE_MSGB_CB_ALLOW_SACCH] = allow_sacch ? 1 : 0;
+   msgb_enqueue(>ho_dtap_cache, msg);
+}
+
+static void ho_dtap_cache_flush(struct gsm_subscriber_connection *conn, int 
send)
+{
+   struct msgb *msg;
+   unsigned int flushed_count = 0;
+
+   if (conn->secondary_lchan || conn->ho_lchan) {
+   LOGP(DHO, LOGL_ERROR, "%s: Cannot send cached DTAP messages, 
handover/assignment is still ongoing\n",
+bsc_subscr_name(conn->bsub));
+   send = 0;
+   }
+
+   while ((msg = msgb_dequeue(>ho_dtap_cache))) {
+   conn->ho_dtap_cache_len --;
+   flushed_count ++;
+   if (send) {
+   int link_id = 
(int)msg->cb[HO_DTAP_CACHE_MSGB_CB_LINK_ID];
+   bool allow_sacch = 
!!msg->cb[HO_DTAP_CACHE_MSGB_CB_ALLOW_SACCH];
+   LOGP(DHO, LOGL_DEBUG, "%s: Sending cached DTAP message 
after handover/assignment (%u/%u)\n",
+bsc_subscr_name(conn->bsub), flushed_count, 
conn->ho_dtap_cache_len);
+   gsm0808_submit_dtap(conn, msg, link_id, allow_sacch);
+   } else
+   msgb_free(msg);
+   }
 }
 
 void bsc_subscr_con_free(struct gsm_subscriber_connection *conn)
@@ -297,6 +343,9 @@
conn->secondary_lchan->conn = NULL;
}
 
+   /* drop pending messages */
+   ho_dtap_cache_flush(conn, 0);
+
llist_del(>entry);
talloc_free(conn);
 }
@@ -319,6 +368,12 @@
 "Called submit dtap without an lchan.\n");
msgb_free(msg);
return -1;
+   }
+
+   /* buffer message during assignment / handover */
+   if (conn->secondary_lchan || conn->ho_lchan) {
+   ho_dtap_cache_add(conn, msg, link_id, !! allow_sacch);
+   return 0;
}
 
sapi = link_id & 0x7;
@@ -454,6 +509,9 @@
osmo_signal_dispatch(SS_LCHAN, S_LCHAN_ASSIGNMENT_COMPL, );
/* FIXME: release old channel */
 
+   /* send pending messages, if any */
+   

[PATCH] osmo-bsc[master]: HO: Add handover decision debugging category

2018-01-18 Thread Neels Hofmeyr

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

HO: Add handover decision debugging category

Change-Id: Iaf99d4e9ae08c38bf364dbb37d42098f976f6b8c
---
M include/osmocom/bsc/debug.h
M src/libcommon/debug.c
2 files changed, 9 insertions(+), 1 deletion(-)


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

diff --git a/include/osmocom/bsc/debug.h b/include/osmocom/bsc/debug.h
index 65e197d..131ae8a 100644
--- a/include/osmocom/bsc/debug.h
+++ b/include/osmocom/bsc/debug.h
@@ -21,6 +21,7 @@
DMSC,
DMGCP,
DHO,
+   DHODEC,
DDB,
DREF,
DGPRS,
diff --git a/src/libcommon/debug.c b/src/libcommon/debug.c
index 68fc597..b5a490b 100644
--- a/src/libcommon/debug.c
+++ b/src/libcommon/debug.c
@@ -106,7 +106,14 @@
},
[DHO] = {
.name = "DHO",
-   .description = "Hand-Over",
+   .description = "Hand-Over Process",
+   .color = "\033[1;38m",
+   .enabled = 1, .loglevel = LOGL_NOTICE,
+   },
+   [DHODEC] = {
+   .name = "DHODEC",
+   .description = "Hand-Over Decision",
+   .color = "\033[1;38m",
.enabled = 1, .loglevel = LOGL_NOTICE,
},
[DDB] = {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf99d4e9ae08c38bf364dbb37d42098f976f6b8c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: HO: Count number of free timeslot on a given BTS

2018-01-18 Thread Neels Hofmeyr

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

HO: Count number of free timeslot on a given BTS

This is needed for handover algorithm to balance free slots and to prevent
congestion of one cell, while other cells still have free capacities.

Change-Id: Ic8bee8a515ee8aa9a99af71756fe60b8dd8f868b
---
M include/osmocom/bsc/chan_alloc.h
M src/libbsc/chan_alloc.c
2 files changed, 67 insertions(+), 0 deletions(-)


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

diff --git a/include/osmocom/bsc/chan_alloc.h b/include/osmocom/bsc/chan_alloc.h
index f2a75c5..748e9cd 100644
--- a/include/osmocom/bsc/chan_alloc.h
+++ b/include/osmocom/bsc/chan_alloc.h
@@ -24,6 +24,9 @@
 
 struct gsm_subscriber_connection;
 
+/* Count number of free TS of given pchan type */
+int bts_count_free_ts(struct gsm_bts *bts, enum gsm_phys_chan_config pchan);
+
 /* Allocate a logical channel (SDCCH, TCH, ...) */
 struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type, int 
allow_bigger);
 
diff --git a/src/libbsc/chan_alloc.c b/src/libbsc/chan_alloc.c
index 9946628..b3056da 100644
--- a/src/libbsc/chan_alloc.c
+++ b/src/libbsc/chan_alloc.c
@@ -68,6 +68,70 @@
return true;
 }
 
+static int trx_count_free_ts(struct gsm_bts_trx *trx, enum 
gsm_phys_chan_config pchan)
+{
+   struct gsm_bts_trx_ts *ts;
+   int j, ss;
+   int count = 0;
+
+   if (!trx_is_usable(trx))
+   return 0;
+
+   for (j = 0; j < 8; j++) {
+   enum gsm_phys_chan_config ts_pchan_is;
+   ts = >ts[j];
+   if (!ts_is_usable(ts))
+   continue;
+
+   ts_pchan_is = ts_pchan(ts);
+
+   if (ts_pchan_is == GSM_PCHAN_PDCH) {
+   /* Dynamic timeslots in PDCH mode will become TCH if 
needed. */
+   switch (ts->pchan) {
+   case GSM_PCHAN_TCH_F_PDCH:
+   if (pchan == GSM_PCHAN_TCH_F)
+   count++;
+   continue;
+
+   case GSM_PCHAN_TCH_F_TCH_H_PDCH:
+   if (pchan == GSM_PCHAN_TCH_F)
+   count++;
+   else if (pchan == GSM_PCHAN_TCH_H)
+   count += 2;
+   continue;
+
+   default:
+   /* Not dynamic, not applicable. */
+   continue;
+   }
+   }
+
+   if (ts_pchan_is != pchan)
+   continue;
+   /* check if all sub-slots are allocated yet */
+   for (ss = 0; ss < ts_subslots(ts); ss++) {
+   struct gsm_lchan *lc = >lchan[ss];
+   if (lc->type == GSM_LCHAN_NONE &&
+   lc->state == LCHAN_S_NONE)
+   count++;
+   }
+   }
+
+   return count;
+}
+
+/* Count number of free TS of given pchan type */
+int bts_count_free_ts(struct gsm_bts *bts, enum gsm_phys_chan_config pchan)
+{
+   struct gsm_bts_trx *trx;
+   int count = 0;
+
+   llist_for_each_entry(trx, >trx_list, list)
+   count += trx_count_free_ts(trx, pchan);
+
+   return count;
+}
+
 static struct gsm_lchan *
 _lc_find_trx(struct gsm_bts_trx *trx, enum gsm_phys_chan_config pchan,
 enum gsm_phys_chan_config dyn_as_pchan)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic8bee8a515ee8aa9a99af71756fe60b8dd8f868b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: Do not perform assignment, if the new channel equals the cur...

2018-01-18 Thread Neels Hofmeyr

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

Do not perform assignment, if the new channel equals the current one

This can happen, if a TCH/H was requested, but because it is not available,
a TCH/F is allocated. If the old channel was TCH/F already, it makes no
sense to assign it.

Change-Id: I284125483fc14b8f82e32ee61aa3866746238eae
---
M src/libbsc/bsc_api.c
1 file changed, 7 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/08/5908/1

diff --git a/src/libbsc/bsc_api.c b/src/libbsc/bsc_api.c
index ec64bb8..53d0281 100644
--- a/src/libbsc/bsc_api.c
+++ b/src/libbsc/bsc_api.c
@@ -221,6 +221,13 @@
return -1;
}
 
+   /* check if we are on TCH/F and requested TCH/H, but got TCH/F */
+   if (conn->lchan->type == new_lchan->type) {
+   lchan_free(new_lchan);
+   LOGP(DMSC, LOGL_NOTICE, "Not assign to equal channel rate.\n");
+   return -1;
+   }
+
/* copy old data to the new channel */
memcpy(_lchan->encr, >lchan->encr, sizeof(new_lchan->encr));
new_lchan->ms_power = conn->lchan->ms_power;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I284125483fc14b8f82e32ee61aa3866746238eae
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: HO: add algorithm cfg; skip HO 1 if HO 2 is configured

2018-01-18 Thread Neels Hofmeyr

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

HO: add algorithm cfg; skip HO 1 if HO 2 is configured

Change-Id: If07c0a7b84937ab92948e9b71b2496a765946020
---
M include/osmocom/bsc/handover_cfg.h
M src/libbsc/handover_decision.c
2 files changed, 13 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/13/5913/1

diff --git a/include/osmocom/bsc/handover_cfg.h 
b/include/osmocom/bsc/handover_cfg.h
index 264cb1b..e281c3f 100644
--- a/include/osmocom/bsc/handover_cfg.h
+++ b/include/osmocom/bsc/handover_cfg.h
@@ -60,6 +60,15 @@
"Enable in-call handover\n" \
"Enable/disable handover: ") \
\
+   HO_CFG_ONE_MEMBER(int, algorithm, 1, \
+   "handover algorithm", "1|2", atoi, "%d", as_is, \
+   HO_CFG_STR_HANDOVER \
+   "Choose algorithm for handover decision\n" \
+   "Algorithm 1: trigger handover based on comparing current cell 
and neighbor RxLev and RxQual," \
+   " only.\n" \
+   "Algorithm 2: trigger handover on RxLev/RxQual, and also to 
balance the load across several" \
+   " cells. Consider available codecs. Prevent repeated handover 
by penalty timers.\n") \
+   \
HO_CFG_ONE_MEMBER(unsigned int, rxlev_avg_win, 10, \
"handover window rxlev averaging", "<1-10>", atoi, "%u", as_is, 
\
HO_CFG_STR_WIN_RXLEV \
diff --git a/src/libbsc/handover_decision.c b/src/libbsc/handover_decision.c
index 158fc1c..1e2e0d9 100644
--- a/src/libbsc/handover_decision.c
+++ b/src/libbsc/handover_decision.c
@@ -265,6 +265,10 @@
int av_rxlev;
unsigned int pwr_interval;
 
+   /* If this cell does not use handover algorithm 1, then we're not 
responsible. */
+   if (ho_get_algorithm(bts->ho) != 1)
+   return 0;
+
/* we currently only do handover for TCH channels */
switch (mr->lchan->type) {
case GSM_LCHAN_TCH_F:

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If07c0a7b84937ab92948e9b71b2496a765946020
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: Allow assignment to TCH channel with signalling only mode

2018-01-18 Thread Neels Hofmeyr

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

Allow assignment to TCH channel with signalling only mode

This makes sense, if silent call is used. Assignment allows to change from
SDCCH (or whatever was available) to given TCH rate.

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


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

diff --git a/src/libbsc/bsc_api.c b/src/libbsc/bsc_api.c
index 53d0281..545cf36 100644
--- a/src/libbsc/bsc_api.c
+++ b/src/libbsc/bsc_api.c
@@ -236,7 +236,8 @@
 
/* copy new data to it */
new_lchan->tch_mode = chan_mode;
-   new_lchan->rsl_cmode = RSL_CMOD_SPD_SPEECH;
+   new_lchan->rsl_cmode = (chan_mode == GSM48_CMODE_SIGN) ?
+   RSL_CMOD_SPD_SIGN : RSL_CMOD_SPD_SPEECH;
 
/* handle AMR correctly */
if (chan_mode == GSM48_CMODE_SPEECH_AMR)
@@ -354,8 +355,6 @@
 {
switch (chan_mode) {
case GSM48_CMODE_SIGN:
-   /* signalling is always possible */
-   return 1;
case GSM48_CMODE_SPEECH_V1:
case GSM48_CMODE_SPEECH_AMR:
case GSM48_CMODE_DATA_3k6:

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2efe9d7ab429e902581ebb9e0e006f2aec6d8972
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: HO: enable handover by initializing at startup; rename init ...

2018-01-18 Thread Neels Hofmeyr

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

HO: enable handover by initializing at startup; rename init function

Change-Id: I224884c84895ebf6c8cf498c16616214cb2b5779
---
M include/osmocom/bsc/handover_decision.h
M src/libbsc/handover_decision.c
M src/osmo-bsc/osmo_bsc_main.c
3 files changed, 6 insertions(+), 7 deletions(-)


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

diff --git a/include/osmocom/bsc/handover_decision.h 
b/include/osmocom/bsc/handover_decision.h
index 81078b0..fe551ca 100644
--- a/include/osmocom/bsc/handover_decision.h
+++ b/include/osmocom/bsc/handover_decision.h
@@ -1,7 +1,3 @@
-#ifndef _HANDOVER_DECISION_H
-#define _HANDOVER_DECISION_H
+#pragma once
 
-void on_dso_load_ho_dec(void);
-
-#endif /* _HANDOVER_DECISION_H */
-
+void handover_decision_1_init(void);
diff --git a/src/libbsc/handover_decision.c b/src/libbsc/handover_decision.c
index 127b362..158fc1c 100644
--- a/src/libbsc/handover_decision.c
+++ b/src/libbsc/handover_decision.c
@@ -343,7 +343,7 @@
return 0;
 }
 
-void on_dso_load_ho_dec(void)
+void handover_decision_1_init(void)
 {
osmo_signal_register_handler(SS_LCHAN, ho_dec_sig_cb, NULL);
 }
diff --git a/src/osmo-bsc/osmo_bsc_main.c b/src/osmo-bsc/osmo_bsc_main.c
index 1555ac1..1aff4c5 100644
--- a/src/osmo-bsc/osmo_bsc_main.c
+++ b/src/osmo-bsc/osmo_bsc_main.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -296,6 +297,8 @@
 
mgcp_init(bsc_gsmnet);
 
+   handover_decision_1_init();
+
signal(SIGINT, _handler);
signal(SIGTERM, _handler);
signal(SIGABRT, _handler);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I224884c84895ebf6c8cf498c16616214cb2b5779
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: fixup: neigh_meas_avg: fix condition to reduce window size

2018-01-18 Thread Neels Hofmeyr

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

fixup: neigh_meas_avg: fix condition to reduce window size

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


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/03/5903/1

diff --git a/src/libbsc/handover_decision.c b/src/libbsc/handover_decision.c
index 1ad4b36..127b362 100644
--- a/src/libbsc/handover_decision.c
+++ b/src/libbsc/handover_decision.c
@@ -100,7 +100,7 @@
int avg = 0;
 
/* reduce window to the actual number of existing measurements */
-   if (window < nmp->rxlev_cnt)
+   if (window > nmp->rxlev_cnt)
window = nmp->rxlev_cnt;
/* this should never happen */
if (window <= 0) {

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

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


[PATCH] osmo-bsc[master]: HO: make bts_by_arfcn_bsic() public

2018-01-18 Thread Neels Hofmeyr

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

HO: make bts_by_arfcn_bsic() public

Change-Id: Ie746f76433f6b46a71a91b7714cc034c4355d993
---
M include/osmocom/bsc/handover_decision.h
M src/libbsc/handover_decision.c
2 files changed, 4 insertions(+), 2 deletions(-)


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

diff --git a/include/osmocom/bsc/handover_decision.h 
b/include/osmocom/bsc/handover_decision.h
index fe551ca..09430d8 100644
--- a/include/osmocom/bsc/handover_decision.h
+++ b/include/osmocom/bsc/handover_decision.h
@@ -1,3 +1,5 @@
 #pragma once
 
+struct gsm_bts *bts_by_arfcn_bsic(const struct gsm_network *net, uint16_t 
arfcn, uint8_t bsic);
+
 void handover_decision_1_init(void);
diff --git a/src/libbsc/handover_decision.c b/src/libbsc/handover_decision.c
index 93ca28b..19fb3ab 100644
--- a/src/libbsc/handover_decision.c
+++ b/src/libbsc/handover_decision.c
@@ -36,8 +36,8 @@
 #include 
 
 /* Find BTS by ARFCN and BSIC */
-static struct gsm_bts *bts_by_arfcn_bsic(const struct gsm_network *net,
-uint16_t arfcn, uint8_t bsic)
+struct gsm_bts *bts_by_arfcn_bsic(const struct gsm_network *net,
+ uint16_t arfcn, uint8_t bsic)
 {
struct gsm_bts *bts;
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie746f76433f6b46a71a91b7714cc034c4355d993
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: Correctly set T3105 for ipaccess BTS type

2018-01-18 Thread Neels Hofmeyr

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

Correctly set T3105 for ipaccess BTS type

The given value is 10 * ms, so 13 is used instead of 128.

If T3105 is set at config to something greater 0, it is used instead of
the default value.

Adjusst nanobts_omlattr_test.c accordingly.

Change-Id: I3d9687619ba4de35f5d2eff3026d903534b2bbd4
---
M src/libbsc/bts_ipaccess_nanobts_omlattr.c
M tests/nanobts_omlattr/nanobts_omlattr_test.c
M tests/nanobts_omlattr/nanobts_omlattr_test.ok
3 files changed, 5 insertions(+), 5 deletions(-)


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

diff --git a/src/libbsc/bts_ipaccess_nanobts_omlattr.c 
b/src/libbsc/bts_ipaccess_nanobts_omlattr.c
index 22ae484..926322c 100644
--- a/src/libbsc/bts_ipaccess_nanobts_omlattr.c
+++ b/src/libbsc/bts_ipaccess_nanobts_omlattr.c
@@ -89,8 +89,8 @@
}
msgb_tv_fixed_put(msgb, NM_ATT_LDAVG_SLOTS, 2, buf);
 
-   /* miliseconds */
-   msgb_tv_put(msgb, NM_ATT_BTS_AIR_TIMER, 128);
+   /* 10 milliseconds */
+   msgb_tv_put(msgb, NM_ATT_BTS_AIR_TIMER, bts->network->T3105 > 0? 
bts->network->T3105 : 13);
 
/* 10 retransmissions of physical config */
msgb_tv_put(msgb, NM_ATT_NY1, 10);
diff --git a/tests/nanobts_omlattr/nanobts_omlattr_test.c 
b/tests/nanobts_omlattr/nanobts_omlattr_test.c
index cdb37a3..674148a 100644
--- a/tests/nanobts_omlattr/nanobts_omlattr_test.c
+++ b/tests/nanobts_omlattr/nanobts_omlattr_test.c
@@ -219,7 +219,7 @@
0x02, 0x01, 0x20, 0x33, 0x1e, 0x24, 0x24, 0xa8, 0x34, 0x21,
0xa8, 0x1f, 0x3f, 0x25,
0x00, 0x01, 0x0a, 0x0c, 0x0a, 0x0b, 0x01, 0x2a, 0x0a, 0x2b,
-   0x03, 0xe8, 0x0a, 0x80,
+   0x03, 0xe8, 0x0a, 0x0d,
0x23, 0x0a, 0x08, 0x03, 0x62, 0x09, 0x3f, 0x99, 0x00, 0x07,
0x00, 0xf1, 0x10, 0x00,
0x01, 0x05, 0x39
diff --git a/tests/nanobts_omlattr/nanobts_omlattr_test.ok 
b/tests/nanobts_omlattr/nanobts_omlattr_test.ok
index 91b655f..9504c09 100644
--- a/tests/nanobts_omlattr/nanobts_omlattr_test.ok
+++ b/tests/nanobts_omlattr/nanobts_omlattr_test.ok
@@ -1,6 +1,6 @@
 Testing nanobts_attr_bts_get()...
-result=  
19555b61676d7318060e00020120331e2424a83421a81f3f2500010a0c0a0b012a0a2b03e80a80230a080362093f99000700f1110539
-expected=19555b61676d7318060e00020120331e2424a83421a81f3f2500010a0c0a0b012a0a2b03e80a80230a080362093f99000700f1110539
+result=  
19555b61676d7318060e00020120331e2424a83421a81f3f2500010a0c0a0b012a0a2b03e80a0d230a080362093f99000700f1110539
+expected=19555b61676d7318060e00020120331e2424a83421a81f3f2500010a0c0a0b012a0a2b03e80a0d230a080362093f99000700f1110539
 ok.
 
 Testing nanobts_attr_nse_get()...

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3d9687619ba4de35f5d2eff3026d903534b2bbd4
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: HO: Always update rqd_ta after receiving measurement report

2018-01-18 Thread Neels Hofmeyr

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

HO: Always update rqd_ta after receiving measurement report

The up-to-date rqd_ta is required for assignment command. If the phone
moves, the timing advance might change. The rqd_ta will be updated by
each measurement report.

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


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/05/5905/1

diff --git a/src/libbsc/abis_rsl.c b/src/libbsc/abis_rsl.c
index d535717..bdd86a9 100644
--- a/src/libbsc/abis_rsl.c
+++ b/src/libbsc/abis_rsl.c
@@ -1512,6 +1512,8 @@
if (msg->lchan->ts->trx->bts->type == GSM_BTS_TYPE_BS11
 || msg->lchan->ts->trx->bts->type == GSM_BTS_TYPE_NOKIA_SITE)
mr->ms_l1.ta >>= 2;
+   /* store TA for next assignment/handover */
+   mr->lchan->rqd_ta = mr->ms_l1.ta;
}
if (TLVP_PRESENT(, RSL_IE_L3_INFO)) {
msg->l3h = (uint8_t *) TLVP_VAL(, RSL_IE_L3_INFO);

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

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


[PATCH] osmo-bsc[master]: HO: Change debug category at handover decision: DHO -> DHODEC

2018-01-18 Thread Neels Hofmeyr

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

HO: Change debug category at handover decision: DHO -> DHODEC

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


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

diff --git a/src/libbsc/handover_decision.c b/src/libbsc/handover_decision.c
index 1e2e0d9..0693613 100644
--- a/src/libbsc/handover_decision.c
+++ b/src/libbsc/handover_decision.c
@@ -65,7 +65,7 @@
/* resolve the gsm_bts structure for the best neighbor */
new_bts = gsm_bts_neighbor(lchan->ts->trx->bts, arfcn, bsic);
if (!new_bts) {
-   LOGP(DHO, LOGL_NOTICE, "unable to determine neighbor BTS "
+   LOGP(DHODEC, LOGL_NOTICE, "unable to determine neighbor BTS "
 "for ARFCN %u BSIC %u ?!?\n", arfcn, bsic);
return -EINVAL;
}
@@ -104,7 +104,7 @@
window = nmp->rxlev_cnt;
/* this should never happen */
if (window <= 0) {
-   LOGP(DHO, LOGL_ERROR, "Requested Neighbor RxLev for invalid 
window size of %d\n", window);
+   LOGP(DHODEC, LOGL_ERROR, "Requested Neighbor RxLev for invalid 
window size of %d\n", window);
return 0;
}
 
@@ -232,26 +232,26 @@
if (!best_cell)
return 0;
 
-   LOGP(DHO, LOGL_INFO, "%s: Cell on ARFCN %u is better: ",
+   LOGP(DHODEC, LOGL_INFO, "%s: Cell on ARFCN %u is better: ",
gsm_ts_name(mr->lchan->ts), best_cell->arfcn);
if (!ho_get_ho_active(bts->ho)) {
-   LOGPC(DHO, LOGL_INFO, "Skipping, Handover disabled\n");
+   LOGPC(DHODEC, LOGL_INFO, "Skipping, Handover disabled\n");
return 0;
}
 
rc = handover_to_arfcn_bsic(mr->lchan, best_cell->arfcn, 
best_cell->bsic);
switch (rc) {
case 0:
-   LOGPC(DHO, LOGL_INFO, "Starting handover: meas report number %d 
\n", mr->nr);
+   LOGPC(DHODEC, LOGL_INFO, "Starting handover: meas report number 
%d \n", mr->nr);
break;
case -ENOSPC:
-   LOGPC(DHO, LOGL_INFO, "No channel available\n");
+   LOGPC(DHODEC, LOGL_INFO, "No channel available\n");
break;
case -EBUSY:
-   LOGPC(DHO, LOGL_INFO, "Handover already active\n");
+   LOGPC(DHODEC, LOGL_INFO, "Handover already active\n");
break;
default:
-   LOGPC(DHO, LOGL_ERROR, "Unknown error\n");
+   LOGPC(DHODEC, LOGL_ERROR, "Unknown error\n");
}
return rc;
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7322b790f647b681bfe3a9c95b04516fbc7cbf88
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: HO: Implement load based handover, as handover_decision_2.c

2018-01-18 Thread Neels Hofmeyr

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

HO: Implement load based handover, as handover_decision_2.c

Change-Id: Ice2d3ef5668564a9d3bc4d5118d59dfaa9af6978
---
M configure.ac
M include/osmocom/bsc/Makefile.am
M include/osmocom/bsc/gsm_data.h
M include/osmocom/bsc/gsm_data_shared.h
M include/osmocom/bsc/handover.h
M include/osmocom/bsc/handover_cfg.h
A include/osmocom/bsc/handover_decision_2.h
M include/osmocom/bsc/handover_vty.h
M include/osmocom/bsc/signal.h
M src/libbsc/Makefile.am
M src/libbsc/abis_rsl.c
M src/libbsc/bsc_api.c
M src/libbsc/bsc_vty.c
M src/libbsc/chan_alloc.c
A src/libbsc/handover_decision_2.c
M src/libbsc/handover_logic.c
M src/libbsc/handover_vty.c
M src/libbsc/net_init.c
M src/libcommon/gsm_data.c
M src/libcommon/handover_cfg.c
M src/osmo-bsc/osmo_bsc_bssap.c
M src/osmo-bsc/osmo_bsc_main.c
M tests/Makefile.am
A tests/handover/Makefile.am
A tests/handover/handover_test.c
A tests/handover/handover_test.ok
M tests/testsuite.at
27 files changed, 3,861 insertions(+), 73 deletions(-)


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

diff --git a/configure.ac b/configure.ac
index d756970..fc4678f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -166,6 +166,7 @@
 tests/subscr/Makefile
 tests/nanobts_omlattr/Makefile
 tests/bssap/Makefile
+tests/handover/Makefile
 doc/Makefile
 doc/examples/Makefile
 Makefile)
diff --git a/include/osmocom/bsc/Makefile.am b/include/osmocom/bsc/Makefile.am
index 699aeb3..a3d9adf 100644
--- a/include/osmocom/bsc/Makefile.am
+++ b/include/osmocom/bsc/Makefile.am
@@ -27,6 +27,7 @@
handover.h \
handover_cfg.h \
handover_decision.h \
+   handover_decision_2.h \
handover_vty.h \
ipaccess.h \
meas_feed.h \
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index d9dd2d4..c24e22a 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -74,8 +75,8 @@
 /* penalty timers for handover */
 struct ho_penalty_timer {
struct llist_head entry;
-   uint8_t bts;
-   time_t timeout;
+   uint8_t bts_nr;
+   unsigned int timeout;
 };
 
 /* active radio connection of a mobile subscriber */
@@ -112,8 +113,18 @@
struct llist_head ho_dtap_cache;
unsigned int ho_dtap_cache_len;
 
-   /* penalty timers for handover */
+   /* failure count and penalty timers for handover */
+   int ho_failure;
struct llist_head ho_penalty_timers;
+
+   /* "Codec List (MSC Preferred)" as received by the BSSAP Assignment 
Request. 3GPP 48.008
+* 3.2.2.103 says:
+* The "Codec List (MSC Preferred)" shall not include codecs
+* that are not supported by the MS.
+* i.e. by heeding the "Codec list (MSC Preferred)", we inherently heed 
the MS bearer
+* capabilities, which the MSC is required to translate into the codec 
list. */
+   struct gsm0808_speech_codec_list codec_list;
+   bool codec_list_present;
 };
 
 static inline struct gsm_bts *conn_get_bts(struct gsm_subscriber_connection 
*conn) {
@@ -243,7 +254,12 @@
uint16_t network_code;
int a5_encryption;
int neci;
+
struct handover_cfg *ho;
+   struct {
+   unsigned int congestion_check_interval_s;
+   struct osmo_timer_list congestion_check_timer;
+   } ho2;
 
struct rate_ctr_group *bsc_ctrs;
 
@@ -443,4 +459,11 @@
 
 bool classmark_is_r99(struct gsm_classmark *cm);
 
+void conn_penalty_timer_add(struct gsm_subscriber_connection *conn,
+   struct gsm_bts *bts, int timeout);
+unsigned int conn_penalty_timer_remaining(struct gsm_subscriber_connection 
*conn,
+ struct gsm_bts *bts);
+void conn_penalty_timer_clear(struct gsm_subscriber_connection *conn,
+ struct gsm_bts *bts);
+
 #endif /* _GSM_DATA_H */
diff --git a/include/osmocom/bsc/gsm_data_shared.h 
b/include/osmocom/bsc/gsm_data_shared.h
index 86c5ca9..776e047 100644
--- a/include/osmocom/bsc/gsm_data_shared.h
+++ b/include/osmocom/bsc/gsm_data_shared.h
@@ -269,6 +269,7 @@
struct gsm_meas_rep meas_rep[MAX_MEAS_REP];
int meas_rep_idx;
int meas_rep_count;
+   uint8_t meas_rep_last_seen_nr;
 
/* GSM Random Access data */
struct gsm48_req_ref *rqd_ref;
diff --git a/include/osmocom/bsc/handover.h b/include/osmocom/bsc/handover.h
index a9349ee..f764456 100644
--- a/include/osmocom/bsc/handover.h
+++ b/include/osmocom/bsc/handover.h
@@ -5,6 +5,8 @@
 struct gsm_subscriber_connection;
 
 int bsc_handover_start(struct gsm_lchan *old_lchan, struct gsm_bts *bts);
+int bsc_handover_start_lchan_change(struct gsm_lchan *old_lchan, struct 
gsm_bts *bts,
+   enum gsm_chan_t new_lchan_type);
 void bsc_clear_handover(struct 

[PATCH] osmo-bsc[master]: Fix: meas_rep.c will only use valid DL measurement reports

2018-01-18 Thread Neels Hofmeyr

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

Fix: meas_rep.c will only use valid DL measurement reports

When averaging measurements, only the valid reports are used. If there is
no valid report in the averaging window at all, an error is returned.

Change-Id: I33056225ead788340755e98113d72e1cbf3ebce6
---
M src/libbsc/meas_rep.c
1 file changed, 19 insertions(+), 4 deletions(-)


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

diff --git a/src/libbsc/meas_rep.c b/src/libbsc/meas_rep.c
index fbd1515..73d9a1f 100644
--- a/src/libbsc/meas_rep.c
+++ b/src/libbsc/meas_rep.c
@@ -29,12 +29,20 @@
 {
switch (field) {
case MEAS_REP_DL_RXLEV_FULL:
+   if (!(rep->flags & MEAS_REP_F_DL_VALID))
+   return -EINVAL;
return rep->dl.full.rx_lev;
case MEAS_REP_DL_RXLEV_SUB:
+   if (!(rep->flags & MEAS_REP_F_DL_VALID))
+   return -EINVAL;
return rep->dl.sub.rx_lev;
case MEAS_REP_DL_RXQUAL_FULL:
+   if (!(rep->flags & MEAS_REP_F_DL_VALID))
+   return -EINVAL;
return rep->dl.full.rx_qual;
case MEAS_REP_DL_RXQUAL_SUB:
+   if (!(rep->flags & MEAS_REP_F_DL_VALID))
+   return -EINVAL;
return rep->dl.sub.rx_qual;
case MEAS_REP_UL_RXLEV_FULL:
return rep->ul.full.rx_lev;
@@ -73,7 +81,7 @@
 enum meas_rep_field field, unsigned int num)
 {
unsigned int i, idx;
-   int avg = 0;
+   int avg = 0, valid_num = 0;
 
if (num < 1)
return -EINVAL;
@@ -86,11 +94,18 @@
 
for (i = 0; i < num; i++) {
int j = (idx+i) % ARRAY_SIZE(lchan->meas_rep);
+   int val = get_field(>meas_rep[j], field);
 
-   avg += get_field(>meas_rep[j], field);
+   if (val >= 0) {
+   avg += val;
+   valid_num++;
+   }
}
 
-   return avg / num;
+   if (valid_num == 0)
+   return -EINVAL;
+
+   return avg / valid_num;
 }
 
 /* Check if N out of M last values for FIELD are >= bd */
@@ -108,7 +123,7 @@
int j = (idx + i) % ARRAY_SIZE(lchan->meas_rep);
int val = get_field(>meas_rep[j], field);
 
-   if (val >= be)
+   if (val >= be) /* implies that val < 0 will not count */
count++;
 
if (count >= n)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I33056225ead788340755e98113d72e1cbf3ebce6
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: HO: add handover algo 2 configuration parameters

2018-01-18 Thread Neels Hofmeyr

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

HO: add handover algo 2 configuration parameters

Change-Id: I8811ee8a75be09048042b511ee4bd9bc1de63976
---
M include/osmocom/bsc/handover_cfg.h
M tests/handover_cfg.vty
2 files changed, 361 insertions(+), 13 deletions(-)


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

diff --git a/include/osmocom/bsc/handover_cfg.h 
b/include/osmocom/bsc/handover_cfg.h
index e281c3f..1b81235 100644
--- a/include/osmocom/bsc/handover_cfg.h
+++ b/include/osmocom/bsc/handover_cfg.h
@@ -1,6 +1,7 @@
 #pragma once
 
 #include 
+#include 
 
 struct vty;
 
@@ -17,6 +18,11 @@
 #define HO_CFG_STR_WIN_RXQUAL HO_CFG_STR_WIN "Received-Quality averaging\n"
 #define HO_CFG_STR_POWER_BUDGET HO_CFG_STR_HANDOVER "Neighbor cell power 
triggering\n" "Neighbor cell power triggering\n"
 #define HO_CFG_STR_AVG_COUNT "Number of values to average over\n"
+#define HO_CFG_STR_2 " (HO algo 2 only)\n"
+#define HO_CFG_STR_MIN "Minimum Level/Quality thresholds before triggering HO" 
HO_CFG_STR_2
+#define HO_CFG_STR_AFS_BIAS "Configure bias to prefer AFS (AMR on TCH/F) over 
other codecs" HO_CFG_STR_2
+#define HO_CFG_STR_MIN_TCH "Minimum free TCH timeslots before cell is 
considered congested" HO_CFG_STR_2
+#define HO_CFG_STR_PENALTY_TIME "Set penalty times to wait between repeated 
handovers" HO_CFG_STR_2
 
 #define as_is(x) (x)
 
@@ -30,6 +36,33 @@
return arg? 1 : 0;
 }
 
+static inline bool a2tdma(const char *arg)
+{
+   if (!strcmp(arg, "full"))
+   return true;
+   return false;
+}
+
+static inline const char *tdma2a(bool val)
+{
+   return val? "full" : "subset";
+}
+
+static inline const int a2congestion_check_interval(const char *arg)
+{
+   if (!strcmp(arg, "disabled"))
+   return 0;
+   return atoi(arg);
+}
+
+static inline const char *congestion_check_interval2a(int val)
+{
+   static char str[9];
+   if (val < 1
+   || snprintf(str, sizeof(str), "%d", val) >= sizeof(str))
+   return "disabled";
+   return str;
+}
 
 /* The HO_CFG_ONE_MEMBER macro gets redefined, depending on whether to define 
struct members,
  * function declarations or definitions... It is of the format
@@ -106,7 +139,104 @@
"Maximum Timing-Advance value (i.e. MS distance) before 
triggering HO\n" \
"Maximum Timing-Advance value (i.e. MS distance) before 
triggering HO\n" \
"Maximum Timing-Advance value (i.e. MS distance) before 
triggering HO\n") \
-
+   \
+   HO_CFG_ONE_MEMBER(bool, as_active, 0, \
+   "handover assignment", "0|1", a2bool, "%d", bool2i, \
+   HO_CFG_STR_HANDOVER \
+   "Enable or disable in-call channel re-assignment" HO_CFG_STR_2 \
+   "Disable in-call assignment\n" \
+   "Enable in-call assignment\n") \
+   \
+   HO_CFG_ONE_MEMBER(int, congestion_check_interval, 10, \
+   "handover congestion-check", "disabled|<1-60>", \
+   a2congestion_check_interval, "%s", congestion_check_interval2a, 
\
+   HO_CFG_STR_HANDOVER \
+   "Configure congestion check interval" HO_CFG_STR_2 \
+   "Disable congestion checking, do not handover based on cell 
overload\n" \
+   "Congestion check interval in seconds\n") \
+   \
+   HO_CFG_ONE_MEMBER(bool, full_tdma, subset, \
+   "handover tdma-measurement", "full|subset", a2tdma, "%s", 
tdma2a, \
+   HO_CFG_STR_HANDOVER \
+   "Define measurement set of TDMA frames" HO_CFG_STR_2 \
+   "Full set of 102/104 TDMA frames\n" \
+   "Sub set of 4 TDMA frames (SACCH)\n") \
+   \
+   HO_CFG_ONE_MEMBER(int, min_rxlev, -100, \
+   "handover min rxlev", "<-110--50>", atoi, "%d", as_is, \
+   HO_CFG_STR_HANDOVER \
+   HO_CFG_STR_MIN \
+   "How weak may RxLev of an MS become before triggering HO\n" \
+   "minimum RxLev (dBm)\n") \
+   \
+   HO_CFG_ONE_MEMBER(int, min_rxqual, 5, \
+   "handover min rxqual", "<0-7>", atoi, "%d", as_is, \
+   HO_CFG_STR_HANDOVER \
+   HO_CFG_STR_MIN \
+   "How bad may RxQual of an MS become before triggering HO\n" \
+   "minimum RxQual (dBm)\n") \
+   \
+   HO_CFG_ONE_MEMBER(int, afs_bias_rxlev, 0, \
+   "handover afs-bias rxlev", "<0-20>", atoi, "%d", as_is, \
+   HO_CFG_STR_HANDOVER \
+   HO_CFG_STR_AFS_BIAS \
+   "RxLev improvement bias for AFS over other codecs\n" \
+   "Virtual RxLev improvement (dBm)\n") \
+   \
+   HO_CFG_ONE_MEMBER(int, afs_bias_rxqual, 0, \
+   "handover afs-bias rxqual", "<0-7>", atoi, "%d", as_is, \
+   HO_CFG_STR_HANDOVER \
+   HO_CFG_STR_AFS_BIAS \
+   "RxQual improvement bias for AFS over other codecs\n" \
+  

[PATCH] osmo-bsc[master]: vty: add various manual handover and assignment trigger comm...

2018-01-18 Thread Neels Hofmeyr

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

vty: add various manual handover and assignment trigger commands

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


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/89/5889/1

diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index e60bdaf..d582802 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -1342,12 +1342,27 @@
return CMD_SUCCESS;
 }
 
-DEFUN(handover_subscr_conn,
-  handover_subscr_conn_cmd,
-  "handover <0-255> <0-255> <0-7> LCHAN_NR <0-255>",
-  "Handover subscriber connection to other BTS\n"
-  "BTS Number (current)\n" "TRX Number\n" "Timeslot Number\n"
-  LCHAN_NR_STR "BTS Number (new)\n")
+static int trigger_ho_or_as(struct vty *vty, struct gsm_lchan *from_lchan, 
struct gsm_bts *to_bts)
+{
+   int rc;
+
+   if (!to_bts || from_lchan->ts->trx->bts == to_bts) {
+   LOGP(DHO, LOGL_NOTICE, "%s Manually triggering Assignment from 
VTY\n",
+gsm_lchan_name(from_lchan));
+   to_bts = from_lchan->ts->trx->bts;
+   } else
+   LOGP(DHO, LOGL_NOTICE, "%s (ARFCN %u) --> BTS %u Manually 
triggering Handover from VTY\n",
+gsm_lchan_name(from_lchan), from_lchan->ts->trx->arfcn, 
to_bts->nr);
+   rc = bsc_handover_start(from_lchan, to_bts);
+   if (rc) {
+   vty_out(vty, "bsc_handover_start() returned %d=%s%s", rc,
+   strerror(-rc), VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+   return CMD_SUCCESS;
+}
+
+static int ho_or_as(struct vty *vty, const char *argv[], int argc)
 {
struct gsm_network *net = gsmnet_from_vty(vty);
struct gsm_subscriber_connection *conn;
@@ -1357,41 +1372,190 @@
unsigned int trx_nr = atoi(argv[1]);
unsigned int ts_nr = atoi(argv[2]);
unsigned int ss_nr = atoi(argv[3]);
-   unsigned int bts_nr_new = atoi(argv[4]);
+   unsigned int bts_nr_new;
+   const char *action;
 
-   /* Lookup the BTS where we want to handover to */
-   llist_for_each_entry(bts, >bts_list, list) {
-   if (bts->nr == bts_nr_new) {
-   new_bts = bts;
-   break;
+   if (argc > 4) {
+   bts_nr_new = atoi(argv[4]);
+
+   /* Lookup the BTS where we want to handover to */
+   llist_for_each_entry(bts, >bts_list, list) {
+   if (bts->nr == bts_nr_new) {
+   new_bts = bts;
+   break;
+   }
+   }
+
+   if (!new_bts) {
+   vty_out(vty, "Unable to trigger handover, specified bts 
#%u does not exist %s",
+   bts_nr_new, VTY_NEWLINE);
+   return CMD_WARNING;
}
}
 
-   if (!new_bts) {
-   vty_out(vty, "Unable to trigger handover,"
-   "specified bts #%u does not exist %s", bts_nr_new,
-   VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   action = new_bts ? "handover" : "assignment";
 
/* Find the connection/lchan that we want to handover */
llist_for_each_entry(conn, >subscr_conns, entry) {
if (conn_get_bts(conn)->nr == bts_nr &&
conn->lchan->ts->trx->nr == trx_nr &&
conn->lchan->ts->nr == ts_nr && conn->lchan->nr == ss_nr) {
-   vty_out(vty, "starting handover for lchan %s...%s",
-   conn->lchan->name, VTY_NEWLINE);
+   vty_out(vty, "starting %s for lchan %s...%s", action, 
conn->lchan->name, VTY_NEWLINE);
lchan_dump_full_vty(vty, conn->lchan);
-   bsc_handover_start(conn->lchan, new_bts);
-   return CMD_SUCCESS;
+   return trigger_ho_or_as(vty, conn->lchan, new_bts);
}
}
 
-   vty_out(vty, "Unable to trigger handover,"
-   "specified connection (bts=%u,trx=%u,ts=%u,ss=%u) does not 
exist%s",
-   bts_nr, trx_nr, ts_nr, ss_nr, VTY_NEWLINE);
+   vty_out(vty, "Unable to trigger %s, specified connection 
(bts=%u,trx=%u,ts=%u,ss=%u) does not exist%s",
+   action, bts_nr, trx_nr, ts_nr, ss_nr, VTY_NEWLINE);
 
return CMD_WARNING;
+}
+
+#define MANUAL_HANDOVER_STR "Manually trigger handover (for debugging)\n"
+#define MANUAL_ASSIGNMENT_STR "Manually trigger assignment (for debugging)\n"
+
+DEFUN(handover_subscr_conn,
+  handover_subscr_conn_cmd,
+  "handover <0-255> <0-255> <0-7> LCHAN_NR <0-255>",
+  MANUAL_HANDOVER_STR
+  "BTS Number (current)\n" "TRX Number\n" "Timeslot Number\n"
+  LCHAN_NR_STR "BTS Number (new)\n")
+{
+   return ho_or_as(vty, argv, 

[PATCH] osmo-bsc[master]: fixup: neigh_meas_avg: detect invalid window size as <=0, lo...

2018-01-18 Thread Neels Hofmeyr

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

fixup: neigh_meas_avg: detect invalid window size as <=0, log if invalid

Change-Id: I8c5d0642aeb4fbee73a035b9f73cf3a09b1bcf90
---
M src/libbsc/handover_decision.c
1 file changed, 3 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/02/5902/1

diff --git a/src/libbsc/handover_decision.c b/src/libbsc/handover_decision.c
index 04ca144..1ad4b36 100644
--- a/src/libbsc/handover_decision.c
+++ b/src/libbsc/handover_decision.c
@@ -103,8 +103,10 @@
if (window < nmp->rxlev_cnt)
window = nmp->rxlev_cnt;
/* this should never happen */
-   if (window == 0)
+   if (window <= 0) {
+   LOGP(DHO, LOGL_ERROR, "Requested Neighbor RxLev for invalid 
window size of %d\n", window);
return 0;
+   }
 
idx = calc_initial_idx(ARRAY_SIZE(nmp->rxlev),
nmp->rxlev_cnt % ARRAY_SIZE(nmp->rxlev),

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

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


[PATCH] osmo-bsc[master]: HO: Add function to count currently ongoing handovers to a g...

2018-01-18 Thread Neels Hofmeyr

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

HO: Add function to count currently ongoing handovers to a given BTS

In order to keep processing power at BTS at a defined level, the handover
decision might want to limit maximum number of slots that require RACH
detection.

Change-Id: I8908e37fe0d8d2eda906cc6301ba0969b25a5575
---
M include/osmocom/bsc/handover.h
M src/libbsc/handover_logic.c
2 files changed, 20 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/95/5895/1

diff --git a/include/osmocom/bsc/handover.h b/include/osmocom/bsc/handover.h
index 9e2ba1a..a9349ee 100644
--- a/include/osmocom/bsc/handover.h
+++ b/include/osmocom/bsc/handover.h
@@ -7,3 +7,5 @@
 int bsc_handover_start(struct gsm_lchan *old_lchan, struct gsm_bts *bts);
 void bsc_clear_handover(struct gsm_subscriber_connection *conn, int 
free_lchan);
 struct gsm_lchan *bsc_handover_pending(struct gsm_lchan *new_lchan);
+
+int bsc_ho_count(struct gsm_bts *bts, bool inter_cell);
diff --git a/src/libbsc/handover_logic.c b/src/libbsc/handover_logic.c
index f525b21..ee7b683 100644
--- a/src/libbsc/handover_logic.c
+++ b/src/libbsc/handover_logic.c
@@ -389,3 +389,21 @@
 {
osmo_signal_register_handler(SS_LCHAN, ho_logic_sig_cb, NULL);
 }
+
+/* Count number of currently ongoing handovers
+ * inter_cell: if true, count only handovers between two cells. If false, 
count only handovers within one
+ * cell. */
+int bsc_ho_count(struct gsm_bts *bts, bool inter_cell)
+{
+   struct bsc_handover *ho;
+   int count = 0;
+
+   llist_for_each_entry(ho, _handovers, list) {
+   if (ho->inter_cell != inter_cell)
+   continue;
+   if (ho->new_lchan->ts->trx->bts == bts)
+   count++;
+   }
+
+   return count;
+}

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

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


[PATCH] osmo-bsc[master]: HO: If handover logic is used to do assignment, signal assig...

2018-01-18 Thread Neels Hofmeyr

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

HO: If handover logic is used to do assignment, signal assignment result

Change-Id: I465caef03626e67d9b3a21bdf730589b9852c211
---
M include/osmocom/bsc/signal.h
M src/libbsc/bsc_api.c
2 files changed, 31 insertions(+), 0 deletions(-)


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

diff --git a/include/osmocom/bsc/signal.h b/include/osmocom/bsc/signal.h
index 58d9acf..9c0d5a3 100644
--- a/include/osmocom/bsc/signal.h
+++ b/include/osmocom/bsc/signal.h
@@ -85,6 +85,8 @@
S_LCHAN_ACTIVATE_NACK,  /* 08.58 Channel Activate NACK */
S_LCHAN_HANDOVER_COMPL, /* 04.08 Handover Completed */
S_LCHAN_HANDOVER_FAIL,  /* 04.08 Handover Failed */
+   S_LCHAN_ASSIGNMENT_COMPL,   /* 04.08 Assignment Completed */
+   S_LCHAN_ASSIGNMENT_FAIL,/* 04.08 Assignment Failed */
S_LCHAN_HANDOVER_DETECT,/* 08.58 Handover Detect */
S_LCHAN_MEAS_REP,   /* 08.58 Measurement Report */
 };
diff --git a/src/libbsc/bsc_api.c b/src/libbsc/bsc_api.c
index 3592c00..ec64bb8 100644
--- a/src/libbsc/bsc_api.c
+++ b/src/libbsc/bsc_api.c
@@ -436,6 +436,21 @@
struct gsm48_hdr *gh;
struct bsc_api *api = conn->network->bsc_api;
 
+   if (conn->ho_lchan) {
+   struct lchan_signal_data sig;
+   struct gsm48_hdr *gh = msgb_l3(msg);
+
+   DEBUGP(DRR, "ASSIGNMENT COMPLETE cause = %s\n",
+   rr_cause_name(gh->data[0]));
+
+   sig.lchan = msg->lchan;
+   sig.mr = NULL;
+   osmo_signal_dispatch(SS_LCHAN, S_LCHAN_ASSIGNMENT_COMPL, );
+   /* FIXME: release old channel */
+
+   return;
+   }
+
if (conn->secondary_lchan != msg->lchan) {
LOGP(DMSC, LOGL_ERROR, "Assignment Compl should occur on second 
lchan.\n");
return;
@@ -471,6 +486,20 @@
uint8_t *rr_failure;
struct gsm48_hdr *gh;
 
+   if (conn->ho_lchan) {
+   struct lchan_signal_data sig;
+   struct gsm48_hdr *gh = msgb_l3(msg);
+
+   DEBUGP(DRR, "ASSIGNMENT FAILED cause = %s\n",
+   rr_cause_name(gh->data[0]));
+
+   sig.lchan = msg->lchan;
+   sig.mr = NULL;
+   osmo_signal_dispatch(SS_LCHAN, S_LCHAN_ASSIGNMENT_FAIL, );
+   /* FIXME: release allocated new channel */
+
+   return;
+   }
 
if (conn->lchan != msg->lchan) {
LOGP(DMSC, LOGL_ERROR, "Assignment failure should occur on 
primary lchan.\n");

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I465caef03626e67d9b3a21bdf730589b9852c211
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: Fix of checking TCH rate at chan_compat_with_mode

2018-01-18 Thread Neels Hofmeyr

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

Fix of checking TCH rate at chan_compat_with_mode

In case of current channel equals TCH/F and we request half rate, we
must return 0, so the calling function will trigger assignment.

Change-Id: Ibb4cb9aef1a1146f984d7c969bfba53c647cae07
---
M src/libbsc/bsc_api.c
1 file changed, 5 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/99/5899/1

diff --git a/src/libbsc/bsc_api.c b/src/libbsc/bsc_api.c
index bd55dfc..3592c00 100644
--- a/src/libbsc/bsc_api.c
+++ b/src/libbsc/bsc_api.c
@@ -357,7 +357,11 @@
 * an explicit override by the 'full_rate' argument */
switch (lchan->type) {
case GSM_LCHAN_TCH_F:
-   return 1;
+   if (full_rate)
+   return 1;
+   else
+   return 0;
+   break;
case GSM_LCHAN_TCH_H:
if (full_rate)
return 0;

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

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


[PATCH] osmo-bsc[master]: HO: Changed availablilty of ts_is_usable() from static to ex...

2018-01-18 Thread Neels Hofmeyr

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

HO: Changed availablilty of ts_is_usable() from static to extern

Change-Id: I3471e38327c4b98490faed9b604fb76438ba9954
---
M include/osmocom/bsc/chan_alloc.h
M src/libbsc/chan_alloc.c
2 files changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/04/5904/1

diff --git a/include/osmocom/bsc/chan_alloc.h b/include/osmocom/bsc/chan_alloc.h
index 62d0286..f2a75c5 100644
--- a/include/osmocom/bsc/chan_alloc.h
+++ b/include/osmocom/bsc/chan_alloc.h
@@ -47,5 +47,6 @@
 void network_chan_load(struct pchan_load *pl, struct gsm_network *net);
 
 bool trx_is_usable(const struct gsm_bts_trx *trx);
+bool ts_is_usable(const struct gsm_bts_trx_ts *ts);
 
 #endif /* _CHAN_ALLOC_H */
diff --git a/src/libbsc/chan_alloc.c b/src/libbsc/chan_alloc.c
index 1caa13d..9946628 100644
--- a/src/libbsc/chan_alloc.c
+++ b/src/libbsc/chan_alloc.c
@@ -34,7 +34,7 @@
 
 #include 
 
-static bool ts_is_usable(const struct gsm_bts_trx_ts *ts)
+bool ts_is_usable(const struct gsm_bts_trx_ts *ts)
 {
if (!trx_is_usable(ts->trx))
return false;

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

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


[PATCH] osmo-bsc[master]: HO prep: introduce per-BTS handover config, with defaults on...

2018-01-18 Thread Neels Hofmeyr

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

HO prep: introduce per-BTS handover config, with defaults on net node

It is desirable to allow configuring handover for each individual network cell.
At the same time, it is desirable to set global defaults.

Treat the 'network' node handover parameters as global defaults, add another
set of parameters for each individual BTS.

This raises questions on how the 'network' node should affect the individual
BTS. The simplistic solution would have been: on creating a BTS in the config,
just copy the current defaults; with serious drawbacks:
- tweaking any parameter in the telnet VTY on network node will never affect
  any running BTS.
- network node defaults *must* be issued before the bts sections in the config
  file.
- when writing a config back to file, we would copy all net node defaults to
  each BTS node, making the network node configs pointless.

Instead, add a handover_cfg API that tracks whether a given node has a value
set or not. A bts node ho_cfg gets a pointer to the network node config and
returns those values if locally unset. If no value is set on any node, use the
"factory" defaults, which are hardcoded in the API. Only write back exactly
those config items that were actually issued in a config file / on the telnet
VTY. (ho_cfg API wise, we could trivially add another ho_cfg level per TRX if
we so desire in the future.)

Implement ho parameters as an opaque config struct with getters and setters to
ensure the tracking is always heeded. Opaqueness dictates allocating instead of
direct embedding in gsm_network and gsm_bts structs, ctx is gsm_net / bts.

This is 100% backwards compatible to
old configs.
- No VTY command syntax changes (only the online help).
- If a 'bts' sets nothing, it will use the 'network' defaults.
- The 'show network' output only changes in presence of individual BTS configs.

On 'show network', say "Handover: On|Off" as before, iff all BTS reflect
identical behavior. Otherwise, output BTS counts of handover being enabled or
not.

Use the same set of VTY commands (same VTY cmd syntax as before) on network and
BTS nodes, i.e. don't duplicate VTY code. From the current vty->node, figure
out which ho_cfg to modify.

For linking, add handover_cfg.c (the value API) in libcommon, while the
handover_vty.c is in libbsc. This is mainly because some utility programs use
gsm_network and hence suck in the ho stuff, but don't need the VTY commands.

Review the VTY online help strings.

Add VTY transcript test for handover options, testing config propagation from
network to bts nodes, 'show network' output and VTY online help strings.
(Needs recent addition of '... !' wildcard to osmo_interact_common.py.)

I considered leaving parts of this more readable, but in the end decided for
heavy use of macros to define and declare the API, because more values will be
added in upcoming patches and I want to prevent myself from messing them up.

Inspired-by: jolly/new_handover branch, which moves the config to 'bts' level
Depends: I7c1ebb2e7f059047903a53de26a0ec1ce7fa9b98 (osmo-python-tests)
Change-Id: I79d35f6d3c0fbee67904378ad7f216df34fde79a
---
M include/osmocom/bsc/Makefile.am
M include/osmocom/bsc/gsm_data.h
M include/osmocom/bsc/gsm_data_shared.h
A include/osmocom/bsc/handover_cfg.h
A include/osmocom/bsc/handover_vty.h
M src/libbsc/Makefile.am
M src/libbsc/bsc_vty.c
M src/libbsc/handover_decision.c
A src/libbsc/handover_vty.c
M src/libbsc/net_init.c
M src/libcommon/Makefile.am
M src/libcommon/gsm_data.c
M src/libcommon/gsm_data_shared.c
A src/libcommon/handover_cfg.c
M tests/Makefile.am
A tests/handover_cfg.vty
16 files changed, 653 insertions(+), 150 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/92/5892/1

diff --git a/include/osmocom/bsc/Makefile.am b/include/osmocom/bsc/Makefile.am
index b067fc2..699aeb3 100644
--- a/include/osmocom/bsc/Makefile.am
+++ b/include/osmocom/bsc/Makefile.am
@@ -25,7 +25,9 @@
gsm_data.h \
gsm_data_shared.h \
handover.h \
+   handover_cfg.h \
handover_decision.h \
+   handover_vty.h \
ipaccess.h \
meas_feed.h \
meas_rep.h \
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index ed2a95c..c09d546 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -227,22 +227,7 @@
uint16_t network_code;
int a5_encryption;
int neci;
-   struct {
-   int active;
-   /* Window RXLEV averaging */
-   unsigned int win_rxlev_avg; /* number of SACCH frames */
-   /* Window RXQUAL averaging */
-   unsigned int win_rxqual_avg;/* number of SACCH frames */
-   /* Window RXLEV neighbouring cells averaging */
-   unsigned int win_rxlev_avg_neigh; /* number of SACCH frames */
-
-   /* how often should we check for power budget HO */
-   unsigned int 

[PATCH] osmo-bsc[master]: HO: fix recovery from failed handover

2018-01-18 Thread Neels Hofmeyr

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

HO: fix recovery from failed handover

Do not instruct the MGW to move the RTP to the new lchan before we have
received a HANDOVER DETECT.

Before:

  Chan Activ
  Chan Activ Ack
  IPACC-CRCX
   -ACK
  IPACC-MDCX
   -ACK
  MGCP MDCX --> MGW
  ...
  HANDOVER DETECT
  Call continues on new lchan

In above sequence, if the HANDOVER DETECT times out, the MGW has moved to the
new lchan which never becomes used and is released. Furthermore, from the IPACC
MDCX until the HANDOVER DETECT, the RTP stream would break off momentarily.

After:

  Chan Activ
  Chan Activ Ack
  IPACC-CRCX
   -ACK
  IPACC-MDCX
   -ACK
  ...
  HANDOVER DETECT
  MGCP MDCX --> MGW
  Call continues on new lchan

If the HANDOVER DETECT times out, the call happily continues on the old lchan.

This change is inspired by Ivan Kluchnikov's HO work, who implemented a similar
fix in the openbsc.git codebase (branch fairwaves/master-rebase): his patch
moves ipacc_mdcx() to connect RTP to the new lchan from switch_for_handover()
(which triggered on S_ABISIP_CRCX_ACK, i.e. creation of the new lchan) to later
on in ho_detect() a.k.a. the S_LCHAN_HANDOVER_DETECT signal handler:
http://git.osmocom.org/openbsc/commit/?h=fairwaves/master-rebase=9507a7a1ea627e07370c9d264816bb190b3b91b8

This patch does essentially the same: remove the mgcp_handover() call from the
MDCX-ACK handling (creation of the new lchan), and add a signal handler for
S_LCHAN_HANDOVER_DETECT to osmo_bsc_mgcp.c to effect the MGW switchover.

Note, it would have been possible to call mgcp_handover() directly from rx of
the HANDOVER DETECT message, but that produces linking fallout in some utils/
projects, which then need to link the mgcp code as well. That is because those
aren't properly separated from the more complex parts of libbsc. Using the
signal is a bit bloaty, but saves the linking hell for now. I've faced a
similar problem twice recently, it would pay off to separate out the simpler
utils/ and ipaccess/ tools so that they don't need to link all of libbsc and
osmo-bsc, at some point (TM).

Change-Id: Iec58c5fcc5697f1775da7ec035108ed1fc8f
---
M include/osmocom/bsc/osmo_bsc_mgcp.h
M src/libbsc/handover_logic.c
M src/osmo-bsc/osmo_bsc_audio.c
M src/osmo-bsc/osmo_bsc_mgcp.c
4 files changed, 66 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/91/5891/1

diff --git a/include/osmocom/bsc/osmo_bsc_mgcp.h 
b/include/osmocom/bsc/osmo_bsc_mgcp.h
index 1e06331..dc2ba34 100644
--- a/include/osmocom/bsc/osmo_bsc_mgcp.h
+++ b/include/osmocom/bsc/osmo_bsc_mgcp.h
@@ -58,5 +58,4 @@
  enum gsm48_chan_mode chan_mode, bool 
full_rate);
 void mgcp_clear_complete(struct mgcp_ctx *mgcp_ctx, struct msgb *resp);
 void mgcp_ass_complete(struct mgcp_ctx *mgcp_ctx, struct gsm_lchan *lchan);
-void mgcp_handover(struct mgcp_ctx *mgcp_ctx, struct gsm_lchan *ho_lchan);
 void mgcp_free_ctx(struct mgcp_ctx *mgcp_ctx);
diff --git a/src/libbsc/handover_logic.c b/src/libbsc/handover_logic.c
index a30cd09..cad0144 100644
--- a/src/libbsc/handover_logic.c
+++ b/src/libbsc/handover_logic.c
@@ -325,7 +325,11 @@
return -ENODEV;
}
 
-   /* FIXME: do we actually want to do something here ? */
+   LOGP(DHO, LOGL_DEBUG, "%s Handover RACH detected\n", 
gsm_lchan_name(new_lchan));
+
+   /* This is just for logging on the DHO category. The actual MGCP 
switchover happens in
+* osmo_bsc_mgcp.c by receiving the same S_LCHAN_HANDOVER_DETECT signal.
+* (Calling mgcp_handover() directly currently breaks linking in 
utils/...) */
 
return 0;
 }
diff --git a/src/osmo-bsc/osmo_bsc_audio.c b/src/osmo-bsc/osmo_bsc_audio.c
index 433dc6c..ceec469 100644
--- a/src/osmo-bsc/osmo_bsc_audio.c
+++ b/src/osmo-bsc/osmo_bsc_audio.c
@@ -50,11 +50,6 @@
 
switch (signal) {
case S_ABISIP_CRCX_ACK:
-   /*
-* TODO: handle handover here... then the audio should go to
-* the old mgcp port..
-*/
-
/* we can ask it to connect now */
LOGP(DMSC, LOGL_DEBUG, "Connecting BTS to port: %d conn: %d\n",
 con->sccp_con->user_plane.rtp_port, 
lchan->abis_ip.conn_id);
@@ -77,14 +72,11 @@
 
case S_ABISIP_MDCX_ACK:
if (con->ho_lchan) {
-   /* NOTE: When an ho_lchan exists, the MDCX is part of an
-* handover operation (intra-bsc). This means we will 
not
-* inform the MSC about the event, which means that no
-* assignment complete message is transmitted, we just
-* inform the logic that controls the MGW about the new
-* connection info */
-   LOGP(DMSC, LOGL_INFO,"RTP connection handover 
initiated...\n");
-   mgcp_handover(con->sccp_con->user_plane.mgcp_ctx, 

[PATCH] osmo-bsc[master]: HO: add indicators for inter-cell and async ho, use for chan...

2018-01-18 Thread Neels Hofmeyr

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

HO: add indicators for inter-cell and async ho, use for chan act type

Change-Id: I2d91765c1f9719c64fd99426a872cecc724215db
---
M src/libbsc/handover_logic.c
1 file changed, 12 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/94/5894/1

diff --git a/src/libbsc/handover_logic.c b/src/libbsc/handover_logic.c
index cad0144..f525b21 100644
--- a/src/libbsc/handover_logic.c
+++ b/src/libbsc/handover_logic.c
@@ -48,6 +48,9 @@
struct osmo_timer_list T3103;
 
uint8_t ho_ref;
+
+   bool inter_cell;
+   bool async;
 };
 
 static LLIST_HEAD(bsc_handovers);
@@ -125,6 +128,10 @@
ho->old_lchan = old_lchan;
ho->new_lchan = new_lchan;
ho->ho_ref = ho_ref++;
+   if (old_lchan->ts->trx->bts != bts) {
+   ho->inter_cell = true;
+   ho->async = true;
+   }
 
/* copy some parameters from old lchan */
memcpy(_lchan->encr, _lchan->encr, sizeof(new_lchan->encr));
@@ -139,7 +146,11 @@
new_lchan->conn->ho_lchan = new_lchan;
 
/* FIXME: do we have a better idea of the timing advance? */
-   rc = rsl_chan_activate_lchan(new_lchan, RSL_ACT_INTER_ASYNC, 
ho->ho_ref);
+   rc = rsl_chan_activate_lchan(new_lchan,
+ho->inter_cell
+  ? (ho->async ? RSL_ACT_INTER_ASYNC : 
RSL_ACT_INTER_SYNC)
+  : RSL_ACT_INTRA_IMM_ASS,
+ho->ho_ref);
if (rc < 0) {
LOGP(DHO, LOGL_ERROR, "could not activate channel\n");
new_lchan->conn->ho_lchan = NULL;

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

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


[PATCH] osmo-bsc[master]: Fix: If paging for half rate was requested, use hr, if suppo...

2018-01-18 Thread Neels Hofmeyr

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

Fix: If paging for half rate was requested, use hr, if supported by MS

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


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/97/5897/1

diff --git a/src/libbsc/gsm_04_08_utils.c b/src/libbsc/gsm_04_08_utils.c
index b17e58e..85eb7b5 100644
--- a/src/libbsc/gsm_04_08_utils.c
+++ b/src/libbsc/gsm_04_08_utils.c
@@ -116,7 +116,7 @@
[CHREQ_T_PAG_R_ANY_NECI1]   = GSM_LCHAN_SDCCH,
[CHREQ_T_PAG_R_ANY_NECI0]   = GSM_LCHAN_SDCCH,
[CHREQ_T_PAG_R_TCH_F]   = GSM_LCHAN_TCH_F,
-   [CHREQ_T_PAG_R_TCH_FH]  = GSM_LCHAN_TCH_F,
+   [CHREQ_T_PAG_R_TCH_FH]  = GSM_LCHAN_TCH_H,
[CHREQ_T_LMU]   = GSM_LCHAN_SDCCH,
[CHREQ_T_RESERVED_SDCCH]= GSM_LCHAN_SDCCH,
[CHREQ_T_PDCH_ONE_PHASE]= GSM_LCHAN_PDTCH,

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

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


[PATCH] osmo-bsc[master]: cosmetic: explicitly init ho_ref start value

2018-01-18 Thread Neels Hofmeyr

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

cosmetic: explicitly init ho_ref start value

The static ho_ref seems to be implicitly initialized to zero, but let's make it
explicit for code readability.

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


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/96/5896/1

diff --git a/src/libbsc/handover_logic.c b/src/libbsc/handover_logic.c
index ee7b683..4b86de7 100644
--- a/src/libbsc/handover_logic.c
+++ b/src/libbsc/handover_logic.c
@@ -93,7 +93,7 @@
 {
struct gsm_lchan *new_lchan;
struct bsc_handover *ho;
-   static uint8_t ho_ref;
+   static uint8_t ho_ref = 0;
int rc;
 
/* don't attempt multiple handovers for the same lchan at

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

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


[PATCH] osmo-bsc[master]: osmo_bsc_mgcp: cosmetic: introduce mgcp_init(), soak up fsm ...

2018-01-18 Thread Neels Hofmeyr

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

osmo_bsc_mgcp: cosmetic: introduce mgcp_init(), soak up fsm init

A subsequent patch will add registration of a signal; cosmetically prepare by
creating a common mgcp_init() function. It makes sense for the FSM registration
to move to it.

Change-Id: I510e1081171706eb3d9fb2db50a9aa4f768929b5
---
M include/osmocom/bsc/osmo_bsc_mgcp.h
M src/osmo-bsc/osmo_bsc_main.c
M src/osmo-bsc/osmo_bsc_mgcp.c
3 files changed, 10 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/90/5890/1

diff --git a/include/osmocom/bsc/osmo_bsc_mgcp.h 
b/include/osmocom/bsc/osmo_bsc_mgcp.h
index 7452513..1e06331 100644
--- a/include/osmocom/bsc/osmo_bsc_mgcp.h
+++ b/include/osmocom/bsc/osmo_bsc_mgcp.h
@@ -52,6 +52,8 @@
mgcp_trans_id_t mgw_pending_trans;
 };
 
+void mgcp_init(struct gsm_network *net);
+
 struct mgcp_ctx *mgcp_assignm_req(void *ctx, struct mgcp_client *mgcp, struct 
osmo_bsc_sccp_con *conn,
  enum gsm48_chan_mode chan_mode, bool 
full_rate);
 void mgcp_clear_complete(struct mgcp_ctx *mgcp_ctx, struct msgb *resp);
diff --git a/src/osmo-bsc/osmo_bsc_main.c b/src/osmo-bsc/osmo_bsc_main.c
index e4c8fc5..1555ac1 100644
--- a/src/osmo-bsc/osmo_bsc_main.c
+++ b/src/osmo-bsc/osmo_bsc_main.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -293,6 +294,8 @@
exit(1);
}
 
+   mgcp_init(bsc_gsmnet);
+
signal(SIGINT, _handler);
signal(SIGTERM, _handler);
signal(SIGABRT, _handler);
diff --git a/src/osmo-bsc/osmo_bsc_mgcp.c b/src/osmo-bsc/osmo_bsc_mgcp.c
index 186c8c5..519eaf4 100644
--- a/src/osmo-bsc/osmo_bsc_mgcp.c
+++ b/src/osmo-bsc/osmo_bsc_mgcp.c
@@ -964,18 +964,11 @@
 {
struct mgcp_ctx *mgcp_ctx;
char name[32];
-   static bool fsm_registered = false;
 
OSMO_ASSERT(mgcp);
OSMO_ASSERT(conn);
 
OSMO_ASSERT(snprintf(name, sizeof(name), "MGW_%i", conn->conn_id) < 
sizeof(name));
-
-   /* Register the fsm description (if not already done) */
-   if (fsm_registered == false) {
-   osmo_fsm_register(_bsc_mgcp);
-   fsm_registered = true;
-   }
 
/* Allocate and configure a new fsm instance */
mgcp_ctx = talloc_zero(ctx, struct mgcp_ctx);
@@ -1093,3 +1086,8 @@
osmo_fsm_inst_free(mgcp_ctx->fsm);
talloc_free(mgcp_ctx);
 }
+
+void mgcp_init(struct gsm_network *net)
+{
+   osmo_fsm_register(_bsc_mgcp);
+}

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

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


[PATCH] osmo-bsc[master]: HO: Send Channel Mode and Multirate IE along with handover c...

2018-01-18 Thread Neels Hofmeyr

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

HO: Send Channel Mode and Multirate IE along with handover command

This is needed, if the channel mode should change when doing handover.
A change in channel mode makes sense, if available resources at the new
BTS are different.

Change-Id: Ib6b17a9be252f1655006ab6773483868017d7926
---
M src/libbsc/gsm_04_08_utils.c
1 file changed, 7 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/93/5893/1

diff --git a/src/libbsc/gsm_04_08_utils.c b/src/libbsc/gsm_04_08_utils.c
index 414fd6d..b17e58e 100644
--- a/src/libbsc/gsm_04_08_utils.c
+++ b/src/libbsc/gsm_04_08_utils.c
@@ -406,6 +406,13 @@
}
/* FIXME: optional bits for type of synchronization? */
 
+   msgb_tv_put(msg, GSM48_IE_CHANMODE_1, new_lchan->tch_mode);
+
+   /* in case of multi rate we need to attach a config */
+   if (new_lchan->tch_mode == GSM48_CMODE_SPEECH_AMR)
+   msgb_tlv_put(msg, GSM48_IE_MUL_RATE_CFG, new_lchan->mr_ms_lv[0],
+   new_lchan->mr_ms_lv + 1);
+
return gsm48_sendmsg(msg);
 }
 

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

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


[PATCH] libosmocore[master]: tests: fix LDADD: link libosmovty from current build

2018-01-18 Thread Neels Hofmeyr
Hello Max, Jenkins Builder,

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

https://gerrit.osmocom.org/5844

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

tests: fix LDADD: link libosmovty from current build

Do not link against the system-wide installed libosmovty during build. Instead,
use the locally built one: add libosmovty.la to LDADD explicitly.

It might be more accurate to add this linking only to those tests that really
require it, but on the one hand ctrl_test (which raises an error) doesn't even
seem to use libosmovty, and on the other hand I don't want to spend time
analysing each and every test for which libs it links now. I am being lazy and
find it sufficient that the tests still work after linking libosmovty to all of
them.

I got:

  /usr/local/lib/libosmovty.so.4: undefined reference to 
`log_set_print_basename'
  collect2: error: ld returned 1 exit status
  Makefile:964: recipe for target 'ctrl/ctrl_test' failed

because a system installation of libosmovty was from a branch with a new symbol
expected present in libosmocore.la (log_set_print_basename), followed by a
build of current master which lacks that symbol.

Change-Id: Id084e6e6efd25cd62b1bd7a4fc7c5985c39130c6
---
M tests/Makefile.am
1 file changed, 3 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/44/5844/3

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 877a302..e6cbd4c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,7 +1,9 @@
 AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include
 AM_CFLAGS = -Wall $(TALLOC_CFLAGS)
 AM_LDFLAGS =
-LDADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS)
+LDADD = $(top_builddir)/src/libosmocore.la \
+   $(top_builddir)/src/vty/libosmovty.la \
+   $(TALLOC_LIBS)
 
 check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test  \
  smscb/smscb_test bits/bitrev_test a5/a5_test  \
@@ -146,7 +148,6 @@
 strrb_strrb_test_SOURCES = strrb/strrb_test.c
 
 vty_vty_test_SOURCES = vty/vty_test.c
-vty_vty_test_LDADD = $(LDADD) $(top_builddir)/src/vty/libosmovty.la
 
 sim_sim_test_SOURCES = sim/sim_test.c
 sim_sim_test_LDADD = $(LDADD) $(top_builddir)/src/sim/libosmosim.la \

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Id084e6e6efd25cd62b1bd7a4fc7c5985c39130c6
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 


libosmocore[master]: tests: fix LDADD: link libosmovty from current build

2018-01-18 Thread Neels Hofmeyr

Patch Set 2:

> > could you clarify?
 > 
 > It's documented in 
 > https://www.gnu.org/software/automake/manual/html_node/Linking.html
 > In a nutshell, LDADD applies to all the programs, prog_LDADD
 > applies single program. So having only "prog_LDADD = $(LDADD)" is
 > confusing and redundant.

The question is whether prog_LDADD overrides or includes LDADD.
If it overrides, we still need to add it explicitly *if* we have a prog_LDADD.

"you can use the prog_LDADD variable [...] to override LDADD. If this variable 
exists for a given program, then that program is not linked using LDADD."

so only a

  prog_LDADD = $(LDADD)

is wrong, and a

  prog_LDADD = $(LDADD) other_things

is still necessary.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id084e6e6efd25cd62b1bd7a4fc7c5985c39130c6
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


[PATCH] libosmocore[master]: libosmocoding: fix typo in library documentation

2018-01-18 Thread Vadim Yanitskiy

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

libosmocoding: fix typo in library documentation

Change-Id: I535d4eba5bad9094a1e9e662f32cd2bfac5b0cef
---
M src/coding/gsm0503_coding.c
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/88/5888/1

diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
index dab6ca1..c94bca7 100644
--- a/src/coding/gsm0503_coding.c
+++ b/src/coding/gsm0503_coding.c
@@ -55,7 +55,7 @@
  * implementing the GSM/GPRS/EGPRS channel coding (and decoding) as
  * specified in 3GPP TS 05.03 / 45.003.
  *
- * libosmocodec is developed as part of the Osmocom (Open Source Mobile
+ * libosmocoding is developed as part of the Osmocom (Open Source Mobile
  * Communications) project, a community-based, collaborative development
  * project to create Free and Open Source implementations of mobile
  * communications systems.  For more information about Osmocom, please

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I535d4eba5bad9094a1e9e662f32cd2bfac5b0cef
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] libosmocore[master]: libosmocoding: use frame length definitions from codec.h

2018-01-18 Thread Vadim Yanitskiy

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

libosmocoding: use frame length definitions from codec.h

Since commit e094157e125a70b9a384ba3cec01261624f4eb59, TCH frame
length definitions were added to libosmocodec.
No need to define them again.

Change-Id: Id8c6132534e36ea1e368432bb259fd4f3a531f90
---
M src/coding/gsm0503_coding.c
1 file changed, 0 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/87/5887/1

diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
index f3b319a..dab6ca1 100644
--- a/src/coding/gsm0503_coding.c
+++ b/src/coding/gsm0503_coding.c
@@ -131,13 +131,6 @@
 #define EGPRS_DATA_C1  612
 #define EGPRS_DATA_C2  EGPRS_DATA_C1
 
-/* TS 101318 Chapter 5.1: 260 bits + 4bit sig */
-#define GSM_FR_BYTES   33
-/* TS 101318 Chapter 5.2: 112 bits, no sig */
-#define GSM_HR_BYTES   14
-/* TS 101318 Chapter 5.3: 244 bits + 4bit sig */
-#define GSM_EFR_BYTES  31
-
 /*! union across the three different EGPRS Uplink header types */
 union gprs_rlc_ul_hdr_egprs {
struct gprs_rlc_ul_header_egprs_1 type1;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id8c6132534e36ea1e368432bb259fd4f3a531f90
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


osmo-mgw[master]: mgcp: make domain name configurable

2018-01-18 Thread Stefan Sperling

Patch Set 1: Code-Review-1

(4 comments)

https://gerrit.osmocom.org/#/c/5878/1/src/libosmo-mgcp/mgcp_protocol.c
File src/libosmo-mgcp/mgcp_protocol.c:

Line 1217:  len = snprintf(buf, sizeof(buf),
snprintf() could return -1 here if the expanded string does not fit into buf.


Line 1220:  rc = send_agent(cfg, buf, len);
Which means we could end up passing -1 as length here...

I suggest returning an error if snprintf() returns -1.


Line 1240:  if (len < 0)
Here it is done correctly.


Line 1243:  buf[sizeof(buf) - 1] = '\0';
Unrelated to your change, but this line is not needed with snprintf() and could 
be removed.

Adding a NUL manually is a common idiom after calling strncpy() because 
strncpy() does not always NUL-terminate the string. But snprintf() is fine.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ia91ac428ba83ac1f9b52a0ec8dbf00ef7876da9e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: Yes


osmo-bts[master]: Allow specifying sysmocom headers explicitly

2018-01-18 Thread Pau Espin Pedrol

Patch Set 2:

> > Otherwise yoy may end up with "-I" only in Makefile.am
 > 
 > No, we may not. The SYSMOBTS_INCDIR is only used in targets which
 > are enabled iff sysmobts support is enabled.

even if sysmobts support is enavbled, I may want to build with 
--enable-sysmobts and without --with-sysmobts, for instance OE recipe in 
meta-sysmocom-bsp does that.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I0416a9f4c428189cd9c3909c8bd016ca2908128a
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-Reviewer: neels 
Gerrit-HasComments: No


osmo-bts[master]: Allow specifying sysmocom headers explicitly

2018-01-18 Thread Max

Patch Set 2:

> '--with-sysmobts-includes=' or '--with-sysmobts-headers=' would be a better 
> name for this option

Perhaps, but I'd rather keep it similar to the other such options for different 
BTS models. If we'd like to rename it, we should do it for all models at once 
and in a separate patch.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I0416a9f4c428189cd9c3909c8bd016ca2908128a
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-Reviewer: neels 
Gerrit-HasComments: No


osmo-bts[master]: Allow specifying sysmocom headers explicitly

2018-01-18 Thread Max

Patch Set 2:

> Otherwise yoy may end up with "-I" only in Makefile.am

No, we may not. The SYSMOBTS_INCDIR is only used in targets which are enabled 
iff sysmobts support is enabled.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I0416a9f4c428189cd9c3909c8bd016ca2908128a
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-Reviewer: neels 
Gerrit-HasComments: No


osmo-bts[master]: Allow specifying sysmocom headers explicitly

2018-01-18 Thread Stefan Sperling

Patch Set 2:

A common way to handle this type of situation is to add -I$(PATH) to CPPFLAGS 
if PATH is set, else don't add anything.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I0416a9f4c428189cd9c3909c8bd016ca2908128a
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-Reviewer: neels 
Gerrit-HasComments: No


osmo-bts[master]: Allow specifying sysmocom headers explicitly

2018-01-18 Thread Pau Espin Pedrol

Patch Set 2: Code-Review-1

Makes sense to leave it empty to get them from standard include directories. 
However, that makes me think we should move the -I inside the SYSMOBTS_INCDIR 
variable. Otherwise yoy may end up with "-I" only in Makefile.am

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I0416a9f4c428189cd9c3909c8bd016ca2908128a
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-Reviewer: neels 
Gerrit-HasComments: No


[PATCH] libosmocore[master]: jenkins: remove obsolete scripts

2018-01-18 Thread Max

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

jenkins: remove obsolete scripts

* jenkins.sh is superseded by jenkins_amd64.sh
* jenkins-arm.sh is superseded by jenkins_arm.sh

N. B: this requires I76dfc11a05007ae5c6e0554fe8132695b67cccaa in
osmo-ci.

Change-Id: Ifbd253cff88c3ac18e469c34e79f1501501e1657
---
D contrib/jenkins-arm.sh
D contrib/jenkins.sh
2 files changed, 0 insertions(+), 61 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/86/5886/1

diff --git a/contrib/jenkins-arm.sh b/contrib/jenkins-arm.sh
deleted file mode 100755
index acdbe3c..000
--- a/contrib/jenkins-arm.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-
-. $(dirname "$0")/jenkins_common.sh
-
-src_dir="$PWD"
-build() {
-build_dir="$1"
-
-prep_build "$src_dir" "$build_dir"
-
-"$src_dir"/configure --enable-static \
-   --prefix=/usr/local/arm-none-eabi \
-   --host=arm-none-eabi \
-   --enable-embedded \
-   --disable-doxygen \
-   --disable-shared \
-   CFLAGS="-Os -ffunction-sections -fdata-sections -nostartfiles 
-nodefaultlibs -Werror"
-
-$MAKE $PARALLEL_MAKE \
-|| cat-testlogs.sh
-}
-
-# verify build in dir other than source tree
-build builddir
-# verify build in source tree
-build .
-
-osmo-clean-workspace.sh
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
deleted file mode 100755
index c341d05..000
--- a/contrib/jenkins.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/sh
-# jenkins build helper script for libosmo-sccp.  This is how we build on 
jenkins.osmocom.org
-
-. $(dirname "$0")/jenkins_common.sh
-
-ENABLE_SANITIZE="--enable-sanitize"
-
-if [ "x$label" = "xFreeBSD_amd64" ]; then
-ENABLE_SANITIZE=""
-fi
-
-src_dir="$PWD"
-build() {
-build_dir="$1"
-
-prep_build "$src_dir" "$build_dir"
-
-"$src_dir"/configure --enable-static $ENABLE_SANITIZE CFLAGS="-Werror" 
CPPFLAGS="-Werror"
-$MAKE V=1 $PARALLEL_MAKE check \
-|| cat-testlogs.sh
-}
-
-# verify build in dir other than source tree
-build builddir
-# verify build in source tree
-build .
-
-# do distcheck only once, which is fine from built source tree, since distcheck
-# is well separated from the source tree state.
-$MAKE distcheck \
-|| cat-testlogs.sh
-
-osmo-clean-workspace.sh

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifbd253cff88c3ac18e469c34e79f1501501e1657
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] libosmocore[master]: jenkins: add dispatcher script

2018-01-18 Thread Max
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5884

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

jenkins: add dispatcher script

Similar to the way we test osmo-bts, add simple dispatcher script which
calls appropriate test depending on a given parameter. This will allow
to simplify the job description. While at it, also rename jenkins-arm.sh
-> jenkins_arm.sh to match the OsmoBTS.

The older scripts are preserved for compatibility and shall be removed
once we update job description in osmo-ci.

Change-Id: I2955e866bce4f000a53369bd601a346c36c82468
---
A contrib/jenkins_amd64.sh
A contrib/jenkins_arch.sh
A contrib/jenkins_arm.sh
3 files changed, 94 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/84/5884/2

diff --git a/contrib/jenkins_amd64.sh b/contrib/jenkins_amd64.sh
new file mode 100755
index 000..d336f0a
--- /dev/null
+++ b/contrib/jenkins_amd64.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+# jenkins build helper script for libosmocore. This is how we build on 
jenkins.osmocom.org
+
+. $(dirname "$0")/jenkins_common.sh
+
+ENABLE_SANITIZE="--enable-sanitize"
+
+if [ "x$label" = "xFreeBSD_amd64" ]; then
+ENABLE_SANITIZE=""
+fi
+
+src_dir="$PWD"
+build() {
+build_dir="$1"
+
+prep_build "$src_dir" "$build_dir"
+
+"$src_dir"/configure --enable-static $ENABLE_SANITIZE CFLAGS="-Werror" 
CPPFLAGS="-Werror"
+$MAKE V=1 $PARALLEL_MAKE check \
+|| cat-testlogs.sh
+}
+
+# verify build in dir other than source tree
+build builddir
+# verify build in source tree
+build .
+
+# do distcheck only once, which is fine from built source tree, since distcheck
+# is well separated from the source tree state.
+$MAKE distcheck \
+|| cat-testlogs.sh
+
+osmo-clean-workspace.sh
diff --git a/contrib/jenkins_arch.sh b/contrib/jenkins_arch.sh
new file mode 100755
index 000..bac9278
--- /dev/null
+++ b/contrib/jenkins_arch.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+# this is a dispatcher script which will call the arch-specific
+# script based on the arch specified as command line argument
+
+arch="$1"
+
+if [ "x$arch" == "x" ]; then
+   echo "Error: You have to specify the architecture as first argument, 
e.g. $0 amd64"
+   exit 2
+fi
+
+if [ ! -d "./contrib" ]; then
+  echo "Run ./contrib/jenkins_arch.sh from the root of the libosmocore tree"
+  exit 1
+fi
+
+set -x -e
+
+case "$arch" in
+
+  amd64)
+./contrib/jenkins_amd64.sh
+  ;;
+
+  arch)
+./contrib/jenkins_arch.sh
+  ;;
+
+  *)
+set +x
+echo "Unexpected architecture '$arch'"
+  ;;
+esac
diff --git a/contrib/jenkins_arm.sh b/contrib/jenkins_arm.sh
new file mode 100755
index 000..acdbe3c
--- /dev/null
+++ b/contrib/jenkins_arm.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+. $(dirname "$0")/jenkins_common.sh
+
+src_dir="$PWD"
+build() {
+build_dir="$1"
+
+prep_build "$src_dir" "$build_dir"
+
+"$src_dir"/configure --enable-static \
+   --prefix=/usr/local/arm-none-eabi \
+   --host=arm-none-eabi \
+   --enable-embedded \
+   --disable-doxygen \
+   --disable-shared \
+   CFLAGS="-Os -ffunction-sections -fdata-sections -nostartfiles 
-nodefaultlibs -Werror"
+
+$MAKE $PARALLEL_MAKE \
+|| cat-testlogs.sh
+}
+
+# verify build in dir other than source tree
+build builddir
+# verify build in source tree
+build .
+
+osmo-clean-workspace.sh

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I2955e866bce4f000a53369bd601a346c36c82468
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder


[PATCH] libosmocore[master]: jenkins: add dispatcher script

2018-01-18 Thread Max

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

jenkins: add dispatcher script

Similar to the way we test osmo-bts, add simple dispatcher script which
calls appropriate test depending on a given parameter. This will allow
to simplify the job description. While at it, also rename jenkins-arm.sh
-> jenkins_arm.sh to match the OsmoBTS.

Change-Id: I2955e866bce4f000a53369bd601a346c36c82468
---
R contrib/jenkins_amd64.sh
A contrib/jenkins_arch.sh
R contrib/jenkins_arm.sh
3 files changed, 33 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/84/5884/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins_amd64.sh
similarity index 100%
rename from contrib/jenkins.sh
rename to contrib/jenkins_amd64.sh
diff --git a/contrib/jenkins_arch.sh b/contrib/jenkins_arch.sh
new file mode 100755
index 000..bac9278
--- /dev/null
+++ b/contrib/jenkins_arch.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+# this is a dispatcher script which will call the arch-specific
+# script based on the arch specified as command line argument
+
+arch="$1"
+
+if [ "x$arch" == "x" ]; then
+   echo "Error: You have to specify the architecture as first argument, 
e.g. $0 amd64"
+   exit 2
+fi
+
+if [ ! -d "./contrib" ]; then
+  echo "Run ./contrib/jenkins_arch.sh from the root of the libosmocore tree"
+  exit 1
+fi
+
+set -x -e
+
+case "$arch" in
+
+  amd64)
+./contrib/jenkins_amd64.sh
+  ;;
+
+  arch)
+./contrib/jenkins_arch.sh
+  ;;
+
+  *)
+set +x
+echo "Unexpected architecture '$arch'"
+  ;;
+esac
diff --git a/contrib/jenkins-arm.sh b/contrib/jenkins_arm.sh
similarity index 100%
rename from contrib/jenkins-arm.sh
rename to contrib/jenkins_arm.sh

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2955e866bce4f000a53369bd601a346c36c82468
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] osmo-iuh[master]: hnbap: log errors on decoding/encoding HNB-REGISTER msgs

2018-01-18 Thread Neels Hofmeyr

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

hnbap: log errors on decoding/encoding HNB-REGISTER msgs

Change-Id: I3c039267fa2cc047c5678bcfe4a603f70c21cdd1
---
M src/hnbgw_hnbap.c
1 file changed, 6 insertions(+), 1 deletion(-)


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

diff --git a/src/hnbgw_hnbap.c b/src/hnbgw_hnbap.c
index 2746c21..8fba13c 100644
--- a/src/hnbgw_hnbap.c
+++ b/src/hnbgw_hnbap.c
@@ -63,6 +63,8 @@
memset(_out, 0, sizeof(accept_out));
rc = hnbap_encode_hnbregisteraccepties(_out,  );
if (rc < 0) {
+   LOGP(DHNBAP, LOGL_ERROR, "Failure to encode HNB-REGISTER-ACCEPT 
to %s: rc=%d\n",
+ctx->identity_info, rc);
return rc;
}
 
@@ -370,8 +372,11 @@
int rc;
 
rc = hnbap_decode_hnbregisterrequesties(, in);
-   if (rc < 0)
+   if (rc < 0) {
+   LOGP(DHNBAP, LOGL_ERROR, "Failure to decode HNB-REGISTER-REQ 
from %s: rc=%d\n",
+ctx->identity_info, rc);
return rc;
+   }
 
/* copy all identity parameters from the message to ctx */
asn1_strncpy(ctx->identity_info, _Identity.hNB_Identity_Info,

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

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


[PATCH] osmo-msc[master]: Delete SMS from the database once they were sent successfully

2018-01-18 Thread Stefan Sperling

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

Delete SMS from the database once they were sent successfully

Currently the SMS database keeps accumulating entries for each SMS.
These entries are never deleted automatically. With this change, we
start deleting SMS which have successfully been sent to subscriber B.

Change-Id: I3749855fe25d9d4e37ec96b0c2bffbc692b66a78
---
M include/osmocom/msc/db.h
M src/libmsc/db.c
M src/libmsc/sms_queue.c
3 files changed, 18 insertions(+), 0 deletions(-)


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

diff --git a/include/osmocom/msc/db.h b/include/osmocom/msc/db.h
index 988c9bd..13c5ed3 100644
--- a/include/osmocom/msc/db.h
+++ b/include/osmocom/msc/db.h
@@ -49,6 +49,7 @@
 int db_sms_mark_delivered(struct gsm_sms *sms);
 int db_sms_inc_deliver_attempts(struct gsm_sms *sms);
 int db_sms_delete_by_msisdn(const char *msisdn);
+int db_sms_delete_sent_message_by_id(unsigned long long sms_id);
 
 /* Statistics counter storage */
 struct osmo_counter;
diff --git a/src/libmsc/db.c b/src/libmsc/db.c
index 7007c7a..e80ef53 100644
--- a/src/libmsc/db.c
+++ b/src/libmsc/db.c
@@ -970,6 +970,22 @@
return 0;
 }
 
+int db_sms_delete_sent_message_by_id(unsigned long long sms_id)
+{
+   dbi_result result;
+
+   result = dbi_conn_queryf(conn,
+   "DELETE FROM SMS WHERE id = %llu AND sent is NOT NULL",
+sms_id);
+   if (!result) {
+   LOGP(DDB, LOGL_ERROR, "Failed to delete SMS %llu.\n", sms_id);
+   return 1;
+   }
+
+   dbi_result_free(result);
+   return 0;
+}
+
 int db_store_counter(struct osmo_counter *ctr)
 {
dbi_result result;
diff --git a/src/libmsc/sms_queue.c b/src/libmsc/sms_queue.c
index 609a0db..1372a2c 100644
--- a/src/libmsc/sms_queue.c
+++ b/src/libmsc/sms_queue.c
@@ -483,6 +483,7 @@
network->sms_queue->pending -= 1;
vsub = vlr_subscr_get(pending->vsub);
sms_pending_free(pending);
+   db_sms_delete_sent_message_by_id(pending->sms_id);
/* Attempt to send another SMS to this subscriber */
sms_send_next(vsub);
vlr_subscr_put(vsub);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3749855fe25d9d4e37ec96b0c2bffbc692b66a78
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 


osmo-mgw[master]: client: do not insist on \n\n when parsing MGCP messages

2018-01-18 Thread dexter

Patch Set 1:

(1 comment)

> (1 comment)
 > 
 > I think there are still some issues in the code, but this does fix
 > the issue I'm seeing. Thanks

https://gerrit.osmocom.org/#/c/5867/1/src/libosmo-mgcp-client/mgcp_client.c
File src/libosmo-mgcp-client/mgcp_client.c:

PS1, Line 317: for_each_non_empty_line
> Unfortunately that fails as soon as we have more than one parameter
I remember having a similar effect when doing 
https://gerrit.osmocom.org/#/c/5879/. Can you try what happens when you send I 
first and then the not implemented parameters?


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie209fb71499e011e52f58575c6af118de2fdee88
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: Yes


[PATCH] osmo-mgw[master]: client: add an optional FSM interface

2018-01-18 Thread dexter

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

client: add an optional FSM interface

the client API is not very intuitive and requires a lot of extra
care when it is used from an osmo-fsm.

- Add an FSM that permits comfortable handling of an MGCP
  connection.

Change-Id: I887ce0c15a831dffeb6251a975337b83942af566
---
M include/Makefile.am
M src/libosmo-mgcp-client/Makefile.am
2 files changed, 2 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/81/5881/1

diff --git a/include/Makefile.am b/include/Makefile.am
index b52e5ea..e8fc211 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -7,6 +7,7 @@
osmocom/legacy_mgcp/mgcp_internal.h \
osmocom/legacy_mgcp/osmux.h \
osmocom/mgcp_client/mgcp_client.h \
+   osmocom/mgcp_client/mgcp_client_fsm.h \
osmocom/mgcp_client/mgcp_common.h \
osmocom/mgcp/mgcp.h \
osmocom/mgcp/mgcp_common.h \
diff --git a/src/libosmo-mgcp-client/Makefile.am 
b/src/libosmo-mgcp-client/Makefile.am
index 1e4e764..a3a920b 100644
--- a/src/libosmo-mgcp-client/Makefile.am
+++ b/src/libosmo-mgcp-client/Makefile.am
@@ -29,6 +29,7 @@
 libosmo_mgcp_client_la_SOURCES = \
mgcp_client.c \
mgcp_client_vty.c \
+   mgcp_client_fsm.c \
$(NULL)
 
 libosmo_mgcp_client_la_LDFLAGS = $(AM_LDFLAGS) -version-info 
$(MGCP_CLIENT_LIBVERSION)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I887ce0c15a831dffeb6251a975337b83942af566
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 


[PATCH] osmo-mgw[master]: mgcp: make domain name configurable

2018-01-18 Thread dexter

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

mgcp: make domain name configurable

At the moment the MGW has a fixed domain name string that is not even
checked properly.

- Make domain name configurable, use the current "mgw" string as
  defualt to maintain compatibility

- Check the domain name with each request. If the endpoint contains
  an unexpected domain name, the request must be rejected.

Change-Id: Ia91ac428ba83ac1f9b52a0ec8dbf00ef7876da9e
---
M include/osmocom/mgcp/mgcp.h
M src/libosmo-mgcp/mgcp_msg.c
M src/libosmo-mgcp/mgcp_protocol.c
M src/libosmo-mgcp/mgcp_vty.c
M tests/mgcp/mgcp_test.c
M tests/mgcp/mgcp_test.ok
6 files changed, 50 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/78/5878/1

diff --git a/include/osmocom/mgcp/mgcp.h b/include/osmocom/mgcp/mgcp.h
index d6397d3..0d156c6 100644
--- a/include/osmocom/mgcp/mgcp.h
+++ b/include/osmocom/mgcp/mgcp.h
@@ -212,6 +212,8 @@
 * message.
 */
uint16_t osmux_dummy;
+   /* domain name of the media gateway */
+   char domain[255+1];
 };
 
 /* config management */
diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c
index 45195de..74acffa 100644
--- a/src/libosmo-mgcp/mgcp_msg.c
+++ b/src/libosmo-mgcp/mgcp_msg.c
@@ -181,6 +181,22 @@
return >endpoints[endp];
 }
 
+/* Check if the domain name, which is supplied with the endpoint name
+ * matches the configuration. */
+static int check_domain_name(struct mgcp_config *cfg, const char *mgcp)
+{
+   char *domain_to_check;
+
+   domain_to_check = strstr(mgcp, "@");
+   if (!domain_to_check)
+   return -EINVAL;
+
+   if (strcmp(domain_to_check+1, cfg->domain) != 0)
+   return -EINVAL;
+
+   return 0;
+}
+
 /* Search the endpoint pool for the endpoint that had been selected via the
  * MGCP message (helper function for mgcp_analyze_header()) */
 static struct mgcp_endpoint *find_endpoint(struct mgcp_config *cfg,
@@ -189,6 +205,11 @@
char *endptr = NULL;
unsigned int gw = INT_MAX;
 
+   if (check_domain_name(cfg, mgcp)) {
+   LOGP(DLMGCP, LOGL_ERROR, "Wrong domain name '%s'\n", mgcp);
+   return NULL;
+   }
+
if (strncmp(mgcp, "ds/e1", 5) == 0)
return find_e1_endpoint(cfg, mgcp);
 
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 9d79343..9c21d38 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -1072,6 +1072,8 @@
return NULL;
}
 
+   osmo_strlcpy(cfg->domain, "mgw", sizeof(cfg->domain));
+
cfg->net_ports.range_start = RTP_PORT_DEFAULT_RANGE_START;
cfg->net_ports.range_end = RTP_PORT_DEFAULT_RANGE_END;
cfg->net_ports.last_port = cfg->net_ports.range_start;
@@ -1208,13 +1210,14 @@
  *  \returns 0 on success, -1 on error */
 int mgcp_send_reset_all(struct mgcp_config *cfg)
 {
+   char buf[MGCP_ENDPOINT_MAXLEN + 128];
+   int len;
int rc;
 
-   static const char mgcp_reset[] = {
-   "RSIP 1 *@mgw MGCP 1.0\r\n"
-   };
+   len = snprintf(buf, sizeof(buf),
+  "RSIP 1 *@%s MGCP 1.0\r\n", cfg->domain);
 
-   rc = send_agent(cfg, mgcp_reset, sizeof mgcp_reset - 1);
+   rc = send_agent(cfg, buf, len);
if (rc <= 0)
return -1;
 
@@ -1228,12 +1231,12 @@
  *  \returns 0 on success, -1 on error */
 int mgcp_send_reset_ep(struct mgcp_endpoint *endp, int endpoint)
 {
-   char buf[128];
+   char buf[MGCP_ENDPOINT_MAXLEN + 128];
int len;
int rc;
 
len = snprintf(buf, sizeof(buf),
-  "RSIP 39 %x@mgw MGCP 1.0\r\n", endpoint);
+  "RSIP 39 %x@%s MGCP 1.0\r\n", endpoint, 
endp->cfg->domain);
if (len < 0)
return -1;
 
diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c
index 7fa3949..7043527 100644
--- a/src/libosmo-mgcp/mgcp_vty.c
+++ b/src/libosmo-mgcp/mgcp_vty.c
@@ -63,6 +63,7 @@
 static int config_write_mgcp(struct vty *vty)
 {
vty_out(vty, "mgcp%s", VTY_NEWLINE);
+   vty_out(vty, "  domain %s%s", g_cfg->domain, VTY_NEWLINE);
if (g_cfg->local_ip)
vty_out(vty, "  local ip %s%s", g_cfg->local_ip, VTY_NEWLINE);
vty_out(vty, "  bind ip %s%s", g_cfg->source_addr, VTY_NEWLINE);
@@ -1179,6 +1180,14 @@
return CMD_SUCCESS;
 }
 
+DEFUN(cfg_mgcp_domain,
+  cfg_mgcp_domain_cmd,
+  "domain NAME", "domain\n" "qualified domain name\n")
+{
+   osmo_strlcpy(g_cfg->domain, argv[0], sizeof(g_cfg->domain));
+   return CMD_SUCCESS;
+}
+
 int mgcp_vty_init(void)
 {
install_element_ve(_mgcp_cmd);
@@ -1240,6 +1249,7 @@
install_element(MGCP_NODE, _mgcp_osmux_dummy_cmd);
install_element(MGCP_NODE, _mgcp_allow_transcoding_cmd);
install_element(MGCP_NODE, _mgcp_no_allow_transcoding_cmd);
+   

[PATCH] osmo-mgw[master]: mgcp: add prefix to virtual trunk

2018-01-18 Thread dexter

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

mgcp: add prefix to virtual trunk

the virtual trunk is addressed without a prefix (just *@domain).

- reorganize find_endpoint() so that it accepts a prefix when
  addressing the virtual trunk.

- do no longer accept wildcarded CRCX requests without prefix
  (will not break anything, the feature of wildcarded CRCX is
  not in use yet)

- keep the old prefix-less method but print a warning that it is
  depreacted.

Change-Id: I2aac3ba0f1f3122dfbb3bf36f74198ecb2b21de5
---
M include/osmocom/mgcp/mgcp_common.h
M src/libosmo-mgcp/mgcp_msg.c
M src/libosmo-mgcp/mgcp_protocol.c
3 files changed, 32 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/80/5880/1

diff --git a/include/osmocom/mgcp/mgcp_common.h 
b/include/osmocom/mgcp/mgcp_common.h
index 7684936..7aa5d3f 100644
--- a/include/osmocom/mgcp/mgcp_common.h
+++ b/include/osmocom/mgcp/mgcp_common.h
@@ -76,4 +76,7 @@
 /  (see also RFC3435 section 3.2.1.3) */
 #define MGCP_ENDPOINT_MAXLEN (255*2+1+1)
 
+/* A prefix to denote the virtual trunk (RTP on both ends) */
+#define MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK "rtpbridge/"
+
 #endif
diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c
index 994b00a..d4b04a7 100644
--- a/src/libosmo-mgcp/mgcp_msg.c
+++ b/src/libosmo-mgcp/mgcp_msg.c
@@ -227,20 +227,38 @@
 {
char *endptr = NULL;
unsigned int gw = INT_MAX;
+   const char *endpoint_number_str;
 
+   /* Check if the domainname in the request is correct */
if (check_domain_name(cfg, mgcp)) {
LOGP(DLMGCP, LOGL_ERROR, "Wrong domain name '%s'\n", mgcp);
return NULL;
}
 
+   /* Check if the E1 trunk is requested */
if (strncmp(mgcp, "ds/e1", 5) == 0)
return find_e1_endpoint(cfg, mgcp);
 
-   if (strncmp(mgcp, "*", 1) == 0) {
-   return find_free_endpoint(cfg->trunk.endpoints,
- cfg->trunk.number_endpoints);
+   /* Check if the virtual trunk is addressed (new, correct way with 
prefix) */
+   if (strncmp
+   (mgcp, MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK,
+strlen(MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK)) == 0) {
+   endpoint_number_str =
+   mgcp + strlen(MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK);
+   if (endpoint_number_str[0] == '*') {
+   return find_free_endpoint(cfg->trunk.endpoints,
+ cfg->trunk.number_endpoints);
+   }
+
+   gw = strtoul(endpoint_number_str, , 16);
+   if (gw < cfg->trunk.number_endpoints && endptr[0] == '@')
+   return >trunk.endpoints[gw];
}
 
+   /* Deprecated method without prefix */
+   LOGP(DLMGCP, LOGL_NOTICE,
+"Addressing virtual trunk without prefix (deprecated), please use 
%s: '%s'\n",
+MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK, mgcp);
gw = strtoul(mgcp, , 16);
if (gw < cfg->trunk.number_endpoints && endptr[0] == '@')
return >trunk.endpoints[gw];
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 24d5bf1..ee744f9 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -235,9 +235,14 @@
 * there is this FIXME note instead. Also the I parameter, which is
 * misplaced as well has been introduced with an earlier patch. */
 
-   rc = msgb_printf(sdp, "Z: %u@%s\n", ENDPOINT_NUMBER(endp), 
endp->cfg->domain);
-   if (rc < 0)
-   goto error;
+   /* NOTE: Only in the virtual trunk we allow dynamic endpoint names */
+   if (endp->tcfg->trunk_type == MGCP_TRUNK_VIRTUAL) {
+   rc = msgb_printf(sdp, "Z: %s%u@%s\n",
+MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK,
+ENDPOINT_NUMBER(endp), endp->cfg->domain);
+   if (rc < 0)
+   goto error;
+   }
 
rc = msgb_printf(sdp, "I: %s%s\n\n", conn->conn->id, osmux_extension);
if (rc < 0)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2aac3ba0f1f3122dfbb3bf36f74198ecb2b21de5
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 


[PATCH] osmo-mgw[master]: mgcp: allow endpoints beginning from zero

2018-01-18 Thread dexter

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

mgcp: allow endpoints beginning from zero

there is a now obsolete constraint that endpoint numbers must
start at 1.

- remove the check to allow also endpoints starting at 0

Change-Id: Iec2f4e36e1ab01ff23875d99e4b0e04af7c1ad98
---
M src/libosmo-mgcp/mgcp_msg.c
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/76/5876/1

diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c
index 7f05a44..45195de 100644
--- a/src/libosmo-mgcp/mgcp_msg.c
+++ b/src/libosmo-mgcp/mgcp_msg.c
@@ -193,7 +193,7 @@
return find_e1_endpoint(cfg, mgcp);
 
gw = strtoul(mgcp, , 16);
-   if (gw > 0 && gw < cfg->trunk.number_endpoints && endptr[0] == '@')
+   if (gw < cfg->trunk.number_endpoints && endptr[0] == '@')
return >trunk.endpoints[gw];
 
LOGP(DLMGCP, LOGL_ERROR, "Not able to find the endpoint: '%s'\n", mgcp);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iec2f4e36e1ab01ff23875d99e4b0e04af7c1ad98
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 


[PATCH] osmo-mgw[master]: mgcp: permit wildcarded endpoint assignment (CRCX)

2018-01-18 Thread dexter

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

mgcp: permit wildcarded endpoint assignment (CRCX)

The mgcp protocol in general allows wildcarded endpoints on CRCX.
osmo-mgw does not support this feature yet.

- when the endpoint name contains a wildcard character, search
  a free endpoint

- return the resulting endpoint name in the parameter section of
  the mgcp response

- add parsing support for the returned endpoint names

Change-Id: Iebc95043569191b6f5fbc8fe266b13fcfcab2e48
---
M include/osmocom/mgcp_client/mgcp_client.h
M src/libosmo-mgcp-client/mgcp_client.c
M src/libosmo-mgcp/mgcp_msg.c
M src/libosmo-mgcp/mgcp_protocol.c
M tests/mgcp/mgcp_test.c
5 files changed, 126 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/79/5879/1

diff --git a/include/osmocom/mgcp_client/mgcp_client.h 
b/include/osmocom/mgcp_client/mgcp_client.h
index 882c908..3393bc4 100644
--- a/include/osmocom/mgcp_client/mgcp_client.h
+++ b/include/osmocom/mgcp_client/mgcp_client.h
@@ -31,6 +31,7 @@
mgcp_trans_id_t trans_id;
const char *comment;
char conn_id[MGCP_CONN_ID_LENGTH];
+   char ep_id[MGCP_ENDPOINT_MAXLEN];
 };
 
 struct mgcp_response {
diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index 9fc414d..e4ca96d 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -226,6 +226,10 @@
OSMO_ASSERT(r->body);
char *data = strstr(r->body, "\n\n");
 
+   /* Warning: This function performs a destructive parsing on r->body.
+* Since this function is called at the very end of the persing
+* process, destructive parsing is acceptable. */
+
if (!data) {
LOGP(DLMGCP, LOGL_ERROR,
 "MGCP response: cannot find start of parameters\n");
@@ -261,21 +265,29 @@
return 0;
 }
 
-/* Parse a line like "I: 0cedfd5a19542d197af9afe5231f1d61" */
-static int mgcp_parse_conn_id(struct mgcp_response *r, const char *line)
+/* Parse a line like "X: something" */
+static int mgcp_parse_head_param(char *result, unsigned int result_len,
+char label, const char *line)
 {
+   char label_string[4];
+
+   /* Detect empty parameters */
if (strlen(line) < 4)
goto response_parse_failure;
 
-   if (memcmp("I: ", line, 3) != 0)
+   /* Check if the label matches */
+   snprintf(label_string, sizeof(label_string), "%c: ", label);
+   if (memcmp(label_string, line, 3) != 0)
goto response_parse_failure;
 
-   osmo_strlcpy(r->head.conn_id, line + 3, sizeof(r->head.conn_id));
+   /* Copy payload part of the string to destinations (the label string
+* is always 3 chars long) */
+   osmo_strlcpy(result, line + 3, result_len);
return 0;
 
 response_parse_failure:
LOGP(DLMGCP, LOGL_ERROR,
-"Failed to parse MGCP response (connectionIdentifier)\n");
+"Failed to parse MGCP response (parameter label: %c)\n", label);
return -EINVAL;
 }
 
@@ -285,18 +297,37 @@
char *line;
int rc = 0;
OSMO_ASSERT(r->body);
-   char *data = r->body;
-   char *data_end = strstr(r->body, "\n\n");
+   char *data;
+   char *data_ptr;
+   char *data_end;
 
-   /* Protect SDP body, for_each_non_empty_line() will
-* only parse until it hits \0 mark. */
+   /* Since this functions performs a destructive parsing, we create a
+* local copy of the body data */
+   data = talloc_zero_size(NULL, strlen(r->body)+1);
+   OSMO_ASSERT(data);
+   data_ptr = data;
+   osmo_strlcpy(data, r->body, strlen(r->body));
+
+   /* If there is an SDP body attached, prevent for_each_non_empty_line()
+* into running in there, we are not yet interested in the parameters
+* stored there. */
+   data_end = strstr(data, "\n\n");
if (data_end)
*data_end = '\0';
 
-   for_each_non_empty_line(line, data) {
+   for_each_non_empty_line(line, data_ptr) {
switch (line[0]) {
+   case 'Z':
+   rc = mgcp_parse_head_param(r->head.ep_id,
+  sizeof(r->head.ep_id),
+  'Z', line);
+   if (rc)
+   goto exit;
+   break;
case 'I':
-   rc = mgcp_parse_conn_id(r, line);
+   rc = mgcp_parse_head_param(r->head.conn_id,
+  sizeof(r->head.conn_id),
+  'I', line);
if (rc)
goto exit;
break;
@@ -306,10 +337,7 @@
}
}
 exit:
-   /* Restore original state */
- 

[PATCH] osmo-mgw[master]: client/common: move constant MGCP_ENDPOINT_MAXLEN

2018-01-18 Thread dexter

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

client/common: move constant MGCP_ENDPOINT_MAXLEN

MGCP_ENDPOINT_MAXLEN is currently only defined for the mgcp client,
since this is in general a common parameter it should be moved to
mgcp_common.h so that both sides can use it.

Change-Id: I9e1c52aa5ebd83b2d9e5178ea24cb27d96cb7ddd
---
M include/osmocom/mgcp/mgcp_common.h
M include/osmocom/mgcp_client/mgcp_client.h
2 files changed, 4 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/77/5877/1

diff --git a/include/osmocom/mgcp/mgcp_common.h 
b/include/osmocom/mgcp/mgcp_common.h
index 29dc458..7684936 100644
--- a/include/osmocom/mgcp/mgcp_common.h
+++ b/include/osmocom/mgcp/mgcp_common.h
@@ -72,4 +72,8 @@
  * (see also RFC3435 2.1.3.2 Names of Connections) */
 #define MGCP_CONN_ID_LENGTH 32+1
 
+/* String length of Endpoint Identifiers.
+/  (see also RFC3435 section 3.2.1.3) */
+#define MGCP_ENDPOINT_MAXLEN (255*2+1+1)
+
 #endif
diff --git a/include/osmocom/mgcp_client/mgcp_client.h 
b/include/osmocom/mgcp_client/mgcp_client.h
index 4caf656..882c908 100644
--- a/include/osmocom/mgcp_client/mgcp_client.h
+++ b/include/osmocom/mgcp_client/mgcp_client.h
@@ -55,9 +55,6 @@
 #define MGCP_MSG_PRESENCE_AUDIO_PORT   0x0010
 #define MGCP_MSG_PRESENCE_CONN_MODE0x0020
 
-/* See also RFC3435 section 3.2.1.3 */
-#define MGCP_ENDPOINT_MAXLEN (255*2+1+1)
-
 struct mgcp_msg {
enum mgcp_verb verb;
/* See MGCP_MSG_PRESENCE_* constants */

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9e1c52aa5ebd83b2d9e5178ea24cb27d96cb7ddd
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 


[PATCH] osmo-msc[master]: Store/retrieve SMS validity time in the SMS datebase

2018-01-18 Thread Stefan Sperling

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

Store/retrieve SMS validity time in the SMS datebase

Compute a validity timestamp based on SMS validity time.
Store the computed value in the database and recompute the validity
time when an SMS is read from the database.

Change-Id: Id27c250d3a64cd109416450e8ca155b18a8b9568
---
M src/libmsc/db.c
1 file changed, 11 insertions(+), 8 deletions(-)


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

diff --git a/src/libmsc/db.c b/src/libmsc/db.c
index 28004f7..5c9f724 100644
--- a/src/libmsc/db.c
+++ b/src/libmsc/db.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -689,9 +690,7 @@
dbi_result result;
char *q_text, *q_daddr, *q_saddr;
unsigned char *q_udata;
-   char *validity_timestamp = "-2-2";
-
-   /* FIXME: generate validity timestamp based on validity_minutes */
+   time_t now, validity_timestamp;
 
dbi_conn_quote_string_copy(conn, (char *)sms->text, _text);
dbi_conn_quote_string_copy(conn, (char *)sms->dst.addr, _daddr);
@@ -699,7 +698,9 @@
dbi_conn_quote_binary_copy(conn, sms->user_data, sms->user_data_len,
   _udata);
 
-   /* FIXME: correct validity period */
+   now = time(NULL);
+   validity_timestamp = now + sms->validity_minutes * 60;
+
result = dbi_conn_queryf(conn,
"INSERT INTO SMS "
"(created, valid_until, "
@@ -709,14 +710,14 @@
 "user_data, text, "
 "dest_addr, dest_ton, dest_npi, "
 "src_addr, src_ton, src_npi) VALUES "
-   "(datetime('now'), %u, "
+   "(datetime('%lld', 'unixepoch'), datetime(%lld, 'unixepoch'), "
"%u, %u, %u, "
"%u, %u, %u, "
"%u, "
"%s, %s, "
"%s, %u, %u, "
"%s, %u, %u)",
-   validity_timestamp,
+   (int64_t)now, (int64_t)validity_timestamp,
sms->reply_path_req, sms->status_rep_req, sms->is_report,
sms->msg_ref, sms->protocol_id, sms->data_coding_scheme,
sms->ud_hdr_ind,
@@ -740,15 +741,17 @@
struct gsm_sms *sms = sms_alloc();
const char *text, *daddr, *saddr;
const unsigned char *user_data;
+   time_t validity_timestamp;
 
if (!sms)
return NULL;
 
sms->id = dbi_result_get_ulonglong(result, "id");
 
-   /* FIXME: validity */
-   /* FIXME: those should all be get_uchar, but sqlite3 is braindead */
sms->created = dbi_result_get_datetime(result, "created");
+   validity_timestamp = dbi_result_get_datetime(result, "valid_until");
+   sms->validity_minutes = (validity_timestamp - sms->created) / 60;
+   /* FIXME: those should all be get_uchar, but sqlite3 is braindead */
sms->reply_path_req = dbi_result_get_ulonglong(result, 
"reply_path_req");
sms->status_rep_req = dbi_result_get_ulonglong(result, 
"status_rep_req");
sms->is_report = dbi_result_get_ulonglong(result, "is_report");

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id27c250d3a64cd109416450e8ca155b18a8b9568
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 


[PATCH] libosmocore[master]: jenkins: move make invocation into shared function

2018-01-18 Thread Max

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

jenkins: move make invocation into shared function

Change-Id: Ied8c1085b8bee2cc4fa65592e805838b8cdae287
---
M contrib/jenkins-arm.sh
M contrib/jenkins.sh
M contrib/jenkins_common.sh
3 files changed, 8 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/74/5874/1

diff --git a/contrib/jenkins-arm.sh b/contrib/jenkins-arm.sh
index acdbe3c..4579596 100755
--- a/contrib/jenkins-arm.sh
+++ b/contrib/jenkins-arm.sh
@@ -16,8 +16,7 @@
--disable-shared \
CFLAGS="-Os -ffunction-sections -fdata-sections -nostartfiles 
-nodefaultlibs -Werror"
 
-$MAKE $PARALLEL_MAKE \
-|| cat-testlogs.sh
+run_make
 }
 
 # verify build in dir other than source tree
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index c341d05..d2b0459 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -15,9 +15,9 @@
 
 prep_build "$src_dir" "$build_dir"
 
-"$src_dir"/configure --enable-static $ENABLE_SANITIZE CFLAGS="-Werror" 
CPPFLAGS="-Werror"
-$MAKE V=1 $PARALLEL_MAKE check \
-|| cat-testlogs.sh
+"$src_dir"/configure  --disable-silent-rules --enable-static 
$ENABLE_SANITIZE CFLAGS="-Werror" CPPFLAGS="-Werror"
+
+run_make
 }
 
 # verify build in dir other than source tree
diff --git a/contrib/jenkins_common.sh b/contrib/jenkins_common.sh
index a6ffe7f..fa1d544 100644
--- a/contrib/jenkins_common.sh
+++ b/contrib/jenkins_common.sh
@@ -26,3 +26,7 @@
 mkdir -p "$_build_dir"
 cd "$_build_dir"
 }
+
+run_make() {
+$MAKE $PARALLEL_MAKE check || cat-testlogs.sh
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ied8c1085b8bee2cc4fa65592e805838b8cdae287
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 


osmo-mgw[master]: client: do not insist on \n\n when parsing MGCP messages

2018-01-18 Thread daniel

Patch Set 1: Code-Review+1

(1 comment)

I think there are still some issues in the code, but this does fix the issue 
I'm seeing. Thanks

https://gerrit.osmocom.org/#/c/5867/1/src/libosmo-mgcp-client/mgcp_client.c
File src/libosmo-mgcp-client/mgcp_client.c:

PS1, Line 317: for_each_non_empty_line
Unfortunately that fails as soon as we have more than one parameter


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie209fb71499e011e52f58575c6af118de2fdee88
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 
Gerrit-HasComments: Yes


[PATCH] libosmocore[master]: Embedded: add sercomm stubs

2018-01-18 Thread Max
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5873

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

Embedded: add sercomm stubs

The sercomm functions are unavailable in case of embedded build. Add
stub and link the tests against it.

Change-Id: I9bc5cb2f822b1a3ffdc6ec29f46b6bac8288314e
---
M .gitignore
M configure.ac
M tests/Makefile.am
A tests/libsercomstub.c
M tests/sercomm/sercomm_test.c
5 files changed, 15 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/73/5873/2

diff --git a/.gitignore b/.gitignore
index 657120d..db17535 100644
--- a/.gitignore
+++ b/.gitignore
@@ -90,3 +90,4 @@
 
 # vi files
 *.sw?
+/tests/libsercomstub.a
diff --git a/configure.ac b/configure.ac
index 3c15896..60c177f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -238,6 +238,7 @@
[embedded=$enableval], [embedded="no"])
 
 AM_CONDITIONAL(ENABLE_STATS_TEST, true)
+AM_CONDITIONAL(ENABLE_SERCOM_STUB, false)
 
 if test x"$embedded" = x"yes"
 then
@@ -253,6 +254,7 @@
AM_CONDITIONAL(ENABLE_GNUTLS, false)
AM_CONDITIONAL(ENABLE_PCSC, false)
AM_CONDITIONAL(ENABLE_PSEUDOTALLOC, true)
+   AM_CONDITIONAL(ENABLE_SERCOM_STUB, true)
AM_CONDITIONAL(ENABLE_STATS_TEST, false)
AC_DEFINE([USE_GNUTLS], [0])
AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than 
fprintf/abort])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e199ccc..5dd8e22 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,6 +3,11 @@
 AM_LDFLAGS =
 LDADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS)
 
+if ENABLE_SERCOM_STUB
+noinst_LIBRARIES = libsercomstub.a
+LDADD += $(top_builddir)/tests/libsercomstub.a
+endif
+
 check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test  \
  smscb/smscb_test bits/bitrev_test a5/a5_test  \
  conv/conv_test auth/milenage_test lapd/lapd_test  \
@@ -55,10 +60,10 @@
 stats_stats_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libosmogsm.la
 
 a5_a5_test_SOURCES = a5/a5_test.c
-a5_a5_test_LDADD = $(top_builddir)/src/gsm/libgsmint.la
+a5_a5_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libgsmint.la
 
 kasumi_kasumi_test_SOURCES = kasumi/kasumi_test.c
-kasumi_kasumi_test_LDADD = $(top_builddir)/src/gsm/libgsmint.la
+kasumi_kasumi_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libgsmint.la
 
 comp128_comp128_test_SOURCES = comp128/comp128_test.c
 comp128_comp128_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libosmogsm.la
@@ -84,10 +89,10 @@
 bits_bitfield_test_SOURCES = bits/bitfield_test.c
 
 conv_conv_test_SOURCES = conv/conv_test.c conv/conv.c
-conv_conv_test_LDADD = $(top_builddir)/src/gsm/libgsmint.la
+conv_conv_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libgsmint.la
 
 conv_conv_gsm0503_test_SOURCES = conv/conv_gsm0503_test.c conv/conv.c 
conv/gsm0503_test_vectors.c
-conv_conv_gsm0503_test_LDADD = $(top_builddir)/src/gsm/libgsmint.la
+conv_conv_gsm0503_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libgsmint.la
 conv_conv_gsm0503_test_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/conv
 
 gsm0808_gsm0808_test_SOURCES = gsm0808/gsm0808_test.c
diff --git a/tests/libsercomstub.c b/tests/libsercomstub.c
new file mode 100644
index 000..99662d0
--- /dev/null
+++ b/tests/libsercomstub.c
@@ -0,0 +1,3 @@
+/* Stubs for embedded build */
+void sercomm_drv_lock(unsigned long __attribute__((unused)) *flags) {}
+void sercomm_drv_unlock(unsigned long __attribute__((unused)) *flags) {}
diff --git a/tests/sercomm/sercomm_test.c b/tests/sercomm/sercomm_test.c
index 4a40f62..058c9eb 100644
--- a/tests/sercomm/sercomm_test.c
+++ b/tests/sercomm/sercomm_test.c
@@ -27,10 +27,6 @@
 
 struct osmo_sercomm_inst g_osi;
 
-/* Locking details are not checked by this test anyway */
-void sercomm_drv_lock(unsigned long __attribute__((unused)) *flags) {}
-void sercomm_drv_unlock(unsigned long __attribute__((unused)) *flags) {}
-
 static const uint8_t valid_dlci3[] = { 0x7E, 3, 0x03, 'f', 'o', 'o', 0x7E };
 static const uint8_t valid_dlci23[] = { 0x7E, 23, 0x03, '2', '3', 0x7E };
 static const uint8_t valid_dlci23esc[] = { 0x7E, 23, 0x03, 0x7D, '2' ^ (1 << 
5), '3', 0x7E };

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I9bc5cb2f822b1a3ffdc6ec29f46b6bac8288314e
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder


[PATCH] libosmocore[master]: Embedded: add sercomm stubs

2018-01-18 Thread Max

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

Embedded: add sercomm stubs

The sercomm functions are unavailable in case of embedded build. Add
stub and link the tests against it.

Change-Id: I9bc5cb2f822b1a3ffdc6ec29f46b6bac8288314e
---
M .gitignore
M configure.ac
M tests/Makefile.am
A tests/libsercomstub.c
M tests/sercomm/sercomm_test.c
5 files changed, 14 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/73/5873/1

diff --git a/.gitignore b/.gitignore
index 657120d..db17535 100644
--- a/.gitignore
+++ b/.gitignore
@@ -90,3 +90,4 @@
 
 # vi files
 *.sw?
+/tests/libsercomstub.a
diff --git a/configure.ac b/configure.ac
index 3c15896..245a142 100644
--- a/configure.ac
+++ b/configure.ac
@@ -253,6 +253,7 @@
AM_CONDITIONAL(ENABLE_GNUTLS, false)
AM_CONDITIONAL(ENABLE_PCSC, false)
AM_CONDITIONAL(ENABLE_PSEUDOTALLOC, true)
+   AM_CONDITIONAL(ENABLE_SERCOM_STUB, true)
AM_CONDITIONAL(ENABLE_STATS_TEST, false)
AC_DEFINE([USE_GNUTLS], [0])
AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than 
fprintf/abort])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e199ccc..5dd8e22 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,6 +3,11 @@
 AM_LDFLAGS =
 LDADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS)
 
+if ENABLE_SERCOM_STUB
+noinst_LIBRARIES = libsercomstub.a
+LDADD += $(top_builddir)/tests/libsercomstub.a
+endif
+
 check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test  \
  smscb/smscb_test bits/bitrev_test a5/a5_test  \
  conv/conv_test auth/milenage_test lapd/lapd_test  \
@@ -55,10 +60,10 @@
 stats_stats_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libosmogsm.la
 
 a5_a5_test_SOURCES = a5/a5_test.c
-a5_a5_test_LDADD = $(top_builddir)/src/gsm/libgsmint.la
+a5_a5_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libgsmint.la
 
 kasumi_kasumi_test_SOURCES = kasumi/kasumi_test.c
-kasumi_kasumi_test_LDADD = $(top_builddir)/src/gsm/libgsmint.la
+kasumi_kasumi_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libgsmint.la
 
 comp128_comp128_test_SOURCES = comp128/comp128_test.c
 comp128_comp128_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libosmogsm.la
@@ -84,10 +89,10 @@
 bits_bitfield_test_SOURCES = bits/bitfield_test.c
 
 conv_conv_test_SOURCES = conv/conv_test.c conv/conv.c
-conv_conv_test_LDADD = $(top_builddir)/src/gsm/libgsmint.la
+conv_conv_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libgsmint.la
 
 conv_conv_gsm0503_test_SOURCES = conv/conv_gsm0503_test.c conv/conv.c 
conv/gsm0503_test_vectors.c
-conv_conv_gsm0503_test_LDADD = $(top_builddir)/src/gsm/libgsmint.la
+conv_conv_gsm0503_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libgsmint.la
 conv_conv_gsm0503_test_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/conv
 
 gsm0808_gsm0808_test_SOURCES = gsm0808/gsm0808_test.c
diff --git a/tests/libsercomstub.c b/tests/libsercomstub.c
new file mode 100644
index 000..99662d0
--- /dev/null
+++ b/tests/libsercomstub.c
@@ -0,0 +1,3 @@
+/* Stubs for embedded build */
+void sercomm_drv_lock(unsigned long __attribute__((unused)) *flags) {}
+void sercomm_drv_unlock(unsigned long __attribute__((unused)) *flags) {}
diff --git a/tests/sercomm/sercomm_test.c b/tests/sercomm/sercomm_test.c
index 4a40f62..058c9eb 100644
--- a/tests/sercomm/sercomm_test.c
+++ b/tests/sercomm/sercomm_test.c
@@ -27,10 +27,6 @@
 
 struct osmo_sercomm_inst g_osi;
 
-/* Locking details are not checked by this test anyway */
-void sercomm_drv_lock(unsigned long __attribute__((unused)) *flags) {}
-void sercomm_drv_unlock(unsigned long __attribute__((unused)) *flags) {}
-
 static const uint8_t valid_dlci3[] = { 0x7E, 3, 0x03, 'f', 'o', 'o', 0x7E };
 static const uint8_t valid_dlci23[] = { 0x7E, 23, 0x03, '2', '3', 0x7E };
 static const uint8_t valid_dlci23esc[] = { 0x7E, 23, 0x03, 0x7D, '2' ^ (1 << 
5), '3', 0x7E };

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9bc5cb2f822b1a3ffdc6ec29f46b6bac8288314e
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 


osmo-bts[master]: Allow specifying sysmocom headers explicitly

2018-01-18 Thread Pau Espin Pedrol

Patch Set 2: Code-Review+1

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

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


osmo-bts[master]: Fix test dependencies

2018-01-18 Thread Pau Espin Pedrol

Patch Set 11: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I94ea8bad8b410550f72ee6a0408f42f6bd8b6cac
Gerrit-PatchSet: 11
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Reviewer: neels 
Gerrit-HasComments: No


[PATCH] libosmocore[master]: Extend Kc buffer

2018-01-18 Thread Max
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/1538

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

Extend Kc buffer

Double the Kc buffer to match the requirements of A5/4 and GEA4.

Related: OS#1910
Change-Id: I8d347bbeadc14cbc7306ea6e9b73e4a1c8c8cb21
---
M TODO-RELEASE
M include/osmocom/crypt/auth.h
2 files changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/38/1538/3

diff --git a/TODO-RELEASE b/TODO-RELEASE
index fb0bfea..55ee40c 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,3 +7,4 @@
 # If any interfaces have been added since the last public release: c:r:a + 1.
 # If any interfaces have been removed or changed since the last public 
release: c:r:0.
 #library   whatdescription / commit summary line
+libosmogsm osmo_auth_vectorexpand kc[] field to accommodate for 
GEA4 and A5/4 key sizes
diff --git a/include/osmocom/crypt/auth.h b/include/osmocom/crypt/auth.h
index 4dbc6a4..1c9ba63 100644
--- a/include/osmocom/crypt/auth.h
+++ b/include/osmocom/crypt/auth.h
@@ -64,7 +64,7 @@
uint8_t ik[16]; /*!< integrity key */
uint8_t res[16];/*!< authentication result */
uint8_t res_len;/*!< length (in bytes) of res */
-   uint8_t kc[8];  /*!< Kc for GSM encryption (A5) */
+   uint8_t kc[16]; /*!< Kc for GSM/GPRS encryption (A5 & GEA) */
uint8_t sres[4];/*!< authentication result for GSM */
uint32_t auth_types;/*!< bitmask of OSMO_AUTH_TYPE_* */
 };

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I8d347bbeadc14cbc7306ea6e9b73e4a1c8c8cb21
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmo-bts[master]: Allow specifying sysmocom headers explicitly

2018-01-18 Thread Max

Patch Set 2:

(2 comments)

https://gerrit.osmocom.org/#/c/5870/2/configure.ac
File configure.ac:

Line 77:CPPFLAGS="$CPPFLAGS -I$SYSMOBTS_INCDIR -I$srcdir/include"
> Is there a need to set CPPFLAGS here if you are passing SYSMOBTS_INCIDR to 
Those are only effective for the duration of header check below.


Line 82:CPPFLAGS=$oldCPPFLAGS
The flags are restored in here.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I0416a9f4c428189cd9c3909c8bd016ca2908128a
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 
Gerrit-HasComments: Yes


osmocom-bb[master]: mobile: Print an error message if the VTY cannot be initialized

2018-01-18 Thread Vadim Yanitskiy

Patch Set 1: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I24161f53fa621ae1c8b1916bd0c8055c494b531e
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


[PATCH] libosmocore[master]: Embedded: disable stats test

2018-01-18 Thread Max

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

Embedded: disable stats test

As of 67bdd80a96bdfc49d1aadbd32cca2b53f123d180 the stats.c is
effectively disable so we should disable the corresponding tests as
well.

Change-Id: I42ff7a6619c0a5926fdc2ec779cf04689c567e15
---
M configure.ac
M tests/Makefile.am
2 files changed, 9 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/71/5871/1

diff --git a/configure.ac b/configure.ac
index f7acf05..3c15896 100644
--- a/configure.ac
+++ b/configure.ac
@@ -236,6 +236,9 @@
[Enable building for embedded use and disable unsupported 
features]
)],
[embedded=$enableval], [embedded="no"])
+
+AM_CONDITIONAL(ENABLE_STATS_TEST, true)
+
 if test x"$embedded" = x"yes"
 then
AC_DEFINE([EMBEDDED],[1],[Select building for embedded use])
@@ -250,6 +253,7 @@
AM_CONDITIONAL(ENABLE_GNUTLS, false)
AM_CONDITIONAL(ENABLE_PCSC, false)
AM_CONDITIONAL(ENABLE_PSEUDOTALLOC, true)
+   AM_CONDITIONAL(ENABLE_STATS_TEST, false)
AC_DEFINE([USE_GNUTLS], [0])
AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than 
fprintf/abort])
 fi
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 877a302..e199ccc 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -17,7 +17,7 @@
 write_queue/wqueue_test socket/socket_test \
 coding/coding_test conv/conv_gsm0503_test  \
 abis/abis_test endian/endian_test sercomm/sercomm_test \
-stats/stats_test prbs/prbs_test gsm23003/gsm23003_test \
+prbs/prbs_test gsm23003/gsm23003_test  \
 codec/codec_ecu_fr_test
 
 if ENABLE_MSGFILE
@@ -40,6 +40,10 @@
 check_PROGRAMS += ctrl/ctrl_test fsm/fsm_test
 endif
 
+if ENABLE_STATS_TEST
+check_PROGRAMS += stats/stats_test
+endif
+
 if ENABLE_GB
 check_PROGRAMS += gb/bssgp_fc_test gb/gprs_bssgp_test gb/gprs_ns_test 
fr/fr_test
 endif

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I42ff7a6619c0a5926fdc2ec779cf04689c567e15
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 


osmo-bts[master]: Fix test dependencies

2018-01-18 Thread Pau Espin Pedrol

Patch Set 11:

(1 comment)

https://gerrit.osmocom.org/#/c/5818/11/tests/sysmobts/Makefile.am
File tests/sysmobts/Makefile.am:

Line 1: AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include 
-I$(top_srcdir)/src/osmo-bts-sysmo -I$(SYSMOBTS_INCDIR)
Relaed to previous patch: Why do we set CPPFLAGS to SYSMOBTS_INCDIR in 
configure.ac and then we set this here?


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I94ea8bad8b410550f72ee6a0408f42f6bd8b6cac
Gerrit-PatchSet: 11
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Reviewer: neels 
Gerrit-HasComments: Yes


osmo-bts[master]: Allow specifying sysmocom headers explicitly

2018-01-18 Thread Pau Espin Pedrol

Patch Set 2:

(1 comment)

https://gerrit.osmocom.org/#/c/5870/2/configure.ac
File configure.ac:

Line 77:CPPFLAGS="$CPPFLAGS -I$SYSMOBTS_INCDIR -I$srcdir/include"
Is there a need to set CPPFLAGS here if you are passing SYSMOBTS_INCIDR to 
AM_CPPFLAGS in Makefile.am later?


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I0416a9f4c428189cd9c3909c8bd016ca2908128a
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 
Gerrit-HasComments: Yes


[PATCH] osmo-bts[master]: Allow specifying sysmocom headers explicitly

2018-01-18 Thread Max
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5870

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

Allow specifying sysmocom headers explicitly

The headers for LC1.5 are specified explicitly. Add corresponding option
to specify sysmoBTS headers location and use it in jenkins build.

This is prerequisite for fixing the build issue revealed by migrating to
stow.

Change-Id: I0416a9f4c428189cd9c3909c8bd016ca2908128a
---
M configure.ac
M contrib/jenkins_sysmobts.sh
M src/osmo-bts-sysmo/Makefile.am
3 files changed, 11 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/70/5870/2

diff --git a/configure.ac b/configure.ac
index 2181743..983458a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,10 +67,19 @@
AC_HELP_STRING([--enable-sysmocom-bts],
[enable code for sysmoBTS L1/PHY [default=no]]),
[enable_sysmocom_bts="yes"],[enable_sysmocom_bts="no"])
+AC_ARG_WITH([sysmobts], [AS_HELP_STRING([--with-sysmobts=INCLUDE_DIR], 
[Location of the sysmobts API header files])],
+
[sysmobts_incdir="$withval"],[sysmobts_incdir="$incdir"])
+AC_SUBST([SYSMOBTS_INCDIR], $sysmobts_incdir)
 AC_MSG_RESULT([$enable_sysmocom_bts])
 AM_CONDITIONAL(ENABLE_SYSMOBTS, test "x$enable_sysmocom_bts" = "xyes")
 if test "$enable_sysmocom_bts" = "yes"; then
+   oldCPPFLAGS=$CPPFLAGS
+   CPPFLAGS="$CPPFLAGS -I$SYSMOBTS_INCDIR -I$srcdir/include"
+   AC_CHECK_HEADER([sysmocom/femtobts/superfemto.h],[],
+   [AC_MSG_ERROR([sysmocom/femtobts/superfemto.h can not 
be found in $sysmobts_incdir])],
+   [#include ])
PKG_CHECK_MODULES(LIBGPS, libgps)
+   CPPFLAGS=$oldCPPFLAGS
 fi
 
 AC_MSG_CHECKING([whether to enable support for osmo-trx based L1/PHY support])
diff --git a/contrib/jenkins_sysmobts.sh b/contrib/jenkins_sysmobts.sh
index 852542b..3e07050 100755
--- a/contrib/jenkins_sysmobts.sh
+++ b/contrib/jenkins_sysmobts.sh
@@ -16,7 +16,7 @@
 mkdir -p "$inst/include/sysmocom/femtobts"
 ln -s $deps/layer1-headers/include/* "$inst/include/sysmocom/femtobts/"
 
-configure_flags="--enable-sysmocom-bts"
+configure_flags="--enable-sysmocom-bts --with-sysmobts=$inst/include/"
 
 # This will not work for the femtobts
 if [ $FIRMWARE_VERSION != "femtobts_v2.7" ]; then
diff --git a/src/osmo-bts-sysmo/Makefile.am b/src/osmo-bts-sysmo/Makefile.am
index 6e917e7..b837d3a 100644
--- a/src/osmo-bts-sysmo/Makefile.am
+++ b/src/osmo-bts-sysmo/Makefile.am
@@ -1,4 +1,4 @@
-AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
+AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(SYSMOBTS_INCDIR)
 AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOCODEC_CFLAGS) 
$(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) 
$(LIBOSMOABIS_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOABIS_CFLAGS) 
$(LIBGPS_CFLAGS) $(ORTP_CFLAGS)
 COMMON_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBOSMOGSM_LIBS) 
$(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) $(LIBOSMOCTRL_LIBS) 
$(ORTP_LIBS)
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I0416a9f4c428189cd9c3909c8bd016ca2908128a
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 


[PATCH] osmo-bts[master]: Allow specifying sysmocom headers explicitly

2018-01-18 Thread Max

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

Allow specifying sysmocom headers explicitly

The headers for LC1.5 are specified explicitly. Add corresponding option
to specify sysmoBTS headers location and use it in jenkins build.

This is prerequisite for fixing the build issue revealed by migrating to
stow.

Change-Id: I0416a9f4c428189cd9c3909c8bd016ca2908128a
---
M configure.ac
M contrib/jenkins_sysmobts.sh
M src/osmo-bts-sysmo/Makefile.am
3 files changed, 11 insertions(+), 2 deletions(-)


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

diff --git a/configure.ac b/configure.ac
index 2181743..d2edc8e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,10 +67,19 @@
AC_HELP_STRING([--enable-sysmocom-bts],
[enable code for sysmoBTS L1/PHY [default=no]]),
[enable_sysmocom_bts="yes"],[enable_sysmocom_bts="no"])
+AC_ARG_WITH([sysmobts], [AS_HELP_STRING([--with-sysmobts=INCLUDE_DIR], 
[Location of the sysmobts API header files])],
+
[sysmobts_incdir="$withval"],[sysmobts_incdir="$incdir"])
+AC_SUBST([SYSMOBTS_INCDIR], $sysmobts_incdir)
 AC_MSG_RESULT([$enable_sysmocom_bts])
 AM_CONDITIONAL(ENABLE_SYSMOBTS, test "x$enable_sysmocom_bts" = "xyes")
 if test "$enable_sysmocom_bts" = "yes"; then
+   oldCPPFLAGS=$CPPFLAGS
+   CPPFLAGS="$CPPFLAGS -I$SYSMOBTS_INCDIR -I$srcdir/include
+   AC_CHECK_HEADER([sysmocom/femtobts/superfemto.h],[],
+   [AC_MSG_ERROR([sysmocom/femtobts/superfemto.h can not 
be found in $sysmobts_incdir])],
+   [#include ])
PKG_CHECK_MODULES(LIBGPS, libgps)
+   CPPFLAGS=$oldCPPFLAGS
 fi
 
 AC_MSG_CHECKING([whether to enable support for osmo-trx based L1/PHY support])
diff --git a/contrib/jenkins_sysmobts.sh b/contrib/jenkins_sysmobts.sh
index 852542b..3e07050 100755
--- a/contrib/jenkins_sysmobts.sh
+++ b/contrib/jenkins_sysmobts.sh
@@ -16,7 +16,7 @@
 mkdir -p "$inst/include/sysmocom/femtobts"
 ln -s $deps/layer1-headers/include/* "$inst/include/sysmocom/femtobts/"
 
-configure_flags="--enable-sysmocom-bts"
+configure_flags="--enable-sysmocom-bts --with-sysmobts=$inst/include/"
 
 # This will not work for the femtobts
 if [ $FIRMWARE_VERSION != "femtobts_v2.7" ]; then
diff --git a/src/osmo-bts-sysmo/Makefile.am b/src/osmo-bts-sysmo/Makefile.am
index 6e917e7..b837d3a 100644
--- a/src/osmo-bts-sysmo/Makefile.am
+++ b/src/osmo-bts-sysmo/Makefile.am
@@ -1,4 +1,4 @@
-AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
+AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(SYSMOBTS_INCDIR)
 AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOCODEC_CFLAGS) 
$(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) 
$(LIBOSMOABIS_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOABIS_CFLAGS) 
$(LIBGPS_CFLAGS) $(ORTP_CFLAGS)
 COMMON_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBOSMOGSM_LIBS) 
$(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) $(LIBOSMOCTRL_LIBS) 
$(ORTP_LIBS)
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0416a9f4c428189cd9c3909c8bd016ca2908128a
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] osmo-bts[master]: Fix test dependencies

2018-01-18 Thread Max
Hello Pau Espin Pedrol, Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/5818

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

Fix test dependencies

The stow-enabled jenkins builds are currently failing like below:

In file included from ../../include/osmo-bts/gsm_data.h:136:0,
 from ../../include/osmo-bts/bts.h:4,
 from misc_test.c:23:
../../include/osmo-bts/gsm_data_shared.h:21:35: fatal error: 
osmocom/abis/e1_input.h: No such file or directory
 #include 

Change-Id: I94ea8bad8b410550f72ee6a0408f42f6bd8b6cac
---
M tests/misc/Makefile.am
M tests/sysmobts/Makefile.am
2 files changed, 3 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/18/5818/10

diff --git a/tests/misc/Makefile.am b/tests/misc/Makefile.am
index 6575fe8..2ddb649 100644
--- a/tests/misc/Makefile.am
+++ b/tests/misc/Makefile.am
@@ -1,6 +1,6 @@
 AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
-AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) 
$(LIBOSMOCODEC_CFLAGS)
-LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS)
+AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) 
$(LIBOSMOCODEC_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(LIBOSMOABIS_CFLAGS)
+LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS) 
$(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS)
 noinst_PROGRAMS = misc_test
 EXTRA_DIST = misc_test.ok
 
diff --git a/tests/sysmobts/Makefile.am b/tests/sysmobts/Makefile.am
index 654ab5d..2a57b2b 100644
--- a/tests/sysmobts/Makefile.am
+++ b/tests/sysmobts/Makefile.am
@@ -1,4 +1,4 @@
-AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include 
-I$(top_srcdir)/src/osmo-bts-sysmo
+AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include 
-I$(top_srcdir)/src/osmo-bts-sysmo -I$(SYSMOBTS_INCDIR)
 AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOCODEC_CFLAGS) 
$(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(ORTP_CFLAGS)
 LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBOSMOGSM_LIBS) 
$(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) $(ORTP_LIBS)
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I94ea8bad8b410550f72ee6a0408f42f6bd8b6cac
Gerrit-PatchSet: 10
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Reviewer: neels 


osmo-bts[master]: Allow specifying sysmocom headers explicitly

2018-01-18 Thread Max

Patch Set 1:

Split to simplify the review. It's expected to fail because the fix is 
incomplete without the follow-up patch.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I0416a9f4c428189cd9c3909c8bd016ca2908128a
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Max 
Gerrit-HasComments: No


[PATCH] osmocom-bb[master]: mobile: Print an error message if the VTY cannot be initialized

2018-01-18 Thread Stefan Sperling

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

mobile: Print an error message if the VTY cannot be initialized

If we fail to initialize the VTY, print an error mesage instead of
failing silently. For example:
"Cannot init VTY on 127.0.0.1 port 4247: Address already in use"

Change-Id: I24161f53fa621ae1c8b1916bd0c8055c494b531e
---
M src/host/layer23/src/mobile/app_mobile.c
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/69/5869/1

diff --git a/src/host/layer23/src/mobile/app_mobile.c 
b/src/host/layer23/src/mobile/app_mobile.c
index 6e1fffb..b0e2a13 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -464,8 +464,11 @@
}
vty_reading = 0;
rc = telnet_init_dynif(l23_ctx, NULL, vty_ip, vty_port);
-   if (rc < 0)
+   if (rc < 0) {
+   fprintf(stderr, "Cannot init VTY on %s port %u: %s\n",
+   vty_ip, vty_port, strerror(errno));
return rc;
+   }
printf("VTY available on %s %u\n", vty_ip, vty_port);
 
osmo_signal_register_handler(SS_GLOBAL, _signal_cb, NULL);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I24161f53fa621ae1c8b1916bd0c8055c494b531e
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 


[PATCH] osmo-gsm-manuals[master]: Add note on vty logging

2018-01-18 Thread Max

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

Add note on vty logging

Change-Id: I2bb52feb37622d0ef35f6be172759adc3813f008
---
M common/chapters/logging.adoc
1 file changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals 
refs/changes/68/5868/1

diff --git a/common/chapters/logging.adoc b/common/chapters/logging.adoc
index beb1341..e79b3ec 100644
--- a/common/chapters/logging.adoc
+++ b/common/chapters/logging.adoc
@@ -127,6 +127,10 @@
 one only for logging, while the other is used for interacting with the
 system. Another option would be to use different log target.
 
+To review the current vty logging configuration, you
+can use:
+   `show logging vty`
+
  Logging to the ring buffer
 
 To avoid having separate VTY session just for logging output while still 
having immediate access to them,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2bb52feb37622d0ef35f6be172759adc3813f008
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] osmo-gsm-manuals[master]: Clarify app-specific log filters

2018-01-18 Thread Max

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

Clarify app-specific log filters

Change-Id: I53e8aed658774781a70fea0b46cafc55496925eb
---
M common/chapters/logging.adoc
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals 
refs/changes/66/5866/1

diff --git a/common/chapters/logging.adoc b/common/chapters/logging.adoc
index beb1341..652b6c2 100644
--- a/common/chapters/logging.adoc
+++ b/common/chapters/logging.adoc
@@ -81,7 +81,10 @@
 To request no filtering, i.e. see all messages, you may use:
`log filter all 1`
 
-As another example, to only see messages relating to a particular
+In addition to generic filtering, applications can implement special log 
filters using the same framework
+to filter on particular context.
+
+For example in OsmoBSC, to only see messages relating to a particular
 subscriber identified by his IMSI, you may use:
`log filter imsi 262020123456789`
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I53e8aed658774781a70fea0b46cafc55496925eb
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] osmo-mgw[master]: client: do not insist on \n\n when parsing MGCP messages

2018-01-18 Thread dexter

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

client: do not insist on \n\n when parsing MGCP messages

The current implementation of mgcp_client.c requires MGCP
paragraphs to be separated wit a \n\n sequence. However,
when the client is used with servers other than osmo-mgcp,
the parapgraph may be formatted differently.

Also allow \n\r\n\r and \r\n\r\n as separator

Change-Id: Ie209fb71499e011e52f58575c6af118de2fdee88
---
M src/libosmo-mgcp-client/mgcp_client.c
1 file changed, 23 insertions(+), 2 deletions(-)


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

diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index 9fc414d..f094a09 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -219,12 +219,33 @@
return -EINVAL;
 }
 
+/* A new section is marked by a double line break, check a few more
+ * patterns as there may be variants */
+static char *mgcp_find_section_end(char *string)
+{
+   char *rc;
+
+   rc = strstr(string, "\n\n");
+   if (rc)
+   return rc;
+
+   rc = strstr(string, "\n\r\n\r");
+   if (rc)
+   return rc;
+
+   rc = strstr(string, "\r\n\r\n");
+   if (rc)
+   return rc;
+
+   return NULL;
+}
+
 int mgcp_response_parse_params(struct mgcp_response *r)
 {
char *line;
int rc;
OSMO_ASSERT(r->body);
-   char *data = strstr(r->body, "\n\n");
+   char *data = mgcp_find_section_end(r->body);
 
if (!data) {
LOGP(DLMGCP, LOGL_ERROR,
@@ -286,7 +307,7 @@
int rc = 0;
OSMO_ASSERT(r->body);
char *data = r->body;
-   char *data_end = strstr(r->body, "\n\n");
+   char *data_end = mgcp_find_section_end(r->body);
 
/* Protect SDP body, for_each_non_empty_line() will
 * only parse until it hits \0 mark. */

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie209fb71499e011e52f58575c6af118de2fdee88
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 


osmo-bts[master]: Fix test dependencies

2018-01-18 Thread Max

Patch Set 9:

I can split it further into 2 separate patches: one fixing cflags and another 
adding cppflags if it helps to clarify this confusion. What do you think?

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I94ea8bad8b410550f72ee6a0408f42f6bd8b6cac
Gerrit-PatchSet: 9
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Reviewer: neels 
Gerrit-HasComments: No


osmo-bts[master]: Fix test dependencies

2018-01-18 Thread Max

Patch Set 9:

Because of 
https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html

In short CPPFLAGS are flags for preprocessor and is the right place to add 
things like include directories. See also implementation for other BTS models. 
The CFLAGS (and corresponding CXXFLAGS for c++) are for passing flags for 
compiler.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I94ea8bad8b410550f72ee6a0408f42f6bd8b6cac
Gerrit-PatchSet: 9
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Reviewer: neels 
Gerrit-HasComments: No


[PATCH] osmo-gsm-manuals[master]: Document workaround for gsmtap logging

2018-01-18 Thread Max

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

Document workaround for gsmtap logging

Document a way to minimize logging to stderr when gsmtap is used as a
log target.

Change-Id: I8e64a0075b5a4bad3f83660e0668e6de45b21008
---
M common/chapters/logging.adoc
1 file changed, 8 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals 
refs/changes/65/5865/1

diff --git a/common/chapters/logging.adoc b/common/chapters/logging.adoc
index beb1341..f385204 100644
--- a/common/chapters/logging.adoc
+++ b/common/chapters/logging.adoc
@@ -167,7 +167,14 @@
 .Wireshark with logs delivered over GSMTAP
 image::../common/images/wireshark-gsmtap-log.png[]
 
-Note: the logs are also duplicated to stderr when GSMTAP logging is configured.
+Note: the logs are also duplicated to stderr when GSMTAP logging is configured 
because stderr is the default log target which is
+initialized automatically. To descrease stderr logging to absolute minimum, 
you can configure it as follows:
+
+OsmoBSC> enable
+OsmoBSC# configure terminal
+OsmoBSC(config)# log stderr
+OsmoBSC(config-log)# logging level all fatal
+
 
  Logging to a file
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8e64a0075b5a4bad3f83660e0668e6de45b21008
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Max 


osmo-bts[master]: Fix test dependencies

2018-01-18 Thread Pau Espin Pedrol

Patch Set 9: Code-Review-1

(6 comments)

I think it's good having 2 separate options (enable-sysmobts, with-sysmobts), 
but it may be a good idea having a more explicit name like 
--with-sysmobts-headers or alike.

Please fix the CPPFLAGS->CFLAGS stuff or explain why is it done like this.

https://gerrit.osmocom.org/#/c/5818/9/configure.ac
File configure.ac:

Line 77:CPPFLAGS="$CPPFLAGS -I$SYSMOBTS_INCDIR -I$srcdir/include 
$LIBOSMOCORE_CFLAGS"
Why CPPFLAGS and not CFLAGS?


Line 82:CPPFLAGS=$oldCPPFLAGS
same


https://gerrit.osmocom.org/#/c/5818/9/contrib/jenkins_sysmobts.sh
File contrib/jenkins_sysmobts.sh:

Line 19: configure_flags="--with-sysmobts=$inst/include/ --enable-sysmocom-bts"
Sound more natural for me first enabling it, then specifying the headers path, 
but it really doesn't matter :P


https://gerrit.osmocom.org/#/c/5818/9/src/osmo-bts-sysmo/Makefile.am
File src/osmo-bts-sysmo/Makefile.am:

Line 1: AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include 
-I$(SYSMOBTS_INCDIR)
agaion why cppflags and not cflags?


https://gerrit.osmocom.org/#/c/5818/9/tests/misc/Makefile.am
File tests/misc/Makefile.am:

Line 2: AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) 
$(LIBOSMOCODEC_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(LIBOSMOABIS_CFLAGS)
In here CFLAGS are used and not CPPFLAGS.


https://gerrit.osmocom.org/#/c/5818/9/tests/sysmobts/Makefile.am
File tests/sysmobts/Makefile.am:

Line 1: AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include 
-I$(top_srcdir)/src/osmo-bts-sysmo -I$(SYSMOBTS_INCDIR)
again CPPFLAGS


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I94ea8bad8b410550f72ee6a0408f42f6bd8b6cac
Gerrit-PatchSet: 9
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Reviewer: neels 
Gerrit-HasComments: Yes


osmo-msc[master]: libmsc: a_iface_bssap.c: Fix compilation warning

2018-01-18 Thread Stefan Sperling

Patch Set 2: -Code-Review

(1 comment)

https://gerrit.osmocom.org/#/c/5424/2/src/libmsc/a_iface_bssap.c
File src/libmsc/a_iface_bssap.c:

Line 328:   msg->l3h = msgb_put(msg, TLVP_LEN(, 
GSM0808_IE_LAYER_3_INFORMATION));
> The point here is that the MSC side is the "trusted core network" and that 
This change should avoid the issue: https://gerrit.osmocom.org/#/c/5689/


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I28073efd5cff58cd212341bceee784caf08d5ad8
Gerrit-PatchSet: 2
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: Yes


[PATCH] osmo-pcu[master]: TBF: make poll state internal

2018-01-18 Thread Max

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

TBF: make poll state internal

* add functions/macros for setting TBF's poll state
* add function for checking TBF's poll state
* update TBF test output due to extended state transition logging

Change-Id: I6db1c4e7bd0a49aeb5e391afe371c36b96c6a702
Related: OS#1539
---
M src/bts.cpp
M src/gprs_rlcmac_sched.cpp
M src/poll_controller.cpp
M src/tbf.cpp
M src/tbf.h
M src/tbf_dl.cpp
M src/tbf_ul.cpp
M tests/tbf/TbfTest.err
8 files changed, 59 insertions(+), 14 deletions(-)


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

diff --git a/src/bts.cpp b/src/bts.cpp
index f614c1a..94354f2 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -399,7 +399,7 @@
 
 static inline bool tbf_check(gprs_rlcmac_tbf *tbf, uint32_t fn, uint8_t 
trx_no, uint8_t ts)
 {
-   if (tbf->state_is_not(GPRS_RLCMAC_RELEASING) && tbf->poll_state == 
GPRS_RLCMAC_POLL_SCHED
+   if (tbf->state_is_not(GPRS_RLCMAC_RELEASING) && tbf->poll_scheduled()
&& tbf->poll_fn == fn && tbf->trx->trx_no == trx_no && tbf->poll_ts 
== ts)
return true;
 
@@ -1010,7 +1010,7 @@
tbf->update_ms(tlli, GPRS_RLCMAC_UL_TBF);
 
LOGPTBF(tbf, LOGL_DEBUG, "RX: [PCU <- BTS] Packet Control Ack\n");
-   tbf->poll_state = GPRS_RLCMAC_POLL_NONE;
+   TBF_POLL_SCHED_UNSET(tbf);
 
/* check if this control ack belongs to packet uplink ack */
ul_tbf = as_ul_tbf(tbf);
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index 3f9fcb1..ebf4714 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -49,8 +49,7 @@
if (ul_tbf->trx->trx_no != trx || !ul_tbf->is_control_ts(ts))
continue;
/* polling for next uplink block */
-   if (ul_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED
-&& ul_tbf->poll_fn == poll_fn)
+   if (ul_tbf->poll_scheduled() && ul_tbf->poll_fn == poll_fn)
*poll_tbf = ul_tbf;
if (ul_tbf->ul_ack_state_is(GPRS_RLCMAC_UL_ACK_SEND_ACK))
*ul_ack_tbf = ul_tbf;
@@ -69,8 +68,7 @@
if (dl_tbf->trx->trx_no != trx || !dl_tbf->is_control_ts(ts))
continue;
/* polling for next uplink block */
-   if (dl_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED
-&& dl_tbf->poll_fn == poll_fn)
+   if (dl_tbf->poll_scheduled() && dl_tbf->poll_fn == poll_fn)
*poll_tbf = dl_tbf;
if (dl_tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_SEND_ASS))
*dl_ass_tbf = dl_tbf;
diff --git a/src/poll_controller.cpp b/src/poll_controller.cpp
index f8ab6c9..5c5a717 100644
--- a/src/poll_controller.cpp
+++ b/src/poll_controller.cpp
@@ -47,14 +47,14 @@
 
llist_for_each(pos, _bts.ul_tbfs()) {
ul_tbf = as_ul_tbf(pos->entry());
-   if (ul_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED) {
+   if (ul_tbf->poll_scheduled()) {
if (elapsed_fn_check(max_delay, frame_number, 
ul_tbf->poll_fn))
ul_tbf->poll_timeout();
}
}
llist_for_each(pos, _bts.dl_tbfs()) {
dl_tbf = as_dl_tbf(pos->entry());
-   if (dl_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED) {
+   if (dl_tbf->poll_scheduled()) {
if (elapsed_fn_check(max_delay, frame_number, 
dl_tbf->poll_fn))
dl_tbf->poll_timeout();
}
diff --git a/src/tbf.cpp b/src/tbf.cpp
index ef78820..241c3eb 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -45,6 +45,12 @@
 
 static void tbf_timer_cb(void *_tbf);
 
+const struct value_string gprs_rlcmac_tbf_poll_state_names[] = {
+   OSMO_VALUE_STRING(GPRS_RLCMAC_POLL_NONE),
+   OSMO_VALUE_STRING(GPRS_RLCMAC_POLL_SCHED), /* a polling was scheduled */
+   { 0, NULL }
+};
+
 const struct value_string gprs_rlcmac_tbf_dl_ass_state_names[] = {
OSMO_VALUE_STRING(GPRS_RLCMAC_DL_ASS_NONE),
OSMO_VALUE_STRING(GPRS_RLCMAC_DL_ASS_SEND_ASS),
@@ -172,7 +178,6 @@
first_ts(0),
first_common_ts(0),
control_ts(0xff),
-   poll_state(GPRS_RLCMAC_POLL_NONE),
poll_fn(0),
poll_ts(0),
n3105(0),
@@ -192,6 +197,7 @@
dl_ass_state(GPRS_RLCMAC_DL_ASS_NONE),
ul_ass_state(GPRS_RLCMAC_UL_ASS_NONE),
ul_ack_state(GPRS_RLCMAC_UL_ACK_NONE),
+   poll_state(GPRS_RLCMAC_POLL_NONE),
m_list(this),
m_ms_list(this),
m_egprs_enabled(false)
diff --git a/src/tbf.h b/src/tbf.h
index 19aa41a..4fea9ff 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -64,6 +64,8 @@
GPRS_RLCMAC_POLL_SCHED, /* a polling was scheduled */
 };
 
+extern const struct value_string gprs_rlcmac_tbf_poll_state_names[];
+
 enum gprs_rlcmac_tbf_dl_ass_state {
GPRS_RLCMAC_DL_ASS_NONE = 0,

[PATCH] osmo-pcu[master]: TBF: make UL ack state internal

2018-01-18 Thread Max

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

TBF: make UL ack state internal

* add functions/macros for setting TBF's UL ack state
* add functions for checking TBF's UL ack state
* update TBF test output due to extended state transition logging

N. B: this should not be confused with TBF-UL state.

Change-Id: I144483447d4b0b93e775da0e926ee45eb8ab39f3
Related: OS#1539
---
M src/gprs_rlcmac_sched.cpp
M src/tbf.cpp
M src/tbf.h
M src/tbf_ul.cpp
M tests/tbf/TbfTest.cpp
M tests/tbf/TbfTest.err
6 files changed, 49 insertions(+), 13 deletions(-)


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

diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index a87217f..3f9fcb1 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -52,7 +52,7 @@
if (ul_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED
 && ul_tbf->poll_fn == poll_fn)
*poll_tbf = ul_tbf;
-   if (ul_tbf->ul_ack_state == GPRS_RLCMAC_UL_ACK_SEND_ACK)
+   if (ul_tbf->ul_ack_state_is(GPRS_RLCMAC_UL_ACK_SEND_ACK))
*ul_ack_tbf = ul_tbf;
if (ul_tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_SEND_ASS))
*dl_ass_tbf = ul_tbf;
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 6ebe77e..ef78820 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -60,6 +60,13 @@
{ 0, NULL }
 };
 
+const struct value_string gprs_rlcmac_tbf_ul_ack_state_names[] = {
+   OSMO_VALUE_STRING(GPRS_RLCMAC_UL_ACK_NONE),
+   OSMO_VALUE_STRING(GPRS_RLCMAC_UL_ACK_SEND_ACK), /* send acknowledge on 
next RTS */
+   OSMO_VALUE_STRING(GPRS_RLCMAC_UL_ACK_WAIT_ACK), /* wait for PACKET 
CONTROL ACK */
+   { 0, NULL }
+};
+
 static const struct value_string tbf_timers_names[] = {
OSMO_VALUE_STRING(T0),
OSMO_VALUE_STRING(T3169),
@@ -165,7 +172,6 @@
first_ts(0),
first_common_ts(0),
control_ts(0xff),
-   ul_ack_state(GPRS_RLCMAC_UL_ACK_NONE),
poll_state(GPRS_RLCMAC_POLL_NONE),
poll_fn(0),
poll_ts(0),
@@ -185,6 +191,7 @@
state(GPRS_RLCMAC_NULL),
dl_ass_state(GPRS_RLCMAC_DL_ASS_NONE),
ul_ass_state(GPRS_RLCMAC_UL_ASS_NONE),
+   ul_ack_state(GPRS_RLCMAC_UL_ACK_NONE),
m_list(this),
m_ms_list(this),
m_egprs_enabled(false)
diff --git a/src/tbf.h b/src/tbf.h
index 7cc0587..19aa41a 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -87,6 +87,8 @@
GPRS_RLCMAC_UL_ACK_WAIT_ACK, /* wait for PACKET CONTROL ACK */
 };
 
+extern const struct value_string gprs_rlcmac_tbf_ul_ack_state_names[];
+
 enum gprs_rlcmac_tbf_direction {
GPRS_RLCMAC_DL_TBF,
GPRS_RLCMAC_UL_TBF
@@ -183,6 +185,7 @@
 #define TBF_SET_STATE(t, st) do { t->set_state(st, __FILE__, __LINE__); } 
while(0)
 #define TBF_SET_ASS_STATE_DL(t, st) do { t->set_ass_state_dl(st, __FILE__, 
__LINE__); } while(0)
 #define TBF_SET_ASS_STATE_UL(t, st) do { t->set_ass_state_ul(st, __FILE__, 
__LINE__); } while(0)
+#define TBF_SET_ACK_STATE(t, st) do { t->set_ack_state(st, __FILE__, 
__LINE__); } while(0)
 #define TBF_SET_ASS_ON(t, fl, chk) do { t->set_assigned_on(fl, chk, __FILE__, 
__LINE__); } while(0)
 
 struct gprs_rlcmac_tbf {
@@ -195,9 +198,11 @@
bool state_is_not(enum gprs_rlcmac_tbf_state rhs) const;
bool dl_ass_state_is(enum gprs_rlcmac_tbf_dl_ass_state rhs) const;
bool ul_ass_state_is(enum gprs_rlcmac_tbf_ul_ass_state rhs) const;
+   bool ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state rhs) const;
void set_state(enum gprs_rlcmac_tbf_state new_state, const char *file, 
int line);
void set_ass_state_dl(enum gprs_rlcmac_tbf_dl_ass_state new_state, 
const char *file, int line);
void set_ass_state_ul(enum gprs_rlcmac_tbf_ul_ass_state new_state, 
const char *file, int line);
+   void set_ack_state(enum gprs_rlcmac_tbf_ul_ack_state new_state, const 
char *file, int line);
void check_pending_ass();
bool check_n_clear(uint8_t state_flag);
void set_assigned_on(uint8_t state_flag, bool check_ccch, const char 
*file, int line);
@@ -279,8 +284,6 @@
 
gprs_llc m_llc;
 
-   enum gprs_rlcmac_tbf_ul_ack_state ul_ack_state;
-
enum gprs_rlcmac_tbf_poll_state poll_state;
uint32_t poll_fn; /* frame number to poll */
uint8_t poll_ts; /* TS to poll */
@@ -343,6 +346,7 @@
enum gprs_rlcmac_tbf_state state;
enum gprs_rlcmac_tbf_dl_ass_state dl_ass_state;
enum gprs_rlcmac_tbf_ul_ass_state ul_ass_state;
+   enum gprs_rlcmac_tbf_ul_ack_state ul_ack_state;
LListHead m_list;
LListHead m_ms_list;
bool m_egprs_enabled;
@@ -383,6 +387,11 @@
 inline bool gprs_rlcmac_tbf::ul_ass_state_is(enum gprs_rlcmac_tbf_ul_ass_state 
rhs) const
 {
return ul_ass_state == rhs;
+}
+
+inline bool gprs_rlcmac_tbf::ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state 
rhs) const
+{
+   return ul_ack_state == rhs;
 

[PATCH] osmo-pcu[master]: TBF: make UL/DL state internal

2018-01-18 Thread Max

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

TBF: make UL/DL state internal

* add functions/macros for setting TBF's UL/DL state
* add functions for checking TBF's UL/DL state
* move pre-free check into separate function
* update TBF test output due to extended state transition logging

N. B: this should not be confused with TBF-UL or TBF-DL state.

Change-Id: Idcbf5775d17b1247f2ed01788f9b0788ce66e871
Related: OS#1539
---
M src/bts.cpp
M src/gprs_rlcmac_sched.cpp
M src/tbf.cpp
M src/tbf.h
M src/tbf_dl.cpp
M tests/tbf/TbfTest.cpp
M tests/tbf/TbfTest.err
7 files changed, 175 insertions(+), 49 deletions(-)


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

diff --git a/src/bts.cpp b/src/bts.cpp
index 873af73..f614c1a 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -1022,11 +1022,11 @@
tbf_free(tbf);
return;
}
-   if (tbf->dl_ass_state == GPRS_RLCMAC_DL_ASS_WAIT_ACK) {
+   if (tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_WAIT_ACK)) {
LOGPTBF(tbf, LOGL_DEBUG, "[UPLINK] DOWNLINK ASSIGNED\n");
/* reset N3105 */
tbf->n3105 = 0;
-   tbf->dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE;
+   TBF_SET_ASS_STATE_DL(tbf, GPRS_RLCMAC_DL_ASS_NONE);
 
new_tbf = tbf->ms() ? tbf->ms()->dl_tbf() : NULL;
if (!new_tbf) {
@@ -1054,11 +1054,11 @@
tbf_assign_control_ts(new_tbf);
return;
}
-   if (tbf->ul_ass_state == GPRS_RLCMAC_UL_ASS_WAIT_ACK) {
+   if (tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_WAIT_ACK)) {
LOGPTBF(tbf, LOGL_DEBUG, "[DOWNLINK] UPLINK ASSIGNED\n");
/* reset N3105 */
tbf->n3105 = 0;
-   tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_NONE;
+   TBF_SET_ASS_STATE_UL(tbf, GPRS_RLCMAC_UL_ASS_NONE);
 
new_tbf = tbf->ms() ? tbf->ms()->ul_tbf() : NULL;
if (!new_tbf) {
@@ -1156,10 +1156,10 @@
/* schedule uplink assignment or reject */
if (ul_tbf) {
LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF in ack message, 
so we provide one:\n");
-   tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_SEND_ASS;
+   TBF_SET_ASS_STATE_UL(tbf, GPRS_RLCMAC_UL_ASS_SEND_ASS);
} else {
LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF in ack message, 
so we packet access reject:\n");
-   tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ;
+   TBF_SET_ASS_STATE_UL(tbf, GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ);
}
 }
 
@@ -1403,7 +1403,7 @@
 
ul_tbf->control_ts = ts_no;
/* schedule uplink assignment */
-   ul_tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_SEND_ASS;
+   TBF_SET_ASS_STATE_UL(ul_tbf, GPRS_RLCMAC_UL_ASS_SEND_ASS);
 
/* get capabilities */
if (ul_tbf->ms())
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index 8925032..a87217f 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -54,11 +54,10 @@
*poll_tbf = ul_tbf;
if (ul_tbf->ul_ack_state == GPRS_RLCMAC_UL_ACK_SEND_ACK)
*ul_ack_tbf = ul_tbf;
-   if (ul_tbf->dl_ass_state == GPRS_RLCMAC_DL_ASS_SEND_ASS)
+   if (ul_tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_SEND_ASS))
*dl_ass_tbf = ul_tbf;
-   if (ul_tbf->ul_ass_state == GPRS_RLCMAC_UL_ASS_SEND_ASS
-   || ul_tbf->ul_ass_state ==
-   GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ)
+   if (ul_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS)
+   || ul_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
*ul_ass_tbf = ul_tbf;
 /* FIXME: Is this supposed to be fair? The last TBF for each wins? Maybe use 
llist_add_tail and skip once we have all
 states? */
@@ -73,10 +72,10 @@
if (dl_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED
 && dl_tbf->poll_fn == poll_fn)
*poll_tbf = dl_tbf;
-   if (dl_tbf->dl_ass_state == GPRS_RLCMAC_DL_ASS_SEND_ASS)
+   if (dl_tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_SEND_ASS))
*dl_ass_tbf = dl_tbf;
-   if (dl_tbf->ul_ass_state == GPRS_RLCMAC_UL_ASS_SEND_ASS
-|| dl_tbf->ul_ass_state == GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ)
+   if (dl_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS)
+   || dl_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
*ul_ass_tbf = dl_tbf;
}
 
@@ -139,13 +138,11 @@
 * because they may kill the TBF when the CONTROL ACK is
 * received, thus preventing the others from being processed.
 */
-   if (tbf == ul_ass_tbf && tbf->ul_ass_state ==
- 

libosmocore[master]: tests: fix LDADD: link libosmovty from current build

2018-01-18 Thread Max

Patch Set 2: -Code-Review

> This is the main change of this patch.

Adding yes, string splitting - no. But like I've said, I don't consider it to 
be blocker.

> following the pattern present in this file

So this slipped passed review sometime before. Should be fixed as well.

> could you clarify?

It's documented in 
https://www.gnu.org/software/automake/manual/html_node/Linking.html
In a nutshell, LDADD applies to all the programs, prog_LDADD applies single 
program. So having only "prog_LDADD = $(LDADD)" is confusing and redundant.

> to fix LDADD in a separate patch?

Sure but please fix all such entries and submit it together with this one.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id084e6e6efd25cd62b1bd7a4fc7c5985c39130c6
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


libosmo-sccp[master]: sccp_types.h: Fix value for SCCP_REFUSAL_UNEQUIPPED_USER

2018-01-18 Thread Max

Patch Set 1: Code-Review+1

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

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


[ABANDON] libosmocore[master]: gsm0480: expose the gsm0480_parse_ss_facility_ie()

2018-01-18 Thread Vadim Yanitskiy
Vadim Yanitskiy has abandoned this change.

Change subject: gsm0480: expose the gsm0480_parse_ss_facility_ie()
..


Abandoned

Change is not required anymore.

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

Gerrit-MessageType: abandon
Gerrit-Change-Id: I35d3360f36c48eb1295610ab96ff264c45af77eb
Gerrit-PatchSet: 9
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-Reviewer: Vadim Yanitskiy