comparison rvinterf/lowlevel/clientcmd.c @ 178:7ab6b29e76bb

rvinterf: forwarding of Rx packets to clients implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 23 Nov 2013 22:15:16 +0000
parents
children 59ee5817b194
comparison
equal deleted inserted replaced
177:fef035264dd4 178:7ab6b29e76bb
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 "../pktmux.h"
12 #include "../localsock.h"
13 #include "client.h"
14
15 void
16 process_msg_from_client(cli)
17 struct client *cli;
18 {
19 int c;
20
21 switch (cli->rx_buf[0]) {
22 case CLI2RVI_WANT_RVTRACE:
23 if (cli->rx_msglen != 9) {
24 send_local_msg_to_client(cli, "-Bad command length");
25 return;
26 }
27 c = cli->int_rvt_count;
28 if (c >= MAX_RVT_INTEREST) {
29 send_local_msg_to_client(cli,
30 "-Error: too many RVT interests");
31 return;
32 }
33 cli->int_rvt_mask[c] = cli->rx_buf[1] << 24 |
34 cli->rx_buf[2] << 16 |
35 cli->rx_buf[3] << 8 | cli->rx_buf[4];
36 cli->int_rvt_match[c] = cli->rx_buf[5] << 24 |
37 cli->rx_buf[6] << 16 |
38 cli->rx_buf[7] << 8 | cli->rx_buf[8];
39 cli->int_rvt_count++;
40 send_local_msg_to_client(cli, "+OK");
41 return;
42 case CLI2RVI_WANT_MUXPROTO:
43 if (cli->rx_msglen != 2) {
44 send_local_msg_to_client(cli, "-Bad command length");
45 return;
46 }
47 if (cli->rx_buf[1] < 0x12 || cli->rx_buf[1] > 0x18) {
48 send_local_msg_to_client(cli,
49 "-Unsupported protocol MUX value");
50 return;
51 }
52 cli->int_proto[cli->rx_buf[1] - 0x12] = 1;
53 send_local_msg_to_client(cli, "+OK");
54 return;
55 case CLI2RVI_PKT_TO_TARGET:
56 case CLI2RVI_RAWBYTES_TO_TARGET:
57 /* To be implemented */
58 default:
59 send_local_msg_to_client(cli, "-Unimplemented command");
60 }
61 }