annotate rvinterf/lowlevel/clientcmd.c @ 220:aa4ba71a1032

gsm-fw: FFS code hooked in, FFS-in-RAM config works on the Pirelli target
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 06 Jan 2014 20:50:33 +0000
parents ec040f521cc2
children 2f285f20d617
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
178
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This rvinterf module implements the handling of client commands.
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <string.h>
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <strings.h>
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <stdlib.h>
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <unistd.h>
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "../pktmux.h"
180
59ee5817b194 rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 178
diff changeset
12 #include "../limits.h"
178
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "../localsock.h"
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #include "client.h"
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 void
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 process_msg_from_client(cli)
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 struct client *cli;
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 {
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 int c;
185
ec040f521cc2 rvinterf works after fixing max_fd
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 180
diff changeset
21 char logmsg[128];
178
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 switch (cli->rx_buf[0]) {
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 case CLI2RVI_WANT_RVTRACE:
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 if (cli->rx_msglen != 9) {
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 send_local_msg_to_client(cli, "-Bad command length");
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 return;
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 }
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 c = cli->int_rvt_count;
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 if (c >= MAX_RVT_INTEREST) {
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 send_local_msg_to_client(cli,
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 "-Error: too many RVT interests");
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 return;
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 }
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 cli->int_rvt_mask[c] = cli->rx_buf[1] << 24 |
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 cli->rx_buf[2] << 16 |
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 cli->rx_buf[3] << 8 | cli->rx_buf[4];
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 cli->int_rvt_match[c] = cli->rx_buf[5] << 24 |
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 cli->rx_buf[6] << 16 |
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 cli->rx_buf[7] << 8 | cli->rx_buf[8];
185
ec040f521cc2 rvinterf works after fixing max_fd
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 180
diff changeset
41 sprintf(logmsg,
ec040f521cc2 rvinterf works after fixing max_fd
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 180
diff changeset
42 "*** Client program interested in RVT mask %08X match %08X",
ec040f521cc2 rvinterf works after fixing max_fd
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 180
diff changeset
43 cli->int_rvt_mask[c], cli->int_rvt_match[c]);
ec040f521cc2 rvinterf works after fixing max_fd
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 180
diff changeset
44 output_line(logmsg);
178
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 cli->int_rvt_count++;
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 send_local_msg_to_client(cli, "+OK");
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 return;
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 case CLI2RVI_WANT_MUXPROTO:
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 if (cli->rx_msglen != 2) {
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 send_local_msg_to_client(cli, "-Bad command length");
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 return;
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 }
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 if (cli->rx_buf[1] < 0x12 || cli->rx_buf[1] > 0x18) {
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 send_local_msg_to_client(cli,
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 "-Unsupported protocol MUX value");
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 return;
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 }
185
ec040f521cc2 rvinterf works after fixing max_fd
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 180
diff changeset
58 sprintf(logmsg,
ec040f521cc2 rvinterf works after fixing max_fd
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 180
diff changeset
59 "*** Client program interested in MUX proto %02X",
ec040f521cc2 rvinterf works after fixing max_fd
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 180
diff changeset
60 cli->rx_buf[1]);
ec040f521cc2 rvinterf works after fixing max_fd
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 180
diff changeset
61 output_line(logmsg);
178
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 cli->int_proto[cli->rx_buf[1] - 0x12] = 1;
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 send_local_msg_to_client(cli, "+OK");
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 return;
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 case CLI2RVI_PKT_TO_TARGET:
180
59ee5817b194 rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 178
diff changeset
66 c = cli->rx_msglen - 1;
59ee5817b194 rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 178
diff changeset
67 if (c < 1 || c > MAX_PKT_TO_TARGET) {
59ee5817b194 rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 178
diff changeset
68 send_local_msg_to_client(cli,
59ee5817b194 rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 178
diff changeset
69 "-Invalid Tx packet length");
59ee5817b194 rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 178
diff changeset
70 return;
59ee5817b194 rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 178
diff changeset
71 }
59ee5817b194 rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 178
diff changeset
72 send_pkt_to_target(cli->rx_buf + 1, c);
59ee5817b194 rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 178
diff changeset
73 log_sent_packet(cli->rx_buf + 1, c);
59ee5817b194 rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 178
diff changeset
74 return;
178
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 case CLI2RVI_RAWBYTES_TO_TARGET:
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 /* To be implemented */
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 default:
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 send_local_msg_to_client(cli, "-Unimplemented command");
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 }
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 }