[MERGED] libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2018-01-17 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT
..


gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

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

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



diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 17657c7..fdec3d2 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -204,6 +204,10 @@
 struct ss_request *req);
 static int parse_ss_invoke(const uint8_t *invoke_data, uint16_t length,
struct ss_request *req);
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct ss_request *req);
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct ss_request *req);
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
struct ss_request *req);
 static int parse_ss_for_bs_req(const uint8_t *ss_req_data,
@@ -372,6 +376,9 @@
  req);
break;
case GSM0480_CTYPE_RETURN_RESULT:
+   rc &= parse_ss_return_result(facility_ie+2,
+component_length,
+req);
break;
case GSM0480_CTYPE_RETURN_ERROR:
break;
@@ -451,6 +458,81 @@
return rc;
 }
 
+/* Parse a Return Result component - see table 3.4 */
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct ss_request *req)
+{
+   uint8_t operation_code;
+   uint8_t offset;
+
+   if (length < 3)
+   return 0;
+
+   /* Mandatory part */
+   if (rr_data[0] != GSM0480_COMPIDTAG_INVOKE_ID) {
+   LOGP(0, LOGL_DEBUG, "Unexpected GSM 04.80 Component-ID tag "
+"0x%02x (expecting Invoke ID tag)\n", rr_data[0]);
+   return 0;
+   }
+
+   offset = rr_data[1] + 2;
+   req->invoke_id = rr_data[2];
+
+   if (offset >= length)
+   return 0;
+
+   if (rr_data[offset] != GSM_0480_SEQUENCE_TAG)
+   return 0;
+
+   if (offset + 2 > length)
+   return 0;
+
+   offset += 2;
+   operation_code = rr_data[offset + 2];
+   req->opcode = operation_code;
+
+   switch (operation_code) {
+   case GSM0480_OP_CODE_USS_NOTIFY:
+   case GSM0480_OP_CODE_USS_REQUEST:
+   case GSM0480_OP_CODE_PROCESS_USS_REQ:
+   return parse_process_uss_req(rr_data + offset + 3,
+   length - offset - 3, req);
+   case GSM0480_OP_CODE_PROCESS_USS_DATA:
+   return parse_process_uss_data(rr_data + offset + 3,
+   length - offset - 3, req);
+   default:
+   LOGP(0, LOGL_DEBUG, "GSM 04.80 operation code 0x%02x "
+   "is not yet handled\n", operation_code);
+   return 0;
+   }
+
+   return 1;
+}
+
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct ss_request *req)
+{
+   uint8_t num_chars;
+
+   /* we need at least that much */
+   if (length < 3)
+   return 0;
+
+   if (uss_req_data[0] != ASN1_IA5_STRING_TAG)
+   return 0;
+
+   num_chars = uss_req_data[1];
+   if (num_chars > length - 2)
+   return 0;
+
+   if (num_chars > GSM0480_USSD_OCTET_STRING_LEN)
+   num_chars = GSM0480_USSD_OCTET_STRING_LEN;
+
+   memcpy(req->ussd_text, uss_req_data + 2, num_chars);
+
+   return 1;
+}
+
 /* Parse the parameters of a Process UnstructuredSS Request */
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
 struct ss_request *req)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 10
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder


libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2018-01-17 Thread Harald Welte

Patch Set 9: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 9
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2018-01-14 Thread Alexander Chemeris

Patch Set 9: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 9
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2018-01-14 Thread Vadim Yanitskiy
Hello Alexander Chemeris, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/3378

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

gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

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


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/78/3378/9

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 17657c7..fdec3d2 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -204,6 +204,10 @@
 struct ss_request *req);
 static int parse_ss_invoke(const uint8_t *invoke_data, uint16_t length,
struct ss_request *req);
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct ss_request *req);
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct ss_request *req);
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
struct ss_request *req);
 static int parse_ss_for_bs_req(const uint8_t *ss_req_data,
@@ -372,6 +376,9 @@
  req);
break;
case GSM0480_CTYPE_RETURN_RESULT:
+   rc &= parse_ss_return_result(facility_ie+2,
+component_length,
+req);
break;
case GSM0480_CTYPE_RETURN_ERROR:
break;
@@ -451,6 +458,81 @@
return rc;
 }
 
