|
91 |
void Serialize (uint8_t buf[4]) const; |
91 |
void Serialize (uint8_t buf[4]) const; |
92 |
/** |
92 |
/** |
93 |
* \param buf buffer to read address from |
93 |
* \param buf buffer to read address from |
94 |
* \returns an Ipv4Address |
94 |
* \return an Ipv4Address |
95 |
* |
95 |
* |
96 |
* The input address is expected to be in network byte order format. |
96 |
* The input address is expected to be in network byte order format. |
97 |
*/ |
97 |
*/ |
|
103 |
* \param os The output stream to which this Ipv4Address is printed |
103 |
* \param os The output stream to which this Ipv4Address is printed |
104 |
*/ |
104 |
*/ |
105 |
void Print (std::ostream &os) const; |
105 |
void Print (std::ostream &os) const; |
106 |
|
106 |
/** |
|
|
107 |
* \return true if address is 255.255.255.255; false otherwise |
108 |
*/ |
107 |
bool IsBroadcast (void) const; |
109 |
bool IsBroadcast (void) const; |
|
|
110 |
/** |
111 |
* \return true only if address is in the range 224.0.0.0 - 239.255.255.255 |
112 |
*/ |
108 |
bool IsMulticast (void) const; |
113 |
bool IsMulticast (void) const; |
109 |
/** |
114 |
/** |
110 |
* \brief Combine this address with a network mask |
115 |
* \brief Combine this address with a network mask |
|
120 |
* \brief Generate subnet-directed broadcast address corresponding to mask |
125 |
* \brief Generate subnet-directed broadcast address corresponding to mask |
121 |
* |
126 |
* |
122 |
* The subnet-directed broadcast address has the host bits set to all |
127 |
* The subnet-directed broadcast address has the host bits set to all |
123 |
* ones. |
128 |
* ones. If this method is called with a mask of 255.255.255.255, |
|
|
129 |
* (i.e., the address is a /32 address), the program will assert, since |
130 |
* there is no subnet associated with a /32 address. |
124 |
* |
131 |
* |
125 |
* \param mask a network mask |
132 |
* \param mask a network mask |
126 |
*/ |
133 |
*/ |
127 |
Ipv4Address GetSubnetDirectedBroadcast (Ipv4Mask const &mask) const; |
134 |
Ipv4Address GetSubnetDirectedBroadcast (Ipv4Mask const &mask) const; |
|
|
135 |
/** |
136 |
* \brief Generate subnet-directed broadcast address corresponding to mask |
137 |
* |
138 |
* The subnet-directed broadcast address has the host bits set to all |
139 |
* ones. If this method is called with a mask of 255.255.255.255, |
140 |
* (i.e., the address is a /32 address), the program will assert, since |
141 |
* there is no subnet associated with a /32 address. |
142 |
* |
143 |
* \param mask a network mask |
144 |
* \return true if the address, when combined with the input mask, has all |
145 |
* of its host bits set to one |
146 |
*/ |
128 |
bool IsSubnetDirectedBroadcast (Ipv4Mask const &mask) const; |
147 |
bool IsSubnetDirectedBroadcast (Ipv4Mask const &mask) const; |
129 |
|
148 |
/** |
|
|
149 |
* \param address an address to compare type with |
150 |
* |
151 |
* \return true if the type of the address stored internally |
152 |
* is compatible with the type of the input address, false otherwise. |
153 |
*/ |
130 |
static bool IsMatchingType (const Address &address); |
154 |
static bool IsMatchingType (const Address &address); |
|
|
155 |
/** |
156 |
* Convert an instance of this class to a polymorphic Address instance. |
157 |
* |
158 |
* \return a new Address instance |
159 |
*/ |
131 |
operator Address () const; |
160 |
operator Address () const; |
|
|
161 |
/** |
162 |
* \param address a polymorphic address |
163 |
* \return a new Ipv4Address from the polymorphic address |
164 |
* |
165 |
* This function performs a type check and asserts if the |
166 |
* type of the input address is not compatible with an |
167 |
* Ipv4Address. |
168 |
*/ |
132 |
static Ipv4Address ConvertFrom (const Address &address); |
169 |
static Ipv4Address ConvertFrom (const Address &address); |
133 |
|
170 |
/** |
|
|
171 |
* \return the 0.0.0.0 address |
172 |
*/ |
134 |
static Ipv4Address GetZero (void); |
173 |
static Ipv4Address GetZero (void); |
|
|
174 |
/** |
175 |
* \return the 0.0.0.0 address |
176 |
*/ |
135 |
static Ipv4Address GetAny (void); |
177 |
static Ipv4Address GetAny (void); |
|
|
178 |
/** |
179 |
* \return the 255.255.255.255 address |
180 |
*/ |
136 |
static Ipv4Address GetBroadcast (void); |
181 |
static Ipv4Address GetBroadcast (void); |
|
|
182 |
/** |
183 |
* \return the 127.0.0.1 address |
184 |
*/ |
137 |
static Ipv4Address GetLoopback (void); |
185 |
static Ipv4Address GetLoopback (void); |
138 |
|
186 |
|
139 |
private: |
187 |
private: |
|
156 |
Ipv4Mask (); |
204 |
Ipv4Mask (); |
157 |
Ipv4Mask (uint32_t mask); |
205 |
Ipv4Mask (uint32_t mask); |
158 |
Ipv4Mask (char const *mask); |
206 |
Ipv4Mask (char const *mask); |
159 |
|
207 |
/** |
|
|
208 |
* \param a first address to compare |
209 |
* \param b second address to compare |
210 |
* \return true if both addresses are equal in their masked bits, |
211 |
* corresponding to this mask |
212 |
*/ |
160 |
bool IsMatch (Ipv4Address a, Ipv4Address b) const; |
213 |
bool IsMatch (Ipv4Address a, Ipv4Address b) const; |
161 |
|
214 |
/** |
|
|
215 |
* \param other a mask to compare |
216 |
* \return true if the mask equals the mask passed as input parameter |
217 |
*/ |
162 |
bool IsEqual (Ipv4Mask other) const; |
218 |
bool IsEqual (Ipv4Mask other) const; |
163 |
/** |
219 |
/** |
164 |
* Get the host-order 32-bit IP mask |
220 |
* Get the host-order 32-bit IP mask |
|
174 |
* \brief Return the inverse mask in host order. |
230 |
* \brief Return the inverse mask in host order. |
175 |
*/ |
231 |
*/ |
176 |
uint32_t GetInverse (void) const; |
232 |
uint32_t GetInverse (void) const; |
177 |
|
233 |
/** |
|
|
234 |
* \brief Print this mask to the given output stream |
235 |
* |
236 |
* The print format is in the typical "255.255.255.0" |
237 |
* \param os The output stream to which this Ipv4Address is printed |
238 |
*/ |
178 |
void Print (std::ostream &os) const; |
239 |
void Print (std::ostream &os) const; |
179 |
|
240 |
/** |
|
|
241 |
* \return the 255.0.0.0 mask corresponding to a typical loopback address |
242 |
*/ |
180 |
static Ipv4Mask GetLoopback (void); |
243 |
static Ipv4Mask GetLoopback (void); |
|
|
244 |
/** |
245 |
* \return the 0.0.0.0 mask |
246 |
*/ |
181 |
static Ipv4Mask GetZero (void); |
247 |
static Ipv4Mask GetZero (void); |
|
|
248 |
/** |
249 |
* \return the 255.255.255.255 mask |
250 |
*/ |
251 |
static Ipv4Mask GetOnes (void); |
182 |
|
252 |
|
183 |
private: |
253 |
private: |
184 |
uint32_t m_mask; |
254 |
uint32_t m_mask; |