osmo-mgw[master]: protocol: reject DLCX/CRCX/MDCX on unsupported parameters

2018-02-05 Thread dexter

Patch Set 2:

> Copy+paste error, uses CRCX in the response function call even for
 > mdcx or dlcx

Fixed.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I8cd5987fc6befcd53a7c4916f77b1a24c904ba48
Gerrit-PatchSet: 2
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


osmo-mgw[master]: protocol: prohibit wildcarded requests for MDCX and DLCX

2018-02-05 Thread dexter

Patch Set 2:

> Copy,+paste error, DLCX used in MDCX api call

fixed.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ia77d44a6a86083e62338e5845b553e5cf13ebd10
Gerrit-PatchSet: 2
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


osmo-mgw[master]: protocol: prohibit wildcarded requests for MDCX and DLCX

2018-02-05 Thread Harald Welte

Patch Set 2:

Only one of two instances fixed. Please be more diligent, thanks.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ia77d44a6a86083e62338e5845b553e5cf13ebd10
Gerrit-PatchSet: 2
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


osmo-mgw[master]: protocol: reject DLCX/CRCX/MDCX on unsupported parameters

2018-02-05 Thread Harald Welte

Patch Set 2:

Same here. only one of many instances fixed. Please check more thoroughly 
before resubmit, thanks.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I8cd5987fc6befcd53a7c4916f77b1a24c904ba48
Gerrit-PatchSet: 2
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


[MERGED] osmo-msc[master]: Implement checks for duplicate uplink UL L3 message

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Implement checks for duplicate uplink UL L3 message
..


Implement checks for duplicate uplink UL L3 message

According to TS 24.007 Section 11.2.3.2.3, it is possible that uplink L3
messages are duplicated in some scenarios, particularly during
assignment/handover procedure.

To avoid L3 entities from seeing duplicated messages, there's a modulo-2
or modulo-4 message sequence counter, based on which the MSC can detect
and suppress such duplicate messages.

It appears that even our unit tests were wrong in that regard so far.
Rather than manually adjusting each and every message, let's make sure
that the sequence number generation always increments as expected, and
that during matching of incoming messages, sequence numbers are masked
out.

Note: the tests will only pass from libosmocore Change-Id
Iec875a77f5458322dfbef174f5abfc0e8c09d464 onwards, due to
gsm48_hdr_msg_type() being broken in earlier versions.

Change-Id: Id15e399ab7e1b05dcd426b292886fa19d36082b1
Closes: #2908
---
M include/osmocom/msc/gsm_data.h
M src/libmsc/gsm_04_08.c
M tests/msc_vlr/msc_vlr_tests.c
3 files changed, 137 insertions(+), 0 deletions(-)

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



diff --git a/include/osmocom/msc/gsm_data.h b/include/osmocom/msc/gsm_data.h
index 27324d7..16e83f3 100644
--- a/include/osmocom/msc/gsm_data.h
+++ b/include/osmocom/msc/gsm_data.h
@@ -184,6 +184,9 @@
uint16_t lac;
struct gsm_encr encr;
 
+   /* N(SD) expected in the received frame, per flow (TS 24.007 
11.2.3.2.3.2.2) */
+   uint8_t n_sd_next[4];
+
struct {
unsigned int mgcp_rtp_endpoint;
uint16_t port_subscr;
diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c
index c9ea2c8..5acc4e4 100644
--- a/src/libmsc/gsm_04_08.c
+++ b/src/libmsc/gsm_04_08.c
@@ -3302,6 +3302,94 @@
conn->received_cm_service_request = false;
 }
 
