VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlInetAddrUtils.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 *********************************************************************/
9 #pragma once
10 
11 #include <vlutil/vlInet.h>
12 #include <vlutil/vlString.h>
13 
14 #ifdef DtUSE_UTILITIES_NAMESPACE
15 namespace DtUSE_UTILITIES_NAMESPACE
16 {
17 #endif
18 
19 class DtInetAddr;
20 
23 namespace DtInetUtils
24 {
28 #define DtUSE_DEFAULT_INET_ADDR 0
29 #define DtINET_IGMPv4_MGMT_GROUP_ADDR 0xE0000001 // == 224.0.0.1
30 
31 #define DtInet_IPv4_ADDR_LEN sizeof( struct in_addr )
32 #define DtInet_IPv6_ADDR_LEN sizeof( struct in6_addr )
33 
37 #define DtNetResLocType_NONE 0
38 #define DtNetResLocType_PORT 1
39 #define DtNetResLocType_NETMASK 2
40 #define DtNetResLocType_PREFIXLEN 3
41 
42 
44 #define DtINET_IPv4_LINK_LOCAL_MASK 0xa9fe0000 // == 169.254.0.0/16
45 #define DtINET_IPv4_LOOPBACK_MASK 0x7f000001 // == 127.0.0.1
46 #define DtINET_IPv6_LINK_LOCAL_MASK 0xfe80 // uppermost 10 bits of address
47 
49 
52 // NB: The reason these values are not the same as AF_INET and AF_INET6 is
53 // simply to make it easier to use these enums in log messages that
54 // identify an address family.
56 {
61 };
62 
64 
74 
80 DT_DLL_VLUTIL bool isIpv4AddrString(const DtString& addrString);
81 
87 DT_DLL_VLUTIL bool isIpv6AddrString(const DtString& addrString);
88 
93 DT_DLL_VLUTIL bool isLoopbackAddrString(const DtString& addrString);
94 
99 DT_DLL_VLUTIL bool isLocalhostAddrString(const DtString& addrString);
100 
105 DT_DLL_VLUTIL bool isLinkLocalAddrString(const DtString& addrString);
106 
112 DT_DLL_VLUTIL bool isMulticastAddrString(const DtString& addrString);
113 
118 DT_DLL_VLUTIL bool isBroadcastAddrString(const DtString& addrString);
119 
141  DtString& modifier, int& modifierType);
142 
149 DT_DLL_VLUTIL bool parseIpv4NetResLoc(const DtString& nrl, DtString& parsedNrl,
150  DtString& modifier, int& modifierType);
151 DT_DLL_VLUTIL bool parseIpv6NetResLoc(const DtString& nrl, DtString& parsedNrl,
152  DtString& modifier, int& modifierType);
153 
156 
159 
165 
170 
176 DT_DLL_VLUTIL DtInetAddr* getPrimaryBroadcastAddress(bool preferIpv6 = false);
177 
180 DT_DLL_VLUTIL const char* removeZoneIndex(char* addrStr);
181 
183 
184 #ifdef _WIN32
185 inline bool IN6_IS_ADDR_BROADCAST(const struct in6_addr *a)
186 {
187  return ( IN6_IS_ADDR_MC_LINKLOCAL(a)
188  && ((a->s6_bytes[2] & 0xf) == 0) && ((a->s6_bytes[3] & 0xf) == 0)
189  && ((a->s6_bytes[4] & 0xf) == 0) && ((a->s6_bytes[5] & 0xf) == 0)
190  && ((a->s6_bytes[6] & 0xf) == 0) && ((a->s6_bytes[7] & 0xf) == 0)
191  && ((a->s6_bytes[8] & 0xf) == 0) && ((a->s6_bytes[9] & 0xf) == 0)
192  && ((a->s6_bytes[10] & 0xf) == 0) && ((a->s6_bytes[11] & 0xf) == 0)
193  && ((a->s6_bytes[12] & 0xf) == 0) && ((a->s6_bytes[13] & 0xf) == 0)
194  && ((a->s6_bytes[14] & 0xf) == 0) && ((a->s6_bytes[15] & 0xf) == 1) );
195 }
196 #else // !_WIN32
197 inline bool IN6_IS_ADDR_BROADCAST(const struct in6_addr *a)
198 {
199  return ( IN6_IS_ADDR_MC_LINKLOCAL(a)
200  && ((a->s6_addr[2] & 0xf) == 0) && ((a->s6_addr[3] & 0xf) == 0)
201  && ((a->s6_addr[4] & 0xf) == 0) && ((a->s6_addr[5] & 0xf) == 0)
202  && ((a->s6_addr[6] & 0xf) == 0) && ((a->s6_addr[7] & 0xf) == 0)
203  && ((a->s6_addr[8] & 0xf) == 0) && ((a->s6_addr[9] & 0xf) == 0)
204  && ((a->s6_addr[10] & 0xf) == 0) && ((a->s6_addr[11] & 0xf) == 0)
205  && ((a->s6_addr[12] & 0xf) == 0) && ((a->s6_addr[13] & 0xf) == 0)
206  && ((a->s6_addr[14] & 0xf) == 0) && ((a->s6_addr[15] & 0xf) == 1) );
207 }
208 #endif
209 
210 }
211 
212 #ifdef DtUSE_UTILITIES_NAMESPACE
213 }
214 #endif
215 
216 

Document ID: Generated on Fri May 15 06:36:13 EDT 2015 from SVN revision 153263
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)