Change in libosmocore[master]: libosmogsm: (re)introduce gsm48_push_l3hdr()

2018-08-02 Thread Vadim Yanitskiy
Vadim Yanitskiy has uploaded this change for review. ( 
https://gerrit.osmocom.org/10328


Change subject: libosmogsm: (re)introduce gsm48_push_l3hdr()
..

libosmogsm: (re)introduce gsm48_push_l3hdr()

There was gsm0480_l3hdr_push() which was declared in a header,
but was not exposed in 'libosmogsm.map'. Also, for some reason
it was a part of GSM 04.80 API, what is not actually correct.

Let's rename this symbol, and properly expose it as a part of
the new GSM 04.08 auxiliary API, i.e. in a separate header.

Change-Id: I8a045efe8335d83fcbe8d43eb180972e3b1d9dda
---
M include/Makefile.am
M include/osmocom/gsm/gsm0480.h
A include/osmocom/gsm/gsm48_utils.h
M src/gsm/Makefile.am
M src/gsm/gsm0411_utils.c
M src/gsm/gsm0480.c
A src/gsm/gsm48_utils.c
M src/gsm/libosmogsm.map
8 files changed, 84 insertions(+), 25 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/28/10328/1

diff --git a/include/Makefile.am b/include/Makefile.am
index ef8ec65..cc29ca8 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -90,6 +90,7 @@
osmocom/gsm/gsm23003.h \
osmocom/gsm/gsm48.h \
osmocom/gsm/gsm48_ie.h \
+   osmocom/gsm/gsm48_utils.h \
osmocom/gsm/gsm_utils.h \
osmocom/gsm/gsup.h \
osmocom/gsm/ipa.h \
diff --git a/include/osmocom/gsm/gsm0480.h b/include/osmocom/gsm/gsm0480.h
index 246f4b3..827464e 100644
--- a/include/osmocom/gsm/gsm0480.h
+++ b/include/osmocom/gsm/gsm0480.h
@@ -121,6 +121,3 @@

 int gsm0480_wrap_invoke(struct msgb *msg, int op, int link_id);
 int gsm0480_wrap_facility(struct msgb *msg);
-
-struct gsm48_hdr *gsm0480_l3hdr_push(struct msgb *msg, uint8_t proto_discr,
-uint8_t msg_type);
diff --git a/include/osmocom/gsm/gsm48_utils.h 
b/include/osmocom/gsm/gsm48_utils.h
new file mode 100644
index 000..0f19a0c
--- /dev/null
+++ b/include/osmocom/gsm/gsm48_utils.h
@@ -0,0 +1,5 @@
+#pragma once
+
+struct gsm48_hdr *gsm48_push_l3hdr(struct msgb *msg,
+  uint8_t pdisc, uint8_t tid,
+  uint8_t msg_type);
diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am
index 29299a6..a945c1e 100644
--- a/src/gsm/Makefile.am
+++ b/src/gsm/Makefile.am
@@ -21,7 +21,7 @@
 BUILT_SOURCES = gsm0503_conv.c

 libgsmint_la_SOURCES =  a5.c rxlev_stat.c tlv_parser.c comp128.c comp128v23.c \
-   gsm_utils.c rsl.c gsm48.c gsm48_ie.c gsm0808.c 
sysinfo.c \
+   gsm_utils.c rsl.c gsm48.c gsm48_ie.c gsm48_utils.c 
gsm0808.c sysinfo.c \
gprs_cipher_core.c gprs_rlc.c gsm0480.c abis_nm.c 
gsm0502.c \
gsm0411_utils.c gsm0411_smc.c gsm0411_smr.c gsm0414.c \
lapd_core.c lapdm.c kasumi.c gsm_04_08_gprs.c \
diff --git a/src/gsm/gsm0411_utils.c b/src/gsm/gsm0411_utils.c
index 53d37a4..6384900 100644
--- a/src/gsm/gsm0411_utils.c
+++ b/src/gsm/gsm0411_utils.c
@@ -35,7 +35,7 @@
 #include 

 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -354,7 +354,7 @@
 uint8_t msg_type)
 {
/* Outgoing proto_discr needs the highest bit set */
-   gsm0480_l3hdr_push(msg, proto | (trans << 4), msg_type);
+   gsm48_push_l3hdr(msg, proto, trans, msg_type);
return 0;
 }

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 3897743..ea39980 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -26,6 +26,7 @@
  */
 
 #include 
+#include 
 #include 

 #include 
@@ -863,10 +864,10 @@
msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY);

/* And finally pre-pend the L3 header */
-   gsm0480_l3hdr_push(msg,
-  GSM48_PDISC_NC_SS | trans_id
-  | (1<<7) /* TI direction = 1 */,
-  GSM0480_MTYPE_RELEASE_COMPLETE);
+   gsm48_push_l3hdr(msg, GSM48_PDISC_NC_SS,
+   trans_id | (1 << 7), /* FIXME: TI direction is always 1 ?!? */
+   GSM0480_MTYPE_RELEASE_COMPLETE);
+
return msg;
 }

@@ -932,17 +933,6 @@
return msg;
 }

-
-struct gsm48_hdr *gsm0480_l3hdr_push(struct msgb *msg, uint8_t proto_discr,
-uint8_t msg_type)
-{
-   struct gsm48_hdr *gh;
-   gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
-   gh->proto_discr = proto_discr;
-   gh->msg_type = msg_type;
-   return gh;
-}
-
 struct msgb *gsm0480_create_ussd_notify(int level, const char *text)
 {
struct msgb *msg;
@@ -954,7 +944,11 @@
gsm0480_wrap_invoke(msg, GSM0480_OP_CODE_USS_NOTIFY, 0);
gsm0480_wrap_facility(msg);

-   gsm0480_l3hdr_push(msg, GSM48_PDISC_NC_SS, GSM0480_MTYPE_REGISTER);
+   /* And finally pre-pend the L3 header */
+   gsm48_push_l3hdr(msg, 

Change in osmo-msc[master]: libmsc/gsm_09_11.c: clean up the local GSM 04.80 API

2018-08-02 Thread Vadim Yanitskiy
Vadim Yanitskiy has uploaded this change for review. ( 
https://gerrit.osmocom.org/10327


Change subject: libmsc/gsm_09_11.c: clean up the local GSM 04.80 API
..

libmsc/gsm_09_11.c: clean up the local GSM 04.80 API

Since we don't process SS/USSD requests in OsmoMSC anymore, there
are some useless GSM 04.80 functions remained from the past.

In particular, this change does the following:

  - removes both gsm0480_send_{ussd_response|return_error}
functions because they are not used anymore;

  - changes symbol prefix from 'gsm0480_' to 'msc_', in order to
avoid possible conflicts with the libosmogsm's GSM 04.80 API;

  - cleans up useless includes;

Change-Id: I2990d8627bce0ce6afb1dcf6b11bb194292380d3
---
M include/osmocom/msc/gsm_04_80.h
M src/libmsc/gsm_04_80.c
M src/libmsc/gsm_09_11.c
3 files changed, 13 insertions(+), 149 deletions(-)



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

diff --git a/include/osmocom/msc/gsm_04_80.h b/include/osmocom/msc/gsm_04_80.h
index 7d63088..c448c91 100644
--- a/include/osmocom/msc/gsm_04_80.h
+++ b/include/osmocom/msc/gsm_04_80.h
@@ -1,18 +1,10 @@
 #pragma once

-#include 
-#include 
-#include 
+#include 

 struct gsm_subscriber_connection;

-int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,
-  uint8_t transaction_id, uint8_t invoke_id,
-  const char *response_text);
-int gsm0480_send_ussd_return_error(struct gsm_subscriber_connection *conn,
-  uint8_t transaction_id, uint8_t invoke_id,
-  uint8_t error_code);
-int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn,
+int msc_send_ussd_reject(struct gsm_subscriber_connection *conn,
 uint8_t transaction_id, int invoke_id,
 uint8_t problem_tag, uint8_t problem_code);

diff --git a/src/libmsc/gsm_04_80.c b/src/libmsc/gsm_04_80.c
index 32e8e23..0adf059 100644
--- a/src/libmsc/gsm_04_80.c
+++ b/src/libmsc/gsm_04_80.c
@@ -22,20 +22,14 @@
  *
  */

-
-#include 
-#include 
-#include 
+#include 
 #include 

-#include 
-#include 
-#include 
 #include 
 #include 

+#include 
 #include 
-#include 
 #include 
 #include 

@@ -48,120 +42,6 @@
return data;
 }

-static inline unsigned char *msgb_push_TLV1(struct msgb *msgb, uint8_t tag,
-   uint8_t value)
-{
-   uint8_t *data = msgb_push(msgb, 3);
-
-   data[0] = tag;
-   data[1] = 1;
-   data[2] = value;
-   return data;
-}
-
-static inline unsigned char *msgb_push_NULL(struct msgb *msgb)
-{
-   uint8_t *data = msgb_push(msgb, 2);
-
-   data[0] = ASN1_NULL_TYPE_TAG;
-   data[1] = 0;
-   return data;
-}
-
-
-/*! Send a MT RELEASE COMPLETE message with USSD-response,
- *  wrapped into the ReturnResult component (see section 3.6.1).
- *
- * \param[in]  connActive subscriber connection
- * \param[in]  transaction_id  Transaction ID with TI flag set
- * \param[in]  invoke_id   InvokeID of the request
- * \param[in]  response_text   The response text
- * \return result of \ref msc_tx_dtap
- */
-int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,
-  uint8_t transaction_id, uint8_t invoke_id,
-  const char *response_text)
-{
-   struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 USSD RSP");
-   struct gsm48_hdr *gh;
-   uint8_t *ptr8;
-   int response_len;
-
-   /* First put the payload text into the message */
-   ptr8 = msgb_put(msg, 0);
-   gsm_7bit_encode_n_ussd(ptr8, msgb_tailroom(msg), response_text, 
_len);
-   msgb_put(msg, response_len);
-
-   /* Then wrap it as an Octet String */
-   msgb_wrap_with_TL(msg, ASN1_OCTET_STRING_TAG);
-
-   /* Pre-pend the DCS octet string */
-   msgb_push_TLV1(msg, ASN1_OCTET_STRING_TAG, 0x0F);
-
-   /* Then wrap these as a Sequence */
-   msgb_wrap_with_TL(msg, GSM_0480_SEQUENCE_TAG);
-
-   /* Pre-pend the operation code */
-   msgb_push_TLV1(msg, GSM0480_OPERATION_CODE,
-   GSM0480_OP_CODE_PROCESS_USS_REQ);
-
-   /* Wrap the operation code and IA5 string as a sequence */
-   msgb_wrap_with_TL(msg, GSM_0480_SEQUENCE_TAG);
-
-   /* Pre-pend the invoke ID */
-   msgb_push_TLV1(msg, GSM0480_COMPIDTAG_INVOKE_ID, invoke_id);
-
-   /* Wrap this up as a Return Result component */
-   msgb_wrap_with_TL(msg, GSM0480_CTYPE_RETURN_RESULT);
-
-   /* Wrap the component in a Facility message */
-   msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY);
-
-   /* And finally pre-pend the L3 header */
-   gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
-   gh->proto_discr  = GSM48_PDISC_NC_SS;
-   gh->proto_discr |= transaction_id << 4;
-   

Change in simtrace2[master]: add synchronous UART transmission and use it in exceptions

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10313 )

Change subject: add synchronous UART transmission and use it in exceptions
..


Patch Set 1:

the ISR_NUMBER field in IPSR will tell us which current interrupt/exception is 
in use.  "0" is normal process mode, so a check for != 0 would bypass the ring 
buffer in any irq/exception context.  If you just want specific faults, you 
have to check for specific numbers.


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1b4ace5185cf2dc32684934ed12bf6a8682e9bad
Gerrit-Change-Number: 10313
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Thu, 02 Aug 2018 21:25:16 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in simtrace2[master]: add synchronous UART transmission and use it in exceptions

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10313 )

Change subject: add synchronous UART transmission and use it in exceptions
..


Patch Set 1: Code-Review+1

(1 comment)

I think in general I would have preferred to simply use a separate Uart 
transmit function from the hardirq handlers.  Either by explicitly changing 
those calls away from printf, or  by catching/redirecting printf using a 
#define that's #included only in the exceptions.c file in order to bypass 
normal printf().

Now we have one conditional in every printf (not really relevant) and some 
global state that we'd have to switch back should we ever want to have 
"non-final" exception handling.

Another idea that just comes to my mind: Couldn't we simply check some CPU 
status flags to know that we're in an exception or in an interrupt?  This way 
the decision to bypass the ring buffer could be entirely automatic without any 
explcit calls to disable the buffer, or any of the hacks I described above? I 
would suggest to look into this.  If it turns out it's not that simple, please 
report back and we can merge your current patch as-is.

https://gerrit.osmocom.org/#/c/10313/1/firmware/libboard/common/source/uart_console.c
File firmware/libboard/common/source/uart_console.c:

https://gerrit.osmocom.org/#/c/10313/1/firmware/libboard/common/source/uart_console.c@169
PS1, Line 169: hift register */
 :  while (!(pUart->UART_SR & UART_SR_TXEMPTY)); /* Wait 
for transfer shift register to be empty (i.e. transfer is complete) */
why do we wait for this?  IMHO this effectively disables the "1 byte fifo" of 
the transfer register?  Shouldn't it be safe to transmit the next byte as soon 
as the hold register has been transferred to the shift register?



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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1b4ace5185cf2dc32684934ed12bf6a8682e9bad
Gerrit-Change-Number: 10313
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Thu, 02 Aug 2018 21:13:24 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: Yes


Change in libosmocore[master]: gsm/gsm0480.c: use the local msgb allocator

