29 #include <sys/types.h> 31 #ifdef HAVE_SYS_FILIO_H 32 #include <sys/filio.h> 34 #ifdef HAVE_SYS_IOCTL_H 35 #include <sys/ioctl.h> 43 #define ETIMEDOUT WSAETIMEDOUT 49 #define close(fd) closesocket (fd) 50 #define ioctl ioctlsocket 52 #include <netinet/in.h> 53 #include <arpa/inet.h> 55 #include <sys/socket.h> 56 #include <netinet/tcp.h> 63 #ifndef HAVE_SOCKLEN_T 64 typedef int socklen_t;
82 #define POLL_INTERVAL 5 125 fd_set rset, wset, eset;
128 FD_SET (scb->
fd, &rset);
140 n = select (scb->
fd + 1, &rset, &wset, &eset, &t);
162 const char *port_str;
165 struct hostent *hostent;
166 struct sockaddr_in sockaddr;
172 unsigned int polls = 0;
183 port_str = strchr (
name,
':');
186 error (
_(
"net_open: No colon in host name!"));
189 tmp = std::min (port_str -
name, (ptrdiff_t)
sizeof hostname - 1);
190 strncpy (hostname,
name, tmp);
191 hostname[tmp] =
'\000';
192 port = atoi (port_str + 1);
196 strcpy (hostname,
"localhost");
198 hostent = gethostbyname (hostname);
206 sockaddr.sin_family = PF_INET;
207 sockaddr.sin_port = htons (port);
208 memcpy (&sockaddr.sin_addr.s_addr, hostent->h_addr,
209 sizeof (
struct in_addr));
223 ioctl (scb->
fd, FIONBIO, &ioarg);
227 n = connect (scb->
fd, (
struct sockaddr *) &sockaddr, sizeof (sockaddr));
232 int err = WSAGetLastError();
241 &&
err == WSAECONNREFUSED
243 &&
err == ECONNREFUSED
255 err != WSAEWOULDBLOCK
289 res = getsockopt (scb->
fd, SOL_SOCKET, SO_ERROR, (
char *) &
err, &len);
295 &&
err == WSAECONNREFUSED
297 &&
err == ECONNREFUSED
313 ioctl (scb->
fd, FIONBIO, &ioarg);
319 setsockopt (scb->
fd, IPPROTO_TCP, TCP_NODELAY,
320 (
char *)&tmp, sizeof (tmp));
326 signal (SIGPIPE, SIG_IGN);
348 return recv (scb->
fd, (
char *) scb->
buf, count, 0);
358 return send (scb->
fd, (
const char *) buf, count, 0);
424 TCP protocol specific variables\n\ 425 Configure variables specific to remote TCP connections"),
429 TCP protocol specific variables\n\ 430 Configure variables specific to remote TCP connections"),
436 Set auto-retry on socket connect"),
_(
"\ 437 Show auto-retry on socket connect"),
443 Set timeout limit in seconds for socket connection"),
_(
"\ 444 Show timeout limit in seconds for socket connection"),
_(
"\ 445 If set to \"unlimited\", GDB will keep attempting to establish a\n\ 446 connection forever, unless interrupted with Ctrl-c.\n\ 447 The default is 15 seconds."),
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t err
int ser_base_set_tty_state(struct serial *scb, serial_ttystate ttystate)
int ser_base_flush_output(struct serial *scb)
static const struct serial_ops tcp_ops
int net_write_prim(struct serial *scb, const void *buf, size_t count)
static int tcp_auto_retry
int serial_write(struct serial *scb, const void *buf, size_t count)
int ser_base_setbaudrate(struct serial *scb, int rate)
int gdb_socket_cloexec(int domain, int style, int protocol)
int ser_base_setstopbits(struct serial *scb, int num)
static unsigned int tcp_retry_limit
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
void ser_base_raw(struct serial *scb)
void ser_base_async(struct serial *scb, int async_p)
struct cmd_list_element * setlist
void add_setshow_uinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
int net_read_prim(struct serial *scb, size_t count)
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
struct cmd_list_element * showlist
static int startswith(const char *string, const char *pattern)
int gdb_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
static struct cmd_list_element * tcp_show_cmdlist
void _initialize_ser_tcp(void)
int ser_base_drain_output(struct serial *scb)
unsigned char buf[BUFSIZ]
static struct cmd_list_element * tcp_set_cmdlist
static int wait_for_connect(struct serial *scb, unsigned int *polls)
void ser_base_print_tty_state(struct serial *scb, serial_ttystate ttystate, struct ui_file *stream)
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
int ser_base_setparity(struct serial *scb, int parity)
void serial_add_interface(const struct serial_ops *optable)
int ser_base_flush_input(struct serial *scb)
int ser_base_readchar(struct serial *scb, int timeout)
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
int ser_base_write(struct serial *scb, const void *buf, size_t count)
static void show_tcp_cmd(const char *args, int from_tty)
void net_close(struct serial *scb)
int ser_tcp_send_break(struct serial *scb)
serial_ttystate ser_base_copy_tty_state(struct serial *scb, serial_ttystate ttystate)
void error(const char *fmt,...)
int(* deprecated_ui_loop_hook)(int signo)
serial_ttystate ser_base_get_tty_state(struct serial *scb)
static void set_tcp_cmd(const char *args, int from_tty)
int net_open(struct serial *scb, const char *name)