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 
33 #include "XrdNet/XrdNetAddrInfo.hh"
34 
35 //------------------------------------------------------------------------------
37 //------------------------------------------------------------------------------
38 
39 struct addrinfo;
40 
41 class XrdNetAddr : public XrdNetAddrInfo
42 {
43 public:
44 
45 //------------------------------------------------------------------------------
50 //------------------------------------------------------------------------------
51 
52 static bool DynDNS() {return dynDNS;}
53 
54 //------------------------------------------------------------------------------
59 //------------------------------------------------------------------------------
60 
61 static bool IPV4Set() {return useIPV4;}
62 
63 //------------------------------------------------------------------------------
71 //------------------------------------------------------------------------------
72 
73 int Port(int pNum=-1);
74 
75 //------------------------------------------------------------------------------
97 //------------------------------------------------------------------------------
98 
99 static const int PortInSpec = (int)0x80000000;
100 
101 const char *Set(const char *hSpec, int pNum=PortInSpec);
102 
103 //------------------------------------------------------------------------------
131 //------------------------------------------------------------------------------
132 
133 const char *Set(const char *hSpec, int &numIP, int maxIP,
134  int pNum=PortInSpec, bool forUDP=false);
135 
136 //------------------------------------------------------------------------------
146 //------------------------------------------------------------------------------
147 
148 const char *Set(const struct sockaddr *sockP, int sockFD=-1);
149 
150 //------------------------------------------------------------------------------
161 //------------------------------------------------------------------------------
162 
163 const char *Set(int sockFD, bool peer=true);
164 
165 //------------------------------------------------------------------------------
175 //------------------------------------------------------------------------------
176 
177 const char *Set(struct addrinfo *rP, int port, bool mapit=false);
178 
179 //------------------------------------------------------------------------------
182 //------------------------------------------------------------------------------
183 
184 static void SetCache(int keeptime);
185 
186 //------------------------------------------------------------------------------
191 //------------------------------------------------------------------------------
192 
193 static void SetDynDNS(bool onoff);
194 
195 //------------------------------------------------------------------------------
200 //------------------------------------------------------------------------------
201 
202 static void SetIPV4();
203 
204 //------------------------------------------------------------------------------
210 //------------------------------------------------------------------------------
211 
212 static 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 
256 private:
257 static struct addrinfo *Hints(int htype, int stype);
258 bool Map64();
259 
260 static struct addrinfo *hostHints;
261 static struct addrinfo *huntHintsTCP;
262 static struct addrinfo *huntHintsUDP;
263 static bool useIPV4;
264 static bool dynDNS;
265 };
266 #endif
XrdNetAddr::SetIPV4
static void SetIPV4()
XrdNetAddr::Map64
bool Map64()
XrdNetAddr::IPV4Set
static bool IPV4Set()
Definition: XrdNetAddr.hh:61
XrdNetAddrInfo::LocInfo
Definition: XrdNetAddrInfo.hh:176
XrdNetAddr::SetIPV6
static void SetIPV6()
XrdNetAddr::SetLocation
void SetLocation(XrdNetAddrInfo::LocInfo &loc)
Definition: XrdNetAddr.hh:221
XrdNetAddr::SetDynDNS
static void SetDynDNS(bool onoff)
XrdNetAddrInfo
Definition: XrdNetAddrInfo.hh:54
XrdNetAddrInfo.hh
XrdNetAddr::Set
const char * Set(struct addrinfo *rP, int port, bool mapit=false)
XrdNetAddr::XrdNetAddr
XrdNetAddr(int port)
XrdNetAddr::Set
const char * Set(const char *hSpec, int &numIP, int maxIP, int pNum=PortInSpec, bool forUDP=false)
XrdNetAddr::XrdNetAddr
XrdNetAddr()
Assignment operator and copy constructor are inherited, no need to define.
Definition: XrdNetAddr.hh:236
XrdNetAddr::Set
const char * Set(int sockFD, bool peer=true)
XrdNetAddr::XrdNetAddr
XrdNetAddr(const sockaddr_in *addr)
Definition: XrdNetAddr.hh:243
XrdNetAddr::dynDNS
static bool dynDNS
Definition: XrdNetAddr.hh:264
XrdNetAddr::~XrdNetAddr
~XrdNetAddr()
Destructor.
Definition: XrdNetAddr.hh:255
XrdNetAddr::PortInSpec
static const int PortInSpec
Definition: XrdNetAddr.hh:99
XrdNetAddr::SetCache
static void SetCache(int keeptime)
XrdNetAddr::XrdNetAddr
XrdNetAddr(const sockaddr *addr)
Definition: XrdNetAddr.hh:240
XrdNetAddr::Hints
static struct addrinfo * Hints(int htype, int stype)
XrdNetAddr::useIPV4
static bool useIPV4
Definition: XrdNetAddr.hh:263
XrdNetAddr::huntHintsUDP
static struct addrinfo * huntHintsUDP
Definition: XrdNetAddr.hh:262
XrdNetAddrInfo::addrLoc
LocInfo addrLoc
Definition: XrdNetAddrInfo.hh:340
XrdNetAddr::Port
int Port(int pNum=-1)
XrdNetAddr::DynDNS
static bool DynDNS()
Definition: XrdNetAddr.hh:52
XrdNetAddr::huntHintsTCP
static struct addrinfo * huntHintsTCP
Definition: XrdNetAddr.hh:261
XrdNetAddr::XrdNetAddr
XrdNetAddr(const XrdNetAddr *addr)
Definition: XrdNetAddr.hh:238
XrdNetAddr::Set
const char * Set(const char *hSpec, int pNum=PortInSpec)
XrdNetAddr::hostHints
static struct addrinfo * hostHints
Definition: XrdNetAddr.hh:260
XrdNetAddr::XrdNetAddr
XrdNetAddr(const sockaddr_in6 *addr)
Definition: XrdNetAddr.hh:246
XrdNetAddr
Definition: XrdNetAddr.hh:42
XrdNetAddr::Set
const char * Set(const struct sockaddr *sockP, int sockFD=-1)