FreeCalypso > hg > freecalypso-sw
comparison rvinterf/asyncshell/rxctl.c @ 874:72d64c172d85
fc-shell: Rx control implemented
| author | Space Falcon <falcon@ivan.Harhan.ORG> |
|---|---|
| date | Sat, 30 May 2015 07:20:50 +0000 |
| parents | |
| children | c9f353b5d70c |
comparison
equal
deleted
inserted
replaced
| 873:3be5a1b4c91a | 874:72d64c172d85 |
|---|---|
| 1 /* | |
| 2 * This module contains the code for enabling and disabling the receiving | |
| 3 * of various packet types via rvinterf. | |
| 4 */ | |
| 5 | |
| 6 #include <sys/types.h> | |
| 7 #include <stdio.h> | |
| 8 #include <ctype.h> | |
| 9 #include <string.h> | |
| 10 #include <strings.h> | |
| 11 #include <stdlib.h> | |
| 12 #include "pktmux.h" | |
| 13 #include "localsock.h" | |
| 14 | |
| 15 void | |
| 16 send_rxctl_cmd(channel, enable) | |
| 17 { | |
| 18 u_char cmdbuf[2]; | |
| 19 | |
| 20 cmdbuf[0] = enable ? CLI2RVI_WANT_MUXPROTO : CLI2RVI_DROP_MUXPROTO; | |
| 21 cmdbuf[1] = channel; | |
| 22 send_init_command(cmdbuf, 2); | |
| 23 } | |
| 24 | |
| 25 void | |
| 26 ati_rx_control(newstate) | |
| 27 { | |
| 28 static int state = 0; | |
| 29 | |
| 30 if (state == newstate) | |
| 31 return; | |
| 32 send_rxctl_cmd(RVT_AT_HEADER, newstate); | |
| 33 state = newstate; | |
| 34 } | |
| 35 | |
| 36 void | |
| 37 gpf_rx_control(newstate) | |
| 38 { | |
| 39 static int state = 0; | |
| 40 | |
| 41 if (state == newstate) | |
| 42 return; | |
| 43 send_rxctl_cmd(RVT_L23_HEADER, newstate); | |
| 44 state = newstate; | |
| 45 } | |
| 46 | |
| 47 void | |
| 48 rxctl_user_cmd(args, enable) | |
| 49 char *args; | |
| 50 { | |
| 51 char *cp, *np; | |
| 52 int gotsome = 0; | |
| 53 | |
| 54 for (cp = args; ; ) { | |
| 55 while (isspace(*cp)) | |
| 56 cp++; | |
| 57 if (!*cp) { | |
| 58 if (!gotsome) | |
| 59 printf("error: argument required\n"); | |
| 60 return; | |
| 61 } | |
| 62 for (np = cp; *cp && !isspace(*cp); cp++) | |
| 63 ; | |
| 64 if (*cp) | |
| 65 *cp++ = '\0'; | |
| 66 if (!strcmp(np, "ati")) | |
| 67 ati_rx_control(enable); | |
| 68 else if (!strcmp(np, "gpf")) | |
| 69 gpf_rx_control(enable); | |
| 70 else { | |
| 71 printf("error: unknown channel \"%s\"\n", np); | |
| 72 return; | |
| 73 } | |
| 74 } | |
| 75 } | |
| 76 | |
| 77 void | |
| 78 cmd_enable(args) | |
| 79 char *args; | |
| 80 { | |
| 81 rxctl_user_cmd(args, 1); | |
| 82 } | |
| 83 | |
| 84 void | |
| 85 cmd_disable(args) | |
| 86 char *args; | |
| 87 { | |
| 88 rxctl_user_cmd(args, 0); | |
| 89 } |
