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 //------------------------------------------------------------------------------
84 //------------------------------------------------------------------------------
85 
86 bool Register(const char *hName);
87 
88 //------------------------------------------------------------------------------
110 //------------------------------------------------------------------------------
111 
112 static const int PortInSpec = (int)0x80000000;
113 
114 const char *Set(const char *hSpec, int pNum=PortInSpec);
115 
116 //------------------------------------------------------------------------------
144 //------------------------------------------------------------------------------
145 
146 const char *Set(const char *hSpec, int &numIP, int maxIP,
147  int pNum=PortInSpec, bool forUDP=false);
148 
149 //------------------------------------------------------------------------------
159 //------------------------------------------------------------------------------
160 
161 const char *Set(const struct sockaddr *sockP, int sockFD=-1);
162 
163 //------------------------------------------------------------------------------
174 //------------------------------------------------------------------------------
175 
176 const char *Set(int sockFD, bool peer=true);
177 
178 //------------------------------------------------------------------------------
188 //------------------------------------------------------------------------------
189 
190 const char *Set(struct addrinfo *rP, int port, bool mapit=false);
191 
192 //------------------------------------------------------------------------------
195 //------------------------------------------------------------------------------
196 
197 static void SetCache(int keeptime);
198 
199 //------------------------------------------------------------------------------
203 //------------------------------------------------------------------------------
204 
205  void SetDialect(const char *dP) {protName = dP;}
206 
207 //------------------------------------------------------------------------------
212 //------------------------------------------------------------------------------
213 
214 static void SetDynDNS(bool onoff);
215 
216 //------------------------------------------------------------------------------
221 //------------------------------------------------------------------------------
222 
223 static void SetIPV4();
224 
225 //------------------------------------------------------------------------------
231 //------------------------------------------------------------------------------
232 
233 static void SetIPV6();
234 
235 //------------------------------------------------------------------------------
240 //------------------------------------------------------------------------------
241 
243 
244 //------------------------------------------------------------------------------
248 //------------------------------------------------------------------------------
249 
250 void SetTLS(bool val);
251 
252 //------------------------------------------------------------------------------
254 //------------------------------------------------------------------------------
255 
256 //------------------------------------------------------------------------------
263 //------------------------------------------------------------------------------
264 
266 
267  XrdNetAddr(const XrdNetAddr *addr) : XrdNetAddrInfo(addr) {}
268 
269  XrdNetAddr(const sockaddr *addr) : XrdNetAddrInfo()
270  {Set(addr);}
271 
272  XrdNetAddr(const sockaddr_in *addr) : XrdNetAddrInfo()
273  {Set((sockaddr *)addr);}
274 
275  XrdNetAddr(const sockaddr_in6 *addr) : XrdNetAddrInfo()
276  {Set((sockaddr *)addr);}
277 
278  XrdNetAddr(int port);
279 
280 //------------------------------------------------------------------------------
282 //------------------------------------------------------------------------------
283 
285 private:
286 static struct addrinfo *Hints(int htype, int stype);
287 bool Map64();
288 
289 static struct addrinfo *hostHints;
290 static struct addrinfo *huntHintsTCP;
291 static struct addrinfo *huntHintsUDP;
292 static bool useIPV4;
293 static bool dynDNS;
294 };
295 #endif
static bool dynDNS
Definition: XrdNetAddr.hh:293
static struct addrinfo * huntHintsTCP
Definition: XrdNetAddr.hh:290
static const int PortInSpec
Definition: XrdNetAddr.hh:112
static bool useIPV4
Definition: XrdNetAddr.hh:292
static struct addrinfo * huntHintsUDP
Definition: XrdNetAddr.hh:291
XrdNetAddr(const sockaddr *addr)
Definition: XrdNetAddr.hh:269
void SetDialect(const char *dP)
Definition: XrdNetAddr.hh:205
static struct addrinfo * hostHints
Definition: XrdNetAddr.hh:289
const char * Set(const char *hSpec, int pNum=PortInSpec)
XrdNetAddr(const sockaddr_in6 *addr)
Definition: XrdNetAddr.hh:275
static struct addrinfo * Hints(int htype, int stype)
Definition: XrdNetAddr.hh:41
static bool DynDNS()
Definition: XrdNetAddr.hh:52
bool Map64()
XrdNetAddr(const XrdNetAddr *addr)
Definition: XrdNetAddr.hh:267
static bool IPV4Set()
Definition: XrdNetAddr.hh:61
static void SetIPV4()
Definition: XrdNetAddrInfo.hh:194
static void SetDynDNS(bool onoff)
Definition: XrdNetAddrInfo.hh:53
const char * protName
Definition: XrdNetAddrInfo.hh:369
void SetTLS(bool val)
static void SetIPV6()
void SetLocation(XrdNetAddrInfo::LocInfo &loc)
XrdNetAddr()
Assignment operator and copy constructor are inherited, no need to define.
Definition: XrdNetAddr.hh:265
XrdNetAddr(const sockaddr_in *addr)
Definition: XrdNetAddr.hh:272
~XrdNetAddr()
Destructor.
Definition: XrdNetAddr.hh:284
static void SetCache(int keeptime)
bool Register(const char *hName)