PERFORCE change 196496 for review
Catalin Nicutar
cnicutar at FreeBSD.org
Thu Jul 21 11:39:33 UTC 2011
http://p4web.freebsd.org/@@196496?ac=10
Change 196496 by cnicutar at cnicutar_cronos on 2011/07/21 11:38:33
Add UTO support to telnet command mode.
Affected files ...
.. //depot/projects/soc2011/cnicutar_tcputo_8/src/contrib/telnet/telnet/commands.c#3 edit
.. //depot/projects/soc2011/cnicutar_tcputo_8/src/contrib/telnet/telnet/externs.h#3 edit
.. //depot/projects/soc2011/cnicutar_tcputo_8/src/contrib/telnet/telnet/main.c#3 edit
Differences ...
==== //depot/projects/soc2011/cnicutar_tcputo_8/src/contrib/telnet/telnet/commands.c#3 (text+ko) ====
@@ -878,6 +878,7 @@
{ "escape", "character to escape back to telnet command mode", NULL, &escape },
{ "rlogin", "rlogin escape character", 0, &rlogin },
{ "tracefile", "file to write trace information to", SetNetTrace, (cc_t *)NetTraceFile},
+ { "timeout", "tcp timeout for this connection", set_timeout, NULL},
{ " ", "", NULL, NULL },
{ " ", "The following need 'localchars' to be toggled true", NULL, NULL },
{ "flushoutput", "character to cause an Abort Output", NULL, termFlushCharp },
@@ -920,6 +921,21 @@
}
}
+void
+set_timeout(char *s)
+{
+ if (s == NULL) {
+ uto = 0;
+ /* There is not way to "take it back". */
+ return;
+ }
+ /* Setting the timeout if net is a valid descriptor. */
+ uto = strtonum(s, 0, INT_MAX, NULL);
+ if (uto && net > 0 && setsockopt(net, IPPROTO_TCP, TCP_SNDUTO_TIMEOUT,
+ &uto, sizeof(uto)))
+ perror("setsockopt UTO");
+}
+
static int
setcmd(int argc, char *argv[])
{
@@ -977,7 +993,8 @@
return 0;
} else if (ct->handler) {
(*ct->handler)(argv[2]);
- printf("%s set to \"%s\".\n", ct->name, (char *)ct->charp);
+ if (ct->charp)
+ printf("%s set to \"%s\".\n", ct->name, (char *)ct->charp);
} else {
if (strcmp("off", argv[2])) {
value = special(argv[2]);
@@ -1043,7 +1060,8 @@
return 0;
} else if (ct->handler) {
(*ct->handler)(0);
- printf("%s reset to \"%s\".\n", ct->name, (char *)ct->charp);
+ if (ct->charp)
+ printf("%s reset to \"%s\".\n", ct->name, (char *)ct->charp);
} else {
*(ct->charp) = _POSIX_VDISABLE;
printf("%s character is '%s'.\n", ct->name, control(*(ct->charp)));
==== //depot/projects/soc2011/cnicutar_tcputo_8/src/contrib/telnet/telnet/externs.h#3 (text+ko) ====
@@ -261,6 +261,7 @@
setcommandmode(void),
set_escape_char(char *s),
setneturg(void),
+ set_timeout(char *s),
sys_telnet_init(void),
telnet(char *),
tel_enter_binary(int),
==== //depot/projects/soc2011/cnicutar_tcputo_8/src/contrib/telnet/telnet/main.c#3 (text+ko) ====
@@ -304,7 +304,10 @@
src_addr = optarg;
break;
case 't':
- uto = strtonum(optarg, 0, INT_MAX, NULL);
+ set_timeout(optarg);
+ if (!uto)
+ fprintf(stderr, "Warning: timeout `%s'"
+ " ignored\n", optarg);
break;
case 'u':
family = AF_UNIX;
More information about the p4-projects
mailing list