gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdbsupport / netstuff.h
CommitLineData
c7ab0aef 1/* Operations on network stuff.
b811d2c2 2 Copyright (C) 2018-2020 Free Software Foundation, Inc.
c7ab0aef
SDJ
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
1a5c2598
TT
19#ifndef COMMON_NETSTUFF_H
20#define COMMON_NETSTUFF_H
c7ab0aef
SDJ
21
22#include <string>
23
24/* Like NI_MAXHOST/NI_MAXSERV, but enough for numeric forms. */
25#define GDB_NI_MAX_ADDR 64
26#define GDB_NI_MAX_PORT 16
27
28/* Helper class to guarantee that we always call 'freeaddrinfo'. */
29
30class scoped_free_addrinfo
31{
32public:
33 /* Default constructor. */
34 explicit scoped_free_addrinfo (struct addrinfo *ainfo)
35 : m_res (ainfo)
36 {
37 }
38
39 /* Destructor responsible for free'ing M_RES by calling
40 'freeaddrinfo'. */
41 ~scoped_free_addrinfo ();
42
43 DISABLE_COPY_AND_ASSIGN (scoped_free_addrinfo);
44
45private:
46 /* The addrinfo resource. */
47 struct addrinfo *m_res;
48};
49
50/* The struct we return after parsing the connection spec. */
51
52struct parsed_connection_spec
53{
54 /* The hostname. */
55 std::string host_str;
56
57 /* The port, if any. */
58 std::string port_str;
59};
60
61
62/* Parse SPEC (which is a string in the form of "ADDR:PORT") and
63 return a 'parsed_connection_spec' structure with the proper fields
64 filled in. Also adjust HINT accordingly. */
65extern parsed_connection_spec
66 parse_connection_spec_without_prefix (std::string spec,
67 struct addrinfo *hint);
68
69/* Parse SPEC (which is a string in the form of
70 "[tcp[6]:|udp[6]:]ADDR:PORT") and return a 'parsed_connection_spec'
71 structure with the proper fields filled in. Also adjust HINT
72 accordingly. */
73extern parsed_connection_spec parse_connection_spec (const char *spec,
74 struct addrinfo *hint);
75
1a5c2598 76#endif /* COMMON_NETSTUFF_H */
This page took 0.165235 seconds and 4 git commands to generate.