/* Serial interface for raw TCP connections on Un*x like systems.
- Copyright (C) 1992-2018 Free Software Foundation, Inc.
+ Copyright (C) 1992-2022 Free Software Foundation, Inc.
This file is part of GDB.
#include "gdbcmd.h"
#include "cli/cli-decode.h"
#include "cli/cli-setshow.h"
-#include "filestuff.h"
-#include "netstuff.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/netstuff.h"
#include <sys/types.h>
#include <sys/ioctl.h> /* For FIONBIO. */
#endif
-#include "gdb_sys_time.h"
+#include "gdbsupport/gdb_sys_time.h"
#ifdef USE_WIN32API
-#include <winsock2.h>
-#include <wspiapi.h>
+#include <ws2tcpip.h>
#ifndef ETIMEDOUT
#define ETIMEDOUT WSAETIMEDOUT
#endif
#endif
#include <signal.h>
-#include "gdb_select.h"
+#include "gdbsupport/gdb_select.h"
#include <algorithm>
#ifndef HAVE_SOCKLEN_T
/* Whether to auto-retry refused connections. */
-static int tcp_auto_retry = 1;
+static bool tcp_auto_retry = true;
/* Timeout period for connections, in seconds. */
else
/* Use gdb_select here, since we have no file descriptors, and on
Windows, plain select doesn't work in that case. */
- n = gdb_select (0, NULL, NULL, NULL, &t);
+ n = interruptible_select (0, NULL, NULL, NULL, &t);
/* If we didn't time out, only count it as one poll. */
if (n > 0 || *polls < POLL_INTERVAL)
/* Flag to indicate whether we've got a connection refused. It will
be true if any of the connections tried was refused. */
bool got_connrefused;
- /* If a connection succeeeds, SUCCESS_AINFO will point to the
+ /* If a connection succeeds, SUCCESS_AINFO will point to the
'struct addrinfo' that succeed. */
struct addrinfo *success_ainfo = NULL;
unsigned int polls = 0;
{
got_connrefused = false;
- for (struct addrinfo *iter = ainfo; iter != NULL; iter = iter->ai_next)
+ for (addrinfo *iter = ainfo; iter != NULL; iter = iter->ai_next)
{
/* Iterate over the list of possible addresses to connect
to. For each, we'll try to connect and see if it
ioctl (scb->fd, FIONBIO, &ioarg);
- if (success_ainfo->ai_socktype == IPPROTO_TCP)
+ if (success_ainfo->ai_protocol == IPPROTO_TCP)
{
/* Disable Nagle algorithm. Needed in some cases. */
int tmp = 1;
return (serial_write (scb, "\377\363", 2));
}
-/* Support for "set tcp" and "show tcp" commands. */
-
-static void
-set_tcp_cmd (const char *args, int from_tty)
-{
- help_list (tcp_set_cmdlist, "set tcp ", all_commands, gdb_stdout);
-}
-
-static void
-show_tcp_cmd (const char *args, int from_tty)
-{
- help_list (tcp_show_cmdlist, "show tcp ", all_commands, gdb_stdout);
-}
-
#ifndef USE_WIN32API
/* The TCP ops. */
#endif /* USE_WIN32API */
+void _initialize_ser_tcp ();
void
-_initialize_ser_tcp (void)
+_initialize_ser_tcp ()
{
#ifdef USE_WIN32API
/* Do nothing; the TCP serial operations will be initialized in
serial_add_interface (&tcp_ops);
#endif /* USE_WIN32API */
- add_prefix_cmd ("tcp", class_maintenance, set_tcp_cmd, _("\
-TCP protocol specific variables\n\
-Configure variables specific to remote TCP connections"),
- &tcp_set_cmdlist, "set tcp ",
- 0 /* allow-unknown */, &setlist);
- add_prefix_cmd ("tcp", class_maintenance, show_tcp_cmd, _("\
-TCP protocol specific variables\n\
-Configure variables specific to remote TCP connections"),
- &tcp_show_cmdlist, "show tcp ",
- 0 /* allow-unknown */, &showlist);
+ add_setshow_prefix_cmd ("tcp", class_maintenance,
+ _("\
+TCP protocol specific variables.\n\
+Configure variables specific to remote TCP connections."),
+ _("\
+TCP protocol specific variables.\n\
+Configure variables specific to remote TCP connections."),
+ &tcp_set_cmdlist, &tcp_show_cmdlist,
+ &setlist, &showlist);
add_setshow_boolean_cmd ("auto-retry", class_obscure,
&tcp_auto_retry, _("\
-Set auto-retry on socket connect"), _("\
-Show auto-retry on socket connect"),
+Set auto-retry on socket connect."), _("\
+Show auto-retry on socket connect."),
NULL, NULL, NULL,
&tcp_set_cmdlist, &tcp_show_cmdlist);
add_setshow_uinteger_cmd ("connect-timeout", class_obscure,
&tcp_retry_limit, _("\
-Set timeout limit in seconds for socket connection"), _("\
-Show timeout limit in seconds for socket connection"), _("\
+Set timeout limit in seconds for socket connection."), _("\
+Show timeout limit in seconds for socket connection."), _("\
If set to \"unlimited\", GDB will keep attempting to establish a\n\
connection forever, unless interrupted with Ctrl-c.\n\
The default is 15 seconds."),