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