comparison uptools/libcoding/sms_submit.c @ 360:68c8cf672ecd

uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 04 Mar 2018 06:24:36 +0000
parents
children d1fa771abeb8
comparison
equal deleted inserted replaced
359:061f8d75083d 360:68c8cf672ecd
1 /*
2 * This library module implements the function for constructing outgoing
3 * SMS-SUBMIT PDUs.
4 */
5
6 #include <sys/types.h>
7 #include <strings.h>
8
9 make_sms_submit_pdu(da, textsrc, textlen, udh, udhl, outbuf)
10 u_char *da, *textsrc, *udh, *outbuf;
11 unsigned textlen, udhl;
12 {
13 u_char *outp = outbuf;
14 unsigned addr_field_len;
15 unsigned udh_octets, udh_chars;
16 u_char ud7[160];
17 unsigned udl, udl_octets;
18
19 if (udh)
20 *outp++ = 0x41;
21 else
22 *outp++ = 0x01;
23 *outp++ = 0;
24 addr_field_len = ((da[0] + 1) >> 1) + 2;
25 bcopy(da, outp, addr_field_len);
26 outp += addr_field_len;
27 *outp++ = 0;
28 *outp++ = 0;
29 if (udh) {
30 udh_octets = udhl + 1;
31 udh_chars = (udh_octets * 8 + 6) / 7;
32 } else {
33 udh_octets = 0;
34 udh_chars = 0;
35 }
36 udl = udh_chars + textlen;
37 *outp++ = udl;
38 udl_octets = (udl * 7 + 7) / 8;
39 bzero(ud7, 160);
40 bcopy(textsrc, ud7 + udh_chars, textlen);
41 gsm7_pack(ud7, outp, udl_octets);
42 if (udh) {
43 *outp = udhl;
44 bcopy(udh, outp + 1, udhl);
45 }
46 outp += udl_octets;
47 return (outp - outbuf);
48 }