FreeCalypso > hg > themwi-system-sw
annotate smpp-trx-sa/log.c @ 264:cdc807117841
*/Makefile: change INSTBIN to /opt/themwi/bin (was /usr/local/bin)
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 05 Nov 2023 16:07:14 -0800 |
parents | f1c024b2b835 |
children |
rev | line source |
---|---|
222
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements smpp-trx-sa log file output. |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <strings.h> |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <time.h> |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 extern FILE *logF; |
262
f1c024b2b835
smpp-trx-sa/log.c: additional cleanup
Mychaela Falconia <falcon@freecalypso.org>
parents:
261
diff
changeset
|
13 extern char fmt_time[]; |
222
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 extern int init_done; |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 void |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 log_fatal_error(cause) |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 char *cause; |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 { |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 if (!init_done) |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 return; |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 fprintf(logF, "\n%s %s\n", fmt_time, cause); |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 } |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 static void |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 pdu_hexdump(pdu, pdulen) |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 u_char *pdu; |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 unsigned pdulen; |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 { |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 unsigned off, chunk; |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 int i, c; |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 for (off = 0; off < pdulen; off += chunk) { |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 fprintf(logF, "%04X: ", off); |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 chunk = pdulen - off; |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 if (chunk > 16) |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 chunk = 16; |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 for (i = 0; i < 16; i++) { |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 if (i < chunk) |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 fprintf(logF, "%02X ", pdu[off + i]); |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 else |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 fputs(" ", logF); |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 if (i == 7 || i == 15) |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 putc(' ', logF); |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 } |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 for (i = 0; i < chunk; i++) { |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 c = pdu[off + i]; |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 if (c < ' ' || c > '~') |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 c = '.'; |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 putc(c, logF); |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 } |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 putc('\n', logF); |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 } |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 } |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 void |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 log_rx_pdu(pdu, pdulen) |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 u_char *pdu; |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 unsigned pdulen; |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 { |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 fprintf(logF, "\n%s Received PDU:\n", fmt_time); |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 pdu_hexdump(pdu, pdulen); |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 } |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 void |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 log_sent_pdu(pdu, pdulen) |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 u_char *pdu; |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 unsigned pdulen; |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 { |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 fprintf(logF, "\n%s Sent PDU:\n", fmt_time); |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 pdu_hexdump(pdu, pdulen); |
9d6e8d99d2b1
smpp-trx-sa: new program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 } |