+/* Parse a Return Result component - see table 3.4 */
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct ss_request *req)
+{
+   uint8_t operation_code;
+   uint8_t offset;
+
+   if (length < 3)
+   return 0;
+
+   /* Mandatory part */
+   if (rr_data[0] != GSM0480_COMPIDTAG_INVOKE_ID) {
+   LOGP(0, LOGL_DEBUG, "Unexpected GSM 04.80 Component-ID tag "
+"0x%02x (expecting Invoke ID tag)\n", rr_data[0]);
+   return 0;
+   }
+
+   offset = rr_data[1] + 2;
+   req->invoke_id = rr_data[2];
+
+   if (offset >= length)
+   return 0;
+
+   if (rr_data[offset] != GSM_0480_SEQUENCE_TAG)
+   return 0;
+
+   if (offset + 2 > length)
+   return 0;
+
+   offset += 2;
+   operation_code = rr_data[offset + 2];
+   req->opcode = operation_code;
+
+   switch (operation_code) {
+   case GSM0480_OP_CODE_USS_NOTIFY:
+   case GSM0480_OP_CODE_USS_REQUEST:
+   case GSM0480_OP_CODE_PROCESS_USS_REQ:
+   return parse_process_uss_req(rr_data + offset + 3,
+   length - offset - 3, req);
+   case GSM0480_OP_CODE_PROCESS_USS_DATA:
+   return parse_process_uss_data(rr_data + offset + 3,
+   length - offset - 3, req);
+   default:
+   LOGP(0, LOGL_DEBUG, "GSM 04.80 operation code 0x%02x "
+   "is not yet handled\n", operation_code);
+   return 0;
+   }
+
+   return 1;
+}
+
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct ss_request *req)
+{
+   uint8_t num_chars;
+
+   /* we need at least that much */
+   if (length < 3)
+   return 0;
+
+   if (uss_req_data[0] != ASN1_IA5_STRING_TAG)
+   return 0;
+
+   num_chars = uss_req_data[1];
+   if (num_chars > length - 2)
+   return 0;
+
+   if (num_chars > GSM0480_USSD_OCTET_STRING_LEN)
+   num_chars = GSM0480_USSD_OCTET_STRING_LEN;
+
+   memcpy(req->ussd_text, uss_req_data + 2, num_chars);
+
+   return 1;
+}
+
 /* Parse the parameters of a Process UnstructuredSS Request */
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
 struct ss_request *req)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 9
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder


[PATCH] libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2018-01-14 Thread Vadim Yanitskiy
Hello Alexander Chemeris, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/3378

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

gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

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


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/78/3378/8

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 7b0fa6d..29d98a6 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -204,6 +204,10 @@
 struct ss_request *req);
 static int parse_ss_invoke(const uint8_t *invoke_data, uint16_t length,
struct ss_request *req);
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct ss_request *req);
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct ss_request *req);
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
struct ss_request *req);
 static int parse_ss_for_bs_req(const uint8_t *ss_req_data,
@@ -372,6 +376,9 @@
  req);
break;
case GSM0480_CTYPE_RETURN_RESULT:
+   rc &= parse_ss_return_result(facility_ie+2,
+component_length,
+req);
break;
case GSM0480_CTYPE_RETURN_ERROR:
break;
@@ -451,6 +458,81 @@
return rc;
 }
 
+/* Parse a Return Result component - see table 3.4 */
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct ss_request *req)
+{
+   uint8_t operation_code;
+   uint8_t offset;
+
+   if (length < 3)
+   return 0;
+
+   /* Mandatory part */
+   if (rr_data[0] != GSM0480_COMPIDTAG_INVOKE_ID) {
+   LOGP(0, LOGL_DEBUG, "Unexpected GSM 04.80 Component-ID tag "
+"0x%02x (expecting Invoke ID tag)\n", rr_data[0]);
+   return 0;
+   }
+
+   offset = rr_data[1] + 2;
+   req->invoke_id = rr_data[2];
+
+   if (offset >= length)
+   return 0;
+
+   if (rr_data[offset] != GSM_0480_SEQUENCE_TAG)
+   return 0;
+
+   if (offset + 2 > length)
+   return 0;
+
+   offset += 2;
+   operation_code = rr_data[offset + 2];
+   req->opcode = operation_code;
+
+   switch (operation_code) {
+   case GSM0480_OP_CODE_USS_NOTIFY:
+   case GSM0480_OP_CODE_USS_REQUEST:
+   case GSM0480_OP_CODE_PROCESS_USS_REQ:
+   return parse_process_uss_req(rr_data + offset + 3,
+   length - offset - 3, req);
+   case GSM0480_OP_CODE_PROCESS_USS_DATA:
+   return parse_process_uss_data(rr_data + offset + 3,
+   length - offset - 3, req);
+   default:
+   LOGP(0, LOGL_DEBUG, "GSM 04.80 operation code 0x%02x "
+   "is not yet handled\n", operation_code);
+   return 0;
+   }
+
+   return 1;
+}
+
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct ss_request *req)
+{
+   uint8_t num_chars;
+
+   /* we need at least that much */
+   if (length < 3)
+   return 0;
+
+   if (uss_req_data[0] != ASN1_IA5_STRING_TAG)
+   return 0;
+
+   num_chars = uss_req_data[1];
+   if (num_chars > length - 2)
+   return 0;
+
+   if (num_chars > GSM0408_USSD_OCTET_STRING_LEN)
+   num_chars = GSM0408_USSD_OCTET_STRING_LEN;
+
+   memcpy(req->ussd_text, uss_req_data + 2, num_chars);
+
+   return 1;
+}
+
 /* Parse the parameters of a Process UnstructuredSS Request */
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
 struct ss_request *req)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 8
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder


libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2018-01-12 Thread Harald Welte

Patch Set 7: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 7
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2018-01-11 Thread Vadim Yanitskiy
Hello Alexander Chemeris, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/3378

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

gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

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


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/78/3378/7

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 730f3c9..d9a90c7 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -204,6 +204,10 @@
 struct gsm0480_ss_request *req);
 static int parse_ss_invoke(const uint8_t *invoke_data, uint16_t length,
struct gsm0480_ss_request *req);
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct gsm0480_ss_request *req);
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct gsm0480_ss_request *req);
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
struct gsm0480_ss_request *req);
 static int parse_ss_for_bs_req(const uint8_t *ss_req_data,
@@ -369,6 +373,9 @@
  req);
break;
case GSM0480_CTYPE_RETURN_RESULT:
+   rc &= parse_ss_return_result(facility_ie+2,
+component_length,
+req);
break;
case GSM0480_CTYPE_RETURN_ERROR:
break;
@@ -448,6 +455,84 @@
return rc;
 }
 
+/* Parse a Return Result component - see table 3.4 */
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct gsm0480_ss_request *req)
+{
+   uint8_t operation_code;
+   uint8_t offset;
+
+   if (length < 3)
+   return 0;
+
+   /* Mandatory part */
+   if (rr_data[0] != GSM0480_COMPIDTAG_INVOKE_ID) {
+   LOGP(0, LOGL_DEBUG, "Unexpected GSM 04.80 Component-ID tag "
+"0x%02x (expecting Invoke ID tag)\n", rr_data[0]);
+   return 0;
+   }
+
+   offset = rr_data[1] + 2;
+   req->invoke_id = rr_data[2];
+
+   if (offset >= length)
+   return 0;
+
+   if (rr_data[offset] != GSM_0480_SEQUENCE_TAG)
+   return 0;
+
+   if (offset + 2 > length)
+   return 0;
+
+   offset += 2;
+   operation_code = rr_data[offset + 2];
+   req->opcode = operation_code;
+
+   switch (operation_code) {
+   case GSM0480_OP_CODE_USS_NOTIFY:
+   case GSM0480_OP_CODE_USS_REQUEST:
+   case GSM0480_OP_CODE_PROCESS_USS_REQ:
+   return parse_process_uss_req(rr_data + offset + 3,
+   length - offset - 3, req);
+   case GSM0480_OP_CODE_PROCESS_USS_DATA:
+   return parse_process_uss_data(rr_data + offset + 3,
+   length - offset - 3, req);
+   default:
+   LOGP(0, LOGL_DEBUG, "GSM 04.80 operation code 0x%02x "
+   "is not yet handled\n", operation_code);
+   return 0;
+   }
+
+   return 1;
+}
+
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct gsm0480_ss_request *req)
+{
+   uint8_t num_chars;
+
+   /* we need at least that much */
+   if (length < 3)
+   return 0;
+
+   if (uss_req_data[0] != ASN1_IA5_STRING_TAG)
+   return 0;
+
+   num_chars = uss_req_data[1];
+   if (num_chars > length - 2)
+   return 0;
+
+   if (num_chars > MAX_LEN_USSD_OCTET_STRING)
+   num_chars = MAX_LEN_USSD_OCTET_STRING;
+
+   memcpy(req->ussd_text, uss_req_data + 2, num_chars);
+
+   req->ussd_text_language = 0x00;
+   req->ussd_text_len = num_chars;
+
+   return 1;
+}
+
 /* Parse the parameters of a Process UnstructuredSS Request */
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
 struct gsm0480_ss_request *req)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 7
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder


libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2018-01-10 Thread Alexander Chemeris

Patch Set 6: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 6
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2018-01-10 Thread Vadim Yanitskiy
Hello Alexander Chemeris, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/3378

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

gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

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


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/78/3378/6

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index d717270..d1e978f 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -204,6 +204,10 @@
 struct gsm0480_ss_request *req);
 static int parse_ss_invoke(const uint8_t *invoke_data, uint16_t length,
struct gsm0480_ss_request *req);
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct gsm0480_ss_request *req);
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct gsm0480_ss_request *req);
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
struct gsm0480_ss_request *req);
 static int parse_ss_for_bs_req(const uint8_t *ss_req_data,
@@ -369,6 +373,9 @@
  req);
break;
case GSM0480_CTYPE_RETURN_RESULT:
+   rc &= parse_ss_return_result(facility_ie+2,
+component_length,
+req);
break;
case GSM0480_CTYPE_RETURN_ERROR:
break;
@@ -448,6 +455,83 @@
return rc;
 }
 
+/* Parse an Return Result component - see table 3.4 */
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct gsm0480_ss_request *req)
+{
+   uint8_t operation_code;
+   uint8_t offset;
+
+   if (length < 3)
+   return 0;
+
+   /* Mandatory part */
+   if (rr_data[0] != GSM0480_COMPIDTAG_INVOKE_ID) {
+   LOGP(0, LOGL_DEBUG, "Unexpected GSM 04.80 Component-ID tag "
+"0x%02x (expecting Invoke ID tag)\n", rr_data[0]);
+   return 0;
+   }
+
+   offset = rr_data[1] + 2;
+   req->invoke_id = rr_data[2];
+
+   if (offset >= length)
+   return 1;
+
+   if (rr_data[offset] != GSM_0480_SEQUENCE_TAG)
+   return 0;
+
+   if (offset + 2 > length)
+   return 0;
+
+   offset += 2;
+   operation_code = rr_data[offset + 2];
+   req->opcode = operation_code;
+
+   switch (operation_code) {
+   case GSM0480_OP_CODE_USS_NOTIFY:
+   case GSM0480_OP_CODE_USS_REQUEST:
+   case GSM0480_OP_CODE_PROCESS_USS_REQ:
+   return parse_process_uss_req(rr_data + offset + 3,
+   length - offset - 3, req);
+   case GSM0480_OP_CODE_PROCESS_USS_DATA:
+   return parse_process_uss_data(rr_data + offset + 3,
+   length - offset - 3, req);
+   default:
+   LOGP(0, LOGL_DEBUG, "GSM 04.80 operation code 0x%02x "
+   "is not yet handled\n", operation_code);
+   return 0;
+   }
+
+   return 1;
+}
+
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct gsm0480_ss_request *req)
+{
+   uint8_t num_chars;
+
+   /* we need at least that much */
+   if (length < 3)
+   return 0;
+
+   if (uss_req_data[0] != ASN1_IA5_STRING_TAG)
+   return 0;
+
+   num_chars = uss_req_data[1];
+   if (num_chars > length - 2)
+   return 0;
+
+   if (num_chars > MAX_LEN_USSD_STRING)
+   num_chars = MAX_LEN_USSD_STRING;
+
+   req->ussd_text_language = 1;
+   req->ussd_text_len = num_chars;
+   memcpy(req->ussd_text, uss_req_data + 2, num_chars);
+
+   return 1;
+}
+
 /* Parse the parameters of a Process UnstructuredSS Request */
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
 struct gsm0480_ss_request *req)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 6
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder


[PATCH] libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2018-01-10 Thread Vadim Yanitskiy
Hello Alexander Chemeris, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/3378

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

gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

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


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/78/3378/5

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index d717270..d1e978f 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -204,6 +204,10 @@
 struct gsm0480_ss_request *req);
 static int parse_ss_invoke(const uint8_t *invoke_data, uint16_t length,
struct gsm0480_ss_request *req);
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct gsm0480_ss_request *req);
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct gsm0480_ss_request *req);
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
struct gsm0480_ss_request *req);
 static int parse_ss_for_bs_req(const uint8_t *ss_req_data,
@@ -369,6 +373,9 @@
  req);