2018-08-02 Thread Vadim Yanitskiy
Vadim Yanitskiy has uploaded this change for review. ( 
https://gerrit.osmocom.org/10326


Change subject: gsm/gsm0480.c: use the local msgb allocator
..

gsm/gsm0480.c: use the local msgb allocator

Change-Id: I23b4b0e1c237b9b27c1db1c9a824b5329d41a38b
---
M src/gsm/gsm0480.c
1 file changed, 8 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/26/10326/1

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 5b51c75..3897743 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -125,13 +125,18 @@
return 0;
 }

+struct msgb *gsm0480_msgb_alloc_name(const char *name)
+{
+   return msgb_alloc_headroom(1024, 128, name);
+}
+
 struct msgb *gsm0480_create_unstructuredSS_Notify(int alertPattern, const char 
*text)
 {
struct msgb *msg;
uint8_t *seq_len_ptr, *ussd_len_ptr, *data;
int len;

-   msg = msgb_alloc_headroom(1024, 128, "GSM 04.80");
+   msg = gsm0480_msgb_alloc_name("TS 04.80 USSD Notify");
if (!msg)
return NULL;

@@ -177,7 +182,7 @@
if (len < 1 || len > 160)
return NULL;

-   msg = msgb_alloc_headroom(1024, 128, "GSM 04.80");
+   msg = gsm0480_msgb_alloc_name("TS 04.80 NotifySS");
if (!msg)
return NULL;

@@ -796,11 +801,6 @@
return rc;
 }

-struct msgb *gsm0480_msgb_alloc_name(const char *name)
-{
-   return msgb_alloc_headroom(1024, 128, name);
-}
-
 /*! Generate a USSD ReturnResult component containing a string in default GSM 
alphabet.
  * \param[in] invoke_idInvokeID of the request to which we 
respond
  * \param[in] text USSD text in ASCII; to be encoded as GSM 7-but 
alphabet
@@ -962,7 +962,7 @@
 {
struct msgb *msg;

-   msg = msgb_alloc_headroom(1024, 128, "GSM 04.80 USSD REL COMPL");
+   msg = gsm0480_msgb_alloc_name("TS 04.80 USSD REL COMPL");
if (!msg)
return NULL;


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

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


Change in libosmocore[master]: gsm/gsm0480.c: prevent NULL-pointer dereference

2018-08-02 Thread Vadim Yanitskiy
Vadim Yanitskiy has uploaded this change for review. ( 
https://gerrit.osmocom.org/10325


Change subject: gsm/gsm0480.c: prevent NULL-pointer dereference
..

gsm/gsm0480.c: prevent NULL-pointer dereference

Change-Id: I444d95941837458b46e581298f76f3a9926c8552
---
M src/gsm/gsm0480.c
1 file changed, 10 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/25/10325/1

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 2d2df4a..5b51c75 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -880,7 +880,11 @@
  */
 struct msgb *gsm0480_gen_return_error(uint8_t invoke_id, uint8_t error_code)
 {
-   struct msgb *msg = gsm0480_msgb_alloc_name("TS 04.80 ReturnError");
+   struct msgb *msg;
+
+   msg = gsm0480_msgb_alloc_name("TS 04.80 ReturnError");
+   if (!msg)
+   return NULL;

/* First insert the problem code */
msgb_push_TLV1(msg, GSM_0480_ERROR_CODE_TAG, error_code);
@@ -906,7 +910,11 @@
  */
 struct msgb *gsm0480_gen_reject(int invoke_id, uint8_t problem_tag, uint8_t 
problem_code)
 {
-   struct msgb *msg = gsm0480_msgb_alloc_name("TS 04.80 Reject");
+   struct msgb *msg;
+
+   msg = gsm0480_msgb_alloc_name("TS 04.80 Reject");
+   if (!msg)
+   return NULL;

/* First insert the problem code */
msgb_push_TLV1(msg, problem_tag, problem_code);

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

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


Change in simtrace2[master]: add libosmcore utilities

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10317 )

Change subject: add libosmcore utilities
..


Patch Set 1: Code-Review+2

we can do this, but in the not too distant future I would want to move to 
linking against a system-wide installed libosmocore.a for arm-none-eabi.  This 
way we don't end up copying code around.


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ifd9120fa951f41693903fb657d10826959f1599f
Gerrit-Change-Number: 10317
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Thu, 02 Aug 2018 20:59:29 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in simtrace2[master]: remsim: fix USB hanging USB transfer

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10319 )

Change subject: remsim: fix USB hanging USB transfer
..


Patch Set 1: Code-Review+2


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I1d124a41cc90893506933f6d76dc7331e52a74f9
Gerrit-Change-Number: 10319
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Thu, 02 Aug 2018 20:58:21 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in simtrace2[master]: cardem (minor): trace tx data send over USB

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10318 )

Change subject: cardem (minor): trace tx data send over USB
..


Patch Set 1:

why are you proposing this change?  debug UART band-width is much lower than 
the SIM card interface, and we are hex-dumping, so it will never be able to 
keep up?


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I69cef43dd5a78e9f82cc045cdb90c326b03d1f68
Gerrit-Change-Number: 10318
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: Harald Welte 
Gerrit-Comment-Date: Thu, 02 Aug 2018 20:57:36 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in simtrace2[master]: cardem: add state name in trace

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10316 )

Change subject: cardem: add state name in trace
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/10316/1/firmware/libcommon/source/card_emu.c
File firmware/libcommon/source/card_emu.c:

https://gerrit.osmocom.org/#/c/10316/1/firmware/libcommon/source/card_emu.c@58
PS1, Line 58:   {
I would suggest to simply use lines like OSMO_VALUE_STRING(ISO_S_WAIT_POWER) 
here. IT is easier to write and ensures the printed name reflects the actual 
enum name of the state.



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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Idf301e09cf14e2412e29dcb252563bc6e4e5c630
Gerrit-Change-Number: 10316
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: Harald Welte 
Gerrit-Comment-Date: Thu, 02 Aug 2018 20:56:24 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in simtrace2[master]: cardem: use TC2 as WI and update WT after ATR

2018-08-02 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/10311 )

Change subject: cardem: use TC2 as WI and update WT after ATR
..

cardem: use TC2 as WI and update WT after ATR

Change-Id: I3e51b16d557bc664f87563e1a3dce6642de474d2
---
M firmware/libcommon/source/card_emu.c
1 file changed, 33 insertions(+), 5 deletions(-)

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



diff --git a/firmware/libcommon/source/card_emu.c 
b/firmware/libcommon/source/card_emu.c
index 51fd923..ad6b4d9 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -363,11 +363,39 @@
TRACE_DEBUG("%u: ATR TX: %02x\n\r", ch->num, byte);
return 1;
} else { /* The ATR has been completely transmitted */
-   /* TODO update WI using optional TC2 and then update WT */
-   //ch->wi = ISO7816_3_DEFAULT_WI;
-   /* update waiting time */
-   //ch->waiting_time = ISO7816_3_INIT_WTIME;
-   //tc_etu_set_wtime(ch->tc_chan, ch->waiting_time);
+   /* search for TC2 to updated WI */
+   ch->wi = ISO7816_3_DEFAULT_WI;
+   if (ch->atr.len >= 2 && ch->atr.atr[1] & 0xf0) { /* Y1 has some 
data */
+   uint8_t atr_td1 = 2;
+   if (ch->atr.atr[1] & 0x10) { /* TA1 is present */
+   atr_td1++;
+   }
+   if (ch->atr.atr[1] & 0x20) { /* TB1 is present */
+   atr_td1++;
+   }
+   if (ch->atr.atr[1] & 0x40) { /* TC1 is present */
+   atr_td1++;
+   }
+   if (ch->atr.atr[1] & 0x80) { /* TD1 is present */
+   if (ch->atr.len > atr_td1 && 
ch->atr.atr[atr_td1] & 0xf0) { /* Y2 has some data */
+   uint8_t atr_tc2 = atr_td1+1;
+   if (ch->atr.atr[atr_td1] & 0x10) { /* 
TA2 is present */
+   atr_tc2++;
+   }
+   if (ch->atr.atr[atr_td1] & 0x20) { /* 
TB2 is present */
+   atr_tc2++;
+   }
+   if (ch->atr.atr[atr_td1] & 0x40) { /* 
TC2 is present */
+   if (ch->atr.len > atr_tc2 && 
ch->atr.atr[atr_tc2]) { /* TC2 encodes WI */
+   ch->wi = 
ch->atr.atr[atr_tc2]; /* set WI */
+   }
+   }
+   }
+   }
+   }
+   /* update waiting time (see ISO 7816-3 10.2) */
+   ch->waiting_time = ch->wi * 960 * ch->fi;
+   tc_etu_set_wtime(ch->tc_chan, ch->waiting_time);
/* reset PTS to initial state */
set_pts_state(ch, PTS_S_WAIT_REQ_PTSS);
/* go to next state */

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3e51b16d557bc664f87563e1a3dce6642de474d2
Gerrit-Change-Number: 10311
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


Change in simtrace2[master]: sniff: send incomplete TPDU when reset is asserted

2018-08-02 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/10312 )

Change subject: sniff: send incomplete TPDU when reset is asserted
..

sniff: send incomplete TPDU when reset is asserted

Change-Id: I8d7e4d604cded535e40d27c2be872268e0f24c20
---
M firmware/libcommon/source/sniffer.c
1 file changed, 17 insertions(+), 0 deletions(-)

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



diff --git a/firmware/libcommon/source/sniffer.c 
b/firmware/libcommon/source/sniffer.c
index 982653c..3cd0b89 100644
--- a/firmware/libcommon/source/sniffer.c
+++ b/firmware/libcommon/source/sniffer.c
@@ -1050,6 +1050,23 @@
/* Handle flags */
if (change_flags) { /* WARNING this is not synced with the data buffer 
handling */
if (change_flags & SNIFF_CHANGE_FLAG_RESET_ASSERT) {
+   switch (iso_state) {
+   case ISO7816_S_IN_ATR:
+   led_blink(LED_RED, BLINK_2F_O); /* indicate 
error to user */
+   usb_send_atr(SNIFF_DATA_FLAG_ERROR_INCOMPLETE); 
/* send incomplete ATR to host software using USB */
+   break;
+   case ISO7816_S_IN_TPDU:
+   led_blink(LED_RED, BLINK_2F_O); /* indicate 
error to user */
+   
usb_send_tpdu(SNIFF_DATA_FLAG_ERROR_INCOMPLETE); /* send incomplete PPS to host 
software using USB */
+   break;
+   case ISO7816_S_IN_PPS_REQ:
+   case ISO7816_S_IN_PPS_RSP:
+   led_blink(LED_RED, BLINK_2F_O); /* indicate 
error to user */
+   usb_send_pps(SNIFF_DATA_FLAG_ERROR_INCOMPLETE); 
/* send incomplete TPDU to host software using USB */
+   break;
+   default:
+   break;
+   }
if (ISO7816_S_RESET != iso_state) {
change_state(ISO7816_S_RESET);
printf("reset asserted\n\r");

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I8d7e4d604cded535e40d27c2be872268e0f24c20
Gerrit-Change-Number: 10312
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


Change in osmo-hlr[master]: hlr_ussd.c: avoid using CR and NL in IUSE responses

2018-08-02 Thread Vadim Yanitskiy
Vadim Yanitskiy has posted comments on this change. ( 
https://gerrit.osmocom.org/10323 )

Change subject: hlr_ussd.c: avoid using CR and NL in IUSE responses
..


Patch Set 1:

> I actually intentionally added the \n in OsmoHLR as we also had the
 > \n in OsmoMSC before, and I wanted to make sure the messages are
 > identical in both cases, not to break tests e.g. in
 > osmo-gsm-tester.

AFAIR, we had exactly '\r' in OsmoMSC (and still have in OpenBSC).
At least, it makes sense to replace '\n' by '\r'...


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

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I09e8a67758698f3b7a578eab956311e269d091ee
Gerrit-Change-Number: 10323
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Comment-Date: Thu, 02 Aug 2018 19:41:06 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in simtrace2[master]: cardem (minor): remove to verbose log trace

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10315 )

Change subject: cardem (minor): remove to verbose log trace
..


Patch Set 1: Code-Review+2


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie43a33af3728c0700f71527ca75d909a9ebd2529
Gerrit-Change-Number: 10315
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Thu, 02 Aug 2018 19:25:50 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in simtrace2[master]: cardem: minor typo fix in comment

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10314 )

Change subject: cardem: minor typo fix in comment
..


Patch Set 1: Code-Review+2


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib1dee95e15db1c6bb3b45920d7c1a567e2ba474b
Gerrit-Change-Number: 10314
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Thu, 02 Aug 2018 19:25:38 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in simtrace2[master]: sniff: send incomplete TPDU when reset is asserted

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10312 )

Change subject: sniff: send incomplete TPDU when reset is asserted
..


Patch Set 1: Code-Review+2


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I8d7e4d604cded535e40d27c2be872268e0f24c20
Gerrit-Change-Number: 10312
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Thu, 02 Aug 2018 19:24:11 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in simtrace2[master]: cardem: use TC2 as WI and update WT after ATR

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10311 )

Change subject: cardem: use TC2 as WI and update WT after ATR
..


Patch Set 1: Code-Review+2


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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3e51b16d557bc664f87563e1a3dce6642de474d2
Gerrit-Change-Number: 10311
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Thu, 02 Aug 2018 19:23:48 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-hlr[master]: hlr_ussd.c: fix: properly print a EUSE / IUSE name

2018-08-02 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/10322 )

Change subject: hlr_ussd.c: fix: properly print a EUSE / IUSE name
..

hlr_ussd.c: fix: properly print a EUSE / IUSE name

We need to distinguish between both EUSE and IUSE, and properly
print their names. Otherwise, garbage is printed in case of IUSE.

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

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



