aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmsc/gsm_04_80.c
diff options
context:
space:
mode:
authorSergey Kostanbaev <sergey.kostanbaev@gmail.com>2015-10-30 15:14:49 +0300
committerIvan Kluchnikov <kluchnikovi@gmail.com>2017-02-07 18:59:54 +0300
commit012c9203e46a359f0178b45e0bc936bcd044ad00 (patch)
treeaa9d1e5e17c62d72c197da23e580fac762b6bc0b /openbsc/src/libmsc/gsm_04_80.c
parent5087f994fdf2457f6b20af90823cb2f668d8c5d5 (diff)
ussd: handle UCS-2 coding
Diffstat (limited to 'openbsc/src/libmsc/gsm_04_80.c')
-rw-r--r--openbsc/src/libmsc/gsm_04_80.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/openbsc/src/libmsc/gsm_04_80.c b/openbsc/src/libmsc/gsm_04_80.c
index 4350557b4..a8cf3e9bf 100644
--- a/openbsc/src/libmsc/gsm_04_80.c
+++ b/openbsc/src/libmsc/gsm_04_80.c
@@ -78,7 +78,10 @@ static inline unsigned char *msgb_push_TLV1(struct msgb *msgb, uint8_t tag,
/* Send response to a mobile-originated ProcessUnstructuredSS-Request */
int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,
- const struct msgb *in_msg, const char *response_text,
+ const struct msgb *in_msg,
+ int response_text_len,
+ uint8_t response_lang,
+ const char *response_text,
const struct ussd_request *req,
uint8_t code,
uint8_t ctype,
@@ -89,33 +92,23 @@ int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,
uint8_t *ptr8;
int response_len;
-#if 1
- /* First put the payload text into the message */
ptr8 = msgb_put(msg, 0);
- gsm_7bit_encode_n_ussd(ptr8, msgb_tailroom(msg), response_text, &response_len);
- msgb_put(msg, response_len);
- /* Then wrap it as an Octet String */
- msgb_wrap_with_ASN1_TL(msg, ASN1_OCTET_STRING_TAG);
-
- /* Pre-pend the DCS octet string */
- msgb_push_TLV1(msg, ASN1_OCTET_STRING_TAG, 0x0F);
-#else
- response_len = strlen(response_text);
- if (response_len > MAX_LEN_USSD_STRING)
- response_len = MAX_LEN_USSD_STRING;
-
- ptr8 = msgb_put(msg, 0);
- memcpy(ptr8, response_text, response_len);
- msgb_put(msg, response_len);
+ if (response_text_len < 0) {
+ /* First put the payload text into the message */
+ gsm_7bit_encode_n_ussd(ptr8, msgb_tailroom(msg), response_text, &response_len);
+ msgb_put(msg, response_len);
+ response_lang = 0x0F;
+ } else {
+ memcpy(ptr8, response_text, response_text_len);
+ msgb_put(msg, response_text_len);
+ }
/* Then wrap it as an Octet String */
msgb_wrap_with_ASN1_TL(msg, ASN1_OCTET_STRING_TAG);
/* Pre-pend the DCS octet string */
- msgb_push_TLV1(msg, ASN1_OCTET_STRING_TAG, 0xf4);
-#endif
-
+ msgb_push_TLV1(msg, ASN1_OCTET_STRING_TAG, response_lang);
/* Then wrap these as a Sequence */
msgb_wrap_with_ASN1_TL(msg, GSM_0480_SEQUENCE_TAG);