FreeCalypso > hg > freecalypso-sw
annotate rvinterf/lowlevel/rvifmain.c @ 187:f5f8776f7c66
rvinterf: added -s option for changing the local socket pathname
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 24 Nov 2013 23:25:59 +0000 |
parents | ebfa9657d03d |
children | cf8583923dc4 |
rev | line source |
---|---|
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
176
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
174
diff
changeset
|
2 * This module contains the main() function for rvinterf |
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <sys/errno.h> |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdio.h> |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <stdlib.h> |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <unistd.h> |
179
ebfa9657d03d
rvinterf: ignore SIGPIPE
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
178
diff
changeset
|
10 #include <signal.h> |
134
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
11 #include <time.h> |
174
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
12 #include "../pktmux.h" |
177
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
13 #include "../localsock.h" |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
14 #include "client.h" |
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 |
177
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
16 extern int target_fd, listener; |
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 extern char *baudrate_name; |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 |
174
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
19 extern u_char rxpkt[]; |
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
20 extern size_t rxpkt_len; |
133
56b53c289785
rvtdump: some restructuring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
127
diff
changeset
|
21 |
177
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
22 struct client *client_head; |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
23 |
134
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
24 char *logfname; |
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
25 FILE *logF; |
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
26 time_t logtime; |
174
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
27 int background; |
177
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
28 int max_fd; |
134
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
29 |
187
f5f8776f7c66
rvinterf: added -s option for changing the local socket pathname
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
179
diff
changeset
|
30 char *socket_pathname = "/tmp/rvinterf_socket"; |
f5f8776f7c66
rvinterf: added -s option for changing the local socket pathname
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
179
diff
changeset
|
31 |
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 main(argc, argv) |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 char **argv; |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 { |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 extern char *optarg; |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 extern int optind; |
174
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
37 int c; |
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 fd_set fds; |
177
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
39 struct client *cli, **clip; |
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 |
187
f5f8776f7c66
rvinterf: added -s option for changing the local socket pathname
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
179
diff
changeset
|
41 while ((c = getopt(argc, argv, "bB:d:l:s:")) != EOF) |
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 switch (c) { |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 case 'b': |
169
e01e3a60c858
rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
134
diff
changeset
|
44 background++; |
e01e3a60c858
rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
134
diff
changeset
|
45 continue; |
e01e3a60c858
rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
134
diff
changeset
|
46 case 'B': |
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 baudrate_name = optarg; |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 continue; |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 case 'd': |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 target_fd = atoi(optarg); |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 continue; |
134
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
52 case 'l': |
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
53 logfname = optarg; |
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
54 continue; |
187
f5f8776f7c66
rvinterf: added -s option for changing the local socket pathname
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
179
diff
changeset
|
55 case 's': |
f5f8776f7c66
rvinterf: added -s option for changing the local socket pathname
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
179
diff
changeset
|
56 socket_pathname = optarg; |
f5f8776f7c66
rvinterf: added -s option for changing the local socket pathname
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
179
diff
changeset
|
57 continue; |
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 case '?': |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 default: |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 usage: fprintf(stderr, |
174
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
61 "usage: %s [options] ttyport\n", argv[0]); |
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 exit(1); |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 } |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 if (target_fd <= 0) { |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 if (argc - optind != 1) |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 goto usage; |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 open_target_serial(argv[optind]); |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 } |
177
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
69 max_fd = target_fd; |
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 set_serial_nonblock(0); |
127
f4f0c8738dcb
rvtdump: satisfactory handling of output from Pirelli's fw
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
126
diff
changeset
|
72 setlinebuf(stdout); |
134
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
73 if (logfname) { |
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
74 logF = fopen(logfname, "w"); |
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
75 if (!logF) { |
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
76 perror(logfname); |
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
77 exit(1); |
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
78 } |
176
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
174
diff
changeset
|
79 fprintf(logF, "*** Log of rvinterf session ***\n"); |
134
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
80 setlinebuf(logF); |
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
81 } |
177
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
82 create_listener_socket(); |
169
e01e3a60c858
rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
134
diff
changeset
|
83 if (background) { |
e01e3a60c858
rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
134
diff
changeset
|
84 c = fork(); |
e01e3a60c858
rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
134
diff
changeset
|
85 if (c < 0) { |
e01e3a60c858
rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
134
diff
changeset
|
86 perror("fork"); |
e01e3a60c858
rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
134
diff
changeset
|
87 exit(1); |
e01e3a60c858
rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
134
diff
changeset
|
88 } |
e01e3a60c858
rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
134
diff
changeset
|
89 if (c) { |
176
7f727aaf5cd4
rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
174
diff
changeset
|
90 printf("rvinterf forked into background (pid %d)\n", c); |
169
e01e3a60c858
rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
134
diff
changeset
|
91 exit(0); |
e01e3a60c858
rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
134
diff
changeset
|
92 } |
e01e3a60c858
rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
134
diff
changeset
|
93 } |
179
ebfa9657d03d
rvinterf: ignore SIGPIPE
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
178
diff
changeset
|
94 signal(SIGPIPE, SIG_IGN); |
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 for (;;) { |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 FD_ZERO(&fds); |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 FD_SET(target_fd, &fds); |
177
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
98 FD_SET(listener, &fds); |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
99 for (clip = &client_head; cli = *clip; ) { |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
100 if (cli->rx_state == 2) { |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
101 close(cli->fd); |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
102 *clip = cli->next; |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
103 free(cli); |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
104 continue; |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
105 } |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
106 FD_SET(cli->fd, &fds); |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
107 clip = &cli->next; |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
108 } |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
109 c = select(max_fd+1, &fds, 0, 0, 0); |
134
e0d56e9be8a2
rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
110 time(&logtime); |
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 if (c < 0) { |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 if (errno == EINTR) |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 continue; |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 perror("select"); |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 exit(1); |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 } |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 if (FD_ISSET(target_fd, &fds)) |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 process_serial_rx(); |
177
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
119 if (FD_ISSET(listener, &fds)) |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
120 handle_listener_select(); |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
121 for (cli = client_head; cli; cli = cli->next) |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
122 if (FD_ISSET(cli->fd, &fds)) |
fef035264dd4
rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
176
diff
changeset
|
123 handle_client_select(cli); |
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 } |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 } |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 handle_rx_packet() |
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 { |
174
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
129 switch (rxpkt[0]) { |
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
130 case RVT_RV_HEADER: |
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
131 if (rxpkt_len < 6) |
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
132 goto unknown; |
178
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
133 if (!background || logF) |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
134 print_rv_trace(); |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
135 if (client_head) |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
136 forward_rv_trace(); |
174
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
137 return; |
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
138 case RVT_L1_HEADER: |
178
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
139 if (!background || logF) |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
140 print_l1_trace(); |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
141 if (client_head) |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
142 forward_nonrvt_pkt(); |
174
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
143 return; |
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
144 case RVT_L23_HEADER: |
178
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
145 if (!background || logF) |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
146 print_g23_trace(); |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
147 if (client_head) |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
148 forward_nonrvt_pkt(); |
174
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
149 return; |
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
150 case RVT_TM_HEADER: |
178
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
151 if (!background || logF) |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
152 print_etm_output_raw(); |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
153 if (client_head) |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
177
diff
changeset
|
154 forward_nonrvt_pkt(); |
174
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
155 return; |
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
156 default: |
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
157 unknown: |
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
158 print_unknown_packet(); |
3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
173
diff
changeset
|
159 } |
126
811b138f1bed
rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
160 } |