diff --git a/src/hlr_ussd.c b/src/hlr_ussd.c
index f9399d2..7b981bb 100644
--- a/src/hlr_ussd.c
+++ b/src/hlr_ussd.c
@@ -126,8 +126,10 @@
struct hlr_ussd_route *rt;
llist_for_each_entry(rt, >ussd_routes, list) {
if (!strncmp(ussd_code, rt->prefix, strlen(rt->prefix))) {
-   LOGP(DSS, LOGL_DEBUG, "Found EUSE %s (prefix %s) for 
USSD Code '%s'\n",
-   rt->u.euse->name, rt->prefix, ussd_code);
+   LOGP(DSS, LOGL_DEBUG, "Found %s '%s' (prefix '%s') for 
USSD "
+   "Code '%s'\n", rt->is_external ? "EUSE" : 
"IUSE",
+   rt->is_external ? rt->u.euse->name : 
rt->u.iuse->name,
+   rt->prefix, ussd_code);
return rt;
}
}

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

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I497e7c1fe41279afdb1256ee69e166066a6462bb
Gerrit-Change-Number: 10322
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


Change in osmo-hlr[master]: hlr_ussd.c: fix: properly print a EUSE / IUSE name

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10322 )

Change subject: hlr_ussd.c: fix: properly print a EUSE / IUSE name
..


Patch Set 1: Code-Review+2


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

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I497e7c1fe41279afdb1256ee69e166066a6462bb
Gerrit-Change-Number: 10322
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Thu, 02 Aug 2018 19:22:57 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-hlr[master]: USSD/hlr_vty.c: print error if EUSE is not found

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10321 )

Change subject: USSD/hlr_vty.c: print error if EUSE is not found
..


Patch Set 1: Code-Review+2


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

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I18045c5e544a99b2414a6f0268f1343df119b9f3
Gerrit-Change-Number: 10321
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Thu, 02 Aug 2018 19:22:37 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-hlr[master]: USSD/hlr_vty.c: print error if EUSE is not found

2018-08-02 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/10321 )

Change subject: USSD/hlr_vty.c: print error if EUSE is not found
..

USSD/hlr_vty.c: print error if EUSE is not found

Change-Id: I18045c5e544a99b2414a6f0268f1343df119b9f3
---
M src/hlr_vty.c
1 file changed, 7 insertions(+), 1 deletion(-)

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



