annotate rvinterf/lowlevel/rviftmode.c @ 934:0d6be90ae74f

rvinterf -v TM: send hex dump only to log file if we have one
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 23 May 2023 06:49:10 +0000
parents bd6dd6120180
children d203a9c7c4e6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
932
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module is for rvinterf only. Whenever we send or receive Test Mode
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * packets, we should be a little more intelligent about how we display and
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * log them. By default we only print a one-line summary, and in verbose mode
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * we also emit a full hex dump.
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 */
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <sys/types.h>
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdio.h>
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <string.h>
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <strings.h>
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 extern u_char rxpkt[];
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 extern size_t rxpkt_len;
934
0d6be90ae74f rvinterf -v TM: send hex dump only to log file if we have one
Mychaela Falconia <falcon@freecalypso.org>
parents: 933
diff changeset
15
932
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 extern int verbose;
934
0d6be90ae74f rvinterf -v TM: send hex dump only to log file if we have one
Mychaela Falconia <falcon@freecalypso.org>
parents: 933
diff changeset
17 extern FILE *logF;
932
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
934
0d6be90ae74f rvinterf -v TM: send hex dump only to log file if we have one
Mychaela Falconia <falcon@freecalypso.org>
parents: 933
diff changeset
19 static void
0d6be90ae74f rvinterf -v TM: send hex dump only to log file if we have one
Mychaela Falconia <falcon@freecalypso.org>
parents: 933
diff changeset
20 hexdump_out(line)
0d6be90ae74f rvinterf -v TM: send hex dump only to log file if we have one
Mychaela Falconia <falcon@freecalypso.org>
parents: 933
diff changeset
21 char *line;
0d6be90ae74f rvinterf -v TM: send hex dump only to log file if we have one
Mychaela Falconia <falcon@freecalypso.org>
parents: 933
diff changeset
22 {
0d6be90ae74f rvinterf -v TM: send hex dump only to log file if we have one
Mychaela Falconia <falcon@freecalypso.org>
parents: 933
diff changeset
23 if (logF)
0d6be90ae74f rvinterf -v TM: send hex dump only to log file if we have one
Mychaela Falconia <falcon@freecalypso.org>
parents: 933
diff changeset
24 fprintf(logF, "%s\n", line);
0d6be90ae74f rvinterf -v TM: send hex dump only to log file if we have one
Mychaela Falconia <falcon@freecalypso.org>
parents: 933
diff changeset
25 else
0d6be90ae74f rvinterf -v TM: send hex dump only to log file if we have one
Mychaela Falconia <falcon@freecalypso.org>
parents: 933
diff changeset
26 printf("%s\n", line);
0d6be90ae74f rvinterf -v TM: send hex dump only to log file if we have one
Mychaela Falconia <falcon@freecalypso.org>
parents: 933
diff changeset
27 }
932
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 void
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 log_sent_tm(pkt, pktlen)
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 u_char *pkt;
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 {
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 output_line("Sent Test Mode packet");
933
bd6dd6120180 rvinterf: -v enables TM hex dump, -vv enables TCH hex dump
Mychaela Falconia <falcon@freecalypso.org>
parents: 932
diff changeset
34 if (verbose >= 1)
934
0d6be90ae74f rvinterf -v TM: send hex dump only to log file if we have one
Mychaela Falconia <falcon@freecalypso.org>
parents: 933
diff changeset
35 packet_hex_dump(pkt, pktlen, hexdump_out);
932
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 }
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 void
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 print_tm_output_new()
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 {
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 output_line("Rx Test Mode packet");
933
bd6dd6120180 rvinterf: -v enables TM hex dump, -vv enables TCH hex dump
Mychaela Falconia <falcon@freecalypso.org>
parents: 932
diff changeset
42 if (verbose >= 1)
934
0d6be90ae74f rvinterf -v TM: send hex dump only to log file if we have one
Mychaela Falconia <falcon@freecalypso.org>
parents: 933
diff changeset
43 packet_hex_dump(rxpkt, (unsigned) rxpkt_len, hexdump_out);
932
3d1abb9f05ef rvinterf proper: move TM logging to new module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 }