break;
case GSM0480_CTYPE_RETURN_RESULT:
+   rc &= parse_ss_return_result(facility_ie+2,
+component_length,
+req);
break;
case GSM0480_CTYPE_RETURN_ERROR:
break;
@@ -448,6 +455,83 @@
return rc;
 }
 
+/* Parse an Return Result component - see table 3.4 */
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct gsm0480_ss_request *req)
+{
+   uint8_t operation_code;
+   uint8_t offset;
+
+   if (length < 3)
+   return 0;
+
+   /* Mandatory part */
+   if (rr_data[0] != GSM0480_COMPIDTAG_INVOKE_ID) {
+   LOGP(0, LOGL_DEBUG, "Unexpected GSM 04.80 Component-ID tag "
+"0x%02x (expecting Invoke ID tag)\n", rr_data[0]);
+   return 0;
+   }
+
+   offset = rr_data[1] + 2;
+   req->invoke_id = rr_data[2];
+
+   if (offset >= length)
+   return 1;
+
+   if (rr_data[offset] != GSM_0480_SEQUENCE_TAG)
+   return 0;
+
+   if (offset + 2 > length)
+   return 0;
+
+   offset += 2;
+   operation_code = rr_data[offset + 2];
+   req->opcode = operation_code;
+
+   switch (operation_code) {
+   case GSM0480_OP_CODE_USS_NOTIFY:
+   case GSM0480_OP_CODE_USS_REQUEST:
+   case GSM0480_OP_CODE_PROCESS_USS_REQ:
+   return parse_process_uss_req(rr_data + offset + 3,
+   length - offset - 3, req);
+   case GSM0480_OP_CODE_PROCESS_USS_DATA:
+   return parse_process_uss_data(rr_data + offset + 3,
+   length - offset - 3, req);
+   default:
+   LOGP(0, LOGL_DEBUG, "GSM 04.80 operation code 0x%02x "
+   "is not yet handled\n", operation_code);
+   return 0;
+   }
+
+   return 1;
+}
+
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct gsm0480_ss_request *req)
+{
+   uint8_t num_chars;
+
+   /* we need at least that much */
+   if (length < 3)
+   return 0;
+
+   if (uss_req_data[0] != ASN1_IA5_STRING_TAG)
+   return 0;
+
+   num_chars = uss_req_data[1];
+   if (num_chars > length - 2)
+   return 0;
+
+   if (num_chars > MAX_LEN_USSD_STRING)
+   num_chars = MAX_LEN_USSD_STRING;
+
+   req->ussd_text_language = 1;
+   req->ussd_text_len = num_chars;
+   memcpy(req->ussd_text, uss_req_data + 2, num_chars);
+
+   return 1;
+}
+
 /* Parse the parameters of a Process UnstructuredSS Request */
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
 struct gsm0480_ss_request *req)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 5
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder


[PATCH] libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2018-01-09 Thread Vadim Yanitskiy
Hello Alexander Chemeris, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/3378

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

gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

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


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/78/3378/4

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index d717270..d1e978f 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -204,6 +204,10 @@
 struct gsm0480_ss_request *req);
 static int parse_ss_invoke(const uint8_t *invoke_data, uint16_t length,
struct gsm0480_ss_request *req);
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct gsm0480_ss_request *req);
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct gsm0480_ss_request *req);
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
struct gsm0480_ss_request *req);
 static int parse_ss_for_bs_req(const uint8_t *ss_req_data,
@@ -369,6 +373,9 @@
  req);
break;
case GSM0480_CTYPE_RETURN_RESULT:
+   rc &= parse_ss_return_result(facility_ie+2,
+component_length,
+req);
break;
case GSM0480_CTYPE_RETURN_ERROR:
break;
@@ -448,6 +455,83 @@
return rc;
 }
 