+/* TS 24.007 11.2.3.2.3 Message Type Octet / Duplicate Detection */
+int gsm0407_pdisc_ctr_bin(uint8_t pdisc)
+{
+   switch (pdisc) {
+   case GSM48_PDISC_MM:
+   case GSM48_PDISC_CC:
+   case GSM48_PDISC_NC_SS:
+   return 0;
+   case GSM48_PDISC_GROUP_CC:
+   return 1;
+   case GSM48_PDISC_BCAST_CC:
+   return 2;
+   case GSM48_PDISC_LOC:
+   return 3;
+   default:
+   return -1;
+   }
+}
+
+/* extract the N(SD) and return the modulo value for a R98 message */
+static uint8_t gsm0407_determine_nsd_ret_modulo_r99(uint8_t pdisc, uint8_t 
msg_type, uint8_t *n_sd)
+{
+   switch (pdisc) {
+   case GSM48_PDISC_MM:
+   case GSM48_PDISC_CC:
+   case GSM48_PDISC_NC_SS:
+   *n_sd = (msg_type >> 6) & 0x3;
+   return 4;
+   case GSM48_PDISC_GROUP_CC:
+   case GSM48_PDISC_BCAST_CC:
+   case GSM48_PDISC_LOC:
+   *n_sd = (msg_type >> 6) & 0x1;
+   return 2;
+   default:
+   /* no sequence number, we cannot detect dups */
+   return 0;
+   }
+}
+
+/* extract the N(SD) and return the modulo value for a R99 message */
+static uint8_t gsm0407_determine_nsd_ret_modulo_r98(uint8_t pdisc, uint8_t 
msg_type, uint8_t *n_sd)
+{
+   switch (pdisc) {
+   case GSM48_PDISC_MM:
+   case GSM48_PDISC_CC:
+   case GSM48_PDISC_NC_SS:
+   case GSM48_PDISC_GROUP_CC:
+   case GSM48_PDISC_BCAST_CC:
+   case GSM48_PDISC_LOC:
+   *n_sd = (msg_type >> 6) & 0x1;
+   return 2;
+   default:
+   /* no sequence number, we cannot detect dups */
+   return 0;
+   }
+}
+
+/* TS 24.007 11.2.3.2 Message Type Octet / Duplicate Detection */
+static bool gsm0407_is_duplicate(struct gsm_subscriber_connection *conn, 
struct msgb *msg)
+{
+   struct gsm48_hdr *gh;
+   uint8_t pdisc;
+   uint8_t n_sd, modulo, bin;
+
+   gh = msgb_l3(msg);
+   pdisc = gsm48_hdr_pdisc(gh);
+
+   if (conn->classmark.classmark1_set && 
conn->classmark.classmark1.rev_lev < 2) {
+   modulo = gsm0407_determine_nsd_ret_modulo_r98(pdisc, 
gh->msg_type, &n_sd);
+   } else { /* R99 */
+   modulo = gsm0407_determine_nsd_ret_modulo_r99(pdisc, 
gh->msg_type, &n_sd);
+   }
+   if (modulo == 0)
+   return false;
+   bin = gsm0407_pdisc_ctr_bin(pdisc);
+   if (bin < 0)
+   return false;
+
+   OSMO_ASSERT(bin < ARRAY_SIZE(conn->n_sd_next));
+   if (n_sd != conn->n_sd_next[bin]) {
+   /* not what we expected: duplicate */
+   return true;
+   } else {
+   /* as expected: no dup; update expected counter for next 
message */
+   conn->n_sd_next[bin] = (n_sd + 1) % modulo;
+   return false;
+   }
+}
 
 /* Main entry point

osmo-msc[master]: Implement checks for duplicate uplink UL L3 message

2018-02-05 Thread Harald Welte

Patch Set 3: Code-Review+2

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

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


osmo-pcu[master]: vty: add commands to show TBF of a certain kind

2018-02-05 Thread Max

Patch Set 1:

> Could be one command with (all|pacch|...)

Sure. What would be advantage of such approach? In case of separate commands 
it's trivial 1-liner functions. If we use single command with parameters than 
we have to check for parameter value using switch or if ladder.

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

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


[PATCH] osmo-mgw[master]: protocol: prohibit wildcarded requests for MDCX and DLCX

2018-02-05 Thread dexter
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6260

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

protocol: prohibit wildcarded requests for MDCX and DLCX

When a wildcarded request is made with a DLCX or MDCX command
the MGW will search for a free endpoint and continues the command
execution with that endpoint.

- Catch the wildcarded request early on DLCX and MDCX and return
  with an error code.

See also TTCN3 testcases:
MGCP_Test.TC_mdcx_wildcarded
MGCP_Test.TC_dlcx_wildcarded

Change-Id: Ia77d44a6a86083e62338e5845b553e5cf13ebd10
---
M src/libosmo-mgcp/mgcp_protocol.c
1 file changed, 16 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/60/6260/3

diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 62487d1..49e1ead 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -739,6 +739,14 @@
 
LOGP(DLMGCP, LOGL_NOTICE, "MDCX: modifying existing connection ...\n");
 
+   /* Prohibit wildcarded requests */
+   if (endp->wildcarded_req) {
+   LOGP(DLMGCP, LOGL_ERROR,
+"DLCX: endpoint:0x%x wildcarded endpoint names not 
supported.\n",
+ENDPOINT_NUMBER(endp));
+   return create_err_response(endp, 507, "MDCX", p->trans);
+   }
+
if (llist_count(&endp->conns) <= 0) {
LOGP(DLMGCP, LOGL_ERROR,
 "MDCX: endpoint:0x%x endpoint is not holding a 
connection.\n",
@@ -912,6 +920,14 @@
 "DLCX: endpoint:0x%x deleting connection ...\n",
 ENDPOINT_NUMBER(endp));
 
+   /* Prohibit wildcarded requests */
+   if (endp->wildcarded_req) {
+   LOGP(DLMGCP, LOGL_ERROR,
+"DLCX: endpoint:0x%x wildcarded endpoint names not 
supported.\n",
+ENDPOINT_NUMBER(endp));
+   return create_err_response(endp, 507, "DLCX", p->trans);
+   }
+
if (llist_count(&endp->conns) <= 0) {
LOGP(DLMGCP, LOGL_ERROR,
 "DLCX: endpoint:0x%x endpoint is not holding a 
connection.\n",

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ia77d44a6a86083e62338e5845b553e5cf13ebd10
Gerrit-PatchSet: 3
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 


[PATCH] osmo-mgw[master]: cosmetic: rename mgcp_ep.c/h to mgcp_endp.c/h

2018-02-05 Thread dexter
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6246

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

cosmetic: rename mgcp_ep.c/h to mgcp_endp.c/h

The short term of endpoint has always been "endp" througout the whole
project and not "ep".

- rename mcgp_ep.c to mgcp_endp.c

- rename mgcp_ep.h to mgcp_endp.h

Change-Id: Id52047bb2d0407655ac272c858ed3412b8ae9e6d
---
M include/osmocom/mgcp/Makefile.am
R include/osmocom/mgcp/mgcp_endp.h
M src/libosmo-mgcp/Makefile.am
M src/libosmo-mgcp/mgcp_conn.c
R src/libosmo-mgcp/mgcp_endp.c
M src/libosmo-mgcp/mgcp_msg.c
M src/libosmo-mgcp/mgcp_network.c
M src/libosmo-mgcp/mgcp_osmux.c
M src/libosmo-mgcp/mgcp_protocol.c
M src/libosmo-mgcp/mgcp_sdp.c
M src/libosmo-mgcp/mgcp_vty.c
M src/osmo-mgw/mgw_main.c
M tests/mgcp/mgcp_test.c
13 files changed, 12 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/46/6246/4

diff --git a/include/osmocom/mgcp/Makefile.am b/include/osmocom/mgcp/Makefile.am
index d706807..7e297e4 100644
--- a/include/osmocom/mgcp/Makefile.am
+++ b/include/osmocom/mgcp/Makefile.am
@@ -3,7 +3,7 @@
mgcp_msg.h \
mgcp_conn.h \
mgcp_stat.h \
-   mgcp_ep.h \
+   mgcp_endp.h \
mgcp_sdp.h \
debug.h \
$(NULL)
diff --git a/include/osmocom/mgcp/mgcp_ep.h b/include/osmocom/mgcp/mgcp_endp.h
similarity index 100%
rename from include/osmocom/mgcp/mgcp_ep.h
rename to include/osmocom/mgcp/mgcp_endp.h
diff --git a/src/libosmo-mgcp/Makefile.am b/src/libosmo-mgcp/Makefile.am
index a785d62..fbb1a2e 100644
--- a/src/libosmo-mgcp/Makefile.am
+++ b/src/libosmo-mgcp/Makefile.am
@@ -42,7 +42,7 @@
mgcp_msg.c \
mgcp_conn.c \
mgcp_stat.c \
-   mgcp_ep.c \
+   mgcp_endp.c \
$(NULL)
 
 libosmo_mgcp_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(MGCP_LIBVERSION)
diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c
index a136fda..cc115a9 100644
--- a/src/libosmo-mgcp/mgcp_conn.c
+++ b/src/libosmo-mgcp/mgcp_conn.c
@@ -24,7 +24,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/src/libosmo-mgcp/mgcp_ep.c b/src/libosmo-mgcp/mgcp_endp.c
similarity index 97%
rename from src/libosmo-mgcp/mgcp_ep.c
rename to src/libosmo-mgcp/mgcp_endp.c
index 5f75f0e..77310c6 100644
--- a/src/libosmo-mgcp/mgcp_ep.c
+++ b/src/libosmo-mgcp/mgcp_endp.c
@@ -22,7 +22,7 @@
  */
 
 #include 
-#include 
+#include 
 
 /* Endpoint typeset definition */
 const struct mgcp_endpoint_typeset ep_typeset = {
diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c
index 034b64f..f533d55 100644
--- a/src/libosmo-mgcp/mgcp_msg.c
+++ b/src/libosmo-mgcp/mgcp_msg.c
@@ -28,7 +28,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 /*! Display an mgcp message on the log output.
  *  \param[in] message mgcp message string
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 6cecbb0..ef6357b 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -39,7 +39,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #define RTP_SEQ_MOD(1 << 16)
diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c
index 1bb7aa6..1d3cab3 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -24,7 +24,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 static struct osmo_fd osmux_fd;
 
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index c6beaa4..b0d9943 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -38,7 +38,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 struct mgcp_request {
diff --git a/src/libosmo-mgcp/mgcp_sdp.c b/src/libosmo-mgcp/mgcp_sdp.c
index 1dffbfc..52b4df4 100644
--- a/src/libosmo-mgcp/mgcp_sdp.c
+++ b/src/libosmo-mgcp/mgcp_sdp.c
@@ -24,7 +24,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 
diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c
index 5378931..14ecd17 100644
--- a/src/libosmo-mgcp/mgcp_vty.c
+++ b/src/libosmo-mgcp/mgcp_vty.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 
diff --git a/src/osmo-mgw/mgw_main.c b/src/osmo-mgw/mgw_main.c
index 4452ae3..f95a1c7 100644
--- a/src/osmo-mgw/mgw_main.c
+++ b/src/osmo-mgw/mgw_main.c
@@ -37,7 +37,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 #include 
diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
index 4d39bda..38a0a46 100644
--- a/tests/mgcp/mgcp_test.c
+++ b/tests/mgcp/mgcp_test.c
@@ -25,7 +25,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 #include 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Id5

[PATCH] osmo-mgw[master]: protocol: reject DLCX/CRCX/MDCX on unsupported parameters

2018-02-05 Thread dexter
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6255

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

protocol: reject DLCX/CRCX/MDCX on unsupported parameters

When an unsupported MGCP parameter (e.g. N) is used, then this
parameter is ignored and the command execution continues. However,
an MGCP command that contains an unsupported parameter should
be rejected.

- Make sure that MGCP commands DLCX, CRCX and MDCX are rejected,
  when they contain unsupported parameters.

Change-Id: I8cd5987fc6befcd53a7c4916f77b1a24c904ba48
---
M src/libosmo-mgcp/mgcp_protocol.c
1 file changed, 3 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/55/6255/3

diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index b0d9943..2cbd87b 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -535,6 +535,7 @@
LOGP(DLMGCP, LOGL_NOTICE,
 "CRCX: endpoint:%x unhandled option: '%c'/%d\n",
 ENDPOINT_NUMBER(endp), *line, *line);
+   return create_err_response(NULL, 539, "CRCX", p->trans);
break;
}
}
@@ -768,6 +769,7 @@
LOGP(DLMGCP, LOGL_NOTICE,
 "MDCX: endpoint:0x%x Unhandled MGCP option: 
'%c'/%d\n",
 ENDPOINT_NUMBER(endp), line[0], line[0]);
+   return create_err_response(NULL, 539, "MDCX", p->trans);
break;
}
}
@@ -918,6 +920,7 @@
LOGP(DLMGCP, LOGL_NOTICE,
 "DLCX: endpoint:0x%x Unhandled MGCP option: 
'%c'/%d\n",
 ENDPOINT_NUMBER(endp), line[0], line[0]);
+   return create_err_response(NULL, 539, "DLCX", p->trans);
break;
}
}

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I8cd5987fc6befcd53a7c4916f77b1a24c904ba48
Gerrit-PatchSet: 3
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 


[PATCH] osmo-mgw[master]: mgcp: fix use-after-free and add callback for endpoint cleanup

2018-02-05 Thread dexter
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6006

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

mgcp: fix use-after-free and add callback for endpoint cleanup

Since we will support multiple different types of endpoints in the
future, all these endpoints will handle connections slightly different
and there will be possibly state that needs to be kept consistant
when a connection is deleted.

In mgcp_network.c where we implement the callback that is used to
create an rtp-bride-endpoint. In that callback we cache the pointer
of the connection we where we want to bride to (opposite connection).
When one of the connections is deleted using a DLCX operation, the
pointer is still there and the next incoming packet causes a use-
after-free segfault.

- introduce an endpoint specific callback function that is executed
  before removing the connection.

- implement the endpoint specific callback for rtp bridge endpoints,
  so that the use-after-free is prevented.

Change-Id: I921d9bbe58be1c3298e164a37f3c974880b3759f
---
M include/osmocom/mgcp/mgcp_endp.h
M include/osmocom/mgcp/mgcp_internal.h
M src/libosmo-mgcp/mgcp_conn.c
M src/libosmo-mgcp/mgcp_endp.c
M src/libosmo-mgcp/mgcp_network.c
5 files changed, 38 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/06/6006/6

diff --git a/include/osmocom/mgcp/mgcp_endp.h b/include/osmocom/mgcp/mgcp_endp.h
index 0225879..a486dcd 100644
--- a/include/osmocom/mgcp/mgcp_endp.h
+++ b/include/osmocom/mgcp/mgcp_endp.h
@@ -33,6 +33,13 @@
 char *buf, unsigned int buf_size,
 struct mgcp_conn *conn);
 
+/* Callback type for endpoint specific cleanup actions. This function
+ * is automatically executed when a connection is freed (see mgcp_conn_free()
+ * in mgcp_conn.c). Depending on the type of the endpoint there may be endpoint
+ * specific things to take care of once a connection has been removed. */
+typedef void (*mgcp_cleanup_cp) (struct mgcp_endpoint *endp,
+struct mgcp_conn *conn);
+
 /*! MGCP endpoint properties */
 struct mgcp_endpoint_type {
/*!< maximum number of connections */
@@ -40,6 +47,9 @@
 
/*!< callback that defines how to dispatch incoming RTP data */
mgcp_dispatch_rtp_cb dispatch_rtp_cb;
+
+   /*!< callback that implements endpoint specific cleanup actions */
+   mgcp_cleanup_cp cleanup_cb;
 };
 
 /*! MGCP endpoint typeset */
diff --git a/include/osmocom/mgcp/mgcp_internal.h 
b/include/osmocom/mgcp/mgcp_internal.h
index 9c57e3f..e4009e8 100644
--- a/include/osmocom/mgcp/mgcp_internal.h
+++ b/include/osmocom/mgcp/mgcp_internal.h
@@ -265,6 +265,7 @@
 int mgcp_send_dummy(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn);
 int mgcp_dispatch_rtp_bridge_cb(int proto, struct sockaddr_in *addr, char *buf,
unsigned int buf_size, struct mgcp_conn *conn);
+void mgcp_cleanup_rtp_bridge_cb(struct mgcp_endpoint *endp, struct mgcp_conn 
*conn);
 int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port,
   struct mgcp_conn_rtp *conn);
 void mgcp_free_rtp_port(struct mgcp_rtp_end *end);
diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c
index cc115a9..62cbdba 100644
--- a/src/libosmo-mgcp/mgcp_conn.c
+++ b/src/libosmo-mgcp/mgcp_conn.c
@@ -201,6 +201,12 @@
if (!conn)
return;
 
+   /* Run endpoint cleanup action. By this we inform the endpoint about
+* the removal of the connection and allow it to clean up its inner
+* state accordingly */
+   if (endp->type->cleanup_cb)
+   endp->type->cleanup_cb(endp, conn);
+
switch (conn->type) {
case MGCP_CONN_TYPE_RTP:
osmux_disable_conn(&conn->u.rtp);
diff --git a/src/libosmo-mgcp/mgcp_endp.c b/src/libosmo-mgcp/mgcp_endp.c
index 6d3a6d4..fa2dd28 100644
--- a/src/libosmo-mgcp/mgcp_endp.c
+++ b/src/libosmo-mgcp/mgcp_endp.c
@@ -28,7 +28,8 @@
 const struct mgcp_endpoint_typeset ep_typeset = {
/* Specify endpoint properties for RTP endpoint */
.rtp.max_conns = 2,
-   .rtp.dispatch_rtp_cb = mgcp_dispatch_rtp_bridge_cb
+   .rtp.dispatch_rtp_cb = mgcp_dispatch_rtp_bridge_cb,
+   .rtp.cleanup_cb = mgcp_cleanup_rtp_bridge_cb
 };
 
 /*! release endpoint, all open connections are closed.
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index ef6357b..6923b97 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -1043,6 +1043,25 @@
 
 }
 
+/*! cleanup an endpoint when a connection on an RTP bridge endpoint is removed.
+ *  \param[in] endp Endpoint on which the connection resides.
+ *  \param[in] conn Connection that is about to be removed (ignored).
+ *  \returns 0 on success, -1 on ERROR. */
+void mgcp_cleanup_rtp_bridge_cb(struct mgcp_endpo

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

2018-02-05 Thread dexter
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/5881

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

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
A include/osmocom/mgcp_client/mgcp_client_fsm.h
M src/libosmo-mgcp-client/Makefile.am
A src/libosmo-mgcp-client/mgcp_client_fsm.c
4 files changed, 673 insertions(+), 0 deletions(-)


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

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/include/osmocom/mgcp_client/mgcp_client_fsm.h 
b/include/osmocom/mgcp_client/mgcp_client_fsm.h
new file mode 100644
index 000..7d06178
--- /dev/null
+++ b/include/osmocom/mgcp_client/mgcp_client_fsm.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include 
+#include 
+#include 
+
+/*! This struct organizes the connection infromation one connection side
+ *  (either remote or local). It is used to pass parameters (local) to the FSM
+ *  and get responses (remote) from the FSM as pointer attached to the FSM
+ *  event.
+ * 
+ *  When modifiying a connection, the endpoint and call_id members may be left
+ *  unpopulated. The call_id field is ignored in this case. If an endpoint
+ *  identifier is supplied it is checked against the internal state to make
+ *  sure it is correct. */
+struct mgcp_conn_peer {
+   /*!< RTP connection IP-Address (optional, string e.g. "127.0.0.1") */
+   char addr[INET_ADDRSTRLEN];
+
+   /*!< RTP connection IP-Port (optional)  */
+   uint16_t port;
+
+   /*!< RTP endpoint */
+   char endpoint[MGCP_ENDPOINT_MAXLEN];
+
+   /*!< CALL ID (unique per connection) */
+   unsigned int call_id;
+};
+
+struct osmo_fsm_inst *mgcp_conn_create(struct mgcp_client *mgcp, struct 
osmo_fsm_inst *parent_fi, uint32_t parent_term_evt,
+  uint32_t parent_evt, struct 
mgcp_conn_peer *conn_peer);
+int mgcp_conn_modify(struct osmo_fsm_inst *fi, uint32_t parent_evt, struct 
mgcp_conn_peer *conn_peer);
+void mgcp_conn_delete(struct osmo_fsm_inst *fi);
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)
diff --git a/src/libosmo-mgcp-client/mgcp_client_fsm.c 
b/src/libosmo-mgcp-client/mgcp_client_fsm.c
new file mode 100644
index 000..83c4b62
--- /dev/null
+++ b/src/libosmo-mgcp-client/mgcp_client_fsm.c
@@ -0,0 +1,638 @@
+/* (C) 2018 by sysmocom s.f.m.c. GmbH 
+ * All Rights Reserved
+ *
+ * Author: Philipp Maier
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Context information, this is attached to the priv pointer of the FSM and
+ * is also handed back when dispatcheing events to the parent FSM. This is
+ * purly intened and not meant to be accessible for the API user */
+struct mgcp_ctx {
+   /* MGCP client instance that is used to interact with the MGW */
+   struct mgcp_client *mgcp;
+
+   /* The ID of the last pending transaction. This is used internally
+* to cancel the transaction in case of an error */
+   mgcp_trans_id_t mgw_pending_trans;
+
+   /* Flag to mark that there is a pending transaction */
+   bool mgw_trans_pending;
+
+   /* Connection ID which has been assigned by he MGW */
+   char conn_id[MGCP_CONN_ID_LENGTH];
+
+   /* Local RTP connection info, the MGW 

osmo-mgw[master]: mgcp: fix use-after-free and add callback for endpoint cleanup

2018-02-05 Thread Harald Welte

Patch Set 6: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I921d9bbe58be1c3298e164a37f3c974880b3759f
Gerrit-PatchSet: 6
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


osmo-mgw[master]: protocol: reject DLCX/CRCX/MDCX on unsupported parameters

2018-02-05 Thread Harald Welte

Patch Set 3: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I8cd5987fc6befcd53a7c4916f77b1a24c904ba48
Gerrit-PatchSet: 3
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


osmo-mgw[master]: protocol: prohibit wildcarded requests for MDCX and DLCX

2018-02-05 Thread Harald Welte

Patch Set 3: Code-Review-2

You're still referring to dlcx in a mdcx codepath.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ia77d44a6a86083e62338e5845b553e5cf13ebd10
Gerrit-PatchSet: 3
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


osmo-mgw[master]: cosmetic: rename mgcp_ep.c/h to mgcp_endp.c/h

2018-02-05 Thread Harald Welte

Patch Set 4: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id52047bb2d0407655ac272c858ed3412b8ae9e6d
Gerrit-PatchSet: 4
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmo-mgw[master]: protocol: reject DLCX/CRCX/MDCX on unsupported parameters

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: protocol: reject DLCX/CRCX/MDCX on unsupported parameters
..


protocol: reject DLCX/CRCX/MDCX on unsupported parameters

When an unsupported MGCP parameter (e.g. N) is used, then this
parameter is ignored and the command execution continues. However,
an MGCP command that contains an unsupported parameter should
be rejected.

- Make sure that MGCP commands DLCX, CRCX and MDCX are rejected,
  when they contain unsupported parameters.

Change-Id: I8cd5987fc6befcd53a7c4916f77b1a24c904ba48
---
M src/libosmo-mgcp/mgcp_protocol.c
1 file changed, 3 insertions(+), 0 deletions(-)

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



diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index b0d9943..2cbd87b 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -535,6 +535,7 @@
LOGP(DLMGCP, LOGL_NOTICE,
 "CRCX: endpoint:%x unhandled option: '%c'/%d\n",
 ENDPOINT_NUMBER(endp), *line, *line);
+   return create_err_response(NULL, 539, "CRCX", p->trans);
break;
}
}
@@ -768,6 +769,7 @@
LOGP(DLMGCP, LOGL_NOTICE,
 "MDCX: endpoint:0x%x Unhandled MGCP option: 
'%c'/%d\n",
 ENDPOINT_NUMBER(endp), line[0], line[0]);
+   return create_err_response(NULL, 539, "MDCX", p->trans);
break;
}
}
@@ -918,6 +920,7 @@
LOGP(DLMGCP, LOGL_NOTICE,
 "DLCX: endpoint:0x%x Unhandled MGCP option: 
'%c'/%d\n",
 ENDPOINT_NUMBER(endp), line[0], line[0]);
+   return create_err_response(NULL, 539, "DLCX", p->trans);
break;
}
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8cd5987fc6befcd53a7c4916f77b1a24c904ba48
Gerrit-PatchSet: 3
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 


[MERGED] osmo-mgw[master]: cosmetic: rename mgcp_ep.c/h to mgcp_endp.c/h

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: cosmetic: rename mgcp_ep.c/h to mgcp_endp.c/h
..


cosmetic: rename mgcp_ep.c/h to mgcp_endp.c/h

The short term of endpoint has always been "endp" througout the whole
project and not "ep".

- rename mcgp_ep.c to mgcp_endp.c

- rename mgcp_ep.h to mgcp_endp.h

Change-Id: Id52047bb2d0407655ac272c858ed3412b8ae9e6d
---
M include/osmocom/mgcp/Makefile.am
R include/osmocom/mgcp/mgcp_endp.h
M src/libosmo-mgcp/Makefile.am
M src/libosmo-mgcp/mgcp_conn.c
R src/libosmo-mgcp/mgcp_endp.c
M src/libosmo-mgcp/mgcp_msg.c
M src/libosmo-mgcp/mgcp_network.c
M src/libosmo-mgcp/mgcp_osmux.c
M src/libosmo-mgcp/mgcp_protocol.c
M src/libosmo-mgcp/mgcp_sdp.c
M src/libosmo-mgcp/mgcp_vty.c
M src/osmo-mgw/mgw_main.c
M tests/mgcp/mgcp_test.c
13 files changed, 12 insertions(+), 12 deletions(-)

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



diff --git a/include/osmocom/mgcp/Makefile.am b/include/osmocom/mgcp/Makefile.am
index d706807..7e297e4 100644
--- a/include/osmocom/mgcp/Makefile.am
+++ b/include/osmocom/mgcp/Makefile.am
@@ -3,7 +3,7 @@
mgcp_msg.h \
mgcp_conn.h \
mgcp_stat.h \
-   mgcp_ep.h \
+   mgcp_endp.h \
mgcp_sdp.h \
debug.h \
$(NULL)
diff --git a/include/osmocom/mgcp/mgcp_ep.h b/include/osmocom/mgcp/mgcp_endp.h
similarity index 100%
rename from include/osmocom/mgcp/mgcp_ep.h
rename to include/osmocom/mgcp/mgcp_endp.h
diff --git a/src/libosmo-mgcp/Makefile.am b/src/libosmo-mgcp/Makefile.am
index a785d62..fbb1a2e 100644
--- a/src/libosmo-mgcp/Makefile.am
+++ b/src/libosmo-mgcp/Makefile.am
@@ -42,7 +42,7 @@
mgcp_msg.c \
mgcp_conn.c \
mgcp_stat.c \
-   mgcp_ep.c \
+   mgcp_endp.c \
$(NULL)
 
 libosmo_mgcp_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(MGCP_LIBVERSION)
diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c
index a136fda..cc115a9 100644
--- a/src/libosmo-mgcp/mgcp_conn.c
+++ b/src/libosmo-mgcp/mgcp_conn.c
@@ -24,7 +24,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/src/libosmo-mgcp/mgcp_ep.c b/src/libosmo-mgcp/mgcp_endp.c
similarity index 97%
rename from src/libosmo-mgcp/mgcp_ep.c
rename to src/libosmo-mgcp/mgcp_endp.c
index 5f75f0e..77310c6 100644
--- a/src/libosmo-mgcp/mgcp_ep.c
+++ b/src/libosmo-mgcp/mgcp_endp.c
@@ -22,7 +22,7 @@
  */
 
 #include 
-#include 
+#include 
 
 /* Endpoint typeset definition */
 const struct mgcp_endpoint_typeset ep_typeset = {
diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c
index 034b64f..f533d55 100644
--- a/src/libosmo-mgcp/mgcp_msg.c
+++ b/src/libosmo-mgcp/mgcp_msg.c
@@ -28,7 +28,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 /*! Display an mgcp message on the log output.
  *  \param[in] message mgcp message string
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 6cecbb0..ef6357b 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -39,7 +39,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #define RTP_SEQ_MOD(1 << 16)
diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c
index 1bb7aa6..1d3cab3 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -24,7 +24,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 static struct osmo_fd osmux_fd;
 
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index c6beaa4..b0d9943 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -38,7 +38,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 struct mgcp_request {
diff --git a/src/libosmo-mgcp/mgcp_sdp.c b/src/libosmo-mgcp/mgcp_sdp.c
index 1dffbfc..52b4df4 100644
--- a/src/libosmo-mgcp/mgcp_sdp.c
+++ b/src/libosmo-mgcp/mgcp_sdp.c
@@ -24,7 +24,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 
diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c
index 5378931..14ecd17 100644
--- a/src/libosmo-mgcp/mgcp_vty.c
+++ b/src/libosmo-mgcp/mgcp_vty.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 
diff --git a/src/osmo-mgw/mgw_main.c b/src/osmo-mgw/mgw_main.c
index 4452ae3..f95a1c7 100644
--- a/src/osmo-mgw/mgw_main.c
+++ b/src/osmo-mgw/mgw_main.c
@@ -37,7 +37,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 #include 
diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
index 4d39bda..38a0a46 100644
--- a/tests/mgcp/mgcp_test.c
+++ b/tests/mgcp/mgcp_test.c
@@ -25,7 +25,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 #include 

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

Gerrit-Messa

[MERGED] osmo-mgw[master]: client: use heap to store mgcp_response

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: client: use heap to store mgcp_response
..


client: use heap to store mgcp_response

The struct that holds the parsing results of the MGCP response is
allocated on the stack. However, it would make sense to allocate
the struct dynamically on the heap. This also would provide a
talloc context that is in reach on most places of the code.

- Allocate struct mgcp_response dynamically in mgcp_client_rx()

- Use struct mgcp_response as talloc context for temporary
  allocated memory while parsing the response.

Change-Id: I5099abe68b580c75b47bc797bf93f01084f0c4db
---
M src/libosmo-mgcp-client/mgcp_client.c
1 file changed, 22 insertions(+), 12 deletions(-)

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



diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index 7476197..c340303 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -257,7 +257,7 @@
 
/* 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);
+   data = talloc_zero_size(r, strlen(r->body)+1);
OSMO_ASSERT(data);
data_ptr = data;
osmo_strlcpy(data, r->body, strlen(r->body));
@@ -336,7 +336,7 @@
 
/* 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);
+   data = talloc_zero_size(r, strlen(r->body)+1);
OSMO_ASSERT(data);
data_ptr = data;
osmo_strlcpy(data, r->body, strlen(r->body));
@@ -410,32 +410,42 @@
  */
 int mgcp_client_rx(struct mgcp_client *mgcp, struct msgb *msg)
 {
-   struct mgcp_response r = { 0 };
+   struct mgcp_response *r;
struct mgcp_response_pending *pending;
int rc;
 
-   rc = mgcp_response_parse_head(&r, msg);
+   r = talloc_zero(mgcp, struct mgcp_response);
+   OSMO_ASSERT(r);
+
+   rc = mgcp_response_parse_head(r, msg);
if (rc) {
LOGP(DLMGCP, LOGL_ERROR, "Cannot parse MGCP response (head)\n");
-   return -1;
+   rc = 1;
+   goto error;
}
 
-   rc = parse_head_params(&r);
+   rc = parse_head_params(r);
if (rc) {
LOGP(DLMGCP, LOGL_ERROR, "Cannot parse MGCP response (head 
parameters)\n");
-   return -1;
+   rc = 1;
+   goto error;
}
 
-   pending = mgcp_client_response_pending_get(mgcp, r.head.trans_id);
+   pending = mgcp_client_response_pending_get(mgcp, r->head.trans_id);
if (!pending) {
LOGP(DLMGCP, LOGL_ERROR,
 "Cannot find matching MGCP transaction for trans_id %d\n",
-r.head.trans_id);
-   return -ENOENT;
+r->head.trans_id);
+   rc = -ENOENT;
+   goto error;
}
 
-   mgcp_client_handle_response(mgcp, pending, &r);
-   return 0;
+   mgcp_client_handle_response(mgcp, pending, r);
+   rc = 0;
+
+error:
+   talloc_free(r);
+   return rc;
 }
 
 static int mgcp_do_read(struct osmo_fd *fd)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5099abe68b580c75b47bc797bf93f01084f0c4db
Gerrit-PatchSet: 5
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-mgw[master]: protocol: fix tagging of wildcarded requests

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: protocol: fix tagging of wildcarded requests
..


protocol: fix tagging of wildcarded requests

When a wildcarded CRCX is done flag "wildcarded_crcx" is set in the
endpoint struct. The flag tells other part of the code whether the
request was wildcarded or not since in some cases the behaviour
might be different for wildcarded requests. The implementation of
this mechanism is not entirely correct. The flag is set on wildcarded
requests but on non wildcarded requests it is not reset. Also the
name is misleading.

- rename wildcarded_crcx to wildcarded_req

- ensure the flag is refreshed with every new request

Change-Id: Ia5063ec65f5bc3a8a0943d1fd823aaeee20b8637
---
M include/osmocom/mgcp/mgcp_endp.h
M src/libosmo-mgcp/mgcp_endp.c
M src/libosmo-mgcp/mgcp_msg.c
M src/libosmo-mgcp/mgcp_protocol.c
4 files changed, 18 insertions(+), 9 deletions(-)

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



diff --git a/include/osmocom/mgcp/mgcp_endp.h b/include/osmocom/mgcp/mgcp_endp.h
index ad5e28d..0225879 100644
--- a/include/osmocom/mgcp/mgcp_endp.h
+++ b/include/osmocom/mgcp/mgcp_endp.h
@@ -79,7 +79,7 @@
 
/*!< Memorize if this endpoint was choosen by the MGW (wildcarded, true)
 *   or if the user has choosen the particular endpoint explicitly. */
-   bool wildcarded_crcx;
+   bool wildcarded_req;
 };
 
 /*! Extract endpoint number for a given endpoint */
diff --git a/src/libosmo-mgcp/mgcp_endp.c b/src/libosmo-mgcp/mgcp_endp.c
index 77310c6..6d3a6d4 100644
--- a/src/libosmo-mgcp/mgcp_endp.c
+++ b/src/libosmo-mgcp/mgcp_endp.c
@@ -51,5 +51,5 @@
endp->local_options.string = NULL;
talloc_free(endp->local_options.codec);
endp->local_options.codec = NULL;
-   endp->wildcarded_crcx = false;
+   endp->wildcarded_req = false;
 }
diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c
index 89046c0..8d22cc5 100644
--- a/src/libosmo-mgcp/mgcp_msg.c
+++ b/src/libosmo-mgcp/mgcp_msg.c
@@ -143,6 +143,7 @@
char *rest = NULL;
struct mgcp_trunk_config *tcfg;
int trunk, endp;
+   struct mgcp_endpoint *endp_ptr;
 
trunk = strtoul(mgcp + 6, &rest, 10);
if (rest == NULL || rest[0] != '/' || trunk < 1) {
@@ -179,7 +180,9 @@
return NULL;
}
 
-   return &tcfg->endpoints[endp];
+   endp_ptr = &tcfg->endpoints[endp];
+   endp_ptr->wildcarded_req = false;
+   return endp_ptr;
 }
 
 /* Find an endpoint that is not in use. Do this by going through the endpoint
@@ -197,7 +200,7 @@
LOGP(DLMGCP, LOGL_DEBUG,
 "endpoint:0x%x found free endpoint\n",
 ENDPOINT_NUMBER(endp));
-   endp->wildcarded_crcx = true;
+   endp->wildcarded_req = true;
return endp;
}
}
@@ -263,8 +266,11 @@
return endp;
}
gw = strtoul(endpoint_number_str, &endptr, 16);
-   if (gw < cfg->trunk.number_endpoints && endptr[0] == '@')
-   return &cfg->trunk.endpoints[gw];
+   if (gw < cfg->trunk.number_endpoints && endptr[0] == '@') {
+   endp = &cfg->trunk.endpoints[gw];
+   endp->wildcarded_req = false;
+   return endp;
+   }
}
 
/* Deprecated method without prefix */
@@ -272,8 +278,11 @@
 "Addressing virtual trunk without prefix (deprecated), please use 
%s: '%s'\n",
 MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK, mgcp);
gw = strtoul(mgcp, &endptr, 16);
-   if (gw < cfg->trunk.number_endpoints && endptr[0] == '@')
-   return &cfg->trunk.endpoints[gw];
+   if (gw < cfg->trunk.number_endpoints && endptr[0] == '@') {
+   endp = &cfg->trunk.endpoints[gw];
+   endp->wildcarded_req = false;
+   return endp;
+   }
 
LOGP(DLMGCP, LOGL_ERROR, "Not able to find the endpoint: '%s'\n", mgcp);
*cause = -500;
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index bfb8768..62487d1 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -199,7 +199,7 @@
int rc;
 
/* NOTE: Only in the virtual trunk we allow dynamic endpoint names */
-   if (endp->wildcarded_crcx
+   if (endp->wildcarded_req
&& endp->tcfg->trunk_type == MGCP_TRUNK_VIRTUAL) {
rc = msgb_printf(msg, "Z: %s%x@%s\r\n",
 MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK,

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia5063ec65f5bc

[MERGED] osmo-mgw[master]: protocol: check requested connection mode

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: protocol: check requested connection mode
..


protocol: check requested connection mode

The connection mode setting (e.g. recvonly) is not checked on CRCX
and MDCX. This allows requests that set the connection mode to
sendrecv or sendonly without ever configuring the remote end of
the connection (half-open connection).

- reject sendrecv or sendonly on half open connections

See also TTCN3 Test:
MGCP_Test.TC_crcx_early_bidir_mode

Change-Id: I6ab01855d3b1faa36aebac357e7b97c563990678
Related: OS#2652
---
M src/libosmo-mgcp/mgcp_protocol.c
1 file changed, 22 insertions(+), 0 deletions(-)

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



diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 23c0c25..bfb8768 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -654,6 +654,17 @@
 
mgcp_rtp_end_config(endp, 0, &conn->end);
 
+   /* check connection mode setting */
+   if (conn->conn->mode != MGCP_CONN_LOOPBACK
+   && conn->conn->mode != MGCP_CONN_RECV_ONLY
+   && conn->end.rtp_port == 0) {
+   LOGP(DLMGCP, LOGL_ERROR,
+"CRCX: endpoint:%x selected connection mode type requires 
an opposite end!\n",
+ENDPOINT_NUMBER(endp));
+   error_code = 527;
+   goto error2;
+   }
+
if (allocate_port(endp, conn) != 0) {
goto error2;
}
@@ -812,6 +823,17 @@
mgcp_set_audio_info(p->cfg, &conn->end.codec,
PTYPE_UNDEFINED, endp->local_options.codec);
 
+   /* check connection mode setting */
+   if (conn->conn->mode != MGCP_CONN_LOOPBACK
+   && conn->conn->mode != MGCP_CONN_RECV_ONLY
+   && conn->end.rtp_port == 0) {
+   LOGP(DLMGCP, LOGL_ERROR,
+"MDCX: endpoint:%x selected connection mode type requires 
an opposite end!\n",
+ENDPOINT_NUMBER(endp));
+   error_code = 527;
+   goto error3;
+   }
+
if (setup_rtp_processing(endp, conn) != 0)
goto error3;
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6ab01855d3b1faa36aebac357e7b97c563990678
Gerrit-PatchSet: 3
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-mgw[master]: cosmetic: Add missing \n on log line

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: cosmetic: Add missing \n on log line
..


cosmetic: Add missing \n on log line

The final log lone in find_endpoint() lacks the \n causing a messed
up log output.

- Add missing \n

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

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



diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c
index f533d55..89046c0 100644
--- a/src/libosmo-mgcp/mgcp_msg.c
+++ b/src/libosmo-mgcp/mgcp_msg.c
@@ -202,7 +202,7 @@
}
}
 
-   LOGP(DLMGCP, LOGL_ERROR, "Not able to find a free endpoint");
+   LOGP(DLMGCP, LOGL_ERROR, "Not able to find a free endpoint\n");
return NULL;
 }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I97fca654b199dfb7aae2359322a56c6d0bae9599
Gerrit-PatchSet: 3
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-mgw[master]: cosmetic: rename mgcp_release_endp to mgcp_endp_release

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: cosmetic: rename mgcp_release_endp to mgcp_endp_release
..


cosmetic: rename mgcp_release_endp to mgcp_endp_release

In order to allow clean prefixes for future endpoint related
functions the "rlease" should be moved to the end of the
function name.

- rename mgcp_release_endp to mgcp_endp_release

Change-Id: I22e938e702f57ad76d38c9f4a1370b110ac1ba11
---
M include/osmocom/mgcp/mgcp_ep.h
M src/libosmo-mgcp/mgcp_ep.c
M src/libosmo-mgcp/mgcp_protocol.c
M src/libosmo-mgcp/mgcp_vty.c
M src/osmo-mgw/mgw_main.c
M tests/mgcp/mgcp_test.c
6 files changed, 13 insertions(+), 12 deletions(-)

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



diff --git a/include/osmocom/mgcp/mgcp_ep.h b/include/osmocom/mgcp/mgcp_ep.h
index 2af4aee..ad5e28d 100644
--- a/include/osmocom/mgcp/mgcp_ep.h
+++ b/include/osmocom/mgcp/mgcp_ep.h
@@ -85,4 +85,5 @@
 /*! Extract endpoint number for a given endpoint */
 #define ENDPOINT_NUMBER(endp) abs((int)(endp - endp->tcfg->endpoints))
 
-void mgcp_release_endp(struct mgcp_endpoint *endp);
+void mgcp_endp_release(struct mgcp_endpoint *endp);
+
diff --git a/src/libosmo-mgcp/mgcp_ep.c b/src/libosmo-mgcp/mgcp_ep.c
index 0b67ec8..5f75f0e 100644
--- a/src/libosmo-mgcp/mgcp_ep.c
+++ b/src/libosmo-mgcp/mgcp_ep.c
@@ -33,7 +33,7 @@
 
 /*! release endpoint, all open connections are closed.
  *  \param[in] endp endpoint to release */
-void mgcp_release_endp(struct mgcp_endpoint *endp)
+void mgcp_endp_release(struct mgcp_endpoint *endp)
 {
LOGP(DLMGCP, LOGL_DEBUG, "Releasing endpoint:0x%x\n",
 ENDPOINT_NUMBER(endp));
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 9fe30f8..c6beaa4 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -583,7 +583,7 @@
if (tcfg->force_realloc)
/* This is not our call, toss everything by releasing
 * the entire endpoint. (rude!) */
-   mgcp_release_endp(endp);
+   mgcp_endp_release(endp);
else {
/* This is not our call, leave everything as it is and
 * return with an error. */
@@ -673,7 +673,7 @@
LOGP(DLMGCP, LOGL_NOTICE,
 "CRCX: endpoint:0x%x CRCX rejected by policy\n",
 ENDPOINT_NUMBER(endp));
-   mgcp_release_endp(endp);
+   mgcp_endp_release(endp);
return create_err_response(endp, 400, "CRCX", p->trans);
break;
case MGCP_POLICY_DEFER:
@@ -703,7 +703,7 @@
 ENDPOINT_NUMBER(endp));
return create_response_with_sdp(endp, conn, "CRCX", p->trans, true);
 error2:
-   mgcp_release_endp(endp);
+   mgcp_endp_release(endp);
LOGP(DLMGCP, LOGL_NOTICE,
 "CRCX: endpoint:0x%x unable to create connection resource error\n",
 ENDPOINT_NUMBER(endp));
@@ -954,7 +954,7 @@
 "DLCX: endpoint:0x%x missing ci (connectionIdentifier), 
will remove all connections at once\n",
 ENDPOINT_NUMBER(endp));
 
-   mgcp_release_endp(endp);
+   mgcp_endp_release(endp);
 
/* Note: In this case we do not return any statistics,
 * as we assume that the client is not interested in
@@ -981,7 +981,7 @@
/* When all connections are closed, the endpoint will be released
 * in order to be ready to be used by another call. */
if (llist_count(&endp->conns) <= 0) {
-   mgcp_release_endp(endp);
+   mgcp_endp_release(endp);
LOGP(DLMGCP, LOGL_DEBUG,
 "DLCX: endpoint:0x%x endpoint released\n",
 ENDPOINT_NUMBER(endp));
diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c
index 99780c8..5378931 100644
--- a/src/libosmo-mgcp/mgcp_vty.c
+++ b/src/libosmo-mgcp/mgcp_vty.c
@@ -1048,7 +1048,7 @@
}
 
endp = &trunk->endpoints[endp_no];
-   mgcp_release_endp(endp);
+   mgcp_endp_release(endp);
return CMD_SUCCESS;
 }
 
diff --git a/src/osmo-mgw/mgw_main.c b/src/osmo-mgw/mgw_main.c
index 8e956e4..4452ae3 100644
--- a/src/osmo-mgw/mgw_main.c
+++ b/src/osmo-mgw/mgw_main.c
@@ -190,7 +190,7 @@
/* Walk over all endpoints and trigger a release, this will 
release all
 * endpoints, possible open connections are forcefully dropped 
*/
for (i = 1; i < reset_trunk->number_endpoints; ++i)
-   mgcp_release_endp(&reset_trunk->endpoints[i]);
+   mgcp_endp_release(&reset_trunk->endpoints[i]);
}
 
return 0;
diff --git a/tests/mgcp/mgcp_test

[MERGED] osmo-mgw[master]: ep: move endpoint struct and define to mgcp_ep.h

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: ep: move endpoint struct and define to mgcp_ep.h
..


