annotate uptools/libcoding/sms_submit.c @ 507:c942be3c7997

new flash support works for PL129N on the Pirelli
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 28 May 2019 05:34:45 +0000
parents d1fa771abeb8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
360
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This library module implements the function for constructing outgoing
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * SMS-SUBMIT PDUs.
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <strings.h>
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
374
d1fa771abeb8 uptools: make_sms_submit_pdu() in libcoding now takes PID and DCS arguments
Mychaela Falconia <falcon@freecalypso.org>
parents: 360
diff changeset
9 make_sms_submit_pdu(da, pid, dcs, textsrc, textlen, udh, udhl, outbuf)
360
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 u_char *da, *textsrc, *udh, *outbuf;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 unsigned textlen, udhl;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 {
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 u_char *outp = outbuf;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 unsigned addr_field_len;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 unsigned udh_octets, udh_chars;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 u_char ud7[160];
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 unsigned udl, udl_octets;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 if (udh)
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 *outp++ = 0x41;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 else
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 *outp++ = 0x01;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 *outp++ = 0;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 addr_field_len = ((da[0] + 1) >> 1) + 2;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 bcopy(da, outp, addr_field_len);
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 outp += addr_field_len;
374
d1fa771abeb8 uptools: make_sms_submit_pdu() in libcoding now takes PID and DCS arguments
Mychaela Falconia <falcon@freecalypso.org>
parents: 360
diff changeset
27 *outp++ = pid;
d1fa771abeb8 uptools: make_sms_submit_pdu() in libcoding now takes PID and DCS arguments
Mychaela Falconia <falcon@freecalypso.org>
parents: 360
diff changeset
28 *outp++ = dcs;
360
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 if (udh) {
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 udh_octets = udhl + 1;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 udh_chars = (udh_octets * 8 + 6) / 7;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 } else {
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 udh_octets = 0;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 udh_chars = 0;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 udl = udh_chars + textlen;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 *outp++ = udl;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 udl_octets = (udl * 7 + 7) / 8;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 bzero(ud7, 160);
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 bcopy(textsrc, ud7 + udh_chars, textlen);
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 gsm7_pack(ud7, outp, udl_octets);
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (udh) {
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 *outp = udhl;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 bcopy(udh, outp + 1, udhl);
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 outp += udl_octets;
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 return (outp - outbuf);
68c8cf672ecd uptools/libcoding: implemented generation of SMS-SUBMIT PDUs
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 }