Change in osmo-mgw[master]: create_response_with_sdp: Fix inclusion of X-Osmux

2019-04-25 Thread Pau Espin Pedrol
Pau Espin Pedrol has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13775 )

Change subject: create_response_with_sdp: Fix inclusion of X-Osmux
..

create_response_with_sdp: Fix inclusion of X-Osmux

In previous code, 2 blocks were handling osmux inclusion one after the
other under same osmux.state. However, first block changes osmux.state
so second block can never be true and X-Osmux is never added.

Change-Id: Iceee8b64978651f1fe6bb883923561b081f73d9b
---
M src/libosmo-mgcp/mgcp_protocol.c
1 file changed, 2 insertions(+), 9 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 be161ad..bfb88bc 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -304,7 +304,6 @@
struct msgb *sdp;
int rc;
struct msgb *result;
-   char osmux_extension[strlen("X-Osmux: 255") + 1];
char local_ip_addr[INET_ADDRSTRLEN];

sdp = msgb_alloc_headroom(4096, 128, "sdp record");
@@ -316,13 +315,6 @@
addr = local_ip_addr;
}

-   if (conn->osmux.state == OSMUX_STATE_NEGOTIATING) {
-   sprintf(osmux_extension, "X-Osmux: %u", conn->osmux.cid);
-   conn->osmux.state = OSMUX_STATE_ACTIVATING;
-   } else {
-   osmux_extension[0] = '\0';
-   }
-
/* Attach optional connection parameters */
if (add_conn_params) {
rc = add_params(sdp, endp, conn);
@@ -332,9 +324,10 @@

/* Attach optional OSMUX parameters */
if (conn->osmux.state == OSMUX_STATE_NEGOTIATING) {
-   rc = msgb_printf(sdp, "%s\r\n", osmux_extension);
+   rc = msgb_printf(sdp, "X-Osmux: %u\r\n", conn->osmux.cid);
if (rc < 0)
goto error;
+   conn->osmux.state = OSMUX_STATE_ACTIVATING;
}

/* Attach line break to separate the parameters from the SDP block */

--
To view, visit https://gerrit.osmocom.org/13775
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iceee8b64978651f1fe6bb883923561b081f73d9b
Gerrit-Change-Number: 13775
Gerrit-PatchSet: 2
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 


Change in osmo-mgw[master]: osmux: Cleanup of CID alloc pool APIs

2019-04-25 Thread Pau Espin Pedrol
Pau Espin Pedrol has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13774 )

Change subject: osmux: Cleanup of CID alloc pool APIs
..

osmux: Cleanup of CID alloc pool APIs

* Cleanup naming to make it far more clear
* Drop 2 variables holding CID values (allocated_cid, cid), in favour of
1 value holdinf the value and one bool stating whether the value is
used.
* Change conn_osmux_allocate_cid to allow allocating either next
available CID or a specific one, in preparation for forthcoming patches.

This commit can be merged straight away because anyway osmux cannot be
enabled in current status (blocked by vty config) and
(conn_)osmux_allocate_cid was/is not called anywhere. However, it helps
improving code base for future re-introduction of Osmux as it is
envisioned.

Change-Id: I737a248ac6c74add8e917fe2e2f36779d0f1d685
---
M include/osmocom/mgcp/mgcp_internal.h
M include/osmocom/mgcp/osmux.h
M src/libosmo-mgcp/mgcp_conn.c
M src/libosmo-mgcp/mgcp_osmux.c
M src/libosmo-mgcp/mgcp_vty.c
M tests/mgcp/mgcp_test.c
6 files changed, 80 insertions(+), 39 deletions(-)

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



diff --git a/include/osmocom/mgcp/mgcp_internal.h 
b/include/osmocom/mgcp/mgcp_internal.h
index 3defc4c..24e28b4 100644
--- a/include/osmocom/mgcp/mgcp_internal.h
+++ b/include/osmocom/mgcp/mgcp_internal.h
@@ -188,9 +188,9 @@
struct {
/* Osmux state: disabled, activating, active */
enum osmux_state state;
-   /* Allocated Osmux circuit ID for this endpoint */
-   int allocated_cid;
-   /* Used Osmux circuit ID for this endpoint */
+   /* Is cid holding valid data? is it allocated from pool? */
+   bool cid_allocated;
+   /* Allocated Osmux circuit ID for this conn */
uint8_t cid;
/* handle to batch messages */
struct osmux_in_handle *in;
diff --git a/include/osmocom/mgcp/osmux.h b/include/osmocom/mgcp/osmux.h
index 685be9c..c080c85 100644
--- a/include/osmocom/mgcp/osmux.h
+++ b/include/osmocom/mgcp/osmux.h
@@ -15,13 +15,16 @@
 int osmux_enable_conn(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn,
  struct in_addr *addr, uint16_t port);
 void osmux_disable_conn(struct mgcp_conn_rtp *conn);
-void osmux_allocate_cid(struct mgcp_conn_rtp *conn);
-void osmux_release_cid(struct mgcp_conn_rtp *conn);
+int conn_osmux_allocate_cid(struct mgcp_conn_rtp *conn, int osmux_cid);
+void conn_osmux_release_cid(struct mgcp_conn_rtp *conn);
 int osmux_xfrm_to_osmux(char *buf, int buf_len, struct mgcp_conn_rtp *conn);
 int osmux_send_dummy(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn);
-int osmux_get_cid(void);
-void osmux_put_cid(uint8_t osmux_cid);
-int osmux_used_cid(void);
+
+void osmux_cid_pool_get(uint8_t osmux_cid);
+int osmux_cid_pool_get_next(void);
+void osmux_cid_pool_put(uint8_t osmux_cid);
+bool osmux_cid_pool_allocated(uint8_t osmux_cid);
+int osmux_cid_pool_count_used(void);

 enum osmux_state {
OSMUX_STATE_DISABLED = 0, /* Osmux not being currently used by endp */
diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c
index bfaa111..af5426f 100644
--- a/src/libosmo-mgcp/mgcp_conn.c
+++ b/src/libosmo-mgcp/mgcp_conn.c
@@ -90,7 +90,8 @@
static unsigned int rate_ctr_index = 0;

conn_rtp->type = MGCP_RTP_DEFAULT;
-   conn_rtp->osmux.allocated_cid = -1;
+   conn_rtp->osmux.cid_allocated = false;
+   conn_rtp->osmux.cid = 0;

/* backpointer to the generic part of the connection */
conn->u.rtp.conn = conn;
@@ -120,7 +121,6 @@
 static void mgcp_rtp_conn_cleanup(struct mgcp_conn_rtp *conn_rtp)
 {
osmux_disable_conn(conn_rtp);
-   osmux_release_cid(conn_rtp);
mgcp_free_rtp_port(_rtp->end);
rate_ctr_group_free(conn_rtp->rate_ctr_group);
 }
diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c
index a2c138d..3bd765e 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -614,31 +614,46 @@

osmux_xfrm_input_close_circuit(conn->osmux.in, conn->osmux.cid);
conn->osmux.state = OSMUX_STATE_DISABLED;
-   conn->osmux.cid = -1;
+   conn_osmux_release_cid(conn);
osmux_handle_put(conn->osmux.in);
 }

 /*! relase OSXMUX cid, that had been allocated to this connection.
  *  \param[in] conn connection with OSMUX cid to release */
-void osmux_release_cid(struct mgcp_conn_rtp *conn)
+void conn_osmux_release_cid(struct mgcp_conn_rtp *conn)
 {
-   if (!conn)
-   return;
-
-   if (conn->osmux.state != OSMUX_STATE_ENABLED)
-   return;
-
-   if (conn->osmux.allocated_cid >= 0)
-   osmux_put_cid(conn->osmux.allocated_cid);
-   conn->osmux.allocated_cid = -1;
+   if 

Change in osmo-trx[master]: lms: Log underrun/overrun events

2019-04-25 Thread Pau Espin Pedrol
Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/13786


Change subject: lms: Log underrun/overrun events
..

lms: Log underrun/overrun events

Change-Id: I8c6b1d3e8515153e5d4079cc6620901ef8ce2449
---
M Transceiver52M/device/lms/LMSDevice.cpp
1 file changed, 10 insertions(+), 2 deletions(-)



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

diff --git a/Transceiver52M/device/lms/LMSDevice.cpp 
b/Transceiver52M/device/lms/LMSDevice.cpp
index 0cd41d3..d0c8e19 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -573,12 +573,20 @@
 {
lms_stream_status_t status;
if (LMS_GetStreamStatus(_lms_stream_rx[chan], ) == 0) {
-   if (status.underrun > m_last_rx_underruns[chan])
+   if (status.underrun > m_last_rx_underruns[chan]) {
*underrun = true;
+   LOGC(DDEV, ERROR) << "chan " << chan << ": recv 
Underrun! ("
+ << m_last_rx_underruns[chan] << " -> "
+ << status.underrun << ")";
+   }
m_last_rx_underruns[chan] = status.underrun;

-   if (status.overrun > m_last_rx_overruns[chan])
+   if (status.overrun > m_last_rx_overruns[chan]) {
*overrun = true;
+   LOGC(DDEV, ERROR) << "chan " << chan << ": recv 
Overrun! ("
+ << m_last_rx_overruns[chan] << " -> "
+ << status.overrun << ")";
+   }
m_last_rx_overruns[chan] = status.overrun;
}
 }

--
To view, visit https://gerrit.osmocom.org/13786
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8c6b1d3e8515153e5d4079cc6620901ef8ce2449
Gerrit-Change-Number: 13786
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 


Change in osmo-trx[master]: cosmetic: Threads.h: Remove trailing whitespace

2019-04-25 Thread Pau Espin Pedrol
Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/13784


Change subject: cosmetic: Threads.h: Remove trailing whitespace
..

cosmetic: Threads.h: Remove trailing whitespace

Change-Id: I0ae6e435a7f0480c3eaa08dccfe824456f33b015
---
M CommonLibs/Threads.h
1 file changed, 2 insertions(+), 2 deletions(-)



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

diff --git a/CommonLibs/Threads.h b/CommonLibs/Threads.h
index 857c5d9..3b76985 100644
--- a/CommonLibs/Threads.h
+++ b/CommonLibs/Threads.h
@@ -55,7 +55,7 @@
 #define OBJDCOUT(text) {}
 #else
 #define DCOUT(text) { COUT(__FILE__ << ":" << __LINE__ << " " << text); }
-#define OBJDCOUT(text) { DCOUT(this << " " << text); }
+#define OBJDCOUT(text) { DCOUT(this << " " << text); }
 #endif
 //@}
 //@}
@@ -152,7 +152,7 @@
pthread_attr_t mAttrib;
// FIXME -- Can this be reduced now?
size_t mStackSize;
-
+

public:


--
To view, visit https://gerrit.osmocom.org/13784
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0ae6e435a7f0480c3eaa08dccfe824456f33b015
Gerrit-Change-Number: 13784
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 


Change in osmo-trx[master]: lms: flush_recv: alloc buf on stack instead of heap

2019-04-25 Thread Pau Espin Pedrol
Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/13782


Change subject: lms: flush_recv: alloc buf on stack instead of heap
..

lms: flush_recv: alloc buf on stack instead of heap

No need to use the heap here since buffer is only used as a temporary
trash. Using the stack is quicker.

Change-Id: Iede8dc0903ee3865a52c8e2fd811bcde444fee33
---
M Transceiver52M/device/lms/LMSDevice.cpp
1 file changed, 1 insertion(+), 3 deletions(-)



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

diff --git a/Transceiver52M/device/lms/LMSDevice.cpp 
b/Transceiver52M/device/lms/LMSDevice.cpp
index 05904e8..064d742 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -450,7 +450,7 @@
 {
#define CHUNK 625
int len = CHUNK * tx_sps;
-   short *buffer = new short[len * 2];
+   short *buffer = (short*) alloca(sizeof(short) * len * 2);
int rc;
lms_stream_meta_t rx_metadata = {};
rx_metadata.flushPartialPacket = false;
@@ -463,7 +463,6 @@
LOGC(DDEV, DEBUG) << "Flush: Recv buffer of len " << rc << " at 
" << std::hex << rx_metadata.timestamp;
if (rc != len) {
LOGC(DDEV, ALERT) << "LMS: Device receive timed out";
-   delete[] buffer;
return false;
}

@@ -471,7 +470,6 @@
}

LOGC(DDEV, INFO) << "Initial timestamp " << ts_initial << std::endl;
-   delete[] buffer;
return true;
 }


--
To view, visit https://gerrit.osmocom.org/13782
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iede8dc0903ee3865a52c8e2fd811bcde444fee33
Gerrit-Change-Number: 13782
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 


Change in osmo-trx[master]: Move duplicated thread_enable_cancel to CommonLibs

2019-04-25 Thread Pau Espin Pedrol
Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/13785


Change subject: Move duplicated thread_enable_cancel to CommonLibs
..

Move duplicated thread_enable_cancel to CommonLibs

Change-Id: I1a479b59bdda01233273dfa919bd678edbe34708
---
M CommonLibs/Threads.cpp
M CommonLibs/Threads.h
M Transceiver52M/device/lms/LMSDevice.cpp
M Transceiver52M/device/uhd/UHDDevice.cpp
4 files changed, 7 insertions(+), 12 deletions(-)



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

diff --git a/CommonLibs/Threads.cpp b/CommonLibs/Threads.cpp
index 2988e12..c056d69 100644
--- a/CommonLibs/Threads.cpp
+++ b/CommonLibs/Threads.cpp
@@ -122,6 +122,12 @@
}
 }

+void thread_enable_cancel(bool cancel)
+{
+   cancel ? pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) :
+pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+}
+
 void Thread::start(void *(*task)(void*), void *arg)
 {
assert(mThread==((pthread_t)0));
diff --git a/CommonLibs/Threads.h b/CommonLibs/Threads.h
index 3b76985..4c5b9ee 100644
--- a/CommonLibs/Threads.h
+++ b/CommonLibs/Threads.h
@@ -142,6 +142,7 @@
thread.start((void *(*)(void*))function, (void*)argument);

 void set_selfthread_name(const char *name);
+void thread_enable_cancel(bool cancel);

 /** A C++ wrapper for pthread threads.  */
 class Thread {
diff --git a/Transceiver52M/device/lms/LMSDevice.cpp 
b/Transceiver52M/device/lms/LMSDevice.cpp
index b924fa7..0cd41d3 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -90,12 +90,6 @@
LOGLV(DLMS, lvl_map[lvl]) << msg;
 }

-static void thread_enable_cancel(bool cancel)
-{
-   cancel ? pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) :
-pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
-}
-
 static void print_range(const char* name, lms_range_t *range)
 {
LOGC(DDEV, INFO) << name << ": Min=" << range->min << " Max=" << 
range->max
diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp 
b/Transceiver52M/device/uhd/UHDDevice.cpp
index 765150f..46284e5 100644
--- a/Transceiver52M/device/uhd/UHDDevice.cpp
+++ b/Transceiver52M/device/uhd/UHDDevice.cpp
@@ -357,12 +357,6 @@
 }
 #endif

-static void thread_enable_cancel(bool cancel)
-{
-   cancel ? pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) :
-pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
-}
-
 uhd_device::uhd_device(size_t tx_sps, size_t rx_sps,
   InterfaceType iface, size_t chans, double lo_offset,
   const std::vector& tx_paths,

--
To view, visit https://gerrit.osmocom.org/13785
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a479b59bdda01233273dfa919bd678edbe34708
Gerrit-Change-Number: 13785
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 


Change in osmo-trx[master]: lms: Improve log during flush recv error

2019-04-25 Thread Pau Espin Pedrol
Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/13783


Change subject: lms: Improve log during flush recv error
..

lms: Improve log during flush recv error

Change-Id: Id45d42599738efd6a5d89787c75779838a979330
---
M Transceiver52M/device/lms/LMSDevice.cpp
1 file changed, 1 insertion(+), 1 deletion(-)



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

diff --git a/Transceiver52M/device/lms/LMSDevice.cpp 
b/Transceiver52M/device/lms/LMSDevice.cpp
index 064d742..b924fa7 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -462,7 +462,7 @@
rc = LMS_RecvStream(_lms_stream_rx[0], [0], len, 
_metadata, 100);
LOGC(DDEV, DEBUG) << "Flush: Recv buffer of len " << rc << " at 
" << std::hex << rx_metadata.timestamp;
if (rc != len) {
-   LOGC(DDEV, ALERT) << "LMS: Device receive timed out";
+   LOGC(DDEV, ALERT) << "Flush: Device receive timed out";
return false;
}


--
To view, visit https://gerrit.osmocom.org/13783
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id45d42599738efd6a5d89787c75779838a979330
Gerrit-Change-Number: 13783
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 


Change in osmo-trx[master]: lms: Remove references to ALERT loglevel

2019-04-25 Thread Pau Espin Pedrol
Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/13787


Change subject: lms: Remove references to ALERT loglevel
..

lms: Remove references to ALERT loglevel

ALERT log level is not Osmocom standard level, it's just a define in
osmo-trx to keep compatibility with old code.

Same goes for one reference to "ERR" intead of "ERROR".

Change-Id: I0e171a8ac8a8bfa804ac97fba3d73efcfa6424b4
---
M Transceiver52M/device/lms/LMSDevice.cpp
1 file changed, 21 insertions(+), 21 deletions(-)



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

diff --git a/Transceiver52M/device/lms/LMSDevice.cpp 
b/Transceiver52M/device/lms/LMSDevice.cpp
index d0c8e19..e971ad4 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -234,7 +234,7 @@

/* configure antennas */
if (!set_antennas()) {
-   LOGC(DDEV, ALERT) << "LMS antenna setting failed";
+   LOGC(DDEV, FATAL) << "LMS antenna setting failed";
goto out_close;
}

@@ -245,7 +245,7 @@
return NORMAL;

 out_close:
-   LOGC(DDEV, ALERT) << "Error in LMS open, closing: " << 
LMS_GetLastErrorMessage();
+   LOGC(DDEV, FATAL) << "Error in LMS open, closing: " << 
LMS_GetLastErrorMessage();
LMS_Close(m_lms_dev);
m_lms_dev = NULL;
return -1;
@@ -456,7 +456,7 @@
rc = LMS_RecvStream(_lms_stream_rx[0], [0], len, 
_metadata, 100);
LOGC(DDEV, DEBUG) << "Flush: Recv buffer of len " << rc << " at 
" << std::hex << rx_metadata.timestamp;
if (rc != len) {
-   LOGC(DDEV, ALERT) << "Flush: Device receive timed out";
+   LOGC(DDEV, ERROR) << "Flush: Device receive timed out";
return false;
}

@@ -472,18 +472,18 @@
int idx;
 
if (chan >= rx_paths.size()) {
-   LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
+   LOGC(DDEV, ERROR) << "Requested non-existent channel " << chan;
return false;
}

idx = get_ant_idx(ant, LMS_CH_RX, chan);
if (idx < 0) {
-   LOGC(DDEV, ALERT) << "Invalid Rx Antenna";
+   LOGC(DDEV, ERROR) << "Invalid Rx Antenna";
return false;
}

if (LMS_SetAntenna(m_lms_dev, LMS_CH_RX, chan, idx) < 0) {
-   LOGC(DDEV, ALERT) << "Unable to set Rx Antenna";
+   LOGC(DDEV, ERROR) << "Unable to set Rx Antenna";
}

return true;
@@ -495,18 +495,18 @@
int idx;

if (chan >= rx_paths.size()) {
-   LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
+   LOGC(DDEV, ERROR) << "Requested non-existent channel " << chan;
return "";
}

idx = LMS_GetAntenna(m_lms_dev, LMS_CH_RX, chan);
if (idx < 0) {
-   LOGC(DDEV, ALERT) << "Error getting Rx Antenna";
+   LOGC(DDEV, ERROR) << "Error getting Rx Antenna";
return "";
}

if (LMS_GetAntennaList(m_lms_dev, LMS_CH_RX, chan, name_list) < idx) {
-   LOGC(DDEV, ALERT) << "Error getting Rx Antenna List";
+   LOGC(DDEV, ERROR) << "Error getting Rx Antenna List";
return "";
}

@@ -518,18 +518,18 @@
int idx;

if (chan >= tx_paths.size()) {
-   LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
+   LOGC(DDEV, ERROR) << "Requested non-existent channel " << chan;
return false;
}

idx = get_ant_idx(ant, LMS_CH_TX, chan);
if (idx < 0) {
-   LOGC(DDEV, ALERT) << "Invalid Rx Antenna";
+   LOGC(DDEV, ERROR) << "Invalid Rx Antenna";
return false;
}

if (LMS_SetAntenna(m_lms_dev, LMS_CH_TX, chan, idx) < 0) {
-   LOGC(DDEV, ALERT) << "Unable to set Rx Antenna";
+   LOGC(DDEV, ERROR) << "Unable to set Rx Antenna";
}

return true;
@@ -541,18 +541,18 @@
int idx;

if (chan >= tx_paths.size()) {
-   LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
+   LOGC(DDEV, ERROR) << "Requested non-existent channel " << chan;
return "";
}

idx = LMS_GetAntenna(m_lms_dev, LMS_CH_TX, chan);
if (idx < 0) {
-   LOGC(DDEV, ALERT) << "Error getting Tx Antenna";
+   LOGC(DDEV, ERROR) << "Error getting Tx Antenna";
return "";
}

if (LMS_GetAntennaList(m_lms_dev, LMS_CH_TX, chan, name_list) < idx) {
-   LOGC(DDEV, ALERT) << "Error getting Tx Antenna List";
+   LOGC(DDEV, ERROR) << "Error getting Tx Antenna List";
return "";
}

@@ -603,7 +603,7 @@
 

Change in osmo-trx[master]: lms: Remove unused var m_last_tx_overruns

2019-04-25 Thread Pau Espin Pedrol
Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/13788


Change subject: lms: Remove unused var m_last_tx_overruns
..

lms: Remove unused var m_last_tx_overruns

Change-Id: I2104205b2af7cd6c86075d5cc4f0f36bde5e5311
---
M Transceiver52M/device/lms/LMSDevice.cpp
M Transceiver52M/device/lms/LMSDevice.h
2 files changed, 0 insertions(+), 2 deletions(-)



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

diff --git a/Transceiver52M/device/lms/LMSDevice.cpp 
b/Transceiver52M/device/lms/LMSDevice.cpp
index e971ad4..e65c93d 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -55,7 +55,6 @@
m_last_rx_underruns.resize(chans, 0);
m_last_rx_overruns.resize(chans, 0);
m_last_tx_underruns.resize(chans, 0);
-   m_last_tx_overruns.resize(chans, 0);
 }

 LMSDevice::~LMSDevice()
