FreeCalypso > hg > themwi-system-sw
comparison smpp-send/build_pdu.c @ 223:f11c3e40c87a
new program smpp-send
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 05 Aug 2023 12:24:31 -0800 |
parents | |
children | 243ed87880a1 |
comparison
equal
deleted
inserted
replaced
222:9d6e8d99d2b1 | 223:f11c3e40c87a |
---|---|
1 /* | |
2 * The function in this module constructs SMPP submit_sm PDUs | |
3 * from input messages. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include <stdio.h> | |
8 #include <stdlib.h> | |
9 #include <string.h> | |
10 #include <strings.h> | |
11 #include "error.h" | |
12 | |
13 extern char src_addr[21], dest_addr[21]; | |
14 extern u_char src_ton, src_npi, dest_ton, dest_npi; | |
15 extern u_char esm_class, pid_byte, dcs_byte; | |
16 extern u_char prio_flag, reg_deliv, replace_flag; | |
17 | |
18 extern int input_lineno; | |
19 | |
20 void | |
21 build_submit_sm(payload, payload_len, udhi) | |
22 u_char *payload; | |
23 unsigned payload_len; | |
24 { | |
25 u_char pdu[512], *dp, esm_class_inst; | |
26 unsigned pdu_len, slen; | |
27 | |
28 /* sanity checks first */ | |
29 if (!src_addr[0]) { | |
30 fprintf(stderr, ERR_PREFIX "src address is not set\n", | |
31 input_lineno); | |
32 exit(1); | |
33 } | |
34 if (!dest_addr[0]) { | |
35 fprintf(stderr, ERR_PREFIX "dest address is not set\n", | |
36 input_lineno); | |
37 exit(1); | |
38 } | |
39 /* proceed */ | |
40 dp = pdu + 4; /* length will be filled last */ | |
41 /* command_id */ | |
42 *dp++ = 0; | |
43 *dp++ = 0; | |
44 *dp++ = 0; | |
45 *dp++ = 0x04; /* submit_sm */ | |
46 /* empty command_status */ | |
47 *dp++ = 0; | |
48 *dp++ = 0; | |
49 *dp++ = 0; | |
50 *dp++ = 0; | |
51 /* dummy sequence_number (will be overwritten by smpp-trx-sa) */ | |
52 *dp++ = 0; | |
53 *dp++ = 0; | |
54 *dp++ = 0; | |
55 *dp++ = 0; | |
56 /* mandatory params */ | |
57 *dp++ = 0; /* empty service_type */ | |
58 *dp++ = src_ton; | |
59 *dp++ = src_npi; | |
60 slen = strlen(src_addr) + 1; | |
61 bcopy(src_addr, dp, slen); | |
62 dp += slen; | |
63 *dp++ = dest_ton; | |
64 *dp++ = dest_npi; | |
65 slen = strlen(dest_addr) + 1; | |
66 bcopy(dest_addr, dp, slen); | |
67 dp += slen; | |
68 esm_class_inst = esm_class; | |
69 if (udhi) | |
70 esm_class_inst |= 0x40; | |
71 *dp++ = esm_class_inst; | |
72 *dp++ = pid_byte; | |
73 *dp++ = prio_flag; | |
74 *dp++ = 0; /* empty schedule_delivery_time */ | |
75 *dp++ = 0; /* empty validity_period */ | |
76 *dp++ = reg_deliv; | |
77 *dp++ = replace_flag; | |
78 *dp++ = dcs_byte; | |
79 *dp++ = 0; /* no canned messages */ | |
80 *dp++ = payload_len; | |
81 bcopy(payload, dp, payload_len); | |
82 dp += payload_len; | |
83 pdu_len = dp - pdu; | |
84 pdu[0] = pdu_len >> 24; | |
85 pdu[1] = pdu_len >> 16; | |
86 pdu[2] = pdu_len >> 8; | |
87 pdu[3] = pdu_len; | |
88 /* local datagram socket output to be implemented */ | |
89 hex_dump_output(pdu, pdu_len); | |
90 } |