nvtsrv: Optionally echo all input from client
This commit is contained in:
+13
-2
@@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -14,7 +15,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define HELP \
|
#define HELP \
|
||||||
"Usage: nvtsrv -dq\n"
|
"Usage: nvtsrv -deq\n"
|
||||||
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@@ -116,10 +117,12 @@ int main(int argc, char **argv)
|
|||||||
char buf[128];
|
char buf[128];
|
||||||
int rc, nr, i, len;
|
int rc, nr, i, len;
|
||||||
int debug, quiet;
|
int debug, quiet;
|
||||||
|
bool do_echo;
|
||||||
|
|
||||||
debug = quiet = 0;
|
debug = quiet = 0;
|
||||||
|
do_echo = false;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "dq")) != -1)
|
while ((opt = getopt(argc, argv, "deq")) != -1)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
{
|
{
|
||||||
@@ -129,6 +132,9 @@ int main(int argc, char **argv)
|
|||||||
case 'd':
|
case 'd':
|
||||||
debug += 1;
|
debug += 1;
|
||||||
break;
|
break;
|
||||||
|
case 'e': /* Echo received data */
|
||||||
|
do_echo = true;
|
||||||
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
quiet = 1;
|
quiet = 1;
|
||||||
break;
|
break;
|
||||||
@@ -205,6 +211,11 @@ int main(int argc, char **argv)
|
|||||||
DBG2_BUF("Rx", buf, nr);
|
DBG2_BUF("Rx", buf, nr);
|
||||||
len = nr;
|
len = nr;
|
||||||
rc = telnet_rx(dd.tnct, buf, &len);
|
rc = telnet_rx(dd.tnct, buf, &len);
|
||||||
|
if (do_echo)
|
||||||
|
{
|
||||||
|
/* Echo received */
|
||||||
|
_tn_tx(NULL, buf, len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user