diff --git a/Transceiver52M/device/lms/LMSDevice.h 
b/Transceiver52M/device/lms/LMSDevice.h
index d1cb12a..4bf2b32 100644
--- a/Transceiver52M/device/lms/LMSDevice.h
+++ b/Transceiver52M/device/lms/LMSDevice.h
@@ -51,7 +51,6 @@
std::vector m_last_rx_underruns;
std::vector m_last_rx_overruns;
std::vector m_last_tx_underruns;
-   std::vector m_last_tx_overruns;

double actualSampleRate;///< the actual USRP sampling rate


--
To view, visit https://gerrit.osmocom.org/13788
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2104205b2af7cd6c86075d5cc4f0f36bde5e5311
Gerrit-Change-Number: 13788
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 


Change in osmo-trx[master]: lms: Catch and log dropped packets by HW during recv

2019-04-25 Thread Pau Espin Pedrol
Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/13789


Change subject: lms: Catch and log dropped packets by HW during recv
..

lms: Catch and log dropped packets by HW during recv

Change-Id: I23554d95b0aff585024610fc12920c9da4f3ba9e
---
M Transceiver52M/device/lms/LMSDevice.cpp
M Transceiver52M/device/lms/LMSDevice.h
2 files changed, 9 insertions(+), 0 deletions(-)



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

diff --git a/Transceiver52M/device/lms/LMSDevice.cpp 
b/Transceiver52M/device/lms/LMSDevice.cpp
index e65c93d..7071589 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -54,6 +54,7 @@

m_last_rx_underruns.resize(chans, 0);
m_last_rx_overruns.resize(chans, 0);
+   m_last_rx_dropped.resize(chans, 0);
m_last_tx_underruns.resize(chans, 0);
 }

@@ -587,6 +588,13 @@
  << status.overrun << ")";
}
m_last_rx_overruns[chan] = status.overrun;
+
+   if (status.droppedPackets > m_last_rx_dropped[chan]) {
+   LOGC(DDEV, ERROR) << "chan " << chan << ": recv Dropped 
packets by HW! ("
+ << m_last_rx_dropped[chan] << " -> "
+ << status.droppedPackets << ")";
+   }
+   m_last_rx_dropped[chan] = m_last_rx_overruns[chan];
}
 }

diff --git a/Transceiver52M/device/lms/LMSDevice.h 
b/Transceiver52M/device/lms/LMSDevice.h
index 4bf2b32..225839d 100644
--- a/Transceiver52M/device/lms/LMSDevice.h
+++ b/Transceiver52M/device/lms/LMSDevice.h
@@ -50,6 +50,7 @@

std::vector m_last_rx_underruns;
std::vector m_last_rx_overruns;
+   std::vector m_last_rx_dropped;
std::vector m_last_tx_underruns;

double actualSampleRate;///< the actual USRP sampling rate

--
To view, visit https://gerrit.osmocom.org/13789
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I23554d95b0aff585024610fc12920c9da4f3ba9e
Gerrit-Change-Number: 13789
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 


Change in osmo-ggsn[master]: ggsn.c: Refactor PCO processing during PDP activation

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13606 )

Change subject: ggsn.c: Refactor PCO processing during PDP activation
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13606
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I4a7d09279b6b259e2b95f1f51159b16838b2d94c
Gerrit-Change-Number: 13606
Gerrit-PatchSet: 3
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-CC: Pau Espin Pedrol 
Gerrit-Comment-Date: Thu, 25 Apr 2019 20:17:24 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-ggsn[master]: ggsn: const-ify input / read-only arguments of PCO related functions

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13568 )

Change subject: ggsn: const-ify input / read-only arguments of PCO related 
functions
..

ggsn: const-ify input / read-only arguments of PCO related functions

Change-Id: Ia0877988180ded4e3c033d7f1fb6e1c2acd60163
---
M ggsn/ggsn.c
1 file changed, 8 insertions(+), 6 deletions(-)

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



diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 65e15c3..a439d01 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -413,9 +413,10 @@
 } __attribute__ ((packed));

 /* determine if IPCP contains given option */
-static uint8_t *ipcp_contains_option(uint8_t *ipcp, size_t ipcp_len, enum 
ipcp_options opt, size_t opt_minlen)
+static const uint8_t *ipcp_contains_option(const uint8_t *ipcp, size_t 
ipcp_len,
+  enum ipcp_options opt, size_t 
opt_minlen)
 {
-   uint8_t *cur_opt = ipcp + sizeof(struct ipcp_hdr);
+   const uint8_t *cur_opt = ipcp + sizeof(struct ipcp_hdr);

/* iterate over Options and check if protocol contained */
while (cur_opt + 2 <= ipcp + ipcp_len) {
@@ -469,9 +470,10 @@
 } __attribute__((packed));

 /* determine if PCO contains given protocol */
-static uint8_t *pco_contains_proto(struct ul255_t *pco, size_t offset, 
uint16_t prot, size_t prot_minlen)
+static const uint8_t *pco_contains_proto(const struct ul255_t *pco, size_t 
offset,
+uint16_t prot, size_t prot_minlen)
 {
-   uint8_t *cur = pco->v + 1 /*length*/ + offset;
+   const uint8_t *cur = pco->v + 1 /*length*/ + offset;

/* iterate over PCO and check if protocol contained */
while (cur + sizeof(struct pco_element) <= pco->v + pco->l) {
@@ -512,9 +514,9 @@
 {
const struct in46_addr *dns1 = >v4.cfg.dns[0];
const struct in46_addr *dns2 = >v4.cfg.dns[1];
-   uint8_t *ipcp;
+   const uint8_t *ipcp, *pco_ipcp;
uint16_t ipcp_len;
-   uint8_t *len1, *len2, *pco_ipcp;
+   uint8_t *len1, *len2;
unsigned int len_appended;
ptrdiff_t consumed;
size_t remain, offset = 0;

--
To view, visit https://gerrit.osmocom.org/13568
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia0877988180ded4e3c033d7f1fb6e1c2acd60163
Gerrit-Change-Number: 13568
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 


Change in osmo-ggsn[master]: ggsn: Remove magic numbers from pco_contains_proto()

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13567 )

Change subject: ggsn: Remove magic numbers from pco_contains_proto()
..

ggsn: Remove magic numbers from pco_contains_proto()

Let's remove some magic numbers and use a data structure to describe
the PCO element header.

Change-Id: I9871ffced677320aa82438332bfdb951ab129f04
---
M ggsn/ggsn.c
1 file changed, 11 insertions(+), 6 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, approved



diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 423f0c0..65e15c3 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -462,18 +462,23 @@
PCO_P_REL_DATA_SVC  = 0x0018,
 };

+struct pco_element {
+   uint16_t protocol_id;   /* network byte order */
+   uint8_t length; /* length of data below */
+   uint8_t data[0];
+} __attribute__((packed));
+
 /* determine if PCO contains given protocol */
 static uint8_t *pco_contains_proto(struct ul255_t *pco, size_t offset, 
uint16_t prot, size_t prot_minlen)
 {
-   uint8_t *cur = pco->v + 1 + offset;
+   uint8_t *cur = pco->v + 1 /*length*/ + offset;

/* iterate over PCO and check if protocol contained */
-   while (cur + 3 <= pco->v + pco->l) {
-   uint16_t cur_prot = osmo_load16be(cur);
-   uint8_t cur_len = cur[2];
-   if (cur_prot == prot && cur_len >= prot_minlen)
+   while (cur + sizeof(struct pco_element) <= pco->v + pco->l) {
+   const struct pco_element *elem = (const struct pco_element 
*)cur;
+   if (ntohs(elem->protocol_id) == prot && elem->length >= 
prot_minlen)
return cur;
-   cur += cur_len + 3;
+   cur += elem->length + sizeof(struct pco_element);
}
return NULL;
 }

--
To view, visit https://gerrit.osmocom.org/13567
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9871ffced677320aa82438332bfdb951ab129f04
Gerrit-Change-Number: 13567
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 


Change in osmo-ggsn[master]: ggsn.c: Refactor PCO processing during PDP activation

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13606 )

Change subject: ggsn.c: Refactor PCO processing during PDP activation
..

ggsn.c: Refactor PCO processing during PDP activation

The existing PCO processing is implemented in a rather convoluted
way.  We scan the list of PCO elements several times for different
PCO protocols.  Let's change to a straight-forward model where we
simply do one iteration over the list of PCO elements and generate
responses step by step.

Change-Id: I4a7d09279b6b259e2b95f1f51159b16838b2d94c
---
M ggsn/ggsn.c
1 file changed, 95 insertions(+), 85 deletions(-)

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



diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 8cd4b05..2d37cf0 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -470,22 +470,6 @@
uint8_t data[0];
 } __attribute__((packed));

-/* determine if PCO contains given protocol */
-static const struct pco_element *pco_contains_proto(const struct ul255_t *pco, 
size_t offset,
-   uint16_t prot, size_t 
prot_minlen)
-{
-   const uint8_t *cur = pco->v + 1 /*length*/ + offset;
-
-   /* iterate over PCO and check if protocol contained */
-   while (cur + sizeof(struct pco_element) <= pco->v + pco->l) {
-   const struct pco_element *elem = (const struct pco_element 
*)cur;
-   if (ntohs(elem->protocol_id) == prot && elem->length >= 
prot_minlen)
-   return elem;
-   cur += elem->length + sizeof(struct pco_element);
-   }
-   return NULL;
-}
-
 /*! Get the peer of pdp based on IP version used.
  *  \param[in] pdp PDP context to select the peer from.
  *  \param[in] v4v6 IP version to select. Valid values are 4 and 6.
@@ -510,101 +494,127 @@
return NULL;
 }

-/* construct an IPCP PCO response from request*/
-static void build_ipcp_pco(const struct apn_ctx *apn, struct pdp_t *pdp, 
struct msgb *msg)
+static void process_pco_element_ipcp(const struct pco_element *pco_elem, 
struct msgb *resp,
+const struct apn_ctx *apn, struct pdp_t 
*pdp)
 {
+   struct ippoolm_t *peer_v4 = pdp_get_peer_ipv(pdp, false);
const struct in46_addr *dns1 = >v4.cfg.dns[0];
const struct in46_addr *dns2 = >v4.cfg.dns[1];
-   const struct pco_element *pco_ipcp;
+   uint8_t *start = resp->tail;
const uint8_t *ipcp;
uint16_t ipcp_len;
uint8_t *len1, *len2;
unsigned int len_appended;
ptrdiff_t consumed;
-   size_t remain, offset = 0;
+   size_t remain;
 
-   /* pco_contains_proto() returns a potentially unaligned pointer into 
pco_req->v (see OS#3194) */
-   pco_ipcp = pco_contains_proto(>pco_req, offset, PCO_P_IPCP, 
sizeof(struct ipcp_hdr));
-   while (pco_ipcp) {
-   uint8_t *start = msg->tail;
+   if (!peer_v4)
+   return;

-   ipcp = pco_ipcp->data;
-   consumed = (ipcp - >pco_req.v[0]);
-   remain = sizeof(pdp->pco_req.v) - consumed;
-   ipcp_len = osmo_load16be(ipcp + 2); /* 1=code + 1=id */
-   if (remain < 0 || remain < ipcp_len)
-   return;
+   ipcp = pco_elem->data;
+   consumed = (ipcp - >pco_req.v[0]);
+   remain = sizeof(pdp->pco_req.v) - consumed;
+   ipcp_len = osmo_load16be(ipcp + 2); /* 1=code + 1=id */
+   if (remain < 0 || remain < ipcp_len)
+   return;

-   /* Three byte T16L header */
-   msgb_put_u16(msg, 0x8021);  /* IPCP */
-   len1 = msgb_put(msg, 1);/* Length of contents: delay */
+   /* Three byte T16L header */
+   msgb_put_u16(resp, 0x8021); /* IPCP */
+   len1 = msgb_put(resp, 1);   /* Length of contents: delay */

-   msgb_put_u8(msg, 0x02); /* ACK */
-   msgb_put_u8(msg, ipcp[1]);  /* ID: Needs to match request */
-   msgb_put_u8(msg, 0x00); /* Length MSB */
-   len2 = msgb_put(msg, 1);/* Length LSB: delay */
+   msgb_put_u8(resp, 0x02);/* ACK */
+   msgb_put_u8(resp, ipcp[1]); /* ID: Needs to match request */
+   msgb_put_u8(resp, 0x00);/* Length MSB */
+   len2 = msgb_put(resp, 1);   /* Length LSB: delay */

-   if (dns1->len == 4 && ipcp_contains_option(ipcp, ipcp_len, 
IPCP_OPT_PRIMARY_DNS, 4)) {
-   msgb_put_u8(msg, 0x81); /* DNS1 Tag */
-   msgb_put_u8(msg, 2 + dns1->len);/* DNS1 Length, incl. 
TL */
-   msgb_put_u32(msg, ntohl(dns1->v4.s_addr));
-   }
-
-   if (dns2->len == 4 && ipcp_contains_option(ipcp, ipcp_len, 
IPCP_OPT_SECONDARY_DNS, 4)) {
-   msgb_put_u8(msg, 0x83); /* DNS2 

Change in osmo-ggsn[master]: ggsn: Fix build_ipcp_pco() in presence of invalid IPCP content

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13570 )

Change subject: ggsn: Fix build_ipcp_pco() in presence of invalid IPCP content
..

ggsn: Fix build_ipcp_pco() in presence of invalid IPCP content

When build_ipcp_pco() iterated over the PCO list, it didn't use
the "outer" pco length as an increment, but used the "inner" IPCP
length.

If an IPCP message with an invalid "inner" length was being processed
(see pcap file attached to OS#3914), the PCO iteration beyond that
broken IPCP would fail, possibly rendering false hits.

Let's make pco_contains_proto() return a pointer to the the pco_element,
so that the caller can use the outer length as an increment.

Change-Id: I8e9cffde092c8c5824abfaeecb742afcf949802c
Related: OS#3914
---
M ggsn/ggsn.c
1 file changed, 7 insertions(+), 6 deletions(-)

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



diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 59523ac..8cd4b05 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -471,8 +471,8 @@
 } __attribute__((packed));

 /* determine if PCO contains given protocol */
-static const uint8_t *pco_contains_proto(const struct ul255_t *pco, size_t 
offset,
-uint16_t prot, size_t prot_minlen)
+static const struct pco_element *pco_contains_proto(const struct ul255_t *pco, 
size_t offset,
+   uint16_t prot, size_t 
prot_minlen)
 {
const uint8_t *cur = pco->v + 1 /*length*/ + offset;

@@ -480,7 +480,7 @@
while (cur + sizeof(struct pco_element) <= pco->v + pco->l) {
const struct pco_element *elem = (const struct pco_element 
*)cur;
if (ntohs(elem->protocol_id) == prot && elem->length >= 
prot_minlen)
-   return cur;
+   return elem;
cur += elem->length + sizeof(struct pco_element);
}
return NULL;
@@ -515,7 +515,8 @@
 {
const struct in46_addr *dns1 = >v4.cfg.dns[0];
const struct in46_addr *dns2 = >v4.cfg.dns[1];
-   const uint8_t *ipcp, *pco_ipcp;
+   const struct pco_element *pco_ipcp;
+   const uint8_t *ipcp;
uint16_t ipcp_len;
uint8_t *len1, *len2;
unsigned int len_appended;
@@ -527,7 +528,7 @@
while (pco_ipcp) {
uint8_t *start = msg->tail;

-   ipcp = (pco_ipcp + 3);  /* 2=type + 1=len */
+   ipcp = pco_ipcp->data;
consumed = (ipcp - >pco_req.v[0]);
remain = sizeof(pdp->pco_req.v) - consumed;
ipcp_len = osmo_load16be(ipcp + 2); /* 1=code + 1=id */
@@ -560,7 +561,7 @@
*len1 = len_appended - 3;
*len2 = len_appended - 3;

-   offset += 3 + ipcp_len;
+   offset += sizeof(pco_ipcp) + pco_ipcp->length;
pco_ipcp = pco_contains_proto(>pco_req, offset, 
PCO_P_IPCP, sizeof(struct ipcp_hdr));
}


--
To view, visit https://gerrit.osmocom.org/13570
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I8e9cffde092c8c5824abfaeecb742afcf949802c
Gerrit-Change-Number: 13570
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 


Change in osmo-ggsn[master]: ggsn: Remove magic numbers from ipcp_contains_option()

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13569 )

Change subject: ggsn: Remove magic numbers from ipcp_contains_option()
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13569
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5b1abc6f403f85986407e9e8359924dfcb58031a
Gerrit-Change-Number: 13569
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Thu, 25 Apr 2019 20:16:48 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-ggsn[master]: ggsn: const-ify input / read-only arguments of PCO related functions

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13568 )

Change subject: ggsn: const-ify input / read-only arguments of PCO related 
functions
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13568
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia0877988180ded4e3c033d7f1fb6e1c2acd60163
Gerrit-Change-Number: 13568
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Thu, 25 Apr 2019 20:16:39 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-ggsn[master]: ggsn: Fix build_ipcp_pco() in presence of invalid IPCP content

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13570 )

Change subject: ggsn: Fix build_ipcp_pco() in presence of invalid IPCP content
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13570
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I8e9cffde092c8c5824abfaeecb742afcf949802c
Gerrit-Change-Number: 13570
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Thu, 25 Apr 2019 20:17:09 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-msc[master]: smpp: Make libsmpp34 use talloc for its allocations

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13562 )

Change subject: smpp: Make libsmpp34 use talloc for its allocations
..


Patch Set 4: Code-Review+2

re-add ++2/+1


--
To view, visit https://gerrit.osmocom.org/13562
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2725ffab6a225813e65768735f01678e2022128
Gerrit-Change-Number: 13562
Gerrit-PatchSet: 4
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Comment-Date: Thu, 25 Apr 2019 20:15:25 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-msc[master]: smpp: Make libsmpp34 use talloc for its allocations

2019-04-25 Thread Harald Welte
Hello Vadim Yanitskiy, Pau Espin Pedrol, Jenkins Builder,

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

https://gerrit.osmocom.org/13562

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

Change subject: smpp: Make libsmpp34 use talloc for its allocations
..

smpp: Make libsmpp34 use talloc for its allocations

We are just introducing smpp34_set_memory_functions() in libsmpp34
to allow applications like OsmoMSC to provide their own heap allocator
callback functions.  Let's used this to integrate with talloc and
hence allow talloc tracking/debugging for libsmpp34 internal
allocations.

Depends: libsmpp34 Change-Id I3656117115e89638c093bfbcbc4369ce302f7a94
Change-Id: Ie2725ffab6a225813e65768735f01678e2022128
Related: OS#3913
---
M src/libmsc/smpp_openbsc.c
1 file changed, 27 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/62/13562/4
--
To view, visit https://gerrit.osmocom.org/13562
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie2725ffab6a225813e65768735f01678e2022128
Gerrit-Change-Number: 13562
Gerrit-PatchSet: 4
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 


Change in osmo-ttcn3-hacks[master]: HNBAP, RUA and RANAP protocol codecs

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13652 )

Change subject: HNBAP, RUA and RANAP protocol codecs
..

HNBAP, RUA and RANAP protocol codecs

This patch introduces protocol codecs for the HNBAP, RUA and RANAP
protocols, which is mandatory for testing IuCS, IuPS or Iuh in
the future.

As Eclipse TITAN ASN.1 only supports the BER codec and the above
protocols all use APER, we need to use an external transcoder from
APER to BER and vice-versa.  This was implemented using a proprietary
ASN.1 compiler / trnaslator which sysmocom is packaging as
libfftranscode, which is made available as binary package
for Debian 9 at https://ftp.osmocom.org/binaries/libfftranscode/

Related: OS#2856, OS#2857, OS#2858
Change-Id: If4a72de9bc54d6e6a7daaca78a4d4aa5684203a5
---
A asn-test/ttcn3_asn1_rename.sh
A library/hnbap/HNBAP_CommonDataTypes.asn
A library/hnbap/HNBAP_Constants.asn
A library/hnbap/HNBAP_Containers.asn
A library/hnbap/HNBAP_EncDec.cc
A library/hnbap/HNBAP_IEs.asn
A library/hnbap/HNBAP_PDU_Contents.asn
A library/hnbap/HNBAP_PDU_Descriptions.asn
A library/hnbap/HNBAP_Types.ttcn
A library/hnbap/regen_makefile.sh
A library/ranap/RANAP_CodecPort.ttcn
A library/ranap/RANAP_CommonDataTypes.asn
A library/ranap/RANAP_Constants.asn
A library/ranap/RANAP_Containers.asn
A library/ranap/RANAP_EncDec.cc
A library/ranap/RANAP_IEs.asn
A library/ranap/RANAP_PDU_Contents.asn
A library/ranap/RANAP_PDU_Descriptions.asn
A library/ranap/RANAP_Selftests.ttcn
A library/ranap/RANAP_Templates.ttcn
A library/ranap/RANAP_Types.ttcn
A library/ranap/regen_makefile.sh
A library/rua/RUA_CommonDataTypes.asn
A library/rua/RUA_Constants.asn
A library/rua/RUA_Containers.asn
A library/rua/RUA_EncDec.cc
A library/rua/RUA_IEs.asn
A library/rua/RUA_PDU_Contents.asn
A library/rua/RUA_PDU_Descriptions.asn
A library/rua/RUA_Types.ttcn
A library/rua/regen_makefile.sh
31 files changed, 12,411 insertions(+), 0 deletions(-)

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




--
To view, visit https://gerrit.osmocom.org/13652
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If4a72de9bc54d6e6a7daaca78a4d4aa5684203a5
Gerrit-Change-Number: 13652
Gerrit-PatchSet: 9
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)