diff --git a/src/hlr_vty.c b/src/hlr_vty.c
index 9532a03..2d9b929 100644
--- a/src/hlr_vty.c
+++ b/src/hlr_vty.c
@@ -193,7 +193,13 @@
USSD_STR "Configure default-route for all USSD to unknown 
destinations\n"
EXT_STR)
 {
-   struct hlr_euse *euse = euse_find(g_hlr, argv[0]);
+   struct hlr_euse *euse;
+
+   euse = euse_find(g_hlr, argv[0]);
+   if (!euse) {
+   vty_out(vty, "%% Cannot find EUSE %s%s", argv[0], VTY_NEWLINE);
+   return CMD_WARNING;
+   }

if (g_hlr->euse_default != euse) {
vty_out(vty, "Switching default route from %s to %s%s",

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

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I18045c5e544a99b2414a6f0268f1343df119b9f3
Gerrit-Change-Number: 10321
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


Change in osmo-hlr[master]: hlr_ussd.c: avoid using CR and NL in IUSE responses

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10323 )

Change subject: hlr_ussd.c: avoid using CR and NL in IUSE responses
..


Patch Set 1:

I actually intentionally added the \n in OsmoHLR as we also had the \n in 
OsmoMSC before, and I wanted to make sure the messages are identical in both 
cases, not to break tests e.g. in osmo-gsm-tester.


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

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I09e8a67758698f3b7a578eab956311e269d091ee
Gerrit-Change-Number: 10323
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Thu, 02 Aug 2018 19:22:07 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in osmo-ttcn3-hacks[master]: IPA_Emulation: Add missing zero byte to strings in IPA CCM ID RESP

2018-08-02 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/10324 )

Change subject: IPA_Emulation: Add missing zero byte to strings in IPA CCM ID 
RESP
..

IPA_Emulation: Add missing zero byte to strings in IPA CCM ID RESP

Change-Id: I3fdc0f47381d5ba1763197d5f264696f04d0396f
---
M library/IPA_Emulation.ttcnpp
M library/IPA_Types.ttcn
2 files changed, 2 insertions(+), 2 deletions(-)

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



diff --git a/library/IPA_Emulation.ttcnpp b/library/IPA_Emulation.ttcnpp
index a271f2d..b10a983 100644
--- a/library/IPA_Emulation.ttcnpp
+++ b/library/IPA_Emulation.ttcnpp
@@ -239,7 +239,7 @@
 private template IpaCcmRespPart t_IdRespPart(IpaCcmIdTag tag, charstring 
payload) := {
len := 0,   /* overwritten by codec */
tag := tag,
-   data := payload
+   data := char2oct(payload) & '00'O
 }

 private function f_send_IPA_EVT(template ASP_IPA_Event evt) runs on 
IPA_Emulation_CT {
diff --git a/library/IPA_Types.ttcn b/library/IPA_Types.ttcn
index 933a3fe..3230329 100644
--- a/library/IPA_Types.ttcn
+++ b/library/IPA_Types.ttcn
@@ -98,7 +98,7 @@
 type record IpaCcmRespPart {
uint16_tlen,
IpaCcmIdTag tag,
-   charstring  data
+   octetstring data
 } with { variant (len) "LENGTHTO(data,tag)" }
 type set of IpaCcmRespPart IpaCcmIdResp;


--
To view, visit https://gerrit.osmocom.org/10324
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: I3fdc0f47381d5ba1763197d5f264696f04d0396f
Gerrit-Change-Number: 10324
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


Change in osmo-ttcn3-hacks[master]: IPA_Emulation: Add missing zero byte to strings in IPA CCM ID RESP

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10324 )

Change subject: IPA_Emulation: Add missing zero byte to strings in IPA CCM ID 
RESP
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/10324
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: I3fdc0f47381d5ba1763197d5f264696f04d0396f
Gerrit-Change-Number: 10324
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Thu, 02 Aug 2018 19:21:16 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-ttcn3-hacks[master]: IPA_Emulation: Add missing zero byte to strings in IPA CCM ID RESP

2018-08-02 Thread Harald Welte
Harald Welte has uploaded this change for review. ( 
https://gerrit.osmocom.org/10324


Change subject: IPA_Emulation: Add missing zero byte to strings in IPA CCM ID 
RESP
..

IPA_Emulation: Add missing zero byte to strings in IPA CCM ID RESP

Change-Id: I3fdc0f47381d5ba1763197d5f264696f04d0396f
---
M library/IPA_Emulation.ttcnpp
M library/IPA_Types.ttcn
2 files changed, 2 insertions(+), 2 deletions(-)



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

diff --git a/library/IPA_Emulation.ttcnpp b/library/IPA_Emulation.ttcnpp
index a271f2d..b10a983 100644
--- a/library/IPA_Emulation.ttcnpp
+++ b/library/IPA_Emulation.ttcnpp
@@ -239,7 +239,7 @@
 private template IpaCcmRespPart t_IdRespPart(IpaCcmIdTag tag, charstring 
payload) := {
len := 0,   /* overwritten by codec */
tag := tag,
-   data := payload
+   data := char2oct(payload) & '00'O
 }

 private function f_send_IPA_EVT(template ASP_IPA_Event evt) runs on 
IPA_Emulation_CT {
diff --git a/library/IPA_Types.ttcn b/library/IPA_Types.ttcn
index 933a3fe..3230329 100644
--- a/library/IPA_Types.ttcn
+++ b/library/IPA_Types.ttcn
@@ -98,7 +98,7 @@
 type record IpaCcmRespPart {
uint16_tlen,
IpaCcmIdTag tag,
-   charstring  data
+   octetstring data
 } with { variant (len) "LENGTHTO(data,tag)" }
 type set of IpaCcmRespPart IpaCcmIdResp;


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

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3fdc0f47381d5ba1763197d5f264696f04d0396f
Gerrit-Change-Number: 10324
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte 


Change in osmo-hlr[master]: hlr_ussd.c: avoid using CR and NL in IUSE responses

2018-08-02 Thread Vadim Yanitskiy
Vadim Yanitskiy has uploaded this change for review. ( 
https://gerrit.osmocom.org/10323


Change subject: hlr_ussd.c: avoid using CR and NL in IUSE responses
..

hlr_ussd.c: avoid using CR and NL in IUSE responses

According to GSM TS 03.38, section 6.1.2.1, CR symbol at the end
is optional, and moreover libosmogsm encoding API will carry
about the bit padding itself.

Change-Id: I09e8a67758698f3b7a578eab956311e269d091ee
---
M src/hlr_ussd.c
1 file changed, 2 insertions(+), 2 deletions(-)



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

diff --git a/src/hlr_ussd.c b/src/hlr_ussd.c
index 7b981bb..d8bbcb5 100644
--- a/src/hlr_ussd.c
+++ b/src/hlr_ussd.c
@@ -297,7 +297,7 @@
if (strlen(subscr.msisdn) == 0)
snprintf(buf, sizeof(buf), "You have no MSISDN!");
else
-   snprintf(buf, sizeof(buf), "Your extension is %s\r", 
subscr.msisdn);
+   snprintf(buf, sizeof(buf), "Your extension is %s", 
subscr.msisdn);
ss_tx_ussd_7bit(ss, true, req->invoke_id, buf);
break;
case -ENOENT:
@@ -315,7 +315,7 @@
const struct osmo_gsup_message *gsup, const 
struct ss_request *req)
 {
char buf[GSM0480_USSD_7BIT_STRING_LEN+1];
-   snprintf(buf, sizeof(buf), "Your IMSI is %s!\n", ss->imsi);
+   snprintf(buf, sizeof(buf), "Your IMSI is %s!", ss->imsi);
ss_tx_ussd_7bit(ss, true, req->invoke_id, buf);
return 0;
 }

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

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I09e8a67758698f3b7a578eab956311e269d091ee
Gerrit-Change-Number: 10323
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 


Change in osmo-hlr[master]: hlr_ussd.c: fix: properly print a EUSE / IUSE name

2018-08-02 Thread Vadim Yanitskiy
Vadim Yanitskiy has uploaded this change for review. ( 
https://gerrit.osmocom.org/10322


Change subject: hlr_ussd.c: fix: properly print a EUSE / IUSE name
..

hlr_ussd.c: fix: properly print a EUSE / IUSE name

We need to distinguish between both EUSE and IUSE, and properly
print their names. Otherwise, garbage is printed in case of IUSE.

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



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

diff --git a/src/hlr_ussd.c b/src/hlr_ussd.c
index f9399d2..7b981bb 100644
--- a/src/hlr_ussd.c
+++ b/src/hlr_ussd.c
@@ -126,8 +126,10 @@
struct hlr_ussd_route *rt;
llist_for_each_entry(rt, >ussd_routes, list) {
if (!strncmp(ussd_code, rt->prefix, strlen(rt->prefix))) {
-   LOGP(DSS, LOGL_DEBUG, "Found EUSE %s (prefix %s) for 
USSD Code '%s'\n",
-   rt->u.euse->name, rt->prefix, ussd_code);
+   LOGP(DSS, LOGL_DEBUG, "Found %s '%s' (prefix '%s') for 
USSD "
+   "Code '%s'\n", rt->is_external ? "EUSE" : 
"IUSE",
+   rt->is_external ? rt->u.euse->name : 
rt->u.iuse->name,
+   rt->prefix, ussd_code);
return rt;
}
}

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

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I497e7c1fe41279afdb1256ee69e166066a6462bb
Gerrit-Change-Number: 10322
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 


Change in osmo-hlr[master]: USSD/hlr_vty.c: print error if EUSE is not found

2018-08-02 Thread Vadim Yanitskiy
Vadim Yanitskiy has uploaded this change for review. ( 
https://gerrit.osmocom.org/10321


Change subject: USSD/hlr_vty.c: print error if EUSE is not found
..

USSD/hlr_vty.c: print error if EUSE is not found

Change-Id: I18045c5e544a99b2414a6f0268f1343df119b9f3
---
M src/hlr_vty.c
1 file changed, 7 insertions(+), 1 deletion(-)



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

diff --git a/src/hlr_vty.c b/src/hlr_vty.c
index 9532a03..2d9b929 100644
--- a/src/hlr_vty.c
+++ b/src/hlr_vty.c
@@ -193,7 +193,13 @@
USSD_STR "Configure default-route for all USSD to unknown 
destinations\n"
EXT_STR)
 {
-   struct hlr_euse *euse = euse_find(g_hlr, argv[0]);
+   struct hlr_euse *euse;
+
+   euse = euse_find(g_hlr, argv[0]);
+   if (!euse) {
+   vty_out(vty, "%% Cannot find EUSE %s%s", argv[0], VTY_NEWLINE);
+   return CMD_WARNING;
+   }

if (g_hlr->euse_default != euse) {
vty_out(vty, "Switching default route from %s to %s%s",

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

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I18045c5e544a99b2414a6f0268f1343df119b9f3
Gerrit-Change-Number: 10321
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 


Change in osmo-mgw[master]: mgcp_sdp: restructure mgcp_write_response_sdp() (rtpmap)

2018-08-02 Thread dexter
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/10310

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

Change subject: mgcp_sdp: restructure mgcp_write_response_sdp() (rtpmap)
..

mgcp_sdp: restructure mgcp_write_response_sdp() (rtpmap)

The function mgcp_write_response_sdp() generates the rtpmap lines in the
sdp response. Since we will likely support multiple codecs we will need
to generate several rtpmap lines. Therefore it makes sense to split up
that part in a separate function without altering the overall
functionality (yet)

- add static function add_rtpmap() to generate the rtpmap.

Change-Id: I520e2d40fe6294c88bae63dfcbc5238ef98101e2
Related: OS#3442
---
M src/libosmo-mgcp/mgcp_sdp.c
1 file changed, 20 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/10/10310/3
--
To view, visit https://gerrit.osmocom.org/10310
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I520e2d40fe6294c88bae63dfcbc5238ef98101e2
Gerrit-Change-Number: 10310
Gerrit-PatchSet: 3
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder


Change in osmo-mgw[master]: mgcp_sdp: restructure mgcp_write_response_sdp() (rtpmap)

2018-08-02 Thread dexter
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/10310

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

Change subject: mgcp_sdp: restructure mgcp_write_response_sdp() (rtpmap)
..

mgcp_sdp: restructure mgcp_write_response_sdp() (rtpmap)

The function mgcp_write_response_sdp() generates the rtpmap lines in the
sdp response. Since we will likely support multiple codecs we will need
to generate several rtpmap lines. Therefore it makes sense to split up
that part in a separate function without altering the overall
functionality (yet)

- add static function add_rtpmap() to generate the rtpmap.

Change-Id: I520e2d40fe6294c88bae63dfcbc5238ef98101e2
Related: OS#3442
---
M src/libosmo-mgcp/mgcp_sdp.c
1 file changed, 20 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/10/10310/2
--
To view, visit https://gerrit.osmocom.org/10310
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I520e2d40fe6294c88bae63dfcbc5238ef98101e2
Gerrit-Change-Number: 10310
Gerrit-PatchSet: 2
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder


Change in osmo-mgw[master]: mgcp_sdp: restructure mgcp_write_response_sdp() (audio)

2018-08-02 Thread dexter
dexter has uploaded a new patch set (#2). ( https://gerrit.osmocom.org/10320 )

Change subject: mgcp_sdp: restructure mgcp_write_response_sdp() (audio)
..

mgcp_sdp: restructure mgcp_write_response_sdp() (audio)

The function mgcp_write_response_sdp() is responsible to write the
audio port and the list with the supported payload type numbers to
the sdp response. At the moment it can only write exactly one payload
type number to the response, but in the future we may want to write
several payload type numbers to the response. Lets add a function
for that so that now.

- add add_audio() helper function to add multiple payload type
  numbers, but keep the functionality as it is for now

Change-Id: I662c725f697b2ffb1e3ad4671a445f943cd79b63
Related: OS#3442
---
M src/libosmo-mgcp/mgcp_sdp.c
1 file changed, 30 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/20/10320/2
--
To view, visit https://gerrit.osmocom.org/10320
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I662c725f697b2ffb1e3ad4671a445f943cd79b63
Gerrit-Change-Number: 10320
Gerrit-PatchSet: 2
Gerrit-Owner: dexter 
Gerrit-CC: Jenkins Builder


Change in osmo-mgw[master]: mgcp_sdp: restructure mgcp_write_response_sdp() (audio)

2018-08-02 Thread dexter
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/10320


Change subject: mgcp_sdp: restructure mgcp_write_response_sdp() (audio)
..

mgcp_sdp: restructure mgcp_write_response_sdp() (audio)

The function mgcp_write_response_sdp() is responsible to write the
audio port and the list with the supported payload type numbers to
the sdp response. At the moment it can only write exactly one payload
type number to the response, but in the future we may want to write
several payload type numbers to the response. Lets add a function
for that so that now.

- add add_audio() helper function to add multiple payload type
  numbers, but keep the functionality as it is for now

Change-Id: I662c725f697b2ffb1e3ad4671a445f943cd79b63
Related: OS#3442
---
M src/libosmo-mgcp/mgcp_sdp.c
1 file changed, 30 insertions(+), 2 deletions(-)



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

diff --git a/src/libosmo-mgcp/mgcp_sdp.c b/src/libosmo-mgcp/mgcp_sdp.c
index 798b3b2..0f68acc 100644
--- a/src/libosmo-mgcp/mgcp_sdp.c
+++ b/src/libosmo-mgcp/mgcp_sdp.c
@@ -304,6 +304,32 @@
return 0;
 }

+/* Add audio string to sdp payload */
+static int add_audio(struct msgb *sdp, int *payload_types, unsigned int 
payload_types_len, int local_port)
+{
+   int rc;
+   unsigned int i;
+
+   if (payload_types_len < 0)
+   return -EINVAL;
+
+   rc = msgb_printf(sdp, "m=audio %d RTP/AVP", local_port);
+   if (rc < 0)
+   return -EINVAL;
+
+   for (i = 0; i < payload_types_len; i++) {
+   rc = msgb_printf(sdp, " %d", payload_types[i]);
+   if (rc < 0)
+   return -EINVAL;
+   }
+
+   rc = msgb_printf(sdp, "\r\n");
+   if (rc < 0)
+   return -EINVAL;
+
+   return 0;
+}
+
 /*! Generate SDP response string.
  *  \param[in] endp trunk endpoint.
  *  \param[in] conn associated rtp connection.
@@ -318,6 +344,7 @@
const char *audio_name;
int payload_type;
int rc;
+   int payload_types[1];

OSMO_ASSERT(endp);
OSMO_ASSERT(conn);
@@ -341,8 +368,9 @@
goto buffer_too_small;

if (payload_type >= 0) {
-   rc = msgb_printf(sdp, "m=audio %d RTP/AVP %d\r\n",
-conn->end.local_port, payload_type);
+
+   payload_types[0] = payload_type;
+   rc = add_audio(sdp, payload_types, 1, conn->end.local_port);
if (rc < 0)
goto buffer_too_small;


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

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


Change in simtrace2[master]: add libosmcore utilities

2018-08-02 Thread Kévin Redon
Kévin Redon has uploaded this change for review. ( 
https://gerrit.osmocom.org/10317


Change subject: add libosmcore utilities
..

add libosmcore utilities

osmo_hexdump is particularly useful.
previously it was only defined, but not implemented.
this cause random behaviour upon call, often resulting in
memory corruption.

Change-Id: Ifd9120fa951f41693903fb657d10826959f1599f
---
A firmware/libosmocore/source/utils.c
1 file changed, 632 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/17/10317/1

diff --git a/firmware/libosmocore/source/utils.c 
b/firmware/libosmocore/source/utils.c
new file mode 100644
index 000..3096572
--- /dev/null
+++ b/firmware/libosmocore/source/utils.c
@@ -0,0 +1,632 @@
+/*
+ * (C) 2011 by Harald Welte 
+ * (C) 2011 by Sylvain Munaut 
+ * (C) 2014 by Nils O. Selåsdal 
+ *
+ * All Rights Reserved
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+
+/*! \addtogroup utils
+ * @{
+ * various utility routines
+ *
+ * \file utils.c */
+
+static char namebuf[255];
+
+/*! get human-readable string for given value
+ *  \param[in] vs Array of value_string tuples
+ *  \param[in] val Value to be converted
+ *  \returns pointer to human-readable string
+ *
+ * If val is found in vs, the array's string entry is returned. Otherwise, an
+ * "unknown" string containing the actual value is composed in a static buffer
+ * that is reused across invocations.
+ */
+const char *get_value_string(const struct value_string *vs, uint32_t val)
+{
+   const char *str = get_value_string_or_null(vs, val);
+   if (str)
+   return str;
+
+   snprintf(namebuf, sizeof(namebuf), "unknown 0x%"PRIx32, val);
+   namebuf[sizeof(namebuf) - 1] = '\0';
+   return namebuf;
+}
+
+/*! get human-readable string or NULL for given value
+ *  \param[in] vs Array of value_string tuples
+ *  \param[in] val Value to be converted
+ *  \returns pointer to human-readable string or NULL if val is not found
+ */
+const char *get_value_string_or_null(const struct value_string *vs,
+uint32_t val)
+{
+   int i;
+
+   for (i = 0;; i++) {
+   if (vs[i].value == 0 && vs[i].str == NULL)
+   break;
+   if (vs[i].value == val)
+   return vs[i].str;
+   }
+
+   return NULL;
+}
+
+/*! get numeric value for given human-readable string
+ *  \param[in] vs Array of value_string tuples
+ *  \param[in] str human-readable string
+ *  \returns numeric value (>0) or negative numer in case of error
+ */
+int get_string_value(const struct value_string *vs, const char *str)
+{
+   int i;
+
+   for (i = 0;; i++) {
+   if (vs[i].value == 0 && vs[i].str == NULL)
+   break;
+   if (!strcasecmp(vs[i].str, str))
+   return vs[i].value;
+   }
+   return -EINVAL;
+}
+
+/*! Convert BCD-encoded digit into printable character
+ *  \param[in] bcd A single BCD-encoded digit
+ *  \returns single printable character
+ */
+char osmo_bcd2char(uint8_t bcd)
+{
+   if (bcd < 0xa)
+   return '0' + bcd;
+   else
+   return 'A' + (bcd - 0xa);
+}
+
+/*! Convert number in ASCII to BCD value
+ *  \param[in] c ASCII character
+ *  \returns BCD encoded value of character
+ */
+uint8_t osmo_char2bcd(char c)
+{
+   if (c >= '0' && c <= '9')
+   return c - 0x30;
+   else if (c >= 'A' && c <= 'F')
+   return 0xa + (c - 'A');
+   else if (c >= 'a' && c <= 'f')
+   return 0xa + (c - 'a');
+   else
+   return 0;
+}
+
+/*! Parse a string containing hexadecimal digits
+ *  \param[in] str string containing ASCII encoded hexadecimal digits
+ *  \param[out] b output buffer
+ *  \param[in] max_len maximum space in output buffer
+ *  \returns number of parsed octets, or -1 on error
+ */
+int osmo_hexparse(const char *str, uint8_t *b, int max_len)
+
+{
+   char c;
+   uint8_t v;
+   const char *strpos;
+   unsigned int nibblepos = 0;
+

Change in simtrace2[master]: remsim: fix USB hanging USB transfer

2018-08-02 Thread Kévin Redon
Kévin Redon has uploaded this change for review. ( 
https://gerrit.osmocom.org/10319


Change subject: remsim: fix USB hanging USB transfer
..

remsim: fix USB hanging USB transfer

After a couple of seconds of USB data exchange between remsim and
cardem, the USB transfer hangs.
On host side (remsim) I can see the USB BULK IN request.
On device side (cardem) I see that data has been submitted and
"sent" over USB, but on wireshark with USBmon I don't see the
corresponding USB BULK IN response.
When exiting remsim or just after powering of qmod (causing an
error in remsim) the USB BULK IN is show in wireshark. Thus it
must have been in a buffer, but not read by libusb_bulk_transfer.
By shortening the timeout a new libusb_bulk_transfer is made more
frequently, and the data gets read successfully.

T;his change also fixes the URB data display.

Change-Id: I1d124a41cc90893506933f6d76dc7331e52a74f9
---
M host/simtrace2-remsim.c
1 file changed, 2 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/19/10319/1

diff --git a/host/simtrace2-remsim.c b/host/simtrace2-remsim.c
index 52c5051..9a681b4 100644
--- a/host/simtrace2-remsim.c
+++ b/host/simtrace2-remsim.c
@@ -536,7 +536,7 @@
/* read data from SIMtrace2 device (local or via USB) */
if (transp->udp_fd < 0) {
rc = libusb_bulk_transfer(transp->usb_devh, 
transp->usb_ep.in,
- buf, sizeof(buf), _len, 
10);
+ buf, sizeof(buf), _len, 
100);
if (rc < 0 && rc != LIBUSB_ERROR_TIMEOUT &&
  rc != LIBUSB_ERROR_INTERRUPTED &&
  rc != LIBUSB_ERROR_IO) {
@@ -553,7 +553,7 @@
}
/* dispatch any incoming data */
if (xfer_len > 0) {
-   printf("URB: %s\n", osmo_hexdump(buf, rc));
+   printf("URB: %s\n", osmo_hexdump(buf, xfer_len));
process_usb_msg(ci, buf, xfer_len);
msg_count++;
byte_count += xfer_len;

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d124a41cc90893506933f6d76dc7331e52a74f9
Gerrit-Change-Number: 10319
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 


Change in simtrace2[master]: cardem (minor): trace tx data send over USB

2018-08-02 Thread Kévin Redon
Kévin Redon has uploaded this change for review. ( 
https://gerrit.osmocom.org/10318


Change subject: cardem (minor): trace tx data send over USB
..

cardem (minor): trace tx data send over USB

Change-Id: I69cef43dd5a78e9f82cc045cdb90c326b03d1f68
---
M firmware/libcommon/source/card_emu.c
1 file changed, 3 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/18/10318/1

diff --git a/firmware/libcommon/source/card_emu.c 
b/firmware/libcommon/source/card_emu.c
index fac6aef..625e880 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -247,6 +247,9 @@
rd = (struct cardemu_usb_msg_rx_data *) msg->l2h;
rd->data_len = msgb_l2len(msg) - sizeof(*rd);

+   TRACE_INFO("%u: %s: %s\n\r",
+   ch->num, __func__, osmo_hexdump(msg->l2h, 
rd->data_len));
+
usb_buf_upd_len_and_submit(msg);
 }
 

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I69cef43dd5a78e9f82cc045cdb90c326b03d1f68
Gerrit-Change-Number: 10318
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 


Change in simtrace2[master]: cardem: add state name in trace

2018-08-02 Thread Kévin Redon
Kévin Redon has uploaded this change for review. ( 
https://gerrit.osmocom.org/10316


Change subject: cardem: add state name in trace
..

cardem: add state name in trace

this helps reading the output while debugging quite a lot

Change-Id: Idf301e09cf14e2412e29dcb252563bc6e4e5c630
---
M firmware/libcommon/source/card_emu.c
1 file changed, 43 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/16/10316/1

diff --git a/firmware/libcommon/source/card_emu.c 
b/firmware/libcommon/source/card_emu.c
index 14a5dd8..fac6aef 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -54,6 +54,46 @@
ISO_S_IN_TPDU,  /* inside a TPDU */
 };

+const struct value_string iso7816_3_card_state_names[] = {
+   {
+   .value = ISO_S_WAIT_POWER,
+   .str = "wait power",
+   },
+   {
+   .value = ISO_S_WAIT_CLK,
+   .str = "wait clock",
+   },
+   {
+   .value = ISO_S_WAIT_RST,
+   .str = "wait reset",
+   },
+   {
+   .value = ISO_S_WAIT_ATR,
+   .str = "wait ATR",
+   },
+   {
+   .value = ISO_S_IN_ATR,
+   .str = "in ATR",
+   },
+   {
+   .value = ISO_S_IN_PTS,
+   .str = "in PTS",
+   },
+   {
+   .value = ISO_S_WAIT_TPDU,
+   .str = "wait TPDU",
+   },
+   {
+   .value = ISO_S_IN_TPDU,
+   .str = "in TPDU",
+   },
+   {
+   .value = 0,
+   .str = NULL,
+   },
+};
+
+
 /* detailed sub-states of ISO_S_IN_PTS */
 enum pts_state {
PTS_S_WAIT_REQ_PTSS,
@@ -285,8 +325,9 @@
if (ch->state == new_state)
return;

-   TRACE_DEBUG("%u: 7816 card state %u -> %u\r\n", ch->num,
-   ch->state, new_state);
+   TRACE_DEBUG("%u: 7816 card state %u (%s) -> %u (%s)\r\n", ch->num,
+   ch->state, get_value_string(iso7816_3_card_state_names, 
ch->state),
+   new_state, get_value_string(iso7816_3_card_state_names, 
new_state));
ch->state = new_state;

switch (new_state) {

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idf301e09cf14e2412e29dcb252563bc6e4e5c630
Gerrit-Change-Number: 10316
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 


Change in simtrace2[master]: sniff: send incomplete TPDU when reset is asserted

2018-08-02 Thread Kévin Redon
Kévin Redon has uploaded this change for review. ( 
https://gerrit.osmocom.org/10312


Change subject: sniff: send incomplete TPDU when reset is asserted
..

sniff: send incomplete TPDU when reset is asserted

Change-Id: I8d7e4d604cded535e40d27c2be872268e0f24c20
---
M firmware/libcommon/source/sniffer.c
1 file changed, 17 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/12/10312/1

diff --git a/firmware/libcommon/source/sniffer.c 
b/firmware/libcommon/source/sniffer.c
index 982653c..3cd0b89 100644
--- a/firmware/libcommon/source/sniffer.c
+++ b/firmware/libcommon/source/sniffer.c
@@ -1050,6 +1050,23 @@
/* Handle flags */
if (change_flags) { /* WARNING this is not synced with the data buffer 
handling */
if (change_flags & SNIFF_CHANGE_FLAG_RESET_ASSERT) {
+   switch (iso_state) {
+   case ISO7816_S_IN_ATR:
+   led_blink(LED_RED, BLINK_2F_O); /* indicate 
error to user */
+   usb_send_atr(SNIFF_DATA_FLAG_ERROR_INCOMPLETE); 
/* send incomplete ATR to host software using USB */
+   break;
+   case ISO7816_S_IN_TPDU:
+   led_blink(LED_RED, BLINK_2F_O); /* indicate 
error to user */
+   
usb_send_tpdu(SNIFF_DATA_FLAG_ERROR_INCOMPLETE); /* send incomplete PPS to host 
software using USB */
+   break;
+   case ISO7816_S_IN_PPS_REQ:
+   case ISO7816_S_IN_PPS_RSP:
+   led_blink(LED_RED, BLINK_2F_O); /* indicate 
error to user */
+   usb_send_pps(SNIFF_DATA_FLAG_ERROR_INCOMPLETE); 
/* send incomplete TPDU to host software using USB */
+   break;
+   default:
+   break;
+   }
if (ISO7816_S_RESET != iso_state) {
change_state(ISO7816_S_RESET);
printf("reset asserted\n\r");

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8d7e4d604cded535e40d27c2be872268e0f24c20
Gerrit-Change-Number: 10312
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 


Change in simtrace2[master]: cardem: minor typo fix in comment

2018-08-02 Thread Kévin Redon
Kévin Redon has uploaded this change for review. ( 
https://gerrit.osmocom.org/10314


Change subject: cardem: minor typo fix in comment
..

cardem: minor typo fix in comment

Change-Id: Ib1dee95e15db1c6bb3b45920d7c1a567e2ba474b
---
M firmware/libcommon/source/card_emu.c
1 file changed, 2 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/14/10314/1

diff --git a/firmware/libcommon/source/card_emu.c 
b/firmware/libcommon/source/card_emu.c
index ad6b4d9..fb68660 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -85,7 +85,7 @@
TPDU_S_WAIT_P2, /* waiting for P2 byte from reader */
TPDU_S_WAIT_P3, /* waiting for P3 byte from reader */
TPDU_S_WAIT_PB, /* waiting for Tx of procedure byte */
-   TPDU_S_WAIT_RX, /* waiitng for more data from reader */
+   TPDU_S_WAIT_RX, /* waiting for more data from reader */
TPDU_S_WAIT_TX, /* waiting for more data to reader */
 };

@@ -792,7 +792,7 @@

card_emu_uart_tx(ch->uart_chan, byte);

-   /* this must happen _after_ the byte has been transmittd */
+   /* this must happen _after_ the byte has been transmitted */
switch (ch->tpdu.state) {
case TPDU_S_WAIT_PB:
/* if we just transmitted the procedure byte, we need to decide

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib1dee95e15db1c6bb3b45920d7c1a567e2ba474b
Gerrit-Change-Number: 10314
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 


Change in simtrace2[master]: cardem (minor): remove to verbose log trace

2018-08-02 Thread Kévin Redon
Kévin Redon has uploaded this change for review. ( 
https://gerrit.osmocom.org/10315


Change subject: cardem (minor): remove to verbose log trace
..

cardem (minor): remove to verbose log trace

Change-Id: Ie43a33af3728c0700f71527ca75d909a9ebd2529
---
M firmware/libcommon/source/card_emu.c
1 file changed, 0 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/15/10315/1

diff --git a/firmware/libcommon/source/card_emu.c 
b/firmware/libcommon/source/card_emu.c
index fb68660..14a5dd8 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -360,7 +360,6 @@
if (ch->atr.idx < ch->atr.len) {
uint8_t byte = ch->atr.atr[ch->atr.idx++];
card_emu_uart_tx(ch->uart_chan, byte);
-   TRACE_DEBUG("%u: ATR TX: %02x\n\r", ch->num, byte);
return 1;
} else { /* The ATR has been completely transmitted */
/* search for TC2 to updated WI */

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie43a33af3728c0700f71527ca75d909a9ebd2529
Gerrit-Change-Number: 10315
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 


Change in simtrace2[master]: cardem: use TC2 as WI and update WT after ATR

2018-08-02 Thread Kévin Redon
Kévin Redon has uploaded this change for review. ( 
https://gerrit.osmocom.org/10311


Change subject: cardem: use TC2 as WI and update WT after ATR
..

cardem: use TC2 as WI and update WT after ATR

Change-Id: I3e51b16d557bc664f87563e1a3dce6642de474d2
---
M firmware/libcommon/source/card_emu.c
1 file changed, 33 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/11/10311/1

diff --git a/firmware/libcommon/source/card_emu.c 
b/firmware/libcommon/source/card_emu.c
index 51fd923..ad6b4d9 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -363,11 +363,39 @@
TRACE_DEBUG("%u: ATR TX: %02x\n\r", ch->num, byte);
return 1;
} else { /* The ATR has been completely transmitted */
-   /* TODO update WI using optional TC2 and then update WT */
-   //ch->wi = ISO7816_3_DEFAULT_WI;
-   /* update waiting time */
-   //ch->waiting_time = ISO7816_3_INIT_WTIME;
-   //tc_etu_set_wtime(ch->tc_chan, ch->waiting_time);
+   /* search for TC2 to updated WI */
+   ch->wi = ISO7816_3_DEFAULT_WI;
+   if (ch->atr.len >= 2 && ch->atr.atr[1] & 0xf0) { /* Y1 has some 
data */
+   uint8_t atr_td1 = 2;
+   if (ch->atr.atr[1] & 0x10) { /* TA1 is present */
+   atr_td1++;
+   }
+   if (ch->atr.atr[1] & 0x20) { /* TB1 is present */
+   atr_td1++;
+   }
+   if (ch->atr.atr[1] & 0x40) { /* TC1 is present */
+   atr_td1++;
+   }
+   if (ch->atr.atr[1] & 0x80) { /* TD1 is present */
+   if (ch->atr.len > atr_td1 && 
ch->atr.atr[atr_td1] & 0xf0) { /* Y2 has some data */
+   uint8_t atr_tc2 = atr_td1+1;
+   if (ch->atr.atr[atr_td1] & 0x10) { /* 
TA2 is present */
+   atr_tc2++;
+   }
+   if (ch->atr.atr[atr_td1] & 0x20) { /* 
TB2 is present */
+   atr_tc2++;
+   }
+   if (ch->atr.atr[atr_td1] & 0x40) { /* 
TC2 is present */
+   if (ch->atr.len > atr_tc2 && 
ch->atr.atr[atr_tc2]) { /* TC2 encodes WI */
+   ch->wi = 
ch->atr.atr[atr_tc2]; /* set WI */
+   }
+   }
+   }
+   }
+   }
+   /* update waiting time (see ISO 7816-3 10.2) */
+   ch->waiting_time = ch->wi * 960 * ch->fi;
+   tc_etu_set_wtime(ch->tc_chan, ch->waiting_time);
/* reset PTS to initial state */
set_pts_state(ch, PTS_S_WAIT_REQ_PTSS);
/* go to next state */

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3e51b16d557bc664f87563e1a3dce6642de474d2
Gerrit-Change-Number: 10311
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 


Change in simtrace2[master]: add synchronous UART transmission and use it in exceptions

2018-08-02 Thread Kévin Redon
Kévin Redon has uploaded this change for review. ( 
https://gerrit.osmocom.org/10313


Change subject: add synchronous UART transmission and use it in exceptions
..

add synchronous UART transmission and use it in exceptions

The default ISR (particularly the HardFault handler) print information,
but this information was not displayed on the console because the UART
IRQ is lower than some default blocking IRQ.
Allowing to set synchronous transfer corrects this.

The underlying Atmel exception library had to be modified to use the
synchronous output, and is now specific to this project since it
includes the uart_console library.
Making UART_PutChar always synchronous when called from an ISR is not
desired because we use TRACE_ macros is some ISR. The synchronous
output must be set explicitly.

Change-Id: I1b4ace5185cf2dc32684934ed12bf6a8682e9bad
---
M firmware/atmel_softpack_libraries/libchip_sam3s/source/exceptions.c
M firmware/libboard/common/include/uart_console.h
M firmware/libboard/common/source/uart_console.c
3 files changed, 74 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/13/10313/1

diff --git 
a/firmware/atmel_softpack_libraries/libchip_sam3s/source/exceptions.c 
b/firmware/atmel_softpack_libraries/libchip_sam3s/source/exceptions.c
index 74e0fbd..e1e8306 100644
--- a/firmware/atmel_softpack_libraries/libchip_sam3s/source/exceptions.c
+++ b/firmware/atmel_softpack_libraries/libchip_sam3s/source/exceptions.c
@@ -2,6 +2,7 @@
  * ATMEL Microcontroller Software Support
  * 
  * Copyright (c) 2009, Atmel Corporation
+ * Copyright (c) 2018, sysmocom -s.f.m.c. GmbH, Author: Kevin Redon 

  *
  * All rights reserved.
  *
@@ -42,6 +43,7 @@
  
**/

 #include "chip.h"
+#include "uart_console.h"

 /*
  *Exported functions
@@ -52,6 +54,7 @@
  */
 void IrqHandlerNotUsed( void )
 {
+UART_SetSync( true );
 printf("NotUsed\r\n");
 while ( 1 ) ;
 }
@@ -61,6 +64,7 @@
  */
 WEAK void NMI_Handler( void )
 {
+UART_SetSync( true );
 printf("NMI\r\n");
 while ( 1 ) ;
 }
@@ -81,6 +85,7 @@

 void hard_fault_handler_c(struct hardfault_args *args)
 {
+UART_SetSync( true );
 printf("\r\nHardFault\r\n");
 printf("R0=%08x, R1=%08x, R2=%08x, R3=%08x, R12=%08x\r\n",
   args->r0, args->r1, args->r2, args->r3, args->r12);
@@ -158,6 +163,7 @@
  */
 WEAK void MemManage_Handler( void )
 {
+UART_SetSync( true );
 printf("MemManage\r\n");
 while ( 1 ) ;
 }
@@ -167,6 +173,7 @@
  */
 WEAK void BusFault_Handler( void )
 {
+UART_SetSync( true );
 printf("BusFault\r\n");
 while ( 1 ) ;
 }
@@ -176,6 +183,7 @@
  */
 WEAK void UsageFault_Handler( void )
 {
+UART_SetSync( true );
 printf("UsageFault\r\n");
 while ( 1 ) ;
 }
@@ -185,6 +193,7 @@
  */
 WEAK void SVC_Handler( void )
 {
+UART_SetSync( true );
 printf("SVC\r\n");
 while ( 1 ) ;
 }
@@ -194,6 +203,7 @@
  */
 WEAK void DebugMon_Handler( void )
 {
+UART_SetSync( true );
 printf("DebugMon\r\n");
 while ( 1 ) ;
 }
@@ -203,6 +213,7 @@
  */
 WEAK void PendSV_Handler( void )
 {
+UART_SetSync( true );
 printf("PendSV\r\n");
 while ( 1 ) ;
 }
@@ -212,6 +223,7 @@
  */
 WEAK void SysTick_Handler( void )
 {
+UART_SetSync( true );
 printf("SysTick\r\n");
 while ( 1 ) ;
 }
@@ -221,6 +233,7 @@
  */
 WEAK void SUPC_IrqHandler( void )
 {
+UART_SetSync( true );
 printf("SUPC\r\n");
 while ( 1 ) ;
 }
@@ -230,6 +243,7 @@
  */
 WEAK void RSTC_IrqHandler( void )
 {
+UART_SetSync( true );
 printf("RSTC\r\n");
 while ( 1 ) ;
 }
@@ -239,6 +253,7 @@
  */
 WEAK void RTC_IrqHandler( void )
 {
+UART_SetSync( true );
 printf("RTC\r\n");
 while ( 1 ) ;
 }
@@ -248,6 +263,7 @@
  */
 WEAK void RTT_IrqHandler( void )
 {
+UART_SetSync( true );
 printf("RTT\r\n");
 while ( 1 ) ;
 }
@@ -257,6 +273,7 @@
  */
 WEAK void WDT_IrqHandler( void )
 {
+UART_SetSync( true );
 printf("WDT\r\n");
 while ( 1 ) ;
 }
@@ -266,6 +283,7 @@
  */
 WEAK void PMC_IrqHandler( void )
 {
+UART_SetSync( true );
 printf("PMC\r\n");
 while ( 1 ) ;
 }
@@ -275,6 +293,7 @@
  */
 WEAK void EEFC_IrqHandler( void )
 {
+UART_SetSync( true );
 printf("EEFC\r\n");
 while ( 1 ) ;
 }
@@ -284,6 +303,7 @@
  */
 WEAK void UART0_IrqHandler( void )
 {
+UART_SetSync( true );
 printf("UART0\r\n");
 while ( 1 ) ;
 }
@@ -293,6 +313,7 @@
  */
 WEAK void UART1_IrqHandler( void )
 {
+UART_SetSync( true );
 printf("UART1\r\n");
 while ( 1 ) ;
 }
@@ -302,6 +323,7 @@
  */
 WEAK void SMC_IrqHandler( void )
 {
+UART_SetSync( true );
 printf("SMC\r\n");
 while ( 1 ) ;
 }
@@ 

Change in osmo-mgw[master]: mgcp_sdp: restructure mgcp_write_response_sdp()

2018-08-02 Thread dexter
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/10310


Change subject: mgcp_sdp: restructure mgcp_write_response_sdp()
..

mgcp_sdp: restructure mgcp_write_response_sdp()

The function mgcp_write_response_sdp() generates the rtpmap lines in the
sdp response. Since we will likely support multiple codecs we will need
to generate several rtpmap lines. Therefore it makes sense to split up
that part in a separate function without altering the overall
functionality (yet)

- add static function add_rtpmap() to generate the rtpmap.

Change-Id: I520e2d40fe6294c88bae63dfcbc5238ef98101e2
Related: OS#3442
---
M src/libosmo-mgcp/mgcp_sdp.c
1 file changed, 20 insertions(+), 6 deletions(-)



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

diff --git a/src/libosmo-mgcp/mgcp_sdp.c b/src/libosmo-mgcp/mgcp_sdp.c
index 102c8c3..798b3b2 100644
--- a/src/libosmo-mgcp/mgcp_sdp.c
+++ b/src/libosmo-mgcp/mgcp_sdp.c
@@ -286,6 +286,24 @@
return 0;
 }

+
+/* Add rtpmap string to the sdp payload, but only when the payload type falls
+ * into the dynamic payload type range */
+static int add_rtpmap(struct msgb *sdp, int payload_type, char *audio_name)
+{
+   int rc;
+
+   if (payload_type >= 96 && payload_type <= 127) {
+   if (!audio_name)
+   return -EINVAL;
+   rc = msgb_printf(sdp, "a=rtpmap:%d %s\r\n", payload_type, 
audio_name);
+   if (rc < 0)
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
 /*! Generate SDP response string.
  *  \param[in] endp trunk endpoint.
  *  \param[in] conn associated rtp connection.
@@ -328,12 +346,8 @@
if (rc < 0)
goto buffer_too_small;

-   /* FIXME: Check if the payload type is from the static range,
-* if yes, omitthe a=rtpmap since it is unnecessary */
-   if (audio_name && endp->tcfg->audio_send_name && (payload_type 
>= 96 && payload_type <= 127)) {
-   rc = msgb_printf(sdp, "a=rtpmap:%d %s\r\n",
-payload_type, audio_name);
-
+   if (endp->tcfg->audio_send_name) {
+   rc = add_rtpmap(sdp, payload_type, audio_name);
if (rc < 0)
goto buffer_too_small;
}

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

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


Change in osmo-mgw[master]: mgcp_test: release endpoints after use

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10306 )

Change subject: mgcp_test: release endpoints after use
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/10306
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: Ic13b4368162149ec36c93f4188fa4c71166e08d5
Gerrit-Change-Number: 10306
Gerrit-PatchSet: 1
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Thu, 02 Aug 2018 12:01:30 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-mgw[master]: mgcp_test: release endpoints after use

2018-08-02 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/10306 )

Change subject: mgcp_test: release endpoints after use
..

mgcp_test: release endpoints after use

The test function test_multilple_codec() in mgcp_test.c creates a
lot of connections, but it never releases them. Just freeing the
cfg object is not enough since the UDP ports stay open and this
may interfere with other tests that also create connections
(port numbers).

- Make sure all endpoints are released when test_multilple_codec()
  is done.

Change-Id: Ic13b4368162149ec36c93f4188fa4c71166e08d5
---
M tests/mgcp/mgcp_test.c
1 file changed, 4 insertions(+), 0 deletions(-)

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



diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
index df6ea2f..ea79485 100644
--- a/tests/mgcp/mgcp_test.c
+++ b/tests/mgcp/mgcp_test.c
@@ -1265,6 +1265,7 @@
struct in_addr addr;
struct mgcp_conn_rtp *conn = NULL;
char conn_id[256];
+   int i;

printf("Testing multiple payload types\n");

@@ -1398,6 +1399,9 @@
OSMO_ASSERT(conn);
OSMO_ASSERT(conn->end.codec->payload_type == 0);

+   for (i = 1; i < cfg->trunk.number_endpoints; i++)
+   mgcp_endp_release(>trunk.endpoints[i]);
+
talloc_free(cfg);
 }


--
To view, visit https://gerrit.osmocom.org/10306
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: Ic13b4368162149ec36c93f4188fa4c71166e08d5
Gerrit-Change-Number: 10306
Gerrit-PatchSet: 2
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


Change in osmo-mgw[master]: mgcp_client: increment local port number when port is in use

2018-08-02 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/10307 )

Change subject: mgcp_client: increment local port number when port is in use
..

mgcp_client: increment local port number when port is in use

The IETF has designated port 2727 for call agents (clients). This
works as long as only one call agent is running. As soon as two
call agents (e.g. osmo-bsc and osmo-msc) run on the same machine.
The port numbers will collide.

To avoid such a situation we will first try the IETF port and if
we fail to use it we increment the port number until we found a
usable port. However, we should only do this if the user has not
configured a non standard port. (The rationale behind this is that
if there is a non standard port configured the choice must have
been made conciously by the user and therefor we should fail hard
so that the user gets aware of the problem.)

Change-Id: Iaa5f41fdb43ec6bf4feaefa174fd82622e37d4d0
Related: OS#2874
---
M src/libosmo-mgcp-client/mgcp_client.c
1 file changed, 37 insertions(+), 4 deletions(-)

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



diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index 00b52f8..3663163 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -779,6 +779,42 @@
return mgcp;
 }
 
+static int init_socket(struct mgcp_client *mgcp)
+{
+   int rc;
+   struct osmo_wqueue *wq;
+   int i;
+
+   wq = >wq;
+
+   for (i = 0; i < 100; i++) {
+
+   /* Initalize socket with the currently configured port
+* number */
+   rc = osmo_sock_init2_ofd(>bfd, AF_INET, SOCK_DGRAM, 
IPPROTO_UDP, mgcp->actual.local_addr,
+mgcp->actual.local_port, 
mgcp->actual.remote_addr, mgcp->actual.remote_port,
+OSMO_SOCK_F_BIND | 
OSMO_SOCK_F_CONNECT);
+   if (rc > 0)
+   return rc;
+
+   /* If there is a different port than the default port
+* configured then we assume that the user has choosen
+* that port conciously and we will not try to resolve
+* this by silently choosing a different port. */
+   if (mgcp->actual.local_port != MGCP_CLIENT_LOCAL_PORT_DEFAULT)
+   return -EINVAL;
+
+   /* Choose a new port number to try next */
+   LOGP(DLMGCP, LOGL_NOTICE,
+"MGCPGW faild to bind to port %u, retrying with port %u -- 
check configuration!\n",
+mgcp->actual.local_port, mgcp->actual.local_port + 1);
+   mgcp->actual.local_port++;
+   }
+
+   LOGP(DLMGCP, LOGL_FATAL, "MGCPGW faild to find a port to bind on %i 
times.\n", i);
+   return -EINVAL;
+}
+
 /*! Initalize client connection (opens socket only, no request is sent yet)
  *  \param[in,out] mgcp MGCP client descriptor.
  *  \returns 0 on success, -EINVAL on error. */
@@ -795,10 +831,7 @@

wq = >wq;

-   rc = osmo_sock_init2_ofd(>bfd, AF_INET, SOCK_DGRAM, IPPROTO_UDP,
-mgcp->actual.local_addr, 
mgcp->actual.local_port,
-mgcp->actual.remote_addr, 
mgcp->actual.remote_port,
-OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT);
+   rc = init_socket(mgcp);
if (rc < 0) {
LOGP(DLMGCP, LOGL_FATAL,
 "Failed to initialize socket %s:%u -> %s:%u for MGCP GW: 
%s\n",

--
To view, visit https://gerrit.osmocom.org/10307
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: Iaa5f41fdb43ec6bf4feaefa174fd82622e37d4d0
Gerrit-Change-Number: 10307
Gerrit-PatchSet: 1
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


Change in osmo-mgw[master]: mgcp_client: increment local port number when port is in use

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10307 )

Change subject: mgcp_client: increment local port number when port is in use
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/10307
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: Iaa5f41fdb43ec6bf4feaefa174fd82622e37d4d0
Gerrit-Change-Number: 10307
Gerrit-PatchSet: 1
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Thu, 02 Aug 2018 12:01:11 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-bts[master]: Clarify frame loss counter for l1sched_chan_state

2018-08-02 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/10308 )

Change subject: Clarify frame loss counter for l1sched_chan_state
..

Clarify frame loss counter for l1sched_chan_state

Each logical channel (e.g. SACCH, SDCCH, etc.) has a counter of
lost L2 frames. Let's use a bit better name for it, and correct
its description in the 'l1sched_chan_state' struct definition.

Change-Id: I92ef95f6b3f647170cfd434a970701406b0a7c82
---
M include/osmo-bts/scheduler.h
M src/common/scheduler.c
M src/osmo-bts-trx/scheduler_trx.c
M src/osmo-bts-virtual/scheduler_virtbts.c
4 files changed, 7 insertions(+), 7 deletions(-)

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



diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h
index 98f38d3..3fe7978 100644
--- a/include/osmo-bts/scheduler.h
+++ b/include/osmo-bts/scheduler.h
@@ -78,7 +78,7 @@
int32_t toa256_sum; /* sum of TOA values (1/256 
symbol) */

/* loss detection */
-   uint8_t lost;   /* (SACCH) loss detection */
+   uint8_t lost_frames;/* how many L2 frames were lost 
*/

/* mode */
uint8_t rsl_cmode, tch_mode; /* mode for TCH channels */
diff --git a/src/common/scheduler.c b/src/common/scheduler.c
index 3842810..5c250e4 100644
--- a/src/common/scheduler.c
+++ b/src/common/scheduler.c
@@ -367,7 +367,7 @@
memcpy(msg->l2h, l2, l2_len);

if (L1SAP_IS_LINK_SACCH(trx_chan_desc[chan].link_id))
-   l1ts->chan_state[chan].lost = 0;
+   l1ts->chan_state[chan].lost_frames = 0;

/* forward primitive */
l1sap_up(l1t->trx, l1sap);
@@ -396,8 +396,8 @@
if (tch_len)
memcpy(msg->l2h, tch, tch_len);

-   if (l1ts->chan_state[chan].lost)
-   l1ts->chan_state[chan].lost--;
+   if (l1ts->chan_state[chan].lost_frames)
+   l1ts->chan_state[chan].lost_frames--;

LOGL1S(DL1P, LOGL_DEBUG, l1t, tn, -1, l1sap->u.data.fn,
   "%s Rx -> RTP: %s\n",
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index a22b53f..4ab937a 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -192,7 +192,7 @@
/* handle loss detection of SACCH */
if (L1SAP_IS_LINK_SACCH(trx_chan_desc[chan].link_id)) {
/* count and send BFI */
-   if (++(l1ts->chan_state[chan].lost) > 1) {
+   if (++(l1ts->chan_state[chan].lost_frames) > 1) {
/* TODO: Should we pass old TOA here? Otherwise we risk
 * unnecessary decreasing TA */

@@ -351,7 +351,7 @@

/* handle loss detection of received TCH frames */
if (rsl_cmode == RSL_CMOD_SPD_SPEECH
-   && ++(chan_state->lost) > 5) {
+   && ++(chan_state->lost_frames) > 5) {
uint8_t tch_data[GSM_FR_BYTES];
int len;

diff --git a/src/osmo-bts-virtual/scheduler_virtbts.c 
b/src/osmo-bts-virtual/scheduler_virtbts.c
index de995e6..cdbb9c1 100644
--- a/src/osmo-bts-virtual/scheduler_virtbts.c
+++ b/src/osmo-bts-virtual/scheduler_virtbts.c
@@ -198,7 +198,7 @@
 #if 0
/* handle loss detection of received TCH frames */
if (rsl_cmode == RSL_CMOD_SPD_SPEECH
-&& ++(chan_state->lost) > 5) {
+&& ++(chan_state->lost_frames) > 5) {
uint8_t tch_data[GSM_FR_BYTES];
int len;


--
To view, visit https://gerrit.osmocom.org/10308
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: I92ef95f6b3f647170cfd434a970701406b0a7c82
Gerrit-Change-Number: 10308
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


Change in osmo-mgw[master]: mgcp_client: use IETF source port as for MGCP

2018-08-02 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/10188 )

Change subject: mgcp_client: use IETF source port as for MGCP
..

mgcp_client: use IETF source port as for MGCP

At the moment the mgcp client uses an arbitrary port as sourceport to
exchange MGCP messages with the MGW. However, IETF has designated a
specific port as sourceport for MGCP clients (Call agents), which is
2727. See also RFC3435, capter 3.5 Transmission over UDP.

- Change MGCP_CLIENT_LOCAL_PORT_DEFAULT from 0 to 2727

Change-Id: I96de84df3a3bf623d98b057ec3f3f621a3330a8a
Closes: OS#2874
---
M include/osmocom/mgcp_client/mgcp_client.h
1 file changed, 2 insertions(+), 1 deletion(-)

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



diff --git a/include/osmocom/mgcp_client/mgcp_client.h 
b/include/osmocom/mgcp_client/mgcp_client.h
index 19c684d..ed2dfb0 100644
--- a/include/osmocom/mgcp_client/mgcp_client.h
+++ b/include/osmocom/mgcp_client/mgcp_client.h
@@ -5,8 +5,9 @@

 #include 

+/* See also: RFC 3435, chapter 3.5 Transmission over UDP */
 #define MGCP_CLIENT_LOCAL_ADDR_DEFAULT "0.0.0.0"
-#define MGCP_CLIENT_LOCAL_PORT_DEFAULT 0
+#define MGCP_CLIENT_LOCAL_PORT_DEFAULT 2727
 #define MGCP_CLIENT_REMOTE_ADDR_DEFAULT "127.0.0.1"
 #define MGCP_CLIENT_REMOTE_PORT_DEFAULT 2427


--
To view, visit https://gerrit.osmocom.org/10188
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: I96de84df3a3bf623d98b057ec3f3f621a3330a8a
Gerrit-Change-Number: 10188
Gerrit-PatchSet: 2
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 


Change in osmo-mgw[master]: mgcp_client: use IETF source port as for MGCP

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10188 )

Change subject: mgcp_client: use IETF source port as for MGCP
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/10188
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: I96de84df3a3bf623d98b057ec3f3f621a3330a8a
Gerrit-Change-Number: 10188
Gerrit-PatchSet: 2
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Comment-Date: Thu, 02 Aug 2018 12:01:13 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-bts[master]: Clarify frame loss counter for l1sched_chan_state

2018-08-02 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/10308 )

Change subject: Clarify frame loss counter for l1sched_chan_state
..


Patch Set 1: Code-Review+2


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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I92ef95f6b3f647170cfd434a970701406b0a7c82
Gerrit-Change-Number: 10308
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Thu, 02 Aug 2018 12:00:06 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in libosmocore[master]: socket: do not set SO_REUSEADDR for IPPROTO_UDP

2018-08-02 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/10289 )

Change subject: socket: do not set SO_REUSEADDR for IPPROTO_UDP
..

socket: do not set SO_REUSEADDR for IPPROTO_UDP

When UDP is used as protocol (proto=IPPROTO_DUP), then we should not set
SO_REUSEADDR in the socket option. Because if we do, we allow two
processes to bind on the same UDP port. The errornous situation will be
undetectable to both applications. So lets only set SO_REUSEADDR when we
do not use UDP.

- Add check if we use UDP, if yes do not set SO_REUSEADDR

Change-Id: I4a8ffb8d598aca88801a4a0322944d7cdd8d4047
Related: OS#3441
---
M src/socket.c
1 file changed, 33 insertions(+), 25 deletions(-)

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



diff --git a/src/socket.c b/src/socket.c
index 0a4e34c..210dbf9 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -209,16 +209,20 @@
if (sfd < 0)
continue;

-   rc = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR,
-   , sizeof(on));
-   if (rc < 0) {
-   LOGP(DLGLOBAL, LOGL_ERROR,
-   "cannot setsockopt socket:"
-   " %s:%u: %s\n",
-   local_host, local_port, 
strerror(errno));
-   close(sfd);
-   continue;
+   if (proto != IPPROTO_UDP) {
+   rc = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR,
+   , sizeof(on));
+   if (rc < 0) {
+   LOGP(DLGLOBAL, LOGL_ERROR,
+"cannot setsockopt socket:"
+" %s:%u: %s\n",
+local_host, local_port,
+strerror(errno));
+   close(sfd);
+   continue;
+   }
}
+
if (bind(sfd, rp->ai_addr, rp->ai_addrlen) == -1) {
LOGP(DLGLOBAL, LOGL_ERROR, "unable to bind 
socket: %s:%u: %s\n",
local_host, local_port, 
strerror(errno));
@@ -345,15 +349,17 @@
continue;
}
} else {
-   rc = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR,
-   , sizeof(on));
-   if (rc < 0) {
-   LOGP(DLGLOBAL, LOGL_ERROR,
-   "cannot setsockopt socket:"
-   " %s:%u: %s\n",
-   host, port, strerror(errno));
-   close(sfd);
-   continue;
+   if (proto != IPPROTO_UDP) {
+   rc = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR,
+   , sizeof(on));
+   if (rc < 0) {
+   LOGP(DLGLOBAL, LOGL_ERROR,
+"cannot setsockopt socket:"
+" %s:%u: %s\n",
+host, port, strerror(errno));
+   close(sfd);
+   continue;
+   }
}
if (bind(sfd, rp->ai_addr, rp->ai_addrlen) == -1) {
LOGP(DLGLOBAL, LOGL_ERROR, "unable to bind 
socket:"
@@ -373,13 +379,15 @@
return -ENODEV;
}

-   rc = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, , sizeof(on));
-   if (rc < 0) {
-   LOGP(DLGLOBAL, LOGL_ERROR,
-"cannot setsockopt socket: %s:%u: %s\n", host, port,
-strerror(errno));
-   close(sfd);
-   sfd = -1;
+   if (proto != IPPROTO_UDP) {
+   rc = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, , sizeof(on));
+   if (rc < 0) {
+   LOGP(DLGLOBAL, LOGL_ERROR,
+"cannot setsockopt socket: %s:%u: %s\n", host,
+port, strerror(errno));
+   close(sfd);
+   sfd = -1;
+   }
}

rc = osmo_sock_init_tail(sfd, type, flags);

--
To view, visit https://gerrit.osmocom.org/10289
To unsubscribe, or for help 

Change in osmo-bts[master]: common/scheduler.c: track TDMA frame loss per logical channels

2018-08-02 Thread Vadim Yanitskiy
Vadim Yanitskiy has uploaded a new patch set (#2). ( 
https://gerrit.osmocom.org/10309 )

Change subject: common/scheduler.c: track TDMA frame loss per logical channels
..

common/scheduler.c: track TDMA frame loss per logical channels

This change modifies the logic of TDMA frame loss tracking. To
be more precise, the tracking logic was moved from per timeslot
level to per logical channel level, what makes OsmoBTS more
accurate in its measurements.

But before getting into details, it's important to clarify some
things about the Uplink burst processing in transceiver (OsmoTRX).
If an Uplink burst is detected, OsmoTRX demodulates it and sends
to OsmoBTS. If nothing is detected on a particular timeslot,
OsmoTRX will do nothing. In other words, it will not
notify OsmoBTS about this.

Meanwhile, there are usually a few logical channels mapped to a
single TDMA timeslot. Let's use SDCCH8 channel configuration as
an example (simplified layout):

  /* SDCCH/8 (ss=0), subscriber A (active) */
  { TRXC_SDCCH8_0,bid=0 },
  { TRXC_SDCCH8_0,bid=1 },
  { TRXC_SDCCH8_0,bid=2 },
  { TRXC_SDCCH8_0,bid=3 }, // <-- last_fn=X

  /* SDCCH/8 (ss=1), subscriber B (inactive) */
  { TRXC_SDCCH8_1,bid=0 },
  { TRXC_SDCCH8_1,bid=1 },
  { TRXC_SDCCH8_1,bid=2 },
  { TRXC_SDCCH8_1,bid=3 },

  /* SDCCH/8 (ss=2), subscriber C (active) */
  { TRXC_SDCCH8_2,bid=0 }, // <-- current_fn=X+5
  { TRXC_SDCCH8_2,bid=1 },
  { TRXC_SDCCH8_2,bid=2 },
  { TRXC_SDCCH8_2,bid=3 },

SDCCH8 has 8 sub-slots, so up to 8 subscribers can use a single
timeslot. Let's imagine there are three subscribers: A, B, and C.
Both A and C are active subscribers, i.e. they are continuously
transmitting UL bursts, while B is not using ss=1 anymore.

The original way of TDMA frame loss tracking was the following:

  - when an UL burst is received, store it's frame number in
the timeslot state structure (last_fn);

  - when the next UL burst is received on same timeslot, compute
how many frames elapsed since the last_fn;

  - if elapsed = (current_fn - last_fn) is lower than 10, then
iterate from (last_fn + 1) until the current_fn and send
dummy zero-filled bursts to the higher layers;

  - otherwise (elapsed > 10), process the current burst,
and do nothing :/

According to our example, subscriber A is sending 4 bursts, then
nobody is sending anything, and then subscriber C is sending
4 bursts. So, there is a 4 frames long gap between the both
transmissions, which is being substituted by dummy bursts. But,
as the logical channel on ss=1 is not active, they are dropped.

This is not that scary, but the current algorithm produces lots
of false-positives, and moreover is not able to track real frame
drops in longer periods (i.e. >10). So, tracking the frame loss
per individual logical channels makes much more sense.

Let's finally drop this hackish 'while (42) { ... }', and track
the amount of lost / received TDMA frames (bursts) individually
per logical channels. Let's also use the multiframe period as
the loss detection period, instead of hardcoded 10. And finally,
let's print more informative debug messages.

Also, it makes sense to use the amount of lost / received bursts
during the calculation of the measurement reports, instead of
sending dummy bursts, but let's do this separately.

Change-Id: I70d05b67a35ddcbdd1b6394dbd7198404a440e76
Related: OS#3428
---
M include/osmo-bts/scheduler.h
M src/common/scheduler.c
2 files changed, 133 insertions(+), 65 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/09/10309/2
--
To view, visit https://gerrit.osmocom.org/10309
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I70d05b67a35ddcbdd1b6394dbd7198404a440e76
Gerrit-Change-Number: 10309
Gerrit-PatchSet: 2
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-CC: Jenkins Builder


Change in osmo-bts[master]: Clarify frame loss counter for l1sched_chan_state

2018-08-02 Thread Vadim Yanitskiy
Vadim Yanitskiy has uploaded this change for review. ( 
https://gerrit.osmocom.org/10308


Change subject: Clarify frame loss counter for l1sched_chan_state
..

Clarify frame loss counter for l1sched_chan_state

Each logical channel (e.g. SACCH, SDCCH, etc.) has a counter of
lost L2 frames. Let's use a bit better name for it, and correct
its description in the 'l1sched_chan_state' struct definition.

Change-Id: I92ef95f6b3f647170cfd434a970701406b0a7c82
---
M include/osmo-bts/scheduler.h
M src/common/scheduler.c
M src/osmo-bts-trx/scheduler_trx.c
M src/osmo-bts-virtual/scheduler_virtbts.c
4 files changed, 7 insertions(+), 7 deletions(-)



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

diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h
index 98f38d3..3fe7978 100644
--- a/include/osmo-bts/scheduler.h
+++ b/include/osmo-bts/scheduler.h
@@ -78,7 +78,7 @@
int32_t toa256_sum; /* sum of TOA values (1/256 
symbol) */

/* loss detection */
-   uint8_t lost;   /* (SACCH) loss detection */
+   uint8_t lost_frames;/* how many L2 frames were lost 
*/

/* mode */
uint8_t rsl_cmode, tch_mode; /* mode for TCH channels */
diff --git a/src/common/scheduler.c b/src/common/scheduler.c
index 3842810..5c250e4 100644
--- a/src/common/scheduler.c
+++ b/src/common/scheduler.c
@@ -367,7 +367,7 @@
memcpy(msg->l2h, l2, l2_len);

if (L1SAP_IS_LINK_SACCH(trx_chan_desc[chan].link_id))
-   l1ts->chan_state[chan].lost = 0;
+   l1ts->chan_state[chan].lost_frames = 0;

/* forward primitive */
l1sap_up(l1t->trx, l1sap);
@@ -396,8 +396,8 @@
if (tch_len)
memcpy(msg->l2h, tch, tch_len);

-   if (l1ts->chan_state[chan].lost)
-   l1ts->chan_state[chan].lost--;
+   if (l1ts->chan_state[chan].lost_frames)
+   l1ts->chan_state[chan].lost_frames--;

LOGL1S(DL1P, LOGL_DEBUG, l1t, tn, -1, l1sap->u.data.fn,
   "%s Rx -> RTP: %s\n",
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index a22b53f..4ab937a 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -192,7 +192,7 @@
/* handle loss detection of SACCH */
if (L1SAP_IS_LINK_SACCH(trx_chan_desc[chan].link_id)) {
/* count and send BFI */
-   if (++(l1ts->chan_state[chan].lost) > 1) {
+   if (++(l1ts->chan_state[chan].lost_frames) > 1) {
/* TODO: Should we pass old TOA here? Otherwise we risk
 * unnecessary decreasing TA */

@@ -351,7 +351,7 @@

/* handle loss detection of received TCH frames */
if (rsl_cmode == RSL_CMOD_SPD_SPEECH
-   && ++(chan_state->lost) > 5) {
+   && ++(chan_state->lost_frames) > 5) {
uint8_t tch_data[GSM_FR_BYTES];
int len;

diff --git a/src/osmo-bts-virtual/scheduler_virtbts.c 
b/src/osmo-bts-virtual/scheduler_virtbts.c
index de995e6..cdbb9c1 100644
--- a/src/osmo-bts-virtual/scheduler_virtbts.c
+++ b/src/osmo-bts-virtual/scheduler_virtbts.c
@@ -198,7 +198,7 @@
 #if 0
/* handle loss detection of received TCH frames */
if (rsl_cmode == RSL_CMOD_SPD_SPEECH
-&& ++(chan_state->lost) > 5) {
+&& ++(chan_state->lost_frames) > 5) {
uint8_t tch_data[GSM_FR_BYTES];
int len;


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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I92ef95f6b3f647170cfd434a970701406b0a7c82
Gerrit-Change-Number: 10308
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy 


Change in osmo-bts[master]: common/scheduler.c: track TDMA frame loss per logical channels

2018-08-02 Thread Vadim Yanitskiy
Vadim Yanitskiy has uploaded this change for review. ( 
https://gerrit.osmocom.org/10309


Change subject: common/scheduler.c: track TDMA frame loss per logical channels
..

common/scheduler.c: track TDMA frame loss per logical channels

This change modifies the logic of TDMA frame loss tracking. To
be more precise, the tracking logic was moved from per timeslot
level to per logical channel level, what makes OsmoBTS more
accurate in its measurements.

But before getting into details, it's important to clarify some
things about the Uplink burst processing in transceiver (OsmoTRX).
If an Uplink burst is detected, OsmoTRX demodulates it and sends
to OsmoBTS. If nothing is detected on a particular timeslot,
OsmoTRX will do nothing. In other words, it will not
notify OsmoBTS about this.

Meanwhile, there are usually a few logical channels mapped to a
single TDMA timeslot. Let's use SDCCH8 channel configuration as
an example (simplified layout):

  /* SDCCH/8 (ss=0), subscriber A (active) */
  { TRXC_SDCCH8_0,bid=0 },
  { TRXC_SDCCH8_0,bid=1 },
  { TRXC_SDCCH8_0,bid=2 },
  { TRXC_SDCCH8_0,bid=3 }, // <-- last_fn=X

  /* SDCCH/8 (ss=1), subscriber B (inactive) */
  { TRXC_SDCCH8_1,bid=0 },
  { TRXC_SDCCH8_1,bid=1 },
  { TRXC_SDCCH8_1,bid=2 },
  { TRXC_SDCCH8_1,bid=3 },

  /* SDCCH/8 (ss=2), subscriber C (active) */
  { TRXC_SDCCH8_2,bid=0 }, // <-- current_fn=X+5
  { TRXC_SDCCH8_2,bid=1 },
  { TRXC_SDCCH8_2,bid=2 },
  { TRXC_SDCCH8_2,bid=3 },

SDCCH8 has 8 sub-slots, so up to 8 subscribers can use a single
timeslot. Let's imagine there are three subscribers: A, B, and C.
Both A and C are active subscribers, i.e. they are continuously
transmitting UL bursts, while B is not using ss=1 anymore.

The original way of TDMA frame loss tracking was the following:

  - when an UL burst is received, store it's frame number in
the timeslot state structure (last_fn);

  - when the next UL burst is received on same timeslot, compute
how many frames elapsed since the last_fn;

  - if elapsed = (current_fn - last_fn) is lower than 10, then
iterate from (last_fn + 1) until the current_fn and send
dummy zero-filled bursts to the higher layers;

  - otherwise (elapsed > 10), process the current burst,
and do nothing :/

According to our example, subscriber A is sending 4 bursts, then
nobody is sending anything, and then subscriber C is sending
4 bursts. So, there is a 4 frames long gap between the both
transmissions, which is being substituted by dummy bursts. But,
as the logical channel on ss=1 is not active, they are dropped.

This is not that scary, but the current algorithm produces lots
of false-positives, and moreover is not able to track real frame
drops in longer periods (i.e. >10). So, tracking the frame loss
per individual logical channels makes much more sense.

Let's finally drop this hackish 'while (42) { ... }', and track
the amount of lost / received TDMA frames (bursts) individually
per logical channels.

Also, it makes sense to use the amount of lost / received bursts
during the calculation of the measurement reports, instead of
sending dummy bursts, but let's do this separately.

Change-Id: I70d05b67a35ddcbdd1b6394dbd7198404a440e76
Related: OS#3428
---
M include/osmo-bts/scheduler.h
M src/common/scheduler.c
2 files changed, 133 insertions(+), 65 deletions(-)



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

diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h
index 3fe7978..4cf5440 100644
--- a/include/osmo-bts/scheduler.h
+++ b/include/osmo-bts/scheduler.h
@@ -79,6 +79,9 @@

/* loss detection */
uint8_t lost_frames;/* how many L2 frames were lost 
*/
+   uint32_tlast_tdma_fn;   /* last processed TDMA frame 
number */
+   uint32_tproc_tdma_fs;   /* how many TDMA frames were 
processed */
+   uint32_tlost_tdma_fs;   /* how many TDMA frames were 
lost */

/* mode */
uint8_t rsl_cmode, tch_mode; /* mode for TCH channels */
@@ -123,7 +126,6 @@

 struct l1sched_ts {
uint8_t mf_index;   /* selected multiframe index */
-   uint32_tmf_last_fn; /* last received frame number */
uint8_t mf_period;  /* period of multiframe */
const struct trx_sched_frame *mf_frames; /* pointer to frame layout */

diff --git a/src/common/scheduler.c b/src/common/scheduler.c
index 5c250e4..9b36fa2 100644
--- a/src/common/scheduler.c
+++ b/src/common/scheduler.c
@@ -219,7 +219,6 @@
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);

l1ts->mf_index = 0;
-   l1ts->mf_last_fn = 0;
INIT_LLIST_HEAD(>dl_prims);
for (i = 0; i < ARRAY_SIZE(l1ts->chan_state); i++) {
   

Change in osmo-mgw[master]: mgcp_client: increment local port number when port is in use

2018-08-02 Thread dexter
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/10307


Change subject: mgcp_client: increment local port number when port is in use
..

mgcp_client: increment local port number when port is in use

The IETF has designated port 2727 for call agents (clients). This
works as long as only one call agent is running. As soon as two
call agents (e.g. osmo-bsc and osmo-msc) run on the same machine.
The port numbers will collide.

To avoid such a situation we will first try the IETF port and if
we fail to use it we increment the port number until we found a
usable port. However, we should only do this if the user has not
configured a non standard port. (The rationale behind this is that
if there is a non standard port configured the choice must have
been made conciously by the user and therefor we should fail hard
so that the user gets aware of the problem.)

Change-Id: Iaa5f41fdb43ec6bf4feaefa174fd82622e37d4d0
Related: OS#2874
---
M src/libosmo-mgcp-client/mgcp_client.c
1 file changed, 37 insertions(+), 4 deletions(-)



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

diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index 00b52f8..3663163 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -779,6 +779,42 @@
return mgcp;
 }

+static int init_socket(struct mgcp_client *mgcp)
+{
+   int rc;
+   struct osmo_wqueue *wq;
+   int i;
+
+   wq = >wq;
+
+   for (i = 0; i < 100; i++) {
+
+   /* Initalize socket with the currently configured port
+* number */
+   rc = osmo_sock_init2_ofd(>bfd, AF_INET, SOCK_DGRAM, 
IPPROTO_UDP, mgcp->actual.local_addr,
+mgcp->actual.local_port, 
mgcp->actual.remote_addr, mgcp->actual.remote_port,
+OSMO_SOCK_F_BIND | 
OSMO_SOCK_F_CONNECT);
+   if (rc > 0)
+   return rc;
+
+   /* If there is a different port than the default port
+* configured then we assume that the user has choosen
+* that port conciously and we will not try to resolve
+* this by silently choosing a different port. */
+   if (mgcp->actual.local_port != MGCP_CLIENT_LOCAL_PORT_DEFAULT)
+   return -EINVAL;
+
+   /* Choose a new port number to try next */
+   LOGP(DLMGCP, LOGL_NOTICE,
+"MGCPGW faild to bind to port %u, retrying with port %u -- 
check configuration!\n",
+mgcp->actual.local_port, mgcp->actual.local_port + 1);
+   mgcp->actual.local_port++;
+   }
+
+   LOGP(DLMGCP, LOGL_FATAL, "MGCPGW faild to find a port to bind on %i 
times.\n", i);
+   return -EINVAL;
+}
+
 /*! Initalize client connection (opens socket only, no request is sent yet)
  *  \param[in,out] mgcp MGCP client descriptor.
  *  \returns 0 on success, -EINVAL on error. */
@@ -795,10 +831,7 @@

wq = >wq;

-   rc = osmo_sock_init2_ofd(>bfd, AF_INET, SOCK_DGRAM, IPPROTO_UDP,
-mgcp->actual.local_addr, 
mgcp->actual.local_port,
-mgcp->actual.remote_addr, 
mgcp->actual.remote_port,
-OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT);
+   rc = init_socket(mgcp);
if (rc < 0) {
LOGP(DLMGCP, LOGL_FATAL,
 "Failed to initialize socket %s:%u -> %s:%u for MGCP GW: 
%s\n",

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

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


Change in libosmocore[master]: socket: do not set SO_REUSEADDR for IPPROTO_UDP

2018-08-02 Thread dexter
dexter has posted comments on this change. ( https://gerrit.osmocom.org/10289 )

Change subject: socket: do not set SO_REUSEADDR for IPPROTO_UDP
..


Patch Set 3:

> Set Ready For Review

I did not notice any major problems in my checks. The GSMTAP problem turned out 
to be normal. I just did not notice the warning before, but it is also there 
with the current master of libosmocore.

However on osmo-mgw there were unit-test problems which are fixed now with 
#10306


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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I4a8ffb8d598aca88801a4a0322944d7cdd8d4047
Gerrit-Change-Number: 10289
Gerrit-PatchSet: 3
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: dexter 
Gerrit-Comment-Date: Thu, 02 Aug 2018 10:30:08 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: socket: do not set SO_REUSEADDR for IPPROTO_UDP

2018-08-02 Thread dexter
dexter has posted comments on this change. ( https://gerrit.osmocom.org/10289 )

Change subject: socket: do not set SO_REUSEADDR for IPPROTO_UDP
..


Set Ready For Review


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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I4a8ffb8d598aca88801a4a0322944d7cdd8d4047
Gerrit-Change-Number: 10289
Gerrit-PatchSet: 3
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: dexter 
Gerrit-Comment-Date: Thu, 02 Aug 2018 10:28:32 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: socket: check return code of setsockopt

2018-08-02 Thread dexter
dexter has posted comments on this change. ( https://gerrit.osmocom.org/10288 )

Change subject: socket: check return code of setsockopt
..


Set Ready For Review


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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I96dbccc3bcff35bf39979dbe0c44aadc8ce20c83
Gerrit-Change-Number: 10288
Gerrit-PatchSet: 2
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: dexter 
Gerrit-Comment-Date: Thu, 02 Aug 2018 10:23:12 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: socket: check return code of setsockopt

2018-08-02 Thread dexter
dexter has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/10288 )

Change subject: socket: check return code of setsockopt
..

socket: check return code of setsockopt

the return code of the last setsockopt() call in osmo_sock_init() is not
checked. Since all other calls to setsockopt are checked, lets check
this one as well.

- check return code of setsockopt() and close the socket on failure

Change-Id: I96dbccc3bcff35bf39979dbe0c44aadc8ce20c83
---
M src/socket.c
1 file changed, 8 insertions(+), 1 deletion(-)

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



diff --git a/src/socket.c b/src/socket.c
index dc5590c..0a4e34c 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -373,7 +373,14 @@
return -ENODEV;
}

-   setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, , sizeof(on));
+   rc = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, , sizeof(on));
+   if (rc < 0) {
+   LOGP(DLGLOBAL, LOGL_ERROR,
+"cannot setsockopt socket: %s:%u: %s\n", host, port,
+strerror(errno));
+   close(sfd);
+   sfd = -1;
+   }

rc = osmo_sock_init_tail(sfd, type, flags);
if (rc < 0) {

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I96dbccc3bcff35bf39979dbe0c44aadc8ce20c83
Gerrit-Change-Number: 10288
Gerrit-PatchSet: 2
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: dexter 


Change in osmo-mgw[master]: mgcp_test: release endpoints after use

2018-08-02 Thread dexter
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/10306


Change subject: mgcp_test: release endpoints after use
..

mgcp_test: release endpoints after use

The test function test_multilple_codec() in mgcp_test.c creates a
lot of connections, but it never releases them. Just freeing the
cfg object is not enough since the UDP ports stay open and this
may interfere with other tests that also create connections
(port numbers).

- Make sure all endpoints are released when test_multilple_codec()
  is done.

Change-Id: Ic13b4368162149ec36c93f4188fa4c71166e08d5
---
M tests/mgcp/mgcp_test.c
1 file changed, 4 insertions(+), 0 deletions(-)



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

diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
index df6ea2f..ea79485 100644
--- a/tests/mgcp/mgcp_test.c
+++ b/tests/mgcp/mgcp_test.c
@@ -1265,6 +1265,7 @@
struct in_addr addr;
struct mgcp_conn_rtp *conn = NULL;
char conn_id[256];
+   int i;

printf("Testing multiple payload types\n");

@@ -1398,6 +1399,9 @@
OSMO_ASSERT(conn);
OSMO_ASSERT(conn->end.codec->payload_type == 0);

+   for (i = 1; i < cfg->trunk.number_endpoints; i++)
+   mgcp_endp_release(>trunk.endpoints[i]);
+
talloc_free(cfg);
 }


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

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