FreeCalypso > hg > themwi-system-sw
annotate utils/smpp-test2.c @ 231:abb3f415b9dd
themwi-update-numdb2: check secondary numbers
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 14 Aug 2023 11:45:41 -0800 |
parents | e1d7db9d734c |
children |
rev | line source |
---|---|
218
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This program connects to an SMPP server in the role of a client, |
221
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
3 * sends a bind_transceiver request, and then goes into a receiving loop, |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
4 * dumping everything that comes back from the server. Received packets |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
5 * are also checked for some command opcodes to which we need to generate |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
6 * a response, and simple auto-responses are generated. |
218
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 */ |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <sys/types.h> |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <sys/socket.h> |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <netinet/in.h> |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <arpa/inet.h> |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <stdio.h> |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <stdlib.h> |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <string.h> |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include <strings.h> |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include <unistd.h> |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 static int tcpsock; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 static struct sockaddr_in server_sin; |
220
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
21 static u_char bind_req[64]; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
22 static unsigned bind_req_len; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
23 static char system_id[16], password[9]; |
218
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 static u_char rx_hdr[16]; |
221
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
25 static unsigned rx_pkt_len, rx_command_id; |
218
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 static void |
220
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
28 construct_bind_req() |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
29 { |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
30 u_char *dp; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
31 unsigned slen; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
32 |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
33 dp = bind_req + 4; /* length will be filled last */ |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
34 /* command_id */ |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
35 *dp++ = 0; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
36 *dp++ = 0; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
37 *dp++ = 0; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
38 *dp++ = 0x09; /* bind_transceiver */ |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
39 /* empty command_status */ |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
40 *dp++ = 0; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
41 *dp++ = 0; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
42 *dp++ = 0; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
43 *dp++ = 0; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
44 /* sequence_number */ |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
45 *dp++ = 0; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
46 *dp++ = 0; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
47 *dp++ = 0; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
48 *dp++ = 1; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
49 /* system_id */ |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
50 slen = strlen(system_id) + 1; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
51 bcopy(system_id, dp, slen); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
52 dp += slen; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
53 /* password */ |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
54 slen = strlen(password) + 1; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
55 bcopy(password, dp, slen); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
56 dp += slen; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
57 /* system_type */ |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
58 strcpy(dp, "SMPP"); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
59 dp += 5; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
60 /* interface_version */ |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
61 *dp++ = 0x34; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
62 /* addr_ton */ |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
63 *dp++ = 0; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
64 /* addr_npi */ |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
65 *dp++ = 0; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
66 /* address_range */ |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
67 *dp++ = 0; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
68 bind_req_len = dp - bind_req; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
69 bind_req[0] = bind_req_len >> 24; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
70 bind_req[1] = bind_req_len >> 16; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
71 bind_req[2] = bind_req_len >> 8; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
72 bind_req[3] = bind_req_len; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
73 } |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
74 |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
75 static void |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
76 print_bind_req() |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
77 { |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
78 unsigned off, chunk; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
79 int i, c; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
80 |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
81 printf("Constructed bind request of %u bytes\n", bind_req_len); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
82 for (off = 0; off < bind_req_len; off += chunk) { |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
83 chunk = bind_req_len - off; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
84 if (chunk > 16) |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
85 chunk = 16; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
86 printf("%02X: ", off); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
87 for (i = 0; i < 16; i++) { |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
88 if (i < chunk) |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
89 printf("%02X ", bind_req[off + i]); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
90 else |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
91 fputs(" ", stdout); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
92 if (i == 7 || i == 15) |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
93 putchar(' '); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
94 } |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
95 for (i = 0; i < chunk; i++) { |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
96 c = bind_req[off + i]; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
97 if (c < ' ' || c > '~') |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
98 c = '.'; |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
99 putchar(c); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
100 } |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
101 putchar('\n'); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
102 } |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
103 } |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
104 |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
105 static void |
218
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 init_stage() |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 int rc; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 rc = connect(tcpsock, (struct sockaddr *) &server_sin, |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 sizeof(struct sockaddr_in)); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 if (rc < 0) { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 perror("connect"); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 exit(1); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 } |
220
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
116 rc = write(tcpsock, bind_req, bind_req_len); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
117 if (rc != bind_req_len) { |
218
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 perror("write"); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 exit(1); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 static void |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 rx_bytes(buf, need_len) |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 u_char *buf; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 unsigned need_len; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 int cc; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 unsigned remain; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 for (remain = need_len; remain; remain -= cc) { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 cc = read(tcpsock, buf, remain); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 if (cc <= 0) { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 perror("read"); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 exit(1); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 static void |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 print_hdr() |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 int i, j, pos; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 fputs("Got header:", stdout); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 pos = 0; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 for (i = 0; i < 4; i++) { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 putchar(' '); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 for (j = 0; j < 4; j++) |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 printf("%02X", rx_hdr[pos++]); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 putchar('\n'); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 static void |
221
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
156 preen_rx_hdr() |
218
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 rx_pkt_len = (rx_hdr[0] << 24) | (rx_hdr[1] << 16) | (rx_hdr[2] << 8) | |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 rx_hdr[3]; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 printf("Rx packet length: %u bytes\n", rx_pkt_len); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 if (rx_pkt_len < 16) { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 printf("Error: packet length is too short\n"); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 exit(1); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 } |
221
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
165 rx_command_id = (rx_hdr[4] << 24) | (rx_hdr[5] << 16) | |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
166 (rx_hdr[6] << 8) | rx_hdr[7]; |
218
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 static void |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 read_and_dump_body() |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 u_char buf[16]; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 unsigned offset, chunk; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 int i, c; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 for (offset = 16; offset < rx_pkt_len; offset += chunk) { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 chunk = rx_pkt_len - offset; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 if (chunk > 16) |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 chunk = 16; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 rx_bytes(buf, chunk); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 printf("%08X: ", offset); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 for (i = 0; i < 16; i++) { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 if (i < chunk) |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 printf("%02X ", buf[i]); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 else |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 fputs(" ", stdout); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 if (i == 7 || i == 15) |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 putchar(' '); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 for (i = 0; i < chunk; i++) { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 c = buf[i]; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 if (c < ' ' || c > '~') |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 c = '.'; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 putchar(c); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 putchar('\n'); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 |
221
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
200 static void |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
201 resp_hdr_only() |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
202 { |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
203 u_char resp[16]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
204 int rc; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
205 |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
206 /* command_length */ |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
207 resp[0] = 0; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
208 resp[1] = 0; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
209 resp[2] = 0; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
210 resp[3] = 16; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
211 /* command_id */ |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
212 resp[4] = rx_hdr[4] | 0x80; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
213 resp[5] = rx_hdr[5]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
214 resp[6] = rx_hdr[6]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
215 resp[7] = rx_hdr[7]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
216 /* command_status */ |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
217 resp[8] = 0; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
218 resp[9] = 0; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
219 resp[10] = 0; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
220 resp[11] = 0; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
221 /* sequence_number */ |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
222 resp[12] = rx_hdr[12]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
223 resp[13] = rx_hdr[13]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
224 resp[14] = rx_hdr[14]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
225 resp[15] = rx_hdr[15]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
226 /* good to go */ |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
227 rc = write(tcpsock, resp, 16); |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
228 if (rc != 16) { |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
229 perror("write"); |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
230 exit(1); |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
231 } |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
232 } |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
233 |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
234 static void |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
235 resp_dummy_msgid() |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
236 { |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
237 u_char resp[17]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
238 int rc; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
239 |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
240 /* command_length */ |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
241 resp[0] = 0; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
242 resp[1] = 0; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
243 resp[2] = 0; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
244 resp[3] = 17; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
245 /* command_id */ |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
246 resp[4] = rx_hdr[4] | 0x80; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
247 resp[5] = rx_hdr[5]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
248 resp[6] = rx_hdr[6]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
249 resp[7] = rx_hdr[7]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
250 /* command_status */ |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
251 resp[8] = 0; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
252 resp[9] = 0; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
253 resp[10] = 0; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
254 resp[11] = 0; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
255 /* sequence_number */ |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
256 resp[12] = rx_hdr[12]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
257 resp[13] = rx_hdr[13]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
258 resp[14] = rx_hdr[14]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
259 resp[15] = rx_hdr[15]; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
260 /* empty message_id */ |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
261 resp[16] = 0; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
262 /* good to go */ |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
263 rc = write(tcpsock, resp, 17); |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
264 if (rc != 17) { |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
265 perror("write"); |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
266 exit(1); |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
267 } |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
268 } |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
269 |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
270 static void |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
271 auto_resp_logic() |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
272 { |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
273 switch (rx_command_id) { |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
274 case 0x005: |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
275 printf("Got deliver_sm, responding with deliver_sm_resp\n"); |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
276 resp_dummy_msgid(); |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
277 return; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
278 case 0x103: |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
279 printf("Got data_sm, responding with data_sm_resp\n"); |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
280 resp_dummy_msgid(); |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
281 return; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
282 case 0x015: |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
283 printf("Got enquire_link, responding with enquire_link_resp\n"); |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
284 resp_hdr_only(); |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
285 return; |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
286 } |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
287 } |
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
288 |
218
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 main(argc, argv) |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 char **argv; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 { |
220
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
292 if (argc < 3 || argc > 4) { |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
293 fprintf(stderr, "usage: %s server-ip system-id [password]\n", |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
294 argv[0]); |
218
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 exit(1); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 server_sin.sin_family = AF_INET; |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 server_sin.sin_addr.s_addr = inet_addr(argv[1]); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 if (server_sin.sin_addr.s_addr == INADDR_NONE) { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 fprintf(stderr, "error: invalid IP address argument \"%s\"\n", |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 argv[1]); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 exit(1); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 server_sin.sin_port = htons(2775); |
220
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
305 if (strlen(argv[2]) > 15) { |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
306 fprintf(stderr, "error: system-id string is too long\n"); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
307 exit(1); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
308 } |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
309 strcpy(system_id, argv[2]); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
310 if (argv[3]) { |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
311 if (strlen(argv[3]) > 8) { |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
312 fprintf(stderr, "error: password string is too long\n"); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
313 exit(1); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
314 } |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
315 strcpy(password, argv[3]); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
316 } |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
317 construct_bind_req(); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
318 setlinebuf(stdout); |
c798a1762c7c
smpp-test1: take strings on the command line, construct bind req
Mychaela Falconia <falcon@freecalypso.org>
parents:
219
diff
changeset
|
319 print_bind_req(); |
218
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 tcpsock = socket(AF_INET, SOCK_STREAM, 0); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 if (tcpsock < 0) { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 perror("socket"); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 exit(1); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 init_stage(); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 for (;;) { |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 rx_bytes(rx_hdr, 16); |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 print_hdr(); |
221
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
329 preen_rx_hdr(); |
218
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 read_and_dump_body(); |
221
e1d7db9d734c
smpp-test2 program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
331 auto_resp_logic(); |
218
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 } |
211a043a385f
smpp-test1 program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 } |