ep: move endpoint struct and define to mgcp_ep.h

The endpoint and the define that computes the endpoint number is
defined in mgcp_internal.h. Since we have a dedicated module for
endpoint related code it makes sense to move the endpoint related
parts there.

- move struct mgcp_endpoint to mgcp_ep.h

- move #define ENDPOINT_NUMBER(endp) to mgcp_ep.h

Change-Id: Ibae55e1859bd41e2d1918eda433418b4bf8365fe
---
M include/osmocom/mgcp/mgcp_ep.h
M include/osmocom/mgcp/mgcp_internal.h
M src/libosmo-mgcp/mgcp_ep.c
M src/libosmo-mgcp/mgcp_msg.c
M src/libosmo-mgcp/mgcp_osmux.c
M src/libosmo-mgcp/mgcp_sdp.c
6 files changed, 40 insertions(+), 22 deletions(-)

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



diff --git a/include/osmocom/mgcp/mgcp_ep.h b/include/osmocom/mgcp/mgcp_ep.h
index 915f542..2af4aee 100644
--- a/include/osmocom/mgcp/mgcp_ep.h
+++ b/include/osmocom/mgcp/mgcp_ep.h
@@ -50,4 +50,39 @@
 /*! static MGCP endpoint typeset (pre-initalized, read-only) */
 extern const struct mgcp_endpoint_typeset ep_typeset;
 
+/*! MGCP endpoint model */
+struct mgcp_endpoint {
+
+   /*!< Call identifier string (as supplied by the call agant) */
+   char *callid;
+
+   /*!< Local connection options (see mgcp_intermal.h) */
+   struct mgcp_lco local_options;
+
+   /*!< List with connections active on this endpoint */
+   struct llist_head conns;
+
+   /*!< Backpointer to the MGW configuration */
+   struct mgcp_config *cfg;
+
+   /*!< Backpointer to the Trunk specific configuration */
+   struct mgcp_trunk_config *tcfg;
+
+   /*!< Endpoint properties (see above) */
+   const struct mgcp_endpoint_type *type;
+
+   /*!< Last MGCP transmission (in case re-transmission is required) */
+   char *last_trans;
+
+   /*!< Last MGCP response (in case re-transmission is required) */
+   char *last_response;
+
+   /*!< Memorize if this endpoint was choosen by the MGW (wildcarded, true)
+*   or if the user has choosen the particular endpoint explicitly. */
+   bool wildcarded_crcx;
+};
+
+/*! Extract endpoint number for a given endpoint */
+#define ENDPOINT_NUMBER(endp) abs((int)(endp - endp->tcfg->endpoints))
+
 void mgcp_release_endp(struct mgcp_endpoint *endp);
diff --git a/include/osmocom/mgcp/mgcp_internal.h 
b/include/osmocom/mgcp/mgcp_internal.h
index c0ee556..9c57e3f 100644
--- a/include/osmocom/mgcp/mgcp_internal.h
+++ b/include/osmocom/mgcp/mgcp_internal.h
@@ -245,29 +245,9 @@
 
 struct mgcp_endpoint_type;
 
-struct mgcp_endpoint {
-   char *callid;
-   struct mgcp_lco local_options;
-
-   struct llist_head conns;
-
-   /* backpointer */
-   struct mgcp_config *cfg;
-   struct mgcp_trunk_config *tcfg;
-
-   const struct mgcp_endpoint_type *type;
-
-   /* fields for re-transmission */
-   char *last_trans;
-   char *last_response;
-
-   /* Memorize if this endpoint was choosen by the MGW (wildcarded, true)
-* or if the user has choosen the particular endpoint explicitly */
-   bool wildcarded_crcx;
-};
 
 
-#define ENDPOINT_NUMBER(endp) abs((int)(endp - endp->tcfg->endpoints))
+
 
 /**
  * Internal structure while parsing a request
diff --git a/src/libosmo-mgcp/mgcp_ep.c b/src/libosmo-mgcp/mgcp_ep.c
index 68e36da..0b67ec8 100644
--- a/src/libosmo-mgcp/mgcp_ep.c
+++ b/src/libosmo-mgcp/mgcp_ep.c
@@ -21,8 +21,8 @@
  *
  */
 
-#include 
 #include 
+#include 
 
 /* Endpoint typeset definition */
 const struct mgcp_endpoint_typeset ep_typeset = {
diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c
index 4055a0c..034b64f 100644
--- a/src/libosmo-mgcp/mgcp_msg.c
+++ b/src/libosmo-mgcp/mgcp_msg.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*! Display an mgcp message on the log output.
  *  \param[in] message mgcp message string
diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c
index d0141f3..1bb7aa6 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static struct osmo_fd osmux_fd;
 
diff --git a/src/libosmo-mgcp/mgcp_sdp.c b/src/libosmo-mgcp/mgcp_sdp.c
index 666b8c2..1dffbfc 100644
--- a/src/libosmo-mgcp/mgcp_sdp.c
+++ b/src/libosmo-mgcp/mgcp_sdp.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibae55e1859bd41e2d1918eda433418b4bf8365fe
Gerrit-PatchSet: 4
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-mgw[master]: protocol: exit cleanly when local cx options check fails

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: protocol: exit cleanly when local cx options check fails
..


protocol: exit cleanly when local cx options check fails

When set_local_cx_options() returns an error code the MGCP command
execution is aborted and and the error code is returned, but on
CRCX the already seized eindpoint is not released.

- Do not generate the error response on the spot, jump to the
  respective label and let the already existing error handling
  do its work.

This patch is a follow-up page to:
Change-Id I02aaa3042f2a0e32eb4ec6b8753deab7082947a0

Change-Id: Iaef4ea6c6a2f24ac8b276966bda72d0b30f25cd5
Related: OS#2654
---
M src/libosmo-mgcp/mgcp_protocol.c
1 file changed, 4 insertions(+), 2 deletions(-)

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



diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 2cbd87b..23c0c25 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -604,7 +604,8 @@
LOGP(DLMGCP, LOGL_ERROR,
 "CRCX: endpoint:%x inavlid local connection options!\n",
 ENDPOINT_NUMBER(endp));
-   return create_err_response(endp, rc, "CRCX", p->trans);
+   error_code = rc;
+   goto error2;
}
 
snprintf(conn_name, sizeof(conn_name), "%s", callid);
@@ -803,7 +804,8 @@
LOGP(DLMGCP, LOGL_ERROR,
 "MDCX: endpoint:%x inavlid local connection options!\n",
 ENDPOINT_NUMBER(endp));
-   return create_err_response(endp, rc, "MDCX", p->trans);
+   error_code = rc;
+   goto error3;
}
 
if (!have_sdp && endp->local_options.codec)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iaef4ea6c6a2f24ac8b276966bda72d0b30f25cd5
Gerrit-PatchSet: 3
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[PATCH] libosmocore[master]: utils: add helper wrapper for osmo_strlcpy()

2018-02-05 Thread Max
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/6197

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

utils: add helper wrapper for osmo_strlcpy()

Add wrapper for osmo_strlcpy() which uses sizeof() to automatically
determine buffer's size and use it for GSMTAP logging. This is pretty
common use case for osmo_strlcpy() so it's a good idea to save some
typing by using generic define.

Related: OS#2864
Change-Id: I03d0d3d32a8d572ad573d03c603e14cdc27a3f7b
---
M include/osmocom/core/utils.h
M src/logging_gsmtap.c
2 files changed, 6 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/97/6197/2

diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index 72266ae..f1e011f 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -26,6 +26,9 @@
 /*! Number of bytes necessary to store given BITS */
 #define OSMO_BYTES_FOR_BITS(BITS) ((BITS + 8 - 1) / 8)
 
+/*! Copy a C-string into a sized buffer using sizeof to detect buffer's size */
+#define OSMO_STRLCPY_ARRAY(array, src) osmo_strlcpy(array, src, sizeof(array))
+
 #include 
 #include 
 #include 
diff --git a/src/logging_gsmtap.c b/src/logging_gsmtap.c
index 82535ad..cb379b0 100644
--- a/src/logging_gsmtap.c
+++ b/src/logging_gsmtap.c
@@ -81,17 +81,16 @@
 
/* Logging header */
golh = (struct gsmtap_osmocore_log_hdr *) msgb_put(msg, sizeof(*golh));
-   osmo_strlcpy(golh->proc_name, target->tgt_gsmtap.ident,
-sizeof(golh->proc_name));
+   OSMO_STRLCPY_ARRAY(golh->proc_name, target->tgt_gsmtap.ident);
if (subsys_name)
-   osmo_strlcpy(golh->subsys, subsys_name+1, sizeof(golh->subsys));
+   OSMO_STRLCPY_ARRAY(golh->subsys, subsys_name + 1);
else
golh->subsys[0] = '\0';
 
