Begin forwarded message:
Date: Fri, 19 Sep 2003 16:37:50 +0400
From: Yury Mikhienko <[EMAIL PROTECTED]>
To: Andreas Fink <[EMAIL PROTECTED]>
Subject: Re: catenate the ff fe prefix in UTF-16 encoded octstr and swapping bytes in
words (if it tnecessary)
Hi Andreas!
I anticipate the wery interesting disscursion :)
> this type of patch should not be necessary, Kannel runs successfully on
> big-endian and little-endian machines (example: PowerPC versus Intel).
> So if it doesnt work for you on SPARC the detection of endianness is
> somehow screwed.
>
> Is this concerning UTF-16 encoded SMS text only?
in this case - yes, but now I modify my code to:
if (msg->sms.coding == DC_UCS2) {
/*
* remove the first two bytes FE FF from octetstring (add from yuryx for SMSCv3.2)
*
*/
Octstr *octstr_tmp = NULL;
short UTF_16_PREFIX = 0xfffe;
#if (defined (__sparc__) || defined (__sparc) || defined (__sun))
UTF_16_PREFIX = 0xfeff; /* in SPARC low byte follow from hight byte in word
(in INTEL, bytes swap in memory) */
#endif
octstr_swap_bytes(pdu->u.submit_sm.short_message); /* <-------- that
necessary for properlly work with UTF-16 encoded content (I use cocoon for serializing
output content on each request) */
octstr_tmp = octstr_create("");
octstr_append_data(octstr_tmp, (char*) &UTF_16_PREFIX, 2);
if(octstr_ncompare(pdu->u.submit_sm.short_message, octstr_tmp, 2) == 0) {
octstr_delete(pdu->u.submit_sm.short_message, 0, 2);
}
octstr_destroy(octstr_tmp);
}
> how do you post process the output?
>
with my code (properlly worked on Intel and SPARC platforms)
2003-09-19 15:57:43 [5] DEBUG: SMPP PDU 0x8177a50 dump:
2003-09-19 15:57:43 [5] DEBUG: type_name: submit_sm
2003-09-19 15:57:43 [5] DEBUG: command_id: 4 = 0x00000004
2003-09-19 15:57:43 [5] DEBUG: command_status: 0 = 0x00000000
2003-09-19 15:57:43 [5] DEBUG: sequence_number: 7 = 0x00000007
2003-09-19 15:57:43 [5] DEBUG: service_type: NULL
2003-09-19 15:57:43 [5] DEBUG: source_addr_ton: 1 = 0x00000001
2003-09-19 15:57:43 [5] DEBUG: source_addr_npi: 1 = 0x00000001
2003-09-19 15:57:43 [5] DEBUG: source_addr: "xxxxx000013"
2003-09-19 15:57:43 [5] DEBUG: dest_addr_ton: 1 = 0x00000001
2003-09-19 15:57:43 [5] DEBUG: dest_addr_npi: 1 = 0x00000001
2003-09-19 15:57:43 [5] DEBUG: destination_addr: "xxxxx010199"
2003-09-19 15:57:43 [5] DEBUG: esm_class: 3 = 0x00000003
2003-09-19 15:57:43 [5] DEBUG: protocol_id: 0 = 0x00000000
2003-09-19 15:57:43 [5] DEBUG: priority_flag: 0 = 0x00000000
2003-09-19 15:57:43 [5] DEBUG: schedule_delivery_time: NULL
2003-09-19 15:57:43 [5] DEBUG: validity_period: NULL
2003-09-19 15:57:43 [5] DEBUG: registered_delivery: 0 = 0x00000000
2003-09-19 15:57:43 [5] DEBUG: replace_if_present_flag: 0 = 0x00000000
2003-09-19 15:57:43 [5] DEBUG: data_coding: 24 = 0x00000018
2003-09-19 15:57:43 [5] DEBUG: sm_default_msg_id: 0 = 0x00000000
2003-09-19 15:57:43 [5] DEBUG: sm_length: 58 = 0x0000003a
2003-09-19 15:57:43 [5] DEBUG: short_message:
2003-09-19 15:57:43 [5] DEBUG: Octet string at 0x8177dd8:
2003-09-19 15:57:43 [5] DEBUG: len: 58
2003-09-19 15:57:43 [5] DEBUG: size: 61
2003-09-19 15:57:43 [5] DEBUG: immutable: 0
2003-09-19 15:57:43 [5] DEBUG: data: 00 79 00 75 00 72 00 79 00 78 00 40 00 6d 00
6f [EMAIL PROTECTED]
2003-09-19 15:57:43 [5] DEBUG: data: 00 62 00 69 00 63 00 6f 00 6d 00 6b 00 2e 00
72 .b.i.c.o.m.k...r
2003-09-19 15:57:43 [5] DEBUG: data: 00 75 00 20 04 3e 04 42 04 3f 04 40 04 30 04
32 .u. .>[EMAIL PROTECTED]
2003-09-19 15:57:43 [5] DEBUG: data: 04 3b 04 35 04 3d 04 3e 00 2e
.;.5.=.>..
2003-09-19 15:57:43 [5] DEBUG: Octet string dump ends.
without the my code I get the following pdu: (and wrong message)
2003-09-19 16:24:44 [5] DEBUG: SMPP[SMPP_TR]: Sending PDU:
2003-09-19 16:24:44 [5] DEBUG: SMPP PDU 0x8176740 dump:
2003-09-19 16:24:44 [5] DEBUG: type_name: submit_sm
2003-09-19 16:24:44 [5] DEBUG: command_id: 4 = 0x00000004
2003-09-19 16:24:44 [5] DEBUG: command_status: 0 = 0x00000000
2003-09-19 16:24:44 [5] DEBUG: sequence_number: 4 = 0x00000004
2003-09-19 16:24:44 [5] DEBUG: service_type: NULL
2003-09-19 16:24:44 [5] DEBUG: source_addr_ton: 1 = 0x00000001
2003-09-19 16:24:44 [5] DEBUG: source_addr_npi: 1 = 0x00000001
2003-09-19 16:24:44 [5] DEBUG: source_addr: "xxxxxx00013"
2003-09-19 16:24:44 [5] DEBUG: dest_addr_ton: 1 = 0x00000001
2003-09-19 16:24:44 [5] DEBUG: dest_addr_npi: 1 = 0x00000001
2003-09-19 16:24:44 [5] DEBUG: destination_addr: "xxxxx010199"
2003-09-19 16:24:44 [5] DEBUG: esm_class: 3 = 0x00000003
2003-09-19 16:24:44 [5] DEBUG: protocol_id: 0 = 0x00000000
2003-09-19 16:24:44 [5] DEBUG: priority_flag: 0 = 0x00000000
2003-09-19 16:24:44 [5] DEBUG: schedule_delivery_time: NULL
2003-09-19 16:24:44 [5] DEBUG: validity_period: NULL
2003-09-19 16:24:44 [5] DEBUG: registered_delivery: 0 = 0x00000000
2003-09-19 16:24:44 [5] DEBUG: replace_if_present_flag: 0 = 0x00000000
2003-09-19 16:24:44 [5] DEBUG: data_coding: 24 = 0x00000018
2003-09-19 16:24:44 [5] DEBUG: sm_default_msg_id: 0 = 0x00000000
2003-09-19 16:24:44 [5] DEBUG: sm_length: 60 = 0x0000003c
2003-09-19 16:24:44 [5] DEBUG: short_message:
2003-09-19 16:24:44 [5] DEBUG: Octet string at 0x8176d80:
2003-09-19 16:24:44 [5] DEBUG: len: 60
2003-09-19 16:24:44 [5] DEBUG: size: 61
2003-09-19 16:24:44 [5] DEBUG: immutable: 0
2003-09-19 16:24:44 [5] DEBUG: data: ff fe 79 00 75 00 72 00 79 00 78 00 40 00 6d
00 [EMAIL PROTECTED]
2003-09-19 16:24:44 [5] DEBUG: data: 6f 00 62 00 69 00 63 00 6f 00 6d 00 6b 00 2e
00 o.b.i.c.o.m.k...
2003-09-19 16:24:44 [5] DEBUG: data: 72 00 75 00 20 00 3e 04 42 04 3f 04 40 04 30
04 r.u. .>[EMAIL PROTECTED]
2003-09-19 16:24:44 [5] DEBUG: data: 32 04 3b 04 35 04 3d 04 3e 04 2e 00
2.;.5.=.>...
2003-09-19 16:24:44 [5] DEBUG: Octet string dump ends.
2003-09-19 16:24:44 [5] DEBUG: SMPP PDU dump ends.
I found and correct the wrong code in pdu_pack function (smpp_pdu.c) in optional
parameters packing section also
diff in attachment
> On Freitag, September 19, 2003, at 11:07 Uhr, Yury Mikhienko wrote:
>
> > Hi developers!
> >
> > I use kannel as SMSGW on the SPARC (with SunOS) platform and I was
> > oblige to implement the following futures in some functions :))
> >
> > in gwlib/octstr.c
> >
> > void octstr_swap_bytes(Octstr *ostr)
> > {
> > unsigned char ch = 0;
> > long pos;
> >
> > seems_valid(ostr);
> >
> > for(pos = 0;pos < ostr->len - 1;pos += 2)
> > {
> > ch = ostr->data[pos];
> > ostr->data[pos] = ostr->data[pos + 1];
> > ostr->data[pos + 1] = ch;
> > }
> > }
> >
> > in gwlib/octstr.h
> >
> > void octstr_swap_bytes(Octstr *ostr);
> >
--
Best regards,
Yury Mikhienko.
IT ERP group head, ZAO "Mobicom-Kavkaz"
--
Best regards,
Yury Mikhienko.
IT ERP group head, ZAO "Mobicom-Kavkaz"
smpp_pdu.patch
Description: Binary data