Change in osmo-ttcn3-hacks[master]: RAN_Adapter: Rename functions from f_bssap_* to f_ran_adapter_*

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13749 )

Change subject: RAN_Adapter: Rename functions from f_bssap_* to f_ran_adapter_*
..

RAN_Adapter: Rename functions from f_bssap_* to f_ran_adapter_*

Change-Id: I73818247f1dfc71c8ece11660e6c18f5f153d186
---
M bsc/BSC_Tests.ttcn
M library/RAN_Adapter.ttcnpp
M msc/MSC_Tests.ttcn
3 files changed, 10 insertions(+), 10 deletions(-)

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



diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index 720669b..fb43d5e 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -316,12 +316,12 @@
/* Call a function of our 'parent component' RAN_Adapter_CT to start the
 * MSC-side BSSAP emulation */
if (handler_mode) {
-   f_bssap_init(g_bssap, mp_bssap_cfg, "VirtMSC", MSC_RanOps);
-   f_bssap_start(g_bssap);
+   f_ran_adapter_init(g_bssap, mp_bssap_cfg, "VirtMSC", 
MSC_RanOps);
+   f_ran_adapter_start(g_bssap);
} else {
-   f_bssap_init(g_bssap, mp_bssap_cfg, "VirtMSC", omit);
+   f_ran_adapter_init(g_bssap, mp_bssap_cfg, "VirtMSC", omit);
connect(self:BSSAP, g_bssap.vc_SCCP:SCCP_SP_PORT);
-   f_bssap_start(g_bssap);
+   f_ran_adapter_start(g_bssap);
f_legacy_bssap_reset();
}

diff --git a/library/RAN_Adapter.ttcnpp b/library/RAN_Adapter.ttcnpp
index 43b4988..a96c6ef 100644
--- a/library/RAN_Adapter.ttcnpp
+++ b/library/RAN_Adapter.ttcnpp
@@ -76,7 +76,7 @@
 }


-function f_bssap_init(inout RAN_Adapter ba, in RAN_Configuration cfg, 
charstring id,
+function f_ran_adapter_init(inout RAN_Adapter ba, in RAN_Configuration cfg, 
charstring id,
template RanOps ops) {
init_pars(ba, cfg);
ops.sccp_addr_local := ba.sccp_addr_own;
@@ -157,7 +157,7 @@

 }

-function f_bssap_start(inout RAN_Adapter ba) {
+function f_ran_adapter_start(inout RAN_Adapter ba) {
ba.vc_SCCP.start(SCCPStart(ba.sccp_pars));
 }

diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index 9a37fb0..b2503b7 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -277,8 +277,8 @@

for (var integer i := 0; i < num_bsc; i := i + 1) {
if (isbound(mp_bssap_cfg[i])) {
-   f_bssap_init(g_bssap[i], mp_bssap_cfg[i], "MSC_Test_" & 
int2str(i), BSC_RanOps);
-   f_bssap_start(g_bssap[i]);
+   f_ran_adapter_init(g_bssap[i], mp_bssap_cfg[i], 
"MSC_Test_" & int2str(i), BSC_RanOps);
+   f_ran_adapter_start(g_bssap[i]);
} else {
testcase.stop("missing BSSAP configuration");
}
@@ -311,7 +311,7 @@
  * to f_init() when the high level functions of the BSC_ConnectionHandler are
  * not needed. */
 function f_init_bssap_direct() runs on MTC_CT {
-   f_bssap_init(g_bssap[0], mp_bssap_cfg[0], "MSC_Test", omit);
+   f_ran_adapter_init(g_bssap[0], mp_bssap_cfg[0], "MSC_Test", omit);
connect(g_bssap[0].vc_SCCP:SCCP_SP_PORT, self:BSSAP_DIRECT);

/* Start guard timer and activate it as default */
@@ -1860,7 +1860,7 @@
var boolean reset_ack_seen := false;
f_init_bssap_direct();

-   f_bssap_start(g_bssap[0]);
+   f_ran_adapter_start(g_bssap[0]);

f_sleep(3.0);


--
To view, visit https://gerrit.osmocom.org/13749
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I73818247f1dfc71c8ece11660e6c18f5f153d186
Gerrit-Change-Number: 13749
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)


Change in osmo-ttcn3-hacks[master]: RAN_Adapter: Support build without IPA / BSSAP support

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13750 )

Change subject: RAN_Adapter: Support build without IPA /  BSSAP support
..

RAN_Adapter: Support build without IPA /  BSSAP support

Change-Id: I5370f0ea6f2f6cfdc3370a6f3d3bf2e6c32af4d2
---
M library/RAN_Adapter.ttcnpp
1 file changed, 7 insertions(+), 1 deletion(-)

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



diff --git a/library/RAN_Adapter.ttcnpp b/library/RAN_Adapter.ttcnpp
index a96c6ef..ae7934e 100644
--- a/library/RAN_Adapter.ttcnpp
+++ b/library/RAN_Adapter.ttcnpp
@@ -22,7 +22,9 @@
 import from SCTPasp_Types all;
 import from SCTPasp_PortType all;

+#ifdef RAN_EMULATION_BSSAP
 import from BSSMAP_Templates all;
+#endif
 import from RAN_Emulation all;

 type record RAN_Adapter {
@@ -96,6 +98,7 @@
connect(ba.vc_M3UA:MTP3_SP_PORT, ba.vc_SCCP:MTP3_SCCP_PORT);
ba.vc_M3UA.start(f_M3UA_Emulation(cfg.sctp_addr, cfg.rctx));
}
+#ifdef IPA_EMULATION_SCCP
case (BSSAP_TRANSPORT_SCCPlite_SERVER) {
ba.vc_IPA := IPA_Emulation_CT.create(id & "-IPA");
map(ba.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
@@ -129,7 +132,8 @@
ba.vc_WAIT.done;
disconnect(ba.vc_IPA:IPA_SP_PORT, ba.vc_WAIT:IPA_SP_PORT);
}
-#endif
+#endif /* SCCP */
+#endif /* BSSAP */
case else {
setverdict(fail, "Unsuppored RAN_Transport");
mtc.stop;
@@ -147,8 +151,10 @@
 #endif
if (cfg.transport == BSSAP_TRANSPORT_SCCPlite_SERVER or
cfg.transport == BSSAP_TRANSPORT_SCCPlite_CLIENT) {
+#ifdef IPA_EMULATION_MGCP
/* connect IPA MGCP port with BSSMAP MGCP port */
connect(ba.vc_IPA:IPA_MGCP_PORT, ba.vc_RAN:MGCP);
+#endif
}
/* start the BSSMAP emulation */
ba.vc_RAN.start(RAN_Emulation.main(valueof(ops), ""));

--
To view, visit https://gerrit.osmocom.org/13750
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I5370f0ea6f2f6cfdc3370a6f3d3bf2e6c32af4d2
Gerrit-Change-Number: 13750
Gerrit-PatchSet: 4
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)


Change in osmo-ttcn3-hacks[master]: RAN_Emulation: Add RANAP support

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13653 )

Change subject: RAN_Emulation: Add RANAP support
..

RAN_Emulation: Add RANAP support

So far, RAN_Emulation only handled BSSAP and hence could be used
to emulate BSCs towards the MSC.  Let's extend it with RANAP support
so we can also emulate RNCs towards the MSC.

We try to share as much code and logic as possible betweeb the two.

Related: OS#2856, OS#2857
Change-Id: Ie79bda764162e5c5a42608bde5c5f486ea531f33
---
M library/RAN_Adapter.ttcnpp
M library/RAN_Emulation.ttcnpp
2 files changed, 345 insertions(+), 10 deletions(-)

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



diff --git a/library/RAN_Adapter.ttcnpp b/library/RAN_Adapter.ttcnpp
index ae7934e..53c8bac 100644
--- a/library/RAN_Adapter.ttcnpp
+++ b/library/RAN_Adapter.ttcnpp
@@ -45,7 +45,8 @@
 type enumerated RAN_Transport {
BSSAP_TRANSPORT_AoIP,   /* 3GPP AoIP: SCCP over M3UA over SCTP */
BSSAP_TRANSPORT_SCCPlite_SERVER, /* SCCPlite: SCCP over IPA over TCP */
-   BSSAP_TRANSPORT_SCCPlite_CLIENT  /* SCCPlite: SCCP over IPA over TCP */
+   BSSAP_TRANSPORT_SCCPlite_CLIENT, /* SCCPlite: SCCP over IPA over TCP */
+   RANAP_TRANSPORT_IuCS/* 3GPP IuCS: SCCP over M3UA over SCTP */
 };

 type record RAN_Configuration {
@@ -90,8 +91,7 @@
ba.vc_RAN := RAN_Emulation_CT.create(id & "-RAN");
}
select (cfg.transport) {
-#ifdef RAN_EMULATION_BSSAP
-   case (BSSAP_TRANSPORT_AoIP) {
+   case (BSSAP_TRANSPORT_AoIP, RANAP_TRANSPORT_IuCS) {
ba.vc_M3UA := M3UA_CT.create(id & "-M3UA");
map(ba.vc_M3UA:SCTP_PORT, system:sctp);
/* connect MTP3 service provider (M3UA) to lower side of SCCP */
@@ -133,7 +133,6 @@
disconnect(ba.vc_IPA:IPA_SP_PORT, ba.vc_WAIT:IPA_SP_PORT);
}
 #endif /* SCCP */
-#endif /* BSSAP */
case else {
setverdict(fail, "Unsuppored RAN_Transport");
mtc.stop;
@@ -145,10 +144,17 @@
T.start;
//T.timeout;
log("Connecting BSSMAP Emulation to SCCP_SP_PORT and starting 
emulation");
-#if RAN_EMULATION_BSSAP
/* connect BSSNAP component to upper side of SCCP */
-   connect(ba.vc_RAN:BSSAP, ba.vc_SCCP:SCCP_SP_PORT);
+   if (cfg.transport == RANAP_TRANSPORT_IuCS) {
+#ifdef RAN_EMULATION_RANAP
+   ops.protocol := RAN_PROTOCOL_RANAP
+   connect(ba.vc_RAN:RANAP, ba.vc_SCCP:SCCP_SP_PORT);
 #endif
+   } else {
+#ifdef RAN_EMULATION_BSSAP
+   connect(ba.vc_RAN:BSSAP, ba.vc_SCCP:SCCP_SP_PORT);
+#endif
+   }
if (cfg.transport == BSSAP_TRANSPORT_SCCPlite_SERVER or
cfg.transport == BSSAP_TRANSPORT_SCCPlite_CLIENT) {
 #ifdef IPA_EMULATION_MGCP
@@ -156,7 +162,6 @@
connect(ba.vc_IPA:IPA_MGCP_PORT, ba.vc_RAN:MGCP);
 #endif
}
-   /* start the BSSMAP emulation */
ba.vc_RAN.start(RAN_Emulation.main(valueof(ops), ""));
}

diff --git a/library/RAN_Emulation.ttcnpp b/library/RAN_Emulation.ttcnpp
index e091133..a74b6de 100644
--- a/library/RAN_Emulation.ttcnpp
+++ b/library/RAN_Emulation.ttcnpp
@@ -48,6 +48,14 @@
 import from MGCP_Templates all;
 #endif

+#ifdef RAN_EMULATION_RANAP
+import from RANAP_CodecPort all;
+import from RANAP_PDU_Descriptions all;
+import from RANAP_Constants all;
+import from RANAP_IEs all;
+import from RANAP_Templates all;
+#endif
+
 /* General "base class" component definition, of which specific implementations
  * derive themselves by means of the "extends" feature */
 type component RAN_ConnHdlr {
@@ -110,6 +118,11 @@
/* Client requests us to create SCCP Connection */
BSSAP_Conn_Req,
 #endif
+#ifdef RAN_EMULATION_RANAP
+   RANAP_PDU,
+   /* Client requests us to create SCCP Connection */
+   RANAP_Conn_Req,
+#endif
 #ifdef RAN_EMULATION_MGCP
/* MGCP, only used for IPA SCCPlite (MGCP in IPA mux) */
MgcpCommand, MgcpResponse,
@@ -147,6 +160,9 @@
 #ifdef RAN_EMULATION_BSSAP
port BSSAP_CODEC_PT BSSAP;
 #endif
+#ifdef RAN_EMULATION_RANAP
+   port RANAP_CODEC_PT RANAP;
+#endif
/* BSSAP port to the per-connection clients */
port RAN_Conn_PT CLIENT;
 #ifdef RAN_EMULATION_MGCP
@@ -487,10 +503,137 @@
 }
 #endif

+#ifdef RAN_EMULATION_RANAP
+type record RANAP_Conn_Req {
+   SCCP_PAR_Addressaddr_peer,
+   SCCP_PAR_Addressaddr_own,
+   RANAP_PDU   ranap
+}
+template (value) RANAP_Conn_Req ts_RANAP_Conn_Req(SCCP_PAR_Address peer, 
SCCP_PAR_Address own, RANAP_PDU ranap) := {
+   addr_peer := peer,
+   addr_own := own,
+   ranap 

Change in osmo-ttcn3-hacks[master]: RAN_Emulation: Modularize protocol support

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13651 )

Change subject: RAN_Emulation: Modularize protocol support
..

RAN_Emulation: Modularize protocol support

The RAN_Emulation currently unconditionally provides BSSAP and MGCP support.
Let's re-structure the code so that support for those protocols is now
possible to enable/disable at compile time.

This patch is in preparation of introducing RANAP support in RAN_Emulation.

Change-Id: Id53ba3ff05f9946230e0e4a759245de14a0f9fbd
Related: OS#2856
---
M bsc-nat/BSC_MS_ConnectionHandler.ttcn
M bsc-nat/MSC_ConnectionHandler.ttcn
M bsc-nat/gen_links.sh
M bsc-nat/regen_makefile.sh
M bsc/MSC_ConnectionHandler.ttcn
M bsc/gen_links.sh
M bsc/regen_makefile.sh
R library/RAN_Adapter.ttcnpp
R library/RAN_Emulation.ttcnpp
M msc/BSC_ConnectionHandler.ttcn
M msc/gen_links.sh
M msc/regen_makefile.sh
12 files changed, 216 insertions(+), 141 deletions(-)

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



diff --git a/bsc-nat/BSC_MS_ConnectionHandler.ttcn 
b/bsc-nat/BSC_MS_ConnectionHandler.ttcn
index 63d0451..e52b678 100644
--- a/bsc-nat/BSC_MS_ConnectionHandler.ttcn
+++ b/bsc-nat/BSC_MS_ConnectionHandler.ttcn
@@ -53,6 +53,7 @@
unitdata_cb := refers(UnitdataCallback),
decode_dtap := false,
role_ms := true,
+   protocol := RAN_PROTOCOL_BSSAP,
sccp_addr_local := omit,
sccp_addr_peer := omit
 }
diff --git a/bsc-nat/MSC_ConnectionHandler.ttcn 
b/bsc-nat/MSC_ConnectionHandler.ttcn
index 383b67b..8635a29 100644
--- a/bsc-nat/MSC_ConnectionHandler.ttcn
+++ b/bsc-nat/MSC_ConnectionHandler.ttcn
@@ -59,6 +59,7 @@
unitdata_cb := refers(UnitdataCallback),
decode_dtap := false,
role_ms := false,
+   protocol := RAN_PROTOCOL_BSSAP,
sccp_addr_local := omit,
sccp_addr_peer := omit
 }
diff --git a/bsc-nat/gen_links.sh b/bsc-nat/gen_links.sh
index e54eec4..16e32b7 100755
--- a/bsc-nat/gen_links.sh
+++ b/bsc-nat/gen_links.sh
@@ -47,7 +47,7 @@
 gen_links $DIR $FILES

 DIR=../library
-FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn 
IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn 
IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp L3_Templates.ttcn 
BSSMAP_Templates.ttcn RAN_Emulation.ttcn MGCP_Types.ttcn MGCP_Templates.ttcn 
MGCP_CodecPort.ttcn MGCP_CodecPort_CtrlFunct.ttcn 
MGCP_CodecPort_CtrlFunctDef.cc Osmocom_CTRL_Types.ttcn 
Osmocom_CTRL_Functions.ttcn BSSAP_CodecPort.ttcn"
+FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn 
IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn 
IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp L3_Templates.ttcn 
BSSMAP_Templates.ttcn RAN_Emulation.ttcnpp MGCP_Types.ttcn MGCP_Templates.ttcn 
MGCP_CodecPort.ttcn MGCP_CodecPort_CtrlFunct.ttcn 
MGCP_CodecPort_CtrlFunctDef.cc Osmocom_CTRL_Types.ttcn 
Osmocom_CTRL_Functions.ttcn BSSAP_CodecPort.ttcn"
 gen_links $DIR $FILES

 ignore_pp_results
diff --git a/bsc-nat/regen_makefile.sh b/bsc-nat/regen_makefile.sh
index c5fe64c..f49df7e 100755
--- a/bsc-nat/regen_makefile.sh
+++ b/bsc-nat/regen_makefile.sh
@@ -4,6 +4,6 @@

 FILES="*.ttcn *.ttcnpp SCCP_EncDec.cc IPA_CodecPort_CtrlFunctDef.cc 
IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc 
RTP_EncDec.cc SDP_EncDec.cc *.c MGCP_CodecPort_CtrlFunctDef.cc"

-export CPPFLAGS_TTCN3="-DIPA_EMULATION_SCCP -DIPA_EMULATION_MGCP 
-DUSE_MTP3_DISTRIBUTOR"
+export CPPFLAGS_TTCN3="-DIPA_EMULATION_SCCP -DIPA_EMULATION_MGCP 
-DRAN_EMULATION_BSSAP -DRAN_EMULATION_MGCP -DUSE_MTP3_DISTRIBUTOR"

 ../regen-makefile.sh $MAIN $FILES
diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn
index 36e554d..520cc3e 100644
--- a/bsc/MSC_ConnectionHandler.ttcn
+++ b/bsc/MSC_ConnectionHandler.ttcn
@@ -376,6 +376,7 @@
unitdata_cb := refers(UnitdataCallback),
decode_dtap := false,
role_ms := false,
+   protocol := RAN_PROTOCOL_BSSAP,
sccp_addr_local := omit,
sccp_addr_peer := omit
 }
diff --git a/bsc/gen_links.sh b/bsc/gen_links.sh
index d8393c3..a4f09f4 100755
--- a/bsc/gen_links.sh
+++ b/bsc/gen_links.sh
@@ -67,7 +67,7 @@
 gen_links $DIR $FILES

 DIR=../library
-FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn 
Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc 
IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn 
IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp L3_Templates.ttcn 
BSSMAP_Templates.ttcn RAN_Emulation.ttcn RLCMAC_CSN1_Types.ttcn 
GSM_RR_Types.ttcn RSL_Types.ttcn RSL_Emulation.ttcn MGCP_Emulation.ttcn 
MGCP_Types.ttcn MGCP_Templates.ttcn MGCP_CodecPort.ttcn 
MGCP_CodecPort_CtrlFunct.ttcn MGCP_CodecPort_CtrlFunctDef.cc 
BSSAP_CodecPort.ttcn RAN_Adapter.ttcn Osmocom_CTRL_Types.ttcn 
Osmocom_CTRL_Functions.ttcn 

Change in osmo-ttcn3-hacks[master]: LLC_Templates: Add SABM, UA, FRMR, DM templates

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13757 )

Change subject: LLC_Templates: Add SABM, UA, FRMR, DM templates
..

LLC_Templates: Add SABM, UA, FRMR, DM templates

Related: OS#3953
Change-Id: Idb40dcd53310b76ea9df6c0090e31175a4382460
---
M library/LLC_Templates.ttcn
1 file changed, 59 insertions(+), 2 deletions(-)

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



diff --git a/library/LLC_Templates.ttcn b/library/LLC_Templates.ttcn
index 086207c..024ae0b 100644
--- a/library/LLC_Templates.ttcn
+++ b/library/LLC_Templates.ttcn
@@ -10,6 +10,14 @@
cR := cr,
pD := '0'B
 }
+template (value) Address_field ts_LLC_Addr(template (value) BIT4 sapi,
+  template (value) BIT1 cr,
+  template (value) BIT1 pd := '0'B) := 
{
+   sAPI := sapi,
+   spare := '00'B,
+   cR := cr,
+   pD := '0'B
+}

 template (value) Control_field_UI ts_LLC_CtrlUI(uint9_t n_u, boolean encrypted 
:= false,
boolean protected := false) := {
@@ -20,7 +28,7 @@
pM := bool2bit(protected)
 }

-template (value) Control_field_U ts_LLC_CtrlU(BIT4 m_bits, BIT1 p_f) := {
+template (value) Control_field_U ts_LLC_CtrlU(template (value) BIT4 m_bits, 
template (value) BIT1 p_f) := {
mBits := m_bits,
pF := p_f,
format := '111'B
@@ -47,7 +55,7 @@
 template PDU_LLC ts_LLC_UI(octetstring payload, BIT4 sapi, BIT1 cr, uint9_t 
n_u,
   boolean encrypted := false, boolean protected := 
false) := {
pDU_LLC_UI := {
-   address_field := t_LLC_Addr(sapi, cr),
+   address_field := ts_LLC_Addr(sapi, cr),
control_field := ts_LLC_CtrlUI(n_u, encrypted, protected),
information_field_UI := payload,
fCS := omit /* causes encoder to generate FCS */
@@ -77,6 +85,55 @@
}
 }

+template PDU_LLC tr_LLC_U(template BIT4 m_bits, template BIT1 p_f, template 
Information_field_U u,
+ template BIT4 sapi, template BIT1 cr) := {
+   pDU_LLC_U := {
+   address_field := t_LLC_Addr(sapi, cr),
+   control_field := tr_LLC_CtrlU(m_bits, p_f),
+   information_field_U := u,
+   fCS := '00'O /* provided by decoder if FCS OK */
+   }
+}
+template (value) PDU_LLC ts_LLC_U(template (value) BIT4 m_bits, template 
(value) BIT1 p_f,
+ template (value) Information_field_U u,
+ template (value) BIT4 sapi, template (value) 
BIT1 cr) := {
+   pDU_LLC_U := {
+   address_field := ts_LLC_Addr(sapi, cr),
+   control_field := ts_LLC_CtrlU(m_bits, p_f),
+   information_field_U := u,
+   fCS := omit /* causes encoder to generate FCS */
+   }
+}
+
+template PDU_LLC tr_LLC_SABM(template SABM_Information sabm_xid, template BIT1 
p_f,
+template BIT4 sapi, template BIT1 cr) :=
+   tr_LLC_U('0111'B, p_f, Information_field_U:{sABM := sabm_xid}, sapi, 
cr);
+template (value) PDU_LLC ts_LLC_SABM(template (value) SABM_Information 
sabm_xid,
+template (value) BIT1 p_f,
+template (value) BIT4 sapi, template 
(value) BIT1 cr) :=
+   ts_LLC_U('0111'B, p_f, Information_field_U:{sABM := sabm_xid}, sapi, 
cr);
+
+template PDU_LLC tr_LLC_UA(template UA_Information ua_xid, template BIT1 p_f,
+  template BIT4 sapi, template BIT1 cr) :=
+   tr_LLC_U('0110'B, p_f, Information_field_U:{uA := ua_xid}, sapi, cr);
+template (value) PDU_LLC ts_LLC_UA(template (value) UA_Information ua_xid,
+  template (value) BIT1 p_f,
+  template (value) BIT4 sapi, template (value) 
BIT1 cr) :=
+   ts_LLC_U('0110'B, p_f, Information_field_U:{uA := ua_xid}, sapi, cr);
+
+template PDU_LLC tr_LLC_FRMR(template FRMR_Information frmr, template BIT1 p_f,
+template BIT4 sapi, template BIT1 cr) :=
+   tr_LLC_U('1000'B, p_f, Information_field_U:{fRMR := frmr}, sapi, cr);
+template (value) PDU_LLC ts_LLC_FRMR(template (value) FRMR_Information frmr,
+template (value) BIT1 p_f,
+template (value) BIT4 sapi, template 
(value) BIT1 cr) :=
+   ts_LLC_U('1000'B, p_f, Information_field_U:{fRMR := frmr}, sapi, cr);
+
+template PDU_LLC tr_LLC_DM(template BIT1 p_f, template BIT4 sapi, template 
BIT1 cr) :=
+   tr_LLC_U('0001'B, p_f, Information_field_U:{dM := ''O}, sapi, cr);
+template (value) PDU_LLC ts_LLC_DM(template (value) BIT1 p_f, template (value) 
BIT4 sapi,
+  template (value) BIT1 cr) :=

Change in osmo-ttcn3-hacks[master]: msc: f_mm_auth(): Add support for UMTS AKA

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13736 )

Change subject: msc: f_mm_auth(): Add support for UMTS AKA
..

msc: f_mm_auth(): Add support for UMTS AKA

Change-Id: Id57adcebd63a06cfa555824e493561fe08f13d6d
---
M msc/BSC_ConnectionHandler.ttcn
M msc/MSC_Tests.ttcn
2 files changed, 30 insertions(+), 9 deletions(-)

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



diff --git a/msc/BSC_ConnectionHandler.ttcn b/msc/BSC_ConnectionHandler.ttcn
index 4534a9b..e408f82 100644
--- a/msc/BSC_ConnectionHandler.ttcn
+++ b/msc/BSC_ConnectionHandler.ttcn
@@ -75,7 +75,8 @@
boolean mm_info,
boolean sgsap_enable,
boolean gsup_enable,
-   integer ran_idx
+   integer ran_idx,
+   boolean use_umts_aka
 };

 /* get a one-octet bitmaks of supported algorithms based on Classmark 
information */
@@ -293,15 +294,34 @@
 function f_mm_auth() runs on BSC_ConnHdlr
 {
if (g_pars.net.expect_auth) {
-   g_pars.vec := f_gen_auth_vec_2g();
-   var GSUP_IE auth_tuple := 
valueof(ts_GSUP_IE_AuthTuple2G(g_pars.vec.rand,
-
g_pars.vec.sres,
-
g_pars.vec.kc));
+   var GSUP_IE auth_tuple;
GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi));
-   GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple));

-   
BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ(g_pars.vec.rand)));
-   
BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G(g_pars.vec.sres)));
+   if (g_pars.use_umts_aka) {
+   g_pars.vec := f_gen_auth_vec_3g();
+   auth_tuple := 
valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand,
+   
g_pars.vec.sres,
+   
g_pars.vec.kc,
+   
g_pars.vec.ik,
+   
g_pars.vec.ck,
+   
g_pars.vec.autn,
+   
g_pars.vec.res));
+   GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple));
+
+   
BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ_3G(g_pars.vec.rand, 
g_pars.vec.autn)));
+   var OCT4 res := substr(g_pars.vec.res, 0, 4);
+   var OCT4 xres := substr(g_pars.vec.res, 4, 4);
+   
BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_3G(res, xres)));
+   } else {
+   g_pars.vec := f_gen_auth_vec_2g();
+   auth_tuple := 
valueof(ts_GSUP_IE_AuthTuple2G(g_pars.vec.rand,
+   
g_pars.vec.sres,
+   
g_pars.vec.kc));
+   GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple));
+
+   
BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ(g_pars.vec.rand)));
+   
BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G(g_pars.vec.sres)));
+   }
}
 }

diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index 8c221dc..7d9c098 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -513,7 +513,8 @@
mm_info := mp_mm_info,
sgsap_enable := sgsap,
gsup_enable := gsup,
-   ran_idx := ran_idx
+   ran_idx := ran_idx,
+   use_umts_aka := false
};
return pars;
 }

--
To view, visit https://gerrit.osmocom.org/13736
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id57adcebd63a06cfa555824e493561fe08f13d6d
Gerrit-Change-Number: 13736
Gerrit-PatchSet: 3
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)


Change in osmo-ttcn3-hacks[master]: LLC_Templates: Add templates for NULL and DISC

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13759 )

Change subject: LLC_Templates: Add templates for NULL and DISC
..

LLC_Templates: Add templates for NULL and DISC

Change-Id: Ia5b350990379bba1677a0c1c99cf37e6651ba84d
---
M library/LLC_Templates.ttcn
1 file changed, 13 insertions(+), 0 deletions(-)

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



diff --git a/library/LLC_Templates.ttcn b/library/LLC_Templates.ttcn
index 024ae0b..b1cdb75 100644
--- a/library/LLC_Templates.ttcn
+++ b/library/LLC_Templates.ttcn
@@ -135,6 +135,19 @@
   template (value) BIT1 cr) :=
ts_LLC_U('0001'B, p_f, Information_field_U:{dM := ''O}, sapi, cr);

+template PDU_LLC tr_LLC_NULL(template BIT1 p_f, template BIT4 sapi, template 
BIT1 cr) :=
+   tr_LLC_U(''B, p_f, Information_field_U:{nULL := ''O}, sapi, cr);
+template (value) PDU_LLC ts_LLC_NULL(template (value) BIT1 p_f, template 
(value) BIT4 sapi,
+template (value) BIT1 cr) :=
+   ts_LLC_U(''B, p_f, Information_field_U:{nULL := ''O}, sapi, cr);
+
+template PDU_LLC tr_LLC_DISC(template BIT1 p_f, template BIT4 sapi, template 
BIT1 cr) :=
+   tr_LLC_U('0100'B, p_f, Information_field_U:{dISC := ''O}, sapi, cr);
+template (value) PDU_LLC ts_LLC_DISC(template (value) BIT1 p_f, template 
(value) BIT4 sapi,
+template (value) BIT1 cr) :=
+   ts_LLC_U('0100'B, p_f, Information_field_U:{dISC := ''O}, sapi, cr);
+
+
 const BIT4 c_LLC_SAPI_LLGMM := '0001'B;
 const BIT4 c_LLC_SAPI_TOM2 := '0010'B;
 const BIT4 c_LLC_SAPI_LL3 := '0011'B;

--
To view, visit https://gerrit.osmocom.org/13759
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia5b350990379bba1677a0c1c99cf37e6651ba84d
Gerrit-Change-Number: 13759
Gerrit-PatchSet: 4
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)


Change in osmo-ttcn3-hacks[master]: sgsn: Add TC_llc_null to test if SGSN survives a LLC NULL packet

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13760 )

Change subject: sgsn: Add TC_llc_null to test if SGSN survives a LLC NULL packet
..

sgsn: Add TC_llc_null to test if SGSN survives a LLC NULL packet

This test case reproduces a bug in OsmoSGSN where it would crash
as a result to sending LLC NULL frames.

Change-Id: I38326f2ebaaff009d4357edad9511ce2ce7736fd
Related: OS#3952
---
M sgsn/SGSN_Tests.ttcn
1 file changed, 25 insertions(+), 2 deletions(-)

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



diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn
index 74cdece..78bee58 100644
--- a/sgsn/SGSN_Tests.ttcn
+++ b/sgsn/SGSN_Tests.ttcn
@@ -375,12 +375,16 @@
f_sleep(20.0);
 }

+function f_send_llc(template (value) PDU_LLC llc_pdu, integer gb_index := 0) 
runs on BSSGP_ConnHdlr {
+   var octetstring llc_enc := enc_PDU_LLC(valueof(llc_pdu));
+   BSSGP[gb_index].send(ts_BSSGP_UL_UD(g_pars.tlli, 
g_pars.bssgp_cell_id[gb_index], llc_enc));
+}
+
 function f_send_l3_gmm_llc(template PDU_L3_MS_SGSN l3_mo, integer gb_index := 
0) runs on BSSGP_ConnHdlr {
var octetstring l3_enc := enc_PDU_L3_MS_SGSN(valueof(l3_mo));
var BIT4 sapi := f_llc_sapi_by_l3_mo(valueof(l3_mo));
var integer n_u := f_llc_get_n_u_tx(llc[bit2int(sapi)]);
-   var octetstring llc_enc := enc_PDU_LLC(valueof(ts_LLC_UI(l3_enc, sapi, 
'0'B, n_u)));
-   BSSGP[gb_index].send(ts_BSSGP_UL_UD(g_pars.tlli, 
g_pars.bssgp_cell_id[gb_index], llc_enc));
+   f_send_llc(ts_LLC_UI(l3_enc, sapi, '0'B, n_u));
 }

 altstep as_mm_identity() runs on BSSGP_ConnHdlr {
@@ -2153,6 +2157,23 @@
vc_conn.done;
 }

+
+/* Send LLC NULL to see if the SGSN survives it (OS#3952) */
+private function f_TC_llc_null(charstring id) runs on BSSGP_ConnHdlr {
+   f_gmm_attach(false, false);
+   f_sleep(1.0);
+   f_send_llc(ts_LLC_NULL('0'B, c_LLC_SAPI_LLGMM, LLC_CR_UL_CMD));
+   /* try to detach to check if SGSN is still alive */
+   f_detach_mo(c_GMM_DTT_MO_GPRS, true, true);
+}
+testcase TC_llc_null() runs on test_CT {
+   var BSSGP_ConnHdlr vc_conn;
+   f_init();
+   f_sleep(1.0);
+   vc_conn := f_start_handler(refers(f_TC_llc_null), testcasename(), g_gb, 
41);
+   vc_conn.done;
+}
+
 control {
execute( TC_attach() );
execute( TC_attach_mnc3() );
@@ -2197,6 +2218,8 @@
execute( TC_attach_pdp_act_deact_mt_t3395_expire() );
execute( TC_attach_pdp_act_user_error_ind_ggsn() );
execute( TC_attach_gmm_attach_req_while_gmm_attach() );
+
+   execute( TC_llc_null() );
 }



--
To view, visit https://gerrit.osmocom.org/13760
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I38326f2ebaaff009d4357edad9511ce2ce7736fd
Gerrit-Change-Number: 13760
Gerrit-PatchSet: 5
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Keith Whyte 


Change in osmo-ttcn3-hacks[master]: msc: Add testcase for UMTS AKA over GERAN TC_lu_imsi_auth3g_tmsi()

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13737 )

Change subject: msc: Add testcase for UMTS AKA over GERAN 
TC_lu_imsi_auth3g_tmsi()
..

msc: Add testcase for UMTS AKA over GERAN TC_lu_imsi_auth3g_tmsi()

Change-Id: I10cc7ed214e83b4624587c60f332034d3f19b22d
---
M msc/MSC_Tests.ttcn
1 file changed, 15 insertions(+), 0 deletions(-)

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



diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index 7d9c098..9a37fb0 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -652,6 +652,20 @@
vc_conn.done;
 }

+private function f_tc_lu_imsi_auth3g_tmsi(charstring id, BSC_ConnHdlrPars 
pars) runs on BSC_ConnHdlr {
+   pars.net.expect_auth := true;
+   pars.use_umts_aka := true;
+   f_init_handler(pars);
+   f_perform_lu();
+}
+testcase TC_lu_imsi_auth3g_tmsi() runs on MTC_CT {
+   var BSC_ConnHdlr vc_conn;
+   f_init();
+   f_vty_config(MSCVTY, "network", "authentication required");
+
+   vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi), 1005);
+   vc_conn.done;
+}

 /* Send CM SERVICE REQ for IMSI that has never performed LU before */
 private function f_tc_cmserv_imsi_unknown(charstring id, BSC_ConnHdlrPars pars)
@@ -4667,6 +4681,7 @@
execute( TC_lu_imsi_reject() );
execute( TC_lu_imsi_timeout_gsup() );
execute( TC_lu_imsi_auth_tmsi() );
+   execute( TC_lu_imsi_auth3g_tmsi() );
execute( TC_cmserv_imsi_unknown() );
execute( TC_lu_and_mo_call() );
execute( TC_lu_auth_sai_timeout() );

--
To view, visit https://gerrit.osmocom.org/13737
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I10cc7ed214e83b4624587c60f332034d3f19b22d
Gerrit-Change-Number: 13737
Gerrit-PatchSet: 3
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)


Change in osmo-ttcn3-hacks[master]: sgsn: Add test cases to verify SABM handling on LLGMM + LL5

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13766 )

Change subject: sgsn: Add test cases to verify SABM handling on LLGMM + LL5
..

sgsn: Add test cases to verify SABM handling on LLGMM + LL5

As OsmoSGSN doesn't implement ABM, the correct resposne to any SABM
is DM.

RelateD: OS#3953
Change-Id: Ib0d371a3356d6cb481b794945476ab40f5e0f02a
---
M sgsn/SGSN_Tests.ttcn
1 file changed, 36 insertions(+), 0 deletions(-)

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



diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn
index 78bee58..889a16f 100644
--- a/sgsn/SGSN_Tests.ttcn
+++ b/sgsn/SGSN_Tests.ttcn
@@ -2174,6 +2174,40 @@
vc_conn.done;
 }