/* strip all leading path elements from file, if any. */
file_basename = strrchr(file, '/');
file = (file_basename && file_basename[1])? file_basename + 1 : file;
-   osmo_strlcpy(golh->src_file.name, file, sizeof(golh->src_file.name));
+   OSMO_STRLCPY_ARRAY(golh->src_file.name, file);
golh->src_file.line_nr = osmo_htonl(line);
golh->level = level;
/* we always store the timestamp in the message, irrespective

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

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


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

2018-02-05 Thread Harald Welte

Patch Set 10: Code-Review+1

Waiting for feedback on dlcx in cleanup question, looks fine otgherwise

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I887ce0c15a831dffeb6251a975337b83942af566
Gerrit-PatchSet: 10
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


libosmocore[master]: utils: add helper wrapper for osmo_strlcpy()

2018-02-05 Thread Harald Welte

Patch Set 2: Code-Review+2

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

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


libosmocore[master]: GSUP: change osmo_gsup_encode() return type

2018-02-05 Thread Harald Welte

Patch Set 2: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Idaa1deecb6d9e15329bd51867b4f6a03357461f0
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


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

2018-02-05 Thread dexter

Patch Set 10:

(8 comments)

> Waiting for feedback on dlcx in cleanup question, looks fine
 > otgherwise

Hmm. I have answered. I wonder why gerrit did not flush the draft messages... 
Hopefully it works this time.

https://gerrit.osmocom.org/#/c/5881/9/include/osmocom/mgcp_client/mgcp_client_fsm.h
File include/osmocom/mgcp_client/mgcp_client_fsm.h:

Line 11:  * 
> naming is not clear enough "conn_info" sounds like some generic information
"peer" sounds good to me.

The call-id and the endpoint in that struct are debatable. For the CRCX when I 
use the struct as input parameter I need to supply an endpoint-id and a call-id.

When I get the response. I might be interested in the endpoin-id the MGW 
actually supplied, so I need this parameter there too. I might not necessarily 
need the call-id since I already know it, but we can echo it here as service 
for the user so he does not need to memorize it. If the endpoint-id was already 
specific, than its the same for the endpoint-id

Trouble starts when it comes to an MDCX. Then I definitely do not need to 
supply a call-id or a connection-id. The FSM knows this by itself. So in this 
case its not entirely clear. The only way I see to resolve this is to have 
separate structs for each case, but this also would complicate the API then.


https://gerrit.osmocom.org/#/c/5881/9/include/osmocom/mgcp_client/mgcp_client_internal.h
File include/osmocom/mgcp_client/mgcp_client_internal.h:

Line 32:struct mgcp_client *mgcp,
> unrelated whitespace change?
Done


https://gerrit.osmocom.org/#/c/5881/9/src/libosmo-mgcp-client/mgcp_client_fsm.c
File src/libosmo-mgcp-client/mgcp_client_fsm.c:

Line 7:  * it under the terms of the GNU General Public License as published by
> no AGPL in those libraries.  the old libosmo-{legacy} mgcp was plain GPLv2-
Done


Line 112: static struct msgb *make_crcx_msg_bind_connect(struct mgcp_ctx 
*mgcp_ctx)
> static?
Done


Line 130: static struct msgb *make_mdcx_msg(struct mgcp_ctx *mgcp_ctx)
> static?
Done


Line 153: struct msgb *make_dlcx_msg(struct mgcp_ctx *mgcp_ctx)
> static?
Done


Line 443: static void fsm_cleanup_cb(struct osmo_fsm_inst *fi, enum 
osmo_fsm_term_cause cause)
> what about the cleanup issuing an unconditional DLCX to the MGW, just incas
It exits always through the cleanup_cb, I thought that this is what the cleanup 
is for? When we terminate regularly (OSMO_FSM_TERM_REGULAR) the cleanup is 
executed, right?

I was thinking about an unconditional DLCX in case of error situations, we 
could do this, but I think it does not make too much sense. Normally errors 
occur because the MGW times out. This usually means that the MGW is down. 
Sending a DLCX in those situation does not make too much sense. Thats why I 
skipped this.

If we want to implement the unconditional DLCX anyway, we could go by the cause 
code to distinguish clean exists from unclean ones.


Line 511:   .name = "MGCP_CONN",
> I think it's not a client FSM, but a client connection (or mgcp connection 
I have renamed it now, but I think the other namings should stay as they are, 
there is already the "mgcp_client" and with "mgcp_client_fsm" I want to express 
the close relationship between the two.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I887ce0c15a831dffeb6251a975337b83942af566
Gerrit-PatchSet: 10
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-HasComments: Yes


[PATCH] osmo-mgw[master]: protocol: prohibit wildcarded requests for MDCX and DLCX

2018-02-05 Thread dexter
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6260

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

protocol: prohibit wildcarded requests for MDCX and DLCX

When a wildcarded request is made with a DLCX or MDCX command
the MGW will search for a free endpoint and continues the command
execution with that endpoint.

- Catch the wildcarded request early on DLCX and MDCX and return
  with an error code.

See also TTCN3 testcases:
MGCP_Test.TC_mdcx_wildcarded
MGCP_Test.TC_dlcx_wildcarded

Change-Id: Ia77d44a6a86083e62338e5845b553e5cf13ebd10
---
M src/libosmo-mgcp/mgcp_protocol.c
1 file changed, 16 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/60/6260/4

diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 62487d1..ea86672 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -739,6 +739,14 @@
 
LOGP(DLMGCP, LOGL_NOTICE, "MDCX: modifying existing connection ...\n");
 
+   /* Prohibit wildcarded requests */
+   if (endp->wildcarded_req) {
+   LOGP(DLMGCP, LOGL_ERROR,
+"MDCX: endpoint:0x%x wildcarded endpoint names not 
supported.\n",
+ENDPOINT_NUMBER(endp));
+   return create_err_response(endp, 507, "MDCX", p->trans);
+   }
+
if (llist_count(&endp->conns) <= 0) {
LOGP(DLMGCP, LOGL_ERROR,
 "MDCX: endpoint:0x%x endpoint is not holding a 
connection.\n",
@@ -912,6 +920,14 @@
 "DLCX: endpoint:0x%x deleting connection ...\n",
 ENDPOINT_NUMBER(endp));
 
+   /* Prohibit wildcarded requests */
+   if (endp->wildcarded_req) {
+   LOGP(DLMGCP, LOGL_ERROR,
+"DLCX: endpoint:0x%x wildcarded endpoint names not 
supported.\n",
+ENDPOINT_NUMBER(endp));
+   return create_err_response(endp, 507, "DLCX", p->trans);
+   }
+
if (llist_count(&endp->conns) <= 0) {
LOGP(DLMGCP, LOGL_ERROR,
 "DLCX: endpoint:0x%x endpoint is not holding a 
connection.\n",

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ia77d44a6a86083e62338e5845b553e5cf13ebd10
Gerrit-PatchSet: 4
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 


osmo-bts[master]: Remove unused variables

2018-02-05 Thread Pau Espin Pedrol

Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/6248/1/src/common/rsl.c
File src/common/rsl.c:

Line 1251
> The Patch looks ok to me, but this line must stay. Its a fix for a nullpoin
Hey thanks for pointing it out, I think this change ended inside the patch 
while playing with git revert -n to remove some whitespace or doing some tests.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I3fec7e4b337f3ea4d8cd79f4e7261babc34911cb
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: Yes


[MERGED] libosmocore[master]: utils: add helper wrapper for osmo_strlcpy()

2018-02-05 Thread Max
Max has submitted this change and it was merged.

Change subject: utils: add helper wrapper for osmo_strlcpy()
..


utils: add helper wrapper for osmo_strlcpy()

Add wrapper for osmo_strlcpy() which uses sizeof() to automatically
determine buffer's size and use it for GSMTAP logging. This is pretty
common use case for osmo_strlcpy() so it's a good idea to save some
typing by using generic define.

Related: OS#2864
Change-Id: I03d0d3d32a8d572ad573d03c603e14cdc27a3f7b
---
M include/osmocom/core/utils.h
M src/logging_gsmtap.c
2 files changed, 6 insertions(+), 4 deletions(-)

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



diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index 72266ae..f1e011f 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -26,6 +26,9 @@
 /*! Number of bytes necessary to store given BITS */
 #define OSMO_BYTES_FOR_BITS(BITS) ((BITS + 8 - 1) / 8)
 
+/*! Copy a C-string into a sized buffer using sizeof to detect buffer's size */
+#define OSMO_STRLCPY_ARRAY(array, src) osmo_strlcpy(array, src, sizeof(array))
+
 #include 
 #include 
 #include 
diff --git a/src/logging_gsmtap.c b/src/logging_gsmtap.c
index 82535ad..cb379b0 100644
--- a/src/logging_gsmtap.c
+++ b/src/logging_gsmtap.c
@@ -81,17 +81,16 @@
 
/* Logging header */
golh = (struct gsmtap_osmocore_log_hdr *) msgb_put(msg, sizeof(*golh));
-   osmo_strlcpy(golh->proc_name, target->tgt_gsmtap.ident,
-sizeof(golh->proc_name));
+   OSMO_STRLCPY_ARRAY(golh->proc_name, target->tgt_gsmtap.ident);
if (subsys_name)
-   osmo_strlcpy(golh->subsys, subsys_name+1, sizeof(golh->subsys));
+   OSMO_STRLCPY_ARRAY(golh->subsys, subsys_name + 1);
else
golh->subsys[0] = '\0';
 
/* strip all leading path elements from file, if any. */
file_basename = strrchr(file, '/');
file = (file_basename && file_basename[1])? file_basename + 1 : file;
-   osmo_strlcpy(golh->src_file.name, file, sizeof(golh->src_file.name));
+   OSMO_STRLCPY_ARRAY(golh->src_file.name, file);
golh->src_file.line_nr = osmo_htonl(line);
golh->level = level;
/* we always store the timestamp in the message, irrespective

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

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


[PATCH] osmo-bts[master]: octphy: octpkt.c: Remove unused static functions

2018-02-05 Thread Pau Espin Pedrol

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

octphy: octpkt.c: Remove unused static functions

Change-Id: I97c08b66d41ab5902a11a1e989e278c56cdee102
---
M src/osmo-bts-octphy/octpkt.c
1 file changed, 0 insertions(+), 32 deletions(-)


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

diff --git a/src/osmo-bts-octphy/octpkt.c b/src/osmo-bts-octphy/octpkt.c
index a6167f5..d96d93d 100644
--- a/src/osmo-bts-octphy/octpkt.c
+++ b/src/osmo-bts-octphy/octpkt.c
@@ -73,22 +73,6 @@
ch->ulSocketId = htonl(socket_id);
 }
 
-/* push a data header (3 dwords) to the start of a msgb. This format is
- * used for event packets */
-static void octvocnet_push_data_hdr(struct msgb *msg,
-uint32_t log_obj_hdl,
-uint32_t log_obj_pkt_port,
-uint32_t dest_fifo_id)
-{
-   tOCTVOCNET_PKT_DATA_HEADER *dh;
-
-   dh = (tOCTVOCNET_PKT_DATA_HEADER *) msgb_push(msg, sizeof(*dh));
-
-   dh->hLogicalObj = htonl(log_obj_hdl);
-   dh->ulLogicalObjPktPort = htonl(log_obj_pkt_port);
-   dh->ulDestFifoId = htonl(dest_fifo_id);
-}
-
 /* common msg_header shared by all control messages. host byte order! */
 void octvc1_fill_msg_hdr(tOCTVC1_MSG_HEADER *mh, uint32_t len,
uint32_t sess_id, uint32_t trans_id,
@@ -108,22 +92,6 @@
mh->ulSessionId = sess_id;
mh->ulReturnCode = 0;
mh->ulUserInfo = user_info;
-}
-
-static void octvc1_push_msg_hdr(struct msgb *msg,
-   uint32_t sess_id,
-   uint32_t trans_id,
-   uint32_t user_info,
-   uint32_t msg_type,
-   uint32_t flags,
-   uint32_t api_cmd)
-{
-   tOCTVC1_MSG_HEADER *mh;
-   uint32_t len = msgb_length(msg);
-
-   mh = (tOCTVC1_MSG_HEADER *) msgb_push(msg, sizeof(*mh));
-
-   octvc1_fill_msg_hdr(mh, len, sess_id, trans_id, user_info, msg_type, 
flags, api_cmd);
 }
 
 #include 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I97c08b66d41ab5902a11a1e989e278c56cdee102
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 


[PATCH] osmo-bts[master]: vty.c: Remove warning message

2018-02-05 Thread Pau Espin Pedrol

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

vty.c: Remove warning message

This warning was included in commit
6d7b78bde165f39dcd9033f0c5386f5699801233 from 2011, and nowadays I only
see this command used in osmo-bts, so I think we most probably drop it
as it doesn't make sense anymore.

Change-Id: Ie277dce00292c8f403b9a2b405efe4429e6af86a
---
M src/common/vty.c
1 file changed, 0 insertions(+), 1 deletion(-)


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

diff --git a/src/common/vty.c b/src/common/vty.c
index 050f922..498ab5a 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -391,7 +391,6 @@
return CMD_SUCCESS;
 }
 
-#warning merge with OpenBSC?
 DEFUN(cfg_bts_unit_id,
   cfg_bts_unit_id_cmd,
   "ipa unit-id <0-65534> <0-255>",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie277dce00292c8f403b9a2b405efe4429e6af86a
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 


[PATCH] osmo-bts[master]: virtual: l1_if.c: Remove unneeded warning message

2018-02-05 Thread Pau Espin Pedrol

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

virtual: l1_if.c: Remove unneeded warning message

Commit 5eb17e28acdd6fba22a1f2e60f4d55aaef18b47a added this warning when
implementing the full function. However, other backends seem to be also
passing the primitive from the stack to l1sap_up without any visible issues.
Furthermore, according to the documentation of l1sap_up, it takes ownership of 
the
msgb, but doesn't take ownserhip of the prim itself.

Change-Id: I45fe40e3377eac999d1dac5356678195381d94ca
---
M src/osmo-bts-virtual/l1_if.c
1 file changed, 1 insertion(+), 2 deletions(-)


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

diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c
index cb6d483..e7478a0 100644
--- a/src/osmo-bts-virtual/l1_if.c
+++ b/src/osmo-bts-virtual/l1_if.c
@@ -163,8 +163,7 @@
goto nomessage;
}
 
-   /* forward primitive, forwarded msg will not be freed */
-#warning "we cannot just pass a l1sap primitive on the stack!!!"
+   /* forward primitive, lsap takes ownership of the msgb. */
l1sap_up(pinst->trx, &l1sap);
DEBUGP(DL1P, "Message forwarded to layer 2.\n");
return;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I45fe40e3377eac999d1dac5356678195381d94ca
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 


[PATCH] osmo-bts[master]: Remove unused variables

2018-02-05 Thread Pau Espin Pedrol
Hello Vadim Yanitskiy, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6248

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

Remove unused variables

Change-Id: I3fec7e4b337f3ea4d8cd79f4e7261babc34911cb
---
M src/common/l1sap.c
M src/osmo-bts-trx/l1_if.c
2 files changed, 0 insertions(+), 5 deletions(-)


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

diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 30c2759..a36ad88 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -448,7 +448,6 @@
   struct osmo_phsap_prim *l1sap,
   struct info_time_ind_param *info_time_ind)
 {
-   struct gsm_bts_trx *trx;
struct gsm_bts_role_bts *btsb = bts->role;
int frames_expired;
 
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index 3c11dfd..8f24ccf 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -135,7 +135,6 @@
  */
 int l1if_provision_transceiver_trx(struct trx_l1h *l1h)
 {
-   struct phy_link *plink = l1h->phy_inst->phy_link;
uint8_t tn;
 
if (!transceiver_available)
@@ -215,7 +214,6 @@
 
llist_for_each_entry(trx, &bts->trx_list, list) {
struct phy_instance *pinst = trx_phy_instance(trx);
-   struct phy_link *plink = pinst->phy_link;
struct trx_l1h *l1h = pinst->u.osmotrx.hdl;
l1h->config.arfcn_sent = 0;
l1h->config.tsc_sent = 0;
@@ -305,7 +303,6 @@
 {
struct gsm_bts_trx *trx;
uint8_t bsic = bts->bsic;
-   struct gsm_bts_role_bts *btsb = bts_role_bts(bts);
 
llist_for_each_entry(trx, &bts->trx_list, list) {
struct phy_instance *pinst = trx_phy_instance(trx);
@@ -327,7 +324,6 @@
 static uint8_t trx_set_trx(struct gsm_bts_trx *trx)
 {
struct phy_instance *pinst = trx_phy_instance(trx);
-   struct phy_link *plink = pinst->phy_link;
struct trx_l1h *l1h = pinst->u.osmotrx.hdl;
uint16_t arfcn = trx->arfcn;
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I3fec7e4b337f3ea4d8cd79f4e7261babc34911cb
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 


[PATCH] osmo-msc[master]: Wrap osmo_strlcpy() calls

2018-02-05 Thread Max
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/6198

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

Wrap osmo_strlcpy() calls

Using following semantic patch:
@@ expression A, B, C; @@
- osmo_strlcpy(A, B, sizeof(A));
+ OSMO_STRLCPY_ARRAY(A, B);

Which was applied using following command:
spatch --dir src -I src --sp-file strlcpy.spatch --in-place --recursive-includes

All the calls to osmo_strlcpy() which use destination buffer obtained
via sizeof() were replaced with the corresponding wrapper macro.

Change-Id: I67b482dedfa11237ac21894fc5930039e12434ab
Related: OS#2864
---
M src/libcommon/gsup_test_client.c
M src/libmsc/db.c
M src/libmsc/gsm_04_08.c
M src/libmsc/gsm_04_11.c
M src/libmsc/smpp_openbsc.c
M src/libmsc/sms_queue.c
M src/libvlr/vlr.c
7 files changed, 34 insertions(+), 36 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/98/6198/2

diff --git a/src/libcommon/gsup_test_client.c b/src/libcommon/gsup_test_client.c
index 8605040..be8e768 100644
--- a/src/libcommon/gsup_test_client.c
+++ b/src/libcommon/gsup_test_client.c
@@ -75,7 +75,7 @@
return NULL;
 
io = talloc_zero(ctx, struct imsi_op);
-   osmo_strlcpy(io->imsi, imsi, sizeof(io->imsi));
+   OSMO_STRLCPY_ARRAY(io->imsi, imsi);
io->type = type;
osmo_timer_setup(&io->timer, imsi_op_timer_cb, io);
llist_add(&io->list, &g_imsi_ops);
@@ -107,7 +107,7 @@
struct osmo_gsup_message gsup = {0};
struct msgb *msg = msgb_alloc_headroom(1200, 200, __func__);
 
-   osmo_strlcpy(gsup.imsi, io->imsi, sizeof(gsup.imsi));
+   OSMO_STRLCPY_ARRAY(gsup.imsi, io->imsi);
gsup.message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST;
 
osmo_gsup_encode(msg, &gsup);
@@ -122,7 +122,7 @@
struct osmo_gsup_message gsup = {0};
struct msgb *msg = msgb_alloc_headroom(1200, 200, __func__);
 
-   osmo_strlcpy(gsup.imsi, io->imsi, sizeof(gsup.imsi));
+   OSMO_STRLCPY_ARRAY(gsup.imsi, io->imsi);
gsup.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST;
 
osmo_gsup_encode(msg, &gsup);
@@ -135,7 +135,7 @@
struct osmo_gsup_message gsup = {0};
struct msgb *msg = msgb_alloc_headroom(1200, 200, __func__);
 
-   osmo_strlcpy(gsup.imsi, io->imsi, sizeof(gsup.imsi));
+   OSMO_STRLCPY_ARRAY(gsup.imsi, io->imsi);
gsup.message_type = OSMO_GSUP_MSGT_INSERT_DATA_RESULT;
 
osmo_gsup_encode(msg, &gsup);
diff --git a/src/libmsc/db.c b/src/libmsc/db.c
index db9989d..d06db10 100644
--- a/src/libmsc/db.c
+++ b/src/libmsc/db.c
@@ -258,7 +258,7 @@
free(quoted);
extension = dbi_result_get_string(result2, "extension");
if (extension)
-   osmo_strlcpy(sms->src.addr, extension, sizeof(sms->src.addr));
+   OSMO_STRLCPY_ARRAY(sms->src.addr, extension);
dbi_result_free(result2);
/* got the extension */
 
@@ -271,7 +271,7 @@
 
daddr = dbi_result_get_string(result, "dest_addr");
if (daddr)
-   osmo_strlcpy(sms->dst.addr, daddr, sizeof(sms->dst.addr));
+   OSMO_STRLCPY_ARRAY(sms->dst.addr, daddr);
 
sms->user_data_len = dbi_result_get_field_length(result, "user_data");
user_data = dbi_result_get_binary(result, "user_data");
@@ -281,7 +281,7 @@
 
text = dbi_result_get_string(result, "text");
if (text)
-   osmo_strlcpy(sms->text, text, sizeof(sms->text));
+   OSMO_STRLCPY_ARRAY(sms->text, text);
return sms;
 }
 
@@ -410,12 +410,12 @@
  "data_coding_scheme");
 
addr = dbi_result_get_string(result, "src_addr");
-   osmo_strlcpy(sms->src.addr, addr, sizeof(sms->src.addr));
+   OSMO_STRLCPY_ARRAY(sms->src.addr, addr);
sms->src.ton = dbi_result_get_ulonglong(result, "src_ton");
sms->src.npi = dbi_result_get_ulonglong(result, "src_npi");
 
addr = dbi_result_get_string(result, "dest_addr");
-   osmo_strlcpy(sms->dst.addr, addr, sizeof(sms->dst.addr));
+   OSMO_STRLCPY_ARRAY(sms->dst.addr, addr);
sms->dst.ton = dbi_result_get_ulonglong(result, "dest_ton");
sms->dst.npi = dbi_result_get_ulonglong(result, "dest_npi");
 
@@ -427,7 +427,7 @@
 
text = dbi_result_get_string(result, "text");
if (text)
-   osmo_strlcpy(sms->text, text, sizeof(sms->text));
+   OSMO_STRLCPY_ARRAY(sms->text, text);
return sms;
 }
 
@@ -766,14 +766,14 @@
sms->dst.ton = dbi_result_get_ulonglong(result, "dest_ton");
daddr = dbi_result_get_string(result, "dest_addr");
if (daddr)
-   osmo_strlcpy(sms->dst.addr, daddr, sizeof(sms->dst.addr));
+   OSMO_STRLCPY_ARRAY(sms->dst.addr, daddr);
sms->receiver = vlr_subscr_find_by_msisdn(net->vlr, sms->dst.addr);
 
sms->src.npi = dbi_result_get_ulonglong(result, "src_npi");

osmo-trx[master]: Add support to set Rx/TxAntenna

2018-02-05 Thread Pau Espin Pedrol

Patch Set 1:

> Regarding to the ws fixes, they are definitely great.
 > But unrelated to the commit at all. I would prefer
 > to see them in a separate change...

Yes I am planning to do it this week, I pushed it here for comments before 
leaving to catch my flight for FOSDEM :)

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


osmocom-bb[master]: Import gprsdecode utility

2018-02-05 Thread Vadim Yanitskiy

Patch Set 5: Code-Review-1

(1 comment)

> I'll leave it up to vadim. Once vadim is happy, let me know for
 > some final review and hopefully +2

I'll rewrite the code to use libosmocoding, because I have
some experience with it and don't want to see the code duplication.

The main idea is to use gsm0503_pdtch_egprs_(de|en)code like
OsmoBTS does. This is what libosmocoding is intended for ;)

https://gerrit.osmocom.org/#/c/5992/5/src/host/gprsdecode/Makefile.am
File src/host/gprsdecode/Makefile.am:

Line 2: AM_CFLAGS = -Wall -O3 -pipe -flto -std=gnu99 -g $(LIBOSMOCORE_CFLAGS) 
$(LIBOSMOGSM_CFLAGS) $(LIBOSMOCODING_CFLAGS) 
ws


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I12234d37c66b83b8abd60f7511fa1d7837db1856
Gerrit-PatchSet: 5
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: fixeria 
Gerrit-HasComments: Yes


osmo-bsc[master]: Make "waiting indicator" of IMMEDIATE ASSIGN REJECT dynamic.

2018-02-05 Thread Stefan Sperling

Patch Set 1:

(2 comments)

https://gerrit.osmocom.org/#/c/6211/1/src/libbsc/abis_rsl.c
File src/libbsc/abis_rsl.c:

Line 1791:  /* Set all request references and wait indications to the same 
value.
> it might make sense to state explicitly here that the spec requires entries
I'll add a reference to the spec I read in the next patchset.


https://gerrit.osmocom.org/#/c/6211/1/src/libbsc/net_init.c
File src/libbsc/net_init.c:

Line 79:osmo_timer_setup(&net->t3122_chan_load_timer, 
update_t3122_chan_load_timer, net);
> I think it might make sense to have each BTS have its own timer, rather tha
I'll add a comment in the next patch set.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I57e38f6d6ba3b23cc6e1f9520b90261dbb1f1cec
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: Yes


[PATCH] osmo-bsc[master]: Make "waiting indicator" of IMMEDIATE ASSIGN REJECT dynamic.

2018-02-05 Thread Stefan Sperling
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/6211

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

Make "waiting indicator" of IMMEDIATE ASSIGN REJECT dynamic.

The IMMEDIATE ASSIGN REJECT message contains a wait indicator which
tells an MS requesting a channel to wait for a specified amount of
time before trying to request a channel again, i.e. the wait indicator
controls the T3122 timeout value in the MS.

Previously, the wait indicator was fixed to 10 seconds.
This is not sufficient if there are a lot of MS requesting channels
because the MS will retry too soon. Instead of using a fixed value,
maintain a dynamic wait indicator value based on average channel load.

The load (used vs. available channels on a BTS) is sampled once per
second, and once 8 samples have been collected we update a BTS-specific
T3122 wait indicator based on the measured load.

While the wait indicator could go up to 255 seconds, this initial
implementation keeps it in the range from 10 to 128 seconds.

Further experimentation and testing will show whether higher wait
indicator values are desirable, if the sampling rate needs to change,
or if the function mapping the load measurement to a wait indicator
value should change (currently we map the load average linearly into
the range [10, 128] inclusive).

Change-Id: I57e38f6d6ba3b23cc6e1f9520b90261dbb1f1cec
Related: OS#2592
---
M include/osmocom/bsc/chan_alloc.h
M include/osmocom/bsc/gsm_data.h
M include/osmocom/bsc/gsm_data_shared.h
M src/libbsc/abis_rsl.c
M src/libbsc/bsc_init.c
M src/libbsc/bsc_vty.c
M src/libbsc/chan_alloc.c
M src/libbsc/net_init.c
M src/libcommon/gsm_data_shared.c
M tests/channel/Makefile.am
M tests/channel/channel_test.c
11 files changed, 143 insertions(+), 30 deletions(-)


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

diff --git a/include/osmocom/bsc/chan_alloc.h b/include/osmocom/bsc/chan_alloc.h
index 748e9cd..98568a5 100644
--- a/include/osmocom/bsc/chan_alloc.h
+++ b/include/osmocom/bsc/chan_alloc.h
@@ -37,17 +37,13 @@
 /* Release the given lchan */
 int lchan_release(struct gsm_lchan *lchan, int sacch_deact, enum rsl_rel_mode 
release_mode);
 
-struct load_counter {
-   unsigned int total;
-   unsigned int used;
-};
-
 struct pchan_load {
struct load_counter pchan[_GSM_PCHAN_MAX];
 };
 
 void bts_chan_load(struct pchan_load *cl, const struct gsm_bts *bts);
 void network_chan_load(struct pchan_load *pl, struct gsm_network *net);
+void bts_update_t3122_chan_load(struct gsm_bts *bts);
 
 bool trx_is_usable(const struct gsm_bts_trx *trx);
 bool ts_is_usable(const struct gsm_bts_trx_ts *ts);
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index bdf7cfb..25dee78 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -308,6 +308,9 @@
/* Periodic location update default value */
uint8_t t3212;
 
+   /* Timer for periodic channel load measurements to maintain each BTS's 
T3122. */
+   struct osmo_timer_list t3122_chan_load_timer;
+
struct {
struct mgcp_client_conf *conf;
struct mgcp_client *client;
diff --git a/include/osmocom/bsc/gsm_data_shared.h 
b/include/osmocom/bsc/gsm_data_shared.h
index 86c5ca9..504b42a 100644
--- a/include/osmocom/bsc/gsm_data_shared.h
+++ b/include/osmocom/bsc/gsm_data_shared.h
@@ -573,6 +573,12 @@
double height;
 };
 
+/* Channel load counter */
+struct load_counter {
+   unsigned int total;
+   unsigned int used;
+};
+
 /* One BTS */
 struct gsm_bts {
/* list header in net->bts_list */
@@ -802,6 +808,13 @@
struct rate_ctr_group *bts_ctrs;
 
struct handover_cfg *ho;
+
+   /* BTS-specific overrides for timer values from struct gsm_network. */
+   uint8_t T3122;  /* ASSIGMENT REJECT wait indication */
+
+   /* Periodic channel load measurements are used to maintain T3122. */
+   struct load_counter chan_load_samples[7];
+   int chan_load_samples_idx;
 };
 
 
diff --git a/src/libbsc/abis_rsl.c b/src/libbsc/abis_rsl.c
index eced0e2..3f8bbc9 100644
--- a/src/libbsc/abis_rsl.c
+++ b/src/libbsc/abis_rsl.c
@@ -1776,8 +1776,7 @@
 
 /* Format an IMM ASS REJ according to 04.08 Chapter 9.1.20 */
 static int rsl_send_imm_ass_rej(struct gsm_bts *bts,
-   unsigned int num_req_refs,
-   struct gsm48_req_ref *rqd_refs,
+   struct gsm48_req_ref *rqd_ref,
uint8_t wait_ind)
 {
uint8_t buf[GSM_MACBLOCK_LEN];
@@ -1789,25 +1788,19 @@
iar->msg_type = GSM48_MT_RR_IMM_ASS_REJ;
iar->page_mode = GSM48_PM_SAME;
 
-   memcpy(&iar->req_ref1, &rqd_refs[0], sizeof(iar->req_ref1));
+   /*
+* Set all request references and wait indications to the same value.
+* 3GPP TS 44.018 v4.5.0 release 4 (section 9.1.20.2) requires that
+* w

osmo-bsc[master]: Make "waiting indicator" of IMMEDIATE ASSIGN REJECT dynamic.

2018-02-05 Thread Harald Welte

Patch Set 2: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I57e38f6d6ba3b23cc6e1f9520b90261dbb1f1cec
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: No


[MERGED] osmo-bsc[master]: Make "waiting indicator" of IMMEDIATE ASSIGN REJECT dynamic.

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Make "waiting indicator" of IMMEDIATE ASSIGN REJECT dynamic.
..


Make "waiting indicator" of IMMEDIATE ASSIGN REJECT dynamic.

The IMMEDIATE ASSIGN REJECT message contains a wait indicator which
tells an MS requesting a channel to wait for a specified amount of
time before trying to request a channel again, i.e. the wait indicator
controls the T3122 timeout value in the MS.

Previously, the wait indicator was fixed to 10 seconds.
This is not sufficient if there are a lot of MS requesting channels
because the MS will retry too soon. Instead of using a fixed value,
maintain a dynamic wait indicator value based on average channel load.

The load (used vs. available channels on a BTS) is sampled once per
second, and once 8 samples have been collected we update a BTS-specific
T3122 wait indicator based on the measured load.

While the wait indicator could go up to 255 seconds, this initial
implementation keeps it in the range from 10 to 128 seconds.

Further experimentation and testing will show whether higher wait
indicator values are desirable, if the sampling rate needs to change,
or if the function mapping the load measurement to a wait indicator
value should change (currently we map the load average linearly into
the range [10, 128] inclusive).

Change-Id: I57e38f6d6ba3b23cc6e1f9520b90261dbb1f1cec
Related: OS#2592
---
M include/osmocom/bsc/chan_alloc.h
M include/osmocom/bsc/gsm_data.h
M include/osmocom/bsc/gsm_data_shared.h
M src/libbsc/abis_rsl.c
M src/libbsc/bsc_init.c
M src/libbsc/bsc_vty.c
M src/libbsc/chan_alloc.c
M src/libbsc/net_init.c
M src/libcommon/gsm_data_shared.c
M tests/channel/Makefile.am
M tests/channel/channel_test.c
11 files changed, 143 insertions(+), 30 deletions(-)

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



diff --git a/include/osmocom/bsc/chan_alloc.h b/include/osmocom/bsc/chan_alloc.h
index 748e9cd..98568a5 100644
--- a/include/osmocom/bsc/chan_alloc.h
+++ b/include/osmocom/bsc/chan_alloc.h
@@ -37,17 +37,13 @@
 /* Release the given lchan */
 int lchan_release(struct gsm_lchan *lchan, int sacch_deact, enum rsl_rel_mode 
release_mode);
 
-struct load_counter {
-   unsigned int total;
-   unsigned int used;
-};
-
 struct pchan_load {
struct load_counter pchan[_GSM_PCHAN_MAX];
 };
 
 void bts_chan_load(struct pchan_load *cl, const struct gsm_bts *bts);
 void network_chan_load(struct pchan_load *pl, struct gsm_network *net);
+void bts_update_t3122_chan_load(struct gsm_bts *bts);
 
 bool trx_is_usable(const struct gsm_bts_trx *trx);
 bool ts_is_usable(const struct gsm_bts_trx_ts *ts);
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index bdf7cfb..25dee78 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -308,6 +308,9 @@
/* Periodic location update default value */
uint8_t t3212;
 
+   /* Timer for periodic channel load measurements to maintain each BTS's 
T3122. */
+   struct osmo_timer_list t3122_chan_load_timer;
+
struct {
struct mgcp_client_conf *conf;
struct mgcp_client *client;
diff --git a/include/osmocom/bsc/gsm_data_shared.h 
b/include/osmocom/bsc/gsm_data_shared.h
index 86c5ca9..504b42a 100644
--- a/include/osmocom/bsc/gsm_data_shared.h
+++ b/include/osmocom/bsc/gsm_data_shared.h
@@ -573,6 +573,12 @@
double height;
 };
 
+/* Channel load counter */
+struct load_counter {
+   unsigned int total;
+   unsigned int used;
+};
+
 /* One BTS */
 struct gsm_bts {
/* list header in net->bts_list */
@@ -802,6 +808,13 @@
struct rate_ctr_group *bts_ctrs;
 
struct handover_cfg *ho;
+
+   /* BTS-specific overrides for timer values from struct gsm_network. */
+   uint8_t T3122;  /* ASSIGMENT REJECT wait indication */
+
+   /* Periodic channel load measurements are used to maintain T3122. */
+   struct load_counter chan_load_samples[7];
+   int chan_load_samples_idx;
 };
 
 
diff --git a/src/libbsc/abis_rsl.c b/src/libbsc/abis_rsl.c
index eced0e2..3f8bbc9 100644
--- a/src/libbsc/abis_rsl.c
+++ b/src/libbsc/abis_rsl.c
@@ -1776,8 +1776,7 @@
 
 /* Format an IMM ASS REJ according to 04.08 Chapter 9.1.20 */
 static int rsl_send_imm_ass_rej(struct gsm_bts *bts,
-   unsigned int num_req_refs,
-   struct gsm48_req_ref *rqd_refs,
+   struct gsm48_req_ref *rqd_ref,
uint8_t wait_ind)
 {
uint8_t buf[GSM_MACBLOCK_LEN];
@@ -1789,25 +1788,19 @@
iar->msg_type = GSM48_MT_RR_IMM_ASS_REJ;
iar->page_mode = GSM48_PM_SAME;
 
-   memcpy(&iar->req_ref1, &rqd_refs[0], sizeof(iar->req_ref1));
+   /*
+* Set all request references and wait indications to the same value.
+* 3GPP TS

osmo-bts[master]: virtual: l1_if.c: Remove unneeded warning message

2018-02-05 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


[MERGED] osmo-bts[master]: gsm_pchan2chan_nr: move warning to pragma message and track ...

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: gsm_pchan2chan_nr: move warning to pragma message and track 
issue
..


gsm_pchan2chan_nr: move warning to pragma message and track issue

Take the chance to move the default option to the end as it's the
usually expected syntax.

Change-Id: I21298fcd0d1c1aafdd3dc1e8c8dae37b271b1d3d
---
M src/common/gsm_data_shared.c
1 file changed, 3 insertions(+), 3 deletions(-)

Approvals:
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Max: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/common/gsm_data_shared.c b/src/common/gsm_data_shared.c
index aa012bc..9aa4ba1 100644
--- a/src/common/gsm_data_shared.c
+++ b/src/common/gsm_data_shared.c
@@ -675,15 +675,15 @@
cbits = 0x08;
cbits += lchan_nr;
break;
-   default:
case GSM_PCHAN_CCCH:
+   default:
/* OSMO_ASSERT(lchan_nr == 0);
 * FIXME: On octphy and litecell, we hit above assertion (see
 * Max's comment at https://gerrit.osmocom.org/589 ); disabled
 * for BTS until this is clarified; remove the #ifdef when it
-* is fixed.
+* is fixed. Tracked in OS#2906.
 */
-#warning "fix caller that passes lchan_nr != 0"
+#pragma message "fix caller that passes lchan_nr != 0"
cbits = 0x10;
break;
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I21298fcd0d1c1aafdd3dc1e8c8dae37b271b1d3d
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy 


osmo-bts[master]: Remove unused variables

2018-02-05 Thread Harald Welte

Patch Set 2: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I3fec7e4b337f3ea4d8cd79f4e7261babc34911cb
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


[MERGED] osmo-bts[master]: l1sap.c: l1sap_tch_rts_ind: Remove unused variables

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: l1sap.c: l1sap_tch_rts_ind: Remove unused variables
..


l1sap.c: l1sap_tch_rts_ind: Remove unused variables

Commit a1fa955212e18ddca286a2c7d30333116406f56b added them without
really making use of them.

Change-Id: Ie7cd648a4b8a5ae59efc8953d6424a91a0f025ef
---
M src/common/l1sap.c
1 file changed, 1 insertion(+), 6 deletions(-)

Approvals:
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Max: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index a36ad88..d3f3111 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -827,8 +827,7 @@
struct gsm_time g_time;
struct gsm_lchan *lchan;
uint8_t chan_nr, marker = 0;
-   uint16_t seq;
-   uint32_t fn, timestamp;
+   uint32_t fn;
int rc;
 
chan_nr = rts_ind->chan_nr;
@@ -863,10 +862,6 @@
} else {
/* Obtain RTP header Marker bit from control buffer */
marker = rtpmsg_marker_bit(resp_msg);
-   /* Obtain RTP header Sequence Number from control buffer */
-   seq = rtpmsg_seq(resp_msg);
-   /* Obtain RTP header Timestamp from control buffer */
-   timestamp = rtpmsg_ts(resp_msg);
 
resp_msg->l2h = resp_msg->data;
msgb_push(resp_msg, sizeof(*resp_l1sap));

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

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


[MERGED] osmo-bts[master]: Remove unused variables

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Remove unused variables
..


Remove unused variables

Change-Id: I3fec7e4b337f3ea4d8cd79f4e7261babc34911cb
---
M src/common/l1sap.c
M src/osmo-bts-trx/l1_if.c
2 files changed, 0 insertions(+), 5 deletions(-)

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



diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 30c2759..a36ad88 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -448,7 +448,6 @@
   struct osmo_phsap_prim *l1sap,
   struct info_time_ind_param *info_time_ind)
 {
-   struct gsm_bts_trx *trx;
struct gsm_bts_role_bts *btsb = bts->role;
int frames_expired;
 
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index 3c11dfd..8f24ccf 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -135,7 +135,6 @@
  */
 int l1if_provision_transceiver_trx(struct trx_l1h *l1h)
 {
-   struct phy_link *plink = l1h->phy_inst->phy_link;
uint8_t tn;
 
if (!transceiver_available)
@@ -215,7 +214,6 @@
 
llist_for_each_entry(trx, &bts->trx_list, list) {
struct phy_instance *pinst = trx_phy_instance(trx);
-   struct phy_link *plink = pinst->phy_link;
struct trx_l1h *l1h = pinst->u.osmotrx.hdl;
l1h->config.arfcn_sent = 0;
l1h->config.tsc_sent = 0;
@@ -305,7 +303,6 @@
 {
struct gsm_bts_trx *trx;
uint8_t bsic = bts->bsic;
-   struct gsm_bts_role_bts *btsb = bts_role_bts(bts);
 
llist_for_each_entry(trx, &bts->trx_list, list) {
struct phy_instance *pinst = trx_phy_instance(trx);
@@ -327,7 +324,6 @@
 static uint8_t trx_set_trx(struct gsm_bts_trx *trx)
 {
struct phy_instance *pinst = trx_phy_instance(trx);
-   struct phy_link *plink = pinst->phy_link;
struct trx_l1h *l1h = pinst->u.osmotrx.hdl;
uint16_t arfcn = trx->arfcn;
 

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

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


[MERGED] osmo-bts[master]: vty.c: Remove warning message

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: vty.c: Remove warning message
..


vty.c: Remove warning message

This warning was included in commit
6d7b78bde165f39dcd9033f0c5386f5699801233 from 2011, and nowadays I only
see this command used in osmo-bts, so I think we most probably drop it
as it doesn't make sense anymore.

Change-Id: Ie277dce00292c8f403b9a2b405efe4429e6af86a
---
M src/common/vty.c
1 file changed, 0 insertions(+), 1 deletion(-)

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



diff --git a/src/common/vty.c b/src/common/vty.c
index 050f922..498ab5a 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -391,7 +391,6 @@
return CMD_SUCCESS;
 }
 
-#warning merge with OpenBSC?
 DEFUN(cfg_bts_unit_id,
   cfg_bts_unit_id_cmd,
   "ipa unit-id <0-65534> <0-255>",

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

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


[MERGED] osmo-bts[master]: octphy: octpkt.c: Remove unused static functions

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: octphy: octpkt.c: Remove unused static functions
..


octphy: octpkt.c: Remove unused static functions

Change-Id: I97c08b66d41ab5902a11a1e989e278c56cdee102
---
M src/osmo-bts-octphy/octpkt.c
1 file changed, 0 insertions(+), 32 deletions(-)

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



diff --git a/src/osmo-bts-octphy/octpkt.c b/src/osmo-bts-octphy/octpkt.c
index a6167f5..d96d93d 100644
--- a/src/osmo-bts-octphy/octpkt.c
+++ b/src/osmo-bts-octphy/octpkt.c
@@ -73,22 +73,6 @@
ch->ulSocketId = htonl(socket_id);
 }
 
-/* push a data header (3 dwords) to the start of a msgb. This format is
- * used for event packets */
-static void octvocnet_push_data_hdr(struct msgb *msg,
-uint32_t log_obj_hdl,
-uint32_t log_obj_pkt_port,
-uint32_t dest_fifo_id)
-{
-   tOCTVOCNET_PKT_DATA_HEADER *dh;
-
-   dh = (tOCTVOCNET_PKT_DATA_HEADER *) msgb_push(msg, sizeof(*dh));
-
-   dh->hLogicalObj = htonl(log_obj_hdl);
-   dh->ulLogicalObjPktPort = htonl(log_obj_pkt_port);
-   dh->ulDestFifoId = htonl(dest_fifo_id);
-}
-
 /* common msg_header shared by all control messages. host byte order! */
 void octvc1_fill_msg_hdr(tOCTVC1_MSG_HEADER *mh, uint32_t len,
uint32_t sess_id, uint32_t trans_id,
@@ -108,22 +92,6 @@
mh->ulSessionId = sess_id;
mh->ulReturnCode = 0;
mh->ulUserInfo = user_info;
-}
-
-static void octvc1_push_msg_hdr(struct msgb *msg,
-   uint32_t sess_id,
-   uint32_t trans_id,
-   uint32_t user_info,
-   uint32_t msg_type,
-   uint32_t flags,
-   uint32_t api_cmd)
-{
-   tOCTVC1_MSG_HEADER *mh;
-   uint32_t len = msgb_length(msg);
-
-   mh = (tOCTVC1_MSG_HEADER *) msgb_push(msg, sizeof(*mh));
-
-   octvc1_fill_msg_hdr(mh, len, sess_id, trans_id, user_info, msg_type, 
flags, api_cmd);
 }
 
 #include 

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

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


[MERGED] osmo-bts[master]: bts-trx: scheduler_trx.c: Fix missing header

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: bts-trx: scheduler_trx.c: Fix missing header
..


bts-trx: scheduler_trx.c: Fix missing header

It is required for bts_shutdown used in trx_fn_timer_cb, and compiler
warns about implicit declaration.

Change-Id: I274662cd657ce8c36ed1d262d138590808bfafea
---
M src/osmo-bts-trx/scheduler_trx.c
1 file changed, 1 insertion(+), 0 deletions(-)

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



diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index d3928f1..0f3272e 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

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

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


[MERGED] osmo-bts[master]: virtual: l1_if.c: Remove unneeded warning message

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: virtual: l1_if.c: Remove unneeded warning message
..


virtual: l1_if.c: Remove unneeded warning message

Commit 5eb17e28acdd6fba22a1f2e60f4d55aaef18b47a added this warning when
implementing the full function. However, other backends seem to be also
passing the primitive from the stack to l1sap_up without any visible issues.
Furthermore, according to the documentation of l1sap_up, it takes ownership of 
the
msgb, but doesn't take ownserhip of the prim itself.

Change-Id: I45fe40e3377eac999d1dac5356678195381d94ca
---
M src/osmo-bts-virtual/l1_if.c
1 file changed, 1 insertion(+), 2 deletions(-)

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



diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c
index cb6d483..e7478a0 100644
--- a/src/osmo-bts-virtual/l1_if.c
+++ b/src/osmo-bts-virtual/l1_if.c
@@ -163,8 +163,7 @@
goto nomessage;
}
 
-   /* forward primitive, forwarded msg will not be freed */
-#warning "we cannot just pass a l1sap primitive on the stack!!!"
+   /* forward primitive, lsap takes ownership of the msgb. */
l1sap_up(pinst->trx, &l1sap);
DEBUGP(DL1P, "Message forwarded to layer 2.\n");
return;

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

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


osmo-bts[master]: octphy: octpkt.c: Remove unused static functions

2018-02-05 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


osmo-bts[master]: vty.c: Remove warning message

2018-02-05 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


[MERGED] osmo-msc[master]: Wrap osmo_strlcpy() calls

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Wrap osmo_strlcpy() calls
..


Wrap osmo_strlcpy() calls

Using following semantic patch:
@@ expression A, B, C; @@
- osmo_strlcpy(A, B, sizeof(A));
+ OSMO_STRLCPY_ARRAY(A, B);

Which was applied using following command:
spatch --dir src -I src --sp-file strlcpy.spatch --in-place --recursive-includes

All the calls to osmo_strlcpy() which use destination buffer obtained
via sizeof() were replaced with the corresponding wrapper macro.

Change-Id: I67b482dedfa11237ac21894fc5930039e12434ab
Related: OS#2864
---
M src/libcommon/gsup_test_client.c
M src/libmsc/db.c
M src/libmsc/gsm_04_08.c
M src/libmsc/gsm_04_11.c
M src/libmsc/smpp_openbsc.c
M src/libmsc/sms_queue.c
M src/libvlr/vlr.c
7 files changed, 34 insertions(+), 36 deletions(-)

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



diff --git a/src/libcommon/gsup_test_client.c b/src/libcommon/gsup_test_client.c
index 8605040..be8e768 100644
--- a/src/libcommon/gsup_test_client.c
+++ b/src/libcommon/gsup_test_client.c
@@ -75,7 +75,7 @@
return NULL;
 
io = talloc_zero(ctx, struct imsi_op);
-   osmo_strlcpy(io->imsi, imsi, sizeof(io->imsi));
+   OSMO_STRLCPY_ARRAY(io->imsi, imsi);
io->type = type;
osmo_timer_setup(&io->timer, imsi_op_timer_cb, io);
llist_add(&io->list, &g_imsi_ops);
@@ -107,7 +107,7 @@
struct osmo_gsup_message gsup = {0};
struct msgb *msg = msgb_alloc_headroom(1200, 200, __func__);
 
-   osmo_strlcpy(gsup.imsi, io->imsi, sizeof(gsup.imsi));
+   OSMO_STRLCPY_ARRAY(gsup.imsi, io->imsi);
gsup.message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST;
 
osmo_gsup_encode(msg, &gsup);
@@ -122,7 +122,7 @@
struct osmo_gsup_message gsup = {0};
struct msgb *msg = msgb_alloc_headroom(1200, 200, __func__);
 
-   osmo_strlcpy(gsup.imsi, io->imsi, sizeof(gsup.imsi));
+   OSMO_STRLCPY_ARRAY(gsup.imsi, io->imsi);
gsup.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST;
 
osmo_gsup_encode(msg, &gsup);
@@ -135,7 +135,7 @@
struct osmo_gsup_message gsup = {0};
struct msgb *msg = msgb_alloc_headroom(1200, 200, __func__);
 
-   osmo_strlcpy(gsup.imsi, io->imsi, sizeof(gsup.imsi));
+   OSMO_STRLCPY_ARRAY(gsup.imsi, io->imsi);
gsup.message_type = OSMO_GSUP_MSGT_INSERT_DATA_RESULT;
 
osmo_gsup_encode(msg, &gsup);
diff --git a/src/libmsc/db.c b/src/libmsc/db.c
index db9989d..d06db10 100644
--- a/src/libmsc/db.c
+++ b/src/libmsc/db.c
@@ -258,7 +258,7 @@
free(quoted);
extension = dbi_result_get_string(result2, "extension");
if (extension)
-   osmo_strlcpy(sms->src.addr, extension, sizeof(sms->src.addr));
+   OSMO_STRLCPY_ARRAY(sms->src.addr, extension);
dbi_result_free(result2);
/* got the extension */
 
@@ -271,7 +271,7 @@
 
daddr = dbi_result_get_string(result, "dest_addr");
if (daddr)
-   osmo_strlcpy(sms->dst.addr, daddr, sizeof(sms->dst.addr));
+   OSMO_STRLCPY_ARRAY(sms->dst.addr, daddr);
 
sms->user_data_len = dbi_result_get_field_length(result, "user_data");
user_data = dbi_result_get_binary(result, "user_data");
@@ -281,7 +281,7 @@
 
text = dbi_result_get_string(result, "text");
if (text)
-   osmo_strlcpy(sms->text, text, sizeof(sms->text));
+   OSMO_STRLCPY_ARRAY(sms->text, text);
return sms;
 }
 
@@ -410,12 +410,12 @@
  "data_coding_scheme");
 
addr = dbi_result_get_string(result, "src_addr");
-   osmo_strlcpy(sms->src.addr, addr, sizeof(sms->src.addr));
+   OSMO_STRLCPY_ARRAY(sms->src.addr, addr);
sms->src.ton = dbi_result_get_ulonglong(result, "src_ton");
sms->src.npi = dbi_result_get_ulonglong(result, "src_npi");
 
addr = dbi_result_get_string(result, "dest_addr");
-   osmo_strlcpy(sms->dst.addr, addr, sizeof(sms->dst.addr));
+   OSMO_STRLCPY_ARRAY(sms->dst.addr, addr);
sms->dst.ton = dbi_result_get_ulonglong(result, "dest_ton");
sms->dst.npi = dbi_result_get_ulonglong(result, "dest_npi");
 
@@ -427,7 +427,7 @@
 
text = dbi_result_get_string(result, "text");
if (text)
-   osmo_strlcpy(sms->text, text, sizeof(sms->text));
+   OSMO_STRLCPY_ARRAY(sms->text, text);
return sms;
 }
 
@@ -766,14 +766,14 @@
sms->dst.ton = dbi_result_get_ulonglong(result, "dest_ton");
daddr = dbi_result_get_string(result, "dest_addr");
if (daddr)
-   osmo_strlcpy(sms->dst.addr, daddr, sizeof(sms->dst.addr));
+   OSMO_STRLCPY_ARRAY(sms->dst.addr, daddr);
sms->receiver = vlr_subscr_find_by_msisdn(net->vlr, sms->dst.addr);
 
sms->src.npi = dbi_result_get_ulo

osmo-msc[master]: Wrap osmo_strlcpy() calls

2018-02-05 Thread Harald Welte

Patch Set 2: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I67b482dedfa11237ac21894fc5930039e12434ab
Gerrit-PatchSet: 2
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-trx[master]: Add support to set Rx/TxAntenna

2018-02-05 Thread Harald Welte

Patch Set 1:

I find "antenna" confusing, but apparently this is the wording the UHD uses.  
It's a an input or output port, or maybe connector of the board/device.  
Whether or not a user attaches an antenna to that (or a 
PA/LNA/duplexer/attenuator, coaxial distribution network, etc.) is completely 
outside our knowledge.

Adding more command-line arguments is in-line with the current "architecture" 
but becomes more and more clumsy and cumbersom - at some point we have to 
introduce the libosmovty based config file that we're talking about for years.  
The question is whether we should keep adding new argumetns, or simply refuse 
to do so until a config file exists...

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

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


osmo-pcu[master]: vty: add commands to show TBF of a certain kind

2018-02-05 Thread Harald Welte

Patch Set 2:

> > Could be one command with (all|pacch|...)
 > 
 > Sure. What would be advantage of such approach? In case of separate
 > commands it's trivial 1-liner functions. If we use single command
 > with parameters than we have to check for parameter value using
 > switch or if ladder.

A signle command with !strmcp if-clauses is more in line to what we have at 
many other places in the code.  At least those instances of VTY code that I 
wrote or I can remember implement the previous approach.  I think ultimately, 
you end up with less lines.  But then I agree, it's not a blocking issue, which 
is why I wrote "could".

Also, note the replication of things like
SHOW_STR "information about TBFs\n

in your approach, where actually you should add a #define like TBF_STR and then 
re-use that.  If you go for a single DEFUN this comes for free.

Also, if one later e.g. introduces something like an optional [stats] argument 
or whatever other argument to show more information, a single function would be 
easier to change, than multiple.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I80f8df4fe663a0346f4289a4220b761e39726312
Gerrit-PatchSet: 2
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-HasComments: No


osmo-trx[master]: Add support to set Rx/TxAntenna

2018-02-05 Thread Pau Espin Pedrol

Patch Set 1:

I agree, using the term TX/RX "path" sounds better to me, but I tried to stick 
to UHD terminology.

 > Adding more command-line arguments is in-line with the current
 > "architecture" but becomes more and more clumsy and cumbersom - at
 > some point we have to introduce the libosmovty based config file
 > that we're talking about for years.  The question is whether we
 > should keep adding new argumetns, or simply refuse to do so until a
 > config file exists...

I agree that we should move to VTY, as it starts to be cumbersome to add more 
parameters and manage them. There's a ticket already created to do it: 
https://osmocom.org/issues/2183. Shall we increase priority? I or someone else 
can work on that at some point.
However, I still think having this RX/TX antenna support has more priority so 
let's merge it for now and drop all the parameters later.

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

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


[MERGED] libosmocore[master]: GSUP: change osmo_gsup_encode() return type

2018-02-05 Thread Max
Max has submitted this change and it was merged.

Change subject: GSUP: change osmo_gsup_encode() return type
..


GSUP: change osmo_gsup_encode() return type

* match return type of osmo_gsup_encode() with osmo_gsup_decode() to allow
  propagating error to caller
* check return value of osmo_gsup_encode() in GSUP test
* return errors instead of braking app with aseert

Change-Id: Idaa1deecb6d9e15329bd51867b4f6a03357461f0
Related: OS#2864
---
M include/osmocom/gsm/gsup.h
M src/gsm/gsup.c
M tests/gsup/gsup_test.c
3 files changed, 13 insertions(+), 6 deletions(-)

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



diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h
index 5cfe1ec..1a8a3b2 100644
--- a/include/osmocom/gsm/gsup.h
+++ b/include/osmocom/gsm/gsup.h
@@ -179,6 +179,6 @@
 
 int osmo_gsup_decode(const uint8_t *data, size_t data_len,
 struct osmo_gsup_message *gsup_msg);
-void osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message 
*gsup_msg);
+int osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message 
*gsup_msg);
 
 /*! @} */
diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c
index eb829f7..b6ac56d 100644
--- a/src/gsm/gsup.c
+++ b/src/gsm/gsup.c
@@ -475,8 +475,9 @@
 /*! Encode a GSUP message
  *  \param[out] msg message buffer to which encoded message is written
  *  \param[in] gsup_msg \ref osmo_gsup_message data to be encoded
+ *  \returns 0 on success; negative otherwise
  */
-void osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message 
*gsup_msg)
+int osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message 
*gsup_msg)
 {
uint8_t u8;
int idx;
@@ -484,14 +485,16 @@
size_t bcd_len;
 
/* generic part */
-   OSMO_ASSERT(gsup_msg->message_type);
+   if(!gsup_msg->message_type)
+   return -ENOMEM;
+
msgb_v_put(msg, gsup_msg->message_type);
 
bcd_len = gsm48_encode_bcd_number(bcd_buf, sizeof(bcd_buf), 0,
  gsup_msg->imsi);
 
-   OSMO_ASSERT(bcd_len > 1);
-   OSMO_ASSERT(bcd_len <= sizeof(bcd_buf));
+   if (bcd_len <= 0 || bcd_len > sizeof(bcd_buf))
+   return -EINVAL;
 
/* Note that gsm48_encode_bcd_number puts the length into the first
 * octet. Since msgb_tlv_put will add this length byte, we'll have to
@@ -560,6 +563,8 @@
msgb_tlv_put(msg, OSMO_GSUP_CHARG_CHAR_IE,
gsup_msg->pdp_charg_enc_len, 
gsup_msg->pdp_charg_enc);
}
+
+   return 0;
 }
 
 /*! @} */
diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c
index eddcc92..b55f1d9 100644
--- a/tests/gsup/gsup_test.c
+++ b/tests/gsup/gsup_test.c
@@ -220,7 +220,9 @@
if (rc < 0)
passed = false;
 
-   osmo_gsup_encode(msg, &gm);
+   rc = osmo_gsup_encode(msg, &gm);
+   if (rc < 0)
+   passed = false;
 
fprintf(stderr, "  generated message: %s\n", msgb_hexdump(msg));
fprintf(stderr, "  original message:  %s\n", 
osmo_hexdump(t->data, t->data_len));

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Idaa1deecb6d9e15329bd51867b4f6a03357461f0
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-Reviewer: Vadim Yanitskiy 


gapk[master]: src/Makefile.am: fix osmo-gapk LDADD dependency

2018-02-05 Thread Vadim Yanitskiy

Patch Set 1: Verified+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I3fdd1731bd372bbb42fe57981e757386e8ede0f0
Gerrit-PatchSet: 1
Gerrit-Project: gapk
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


osmo-trx[master]: Add support to set Rx/TxAntenna

2018-02-05 Thread Harald Welte

Patch Set 1:

well, we can only consider merging it after you have tested it successfully in 
some manual tests (maybe together with martin or roh to check if the correct 
output/input is actually used on the RF side).

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

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


osmo-trx[master]: Add support to set Rx/TxAntenna

2018-02-05 Thread Pau Espin Pedrol

Patch Set 1:

> well, we can only consider merging it after you have tested it
 > successfully in some manual tests (maybe together with martin or
 > roh to check if the correct output/input is actually used on the RF
 > side).



I'm reworking the commit now to improve/fix some stuff, but I can already test 
it by using the LimeSuiteGUI app, as it shows the configured paths in the chip, 
that's how we noticed the wrong path was being used.

If we changed the option there and saved it into the chip, then re-opened the 
app the value stayed. However, if before re-opening the app osmo-trx was run, 
afterwards when the app was re-opened it showded the paths had been changed to 
the default ones.

I am testing now doing the same and it seems the correct paths are then set up 
fine osmo-trx.

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

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


osmo-mgw[master]: Turn libosmo-mgcp into local, non-installed library

2018-02-05 Thread dexter

Patch Set 2: Code-Review+1

> Patch Set 2: Commit message was updated.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iba0a2c9c694e360356ac2ca584e97795281c6198
Gerrit-PatchSet: 2
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


[PATCH] osmo-trx[master]: Add support to set Rx/TxAntenna

2018-02-05 Thread Pau Espin Pedrol
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/6238

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

Add support to set Rx/TxAntenna

Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
---
M Transceiver52M/UHDDevice.cpp
M Transceiver52M/USRPDevice.cpp
M Transceiver52M/USRPDevice.h
M Transceiver52M/osmo-trx.cpp
M Transceiver52M/radioDevice.h
5 files changed, 253 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/38/6238/2

diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp
index 1120299..1687a60 100644
--- a/Transceiver52M/UHDDevice.cpp
+++ b/Transceiver52M/UHDDevice.cpp
@@ -208,7 +208,9 @@
 class uhd_device : public RadioDevice {
 public:
uhd_device(size_t tx_sps, size_t rx_sps, InterfaceType type,
-  size_t chans, double offset);
+  size_t chans, double offset,
+  const std::vector& tx_paths,
+  const std::vector& rx_paths);
~uhd_device();
 
int open(const std::string &args, int ref, bool swap_channels);
@@ -248,6 +250,11 @@
double getRxFreq(size_t chan);
double getRxFreq();
 
+   bool setRxAntenna(const std::string &ant, size_t chan);
+   std::string getRxAntenna(size_t chan);
+   bool setTxAntenna(const std::string &ant, size_t chan);
+   std::string getTxAntenna(size_t chan);
+
inline double getSampleRate() { return tx_rate; }
inline double numberRead() { return rx_pkt_cnt; }
inline double numberWritten() { return 0; }
@@ -280,6 +287,7 @@
 
std::vector tx_gains, rx_gains;
std::vector tx_freqs, rx_freqs;
+   std::vector tx_paths, rx_paths;
size_t tx_spp, rx_spp;
 
bool started;
@@ -295,6 +303,7 @@
void init_gains();
void set_channels(bool swap);
void set_rates();
+   bool set_antennas();
bool parse_dev_type();
bool flush_recv(size_t num_pkts);
int check_rx_md_err(uhd::rx_metadata_t &md, ssize_t num_smpls);
@@ -353,7 +362,9 @@
 }
 
 uhd_device::uhd_device(size_t tx_sps, size_t rx_sps,
-  InterfaceType iface, size_t chans, double offset)
+  InterfaceType iface, size_t chans, double offset,
+  const std::vector& tx_paths,
+  const std::vector& rx_paths)
: tx_gain_min(0.0), tx_gain_max(0.0),
  rx_gain_min(0.0), rx_gain_max(0.0),
  tx_spp(0), rx_spp(0),
