FreeCalypso > hg > freecalypso-tools
comparison rvinterf/lowlevel/clientcmd.c @ 0:e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 11 Jun 2016 00:13:35 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e7502631a0f9 |
---|---|
1 /* | |
2 * This rvinterf module implements the handling of client commands. | |
3 */ | |
4 | |
5 #include <sys/types.h> | |
6 #include <stdio.h> | |
7 #include <string.h> | |
8 #include <strings.h> | |
9 #include <stdlib.h> | |
10 #include <unistd.h> | |
11 #include "../include/pktmux.h" | |
12 #include "../include/limits.h" | |
13 #include "../include/localsock.h" | |
14 #include "client.h" | |
15 | |
16 void | |
17 process_msg_from_client(cli) | |
18 struct client *cli; | |
19 { | |
20 int c; | |
21 | |
22 switch (cli->rx_buf[0]) { | |
23 case CLI2RVI_WANT_RVTRACE: | |
24 if (cli->rx_msglen != 9) { | |
25 send_local_msg_to_client(cli, "-Bad command length"); | |
26 return; | |
27 } | |
28 c = cli->int_rvt_count; | |
29 if (c >= MAX_RVT_INTEREST) { | |
30 send_local_msg_to_client(cli, | |
31 "-Error: too many RVT interests"); | |
32 return; | |
33 } | |
34 cli->int_rvt_mask[c] = cli->rx_buf[1] << 24 | | |
35 cli->rx_buf[2] << 16 | | |
36 cli->rx_buf[3] << 8 | cli->rx_buf[4]; | |
37 cli->int_rvt_match[c] = cli->rx_buf[5] << 24 | | |
38 cli->rx_buf[6] << 16 | | |
39 cli->rx_buf[7] << 8 | cli->rx_buf[8]; | |
40 cli->int_rvt_count++; | |
41 send_local_msg_to_client(cli, "+OK"); | |
42 return; | |
43 case CLI2RVI_WANT_MUXPROTO: | |
44 if (cli->rx_msglen != 2) { | |
45 send_local_msg_to_client(cli, "-Bad command length"); | |
46 return; | |
47 } | |
48 if (cli->rx_buf[1] < 0x12 || cli->rx_buf[1] > 0x1D) { | |
49 send_local_msg_to_client(cli, | |
50 "-Unsupported protocol MUX value"); | |
51 return; | |
52 } | |
53 cli->int_proto[cli->rx_buf[1] - 0x12] = 1; | |
54 send_local_msg_to_client(cli, "+OK"); | |
55 return; | |
56 case CLI2RVI_DROP_MUXPROTO: | |
57 if (cli->rx_msglen != 2) { | |
58 send_local_msg_to_client(cli, "-Bad command length"); | |
59 return; | |
60 } | |
61 if (cli->rx_buf[1] < 0x12 || cli->rx_buf[1] > 0x1D) { | |
62 send_local_msg_to_client(cli, | |
63 "-Unsupported protocol MUX value"); | |
64 return; | |
65 } | |
66 cli->int_proto[cli->rx_buf[1] - 0x12] = 0; | |
67 send_local_msg_to_client(cli, "+OK"); | |
68 return; | |
69 case CLI2RVI_RESET_PACKET_RX: | |
70 cli->int_rvt_count = 0; | |
71 bzero(cli->int_proto, sizeof(cli->int_proto)); | |
72 send_local_msg_to_client(cli, "+OK"); | |
73 return; | |
74 case CLI2RVI_PKT_TO_TARGET: | |
75 c = cli->rx_msglen - 1; | |
76 if (c < 1 || c > MAX_PKT_TO_TARGET) { | |
77 send_local_msg_to_client(cli, | |
78 "-Invalid Tx packet length"); | |
79 return; | |
80 } | |
81 send_pkt_to_target(cli->rx_buf + 1, c); | |
82 log_sent_packet(cli->rx_buf + 1, c); | |
83 return; | |
84 case CLI2RVI_RAWBYTES_TO_TARGET: | |
85 /* To be implemented */ | |
86 default: | |
87 send_local_msg_to_client(cli, "-Unimplemented command"); | |
88 } | |
89 } |