+/* Send LLC SABM to see if the SGSN rejects it properly with DM */
+private function f_TC_llc_sabm_dm_llgmm(charstring id) runs on BSSGP_ConnHdlr {
+   f_gmm_attach(false, false);
+   f_sleep(1.0);
+   f_send_llc(ts_LLC_SABM({}, '1'B, c_LLC_SAPI_LLGMM, LLC_CR_UL_CMD));
+   BSSGP[0].receive(tr_BD_LLC(tr_LLC_DM(?, c_LLC_SAPI_LLGMM, 
LLC_CR_DL_RSP)));
+   setverdict(pass);
+}
+testcase TC_llc_sabm_dm_llgmm() runs on test_CT {
+   var BSSGP_ConnHdlr vc_conn;
+   f_init();
+   f_sleep(1.0);
+   vc_conn := f_start_handler(refers(f_TC_llc_sabm_dm_llgmm), 
testcasename(), g_gb, 42);
+   vc_conn.done;
+}
+
+/* Send LLC SABM to see if the SGSN rejects it properly with DM */
+private function f_TC_llc_sabm_dm_ll5(charstring id) runs on BSSGP_ConnHdlr {
+   f_gmm_attach(false, false);
+   f_sleep(1.0);
+   f_send_llc(ts_LLC_SABM({}, '1'B, c_LLC_SAPI_LL5, LLC_CR_UL_CMD));
+   BSSGP[0].receive(tr_BD_LLC(tr_LLC_DM(?, c_LLC_SAPI_LL5, 
LLC_CR_DL_RSP)));
+   setverdict(pass);
+}
+testcase TC_llc_sabm_dm_ll5() runs on test_CT {
+   var BSSGP_ConnHdlr vc_conn;
+   f_init();
+   f_sleep(1.0);
+   vc_conn := f_start_handler(refers(f_TC_llc_sabm_dm_ll5), 
testcasename(), g_gb, 43);
+   vc_conn.done;
+}
+
+
+
 control {
execute( TC_attach() );
execute( TC_attach_mnc3() );
@@ -2220,6 +2254,8 @@
execute( TC_attach_gmm_attach_req_while_gmm_attach() );

execute( TC_llc_null() );
+   execute( TC_llc_sabm_dm_llgmm() );
+   execute( TC_llc_sabm_dm_ll5() );
 }



--
To view, visit https://gerrit.osmocom.org/13766
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib0d371a3356d6cb481b794945476ab40f5e0f02a
Gerrit-Change-Number: 13766
Gerrit-PatchSet: 3
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)


Change in osmo-ttcn3-hacks[master]: deps/Makefile: Use osmocom fork of LLC protocol module

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13758 )

Change subject: deps/Makefile: Use osmocom fork of LLC protocol module
..

deps/Makefile: Use osmocom fork of LLC protocol module

Change-Id: I8b9f107f0a99dcbd8148a3d431a101d194dfe788
---
M deps/Makefile
1 file changed, 2 insertions(+), 2 deletions(-)

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



diff --git a/deps/Makefile b/deps/Makefile
index 7cf9300..6b19cf3 100644
--- a/deps/Makefile
+++ b/deps/Makefile
@@ -37,13 +37,13 @@
titan.ProtocolModules.GTP_v13.5.0 \
titan.ProtocolModules.GTPv2_v13.7.0 \
titan.ProtocolModules.ISUP_Q.762 \
-   titan.ProtocolModules.LLC_v7.1.0 \
titan.ProtocolModules.MobileL3_v13.4.0 \
titan.ProtocolModules.NS_v7.3.0 \
titan.ProtocolModules.SNDCP_v7.0.0 \
titan.ProtocolEmulations.SCCP

 OSMOGITHUB_REPOS=  titan.TestPorts.SCTPasp \
+   titan.ProtocolModules.LLC_v7.1.0 \
titan.ProtocolModules.SGsAP_13.2.0 \
titan.TestPorts.MTP3asp \
titan.ProtocolEmulations.M3UA
@@ -69,7 +69,7 @@
 titan.ProtocolModules.IP_commit=   R.10.B-1-g99d0ec9
 titan.ProtocolModules.ISUP_Q.762_commit=   R.8.A
 titan.ProtocolModules.L2TP_commit= R.2.A
-titan.ProtocolModules.LLC_v7.1.0_commit=   R.2.A
+titan.ProtocolModules.LLC_v7.1.0_commit=   
2a3c09fbf7bae22f802aa88689800f38a1f3732d
 titan.ProtocolModules.MAP_commit=  R.2.A-1-g79c6a3d
 titan.ProtocolModules.M2PA_commit= R.2.A
 titan.ProtocolModules.M3UA_commit= R.2.A

--
To view, visit https://gerrit.osmocom.org/13758
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I8b9f107f0a99dcbd8148a3d431a101d194dfe788
Gerrit-Change-Number: 13758
Gerrit-PatchSet: 4
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)


Change in osmo-ttcn3-hacks[master]: sgsn: Add test cases to verify SABM handling on LLGMM + LL5

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13766 )

Change subject: sgsn: Add test cases to verify SABM handling on LLGMM + LL5
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13766
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib0d371a3356d6cb481b794945476ab40f5e0f02a
Gerrit-Change-Number: 13766
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Thu, 25 Apr 2019 20:06:13 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-ttcn3-hacks[master]: sgsn: Add TC_llc_null to test if SGSN survives a LLC NULL packet

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13760 )

Change subject: sgsn: Add TC_llc_null to test if SGSN survives a LLC NULL packet
..


Patch Set 4: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13760
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I38326f2ebaaff009d4357edad9511ce2ce7736fd
Gerrit-Change-Number: 13760
Gerrit-PatchSet: 4
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Keith Whyte 
Gerrit-Comment-Date: Thu, 25 Apr 2019 20:06:11 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-ttcn3-hacks[master]: LLC_Templates: Add templates for NULL and DISC

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13759 )

Change subject: LLC_Templates: Add templates for NULL and DISC
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13759
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia5b350990379bba1677a0c1c99cf37e6651ba84d
Gerrit-Change-Number: 13759
Gerrit-PatchSet: 3
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Thu, 25 Apr 2019 20:05:39 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-ttcn3-hacks[master]: deps/Makefile: Use osmocom fork of LLC protocol module

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13758 )

Change subject: deps/Makefile: Use osmocom fork of LLC protocol module
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13758
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I8b9f107f0a99dcbd8148a3d431a101d194dfe788
Gerrit-Change-Number: 13758
Gerrit-PatchSet: 3
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Thu, 25 Apr 2019 20:05:34 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-msc[master]: libmsc/gsm_04_11.c: clarify implicit CP-ACK handling

2019-04-25 Thread Vadim Yanitskiy
Vadim Yanitskiy has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13633 )

Change subject: libmsc/gsm_04_11.c: clarify implicit CP-ACK handling
..

libmsc/gsm_04_11.c: clarify implicit CP-ACK handling

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

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



diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index 434f878..da0744a 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -1238,11 +1238,13 @@
LOG_TRANS(trans, LOGL_DEBUG, "receiving SMS message %s\n",
  gsm48_pdisc_msgtype_name(gsm48_hdr_pdisc(gh), 
gsm48_hdr_msg_type(gh)));

-   /* 5.4: For MO, if a CP-DATA is received for a new
-* transaction, equals reception of an implicit
-* last CP-ACK for previous transaction */
+   /* According to section 5.3.4, due to structure of message flow on
+* SAPI 0 and 3 it is possible that the CP-ACK of a short message
+* transfer might not be received. In this case the reception of
+* CP-DATA may be interpreted as the reception of the awaited
+* CP-ACK (implicit) and CP-DATA message. */
if (trans->sms.smc_inst.cp_state == GSM411_CPS_IDLE
-&& msg_type == GSM411_MT_CP_DATA) {
+   && msg_type == GSM411_MT_CP_DATA) {
int i;
struct gsm_trans *ptrans;


--
To view, visit https://gerrit.osmocom.org/13633
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3c5327a5019590c65d0ccb33a52f07b3988ea952
Gerrit-Change-Number: 13633
Gerrit-PatchSet: 2
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Vadim Yanitskiy 


Change in osmo-ttcn3-hacks[master]: LLC_Templates: Add SABM, UA, FRMR, DM templates

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13757 )

Change subject: LLC_Templates: Add SABM, UA, FRMR, DM templates
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13757
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Idb40dcd53310b76ea9df6c0090e31175a4382460
Gerrit-Change-Number: 13757
Gerrit-PatchSet: 3
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Thu, 25 Apr 2019 20:00:56 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-bts[master]: common/paging.c: fix unaligned pointer access

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13769 )

Change subject: common/paging.c: fix unaligned pointer access
..

common/paging.c: fix unaligned pointer access

Passing a pointer to a packed structure to tmsi_mi_to_uint() may
result in unaligned pointer value. Found with clang-8.

Change-Id: Ief69854973a098e6da7c05f4417dc11988edd777
---
M src/common/paging.c
1 file changed, 22 insertions(+), 6 deletions(-)

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



diff --git a/src/common/paging.c b/src/common/paging.c
index aa604e7..111f947 100644
--- a/src/common/paging.c
+++ b/src/common/paging.c
@@ -302,7 +302,9 @@
uint8_t cneed2, const uint8_t *identity3_lv)
 {
struct gsm48_paging2 *pt2 = (struct gsm48_paging2 *) out_buf;
+   uint32_t tmsi;
uint8_t *cur;
+   int rc;

memset(out_buf, 0, sizeof(*pt2));

@@ -311,8 +313,12 @@
pt2->pag_mode = GSM48_PM_NORMAL;
pt2->cneed1 = cneed1;
pt2->cneed2 = cneed2;
-   tmsi_mi_to_uint(>tmsi1, tmsi1_lv);
-   tmsi_mi_to_uint(>tmsi2, tmsi2_lv);
+   rc = tmsi_mi_to_uint(, tmsi1_lv);
+   if (rc == 0)
+   pt2->tmsi1 = tmsi;
+   rc = tmsi_mi_to_uint(, tmsi2_lv);
+   if (rc == 0)
+   pt2->tmsi2 = tmsi;
cur = out_buf + sizeof(*pt2);

if (identity3_lv)
@@ -329,6 +335,8 @@
const uint8_t *tmsi4_lv, uint8_t cneed4)
 {
struct gsm48_paging3 *pt3 = (struct gsm48_paging3 *) out_buf;
+   uint32_t tmsi;
+   int rc;

memset(out_buf, 0, sizeof(*pt3));

@@ -337,10 +345,18 @@
pt3->pag_mode = GSM48_PM_NORMAL;
pt3->cneed1 = cneed1;
pt3->cneed2 = cneed2;
-   tmsi_mi_to_uint(>tmsi1, tmsi1_lv);
-   tmsi_mi_to_uint(>tmsi2, tmsi2_lv);
-   tmsi_mi_to_uint(>tmsi3, tmsi3_lv);
-   tmsi_mi_to_uint(>tmsi4, tmsi4_lv);
+   rc = tmsi_mi_to_uint(, tmsi1_lv);
+   if (rc == 0)
+   pt3->tmsi1 = tmsi;
+   rc = tmsi_mi_to_uint(, tmsi2_lv);
+   if (rc == 0)
+   pt3->tmsi2 = tmsi;
+   rc = tmsi_mi_to_uint(, tmsi3_lv);
+   if (rc == 0)
+   pt3->tmsi3 = tmsi;
+   rc = tmsi_mi_to_uint(, tmsi4_lv);
+   if (rc == 0)
+   pt3->tmsi4 = tmsi;

/* The structure definition in libosmocore is wrong. It includes as last
 * byte some invalid definition of chneed3/chneed4, so we must do this 
by hand

--
To view, visit https://gerrit.osmocom.org/13769
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ief69854973a098e6da7c05f4417dc11988edd777
Gerrit-Change-Number: 13769
Gerrit-PatchSet: 2
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 


Change in osmo-sgsn[master]: gb_proxy: cosmetic: Use 'bool' in data structures where applicable

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13762 )

Change subject: gb_proxy: cosmetic: Use 'bool' in data structures where 
applicable
..


Patch Set 4: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13762
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I63876f52d5de87e4c99d92669270fd1f487e217c
Gerrit-Change-Number: 13762
Gerrit-PatchSet: 4
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Thu, 25 Apr 2019 20:00:23 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-sgsn[master]: gb_proxy: cosmetic: Use 'bool' in data structures where applicable

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13762 )

Change subject: gb_proxy: cosmetic: Use 'bool' in data structures where 
applicable
..

gb_proxy: cosmetic: Use 'bool' in data structures where applicable

If we ever only use 0/1 in an 'int', we should have used 'bool'.

Change-Id: I63876f52d5de87e4c99d92669270fd1f487e217c
---
M include/osmocom/sgsn/gb_proxy.h
M src/gprs/gb_proxy.c
M src/gprs/gb_proxy_patch.c
M src/gprs/gb_proxy_tlli.c
M src/gprs/gb_proxy_vty.c
5 files changed, 36 insertions(+), 35 deletions(-)

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



diff --git a/include/osmocom/sgsn/gb_proxy.h b/include/osmocom/sgsn/gb_proxy.h
index a3e1a02..1e8fb25 100644
--- a/include/osmocom/sgsn/gb_proxy.h
+++ b/include/osmocom/sgsn/gb_proxy.h
@@ -10,6 +10,7 @@

 #include 
 #include 
+#include 

 #define GBPROXY_INIT_VU_GEN_TX 256

@@ -83,7 +84,7 @@
 };

 struct gbproxy_match {
-   int   enable;   /* is this match enabled? */
+   bool  enable;   /* is this match enabled? */
char *re_str;   /* regular expression (for IMSI) in string 
format */
regex_t re_comp;/* compiled regular expression (for IMSI) */
 };
@@ -119,11 +120,11 @@
uint32_t stored_msgs_max_len;

/* Should the P-TMSI be patched on the fly (required for 2-SGSN config) 
*/
-   int patch_ptmsi;
+   bool patch_ptmsi;
/* Should the IMSI be acquired by the proxy (required for 2-SGSN 
config) */
-   int acquire_imsi;
+   bool acquire_imsi;
/* Should we route subscribers to two different SGSNs? */
-   int route_to_sgsn2;
+   bool route_to_sgsn2;
/* NSEI of the second SGSN */
uint16_t nsip_sgsn2_nsei;
/* should we keep a cache of per-subscriber state even after 
de-registration? */
@@ -154,7 +155,7 @@

/* BVCI used for Point-to-Point to this peer */
uint16_t bvci;
-   int blocked;
+   bool blocked;

/* Routeing Area that this peer is part of (raw 04.08 encoding) */
uint8_t ra[6];
@@ -175,9 +176,9 @@
/* newly-assigned TLLI (e.g. during P-TMSI allocation procedure) */
uint32_t assigned;
/* has the BSS side validated (confirmed) the new TLLI? */
-   int bss_validated;
+   bool bss_validated;
/* has the SGSN side validated (confirmed) the new TLLI? */
-   int net_validated;
+   bool net_validated;
/* NOTE: once both are validated, we set current = assigned and 
assigned = 0 */

/* The P-TMSI for this subscriber */
@@ -204,7 +205,7 @@
size_t imsi_len;

/* is the IMSI acquisition still pending? */
-   int imsi_acq_pending;
+   bool imsi_acq_pending;

/* queue of stored UL messages (until IMSI acquisition completes and we 
can
 * determine which of the SGSNs we should route this to */
@@ -215,10 +216,10 @@
unsigned vu_gen_tx_bss;

/* is this subscriber deregistered (TLLI invalidated)? */
-   int is_deregistered;
+   bool is_deregistered;

/* does this link match either the (2-SGSN) routing or the patching 
rule? */
-   int is_matching[GBPROX_MATCH_LAST];
+   bool is_matching[GBPROX_MATCH_LAST];
 };


diff --git a/src/gprs/gb_proxy.c b/src/gprs/gb_proxy.c
index 0b5758a..3da7bfd 100644
--- a/src/gprs/gb_proxy.c
+++ b/src/gprs/gb_proxy.c
@@ -310,7 +310,7 @@
in_progress = 1;

gbproxy_link_info_discard_messages(link_info);
-   link_info->imsi_acq_pending = 0;
+   link_info->imsi_acq_pending = false;

return in_progress;
 }
@@ -531,7 +531,7 @@
 * implementation relies on the MS doing proper retransmissions
 * of the triggering message instead */

-   link_info->imsi_acq_pending = 1;
+   link_info->imsi_acq_pending = true;
}

return 0;
@@ -836,11 +836,11 @@

switch (pdu_type) {
case BSSGP_PDUT_BVC_BLOCK_ACK:
-   peer->blocked = 1;
+   peer->blocked = true;
rate_ctr_inc(>ctrg->ctr[GBPROX_PEER_CTR_BLOCKED]);
break;
case BSSGP_PDUT_BVC_UNBLOCK_ACK:
-   peer->blocked = 0;
+   peer->blocked = false;
rate_ctr_inc(>ctrg->ctr[GBPROX_PEER_CTR_UNBLOCKED]);
break;
default:
diff --git a/src/gprs/gb_proxy_patch.c b/src/gprs/gb_proxy_patch.c
index 251bb67..6235b04 100644
--- a/src/gprs/gb_proxy_patch.c
+++ b/src/gprs/gb_proxy_patch.c
@@ -398,7 +398,7 @@
 {
if (match->enable) {
regfree(>re_comp);
-   match->enable = 0;
+   match->enable = false;
}
talloc_free(match->re_str);
match->re_str = NULL;
@@ -419,7 +419,7 @@
 REG_EXTENDED | 

Change in osmo-sgsn[master]: LLC: Store the XID inside the LLC Entity, not LLC Mgmg Entity

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13623 )

Change subject: LLC: Store the XID inside the LLC Entity, not LLC Mgmg Entity
..

LLC: Store the XID inside the LLC Entity, not LLC Mgmg Entity

For every logical session between a MS and the SGSN, there is one LLME
(LLC Management Entity) and a set of LLEs (Logical Link Entities): One
for each SAPI.

The XID procedure used to establish LLC configuration values such as
N201 (MTU) parameters happens on each LLE separately. The negotiated
parameters only affect that one LLE (SAPI) and are not global.

Still, the OsmoSGSN LLC code has the "struct llist_head *xid" member as
part of the gprs_llc_llme, and not as part of the gprs_llc_lle. This
list is a cache of the XID fields we have sent with the last XID
request, which is used in processing the response from the MS.

If two XID handshakes were to occur concurrently on two LLEs, the state
between them would get messed up. It must be maintained separately for
each LLE.

Closes: OS#3955
Change-Id: Iaeb54ca5ac58391be45e56c2e721f531969f3a9e
---
M include/osmocom/sgsn/gprs_llc.h
M src/gprs/gprs_llc.c
M src/gprs/gprs_sndcp.c
3 files changed, 25 insertions(+), 26 deletions(-)

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



diff --git a/include/osmocom/sgsn/gprs_llc.h b/include/osmocom/sgsn/gprs_llc.h
index 376ae9a..711bcd6 100644
--- a/include/osmocom/sgsn/gprs_llc.h
+++ b/include/osmocom/sgsn/gprs_llc.h
@@ -145,6 +145,13 @@
unsigned int retrans_ctr;

struct gprs_llc_params params;
+
+   /* Copy of the XID fields we have sent with the last
+* network originated XID-Request. Since the phone
+* may strip the optional fields in the confirmation
+* we need to remeber those fields in order to be
+* able to create the compression entity. */
+   struct llist_head *xid;
 };

 #define NUM_SAPIS  16
@@ -169,13 +176,6 @@
uint16_t nsei;
struct gprs_llc_lle lle[NUM_SAPIS];

-   /* Copy of the XID fields we have sent with the last
-* network originated XID-Request. Since the phone
-* may strip the optional fields in the confirmation
-* we need to remeber those fields in order to be
-* able to create the compression entity. */
-   struct llist_head *xid;
-
/* Compression entities */
struct {
/* In these two list_heads we will store the
diff --git a/src/gprs/gprs_llc.c b/src/gprs/gprs_llc.c
index 2ec7100..acf4b54 100644
--- a/src/gprs/gprs_llc.c
+++ b/src/gprs/gprs_llc.c
@@ -53,7 +53,7 @@
 /* Generate XID message */
 static int gprs_llc_generate_xid(uint8_t *bytes, int bytes_len,
 struct gprs_llc_xid_field *l3_xid_field,
-struct gprs_llc_llme *llme)
+struct gprs_llc_lle *lle)
 {
/* Note: Called by gprs_ll_xid_req() */

@@ -90,8 +90,8 @@
}

