aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/gsm_04_80.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-07-26 17:56:55 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-07-26 17:56:55 +0800
commitba81ab329ccaff7fe7632eef047fb1b3fa81f760 (patch)
treee132d8f311257a8faeb49c33a78139f19e71fe90 /openbsc/src/gsm_04_80.c
parent6a4b362ceb7dd1742de2d1ffebadf1846634a3af (diff)
gsm_04_80: Use the return value of gsm_7bit_encode as length
Use the idiom msgb_put(msg, 0) to get the data pointer, then encode the string into the msgb and then adjust the size.
Diffstat (limited to 'openbsc/src/gsm_04_80.c')
-rw-r--r--openbsc/src/gsm_04_80.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/openbsc/src/gsm_04_80.c b/openbsc/src/gsm_04_80.c
index 71fb40577..2d061e316 100644
--- a/openbsc/src/gsm_04_80.c
+++ b/openbsc/src/gsm_04_80.c
@@ -318,13 +318,10 @@ int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,
u_int8_t *ptr8;
int response_len;
- response_len = (strlen(response_text) * 7) / 8;
- if (((strlen(response_text) * 7) % 8) != 0)
- response_len += 1;
-
/* First put the payload text into the message */
- ptr8 = msgb_put(msg, response_len);
- gsm_7bit_encode(ptr8, response_text);
+ ptr8 = msgb_put(msg, 0);
+ response_len = gsm_7bit_encode(ptr8, response_text);
+ msgb_put(msg, response_len);
/* Then wrap it as an Octet String */
msgb_wrap_with_TL(msg, ASN1_OCTET_STRING_TAG);