xrootd
XrdNetAddr.hh
Go to the documentation of this file.
1#ifndef __XRDNETADDR_HH__
2#define __XRDNETADDR_HH__
3/******************************************************************************/
4/* */
5/* X r d N e t A d d r . h h */
6/* */
7/* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* All Rights Reserved */
9/* Produced by Andrew Hanushevsky for Stanford University under contract */
10/* DE-AC02-76-SFO0515 with the Department of Energy */
11/* */
12/* This file is part of the XRootD software suite. */
13/* */
14/* XRootD is free software: you can redistribute it and/or modify it under */
15/* the terms of the GNU Lesser General Public License as published by the */
16/* Free Software Foundation, either version 3 of the License, or (at your */
17/* option) any later version. */
18/* */
19/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22/* License for more details. */
23/* */
24/* You should have received a copy of the GNU Lesser General Public License */
25/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27/* */
28/* The copyright holder's institutional names and contributor's names may not */
29/* be used to endorse or promote products derived from this software without */
30/* specific prior written permission of the institution or contributor. */
31/******************************************************************************/
32
34
35//------------------------------------------------------------------------------
37//------------------------------------------------------------------------------
38
39struct addrinfo;
40
42{
43public:
44
45//------------------------------------------------------------------------------
50//------------------------------------------------------------------------------
51
52static bool DynDNS() {return dynDNS;}
53
54//------------------------------------------------------------------------------
59//------------------------------------------------------------------------------
60
61static bool IPV4Set() {return useIPV4;}
62
63//------------------------------------------------------------------------------
71//------------------------------------------------------------------------------
72
73int Port(int pNum=-1);
74
75//------------------------------------------------------------------------------
97//------------------------------------------------------------------------------
98
99static const int PortInSpec = (int)0x80000000;
100
101const char *Set(const char *hSpec, int pNum=PortInSpec);
102
103//------------------------------------------------------------------------------
131//------------------------------------------------------------------------------
132
133const char *Set(const char *hSpec, int &numIP, int maxIP,
134 int pNum=PortInSpec, bool forUDP=false);
135
136//------------------------------------------------------------------------------
146//------------------------------------------------------------------------------
147
148const char *Set(const struct sockaddr *sockP, int sockFD=-1);
149
150//------------------------------------------------------------------------------
161//------------------------------------------------------------------------------
162
163const char *Set(int sockFD, bool peer=true);
164
165//------------------------------------------------------------------------------
175//------------------------------------------------------------------------------
176
177const char *Set(struct addrinfo *rP, int port, bool mapit=false);
178
179//------------------------------------------------------------------------------
182//------------------------------------------------------------------------------
183
184static void SetCache(int keeptime);
185
186//------------------------------------------------------------------------------
191//------------------------------------------------------------------------------
192
193static void SetDynDNS(bool onoff);
194
195//------------------------------------------------------------------------------
200//------------------------------------------------------------------------------
201
202static void SetIPV4();
203
204//------------------------------------------------------------------------------
210//------------------------------------------------------------------------------
211
212static void SetIPV6();
213
214//------------------------------------------------------------------------------
219//------------------------------------------------------------------------------
220
222
223//------------------------------------------------------------------------------
225//------------------------------------------------------------------------------
226
227//------------------------------------------------------------------------------
234//------------------------------------------------------------------------------
235
237
238 XrdNetAddr(const XrdNetAddr *addr) : XrdNetAddrInfo(addr) {}
239
240 XrdNetAddr(const sockaddr *addr) : XrdNetAddrInfo()
241 {Set(addr);}
242
243 XrdNetAddr(const sockaddr_in *addr) : XrdNetAddrInfo()
244 {Set((sockaddr *)addr);}
245
246 XrdNetAddr(const sockaddr_in6 *addr) : XrdNetAddrInfo()
247 {Set((sockaddr *)addr);}
248
249 XrdNetAddr(int port);
250
251//------------------------------------------------------------------------------
253//------------------------------------------------------------------------------
254
256private:
257static struct addrinfo *Hints(int htype, int stype);
258bool Map64();
259
260static struct addrinfo *hostHints;
261static struct addrinfo *huntHintsTCP;
262static struct addrinfo *huntHintsUDP;
263static bool useIPV4;
264static bool dynDNS;
265};
266#endif
Definition: XrdNetAddrInfo.hh:54
LocInfo addrLoc
Definition: XrdNetAddrInfo.hh:340
Definition: XrdNetAddr.hh:42
static bool useIPV4
Definition: XrdNetAddr.hh:263
~XrdNetAddr()
Destructor.
Definition: XrdNetAddr.hh:255
XrdNetAddr()
Assignment operator and copy constructor are inherited, no need to define.
Definition: XrdNetAddr.hh:236
const char * Set(struct addrinfo *rP, int port, bool mapit=false)
XrdNetAddr(const XrdNetAddr *addr)
Definition: XrdNetAddr.hh:238
static void SetIPV4()
bool Map64()
XrdNetAddr(int port)
XrdNetAddr(const sockaddr_in6 *addr)
Definition: XrdNetAddr.hh:246
static struct addrinfo * huntHintsUDP
Definition: XrdNetAddr.hh:262
static void SetIPV6()
XrdNetAddr(const sockaddr_in *addr)
Definition: XrdNetAddr.hh:243
void SetLocation(XrdNetAddrInfo::LocInfo &loc)
Definition: XrdNetAddr.hh:221
static bool DynDNS()
Definition: XrdNetAddr.hh:52
static void SetCache(int keeptime)
const char * Set(const struct sockaddr *sockP, int sockFD=-1)
static struct addrinfo * Hints(int htype, int stype)
const char * Set(int sockFD, bool peer=true)
const char * Set(const char *hSpec, int &numIP, int maxIP, int pNum=PortInSpec, bool forUDP=false)
int Port(int pNum=-1)
XrdNetAddr(const sockaddr *addr)
Definition: XrdNetAddr.hh:240
static struct addrinfo * huntHintsTCP
Definition: XrdNetAddr.hh:261
static bool IPV4Set()
Definition: XrdNetAddr.hh:61
static bool dynDNS
Definition: XrdNetAddr.hh:264
static void SetDynDNS(bool onoff)
static const int PortInSpec
Definition: XrdNetAddr.hh:99
const char * Set(const char *hSpec, int pNum=PortInSpec)
static struct addrinfo * hostHints
Definition: XrdNetAddr.hh:260
Definition: XrdNetAddrInfo.hh:176