/* Store generated XID for later reference */
-   talloc_free(llme->xid);
-   llme->xid = gprs_llc_copy_xid(llme, _fields);
+   talloc_free(lle->xid);
+   lle->xid = gprs_llc_copy_xid(lle->llme, _fields);

return gprs_llc_compile_xid(bytes, bytes_len, _fields);
 }
@@ -99,7 +99,7 @@
 /* Generate XID message that will cause the GMM to reset */
 static int gprs_llc_generate_xid_for_gmm_reset(uint8_t *bytes,
   int bytes_len, uint32_t iov_ui,
-  struct gprs_llc_llme *llme)
+  struct gprs_llc_lle *lle)
 {
/* Called by gprs_llgmm_reset() and
 * gprs_llgmm_reset_oldmsg() */
@@ -124,8 +124,8 @@
llist_add(_reset.list, _fields);

/* Store generated XID for later reference */
-   talloc_free(llme->xid);
-   llme->xid = gprs_llc_copy_xid(llme, _fields);
+   talloc_free(lle->xid);
+   lle->xid = gprs_llc_copy_xid(lle->llme, _fields);

return gprs_llc_compile_xid(bytes, bytes_len, _fields);
 }
@@ -144,8 +144,8 @@
struct gprs_llc_xid_field *xid_field_request_l3 = NULL;

/* Pick layer3 XID from the XID request we have sent last */
-   if (lle->llme->xid) {
-   llist_for_each_entry(xid_field_request, lle->llme->xid, list) {
+   if (lle->xid) {
+   llist_for_each_entry(xid_field_request, lle->xid, list) {
if (xid_field_request->type == GPRS_LLC_XID_T_L3_PAR)
xid_field_request_l3 = xid_field_request;
}
@@ -189,8 +189,8 @@
}

/* Flush pending XID fields */
-   talloc_free(lle->llme->xid);
-   lle->llme->xid = NULL;
+   talloc_free(lle->xid);
+   lle->xid = NULL;

return 0;
 }
@@ -325,8 +325,7 

Change in osmo-sgsn[master]: gb_proxy.h: Add missing comments; improve comments

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13761 )

Change subject: gb_proxy.h: Add missing comments; improve comments
..


Patch Set 4: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13761
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I61bdd3b1cec037bce825c234a8a274b70629adc8
Gerrit-Change-Number: 13761
Gerrit-PatchSet: 4
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Thu, 25 Apr 2019 20:00:06 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-bts[master]: common/rsl.c: fix unaligned pointers in rsl_add_rtp_stats()

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13768 )

Change subject: common/rsl.c: fix unaligned pointers in rsl_add_rtp_stats()
..

common/rsl.c: fix unaligned pointers in rsl_add_rtp_stats()

Found using clang-8:

  rsl.c:1646:7: warning: taking address of packed member 'packets_sent'
of class or structure 'ipa_stats' may result in an
unaligned pointer value
  rsl.c:1646:28: warning: taking address of packed member 'octets_sent'
 of class or structure 'ipa_stats' may result in an
 unaligned pointer value
  rsl.c:1647:7: warning: taking address of packed member 'packets_recv'
of class or structure 'ipa_stats' may result in an
unaligned pointer value
  rsl.c:1647:28: warning: taking address of packed member 'octets_recv'
 of class or structure 'ipa_stats' may result in an
 unaligned pointer value
  rsl.c:1648:7: warning: taking address of packed member 'packets_lost'
of class or structure 'ipa_stats' may result in an
unaligned pointer value
  rsl.c:1648:28: warning: taking address of packed member 'arrival_jitter'
 of class or structure 'ipa_stats' may result in an
 unaligned pointer value

Change-Id: Ifba33cfd8edeccc99a21c7d076db7119c29d4f40
---
M src/common/rsl.c
1 file changed, 23 insertions(+), 23 deletions(-)

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



diff --git a/src/common/rsl.c b/src/common/rsl.c
index 8f5d689..c2a7db6 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -1627,33 +1627,33 @@
  */
 static void rsl_add_rtp_stats(struct gsm_lchan *lchan, struct msgb *msg)
 {
-   struct ipa_stats {
-   uint32_t packets_sent;
-   uint32_t octets_sent;
-   uint32_t packets_recv;
-   uint32_t octets_recv;
-   uint32_t packets_lost;
-   uint32_t arrival_jitter;
-   uint32_t avg_tx_delay;
-   } __attribute__((packed));
+   uint32_t packets_sent, octets_sent;
+   uint32_t packets_recv, octets_recv;
+   uint32_t packets_lost;
+   uint32_t arrival_jitter;

-   struct ipa_stats stats;
+   msgb_tv_put(msg, RSL_IE_IPAC_CONN_STAT, sizeof(uint32_t) * 7);

-   memset(, 0, sizeof(stats));
-
-   if (lchan->abis_ip.rtp_socket)
+   if (lchan->abis_ip.rtp_socket) {
osmo_rtp_socket_stats(lchan->abis_ip.rtp_socket,
-   _sent, _sent,
-   _recv, _recv,
-   _lost, 
_jitter);
-   /* convert to network byte order */
-   stats.packets_sent = htonl(stats.packets_sent);
-   stats.octets_sent = htonl(stats.octets_sent);
-   stats.packets_recv = htonl(stats.packets_recv);
-   stats.octets_recv = htonl(stats.octets_recv);
-   stats.packets_lost = htonl(stats.packets_lost);
+ _sent, _sent,
+ _recv, _recv,
+ _lost, _jitter);

-   msgb_tlv_put(msg, RSL_IE_IPAC_CONN_STAT, sizeof(stats), (uint8_t *) 
);
+   /* msgb_put_u32() uses osmo_store32be(),
+* so we don't need to call htonl(). */
+   msgb_put_u32(msg, packets_sent);
+   msgb_put_u32(msg, octets_sent);
+   msgb_put_u32(msg, packets_recv);
+   msgb_put_u32(msg, octets_recv);
+   msgb_put_u32(msg, packets_lost);
+   msgb_put_u32(msg, arrival_jitter);
+   /* FIXME: AVG Tx delay is always 0 */
+   msgb_put_u32(msg, 0);
+   } else {
+   msgb_put(msg, sizeof(uint32_t) * 7);
+   memset(msg->tail, 0x00, sizeof(uint32_t) * 7);
+   }
 }

 int rsl_tx_ipac_dlcx_ind(struct gsm_lchan *lchan, uint8_t cause)

--
To view, visit https://gerrit.osmocom.org/13768
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifba33cfd8edeccc99a21c7d076db7119c29d4f40
Gerrit-Change-Number: 13768
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Vadim Yanitskiy 


Change in osmo-sgsn[master]: gb_proxy.h: Add missing comments; improve comments

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13761 )

Change subject: gb_proxy.h: Add missing comments; improve comments
..

gb_proxy.h: Add missing comments; improve comments

When the patching and routing features were introduced, a lot of the
new structures were not documented at the same level as the pre-existing
code.  Let's fix that.

Change-Id: I61bdd3b1cec037bce825c234a8a274b70629adc8
---
M include/osmocom/sgsn/gb_proxy.h
1 file changed, 46 insertions(+), 13 deletions(-)

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



diff --git a/include/osmocom/sgsn/gb_proxy.h b/include/osmocom/sgsn/gb_proxy.h
index 7e2ae42..a3e1a02 100644
--- a/include/osmocom/sgsn/gb_proxy.h
+++ b/include/osmocom/sgsn/gb_proxy.h
@@ -70,29 +70,30 @@
 };

 enum gbproxy_keep_mode {
-   GBPROX_KEEP_NEVER,
-   GBPROX_KEEP_REATTACH,
-   GBPROX_KEEP_IDENTIFIED,
-   GBPROX_KEEP_ALWAYS,
+   GBPROX_KEEP_NEVER,  /* don't ever keep TLLI/IMSI state of 
de-registered subscribers */
+   GBPROX_KEEP_REATTACH,   /* keep if re-attach has been requested by SGSN 
*/
+   GBPROX_KEEP_IDENTIFIED, /* keep if we had resolved an IMSI */
+   GBPROX_KEEP_ALWAYS, /* always keep */
 };

 enum gbproxy_match_id {
-   GBPROX_MATCH_PATCHING,
-   GBPROX_MATCH_ROUTING,
+   GBPROX_MATCH_PATCHING,  /* match rule on whether or not we should patch 
*/
+   GBPROX_MATCH_ROUTING,   /* match rule on whether or not we should route 
(2-SGSN) */
GBPROX_MATCH_LAST
 };

 struct gbproxy_match {
-   int   enable;
-   char *re_str;
-   regex_t re_comp;
+   int   enable;   /* is this match enabled? */
+   char *re_str;   /* regular expression (for IMSI) in string 
format */
+   regex_t re_comp;/* compiled regular expression (for IMSI) */
 };

+/* global gb-proxy configuration */
 struct gbproxy_config {
/* parsed from config file */
uint16_t nsip_sgsn_nsei;

-   /* misc */
+   /* NS instance of libosmogb */
struct gprs_ns_inst *nsi;

/* Linked list of all Gb peers (except SGSN) */
@@ -101,10 +102,13 @@
/* Counter */
struct rate_ctr_group *ctrg;

-   /* force mcc/mnc */
+   /* MCC/MNC to be patched into RA-ID on the way from BSS to SGSN? */
struct osmo_plmn_id core_plmn;
+
+   /* APN to be patched into PDP CTX ACT REQ on the way from BSS to SGSN */
uint8_t* core_apn;
size_t core_apn_size;
+
/* Frequency (sec) at which timer to clean stale links is fired (0 
disabled) */
unsigned int clean_stale_timer_freq;
/* If !0, Max age to consider a struct gbproxy_link_info as stale */
@@ -114,14 +118,18 @@
/* If !0, Max len of gbproxy_link_info->stored_msgs (list of msgb) */
uint32_t stored_msgs_max_len;

-   /* Experimental config */
+   /* Should the P-TMSI be patched on the fly (required for 2-SGSN config) 
*/
int patch_ptmsi;
+   /* Should the IMSI be acquired by the proxy (required for 2-SGSN 
config) */
int acquire_imsi;
+   /* Should we route subscribers to two different SGSNs? */
int route_to_sgsn2;
+   /* NSEI of the second SGSN */
uint16_t nsip_sgsn2_nsei;
+   /* should we keep a cache of per-subscriber state even after 
de-registration? */
enum gbproxy_keep_mode keep_link_infos;

-   /* IMSI checking/matching */
+   /* IMSI checking/matching for 2-SGSN routing and patching */
struct gbproxy_match matches[GBPROX_MATCH_LAST];
 };

@@ -133,7 +141,9 @@
int logical_link_count;
 };

+/* one peer at NS level that we interact with (BSS/PCU) */
 struct gbproxy_peer {
+   /* linked to gbproxy_config.bts_peers */
struct llist_head list;

/* point back to the config */
@@ -152,6 +162,7 @@
/* Counter */
struct rate_ctr_group *ctrg;

+   /* State related to on-the-fly patching of certain messages */
struct gbproxy_patch_state patch_state;

/* Fired periodically to clean up stale links from list */
@@ -159,32 +170,54 @@
 };

 struct gbproxy_tlli_state {
+   /* currently active TLLI */
uint32_t current;
+   /* newly-assigned TLLI (e.g. during P-TMSI allocation procedure) */
uint32_t assigned;
+   /* has the BSS side validated (confirmed) the new TLLI? */
int bss_validated;
+   /* has the SGSN side validated (confirmed) the new TLLI? */
int net_validated;
+   /* NOTE: once both are validated, we set current = assigned and 
assigned = 0 */

+   /* The P-TMSI for this subscriber */
uint32_t ptmsi;
 };

+/* One TLLI (= UE, = Subscriber) served via this proxy */
 struct gbproxy_link_info {
+   /* link to gbproxy_peer.patch_state.logical_links */
struct 

Change in osmo-sgsn[master]: LLC: Store the XID inside the LLC Entity, not LLC Mgmg Entity

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13623 )

Change subject: LLC: Store the XID inside the LLC Entity, not LLC Mgmg Entity
..


Patch Set 4: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13623
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Iaeb54ca5ac58391be45e56c2e721f531969f3a9e
Gerrit-Change-Number: 13623
Gerrit-PatchSet: 4
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Thu, 25 Apr 2019 19:59:55 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-mgw[master]: Introduce log fmt helpers LOGPENDP and LOGPCONN

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13773 )

Change subject: Introduce log fmt helpers LOGPENDP and LOGPCONN
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13773
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1c49b1eb16bc5f1010376da5cf407ca6e31d81f2
Gerrit-Change-Number: 13773
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Thu, 25 Apr 2019 19:59:21 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-sgsn[master]: gprs_llc: Correctly refuse any ABM command (SABM, DISC) with DM

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13767 )

Change subject: gprs_llc: Correctly refuse any ABM command (SABM, DISC) with DM
..

gprs_llc: Correctly refuse any ABM command (SABM, DISC) with DM

According to Section 6.4.1.4 of 3GPP TS 04.64
The DM unnumbered response shall be used by an LLE to report to
its peer that the LLE is in a state such that ABM operation
cannot be performed. An LLE shall transmit a DM response to any
valid command received that it cannot action.

Closes: OS#3953
Change-Id: Ie8b8e16d5a68f19f21dc4fdb5703c8a794e0173c
---
M src/gprs/gprs_llc.c
1 file changed, 22 insertions(+), 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/gprs/gprs_llc.c b/src/gprs/gprs_llc.c
index 654f2c0..2ec7100 100644
--- a/src/gprs/gprs_llc.c
+++ b/src/gprs/gprs_llc.c
@@ -44,6 +44,7 @@
 static struct gprs_llc_llme *llme_alloc(uint32_t tlli);
 static int gprs_llc_tx_xid(struct gprs_llc_lle *lle, struct msgb *msg,
   int command);
+static int gprs_llc_tx_dm(struct gprs_llc_lle *lle);
 static int gprs_llc_tx_u(struct msgb *msg, uint8_t sapi,
 int command, enum gprs_llc_u_cmd u_cmd, int pf_bit);

@@ -676,6 +677,18 @@
return gprs_llc_tx_u(msg, lle->sapi, command, GPRS_LLC_U_XID, 1);
 }

+static int gprs_llc_tx_dm(struct gprs_llc_lle *lle)
+{
+   struct msgb *msg = msgb_alloc_headroom(4096, 1024, "LLC_DM");
+
+   /* copy identifiers from LLE to ensure lower layers can route */
+   msgb_tlli(msg) = lle->llme->tlli;
+   msgb_bvci(msg) = lle->llme->bvci;
+   msgb_nsei(msg) = lle->llme->nsei;
+
+   return gprs_llc_tx_u(msg, lle->sapi, 0, GPRS_LLC_U_DM_RESP, 1);
+}
+
 /* encrypt information field + FCS, if needed! */
 static int apply_gea(struct gprs_llc_lle *lle, uint16_t crypt_len, uint16_t nu,
 uint32_t oc, uint8_t sapi, uint8_t *fcs, uint8_t *data)
@@ -802,6 +815,8 @@
   struct gprs_llc_lle *lle)
 {
switch (gph->cmd) {
+#if 0
+   /* we don't fully imoplement ABM, so refuse it properly (OS#3953) */
case GPRS_LLC_SABM: /* Section 6.4.1.1 */
lle->v_sent = lle->v_ack = lle->v_recv = 0;
if (lle->state == GPRS_LLES_ASSIGNED_ADM) {
@@ -827,6 +842,13 @@
break;
case GPRS_LLC_FRMR: /* Section 6.4.1.5 */
break;
+#else
+   case GPRS_LLC_SABM:
+   case GPRS_LLC_DISC:
+   /* send DM to properly signal we don't do ABM */
+   gprs_llc_tx_dm(lle);
+   break;
+#endif
case GPRS_LLC_XID: /* Section 6.4.1.6 */
rx_llc_xid(lle, gph);
break;

--
To view, visit https://gerrit.osmocom.org/13767
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie8b8e16d5a68f19f21dc4fdb5703c8a794e0173c
Gerrit-Change-Number: 13767
Gerrit-PatchSet: 3
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Vadim Yanitskiy 


Change in osmo-sgsn[master]: gprs_llc: Correctly refuse any ABM command (SABM, DISC) with DM

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13767 )

Change subject: gprs_llc: Correctly refuse any ABM command (SABM, DISC) with DM
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13767
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie8b8e16d5a68f19f21dc4fdb5703c8a794e0173c
Gerrit-Change-Number: 13767
Gerrit-PatchSet: 3
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Comment-Date: Thu, 25 Apr 2019 19:59:37 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-mgw[master]: osmux: Cleanup of CID alloc pool APIs

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13774 )

Change subject: osmux: Cleanup of CID alloc pool APIs
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13774
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I737a248ac6c74add8e917fe2e2f36779d0f1d685
Gerrit-Change-Number: 13774
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Thu, 25 Apr 2019 19:57:31 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-sgsn[master]: gprs_gmm: send Service Reject when no PDP ctxs are available.

2019-04-25 Thread lynxis lazus
lynxis lazus has posted comments on this change. ( 
https://gerrit.osmocom.org/13744 )

Change subject: gprs_gmm: send Service Reject when no PDP ctxs are available.
..


Patch Set 6:

(1 comment)

https://gerrit.osmocom.org/#/c/13744/6/src/gprs/gprs_gmm.c
File src/gprs/gprs_gmm.c:

https://gerrit.osmocom.org/#/c/13744/6/src/gprs/gprs_gmm.c@1935
PS6, Line 1935: reject_cause = 
GMM_CAUSE_NO_PDP_ACTIVATED;
> If you sent the GMM_CAUSE_NO_PDP_ACTIVATED: […]
At the moment you check if the MS & SGSN is out of sync.
But if you on check if there are no PDP Contexts on SGSN, you can directly sent 
this reject_cause.



--
To view, visit https://gerrit.osmocom.org/13744
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If610cbef17c25ec44e65d4f1b2340d102c560437
Gerrit-Change-Number: 13744
Gerrit-PatchSet: 6
Gerrit-Owner: Mykola Shchetinin 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Mykola Shchetinin 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Comment-Date: Thu, 25 Apr 2019 19:56:12 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in osmo-mgw[master]: create_response_with_sdp: Fix inclusion of X-Osmux

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13775 )

Change subject: create_response_with_sdp: Fix inclusion of X-Osmux
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13775
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Iceee8b64978651f1fe6bb883923561b081f73d9b
Gerrit-Change-Number: 13775
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Thu, 25 Apr 2019 19:56:03 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in openbsc[master]: osmo-bsc_nat: Parse MGCP Connection ID as hex

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13778 )

Change subject: osmo-bsc_nat: Parse MGCP Connection ID as hex
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13778
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I49b8b61644bf706162102dce268cae2265536fc5
Gerrit-Change-Number: 13778
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Willmann 
Gerrit-Reviewer: Daniel Willmann 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: dexter 
Gerrit-Comment-Date: Thu, 25 Apr 2019 19:55:09 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in openbsc[master]: osmo-bsc_nat: Parse MGCP Connection ID as hex

2019-04-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13778 )

Change subject: osmo-bsc_nat: Parse MGCP Connection ID as hex
..

osmo-bsc_nat: Parse MGCP Connection ID as hex

Our ttcn3-bscnat-tests would randomly fail. After the CRCX ACK returns
from the MSC the bsc-nat reports it could not find a CI it it and
deletes the connection on the BSC-side.

This happens because the field is parsed as a decimal value instead of
hexadecimal. So a value of 00FED122 is parsed as '0' which is a reserved
value in our program.

This fix parses the field as hexadecimal value and also logs an error if
the value happens to be 0.

make check will now test if a hexadecimal CI is parsed correctly.

Fixes: OS#3951
Change-Id: I49b8b61644bf706162102dce268cae2265536fc5
---
M openbsc/src/libmgcp/mgcp_protocol.c
M openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
M openbsc/tests/bsc-nat/bsc_data.c
M openbsc/tests/bsc-nat/bsc_nat_test.c
4 files changed, 11 insertions(+), 8 deletions(-)

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



diff --git a/openbsc/src/libmgcp/mgcp_protocol.c 
b/openbsc/src/libmgcp/mgcp_protocol.c
index 84dbc1f..689c91f 100644
--- a/openbsc/src/libmgcp/mgcp_protocol.c
+++ b/openbsc/src/libmgcp/mgcp_protocol.c
@@ -208,7 +208,7 @@

