mirror of https://gerrit.osmocom.org/libosmocore
gsm: Revert the gsm_7bit_encode changes as they are wrong
This reverts commitf996b05dbd
and2b0cac4ef8
. 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.
This commit is contained in:
parent
98de27a187
commit
47aa482bb0
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue