This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Vadim Yanitskiy gerrit-no-reply at lists.osmocom.orgReview 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 <axilirator at gmail.com>