len = snprintf(sdp_record, size,
"v=0\r\n"
-   "o=- %u 23 IN IP4 %s\r\n"
+   "o=- %x 23 IN IP4 %s\r\n"
"s=-\r\n"
"c=IN IP4 %s\r\n"
"t=0 0\r\n",
@@ -285,7 +285,7 @@
}

len = snprintf(sdp_record, sizeof(sdp_record),
-  "I: %u%s\n\n", endp->ci, osmux_extension);
+  "I: %x%s\n\n", endp->ci, osmux_extension);
if (len < 0)
return NULL;

@@ -512,7 +512,7 @@
uint32_t ci = strtoul(_ci, NULL, 10);

if (ci != endp->ci) {
-   LOGP(DMGCP, LOGL_ERROR, "ConnectionIdentifiers do not match on 
0x%x. %u != %s\n",
+   LOGP(DMGCP, LOGL_ERROR, "ConnectionIdentifiers do not match on 
0x%x. %x != %x\n",
ENDPOINT_NUMBER(endp), endp->ci, _ci);
return -1;
}
@@ -891,7 +891,7 @@
osmo_jibuf_set_dequeue_cb(endp->bts_jb, mgcp_dejitter_udp_send, 
>net_end);
}

-   LOGP(DMGCP, LOGL_DEBUG, "Creating endpoint on: 0x%x CI: %u port: 
%u/%u\n",
+   LOGP(DMGCP, LOGL_DEBUG, "Creating endpoint on: 0x%x CI: %x port: 
%u/%u\n",
ENDPOINT_NUMBER(endp), endp->ci,
endp->net_end.local_port, endp->bts_end.local_port);
if (p->cfg->change_cb)
diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c 
b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
index 311ab94..17dc659 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
@@ -812,11 +812,14 @@
return CI_UNUSED;
}

-   if (sscanf(res, "I: %u", ) != 1) {
+   if (sscanf(res, "I: %x", ) != 1) {
LOGP(DMGCP, LOGL_ERROR, "Failed to parse CI in msg '%s'\n", 
str);
return CI_UNUSED;
}

+   if (ci == CI_UNUSED)
+   LOGP(DMGCP, LOGL_ERROR, "CI field '%s' parsed as reserved value 
CI_UNUSED\n", str);
+
return ci;
 }

diff --git a/openbsc/tests/bsc-nat/bsc_data.c b/openbsc/tests/bsc-nat/bsc_data.c
index 71d5391..d29caef 100644
--- a/openbsc/tests/bsc-nat/bsc_data.c
+++ b/openbsc/tests/bsc-nat/bsc_data.c
@@ -157,8 +157,8 @@


 /* patch the ip and port */
-static const char crcx_resp[] = "200 23265295\r\nI: 1\r\n\r\nv=0\r\nc=IN IP4 
172.16.18.2\r\nm=audio 4002 RTP/AVP 98 3\r\na=rtpmap:98 AMR/8000\r\n";
-static const char crcx_resp_patched[] = "200 23265295\r\nI: 
1\r\n\r\nv=0\r\nc=IN IP4 10.0.0.1\r\nm=audio 999 RTP/AVP 98 3\r\na=rtpmap:98 
AMR/8000\r\na=fmtp:98 mode-set=2 octet-align=1\r\n";
+static const char crcx_resp[] = "200 23265295\r\nI: 0F\r\n\r\nv=0\r\nc=IN IP4 
172.16.18.2\r\nm=audio 4002 RTP/AVP 98 3\r\na=rtpmap:98 AMR/8000\r\n";
+static const char crcx_resp_patched[] = "200 23265295\r\nI: 
0F\r\n\r\nv=0\r\nc=IN IP4 10.0.0.1\r\nm=audio 999 RTP/AVP 98 3\r\na=rtpmap:98 
AMR/8000\r\na=fmtp:98 mode-set=2 octet-align=1\r\n";

 /* patch the ip and port */
 static const char mdcx[] = "MDCX 23330829 8@mgw MGCP 1.0\r\nC: 
394b0439fb\r\nI: 1\r\nL: p:20, a:AMR, nt:IN\r\nM: recvonly\r\n\r\nv=0\r\no=- 
1049380491 0 IN IP4 172.16.18.2\r\ns=-\r\nc=IN IP4 172.16.18.2\r\nt=0 
0\r\nm=audio 4410 RTP/AVP 126\r\na=rtpmap:126 AMR/8000/1\r\na=fmtp:126 
mode-set=2  octet-align=1;start-mode=0\r\na=ptime:20\r\na=recvonly\r\nm=image 
4412 udptl t38\r\na=T38FaxVersion:0\r\na=T38MaxBitRate:14400\r\n";
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c 
b/openbsc/tests/bsc-nat/bsc_nat_test.c
index 2914a01..e0d0051 100644
--- 

Change in osmo-sgsn[master]: gprs_gmm: send Service Reject when no PDP ctxs are available.

2019-04-25 Thread lynxis lazus
lynxis lazus has posted comments on this change. ( 
https://gerrit.osmocom.org/13744 )

Change subject: gprs_gmm: send Service Reject when no PDP ctxs are available.
..


Patch Set 6: Code-Review-1

(1 comment)

https://gerrit.osmocom.org/#/c/13744/6/src/gprs/gprs_gmm.c
File src/gprs/gprs_gmm.c:

https://gerrit.osmocom.org/#/c/13744/6/src/gprs/gprs_gmm.c@1935
PS6, Line 1935: reject_cause = 
GMM_CAUSE_NO_PDP_ACTIVATED;
If you sent the GMM_CAUSE_NO_PDP_ACTIVATED:
You have to disable all PDP Context active on the SGSN side _without_ 
communicating with the MS. This means the SGSN must talk to the GGSN to disable 
the PDP Contexts and remove also the internal state of all active PDP Contexts.
The MS will invalidate all PDP Contexts when receiving this cause code.

There is also another solution, you could try to do the RAB asignment and if 
there are missing RAB, accept the service request and attach a 
GMM_PDP_CTX_STATUS IE to it. The MS will use this Status and discard all 
non-listed PDP Contexts. Now the MS & SGSN is in sync again.



--
To view, visit https://gerrit.osmocom.org/13744
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If610cbef17c25ec44e65d4f1b2340d102c560437
Gerrit-Change-Number: 13744
Gerrit-PatchSet: 6
Gerrit-Owner: Mykola Shchetinin 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Mykola Shchetinin 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: lynxis lazus 
Gerrit-Comment-Date: Thu, 25 Apr 2019 19:49:00 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: Yes


Change in osmo-msc[master]: libmsc/gsm_04_11.c: clarify implicit CP-ACK handling

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13633 )

Change subject: libmsc/gsm_04_11.c: clarify implicit CP-ACK handling
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13633
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3c5327a5019590c65d0ccb33a52f07b3988ea952
Gerrit-Change-Number: 13633
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Thu, 25 Apr 2019 19:54:43 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-ccid-firmware[master]: configure GCLK for ISO baud rates

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13781 )

Change subject: configure GCLK for ISO baud rates
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13781
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I2c69848582e49031fa6453f535a2bf1408f8e22e
Gerrit-Change-Number: 13781
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Thu, 25 Apr 2019 19:51:04 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in docker-playground[master]: Add OSMO_*_BRANCH environment variables for build args

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13779 )

Change subject: Add OSMO_*_BRANCH environment variables for build args
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13779
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If3bc5fae07cf63c4fef68306be4c4328660bc869
Gerrit-Change-Number: 13779
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Willmann 
Gerrit-Reviewer: Daniel Willmann 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: osmith 
Gerrit-Comment-Date: Thu, 25 Apr 2019 19:53:08 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-ccid-firmware[master]: output 50 MHz for RMII

2019-04-25 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13780 )

Change subject: output 50 MHz for RMII
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13780
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id3a3dee15c3986536b0623d0f39ca62e94acd1fd
Gerrit-Change-Number: 13780
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Thu, 25 Apr 2019 19:50:20 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-msc[master]: configure.ac: drop useless SQLite3 dependency

2019-04-25 Thread Vadim Yanitskiy
Vadim Yanitskiy has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13639 )

Change subject: configure.ac: drop useless SQLite3 dependency
..

configure.ac: drop useless SQLite3 dependency

We don't use SQLite3 directly, we use libdbi and libdbdsqlite3.

Change-Id: Ibf4eb53e60a2957eca99a2c8e613f75a8c43ac89
---
M configure.ac
M src/utils/Makefile.am
2 files changed, 0 insertions(+), 6 deletions(-)

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



diff --git a/configure.ac b/configure.ac
index e500375..8ab6021 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,11 +112,6 @@
 AC_HEADER_STDC
 AC_CHECK_HEADERS(dbi/dbd.h,,AC_MSG_ERROR(DBI library is not installed))

-found_sqlite3=yes
-PKG_CHECK_MODULES(SQLITE3, sqlite3, ,found_sqlite3=no)
-AM_CONDITIONAL(HAVE_SQLITE3, test "$found_sqlite3" = yes)
-AC_SUBST(found_sqlite3)
-

 dnl Checks for typedefs, structures and compiler characteristics
 AX_CHECK_COMPILE_FLAG([-Werror=implicit], [CFLAGS="$CFLAGS -Werror=implicit"])
diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am
index 2d67102..cb0faf6 100644
--- a/src/utils/Makefile.am
+++ b/src/utils/Makefile.am
@@ -10,7 +10,6 @@
$(LIBOSMOGSM_CFLAGS) \
$(LIBOSMOABIS_CFLAGS) \
$(COVERAGE_CFLAGS) \
-   $(SQLITE3_CFLAGS) \
$(LIBSMPP34_CFLAGS) \
$(NULL)


--
To view, visit https://gerrit.osmocom.org/13639
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibf4eb53e60a2957eca99a2c8e613f75a8c43ac89
Gerrit-Change-Number: 13639
Gerrit-PatchSet: 2
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 


Change in osmo-msc[master]: libmsc/db.c: print info about database name and libdbi version

2019-04-25 Thread Vadim Yanitskiy
Vadim Yanitskiy has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13641 )

Change subject: libmsc/db.c: print info about database name and libdbi version
..

libmsc/db.c: print info about database name and libdbi version

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

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



