summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-07 13:54:53 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-07 13:59:16 +0200
commit47aa482bb0094edfc21bbb45dc0f0e8c9c42c521 (patch)
tree3456dd938cd25440091ad6c9c8d3d58abb76d49b /src
parent98de27a18740ea147ffee634ed3d2006329b254f (diff)
gsm: Revert the gsm_7bit_encode changes as they are wrong
This reverts commit f996b05dbddccb8e8788dd69777a4fedfa2373eb and 2b0cac4ef83137ee0bdd583aee877eac467abeab. A detailed explanation can be found here: http://lists.osmocom.org/pipermail/openbsc/2013-July/004737.html The short description is that: 1.) The API should return (as out parameter) the number of octets used. 2.) The handling for the <CR> encoding only applies to USSD and it is incomplete. On top of that it broke the SMS test.
Diffstat (limited to 'src')
-rw-r--r--src/gsm/gsm0480.c33
-rw-r--r--src/gsm/gsm_utils.c6
2 files changed, 9 insertions, 30 deletions
diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 89d43c84..b9b3ed97 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -85,7 +85,7 @@ struct msgb *gsm0480_create_unstructuredSS_Notify(int alertPattern, const char *
{
struct msgb *msg;
uint8_t *seq_len_ptr, *ussd_len_ptr, *data;
- int len, octet_len;
+ int len;
msg = msgb_alloc_headroom(1024, 128, "GSM 04.80");
if (!msg)
@@ -106,13 +106,8 @@ struct msgb *gsm0480_create_unstructuredSS_Notify(int alertPattern, const char *
ussd_len_ptr = msgb_put(msg, 1);
data = msgb_put(msg, 0);
len = gsm_7bit_encode(data, text);
- octet_len = len*7/8;
- if (len*7%8 != 0)
- octet_len++;
- /* Warning, len indicates the amount of septets
- * (characters), we need amount of octets occupied */
- msgb_put(msg, octet_len);
- ussd_len_ptr[0] = octet_len;
+ msgb_put(msg, len);
+ ussd_len_ptr[0] = len;
/* USSD-String } */
/* alertingPattern { */
@@ -132,7 +127,7 @@ struct msgb *gsm0480_create_notifySS(const char *text)
struct msgb *msg;
uint8_t *data, *tmp_len;
uint8_t *seq_len_ptr, *cal_len_ptr, *opt_len_ptr, *nam_len_ptr;
- int len, octet_len;
+ int len;
len = strlen(text);
if (len < 1 || len > 160)
@@ -178,17 +173,12 @@ struct msgb *gsm0480_create_notifySS(const char *text)
tmp_len = msgb_put(msg, 1);
data = msgb_put(msg, 0);
len = gsm_7bit_encode(data, text);
- octet_len = len*7/8;
- if (len*7%8 != 0)
- octet_len++;
- /* Warning, len indicates the amount of septets
- * (characters), we need amount of octets occupied */
- tmp_len[0] = octet_len;
- msgb_put(msg, octet_len);
+ tmp_len[0] = len;
+ msgb_put(msg, len);
/* }; namePresentationAllowed */
- cal_len_ptr[0] = 3 + 3 + 2 + octet_len;
+ cal_len_ptr[0] = 3 + 3 + 2 + len;
opt_len_ptr[0] = cal_len_ptr[0] + 2;
/* }; callingName */
@@ -425,7 +415,7 @@ struct msgb *gsm0480_create_ussd_resp(uint8_t invoke_id, uint8_t trans_id, const
struct msgb *msg;
struct gsm48_hdr *gh;
uint8_t *ptr8;
- int response_len, octet_len;
+ int response_len;
msg = msgb_alloc_headroom(1024, 128, "GSM 04.80");
if (!msg)
@@ -434,12 +424,7 @@ struct msgb *gsm0480_create_ussd_resp(uint8_t invoke_id, uint8_t trans_id, const
/* First put the payload text into the message */
ptr8 = msgb_put(msg, 0);
response_len = gsm_7bit_encode(ptr8, text);
- octet_len = response_len*7/8;
- if (response_len*7%8 != 0)
- octet_len++;
- /* Warning, response_len indicates the amount of septets
- * (characters), we need amount of octets occupied */
- msgb_put(msg, octet_len);
+ msgb_put(msg, response_len);
/* Then wrap it as an Octet String */
msgb_wrap_with_TL(msg, ASN1_OCTET_STRING_TAG);
diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c
index fa77eae4..9569cf32 100644
--- a/src/gsm/gsm_utils.c
+++ b/src/gsm/gsm_utils.c
@@ -241,12 +241,6 @@ int gsm_septets2octets(uint8_t *result, const uint8_t *rdata, uint8_t septet_len
result[z++] = cb;
shift++;
}
- /* To avoid the situation where the receiving entity confuses 7 binary
- * zero pad bits as the @ character, the carriage return or <CR>
- * character (defined in subclause 7.1.1) shall be used for padding in
- * this situation. */
- if (shift == 7)
- result[z - 1] |= 0x1a;
free(data);