xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 IPV4Set() {return useIPV4;}
53 
54 //------------------------------------------------------------------------------
62 //------------------------------------------------------------------------------
63 
64 int Port(int pNum=-1);
65 
66 //------------------------------------------------------------------------------
88 //------------------------------------------------------------------------------
89 
90 static const int PortInSpec = (int)0x80000000;
91 
92 const char *Set(const char *hSpec, int pNum=PortInSpec);
93 
94 //------------------------------------------------------------------------------
122 //------------------------------------------------------------------------------
123 
124 const char *Set(const char *hSpec, int &numIP, int maxIP,
125  int pNum=PortInSpec, bool forUDP=false);
126 
127 //------------------------------------------------------------------------------
137 //------------------------------------------------------------------------------
138 
139 const char *Set(const struct sockaddr *sockP, int sockFD=-1);
140 
141 //------------------------------------------------------------------------------
152 //------------------------------------------------------------------------------
153 
154 const char *Set(int sockFD, bool peer=true);
155 
156 //------------------------------------------------------------------------------
166 //------------------------------------------------------------------------------
167 
168 const char *Set(struct addrinfo *rP, int port, bool mapit=false);
169 
170 //------------------------------------------------------------------------------
173 //------------------------------------------------------------------------------
174 
175 static void SetCache(int keeptime);
176 
177 //------------------------------------------------------------------------------
182 //------------------------------------------------------------------------------
183 
184 static void SetIPV4();
185 
186 //------------------------------------------------------------------------------
192 //------------------------------------------------------------------------------
193 
194 static void SetIPV6();
195 
196 //------------------------------------------------------------------------------
201 //------------------------------------------------------------------------------
202 
204 
205 //------------------------------------------------------------------------------
207 //------------------------------------------------------------------------------
208 
209 //------------------------------------------------------------------------------
216 //------------------------------------------------------------------------------
217 
219 
220  XrdNetAddr(const XrdNetAddr *addr) : XrdNetAddrInfo(addr) {}
221 
222  XrdNetAddr(const sockaddr *addr) : XrdNetAddrInfo()
223  {Set(addr);}
224 
225  XrdNetAddr(const sockaddr_in *addr) : XrdNetAddrInfo()
226  {Set((sockaddr *)addr);}
227 
228  XrdNetAddr(const sockaddr_in6 *addr) : XrdNetAddrInfo()
229  {Set((sockaddr *)addr);}
230 
231  XrdNetAddr(int port);
232 
233 //------------------------------------------------------------------------------
235 //------------------------------------------------------------------------------
236 
238 private:
239 static struct addrinfo *Hints(int htype, int stype);
240 bool Map64();
241 
242 static struct addrinfo *hostHints;
243 static struct addrinfo *huntHintsTCP;
244 static struct addrinfo *huntHintsUDP;
245 static bool useIPV4;
246 };
247 #endif
static struct addrinfo * huntHintsTCP
Definition: XrdNetAddr.hh:243
static const int PortInSpec
Definition: XrdNetAddr.hh:90
static bool useIPV4
Definition: XrdNetAddr.hh:245
static struct addrinfo * huntHintsUDP
Definition: XrdNetAddr.hh:244
XrdNetAddr(const sockaddr *addr)
Definition: XrdNetAddr.hh:222
LocInfo addrLoc
Definition: XrdNetAddrInfo.hh:340
static struct addrinfo * hostHints
Definition: XrdNetAddr.hh:242
const char * Set(const char *hSpec, int pNum=PortInSpec)
XrdNetAddr(const sockaddr_in6 *addr)
Definition: XrdNetAddr.hh:228
static struct addrinfo * Hints(int htype, int stype)
Definition: XrdNetAddr.hh:41
bool Map64()
XrdNetAddr(const XrdNetAddr *addr)
Definition: XrdNetAddr.hh:220
static bool IPV4Set()
Definition: XrdNetAddr.hh:52
static void SetIPV4()
Definition: XrdNetAddrInfo.hh:175
Definition: XrdNetAddrInfo.hh:53
static void SetIPV6()
void SetLocation(XrdNetAddrInfo::LocInfo &loc)
Definition: XrdNetAddr.hh:203
XrdNetAddr()
Assignment operator and copy constructor are inherited, no need to define.
Definition: XrdNetAddr.hh:218
XrdNetAddr(const sockaddr_in *addr)
Definition: XrdNetAddr.hh:225
~XrdNetAddr()
Destructor.
Definition: XrdNetAddr.hh:237
static void SetCache(int keeptime)