@@ -365,6 +376,8 @@
this->chans = chans;
this->offset = offset;
this->iface = iface;
+   this->tx_paths = tx_paths;
+   this->rx_paths = rx_paths;
 }
 
 uhd_device::~uhd_device()
@@ -439,6 +452,33 @@
 
ts_offset = static_cast(desc.offset * rx_rate);
LOG(INFO) << "Rates configured for " << desc.str;
+}
+
+bool uhd_device::set_antennas()
+{
+   unsigned int i;
+
+   for (i = 0; i < tx_paths.size(); i++) {
+   if (tx_paths[i] == "")
+   continue;
+   LOG(DEBUG) << "Configuring channel " << i << " with antenna " 
<< tx_paths[i];
+   if (!setTxAntenna(tx_paths[i], i)) {
+   LOG(ALERT) << "Failed configuring channel " << i << " 
with antenna " << tx_paths[i];
+   return false;
+   }
+   }
+
+   for (i = 0; i < rx_paths.size(); i++) {
+   if (rx_paths[i] == "")
+   continue;
+   LOG(DEBUG) << "Configuring channel " << i << " with antenna " 
<< rx_paths[i];
+   if (!setRxAntenna(rx_paths[i], i)) {
+   LOG(ALERT) << "Failed configuring channel " << i << " 
with antenna " << rx_paths[i];
+   return false;
+   }
+   }
+   LOG(INFO) << "Antennas configured successfully";
+   return true;
 }
 
 double uhd_device::setTxGain(double db, size_t chan)
@@ -641,6 +681,11 @@
set_channels(swap_channels);
 } catch (const std::exception &e) {
LOG(ALERT) << "Channel setting failed - " << e.what();
+   return -1;
+   }
+
+   if (!set_antennas()) {
+   LOG(ALERT) << "UHD antenna setting failed";
return -1;
}
 
@@ -1165,6 +1210,78 @@
return rx_freqs[chan];
 }
 