diff --git a/src/libmsc/db.c b/src/libmsc/db.c
index 0384320..a9aaf94 100644
--- a/src/libmsc/db.c
+++ b/src/libmsc/db.c
@@ -615,6 +615,9 @@
 {
dbi_initialize_r(NULL, );

+   LOGP(DDB, LOGL_NOTICE, "Init database connection to '%s' using %s\n",
+name, dbi_version());
+
conn = dbi_conn_new_r("sqlite3", inst);
if (conn == NULL) {
LOGP(DDB, LOGL_FATAL, "Failed to create database connection to 
sqlite3 db '%s'; "

--
To view, visit https://gerrit.osmocom.org/13641
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaed452548eb2d847738b78d3489bf6f507a2e3c1
Gerrit-Change-Number: 13641
Gerrit-PatchSet: 2
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 


Change in osmo-msc[master]: configure.ac: drop useless SQLite3 dependency

2019-04-25 Thread Vadim Yanitskiy
Vadim Yanitskiy has posted comments on this change. ( 
https://gerrit.osmocom.org/13639 )

Change subject: configure.ac: drop useless SQLite3 dependency
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13639
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ibf4eb53e60a2957eca99a2c8e613f75a8c43ac89
Gerrit-Change-Number: 13639
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Comment-Date: Thu, 25 Apr 2019 19:22:41 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-msc[master]: libmsc/db.c: print info about database name and libdbi version

2019-04-25 Thread Vadim Yanitskiy
Vadim Yanitskiy has posted comments on this change. ( 
https://gerrit.osmocom.org/13641 )

Change subject: libmsc/db.c: print info about database name and libdbi version
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13641
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Iaed452548eb2d847738b78d3489bf6f507a2e3c1
Gerrit-Change-Number: 13641
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Comment-Date: Thu, 25 Apr 2019 19:22:46 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in docker-playground[master]: Add OSMO_*_BRANCH environment variables for build args

2019-04-25 Thread Daniel Willmann
Daniel Willmann has posted comments on this change. ( 
https://gerrit.osmocom.org/13779 )

Change subject: Add OSMO_*_BRANCH environment variables for build args
..


Patch Set 1: Verified+1

I didn't run all the tests, but ttcn3-bsc-test and ttcn3-msc-test ran 
successfully on my machine.


--
To view, visit https://gerrit.osmocom.org/13779
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If3bc5fae07cf63c4fef68306be4c4328660bc869
Gerrit-Change-Number: 13779
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Willmann 
Gerrit-Reviewer: Daniel Willmann 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: osmith 
Gerrit-Comment-Date: Thu, 25 Apr 2019 17:02:28 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in docker-playground[master]: Add OSMO_*_BRANCH environment variables for build args

2019-04-25 Thread Daniel Willmann
Daniel Willmann has removed Harald Welte from this change.  ( 
https://gerrit.osmocom.org/13779 )

Change subject: Add OSMO_*_BRANCH environment variables for build args
..


Removed reviewer Harald Welte.
--
To view, visit https://gerrit.osmocom.org/13779
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-MessageType: deleteReviewer
Gerrit-Change-Id: If3bc5fae07cf63c4fef68306be4c4328660bc869
Gerrit-Change-Number: 13779
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Willmann 
Gerrit-Reviewer: Daniel Willmann 


Change in osmo-ccid-firmware[master]: output 50 MHz for RMII

2019-04-25 Thread Kévin Redon
Kévin Redon has uploaded this change for review. ( 
https://gerrit.osmocom.org/13780


Change subject: output 50 MHz for RMII
..

output 50 MHz for RMII

in hardware revision 2 the Ethernet PHY RMII_CLOCK input clock is
connected to the MCU pin PA10.
GCLK4 of the MCU now outputs the required 50 MHz clock on this pin.
the same clock is re-used for UART debug to generate the 921600
bps baud rate.

Change-Id: Id3a3dee15c3986536b0623d0f39ca62e94acd1fd
---
M sysmoOCTSIM/atmel_start_config.atstart
M sysmoOCTSIM/atmel_start_pins.h
M sysmoOCTSIM/config/hpl_gclk_config.h
M sysmoOCTSIM/config/peripheral_clk_config.h
M sysmoOCTSIM/driver_init.c
5 files changed, 63 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/80/13780/1

diff --git a/sysmoOCTSIM/atmel_start_config.atstart 
b/sysmoOCTSIM/atmel_start_config.atstart
index 4fda2f8..6357a74 100644
--- a/sysmoOCTSIM/atmel_start_config.atstart
+++ b/sysmoOCTSIM/atmel_start_config.atstart
@@ -702,7 +702,7 @@
   gclk_arch_gen_3_runstdby: false
   gclk_arch_gen_4_enable: true
   gclk_arch_gen_4_idc: false
-  gclk_arch_gen_4_oe: false
+  gclk_arch_gen_4_oe: true
   gclk_arch_gen_4_oov: false
   gclk_arch_gen_4_runstdby: false
   gclk_arch_gen_5_enable: true
@@ -748,7 +748,7 @@
   gclk_gen_3_div: 1
   gclk_gen_3_div_sel: false
   gclk_gen_3_oscillator: 32kHz External Crystal Oscillator (XOSC32K)
-  gclk_gen_4_div: 1
+  gclk_gen_4_div: 2
   gclk_gen_4_div_sel: false
   gclk_gen_4_oscillator: Digital Phase Locked Loop (DPLL1)
   gclk_gen_5_div: 5
@@ -1462,6 +1462,16 @@
 mode: Peripheral IO
 user_label: SIM2_IO
 configuration: null
+  RMII_CLOCK:
+name: PA10
+definition: Atmel:SAME54_Drivers:0.0.1::SAME54N19A-AF::pad::PA10
+mode: Advanced
+user_label: RMII_CLOCK
+configuration:
+  pad_direction: Out
+  pad_function: M
+  pad_initial_level: Low
+  pad_pull_config: 'Off'
   SIMCLK_20MHZ:
 name: PA11
 definition: Atmel:SAME54_Drivers:0.0.1::SAME54N19A-AF::pad::PA11
diff --git a/sysmoOCTSIM/atmel_start_pins.h b/sysmoOCTSIM/atmel_start_pins.h
index 0264736..7cbaed5 100644
--- a/sysmoOCTSIM/atmel_start_pins.h
+++ b/sysmoOCTSIM/atmel_start_pins.h
@@ -31,6 +31,7 @@
 #define SIM5_INT GPIO(GPIO_PORTA, 3)
 #define SIM0_IO GPIO(GPIO_PORTA, 4)
 #define SIM2_IO GPIO(GPIO_PORTA, 9)
+#define RMII_CLOCK GPIO(GPIO_PORTA, 10)
 #define SIMCLK_20MHZ GPIO(GPIO_PORTA, 11)
 #define SIM1_IO GPIO(GPIO_PORTA, 16)
 #define VB0 GPIO(GPIO_PORTA, 20)
diff --git a/sysmoOCTSIM/config/hpl_gclk_config.h 
b/sysmoOCTSIM/config/hpl_gclk_config.h
index 71c26e1..81a1f03 100644
--- a/sysmoOCTSIM/config/hpl_gclk_config.h
+++ b/sysmoOCTSIM/config/hpl_gclk_config.h
@@ -349,7 +349,7 @@
 //  Indicates whether Output Enable is enabled or not
 //  gclk_arch_gen_4_oe
 #ifndef CONF_GCLK_GEN_4_OE
-#define CONF_GCLK_GEN_4_OE 0
+#define CONF_GCLK_GEN_4_OE 1
 #endif

 //  Output Off Value
@@ -378,7 +378,7 @@
 // Generic clock generator 4 division <0x-0x>
 //  gclk_gen_4_div
 #ifndef CONF_GCLK_GEN_4_DIV
-#define CONF_GCLK_GEN_4_DIV 1
+#define CONF_GCLK_GEN_4_DIV 2
 #endif
 // 
 // 
diff --git a/sysmoOCTSIM/config/peripheral_clk_config.h 
b/sysmoOCTSIM/config/peripheral_clk_config.h
index 4bff6ff..2ae1f63 100644
--- a/sysmoOCTSIM/config/peripheral_clk_config.h
+++ b/sysmoOCTSIM/config/peripheral_clk_config.h
@@ -641,7 +641,7 @@
  * \brief SERCOM7's Core Clock frequency
  */
 #ifndef CONF_GCLK_SERCOM7_CORE_FREQUENCY
-#define CONF_GCLK_SERCOM7_CORE_FREQUENCY 1
+#define CONF_GCLK_SERCOM7_CORE_FREQUENCY 5000
 #endif

 /**
diff --git a/sysmoOCTSIM/driver_init.c b/sysmoOCTSIM/driver_init.c
index 0b6b190..1233d02 100644
--- a/sysmoOCTSIM/driver_init.c
+++ b/sysmoOCTSIM/driver_init.c
@@ -503,6 +503,53 @@

gpio_set_pin_function(SIM5_INT, GPIO_PIN_FUNCTION_OFF);

+   // GPIO on PA10
+
+   gpio_set_pin_direction(RMII_CLOCK,
+  //  Pin direction
+  //  pad_direction
+  //  Off
+  //  In
+  //  Out
+  GPIO_DIRECTION_OUT);
+
+   gpio_set_pin_level(RMII_CLOCK,
+  //  Initial level
+  //  pad_initial_level
+  //  Low
+  //  High
+  false);
+
+   gpio_set_pin_pull_mode(RMII_CLOCK,
+  //  Pull configuration
+  //  pad_pull_config
+  //  Off
+  //  Pull-up
+  //  Pull-down
+  GPIO_PULL_OFF);
+
+   gpio_set_pin_function(RMII_CLOCK,
+ //  Pin function
+ //  

Change in osmo-ccid-firmware[master]: configure GCLK for ISO baud rates

2019-04-25 Thread Kévin Redon
Kévin Redon has uploaded this change for review. ( 
https://gerrit.osmocom.org/13781


Change subject: configure GCLK for ISO baud rates
..

configure GCLK for ISO baud rates

the SERCOMM clock triplet 0.5 MHz (100 MHz / 200),
7.0588 MHz (120 MHz / 17), and 50 MHz (100 MHz / 2) allows to
generate all possible ISO 7816 baud rates (from
F = 2048 / D = 1 @ f = 2.5 MHz -> 1220 bps to
F = 372 / D = 64 @ f = 20 MHz -> 3.4 Mbps) with a maximum baud
rate error of 2.57 %, for available SIM clocks 2.5, 5, 10, 20 MHz.
2.57% means a bit more than quarter a bit might be wrong after the
11 bits ISO transmission (still less than half a bit).
This triplet is one of the optimum when 3 clocks are used.
An additional clock would be required for higher accuracy.

The 50 MHz clock is re-used from the RMII clock output.

Change-Id: I2c69848582e49031fa6453f535a2bf1408f8e22e
---
M sysmoOCTSIM/atmel_start_config.atstart
M sysmoOCTSIM/config/hpl_gclk_config.h
M sysmoOCTSIM/config/peripheral_clk_config.h
3 files changed, 17 insertions(+), 17 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/81/13781/1

diff --git a/sysmoOCTSIM/atmel_start_config.atstart 
b/sysmoOCTSIM/atmel_start_config.atstart
index 6357a74..3854fb5 100644
--- a/sysmoOCTSIM/atmel_start_config.atstart
+++ b/sysmoOCTSIM/atmel_start_config.atstart
@@ -666,7 +666,7 @@
   enable_gclk_gen_3: true
   enable_gclk_gen_4: true
   enable_gclk_gen_5: true
-  enable_gclk_gen_6: false
+  enable_gclk_gen_6: true
   enable_gclk_gen_7: false
   enable_gclk_gen_8: false
   enable_gclk_gen_9: false
@@ -710,7 +710,7 @@
   gclk_arch_gen_5_oe: true
   gclk_arch_gen_5_oov: false
   gclk_arch_gen_5_runstdby: false
-  gclk_arch_gen_6_enable: false
+  gclk_arch_gen_6_enable: true
   gclk_arch_gen_6_idc: false
   gclk_arch_gen_6_oe: false
   gclk_arch_gen_6_oov: false
@@ -742,7 +742,7 @@
   gclk_gen_1_div: 1
   gclk_gen_1_div_sel: false
   gclk_gen_1_oscillator: Digital Frequency Locked Loop (DFLL48M)
-  gclk_gen_2_div: 30
+  gclk_gen_2_div: 200
   gclk_gen_2_div_sel: false
   gclk_gen_2_oscillator: Digital Phase Locked Loop (DPLL1)
   gclk_gen_3_div: 1
@@ -754,9 +754,9 @@
   gclk_gen_5_div: 5
   gclk_gen_5_div_sel: false
   gclk_gen_5_oscillator: Digital Phase Locked Loop (DPLL1)
-  gclk_gen_6_div: 1
+  gclk_gen_6_div: 17
   gclk_gen_6_div_sel: false
-  gclk_gen_6_oscillator: External Crystal Oscillator 8-48MHz (XOSC1)
+  gclk_gen_6_oscillator: Digital Phase Locked Loop (DPLL0)
   gclk_gen_7_div: 1
   gclk_gen_7_div_sel: false
   gclk_gen_7_oscillator: External Crystal Oscillator 8-48MHz (XOSC1)
diff --git a/sysmoOCTSIM/config/hpl_gclk_config.h 
b/sysmoOCTSIM/config/hpl_gclk_config.h
index 81a1f03..158fc93 100644
--- a/sysmoOCTSIM/config/hpl_gclk_config.h
+++ b/sysmoOCTSIM/config/hpl_gclk_config.h
@@ -226,7 +226,7 @@
 // Generic clock generator 2 division <0x-0x>
 //  gclk_gen_2_div
 #ifndef CONF_GCLK_GEN_2_DIV
-#define CONF_GCLK_GEN_2_DIV 30
+#define CONF_GCLK_GEN_2_DIV 200
 #endif
 // 
 // 
@@ -463,7 +463,7 @@
 //  Indicates whether generic clock 6 configuration is enabled or not
 //  enable_gclk_gen_6
 #ifndef CONF_GCLK_GENERATOR_6_CONFIG
-#define CONF_GCLK_GENERATOR_6_CONFIG 0
+#define CONF_GCLK_GENERATOR_6_CONFIG 1
 #endif

 //  Generic Clock Generator Control
@@ -480,7 +480,7 @@
 //  This defines the clock source for generic clock generator 6
 //  gclk_gen_6_oscillator
 #ifndef CONF_GCLK_GEN_6_SOURCE
-#define CONF_GCLK_GEN_6_SOURCE GCLK_GENCTRL_SRC_XOSC1
+#define CONF_GCLK_GEN_6_SOURCE GCLK_GENCTRL_SRC_DPLL0
 #endif

 //  Run in Standby
@@ -522,7 +522,7 @@
 //  Indicates whether Generic Clock Generator Enable is enabled or not
 //  gclk_arch_gen_6_enable
 #ifndef CONF_GCLK_GEN_6_GENEN
-#define CONF_GCLK_GEN_6_GENEN 0
+#define CONF_GCLK_GEN_6_GENEN 1
 #endif
 // 

@@ -530,7 +530,7 @@
 // Generic clock generator 6 division <0x-0x>
 //  gclk_gen_6_div
 #ifndef CONF_GCLK_GEN_6_DIV
-#define CONF_GCLK_GEN_6_DIV 1
+#define CONF_GCLK_GEN_6_DIV 17
 #endif
 // 
 // 
diff --git a/sysmoOCTSIM/config/peripheral_clk_config.h 
b/sysmoOCTSIM/config/peripheral_clk_config.h
index 2ae1f63..f794792 100644
--- a/sysmoOCTSIM/config/peripheral_clk_config.h
+++ b/sysmoOCTSIM/config/peripheral_clk_config.h
@@ -81,7 +81,7 @@
  * \brief SERCOM0's Core Clock frequency
  */
 #ifndef CONF_GCLK_SERCOM0_CORE_FREQUENCY
-#define CONF_GCLK_SERCOM0_CORE_FREQUENCY 333
+#define CONF_GCLK_SERCOM0_CORE_FREQUENCY 50
 #endif

 /**
@@ -161,7 +161,7 @@
  * \brief SERCOM1's Core Clock frequency
  */
 #ifndef CONF_GCLK_SERCOM1_CORE_FREQUENCY
-#define CONF_GCLK_SERCOM1_CORE_FREQUENCY 333
+#define CONF_GCLK_SERCOM1_CORE_FREQUENCY 50
 #endif

 /**
@@ -241,7 +241,7 @@
  * \brief SERCOM2's Core Clock frequency
  */
 #ifndef CONF_GCLK_SERCOM2_CORE_FREQUENCY

Change in docker-playground[master]: Add OSMO_*_BRANCH environment variables for build args

2019-04-25 Thread Daniel Willmann
Daniel Willmann has uploaded this change for review. ( 
https://gerrit.osmocom.org/13779


Change subject: Add OSMO_*_BRANCH environment variables for build args
..

Add OSMO_*_BRANCH environment variables for build args

Previously we could only set OSMO_TTCN3_BRANCH as environment variable
to build a test other than master.

This patch adds environment variables for all osmo-*-master images which
allow docker tests to be executed for an arbitrary commit.

The origin/ prefix from the git checkout command is removed so the
*_BRANCH variable doesn't have to contain branch names, but van also
contain arbitrary commits. This shouldn't have any adverse effect as we
only have one remote in the checkout.

Change-Id: If3bc5fae07cf63c4fef68306be4c4328660bc869
---
M make/Makefile
M osmo-bsc-master/Dockerfile
M osmo-bts-master/Dockerfile
M osmo-ggsn-master/Dockerfile
M osmo-hlr-master/Dockerfile
M osmo-hnbgw-master/Dockerfile
M osmo-mgw-master/Dockerfile
M osmo-msc-master/Dockerfile
M osmo-nitb-master/Dockerfile
M osmo-pcu-master/Dockerfile
M osmo-sgsn-master/Dockerfile
M osmo-sip-master/Dockerfile
M osmo-stp-master/Dockerfile
13 files changed, 40 insertions(+), 13 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/docker-playground 
refs/changes/79/13779/1

diff --git a/make/Makefile b/make/Makefile
index 7dfa795..000db25 100644
--- a/make/Makefile
+++ b/make/Makefile
@@ -17,6 +17,18 @@
 USERNAME?=$(USER)
 NAME?=$(shell basename $(CURDIR))
 OSMO_TTCN3_BRANCH?=master
+OSMO_BSC_BRANCH?=master
+OSMO_BTS_BRANCH?=master
+OSMO_GGSN_BRANCH?=master
+OSMO_HLR_BRANCH?=master
+OSMO_IUH_BRANCH?=master
+OSMO_MGW_BRANCH?=master
+OSMO_MSC_BRANCH?=master
+OSMO_NITB_BRANCH?=master
+OSMO_PCU_BRANCH?=master
+OSMO_SGSN_BRANCH?=master
+OSMO_SIP_BRANCH?=master
+OSMO_STP_BRANCH?=master
 PULL?=

 RELEASE_SUPPORT := $(shell dirname $(abspath $(lastword 
$(MAKEFILE_LIST/.make-release-support
@@ -42,6 +54,18 @@

 docker-build: .release
docker build --build-arg USER=$(USERNAME) --build-arg 
OSMO_TTCN3_BRANCH=$(OSMO_TTCN3_BRANCH) \
+   --build-arg OSMO_BSC_BRANCH=$(OSMO_BSC_BRANCH) \
+   --build-arg OSMO_BTS_BRANCH=$(OSMO_BTS_BRANCH) \
+   --build-arg OSMO_GGSN_BRANCH=$(OSMO_GGSN_BRANCH) \
+   --build-arg OSMO_HLR_BRANCH=$(OSMO_HLR_BRANCH) \
+   --build-arg OSMO_IUH_BRANCH=$(OSMO_IUH_BRANCH) \
+   --build-arg OSMO_MGW_BRANCH=$(OSMO_MGW_BRANCH) \
+   --build-arg OSMO_MSC_BRANCH=$(OSMO_MSC_BRANCH) \
+   --build-arg OSMO_NITB_BRANCH=$(OSMO_NITB_BRANCH) \
+   --build-arg OSMO_PCU_BRANCH=$(OSMO_PCU_BRANCH) \
+   --build-arg OSMO_SGSN_BRANCH=$(OSMO_SGSN_BRANCH) \
+   --build-arg OSMO_SIP_BRANCH=$(OSMO_SIP_BRANCH) \
+   --build-arg OSMO_STP_BRANCH=$(OSMO_STP_BRANCH) \
$(PULL) -t $(IMAGE):latest .
@DOCKER_MAJOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' 
| cut -d\. -f1) ; \
DOCKER_MINOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' | 
cut -d\. -f2) ; \
diff --git a/osmo-bsc-master/Dockerfile b/osmo-bsc-master/Dockerfile
index 61ac8e4..bcd0573 100644
--- a/osmo-bsc-master/Dockerfile
+++ b/osmo-bsc-master/Dockerfile
@@ -32,7 +32,7 @@
 ADDhttp://git.osmocom.org/osmo-bsc/patch?h=$OSMO_BSC_BRANCH 
/tmp/commit-osmo-bsc

 RUNcd osmo-bsc && \
-   git fetch && git checkout -f -B $OSMO_BSC_BRANCH 
origin/$OSMO_BSC_BRANCH && \
+   git fetch && git checkout -f -B $OSMO_BSC_BRANCH $OSMO_BSC_BRANCH && \
git rev-parse --abbrev-ref HEAD && git rev-parse HEAD && \
autoreconf -fi && \
./configure && \
diff --git a/osmo-bts-master/Dockerfile b/osmo-bts-master/Dockerfile
index be58081..f4ddf3a 100644
--- a/osmo-bts-master/Dockerfile
+++ b/osmo-bts-master/Dockerfile
@@ -33,7 +33,7 @@
 ADDhttp://git.osmocom.org/osmo-bts/patch?h=$OSMO_BTS_BRANCH 
/tmp/commit-osmo-bts

 RUNcd osmo-bts && \
-   git fetch && git checkout -f -B $OSMO_BTS_BRANCH 
origin/$OSMO_BTS_BRANCH && \
+   git fetch && git checkout -f -B $OSMO_BTS_BRANCH $OSMO_BTS_BRANCH && \
git rev-parse --abbrev-ref HEAD && git rev-parse HEAD && \
autoreconf -fi && \
./configure --enable-trx && \
diff --git a/osmo-ggsn-master/Dockerfile b/osmo-ggsn-master/Dockerfile
index ca4f111..cf84d02 100644
--- a/osmo-ggsn-master/Dockerfile
+++ b/osmo-ggsn-master/Dockerfile
@@ -25,7 +25,7 @@
 RUNgit clone git://git.osmocom.org/osmo-ggsn.git
 ADDhttp://git.osmocom.org/osmo-ggsn/patch/?h=$OSMO_GGSN_BRANCH /tmp/commit
 RUNcd osmo-ggsn && \
-   git fetch && git checkout -f -B $OSMO_GGSN_BRANCH 
origin/$OSMO_GGSN_BRANCH && \
+   git fetch && git checkout -f -B $OSMO_GGSN_BRANCH $OSMO_GGSN_BRANCH && \
git rev-parse --abbrev-ref HEAD && git rev-parse HEAD && \
autoreconf -fi && \
./configure && \
diff --git 

Change in openbsc[master]: osmo-bsc_nat: Parse MGCP Connection ID as hex

2019-04-25 Thread dexter
dexter has posted comments on this change. ( https://gerrit.osmocom.org/13778 )

Change subject: osmo-bsc_nat: Parse MGCP Connection ID as hex
..


Patch Set 1: Code-Review+2

> Build Successful
 >
 > https://jenkins.osmocom.org/jenkins/job/gerrit-openbsc/210/ :
 > SUCCESS'  --verified 1 --code-review 0


--
To view, visit https://gerrit.osmocom.org/13778
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I49b8b61644bf706162102dce268cae2265536fc5
Gerrit-Change-Number: 13778
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Willmann 
Gerrit-Reviewer: Daniel Willmann 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: dexter 
Gerrit-Comment-Date: Thu, 25 Apr 2019 08:34:11 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in openbsc[master]: osmo-bsc_nat: Parse MGCP Connection ID as hex

2019-04-25 Thread Daniel Willmann
Daniel Willmann has uploaded this change for review. ( 
https://gerrit.osmocom.org/13778


Change subject: osmo-bsc_nat: Parse MGCP Connection ID as hex
..

osmo-bsc_nat: Parse MGCP Connection ID as hex

Our ttcn3-bscnat-tests would randomly fail. After the CRCX ACK returns
from the MSC the bsc-nat reports it could not find a CI it it and
deletes the connection on the BSC-side.

This happens because the field is parsed as a decimal value instead of
hexadecimal. So a value of 00FED122 is parsed as '0' which is a reserved
value in our program.

This fix parses the field as hexadecimal value and also logs an error if
the value happens to be 0.

make check will now test if a hexadecimal CI is parsed correctly.

Fixes: OS#3951
Change-Id: I49b8b61644bf706162102dce268cae2265536fc5
---
M openbsc/src/libmgcp/mgcp_protocol.c
M openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
M openbsc/tests/bsc-nat/bsc_data.c
M openbsc/tests/bsc-nat/bsc_nat_test.c
4 files changed, 11 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/78/13778/1

diff --git a/openbsc/src/libmgcp/mgcp_protocol.c 
b/openbsc/src/libmgcp/mgcp_protocol.c
index 84dbc1f..689c91f 100644
--- a/openbsc/src/libmgcp/mgcp_protocol.c
+++ b/openbsc/src/libmgcp/mgcp_protocol.c
@@ -208,7 +208,7 @@

len = snprintf(sdp_record, size,
"v=0\r\n"
-   "o=- %u 23 IN IP4 %s\r\n"
+   "o=- %x 23 IN IP4 %s\r\n"
"s=-\r\n"
"c=IN IP4 %s\r\n"
"t=0 0\r\n",
@@ -285,7 +285,7 @@
}

len = snprintf(sdp_record, sizeof(sdp_record),
-  "I: %u%s\n\n", endp->ci, osmux_extension);
+  "I: %x%s\n\n", endp->ci, osmux_extension);
if (len < 0)
return NULL;

@@ -512,7 +512,7 @@
uint32_t ci = strtoul(_ci, NULL, 10);

if (ci != endp->ci) {
-   LOGP(DMGCP, LOGL_ERROR, "ConnectionIdentifiers do not match on 
0x%x. %u != %s\n",
+   LOGP(DMGCP, LOGL_ERROR, "ConnectionIdentifiers do not match on 
0x%x. %x != %x\n",
ENDPOINT_NUMBER(endp), endp->ci, _ci);
return -1;
}
@@ -891,7 +891,7 @@
osmo_jibuf_set_dequeue_cb(endp->bts_jb, mgcp_dejitter_udp_send, 
>net_end);
}

-   LOGP(DMGCP, LOGL_DEBUG, "Creating endpoint on: 0x%x CI: %u port: 
%u/%u\n",
+   LOGP(DMGCP, LOGL_DEBUG, "Creating endpoint on: 0x%x CI: %x port: 
%u/%u\n",
ENDPOINT_NUMBER(endp), endp->ci,
endp->net_end.local_port, endp->bts_end.local_port);
if (p->cfg->change_cb)
diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c 
b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
index 311ab94..17dc659 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
@@ -812,11 +812,14 @@
return CI_UNUSED;
}

-   if (sscanf(res, "I: %u", ) != 1) {
+   if (sscanf(res, "I: %x", ) != 1) {
LOGP(DMGCP, LOGL_ERROR, "Failed to parse CI in msg '%s'\n", 
str);
return CI_UNUSED;
}

+   if (ci == CI_UNUSED)
+   LOGP(DMGCP, LOGL_ERROR, "CI field '%s' parsed as reserved value 
CI_UNUSED\n", str);
+
return ci;
 }

diff --git a/openbsc/tests/bsc-nat/bsc_data.c b/openbsc/tests/bsc-nat/bsc_data.c
index 71d5391..d29caef 100644
--- a/openbsc/tests/bsc-nat/bsc_data.c
+++ b/openbsc/tests/bsc-nat/bsc_data.c
@@ -157,8 +157,8 @@


 /* patch the ip and port */
-static const char crcx_resp[] = "200 23265295\r\nI: 1\r\n\r\nv=0\r\nc=IN IP4 
172.16.18.2\r\nm=audio 4002 RTP/AVP 98 3\r\na=rtpmap:98 AMR/8000\r\n";
-static const char crcx_resp_patched[] = "200 23265295\r\nI: 
1\r\n\r\nv=0\r\nc=IN IP4 10.0.0.1\r\nm=audio 999 RTP/AVP 98 3\r\na=rtpmap:98 
AMR/8000\r\na=fmtp:98 mode-set=2 octet-align=1\r\n";
+static const char crcx_resp[] = "200 23265295\r\nI: 0F\r\n\r\nv=0\r\nc=IN IP4 
172.16.18.2\r\nm=audio 4002 RTP/AVP 98 3\r\na=rtpmap:98 AMR/8000\r\n";
+static const char crcx_resp_patched[] = "200 23265295\r\nI: 
0F\r\n\r\nv=0\r\nc=IN IP4 10.0.0.1\r\nm=audio 999 RTP/AVP 98 3\r\na=rtpmap:98 
AMR/8000\r\na=fmtp:98 mode-set=2 octet-align=1\r\n";

 /* patch the ip and port */
 static const char mdcx[] = "MDCX 23330829 8@mgw MGCP 1.0\r\nC: 
394b0439fb\r\nI: 1\r\nL: p:20, a:AMR, nt:IN\r\nM: recvonly\r\n\r\nv=0\r\no=- 
1049380491 0 IN IP4 172.16.18.2\r\ns=-\r\nc=IN IP4 172.16.18.2\r\nt=0 
0\r\nm=audio 4410 RTP/AVP 126\r\na=rtpmap:126 AMR/8000/1\r\na=fmtp:126 
mode-set=2  octet-align=1;start-mode=0\r\na=ptime:20\r\na=recvonly\r\nm=image 
4412 udptl t38\r\na=T38FaxVersion:0\r\na=T38MaxBitRate:14400\r\n";
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c 
b/openbsc/tests/bsc-nat/bsc_nat_test.c
index 2914a01..e0d0051 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++