FreeCalypso > hg > freecalypso-tools
comparison rvinterf/asyncshell/rxctl.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 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 tch_rx_control(newstate) | |
| 49 { | |
| 50 static int state = 0; | |
| 51 | |
| 52 if (state == newstate) | |
| 53 return; | |
| 54 send_rxctl_cmd(RVT_TCH_HEADER, newstate); | |
| 55 state = newstate; | |
| 56 } | |
| 57 | |
| 58 void | |
| 59 rxctl_user_cmd(args, enable) | |
| 60 char *args; | |
| 61 { | |
| 62 char *cp, *np; | |
| 63 int gotsome = 0; | |
| 64 | |
| 65 for (cp = args; ; ) { | |
| 66 while (isspace(*cp)) | |
| 67 cp++; | |
| 68 if (!*cp) { | |
| 69 if (!gotsome) | |
| 70 printf("error: argument required\n"); | |
| 71 return; | |
| 72 } | |
| 73 for (np = cp; *cp && !isspace(*cp); cp++) | |
| 74 ; | |
| 75 if (*cp) | |
| 76 *cp++ = '\0'; | |
| 77 if (!strcmp(np, "ati")) | |
| 78 ati_rx_control(enable); | |
| 79 else if (!strcmp(np, "gpf")) | |
| 80 gpf_rx_control(enable); | |
| 81 else if (!strcmp(np, "tch")) | |
| 82 tch_rx_control(enable); | |
| 83 else { | |
| 84 printf("error: unknown channel \"%s\"\n", np); | |
| 85 return; | |
| 86 } | |
| 87 gotsome++; | |
| 88 } | |
| 89 } | |
| 90 | |
| 91 void | |
| 92 cmd_enable(args) | |
| 93 char *args; | |
| 94 { | |
| 95 rxctl_user_cmd(args, 1); | |
| 96 } | |
| 97 | |
| 98 void | |
| 99 cmd_disable(args) | |
| 100 char *args; | |
| 101 { | |
| 102 rxctl_user_cmd(args, 0); | |
| 103 } |