+/* Parse an Return Result component - see table 3.4 */
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct gsm0480_ss_request *req)
+{
+   uint8_t operation_code;
+   uint8_t offset;
+
+   if (length < 3)
+   return 0;
+
+   /* Mandatory part */
+   if (rr_data[0] != GSM0480_COMPIDTAG_INVOKE_ID) {
+   LOGP(0, LOGL_DEBUG, "Unexpected GSM 04.80 Component-ID tag "
+"0x%02x (expecting Invoke ID tag)\n", rr_data[0]);
+   return 0;
+   }
+
+   offset = rr_data[1] + 2;
+   req->invoke_id = rr_data[2];
+
+   if (offset >= length)
+   return 1;
+
+   if (rr_data[offset] != GSM_0480_SEQUENCE_TAG)
+   return 0;
+
+   if (offset + 2 > length)
+   return 0;
+
+   offset += 2;
+   operation_code = rr_data[offset + 2];
+   req->opcode = operation_code;
+
+   switch (operation_code) {
+   case GSM0480_OP_CODE_USS_NOTIFY:
+   case GSM0480_OP_CODE_USS_REQUEST:
+   case GSM0480_OP_CODE_PROCESS_USS_REQ:
+   return parse_process_uss_req(rr_data + offset + 3,
+   length - offset - 3, req);
+   case GSM0480_OP_CODE_PROCESS_USS_DATA:
+   return parse_process_uss_data(rr_data + offset + 3,
+   length - offset - 3, req);
+   default:
+   LOGP(0, LOGL_DEBUG, "GSM 04.80 operation code 0x%02x "
+   "is not yet handled\n", operation_code);
+   return 0;
+   }
+
+   return 1;
+}
+
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct gsm0480_ss_request *req)
+{
+   uint8_t num_chars;
+
+   /* we need at least that much */
+   if (length < 3)
+   return 0;
+
+   if (uss_req_data[0] != ASN1_IA5_STRING_TAG)
+   return 0;
+
+   num_chars = uss_req_data[1];
+   if (num_chars > length - 2)
+   return 0;
+
+   if (num_chars > MAX_LEN_USSD_STRING)
+   num_chars = MAX_LEN_USSD_STRING;
+
+   req->ussd_text_language = 1;
+   req->ussd_text_len = num_chars;
+   memcpy(req->ussd_text, uss_req_data + 2, num_chars);
+
+   return 1;
+}
+
 /* Parse the parameters of a Process UnstructuredSS Request */
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
 struct gsm0480_ss_request *req)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder


libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2017-08-09 Thread Harald Welte

Patch Set 3: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2017-07-30 Thread Alexander Chemeris

Patch Set 3: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Alexander Chemeris 
Gerrit-Reviewer: Ivan Kluchnikov 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2017-07-29 Thread Vadim Yanitskiy

gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

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


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/78/3378/2

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index e8a3bc3..7e036ba 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -202,6 +202,10 @@
 struct ss_request *req);
 static int parse_ss_invoke(const uint8_t *invoke_data, uint16_t length,
struct ss_request *req);
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct ss_request *req);
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct ss_request *req);
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
struct ss_request *req);
 static int parse_ss_for_bs_req(const uint8_t *ss_req_data,
@@ -360,6 +364,9 @@
  req);
break;
case GSM0480_CTYPE_RETURN_RESULT:
+   rc &= parse_ss_return_result(facility_ie+2,
+component_length,
+req);
break;
case GSM0480_CTYPE_RETURN_ERROR:
break;
@@ -439,6 +446,83 @@
return rc;
 }
 
+/* Parse an Return Result component - see table 3.4 */
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct ss_request *req)
+{
+   uint8_t operation_code;
+   uint8_t offset;
+
+   if (length < 3)
+   return 0;
+
+   /* Mandatory part */
+   if (rr_data[0] != GSM0480_COMPIDTAG_INVOKE_ID) {
+   LOGP(0, LOGL_DEBUG, "Unexpected GSM 04.80 Component-ID tag "
+"0x%02x (expecting Invoke ID tag)\n", rr_data[0]);
+   return 0;
+   }
+
+   offset = rr_data[1] + 2;
+   req->invoke_id = rr_data[2];
+
+   if (offset >= length)
+   return 1;
+
+   if (rr_data[offset] != GSM_0480_SEQUENCE_TAG)
+   return 0;
+
+   if (offset + 2 > length)
+   return 0;
+
+   offset += 2;
+   operation_code = rr_data[offset + 2];
+   req->opcode = operation_code;
+
+   switch (operation_code) {
+   case GSM0480_OP_CODE_USS_NOTIFY:
+   case GSM0480_OP_CODE_USS_REQUEST:
+   case GSM0480_OP_CODE_PROCESS_USS_REQ:
+   return parse_process_uss_req(rr_data + offset + 3,
+   length - offset - 3, req);
+   case GSM0480_OP_CODE_PROCESS_USS_DATA:
+   return parse_process_uss_data(rr_data + offset + 3,
+   length - offset - 3, req);
+   default:
+   LOGP(0, LOGL_DEBUG, "GSM 04.80 operation code 0x%02x "
+   "is not yet handled\n", operation_code);
+   return 0;
+   }
+
+   return 1;
+}
+
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct ss_request *req)
+{
+   uint8_t num_chars;
+
+   /* we need at least that much */
+   if (length < 3)
+   return 0;
+
+   if (uss_req_data[0] != ASN1_IA5_STRING_TAG)
+   return 0;
+
+   num_chars = uss_req_data[1];
+   if (num_chars > length - 2)
+   return 0;
+
+   if (num_chars > MAX_LEN_USSD_STRING)
+   num_chars = MAX_LEN_USSD_STRING;
+
+   req->ussd_text_language = 1;
+   req->ussd_text_len = num_chars;
+   memcpy(req->ussd_text, uss_req_data + 2, num_chars);
+
+   return 1;
+}
+
 /* Parse the parameters of a Process UnstructuredSS Request */
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
 struct ss_request *req)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2017-07-29 Thread Vadim Yanitskiy

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

gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

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


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/78/3378/1

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index e8a3bc3..7e036ba 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -202,6 +202,10 @@
 struct ss_request *req);
 static int parse_ss_invoke(const uint8_t *invoke_data, uint16_t length,
struct ss_request *req);
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct ss_request *req);
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct ss_request *req);
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
struct ss_request *req);
 static int parse_ss_for_bs_req(const uint8_t *ss_req_data,
@@ -360,6 +364,9 @@
  req);
break;
case GSM0480_CTYPE_RETURN_RESULT:
+   rc &= parse_ss_return_result(facility_ie+2,
+component_length,
+req);
break;
case GSM0480_CTYPE_RETURN_ERROR:
break;
@@ -439,6 +446,83 @@
return rc;
 }
 
+/* Parse an Return Result component - see table 3.4 */
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct ss_request *req)
+{
+   uint8_t operation_code;
+   uint8_t offset;
+
+   if (length < 3)
+   return 0;
+
+   /* Mandatory part */
+   if (rr_data[0] != GSM0480_COMPIDTAG_INVOKE_ID) {
+   LOGP(0, LOGL_DEBUG, "Unexpected GSM 04.80 Component-ID tag "
+"0x%02x (expecting Invoke ID tag)\n", rr_data[0]);
+   return 0;
+   }
+
+   offset = rr_data[1] + 2;
+   req->invoke_id = rr_data[2];
+
+   if (offset >= length)
+   return 1;
+
+   if (rr_data[offset] != GSM_0480_SEQUENCE_TAG)
+   return 0;
+
+   if (offset + 2 > length)
+   return 0;
+
+   offset += 2;
+   operation_code = rr_data[offset + 2];
+   req->opcode = operation_code;
+
+   switch (operation_code) {
+   case GSM0480_OP_CODE_USS_NOTIFY:
+   case GSM0480_OP_CODE_USS_REQUEST:
+   case GSM0480_OP_CODE_PROCESS_USS_REQ:
+   return parse_process_uss_req(rr_data + offset + 3,
+   length - offset - 3, req);
+   case GSM0480_OP_CODE_PROCESS_USS_DATA:
+   return parse_process_uss_data(rr_data + offset + 3,
+   length - offset - 3, req);
+   default:
+   LOGP(0, LOGL_DEBUG, "GSM 04.80 operation code 0x%02x "
+   "is not yet handled\n", operation_code);
+   return 0;
+   }
+
+   return 1;
+}
+
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct ss_request *req)
+{
+   uint8_t num_chars;
+
+   /* we need at least that much */
+   if (length < 3)
+   return 0;
+
+   if (uss_req_data[0] != ASN1_IA5_STRING_TAG)
+   return 0;
+
+   num_chars = uss_req_data[1];
+   if (num_chars > length - 2)
+   return 0;
+
+   if (num_chars > MAX_LEN_USSD_STRING)
+   num_chars = MAX_LEN_USSD_STRING;
+
+   req->ussd_text_language = 1;
+   req->ussd_text_len = num_chars;
+   memcpy(req->ussd_text, uss_req_data + 2, num_chars);
+
+   return 1;
+}
+
 /* Parse the parameters of a Process UnstructuredSS Request */
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
 struct ss_request *req)

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

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