annotate smpp-send/hexdump.c @ 223:f11c3e40c87a

new program smpp-send
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 05 Aug 2023 12:24:31 -0800
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
223
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements debug hex dump output of SMPP submit_sm PDUs
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * constructed by our smpp-send program.
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 void
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 hex_dump_output(pdu, pdulen)
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 u_char *pdu;
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 unsigned pdulen;
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 {
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 unsigned off, chunk;
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 int i, c;
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 printf("Constructed PDU of %u bytes:\n", pdulen);
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 for (off = 0; off < pdulen; off += chunk) {
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 printf("%04X: ", off);
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 chunk = pdulen - off;
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 if (chunk > 16)
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 chunk = 16;
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 for (i = 0; i < 16; i++) {
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 if (i < chunk)
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 printf("%02X ", pdu[off + i]);
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 else
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 fputs(" ", stdout);
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 if (i == 7 || i == 15)
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 putchar(' ');
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 for (i = 0; i < chunk; i++) {
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 c = pdu[off + i];
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 if (c < ' ' || c > '~')
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 c = '.';
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 putchar(c);
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 }
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 putchar('\n');
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 }
f11c3e40c87a new program smpp-send
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 }