FreeCalypso > hg > freecalypso-sw
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/lowlevel/clientcmd.c Sat Nov 23 22:15:16 2013 +0000 @@ -0,0 +1,61 @@ +/* + * This rvinterf module implements the handling of client commands. + */ + +#include <sys/types.h> +#include <stdio.h> +#include <string.h> +#include <strings.h> +#include <stdlib.h> +#include <unistd.h> +#include "../pktmux.h" +#include "../localsock.h" +#include "client.h" + +void +process_msg_from_client(cli) + struct client *cli; +{ + int c; + + switch (cli->rx_buf[0]) { + case CLI2RVI_WANT_RVTRACE: + if (cli->rx_msglen != 9) { + send_local_msg_to_client(cli, "-Bad command length"); + return; + } + c = cli->int_rvt_count; + if (c >= MAX_RVT_INTEREST) { + send_local_msg_to_client(cli, + "-Error: too many RVT interests"); + return; + } + cli->int_rvt_mask[c] = cli->rx_buf[1] << 24 | + cli->rx_buf[2] << 16 | + cli->rx_buf[3] << 8 | cli->rx_buf[4]; + cli->int_rvt_match[c] = cli->rx_buf[5] << 24 | + cli->rx_buf[6] << 16 | + cli->rx_buf[7] << 8 | cli->rx_buf[8]; + cli->int_rvt_count++; + send_local_msg_to_client(cli, "+OK"); + return; + case CLI2RVI_WANT_MUXPROTO: + if (cli->rx_msglen != 2) { + send_local_msg_to_client(cli, "-Bad command length"); + return; + } + if (cli->rx_buf[1] < 0x12 || cli->rx_buf[1] > 0x18) { + send_local_msg_to_client(cli, + "-Unsupported protocol MUX value"); + return; + } + cli->int_proto[cli->rx_buf[1] - 0x12] = 1; + send_local_msg_to_client(cli, "+OK"); + return; + case CLI2RVI_PKT_TO_TARGET: + case CLI2RVI_RAWBYTES_TO_TARGET: + /* To be implemented */ + default: + send_local_msg_to_client(cli, "-Unimplemented command"); + } +}