Mention support for AMD/znver5 in GAS
[binutils-gdb.git] / gdbsupport / netstuff.h
blobf0df5fe76716d91317d582ff792040cd963dc800
1 /* Operations on network stuff.
2 Copyright (C) 2018-2024 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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/>. */
19 #ifndef COMMON_NETSTUFF_H
20 #define COMMON_NETSTUFF_H
22 #include <string>
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
28 /* Helper class to guarantee that we always call 'freeaddrinfo'. */
30 class scoped_free_addrinfo
32 public:
33 /* Default constructor. */
34 explicit scoped_free_addrinfo (struct addrinfo *ainfo)
35 : m_res (ainfo)
39 /* Destructor responsible for free'ing M_RES by calling
40 'freeaddrinfo'. */
41 ~scoped_free_addrinfo ();
43 DISABLE_COPY_AND_ASSIGN (scoped_free_addrinfo);
45 private:
46 /* The addrinfo resource. */
47 struct addrinfo *m_res;
50 /* The struct we return after parsing the connection spec. */
52 struct parsed_connection_spec
54 /* The hostname. */
55 std::string host_str;
57 /* The port, if any. */
58 std::string port_str;
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. */
65 extern parsed_connection_spec
66 parse_connection_spec_without_prefix (std::string spec,
67 struct addrinfo *hint);
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. */
73 extern parsed_connection_spec parse_connection_spec (const char *spec,
74 struct addrinfo *hint);
76 #endif /* COMMON_NETSTUFF_H */