FreeCalypso > hg > freecalypso-sw
annotate rvinterf/lowlevel/clientcmd.c @ 1034:405b5469abc4 default tip
top README: repository change notice
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 12 Jun 2016 19:06:34 +0000 |
parents | 5f919af515f1 |
children |
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> |
256
2f285f20d617
rvinterf: *.h moved into include subdir
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
185
diff
changeset
|
11 #include "../include/pktmux.h" |
2f285f20d617
rvinterf: *.h moved into include subdir
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
185
diff
changeset
|
12 #include "../include/limits.h" |
2f285f20d617
rvinterf: *.h moved into include subdir
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
185
diff
changeset
|
13 #include "../include/localsock.h" |
178
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; |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 switch (cli->rx_buf[0]) { |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 case CLI2RVI_WANT_RVTRACE: |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 if (cli->rx_msglen != 9) { |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 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
|
26 return; |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 } |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 c = cli->int_rvt_count; |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 if (c >= MAX_RVT_INTEREST) { |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 send_local_msg_to_client(cli, |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 "-Error: too many RVT interests"); |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 return; |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 } |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 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
|
35 cli->rx_buf[2] << 16 | |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 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
|
37 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
|
38 cli->rx_buf[6] << 16 | |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 cli->rx_buf[7] << 8 | cli->rx_buf[8]; |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 cli->int_rvt_count++; |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 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
|
42 return; |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 case CLI2RVI_WANT_MUXPROTO: |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 if (cli->rx_msglen != 2) { |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 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
|
46 return; |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 } |
1008
5f919af515f1
rvinterf: beginning of support for new TCH and KEEPALIVE RVTMUX channels
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
871
diff
changeset
|
48 if (cli->rx_buf[1] < 0x12 || cli->rx_buf[1] > 0x1D) { |
178
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 send_local_msg_to_client(cli, |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 "-Unsupported protocol MUX value"); |
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 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
|
54 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
|
55 return; |
871
a5c8f48003cd
rvinterf: client programs can now selectively stop receiving packets of a
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
870
diff
changeset
|
56 case CLI2RVI_DROP_MUXPROTO: |
a5c8f48003cd
rvinterf: client programs can now selectively stop receiving packets of a
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
870
diff
changeset
|
57 if (cli->rx_msglen != 2) { |
a5c8f48003cd
rvinterf: client programs can now selectively stop receiving packets of a
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
870
diff
changeset
|
58 send_local_msg_to_client(cli, "-Bad command length"); |
a5c8f48003cd
rvinterf: client programs can now selectively stop receiving packets of a
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
870
diff
changeset
|
59 return; |
a5c8f48003cd
rvinterf: client programs can now selectively stop receiving packets of a
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
870
diff
changeset
|
60 } |
1008
5f919af515f1
rvinterf: beginning of support for new TCH and KEEPALIVE RVTMUX channels
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
871
diff
changeset
|
61 if (cli->rx_buf[1] < 0x12 || cli->rx_buf[1] > 0x1D) { |
871
a5c8f48003cd
rvinterf: client programs can now selectively stop receiving packets of a
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
870
diff
changeset
|
62 send_local_msg_to_client(cli, |
a5c8f48003cd
rvinterf: client programs can now selectively stop receiving packets of a
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
870
diff
changeset
|
63 "-Unsupported protocol MUX value"); |
a5c8f48003cd
rvinterf: client programs can now selectively stop receiving packets of a
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
870
diff
changeset
|
64 return; |
a5c8f48003cd
rvinterf: client programs can now selectively stop receiving packets of a
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
870
diff
changeset
|
65 } |
a5c8f48003cd
rvinterf: client programs can now selectively stop receiving packets of a
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
870
diff
changeset
|
66 cli->int_proto[cli->rx_buf[1] - 0x12] = 0; |
a5c8f48003cd
rvinterf: client programs can now selectively stop receiving packets of a
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
870
diff
changeset
|
67 send_local_msg_to_client(cli, "+OK"); |
a5c8f48003cd
rvinterf: client programs can now selectively stop receiving packets of a
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
870
diff
changeset
|
68 return; |
266
cb833ff54d88
rvinterf: CLI2RVI_RESET_PACKET_RX command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
256
diff
changeset
|
69 case CLI2RVI_RESET_PACKET_RX: |
cb833ff54d88
rvinterf: CLI2RVI_RESET_PACKET_RX command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
256
diff
changeset
|
70 cli->int_rvt_count = 0; |
cb833ff54d88
rvinterf: CLI2RVI_RESET_PACKET_RX command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
256
diff
changeset
|
71 bzero(cli->int_proto, sizeof(cli->int_proto)); |
cb833ff54d88
rvinterf: CLI2RVI_RESET_PACKET_RX command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
256
diff
changeset
|
72 send_local_msg_to_client(cli, "+OK"); |
cb833ff54d88
rvinterf: CLI2RVI_RESET_PACKET_RX command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
256
diff
changeset
|
73 return; |
178
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 case CLI2RVI_PKT_TO_TARGET: |
180
59ee5817b194
rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
178
diff
changeset
|
75 c = cli->rx_msglen - 1; |
59ee5817b194
rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
178
diff
changeset
|
76 if (c < 1 || c > MAX_PKT_TO_TARGET) { |
59ee5817b194
rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
178
diff
changeset
|
77 send_local_msg_to_client(cli, |
59ee5817b194
rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
178
diff
changeset
|
78 "-Invalid Tx packet length"); |
59ee5817b194
rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
178
diff
changeset
|
79 return; |
59ee5817b194
rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
178
diff
changeset
|
80 } |
59ee5817b194
rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
178
diff
changeset
|
81 send_pkt_to_target(cli->rx_buf + 1, c); |
59ee5817b194
rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
178
diff
changeset
|
82 log_sent_packet(cli->rx_buf + 1, c); |
59ee5817b194
rvinterf: packet sending implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
178
diff
changeset
|
83 return; |
178
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 case CLI2RVI_RAWBYTES_TO_TARGET: |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 /* To be implemented */ |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 default: |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 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
|
88 } |
7ab6b29e76bb
rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 } |