VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlInetAddr.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 *********************************************************************/
8 #pragma once
9 
10 #include <vlutil/vlInet.h>
11 #include <vlutil/vlInetAddrUtils.h>
12 #include <vlutil/vlString.h>
13 #include <vlutil/vlUtilTypes.h>
14 
15 #ifdef DtUSE_UTILITIES_NAMESPACE
16 namespace DtUSE_UTILITIES_NAMESPACE
17 {
18 #endif
19 
20 // Ref. RFC3513
23 {
25  DtInetIpv6_Interface = 1, // AKA node-local
27  DtInetIpv6_Subnet = 3, // MS only, not in RFC3513
28  DtInetIpv6_AdminLocal = 4, // in RFC3513, but not used in Linux
32 };
33 
37 {
38 public:
39 
43 
50  DtInetAddr( const DtString& addrString, const DtString& netmaskString = "" );
51  DtInetAddr( const char* addrString, const char* netmaskString = NULL );
53 
58  DtInetAddr( const struct sockaddr_in& addr, DtU32 netmask = 0 );
59  DtInetAddr( const DtU32 addr, DtU32 netmask = 0 );
61 
63  DtInetAddr( const struct sockaddr_in6& addr, DtU32 prefixLen = 0 );
64 
67  DtInetAddr( const struct sockaddr_storage& addr, DtU32 prefixLen = 0 );
68 
72  DtInetAddr( const DtU128& addr, DtInetUtils::DtInetAddrFamily family,
73  DtU32 prefixLen = 0);
74 
77  DtInetAddr( void* boostAsioIpAddress );
78 
80  virtual ~DtInetAddr( );
81 
83  DtInetAddr( const DtInetAddr& orig );
84 
86  DtInetAddr& operator=(const DtInetAddr& orig);
87 
91  virtual DtString toDtString( bool useShortForm = false ) const;
92 
94  virtual DtInetUtils::DtInetAddrFamily family() const;
95 
98  virtual bool isIPv4() const;
99  virtual bool isIPv6() const;
101 
104  virtual void setNetmask( DtU32 mask );
105 
109  virtual DtU32 netmask() const;
110 
112  virtual void setPrefixLen( DtU64 prefixLen );
113 
115  virtual DtU64 prefix() const;
116 
118  virtual bool isMulticast() const;
119 
121  virtual bool isBroadcast() const;
122 
124  virtual bool isLoopback() const;
125 
128  virtual bool isAnyAddr() const;
129 
132  virtual const DtInetAddr* getBroadcastAddr();
133 
135  virtual const DtInetAddr* getLoopbackAddr();
136 
140  virtual int toSockaddr( struct sockaddr_in* s ) const;
141  virtual int toSockaddr( struct sockaddr_in6* s ) const;
143 
145  virtual void toAddrStorage( struct sockaddr_storage* addrStor ) const;
146 
148  virtual DtU128 toU128() const;
149 
152  virtual DtU32 toULong() const;
153 
155  virtual void setScope( DtInetIpv6Scope scopeId );
156 
159  virtual DtInetIpv6Scope scope() const;
160 
164  virtual void* boostAddress();
165  virtual const void* boostAddress() const;
166 
169  friend DT_DLL_VLUTIL bool operator==( const DtInetAddr& addr1, const DtInetAddr& addr2 );
170  friend DT_DLL_VLUTIL bool operator!=( const DtInetAddr& addr1, const DtInetAddr& addr2 );
171  friend DT_DLL_VLUTIL bool operator<( const DtInetAddr& addr1, const DtInetAddr& addr2 );
172  friend DT_DLL_VLUTIL bool operator>( const DtInetAddr& addr1, const DtInetAddr& addr2 );
174 
176  static const DtInetAddr& loopbackAddress(DtInetUtils::DtInetAddrFamily family = DtInetUtils::DtInetAddrFamily_IPv4);
177 
178 protected:
179  void init();
180  void initFromStrings(const char* addrString, const char* netmaskString);
181 
182 protected:
183 
184 #ifdef DtDIAGNOSTIC
185  DtString myAddressStr;
186 #endif
187 
189  void* myAddr;
190 
193 
196 
201 
203 
204 };
205 // end of class DtInetAddr
206 
207 #ifdef DtUSE_UTILITIES_NAMESPACE
208 }
209 #endif
210 
Definition: vlInetAddr.h:31
bool myIsBroadcast
Definition: vlInetAddr.h:197
const bool operator==(const DtU128 &lhs, const DtU128 &rhs)
Definition: vlInetAddrUtils.h:58
A Host byte aligned 128 unsigned integer data structure.
Definition: vlUtilTypes.h:23
Contains the DtString class declaration.
Definition: vlInetAddr.h:24
Definition: vlInetAddr.h:30
void * myAddr
Private data, do not change.
Definition: vlInetAddr.h:189
unsigned long long DtU64
-------—— Network Layout for a long long (64 bytes unsigned)
Definition: vlMachineTypes.h:185
Definition: vlInetAddr.h:27
bool myIsAnyAddr
Definition: vlInetAddr.h:200
bool myIsLoopback
Definition: vlInetAddr.h:199
DtInetAddr * myLoopbackAddr
Definition: vlInetAddr.h:195
Definition: vlInetAddr.h:26
DtInetAddrFamily
Definition: vlInetAddrUtils.h:55
Definition: vlInetAddr.h:29
Represents a IPv4 or IPv6 address.
Definition: vlInetAddr.h:36
This file declares useful defaults constants and static methods for IP address handling.
DtU64 myPrefixLen
Definition: vlInetAddr.h:192
Definition: vlInetAddr.h:25
DtInetAddr * myBroadcastAddr
Definition: vlInetAddr.h:194
DtU64 myIpv4Netmask
Definition: vlInetAddr.h:191
DtInetIpv6Scope myIpv6ScopeId
Definition: vlInetAddr.h:202
const bool operator!=(const DtU128 &lhs, const DtU128 &rhs)
DtInetIpv6Scope
Definition: vlInetAddr.h:22
unsigned long DtU32
A 32 bit unsigned integer value.
Definition: vlMachineTypes.h:153
Instances of DtString are used to represent strings.
Definition: vlString.h:29
const bool operator<(const DtU128 &lhs, const DtU128 &rhs)
Definition: vlInetAddr.h:28
const bool operator>(const DtU128 &lhs, const DtU128 &rhs)
This file declares useful defaults constants and static methods employed with the networking abstract...
#define DT_DLL_VLUTIL
Definition: vlMachineTypes.h:109
bool myIsMulticast
Definition: vlInetAddr.h:198

Document ID: Generated on Tue Aug 10 00:12:31 EDT 2021 from SVN revision 232765
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)