+bool uhd_device::setRxAntenna(const std::string &ant, size_t chan)
+{
+   std::vector avail;
+   if (chan >= rx_paths.size()) {
+   LOG(ALERT) << "Requested non-existent channel " << chan;
+   return false;
+   }
+
+   avail = usrp_dev->get_rx_antennas(chan);
+   if (std::find(avail.begin(), avail.end(), ant) == avail.end()) {
+   LOG(ALERT) << "Requested non-existent Rx antenna " << ant << " 
on channel " << chan;
+   LOG(INFO) << "Available Rx antennas: ";
+   for (std::vector::const_iterator i = 
avail.begin(); i !

[PATCH] osmo-trx[master]: Fix whitespace

2018-02-05 Thread Pau Espin Pedrol

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

Fix whitespace

Change-Id: Icda84caa998614ce6c15d5118f8c5c1568ba9a79
---
M Transceiver52M/UHDDevice.cpp
M Transceiver52M/USRPDevice.cpp
M Transceiver52M/USRPDevice.h
3 files changed, 47 insertions(+), 48 deletions(-)


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

diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp
index 09317a9..1120299 100644
--- a/Transceiver52M/UHDDevice.cpp
+++ b/Transceiver52M/UHDDevice.cpp
@@ -1,5 +1,5 @@
 /*
- * Device support for Ettus Research UHD driver 
+ * Device support for Ettus Research UHD driver
  *
  * Copyright 2010,2011 Free Software Foundation, Inc.
  * Copyright (C) 2015 Ettus Research LLC
@@ -143,8 +143,8 @@
 public:
/** Sample buffer constructor
@param len number of 32-bit samples the buffer should hold
-   @param rate sample clockrate 
-   @param timestamp 
+   @param rate sample clockrate
+   @param timestamp
*/
smpl_buf(size_t len, double rate);
~smpl_buf();
@@ -172,7 +172,7 @@
*/
std::string str_status(size_t ts) const;
 
-   /** Formatted error string 
+   /** Formatted error string
@param code an error code
@return a formatted error string
*/
@@ -705,7 +705,7 @@
for (size_t i = 0; i < rx_buffers.size(); i++)
rx_buffers[i] = new smpl_buf(buf_len, rx_rate);
 
-   // Initialize and shadow gain values 
+   // Initialize and shadow gain values
init_gains();
 
// Print configuration
@@ -926,7 +926,7 @@
 
rx_pkt_cnt++;
 
-   // Check for errors 
+   // Check for errors
rc = check_rx_md_err(metadata, num_smpls);
switch (rc) {
case ERROR_UNRECOVERABLE:
diff --git a/Transceiver52M/USRPDevice.cpp b/Transceiver52M/USRPDevice.cpp
index e5be58d..162bb24 100644
--- a/Transceiver52M/USRPDevice.cpp
+++ b/Transceiver52M/USRPDevice.cpp
@@ -27,7 +27,7 @@
Compilation Flags
 
SWLOOPBACK  compile for software loopback testing
-*/ 
+*/
 
 
 #include 
@@ -80,7 +80,7 @@
   else
 pingOffset = 0;
 
-#ifdef SWLOOPBACK 
+#ifdef SWLOOPBACK
   samplePeriod = 1.0e6/actualSampleRate;
   loopbackBufferSize = 0;
   gettimeofday(&lastReadTime,NULL);
@@ -93,9 +93,9 @@
   writeLock.unlock();
 
   LOG(INFO) << "opening USRP device..";
-#ifndef SWLOOPBACK 
+#ifndef SWLOOPBACK
   string rbf = "std_inband.rbf";
-  //string rbf = "inband_1rxhb_1tx.rbf"; 
+  //string rbf = "inband_1rxhb_1tx.rbf";
   m_uRx.reset();
   if (!skipRx) {
   try {
@@ -144,7 +144,7 @@
 
   if (!skipRx) m_uRx->stop();
   m_uTx->stop();
-  
+
 #endif
 
   switch (dboardConfig) {
@@ -175,19 +175,19 @@
   samplesRead = 0;
   samplesWritten = 0;
   started = false;
-  
+
   return NORMAL;
 }
 
 
 
-bool USRPDevice::start() 
+bool USRPDevice::start()
 {
   LOG(INFO) << "starting USRP...";
-#ifndef SWLOOPBACK 
+#ifndef SWLOOPBACK
   if (!m_uRx && !skipRx) return false;
   if (!m_uTx) return false;
-  
+
   if (!skipRx) m_uRx->stop();
   m_uTx->stop();
 
@@ -217,8 +217,8 @@
   hi32Timestamp = 0;
   isAligned = false;
 
- 
-  if (!skipRx) 
+
+  if (!skipRx)
   started = (m_uRx->start() && m_uTx->start());
   else
   started = m_uTx->start();
@@ -229,14 +229,14 @@
 #endif
 }
 
-bool USRPDevice::stop() 
+bool USRPDevice::stop()
 {
-#ifndef SWLOOPBACK 
+#ifndef SWLOOPBACK
   if (!m_uRx) return false;
   if (!m_uTx) return false;
-  
+
   delete[] currData;
-  
+
   started = !(m_uRx->stop() && m_uTx->stop());
   return !started;
 #else
@@ -257,7 +257,7 @@
 double USRPDevice::maxRxGain()
 {
   return m_dbRx->gain_max();
-} 
+}
 
 double USRPDevice::minRxGain()
 {
@@ -318,23 +318,23 @@
 int USRPDevice::readSamples(std::vector &bufs, int len, bool *overrun,
 TIMESTAMP timestamp, bool *underrun, unsigned 
*RSSI)
 {
-#ifndef SWLOOPBACK 
+#ifndef SWLOOPBACK
   if (!m_uRx)
 return 0;
 
   short *buf = bufs[0];
 
   timestamp += timestampOffset;
-  
+
   if (timestamp + len < timeStart) {
 memset(buf,0,len*2*sizeof(short));
 return len;
   }
 
   if (underrun) *underrun = false;
- 
+
   uint32_t readBuf[2000];
- 
+
   while (1) {
 //guestimate USB read size
 int readLen=0;
@@ -344,7 +344,7 @@
   readLen = 512 * ((int) ceil((float) numSamplesNeeded/126.0));
   if (readLen > 8000) readLen= (8000/512)*512;
 }
-
+
 // read USRP packets, parse and save A/D data as needed
 readLen = m_uRx->read((void *)readBuf,readLen,overrun);
 for(int pktNum = 0; pktNum < (readLen/512); pktNum++) {
@@ -381,13 +381,13 @@
continue;
   }
   if ((word0 >> 28) & 0x04) {
-   if (underrun) *underrun = true; 
+   if (underrun) *underrun = true;
LOG(DEBUG) << "UNDERRUN in TRX->USRP interface";
   }
   if (RSSI) *RSSI = (word0 >> 21) & 0x3f;
-  
+
   if (!isAligned) continue;

[PATCH] osmo-pcu[master]: Simplify TS alloc: replace debug printer

2018-02-05 Thread Max
Hello Harald Welte, Jenkins Builder, Holger Freyther,

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

https://gerrit.osmocom.org/3929

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

Simplify TS alloc: replace debug printer

Replace unreadable recursive debug printer with simpler functions.

Note: the new printer also correctly handle reserved TS so Control slot
overrides TS for the bits set for both Uplink and Downlink slots. This
does not change the allocation semantics of course but requires cosmetic
adjustement to TBF tests output.

Change-Id: Ia13855877b2145cb57b1646f5562b2af3b87bcfb
Related: OS#2282
---
M src/gprs_rlcmac_ts_alloc.cpp
1 file changed, 3 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/29/3929/13

diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index bfa1ac7..852027b 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -36,20 +36,6 @@
 /* Consider a PDCH as idle if has at most this number of TBFs assigned to it */
 #define PDCH_IDLE_TBF_THRESH   1
 
-static char *set_flag_chars(char *buf, uint8_t val, char set_char, char 
unset_char = 0)
-{
-   int i;
-
-   for (i = 0; i < 8; i += 1, val = val >> 1) {
-   if (val & 1)
-   buf[i] = set_char;
-   else if (unset_char)
-   buf[i] = unset_char;
-   }
-
-   return buf;
-}
-
 static uint8_t find_possible_pdchs(const struct gprs_rlcmac_trx *trx, uint8_t 
max_slots, uint8_t mask,
   const char *mask_reason = NULL)
 {
@@ -537,11 +523,9 @@
*dl_slots &= pdch_slots;
*ul_slots &= pdch_slots;
 
-   LOGP(DRLCMAC, LOGL_DEBUG, "- Possible DL/UL slots: 
(TS=0)\"%s\"(TS=7)\n",
-   set_flag_chars(set_flag_chars(set_flag_chars(slot_info,
-   *dl_slots, 'D', '.'),
-   *ul_slots, 'U'),
-   *ul_slots & *dl_slots, 'C'));
+   ts_format(slot_info, *dl_slots, *ul_slots);
+   LOGP(DRLCMAC, LOGL_DEBUG,
+"- Possible DL/UL slots: (TS=0)\"%s\"(TS=7)\n", slot_info);
 
/* Check for each UL (TX) slot */
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ia13855877b2145cb57b1646f5562b2af3b87bcfb
Gerrit-PatchSet: 13
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 


[PATCH] osmo-pcu[master]: Simplify TS alloc: don't use PDCH for free TFI

2018-02-05 Thread Max
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/6223

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

Simplify TS alloc: don't use PDCH for free TFI

Don't use PDCH from free TFI lookup routine. This allows for simpler
function which can be moved to mslot_class.c alongside with other
similar helpers.

Change-Id: Ie154866900453d232a890f7b9a30911b451525a1
Related: OS#2282
---
M src/bts.h
M src/gprs_rlcmac_ts_alloc.cpp
M src/mslot_class.c
M src/mslot_class.h
4 files changed, 21 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/23/6223/2

diff --git a/src/bts.h b/src/bts.h
index 5679b98..f69f738 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+   #include 
 }
 
 #include "poll_controller.h"
@@ -44,7 +45,6 @@
 #define LLC_CODEL_DISABLE 0
 #define LLC_CODEL_USE_DEFAULT (-1)
 #define MAX_GPRS_CS 9
-#define NO_FREE_TFI 0x
 
 /* see bts->gsmtap_categ_mask */
 enum pcu_gsmtap_category {
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index 77c76f9..70b321c 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -58,23 +58,6 @@
return was_set;
 }
 
-static inline int8_t find_free_tfi(const struct gprs_rlcmac_pdch *pdch, enum 
gprs_rlcmac_tbf_direction dir)
-{
-   uint32_t tfi_map = pdch->assigned_tfi(dir);
-   int8_t tfi;
-
-   if (tfi_map == NO_FREE_TFI)
-   return -1;
-
-   /* look for USF, don't use USF=7 */
-   for (tfi = 0; tfi < 32; tfi++) {
-   if (!(tfi_map & (1 << tfi)))
-   return tfi;
-   }
-
-   return -1;
-}
-
 static int find_possible_pdchs(const struct gprs_rlcmac_trx *trx, size_t 
max_slots, uint8_t mask,
   const char *mask_reason = NULL)
 {
@@ -183,7 +166,7 @@
/* We have found a candidate */
/* Make sure that a TFI is available */
if (free_tfi) {
-   tfi = find_free_tfi(pdch, dir);
+   tfi = find_free_tfi(pdch->assigned_tfi(dir));
if (tfi < 0) {
LOGP(DRLCMAC, LOGL_DEBUG,
"- Skipping TS %d, because "
diff --git a/src/mslot_class.c b/src/mslot_class.c
index dad94ae..d403f00 100644
--- a/src/mslot_class.c
+++ b/src/mslot_class.c
@@ -230,6 +230,22 @@
return -1;
 }
 
+/* look for USF, don't use USF=7 */
+int8_t find_free_tfi(uint32_t tfi_map)
+{
+   int8_t tfi;
+
+   if (tfi_map == NO_FREE_TFI)
+   return -1;
+
+   for (tfi = 0; tfi < 32; tfi++) {
+   if (!(tfi_map & (1 << tfi)))
+   return tfi;
+   }
+
+   return -1;
+}
+
 void masked_override_with(char *buf, uint8_t mask, char set_char)
 {
int i;
diff --git a/src/mslot_class.h b/src/mslot_class.h
index d8b024b..445455f 100644
--- a/src/mslot_class.h
+++ b/src/mslot_class.h
@@ -36,6 +36,8 @@
 
 #define DEFAULT_MSLOT_CLASS 12
 
+#define NO_FREE_TFI 0x
+
 enum { MASK_TT = 0, MASK_TR = 1 };
 
 /* multislot class selection routines */
@@ -52,5 +54,6 @@
 /* multislot allocation helper routines */
 void mslot_fill_rx_mask(uint8_t mslot_class, uint8_t num_tx, uint8_t *rx_mask);
 int8_t find_free_usf(uint8_t usf_map);
+int8_t find_free_tfi(uint32_t tfi_map);
 void masked_override_with(char *buf, uint8_t mask, char set_char);
 void ts_format(char *buf, uint8_t dl_mask, uint8_t ul_mask);

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie154866900453d232a890f7b9a30911b451525a1
Gerrit-PatchSet: 2
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-pcu[master]: Simplify TS alloc: move slot check into functions

2018-02-05 Thread Max
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/3935

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

Simplify TS alloc: move slot check into functions

Move timeslot applicability check outside of nested for loop into
separate functions and document them. Add corresponding tests.

This allows us to clarify types used in TS-related computations.

Change-Id: Ic39e848da47dc11357782362fdf6206d2c1457c2
Related: OS#2282
---
M src/gprs_rlcmac_ts_alloc.cpp
M src/mslot_class.c
M src/mslot_class.h
M tests/alloc/MslotTest.cpp
M tests/alloc/MslotTest.ok
5 files changed, 626 insertions(+), 123 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/35/3935/11

diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index 86041f6..3074af4 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -50,19 +50,11 @@
return buf;
 }
 
-static bool test_and_set_bit(uint32_t *bits, size_t elem)
-{
-   bool was_set = bits[elem/32] & (1 << (elem % 32));
-   bits[elem/32] |= (1 << (elem % 32));
-
-   return was_set;
-}
-
-static int find_possible_pdchs(const struct gprs_rlcmac_trx *trx, size_t 
max_slots, uint8_t mask,
-  const char *mask_reason = NULL)
+static uint8_t find_possible_pdchs(const struct gprs_rlcmac_trx *trx, uint8_t 
max_slots, uint8_t mask,
+  const char *mask_reason = NULL)
 {
unsigned ts;
-   int valid_ts_set = 0;
+   uint8_t valid_ts_set = 0;
int8_t last_tsc = -1; /* must be signed */
 
for (ts = 0; ts < ARRAY_SIZE(trx->pdch); ts++) {
@@ -349,7 +341,7 @@
int trx_no;
int tfi = -1;
int usf = -1;
-   int mask = 0xff;
+   uint8_t mask = 0xff;
const char *mask_reason = NULL;
const GprsMs *ms = ms_;
const gprs_rlcmac_tbf *tbf = tbf_;
@@ -456,6 +448,58 @@
return capacity;
 }
 
+/*! Decide if a given slot should be skipped by multislot allocator
+ *
+ *  \param[in] ms_class Pointer to MS Class object
+ *  \param[in] check_tr Flag indicating whether we should check for Tra or Tta 
parameters for a given MS class
+ *  \param[in] rx_window Receive window
+ *  \param[in] tx_window Transmit window
+ *  \param[in,out] checked_rx array with already checked RX timeslots
+ *  \returns true if the slot should be skipped, false otherwise
+ */
+static bool skip_slot(uint8_t mslot_class, bool check_tr,
+ int16_t rx_window, int16_t tx_window,
+ uint32_t *checked_rx)
+{
+   uint8_t common_slot_count, req_common_slots,
+   rx_slot_count = pcu_bitcount(rx_window),
+   tx_slot_count = pcu_bitcount(tx_window);
+
+   /* Check compliance with TS 45.002, table 6.4.2.2.1 */
+   /* Whether to skip this round doesn not only depend on the bit
+* sets but also on check_tr. Therefore this check must be done
+* before doing the mslot_test_and_set_bit shortcut. */
+   if (mslot_class_get_type(mslot_class) == 1) {
+   uint16_t slot_sum = rx_slot_count + tx_slot_count;
+   /* Assume down + up / dynamic.
+* TODO: For ext-dynamic, down only, up only add more cases.
+*/
+   if (slot_sum <= 6 && tx_slot_count < 3) {
+   if (!check_tr)
+   return true; /* Skip Tta */
+   } else if (slot_sum > 6 && tx_slot_count < 3) {
+   if (check_tr)
+   return true; /* Skip Tra */
+   } else
+   return true; /* No supported row in TS 45.002, table 
6.4.2.2.1. */
+   }
+
+   /* Avoid repeated RX combination check */
+   if (mslot_test_and_set_bit(checked_rx, rx_window))
+   return true;
+
+   /* Check number of common slots according to TS 45.002, §6.4.2.2 */
+   common_slot_count = pcu_bitcount(tx_window & rx_window);
+   req_common_slots = OSMO_MIN(tx_slot_count, rx_slot_count);
+   if (mslot_class_get_type(mslot_class) == 1)
+   req_common_slots = OSMO_MIN(req_common_slots, 2);
+
+   if (req_common_slots != common_slot_count)
+   return true;
+
+   return false;
+}
+
 /*! Find set of slots available for allocation while taking MS class into 
account
  *
  *  \param[in] trx Pointer to TRX object
@@ -467,16 +511,12 @@
 int find_multi_slots(struct gprs_rlcmac_trx *trx, uint8_t mslot_class, uint8_t 
*ul_slots, uint8_t *dl_slots)
 {
uint8_t Tx = mslot_class_get_tx(mslot_class),   /* Max number of Tx 
slots */
-   Sum = mslot_class_get_sum(mslot_class); /* Max number of Tx + 
Rx slots */
-   int rx_window, tx_window, pdch_slots;
+   Sum = mslot_class_get_sum(mslot_class), /* Max number of Tx + 
Rx slots */
+   max_slots, num_tx, mask_sel, pdch_slots, ul_ts, dl_ts;

[PATCH] osmo-pcu[master]: Simplify TS alloc: split off RX mask computation

2018-02-05 Thread Max
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/3913

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

Simplify TS alloc: split off RX mask computation

Move computation of RX mask into separate function and document it. This
allows to significantly shrink find_multi_slot() function and overall
improve code readability.

Since the test output requires cosmetic adjustment anyway due to change
in the sequence of log messages, use this opportunity to better group
and format log message.

Change-Id: I731726a096bba7ee97499e5cbe3e7401869d7392
Related: OS#2282
---
M src/gprs_rlcmac_ts_alloc.cpp
M src/mslot_class.c
M src/mslot_class.h
M tests/tbf/TbfTest.err
4 files changed, 57 insertions(+), 49 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/13/3913/13

diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index c45aa39..19f78ad 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -471,48 +471,27 @@
  */
 int find_multi_slots(struct gprs_rlcmac_trx *trx, uint8_t mslot_class, uint8_t 
*ul_slots, uint8_t *dl_slots)
 {
-   uint8_t Tx, Sum;/* Maximum Number of Slots: RX, Tx, Sum Rx+Tx */
-   uint8_t Tta, Ttb, Tra, Trb; /* Minimum Number of Slots */
-   uint8_t Type; /* Type of Mobile */
+   uint8_t Tx = mslot_class_get_tx(mslot_class),   /* Max number of Tx 
slots */
+   Sum = mslot_class_get_sum(mslot_class); /* Max number of Tx + 
Rx slots */
int rx_window, tx_window, pdch_slots;
-   static const char *digit[10] = { 
"0","1","2","3","4","5","6","7","8","9" };
char slot_info[9] = {0};
-   int max_capacity;
-   uint8_t max_ul_slots;
-   uint8_t max_dl_slots;
+   int max_capacity = -1;
+   uint8_t max_ul_slots = 0, max_dl_slots = 0;
unsigned max_slots;
 
unsigned ul_ts, dl_ts;
unsigned num_tx;
-   enum {MASK_TT, MASK_TR};
unsigned mask_sel;
 
if (mslot_class)
LOGP(DRLCMAC, LOGL_DEBUG, "Slot Allocation (Algorithm B) for 
class %d\n",
 mslot_class);
 
-   Tx = mslot_class_get_tx(mslot_class);
-   Sum = mslot_class_get_sum(mslot_class);
-   Tta = mslot_class_get_ta(mslot_class);
-   Ttb = mslot_class_get_tb(mslot_class);
-
-   /* FIXME: use actual TA offset for computation - make sure to adjust "1 
+ MS_TO" accordingly
-  see also "Offset required" bit in 3GPP TS 24.008 §10.5.1.7 */
-   Tra = mslot_class_get_ra(mslot_class, 0);
-   Trb = mslot_class_get_rb(mslot_class, 0);
-
-   Type = mslot_class_get_type(mslot_class);
-
if (Tx == MS_NA) {
LOGP(DRLCMAC, LOGL_NOTICE, "Multislot class %d not 
applicable.\n",
 mslot_class);
return -EINVAL;
}
-
-   LOGP(DRLCMAC, LOGL_DEBUG, "- Rx=%d Tx=%d Sum Rx+Tx=%s  Tta=%s Ttb=%d "
-   " Tra=%d Trb=%d Type=%d\n", mslot_class_get_rx(mslot_class), Tx,
-   (Sum == MS_NA) ? "N/A" : digit[Sum],
-   (Tta == MS_NA) ? "N/A" : digit[Tta], Ttb, Tra, Trb, Type);
 
max_slots = OSMO_MAX(mslot_class_get_rx(mslot_class), Tx);
 
@@ -535,29 +514,12 @@
 
/* Check for each UL (TX) slot */
 
-   max_capacity = -1;
-   max_ul_slots = 0;
-   max_dl_slots = 0;
-
/* Iterate through possible numbers of TX slots */
for (num_tx = 1; num_tx <= mslot_class_get_tx(mslot_class); num_tx += 
1) {
uint16_t tx_valid_win = (1 << num_tx) - 1;
+   uint8_t rx_mask[MASK_TR + 1];
 
-   uint8_t rx_mask[MASK_TR+1];
-   if (Type == 1) {
-   rx_mask[MASK_TT] = (0x100 >> OSMO_MAX(Ttb, Tta)) - 1;
-   rx_mask[MASK_TT] &= ~((1 << (Trb + num_tx)) - 1);
-   rx_mask[MASK_TR] = (0x100 >> Ttb) - 1;
-   rx_mask[MASK_TR] &=
-   ~((1 << (OSMO_MAX(Trb, Tra) + num_tx)) - 1);
-   } else {
-   /* Class type 2 MS have independant RX and TX */
-   rx_mask[MASK_TT] = 0xff;
-   rx_mask[MASK_TR] = 0xff;
-   }
-
-   rx_mask[MASK_TT] = (rx_mask[MASK_TT] << 3) | (rx_mask[MASK_TT] 
>> 5);
-   rx_mask[MASK_TR] = (rx_mask[MASK_TR] << 3) | (rx_mask[MASK_TR] 
>> 5);
+   mslot_fill_rx_mask(mslot_class, num_tx, rx_mask);
 
/* Rotate group of TX slots: UUU-, -UUU, ..., UU-U */
for (ul_ts = 0; ul_ts < 8; ul_ts += 1, tx_valid_win <<= 1) {
@@ -626,7 +588,7 @@
/* Whether to skip this round doesn not only depend on the bit
 * sets but also on mask_sel. Therefore this check must be done
 * before doing the test_and_set_bit shortcut. */
-   if (Type == 1) {
+   if (mslot_class_get_type(mslot_class) == 1) {
   

osmo-mgw[master]: Turn libosmo-mgcp into local, non-installed library

2018-02-05 Thread Pau Espin Pedrol

Patch Set 2:

(4 comments)

https://gerrit.osmocom.org/#/c/6270/2/src/osmo-mgw/Makefile.am
File src/osmo-mgw/Makefile.am:

Line 11:$(LIBOSMOGSM_CFLAGS) \
this seems non-related to the patch.


Line 28:$(LIBOSMOGSM_LIBS) \
this seems non-related to the patch.


https://gerrit.osmocom.org/#/c/6270/2/tests/mgcp/Makefile.am
File tests/mgcp/Makefile.am:

Line 12:$(LIBOSMOGSM_CFLAGS) \
same.

If for soe reason related to the change, may be good having a LIBOSMOMGCP_* set 
of variables which we then include in osmo-mgw, to be able to go back to SO in 
the future.


Line 37:$(LIBOSMOGSM_LIBS) \
same


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iba0a2c9c694e360356ac2ca584e97795281c6198
Gerrit-PatchSet: 2
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: Yes


[PATCH] osmo-ttcn3-hacks[master]: Don't symlink non-existent file

2018-02-05 Thread Max

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

Don't symlink non-existent file

Change-Id: I10309f07fb207c027703f0b43a478c152a029b6d
---
M bsc-nat/gen_links.sh
M bsc/gen_links.sh
M ggsn_tests/gen_links.sh
M gprs_gb/gen_links.sh
M hlr/gen_links.sh
M mgw/gen_links.sh
M msc/gen_links.sh
M selftest/gen_links.sh
M sysinfo/gen_links.sh
9 files changed, 9 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/75/6275/1

diff --git a/bsc-nat/gen_links.sh b/bsc-nat/gen_links.sh
index 65b1602..d27c092 100755
--- a/bsc-nat/gen_links.sh
+++ b/bsc-nat/gen_links.sh
@@ -16,7 +16,7 @@
 #gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
-FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCConversion.hh TCCInterface.cc TCCInterface_ip.h 
SDP_EncDec.cc"
+FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCInterface.cc TCCInterface_ip.h SDP_EncDec.cc"
 gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src
diff --git a/bsc/gen_links.sh b/bsc/gen_links.sh
index 6417a3c..e807ca5 100755
--- a/bsc/gen_links.sh
+++ b/bsc/gen_links.sh
@@ -16,7 +16,7 @@
 #gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
-FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCConversion.hh TCCInterface.cc TCCInterface_ip.h 
SDP_EncDec.cc"
+FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCInterface.cc TCCInterface_ip.h SDP_EncDec.cc"
 gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src
diff --git a/ggsn_tests/gen_links.sh b/ggsn_tests/gen_links.sh
index 58c681f..1ab8009 100755
--- a/ggsn_tests/gen_links.sh
+++ b/ggsn_tests/gen_links.sh
@@ -16,7 +16,7 @@
 #gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
-FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCConversion.hh TCCInterface.cc TCCInterface_ip.h"
+FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCInterface.cc TCCInterface_ip.h"
 gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src
diff --git a/gprs_gb/gen_links.sh b/gprs_gb/gen_links.sh
index 9f4cea4..2b56a2b 100755
--- a/gprs_gb/gen_links.sh
+++ b/gprs_gb/gen_links.sh
@@ -16,7 +16,7 @@
 #gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
-FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCConversion.hh TCCInterface.cc TCCInterface_ip.h"
+FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCInterface.cc TCCInterface_ip.h"
 gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src
diff --git a/hlr/gen_links.sh b/hlr/gen_links.sh
index 6d83882..02da0ea 100755
--- a/hlr/gen_links.sh
+++ b/hlr/gen_links.sh
@@ -12,7 +12,7 @@
 }
 
 DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
-FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCConversion.hh
+FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc
 TCCInterface.cc TCCInterface_ip.h"
 gen_links $DIR $FILES
 
diff --git a/mgw/gen_links.sh b/mgw/gen_links.sh
index acdeb40..03b7db2 100755
--- a/mgw/gen_links.sh
+++ b/mgw/gen_links.sh
@@ -16,7 +16,7 @@
 #gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
-FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCConversion.hh TCCInterface.cc TCCInterface_ip.h"
+FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCInterface.cc TCCInterface_ip.h"
 gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src
diff --git a/msc/gen_links.sh b/msc/gen_links.sh
index 4249947..12f99a4 100755
--- a/msc/gen_links.sh
+++ b/msc/gen_links.sh
@@ -16,7 +16,7 @@
 gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
-FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCConversion.hh TCCInterface.cc TCCInterface_ip.h"
+FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCInterface.cc TCCInterface_ip.h"
 gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src
diff --git a/selftest/gen_links.sh b/selftest/gen_links.sh
index 5f53e44..611ba5c 100755
--- a/selftest/gen_links.sh
+++ b/selftest/gen_links.sh
@@ -16,7 +16,7 @@
 #gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
-FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCConversion.hh TCCInterface.cc TCCInterface_ip.h 
SDP_EncDec.cc"
+FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCInterface.cc TCCInterface_ip.h SDP_EncDec.cc"
 gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.TestPorts.Common_Componen

[PATCH] osmo-ttcn3-hacks[master]: Fix regen_makefile warning

2018-02-05 Thread Max

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

Fix regen_makefile warning

Having MSC_Tests.ttcn in call to regen-makefile.sh is redundant because
it#s included into *.ttcn mask which is part of $FILES. This leads to
following warning:

ttcn3_makefilegen: warning: File `MSC_Tests.ttcn' was given more than once for 
the Makefile.

Fix this be removing redundant parameter.

Change-Id: Ib94dbe65fa2ae53d95b3f0524af77b1303e33ce3
---
M msc/regen_makefile.sh
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/76/6276/1

diff --git a/msc/regen_makefile.sh b/msc/regen_makefile.sh
index dacd10b..72b409e 100755
--- a/msc/regen_makefile.sh
+++ b/msc/regen_makefile.sh
@@ -2,4 +2,4 @@
 
 FILES="*.ttcn SCCP_EncDec.cc  SCTPasp_PT.cc  TCCConversion.cc TCCInterface.cc 
UD_PT.cc MNCC_EncDec.cc IPL4asp_PT.cc IPL4asp_discovery.cc SDP_EncDec.cc 
RTP_EncDec.cc IPA_CodecPort_CtrlFunctDef.cc RTP_CodecPort_CtrlFunctDef.cc 
MGCP_CodecPort_CtrlFunctDef.cc TELNETasp_PT.cc Native_FunctionDefs.cc *.c"
 
-../regen-makefile.sh MSC_Tests.ttcn $FILES
+../regen-makefile.sh $FILES

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib94dbe65fa2ae53d95b3f0524af77b1303e33ce3
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] osmo-ttcn3-hacks[master]: Fix regen_makefile warning

2018-02-05 Thread Max
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/6276

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

Fix regen_makefile warning

Having MSC_Tests.ttcn in call to regen-makefile.sh is redundant because
it's included into *.ttcn mask which is part of $FILES. This leads to
following warning:

ttcn3_makefilegen: warning: File `MSC_Tests.ttcn' was given more than once for 
the Makefile.

Fix this be removing redundant parameter.

Change-Id: Ib94dbe65fa2ae53d95b3f0524af77b1303e33ce3
---
M msc/regen_makefile.sh
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/76/6276/2

diff --git a/msc/regen_makefile.sh b/msc/regen_makefile.sh
index dacd10b..72b409e 100755
--- a/msc/regen_makefile.sh
+++ b/msc/regen_makefile.sh
@@ -2,4 +2,4 @@
 
 FILES="*.ttcn SCCP_EncDec.cc  SCTPasp_PT.cc  TCCConversion.cc TCCInterface.cc 
UD_PT.cc MNCC_EncDec.cc IPL4asp_PT.cc IPL4asp_discovery.cc SDP_EncDec.cc 
RTP_EncDec.cc IPA_CodecPort_CtrlFunctDef.cc RTP_CodecPort_CtrlFunctDef.cc 
MGCP_CodecPort_CtrlFunctDef.cc TELNETasp_PT.cc Native_FunctionDefs.cc *.c"
 
-../regen-makefile.sh MSC_Tests.ttcn $FILES
+../regen-makefile.sh $FILES

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib94dbe65fa2ae53d95b3f0524af77b1303e33ce3
Gerrit-PatchSet: 2
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 


osmo-ttcn3-hacks[master]: Don't symlink non-existent file

2018-02-05 Thread Pau Espin Pedrol

Patch Set 1: Code-Review+1

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

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


osmo-ttcn3-hacks[master]: Fix regen_makefile warning

2018-02-05 Thread Pau Espin Pedrol

Patch Set 2: Code-Review-1

This is likely an issue present in all different subdirs using the 
regen_makefile.sh stuff, so it makes more sense to uniform all of them and fix 
it the same way for all in one commit.

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

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


[PATCH] osmo-bsc[master]: Add stat items for the BTS's channel load average and T3122.

2018-02-05 Thread Stefan Sperling

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

Add stat items for the BTS's channel load average and T3122.

In addition to logging the current values of a BTS's channel load
average and T3122 override, maintain stat items for these values.
This allows for plotting these values over time, for instance.

These values show up in the VTY under 'show stats' like this:

base transceiver station:
 Channel load average.:   25 %
 T3122 IMMEDIATE ASSIGNMENT REJECT wait indicator.: 32 s

Change-Id: Icace0176e8b1d23d7c7b4816f7c67c65312844fa
Suggested-by: laforge
---
M include/osmocom/bsc/gsm_data.h
M include/osmocom/bsc/gsm_data_shared.h
M src/libbsc/chan_alloc.c
M src/libcommon/gsm_data_shared.c
4 files changed, 28 insertions(+), 2 deletions(-)


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

diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 25dee78..9a35ca9 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -177,6 +178,11 @@
 };
 
 enum {
+   BTS_STAT_CHAN_LOAD_AVERAGE,
+   BTS_STAT_T3122,
+};
+
+enum {
BSC_CTR_HANDOVER_ATTEMPTED,
BSC_CTR_HANDOVER_NO_CHANNEL,
BSC_CTR_HANDOVER_TIMEOUT,
diff --git a/include/osmocom/bsc/gsm_data_shared.h 
b/include/osmocom/bsc/gsm_data_shared.h
index 504b42a..8bebd1b 100644
--- a/include/osmocom/bsc/gsm_data_shared.h
+++ b/include/osmocom/bsc/gsm_data_shared.h
@@ -806,6 +806,7 @@
struct pcu_sock_state *pcu_state;
 
struct rate_ctr_group *bts_ctrs;
+   struct osmo_stat_item_group *bts_statg;
 
struct handover_cfg *ho;
 
diff --git a/src/libbsc/chan_alloc.c b/src/libbsc/chan_alloc.c
index 5e2c0ee..500ad59 100644
--- a/src/libbsc/chan_alloc.c
+++ b/src/libbsc/chan_alloc.c
@@ -656,6 +656,8 @@
load = ((used / total) * 100);
LOGP(DRLL, LOGL_DEBUG, "(bts=%d) channel load average is %lu.%.2lu%%\n",
 bts->nr, (load & 0xff00) >> 8, (load & 0xff) / 10);
+   osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_LOAD_AVERAGE],
+  (load & 0xff00) >> 8);
 
/* Calculate new T3122 wait indicator. */
wait_ind = ((used / total) * max_wait_ind);
@@ -667,4 +669,5 @@
 
LOGP(DRLL, LOGL_DEBUG, "(bts=%d) T3122 wait indicator set to %lu 
seconds\n", bts->nr, wait_ind);
bts->T3122 = (uint8_t)wait_ind;
+   osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_T3122], wait_ind);
 }
diff --git a/src/libcommon/gsm_data_shared.c b/src/libcommon/gsm_data_shared.c
index 3afc67e..57bf77d 100644
--- a/src/libcommon/gsm_data_shared.c
+++ b/src/libcommon/gsm_data_shared.c
@@ -30,10 +30,24 @@
 #include 
 #include 
 #include 
-#include 
+#include 
+#include 
 
 #include 
 #include 
+
+static const struct osmo_stat_item_desc bts_stat_desc[] = {
+   { "chanloadavg", "Channel load average.", "%", 16, 0 },
+   { "T3122", "T3122 IMMEDIATE ASSIGNMENT REJECT wait indicator.", "s", 
16, GSM_T3122_DEFAULT },
+};
+
+static const struct osmo_stat_item_group_desc bts_statg_desc = {
+   .group_name_prefix = "bts",
+   .group_description = "base transceiver station",
+   .class_id = OSMO_STATS_CLASS_GLOBAL,
+   .num_items = ARRAY_SIZE(bts_stat_desc),
+   .item_desc = bts_stat_desc,
+};
 
 void gsm_abis_mo_reset(struct gsm_abis_mo *mo)
 {
@@ -353,11 +367,13 @@
talloc_free(bts);
return NULL;
}
+   bts->bts_statg = osmo_stat_item_group_alloc(bts, &bts_statg_desc, 0);
 
/* create our primary TRX */
bts->c0 = gsm_bts_trx_alloc(bts);
if (!bts->c0) {
-   talloc_free(bts->bts_ctrs);
+   rate_ctr_group_free(bts->bts_ctrs);
+   osmo_stat_item_group_free(bts->bts_statg);
talloc_free(bts);
return NULL;
}

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

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


osmo-trx[master]: Fix whitespace

2018-02-05 Thread Vadim Yanitskiy

Patch Set 1: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Icda84caa998614ce6c15d5118f8c5c1568ba9a79
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


[PATCH] osmo-bts[master]: Add 'show (bts|trx|ts|lchan)' commands

2018-02-05 Thread Harald Welte

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

Add 'show (bts|trx|ts|lchan)' commands

This is more or less a 1:1 import from the BSC side commands.  Having
the commands on the BTS side will allow us to expose information that's
not visible to the BSC [in upcoming, separate patches].

Change-Id: I2a596938849a9c84fe6fedcac5d7f71ee97af575
---
M src/common/vty.c
1 file changed, 402 insertions(+), 1 deletion(-)


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

diff --git a/src/common/vty.c b/src/common/vty.c
index 498ab5a..3834580 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -29,6 +29,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -54,6 +55,14 @@
 #include 
 
 #define VTY_STR"Configure the VTY\n"
+
+#define BTS_NR_STR "BTS Number\n"
+#define TRX_NR_STR "TRX Number\n"
+#define TS_NR_STR "Timeslot Number\n"
+#define LCHAN_NR_STR "Logical Channel Number\n"
+#define BTS_TRX_STR BTS_NR_STR TRX_NR_STR
+#define BTS_TRX_TS_STR BTS_TRX_STR TS_NR_STR
+#define BTS_TRX_TS_LCHAN_STR BTS_TRX_TS_STR LCHAN_NR_STR
 
 int g_vty_port_num = OSMO_VTY_PORT_BTS;
 
@@ -784,7 +793,7 @@
 
 DEFUN(show_bts, show_bts_cmd, "show bts <0-255>",
SHOW_STR "Display information about a BTS\n"
-   "BTS number")
+   BTS_NR_STR)
 {
struct gsm_network *net = gsmnet_from_vty(vty);
int bts_nr;
@@ -805,6 +814,394 @@
bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
 
return CMD_SUCCESS;
+}
+
+static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
+{
+   vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
+   trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
+   vty_out(vty, "Description: %s%s",
+   trx->description ? trx->description : "(null)", VTY_NEWLINE);
+   vty_out(vty, "  RF Nominal Power: %d dBm, reduced by %u dB, "
+   "resulting BS power: %d dBm%s",
+   trx->nominal_power, trx->max_power_red,
+   trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
+   vty_out(vty, "  NM State: ");
+   net_dump_nmstate(vty, &trx->mo.nm_state);
+   vty_out(vty, "  RSL State: %s%s", trx->rsl_link? "connected" : 
"disconnected", VTY_NEWLINE);
+   vty_out(vty, "  Baseband Transceiver NM State: ");
+   net_dump_nmstate(vty, &trx->bb_transc.mo.nm_state);
+   vty_out(vty, "  IPA stream ID: 0x%02x%s", trx->rsl_tei, VTY_NEWLINE);
+}
+
+static inline void print_all_trx(struct vty *vty, const struct gsm_bts *bts)
+{
+   uint8_t trx_nr;
+   for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++)
+   trx_dump_vty(vty, gsm_bts_trx_num(bts, trx_nr));
+}
+
+DEFUN(show_trx,
+  show_trx_cmd,
+  "show trx [<0-255>] [<0-255>]",
+   SHOW_STR "Display information about a TRX\n"
+   BTS_TRX_STR)
+{
+   struct gsm_network *net = gsmnet_from_vty(vty);
+   struct gsm_bts *bts = NULL;
+   int bts_nr, trx_nr;
+
+   if (argc >= 1) {
+   /* use the BTS number that the user has specified */
+   bts_nr = atoi(argv[0]);
+   if (bts_nr >= net->num_bts) {
+   vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+   bts = gsm_bts_num(net, bts_nr);
+   }
+   if (argc >= 2) {
+   trx_nr = atoi(argv[1]);
+   if (trx_nr >= bts->num_trx) {
+   vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+   trx_dump_vty(vty, gsm_bts_trx_num(bts, trx_nr));
+   return CMD_SUCCESS;
+   }
+   if (bts) {
+   /* print all TRX in this BTS */
+   print_all_trx(vty, bts);
+   return CMD_SUCCESS;
+   }
+
+   for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
+   print_all_trx(vty, gsm_bts_num(net, bts_nr));
+
+   return CMD_SUCCESS;
+}
+
+
+static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
+{
+   vty_out(vty, "BTS %u, TRX %u, Timeslot %u, phys cfg %s, TSC %u",
+   ts->trx->bts->nr, ts->trx->nr, ts->nr,
+   gsm_pchan_name(ts->pchan), gsm_ts_tsc(ts));
+   if (ts->pchan == GSM_PCHAN_TCH_F_PDCH)
+   vty_out(vty, " (%s mode)",
+   ts->flags & TS_F_PDCH_ACTIVE ? "PDCH" : "TCH/F");
+   vty_out(vty, "%s", VTY_NEWLINE);
+   vty_out(vty, "  NM State: ");
+   net_dump_nmstate(vty, &ts->mo.nm_state);
+}
+
+DEFUN(show_ts,
+  show_ts_cmd,
+  "show timeslot [<0-255>] [<0-255>] [<0-7>]",
+   SHOW_STR "Display information about a TS\n"
+   BTS_TRX_TS_STR)
+{
+   struct gsm_network *net = gsmnet_from_vty(vty);
+   struct gsm_bts *bts = NULL;
+   struct gsm_bts_trx *trx = NULL;
+   struct gsm_bts_trx_ts *ts = NU

[PATCH] osmo-bsc[master]: gsm_data_shared.h: Remove unused sacch_deact member field

2018-02-05 Thread Harald Welte

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

gsm_data_shared.h: Remove unused sacch_deact member field

Change-Id: I806b957b7f6fbbb1206d29ceeccd401c98c26990
---
M include/osmocom/bsc/gsm_data_shared.h
1 file changed, 0 insertions(+), 1 deletion(-)


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

diff --git a/include/osmocom/bsc/gsm_data_shared.h 
b/include/osmocom/bsc/gsm_data_shared.h
index 504b42a..7a650fe 100644
--- a/include/osmocom/bsc/gsm_data_shared.h
+++ b/include/osmocom/bsc/gsm_data_shared.h
@@ -226,7 +226,6 @@
 
/* Established data link layer services */
uint8_t sapis[8];
-   int sacch_deact;
 
struct {
uint32_t bound_ip;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I806b957b7f6fbbb1206d29ceeccd401c98c26990
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmocom-bb[master]: l1ctl_proto.h: define burst indication messages

2018-02-05 Thread Vadim Yanitskiy
Hello Max, Jenkins Builder,

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

https://gerrit.osmocom.org/6237

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

l1ctl_proto.h: define burst indication messages

One burst indication message carries a single raw burst, forwarded
to the higher layers from DSP. The burst bits are hard-bits (0 or 1)
coming from demodulator, packed to 14.5 bytes. This is why we call
them 'raw' - no bit correction nor deciphering is performed.

Related: OS#1672
Change-Id: I75e33c38accdf2a0af961c89836c5e7a3a056bda
---
M include/l1ctl_proto.h
1 file changed, 14 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/37/6237/4

diff --git a/include/l1ctl_proto.h b/include/l1ctl_proto.h
index 37d3d87..1706534 100644
--- a/include/l1ctl_proto.h
+++ b/include/l1ctl_proto.h
@@ -56,6 +56,7 @@
L1CTL_TRAFFIC_REQ,
L1CTL_TRAFFIC_CONF,
L1CTL_TRAFFIC_IND,
+   L1CTL_BURST_IND,
 
/* configure TBF for uplink/downlink */
L1CTL_TBF_CFG_REQ,
@@ -295,6 +296,19 @@
};
 } __attribute__((packed));
 
+#define BI_FLG_DUMMY (1 << 4)
+#define BI_FLG_SACCH (1 << 5)
+
+struct l1ctl_burst_ind {
+   uint32_t frame_nr;
+   uint16_t band_arfcn;/* ARFCN + band + ul indicator   */
+   uint8_t chan_nr;/* GSM 08.58 channel number (9.3.1)  */
+   uint8_t flags;  /* BI_FLG_xxx + burst_id = 2LSBs */
+   uint8_t rx_level;   /* 0 .. 63 in typical GSM notation (dBm+110) */
+   uint8_t snr;/* Reported SNR >> 8 (0-255) */
+   uint8_t bits[15];   /* 114 bits + 2 steal bits. Filled MSB first */
+} __attribute__((packed));
+
 /* a single L1CTL_PM response */
 struct l1ctl_pm_conf {
uint16_t band_arfcn;

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I75e33c38accdf2a0af961c89836c5e7a3a056bda
Gerrit-PatchSet: 4
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: tnt 


osmocom-bb[master]: Import gprsdecode utility from SRLabs

2018-02-05 Thread Vadim Yanitskiy

Patch Set 6: Code-Review+1

At this state it looks much better for me ;)

Changed the code to use libosmocoding and avoid
the code duplication (e.g. CRC, convolutional codes).

Regression tests are passing.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I12234d37c66b83b8abd60f7511fa1d7837db1856
Gerrit-PatchSet: 6
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: fixeria 
Gerrit-HasComments: No


[PATCH] osmo-bts[master]: gsm_lchan: remove unused member fields

2018-02-05 Thread Harald Welte

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

gsm_lchan: remove unused member fields

Change-Id: Icfc601e664ccf33078955e54b02315085cff20a8
---
M include/osmo-bts/gsm_data_shared.h
1 file changed, 0 insertions(+), 2 deletions(-)


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

diff --git a/include/osmo-bts/gsm_data_shared.h 
b/include/osmo-bts/gsm_data_shared.h
index 31198fc..a1ac27a 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -242,11 +242,9 @@
} encr;
 
/* AMR bits */
-   uint8_t mr_ms_lv[7];
uint8_t mr_bts_lv[7];
 
/* Established data link layer services */
-   uint8_t sapis[8];
int sacch_deact;
 
struct {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icfc601e664ccf33078955e54b02315085cff20a8
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmo-bts[master]: Print much more information during 'show lchan'

2018-02-05 Thread Harald Welte

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

Print much more information during 'show lchan'

This adds print-out of remote RTP IP/Port, LAPDm SAPI information,
MS Timing offset, propagation delay, encryption algorithm+state,
loopback status and radio link failure counter to the "show lchan"
command.  It also adds TODO comments fro those bits that are not yet
printed but which would make sense to print.

Change-Id: Ic4bc47638b7b402aee9344dc912745a9929c37f4
---
M include/osmo-bts/gsm_data_shared.h
M src/common/gsm_data_shared.c
M src/common/vty.c
3 files changed, 47 insertions(+), 0 deletions(-)


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

diff --git a/include/osmo-bts/gsm_data_shared.h 
b/include/osmo-bts/gsm_data_shared.h
index a1ac27a..f694114 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -345,6 +345,11 @@
struct msgb *pending_rel_ind_msg;
 };
 
+extern const struct value_string lchan_ciph_state_names[];
+static inline const char *lchan_ciph_state_name(uint8_t state) {
+   return get_value_string(lchan_ciph_state_names, state);
+}
+
 enum {
TS_F_PDCH_ACTIVE =  0x1000,
TS_F_PDCH_ACT_PENDING = 0x2000,
diff --git a/src/common/gsm_data_shared.c b/src/common/gsm_data_shared.c
index 9aa4ba1..1ef223c 100644
--- a/src/common/gsm_data_shared.c
+++ b/src/common/gsm_data_shared.c
@@ -854,3 +854,13 @@
trx->bts->ip_access.bts_id, trx->nr);
return buf;
 }
+
+const struct value_string lchan_ciph_state_names[] = {
+   { LCHAN_CIPH_NONE,  "NONE" },
+   { LCHAN_CIPH_RX_REQ,"RX_REQ" },
+   { LCHAN_CIPH_RX_CONF,   "RX_CONF" },
+   { LCHAN_CIPH_RXTX_REQ,  "RXTX_REQ" },
+   { LCHAN_CIPH_RX_CONF_TX_REQ,"RX_CONF_TX_REQ" },
+   { LCHAN_CIPH_RXTX_CONF, "RXTX_CONF" },
+   { 0, NULL }
+};
diff --git a/src/common/vty.c b/src/common/vty.c
index c54ab89..43311cd 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -1060,6 +1060,38 @@
inet_ntoa(ia), lchan->abis_ip.bound_port,
lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
VTY_NEWLINE);
+   if (lchan->abis_ip.connect_ip) {
+   ia.s_addr = htonl(lchan->abis_ip.connect_ip);
+   vty_out(vty, "  Conn. IP: %s Port %u RTP_TYPE=%u 
SPEECH_MODE=0x%02u%s",
+   inet_ntoa(ia), lchan->abis_ip.connect_port,
+   lchan->abis_ip.rtp_payload, lchan->abis_ip.speech_mode,
+   VTY_NEWLINE);
+   }
+
+#define LAPDM_ESTABLISHED(link, sapi_idx) \
+   (link).datalink[sapi_idx].dl.state == LAPD_STATE_MF_EST
+   vty_out(vty, "  LAPDm SAPIs: DCCH %c%c, SACCH %c%c%s",
+   LAPDM_ESTABLISHED(lchan->lapdm_ch.lapdm_dcch, DL_SAPI0) ? '0' : 
'-',
+   LAPDM_ESTABLISHED(lchan->lapdm_ch.lapdm_dcch, DL_SAPI3) ? '3' : 
'-',
+   LAPDM_ESTABLISHED(lchan->lapdm_ch.lapdm_acch, DL_SAPI0) ? '0' : 
'-',
+   LAPDM_ESTABLISHED(lchan->lapdm_ch.lapdm_acch, DL_SAPI3) ? '3' : 
'-',
+   VTY_NEWLINE);
+#undef LAPDM_ESTABLISHED
+   vty_out(vty, "  Valid System Information: 0x%08x%s",
+   lchan->si.valid, VTY_NEWLINE);
+   /* TODO: L1 SAPI (but those are BTS speific :( */
+   /* TODO: AMR bits */
+   vty_out(vty, "  MS Timing Offset: %d, propagation delay: %d symbols %s",
+   lchan->ms_t_offs, lchan->p_offs, VTY_NEWLINE);
+   if (lchan->encr.alg_id) {
+   vty_out(vty, "  Ciphering A5/%u State: %s, N(S)=%u%s",
+   lchan->encr.alg_id-1, 
lchan_ciph_state_name(lchan->ciph_state),
+   lchan->ciph_ns, VTY_NEWLINE);
+   }
+   if (lchan->loopback)
+   vty_out(vty, "  RTP/PDCH Loopback Enabled%s", VTY_NEWLINE);
+   vty_out(vty, "  Radio Link Failure Counter 'S': %d%s", lchan->s, 
VTY_NEWLINE);
+   /* TODO: MS Power Control */
 }
 
 static void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic4bc47638b7b402aee9344dc912745a9929c37f4
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmo-bts[master]: Add 'show (bts|trx|ts|lchan)' commands

2018-02-05 Thread Harald Welte
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/6278

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

Add 'show (bts|trx|ts|lchan)' commands

This is more or less a 1:1 import from the BSC side commands.  Having
the commands on the BTS side will allow us to expose information that's
not visible to the BSC [in upcoming, separate patches].

Change-Id: I2a596938849a9c84fe6fedcac5d7f71ee97af575
---
M src/common/vty.c
1 file changed, 402 insertions(+), 1 deletion(-)


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

diff --git a/src/common/vty.c b/src/common/vty.c
index 498ab5a..c54ab89 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -29,6 +29,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -54,6 +55,14 @@
 #include 
 
 #define VTY_STR"Configure the VTY\n"
+
+#define BTS_NR_STR "BTS Number\n"
+#define TRX_NR_STR "TRX Number\n"
+#define TS_NR_STR "Timeslot Number\n"
+#define LCHAN_NR_STR "Logical Channel Number\n"
+#define BTS_TRX_STR BTS_NR_STR TRX_NR_STR
+#define BTS_TRX_TS_STR BTS_TRX_STR TS_NR_STR
+#define BTS_TRX_TS_LCHAN_STR BTS_TRX_TS_STR LCHAN_NR_STR
 
 int g_vty_port_num = OSMO_VTY_PORT_BTS;
 
@@ -784,7 +793,7 @@
 
 DEFUN(show_bts, show_bts_cmd, "show bts <0-255>",
SHOW_STR "Display information about a BTS\n"
-   "BTS number")
+   BTS_NR_STR)
 {
struct gsm_network *net = gsmnet_from_vty(vty);
int bts_nr;
@@ -805,6 +814,394 @@
bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
 
return CMD_SUCCESS;
+}
+
+static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
+{
+   vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
+   trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
+   vty_out(vty, "Description: %s%s",
+   trx->description ? trx->description : "(null)", VTY_NEWLINE);
+   vty_out(vty, "  RF Nominal Power: %d dBm, reduced by %u dB, "
+   "resulting BS power: %d dBm%s",
+   trx->nominal_power, trx->max_power_red,
+   trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
+   vty_out(vty, "  NM State: ");
+   net_dump_nmstate(vty, &trx->mo.nm_state);
+   vty_out(vty, "  RSL State: %s%s", trx->rsl_link? "connected" : 
"disconnected", VTY_NEWLINE);
+   vty_out(vty, "  Baseband Transceiver NM State: ");
+   net_dump_nmstate(vty, &trx->bb_transc.mo.nm_state);
+   vty_out(vty, "  IPA stream ID: 0x%02x%s", trx->rsl_tei, VTY_NEWLINE);
+}
+
+static inline void print_all_trx(struct vty *vty, const struct gsm_bts *bts)
+{
+   uint8_t trx_nr;
+   for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++)
+   trx_dump_vty(vty, gsm_bts_trx_num(bts, trx_nr));
+}
+
+DEFUN(show_trx,
+  show_trx_cmd,
+  "show trx [<0-255>] [<0-255>]",
+   SHOW_STR "Display information about a TRX\n"
+   BTS_TRX_STR)
+{
+   struct gsm_network *net = gsmnet_from_vty(vty);
+   struct gsm_bts *bts = NULL;
+   int bts_nr, trx_nr;
+
+   if (argc >= 1) {
+   /* use the BTS number that the user has specified */
+   bts_nr = atoi(argv[0]);
+   if (bts_nr >= net->num_bts) {
+   vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+   bts = gsm_bts_num(net, bts_nr);
+   }
+   if (argc >= 2) {
+   trx_nr = atoi(argv[1]);
+   if (trx_nr >= bts->num_trx) {
+   vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+   trx_dump_vty(vty, gsm_bts_trx_num(bts, trx_nr));
+   return CMD_SUCCESS;
+   }
+   if (bts) {
+   /* print all TRX in this BTS */
+   print_all_trx(vty, bts);
+   return CMD_SUCCESS;
+   }
+
+   for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
+   print_all_trx(vty, gsm_bts_num(net, bts_nr));
+
+   return CMD_SUCCESS;
+}
+
+
+static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
+{
+   vty_out(vty, "BTS %u, TRX %u, Timeslot %u, phys cfg %s, TSC %u",
+   ts->trx->bts->nr, ts->trx->nr, ts->nr,
+   gsm_pchan_name(ts->pchan), gsm_ts_tsc(ts));
+   if (ts->pchan == GSM_PCHAN_TCH_F_PDCH)
+   vty_out(vty, " (%s mode)",
+   ts->flags & TS_F_PDCH_ACTIVE ? "PDCH" : "TCH/F");
+   vty_out(vty, "%s", VTY_NEWLINE);
+   vty_out(vty, "  NM State: ");
+   net_dump_nmstate(vty, &ts->mo.nm_state);
+}
+
+DEFUN(show_ts,
+  show_ts_cmd,
+  "show timeslot [<0-255>] [<0-255>] [<0-7>]",
+   SHOW_STR "Display information about a TS\n"
+   BTS_TRX_TS_STR)
+{
+   struct gsm_network *net = gsmnet_from_vty(vty);
+   str

[PATCH] osmo-bts[master]: vty: don't print "Bound IP / Port" if it isn't bound [yet]

2018-02-05 Thread Harald Welte

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

vty: don't print "Bound IP / Port" if it isn't bound [yet]

Change-Id: I28705b56582d334d568d98a371daa6bb9ef1f625
---
M src/common/vty.c
1 file changed, 7 insertions(+), 5 deletions(-)


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

diff --git a/src/common/vty.c b/src/common/vty.c
index 43311cd..066f03d 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -1055,11 +1055,13 @@
get_value_string(gsm48_cmode_names, lchan->tch_mode),
VTY_NEWLINE);
 
-   ia.s_addr = htonl(lchan->abis_ip.bound_ip);
-   vty_out(vty, "  Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
-   inet_ntoa(ia), lchan->abis_ip.bound_port,
-   lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
-   VTY_NEWLINE);
+   if (lchan->abis_ip.bound_ip) {
+   ia.s_addr = htonl(lchan->abis_ip.bound_ip);
+   vty_out(vty, "  Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
+   inet_ntoa(ia), lchan->abis_ip.bound_port,
+   lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
+   VTY_NEWLINE);
+   }
if (lchan->abis_ip.connect_ip) {
ia.s_addr = htonl(lchan->abis_ip.connect_ip);
vty_out(vty, "  Conn. IP: %s Port %u RTP_TYPE=%u 
SPEECH_MODE=0x%02u%s",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I28705b56582d334d568d98a371daa6bb9ef1f625
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[MERGED] osmo-bsc[master]: gsm_data_shared.h: Remove unused sacch_deact member field

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: gsm_data_shared.h: Remove unused sacch_deact member field
..


gsm_data_shared.h: Remove unused sacch_deact member field

Change-Id: I806b957b7f6fbbb1206d29ceeccd401c98c26990
---
M include/osmocom/bsc/gsm_data_shared.h
1 file changed, 0 insertions(+), 1 deletion(-)

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



diff --git a/include/osmocom/bsc/gsm_data_shared.h 
b/include/osmocom/bsc/gsm_data_shared.h
index 504b42a..7a650fe 100644
--- a/include/osmocom/bsc/gsm_data_shared.h
+++ b/include/osmocom/bsc/gsm_data_shared.h
@@ -226,7 +226,6 @@
 
/* Established data link layer services */
uint8_t sapis[8];
-   int sacch_deact;
 
struct {
uint32_t bound_ip;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I806b957b7f6fbbb1206d29ceeccd401c98c26990
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmo-bsc[master]: gsm_data_shared.h: Remove unused sacch_deact member field

2018-02-05 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


osmo-bts[master]: gsm_lchan: remove unused member fields

2018-02-05 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Icfc601e664ccf33078955e54b02315085cff20a8
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-HasComments: No


osmo-bts[master]: Add 'show (bts|trx|ts|lchan)' commands

2018-02-05 Thread Harald Welte

Patch Set 2: Code-Review+2

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

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


osmo-bts[master]: Print much more information during 'show lchan'

2018-02-05 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ic4bc47638b7b402aee9344dc912745a9929c37f4
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-HasComments: No


osmo-bts[master]: vty: don't print "Bound IP / Port" if it isn't bound [yet]

2018-02-05 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I28705b56582d334d568d98a371daa6bb9ef1f625
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-HasComments: No


[PATCH] osmo-bsc[master]: vty: print RTP IP of lchan if actually bound; print remote (...

2018-02-05 Thread Harald Welte

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

vty: print RTP IP of lchan if actually bound; print remote (mgw) IP

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


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

diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index 2246349..3da4745 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -1164,11 +1164,21 @@
vty_out(vty, "  No Subscriber%s", VTY_NEWLINE);
if (is_ipaccess_bts(lchan->ts->trx->bts)) {
struct in_addr ia;
-   ia.s_addr = htonl(lchan->abis_ip.bound_ip);
-   vty_out(vty, "  Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
-   inet_ntoa(ia), lchan->abis_ip.bound_port,
-   lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
-   VTY_NEWLINE);
+   if (lchan->abis_ip.bound_ip) {
+   ia.s_addr = htonl(lchan->abis_ip.bound_ip);
+   vty_out(vty, "  Bound IP: %s Port %u RTP_TYPE2=%u 
CONN_ID=%u%s",
+   inet_ntoa(ia), lchan->abis_ip.bound_port,
+   lchan->abis_ip.rtp_payload2, 
lchan->abis_ip.conn_id,
+   VTY_NEWLINE);
+   }
+   if (lchan->abis_ip.connect_ip) {
+   ia.s_addr = htonl(lchan->abis_ip.connect_ip);
+   vty_out(vty, "  Conn. IP: %s Port %u RTP_TYPE=%u 
SPEECH_MODE=0x%02x%s",
+   inet_ntoa(ia), lchan->abis_ip.connect_port,
+   lchan->abis_ip.rtp_payload, 
lchan->abis_ip.speech_mode,
+   VTY_NEWLINE);
+   }
+
}
 
/* we want to report the last measurement report */

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I87840aa0f5b9c04d7736bf5f649142219853711a
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


osmocom-bb[master]: Import gprsdecode utility from SRLabs

2018-02-05 Thread Max

Patch Set 6:

Seems like 'authors' file was lost during update, as well as 'copying' and 
'news'. Unless it's intentional of course.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I12234d37c66b83b8abd60f7511fa1d7837db1856
Gerrit-PatchSet: 6
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: fixeria 
Gerrit-HasComments: No


osmo-msc[master]: a_iface: correct data type for a.conn_id in gsm_subscriber_c...

2018-02-05 Thread Max

Patch Set 1: Code-Review+1

Would be nice to add some spec. reference explaining why it's uint32.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ibf14d7c9a547c4eeb873975e7dcddef223e7df46
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-HasComments: No


[MERGED] osmo-bts[master]: gsm_lchan: remove unused member fields

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: gsm_lchan: remove unused member fields
..


gsm_lchan: remove unused member fields

Change-Id: Icfc601e664ccf33078955e54b02315085cff20a8
---
M include/osmo-bts/gsm_data_shared.h
1 file changed, 0 insertions(+), 2 deletions(-)

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



diff --git a/include/osmo-bts/gsm_data_shared.h 
b/include/osmo-bts/gsm_data_shared.h
index 31198fc..a1ac27a 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -242,11 +242,9 @@
} encr;
 
/* AMR bits */
-   uint8_t mr_ms_lv[7];
uint8_t mr_bts_lv[7];
 
/* Established data link layer services */
-   uint8_t sapis[8];
int sacch_deact;
 
struct {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Icfc601e664ccf33078955e54b02315085cff20a8
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-bts[master]: Add 'show (bts|trx|ts|lchan)' commands

2018-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Add 'show (bts|trx|ts|lchan)' commands
..


Add 'show (bts|trx|ts|lchan)' commands

This is more or less a 1:1 import from the BSC side commands.  Having
the commands on the BTS side will allow us to expose information that's
not visible to the BSC [in upcoming, separate patches].

Change-Id: I2a596938849a9c84fe6fedcac5d7f71ee97af575
---
M src/common/vty.c
1 file changed, 402 insertions(+), 1 deletion(-)

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



diff --git a/src/common/vty.c b/src/common/vty.c
index 498ab5a..c54ab89 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -29,6 +29,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -54,6 +55,14 @@
 #include 
 
 #define VTY_STR"Configure the VTY\n"
+
+#define BTS_NR_STR "BTS Number\n"
+#define TRX_NR_STR "TRX Number\n"
+#define TS_NR_STR "Timeslot Number\n"
+#define LCHAN_NR_STR "Logical Channel Number\n"
+#define BTS_TRX_STR BTS_NR_STR TRX_NR_STR
+#define BTS_TRX_TS_STR BTS_TRX_STR TS_NR_STR
+#define BTS_TRX_TS_LCHAN_STR BTS_TRX_TS_STR LCHAN_NR_STR
 
 int g_vty_port_num = OSMO_VTY_PORT_BTS;
 
@@ -784,7 +793,7 @@
 
 DEFUN(show_bts, show_bts_cmd, "show bts <0-255>",
SHOW_STR "Display information about a BTS\n"
-   "BTS number")
+   BTS_NR_STR)
 {
struct gsm_network *net = gsmnet_from_vty(vty);
int bts_nr;
@@ -805,6 +814,394 @@
bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
 
return CMD_SUCCESS;
+}
+
+static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
+{
+   vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
+   trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
+   vty_out(vty, "Description: %s%s",
+   trx->description ? trx->description : "(null)", VTY_NEWLINE);
+   vty_out(vty, "  RF Nominal Power: %d dBm, reduced by %u dB, "
+   "resulting BS power: %d dBm%s",
+   trx->nominal_power, trx->max_power_red,
+   trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
+   vty_out(vty, "  NM State: ");
+   net_dump_nmstate(vty, &trx->mo.nm_state);
+   vty_out(vty, "  RSL State: %s%s", trx->rsl_link? "connected" : 
"disconnected", VTY_NEWLINE);
+   vty_out(vty, "  Baseband Transceiver NM State: ");
+   net_dump_nmstate(vty, &trx->bb_transc.mo.nm_state);
+   vty_out(vty, "  IPA stream ID: 0x%02x%s", trx->rsl_tei, VTY_NEWLINE);
+}
+
+static inline void print_all_trx(struct vty *vty, const struct gsm_bts *bts)
+{
+   uint8_t trx_nr;
+   for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++)
+   trx_dump_vty(vty, gsm_bts_trx_num(bts, trx_nr));
+}
+
+DEFUN(show_trx,
+  show_trx_cmd,
+  "show trx [<0-255>] [<0-255>]",
+   SHOW_STR "Display information about a TRX\n"
+   BTS_TRX_STR)
+{
+   struct gsm_network *net = gsmnet_from_vty(vty);
+   struct gsm_bts *bts = NULL;
+   int bts_nr, trx_nr;
+
+   if (argc >= 1) {
+   /* use the BTS number that the user has specified */
+   bts_nr = atoi(argv[0]);
+   if (bts_nr >= net->num_bts) {
+   vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+   bts = gsm_bts_num(net, bts_nr);
+   }
+   if (argc >= 2) {
+   trx_nr = atoi(argv[1]);
+   if (trx_nr >= bts->num_trx) {
+   vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+   trx_dump_vty(vty, gsm_bts_trx_num(bts, trx_nr));
+   return CMD_SUCCESS;
+   }
+   if (bts) {
+   /* print all TRX in this BTS */
+   print_all_trx(vty, bts);
+   return CMD_SUCCESS;
+   }
+
+   for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
+   print_all_trx(vty, gsm_bts_num(net, bts_nr));
+
+   return CMD_SUCCESS;
+}
+
+
+static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
+{
+   vty_out(vty, "BTS %u, TRX %u, Timeslot %u, phys cfg %s, TSC %u",
+   ts->trx->bts->nr, ts->trx->nr, ts->nr,
+   gsm_pchan_name(ts->pchan), gsm_ts_tsc(ts));
+   if (ts->pchan == GSM_PCHAN_TCH_F_PDCH)
+   vty_out(vty, " (%s mode)",
+   ts->flags & TS_F_PDCH_ACTIVE ? "PDCH" : "TCH/F");
+   vty_out(vty, "%s", VTY_NEWLINE);
+   vty_out(vty, "  NM State: ");
+   net_dump_nmstate(vty, &ts->mo.nm_state);
+}
+
+DEFUN(show_ts,
+  show_ts_cmd,
+  "show timeslot [<0-255>] [<0-255>] [<0-7>]",
+   SHOW_STR "Display information about a TS\n"
+   BTS_TRX_TS_STR)
+{
+   struct gsm_

[PATCH] osmo-bts[master]: Print much more information during 'show lchan'

2018-02-05 Thread Harald Welte
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/6281

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

Print much more information during 'show lchan'

This adds printing of remote RTP IP/Port, LAPDm SAPI information,
MS Timing offset, propagation delay, encryption algorithm+state,
loopback status and radio link failure counter to the "show lchan"
command.  It also adds TODO comments fro those bits that are not yet
printed but which would make sense to print.

Change-Id: Ic4bc47638b7b402aee9344dc912745a9929c37f4
---
M include/osmo-bts/gsm_data_shared.h
M src/common/gsm_data_shared.c
M src/common/vty.c
3 files changed, 47 insertions(+), 0 deletions(-)


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

diff --git a/include/osmo-bts/gsm_data_shared.h 
b/include/osmo-bts/gsm_data_shared.h
index a1ac27a..f694114 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -345,6 +345,11 @@
struct msgb *pending_rel_ind_msg;
 };
 
+extern const struct value_string lchan_ciph_state_names[];
+static inline const char *lchan_ciph_state_name(uint8_t state) {
+   return get_value_string(lchan_ciph_state_names, state);
+}
+
 enum {
TS_F_PDCH_ACTIVE =  0x1000,
TS_F_PDCH_ACT_PENDING = 0x2000,
diff --git a/src/common/gsm_data_shared.c b/src/common/gsm_data_shared.c
index 9aa4ba1..1ef223c 100644
--- a/src/common/gsm_data_shared.c
+++ b/src/common/gsm_data_shared.c
@@ -854,3 +854,13 @@
trx->bts->ip_access.bts_id, trx->nr);
return buf;
 }
+
+const struct value_string lchan_ciph_state_names[] = {
+   { LCHAN_CIPH_NONE,  "NONE" },
+   { LCHAN_CIPH_RX_REQ,"RX_REQ" },
+   { LCHAN_CIPH_RX_CONF,   "RX_CONF" },
+   { LCHAN_CIPH_RXTX_REQ,  "RXTX_REQ" },
+   { LCHAN_CIPH_RX_CONF_TX_REQ,"RX_CONF_TX_REQ" },
+   { LCHAN_CIPH_RXTX_CONF, "RXTX_CONF" },
+   { 0, NULL }
+};
diff --git a/src/common/vty.c b/src/common/vty.c
index c54ab89..43311cd 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -1060,6 +1060,38 @@
inet_ntoa(ia), lchan->abis_ip.bound_port,
lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
VTY_NEWLINE);
+   if (lchan->abis_ip.connect_ip) {
+   ia.s_addr = htonl(lchan->abis_ip.connect_ip);
+   vty_out(vty, "  Conn. IP: %s Port %u RTP_TYPE=%u 
SPEECH_MODE=0x%02u%s",
+   inet_ntoa(ia), lchan->abis_ip.connect_port,
+   lchan->abis_ip.rtp_payload, lchan->abis_ip.speech_mode,
+   VTY_NEWLINE);
+   }
+
+#define LAPDM_ESTABLISHED(link, sapi_idx) \
+   (link).datalink[sapi_idx].dl.state == LAPD_STATE_MF_EST
+   vty_out(vty, "  LAPDm SAPIs: DCCH %c%c, SACCH %c%c%s",
+   LAPDM_ESTABLISHED(lchan->lapdm_ch.lapdm_dcch, DL_SAPI0) ? '0' : 
'-',
+   LAPDM_ESTABLISHED(lchan->lapdm_ch.lapdm_dcch, DL_SAPI3) ? '3' : 
'-',
+   LAPDM_ESTABLISHED(lchan->lapdm_ch.lapdm_acch, DL_SAPI0) ? '0' : 
'-',
+   LAPDM_ESTABLISHED(lchan->lapdm_ch.lapdm_acch, DL_SAPI3) ? '3' : 
'-',
+   VTY_NEWLINE);
+#undef LAPDM_ESTABLISHED
+   vty_out(vty, "  Valid System Information: 0x%08x%s",
+   lchan->si.valid, VTY_NEWLINE);
+   /* TODO: L1 SAPI (but those are BTS speific :( */
+   /* TODO: AMR bits */
+   vty_out(vty, "  MS Timing Offset: %d, propagation delay: %d symbols %s",
+   lchan->ms_t_offs, lchan->p_offs, VTY_NEWLINE);
+   if (lchan->encr.alg_id) {
+   vty_out(vty, "  Ciphering A5/%u State: %s, N(S)=%u%s",
+   lchan->encr.alg_id-1, 
lchan_ciph_state_name(lchan->ciph_state),
+   lchan->ciph_ns, VTY_NEWLINE);
+   }
+   if (lchan->loopback)
+   vty_out(vty, "  RTP/PDCH Loopback Enabled%s", VTY_NEWLINE);
+   vty_out(vty, "  Radio Link Failure Counter 'S': %d%s", lchan->s, 
VTY_NEWLINE);
+   /* TODO: MS Power Control */
 }
 
 static void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ic4bc47638b7b402aee9344dc912745a9929c37f4
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bts[master]: vty: don't print "Bound IP / Port" if it isn't bound [yet]

2018-02-05 Thread Harald Welte
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/6282

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

vty: don't print "Bound IP / Port" if it isn't bound [yet]

Change-Id: I28705b56582d334d568d98a371daa6bb9ef1f625
---
M src/common/vty.c
1 file changed, 7 insertions(+), 5 deletions(-)


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

diff --git a/src/common/vty.c b/src/common/vty.c
index 43311cd..066f03d 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -1055,11 +1055,13 @@
get_value_string(gsm48_cmode_names, lchan->tch_mode),
VTY_NEWLINE);
 
-   ia.s_addr = htonl(lchan->abis_ip.bound_ip);
-   vty_out(vty, "  Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
-   inet_ntoa(ia), lchan->abis_ip.bound_port,
-   lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
-   VTY_NEWLINE);
+   if (lchan->abis_ip.bound_ip) {
+   ia.s_addr = htonl(lchan->abis_ip.bound_ip);
+   vty_out(vty, "  Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
+   inet_ntoa(ia), lchan->abis_ip.bound_port,
+   lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
+   VTY_NEWLINE);
+   }
if (lchan->abis_ip.connect_ip) {
ia.s_addr = htonl(lchan->abis_ip.connect_ip);
vty_out(vty, "  Conn. IP: %s Port %u RTP_TYPE=%u 
SPEECH_MODE=0x%02u%s",

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I28705b56582d334d568d98a371daa6bb9ef1f625
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


  1   2   >