author | Tom Henderson <tomh@tomh.org> |
Fri, 28 Nov 2008 06:05:27 -0800 | |
changeset 3956 | 0339a8ad5983 |
parent 3183 | fc3b2e03e61e |
child 4726 | 0488cf67d707 |
permissions | -rw-r--r-- |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2005 INRIA |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
*/ |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
|
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#ifndef IPV4_ADDRESS_H |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
#define IPV4_ADDRESS_H |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
|
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include <stdint.h> |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
#include <ostream> |
1158
12d68dff3353
new address types
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
784
diff
changeset
|
26 |
#include "address.h" |
2492
f2293afeeac1
make Ipv4Address/Ipv4Mask attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1767
diff
changeset
|
27 |
#include "ns3/attribute-helper.h" |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
|
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
namespace ns3 { |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
|
979
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
31 |
class Ipv4Mask; |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
32 |
|
3183 | 33 |
/** |
34 |
* \ingroup address |
|
35 |
* |
|
36 |
* \brief Ipv4 addresses are stored in host order in this class. |
|
37 |
*/ |
|
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
38 |
class Ipv4Address { |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
39 |
public: |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
40 |
Ipv4Address (); |
625
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
41 |
/** |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
42 |
* input address is in host order. |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
43 |
* \param address The host order 32-bit address |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
44 |
*/ |
2335
854dbe96e04c
fix bug 137: Make Ipv4Address (uint32_t) constructor explicit. patch by Gustavo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1767
diff
changeset
|
45 |
explicit Ipv4Address (uint32_t address); |
625
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
46 |
/** |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
47 |
* \brief Constructs an Ipv4Address by parsing a the input C-string |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
48 |
* |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
49 |
* Input address is in format: |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
50 |
* hhh.xxx.xxx.lll |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
51 |
* where h is the high byte and l the |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
52 |
* low byte |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
53 |
* \param address C-string containing the address as described above |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
54 |
*/ |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
55 |
Ipv4Address (char const *address); |
3179
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3094
diff
changeset
|
56 |
/** |
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3094
diff
changeset
|
57 |
* Get the host-order 32-bit IP address |
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3094
diff
changeset
|
58 |
* \return the host-order 32-bit IP address |
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3094
diff
changeset
|
59 |
*/ |
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3094
diff
changeset
|
60 |
uint32_t Get (void) const; |
625
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
61 |
/** |
1044
f6180a7631ee
Add Set methods to class Ipv4Address (like the non-default ctors)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
62 |
* input address is in host order. |
f6180a7631ee
Add Set methods to class Ipv4Address (like the non-default ctors)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
63 |
* \param address The host order 32-bit address |
f6180a7631ee
Add Set methods to class Ipv4Address (like the non-default ctors)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
64 |
*/ |
f6180a7631ee
Add Set methods to class Ipv4Address (like the non-default ctors)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
65 |
void Set (uint32_t address); |
f6180a7631ee
Add Set methods to class Ipv4Address (like the non-default ctors)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
66 |
/** |
f6180a7631ee
Add Set methods to class Ipv4Address (like the non-default ctors)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
67 |
* \brief Sets an Ipv4Address by parsing a the input C-string |
f6180a7631ee
Add Set methods to class Ipv4Address (like the non-default ctors)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
68 |
* |
f6180a7631ee
Add Set methods to class Ipv4Address (like the non-default ctors)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
69 |
* Input address is in format: |
f6180a7631ee
Add Set methods to class Ipv4Address (like the non-default ctors)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
70 |
* hhh.xxx.xxx.lll |
f6180a7631ee
Add Set methods to class Ipv4Address (like the non-default ctors)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
71 |
* where h is the high byte and l the |
f6180a7631ee
Add Set methods to class Ipv4Address (like the non-default ctors)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
72 |
* low byte |
f6180a7631ee
Add Set methods to class Ipv4Address (like the non-default ctors)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
73 |
* \param address C-string containing the address as described above |
f6180a7631ee
Add Set methods to class Ipv4Address (like the non-default ctors)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
74 |
*/ |
f6180a7631ee
Add Set methods to class Ipv4Address (like the non-default ctors)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
75 |
void Set (char const *address); |
f6180a7631ee
Add Set methods to class Ipv4Address (like the non-default ctors)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
76 |
/** |
625
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
77 |
* \brief Comparison operation between two Ipv4Addresses |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
78 |
* \param other address to which to compare this address |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
79 |
* \return True if the addresses are equal. False otherwise. |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
80 |
*/ |
1709
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
81 |
bool IsEqual (const Ipv4Address &other) const |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
82 |
{ |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
83 |
return m_address == other.m_address; |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
84 |
} |
625
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
85 |
/** |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
86 |
* Serialize this address to a 4-byte buffer |
1158
12d68dff3353
new address types
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
784
diff
changeset
|
87 |
* |
625
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
88 |
* \param buf output buffer to which this address gets overwritten with this |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
89 |
* Ipv4Address |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
90 |
*/ |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
91 |
void Serialize (uint8_t buf[4]) const; |
625
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
92 |
/** |
1158
12d68dff3353
new address types
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
784
diff
changeset
|
93 |
* \param buf buffer to read address from |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
94 |
* \return an Ipv4Address |
1158
12d68dff3353
new address types
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
784
diff
changeset
|
95 |
* |
12d68dff3353
new address types
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
784
diff
changeset
|
96 |
* The input address is expected to be in network byte order format. |
12d68dff3353
new address types
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
784
diff
changeset
|
97 |
*/ |
12d68dff3353
new address types
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
784
diff
changeset
|
98 |
static Ipv4Address Deserialize (const uint8_t buf[4]); |
12d68dff3353
new address types
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
784
diff
changeset
|
99 |
/** |
625
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
100 |
* \brief Print this address to the given output stream |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
101 |
* |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
102 |
* The print format is in the typical "192.168.1.1" |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
103 |
* \param os The output stream to which this Ipv4Address is printed |
12fa3d0c4f94
droptail and ipv4address dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
256
diff
changeset
|
104 |
*/ |
256
8978ff0dc351
replace pointer with reference
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
234
diff
changeset
|
105 |
void Print (std::ostream &os) const; |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
106 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
107 |
* \return true if address is 255.255.255.255; false otherwise |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
108 |
*/ |
986
a1354f6319fe
Add Ipv4Address::CombineMask, and implement Ipv4Address::IsBroadcast.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
109 |
bool IsBroadcast (void) const; |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
110 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
111 |
* \return true only if address is in the range 224.0.0.0 - 239.255.255.255 |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
112 |
*/ |
986
a1354f6319fe
Add Ipv4Address::CombineMask, and implement Ipv4Address::IsBroadcast.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
113 |
bool IsMulticast (void) const; |
979
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
114 |
/** |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
115 |
* \brief Combine this address with a network mask |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
116 |
* |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
117 |
* This method returns an IPv4 address that is this address combined |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
118 |
* (bitwise and) with a network mask, yielding an IPv4 network |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
119 |
* address. |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
120 |
* |
1250
243eb985ad00
fix dox warning
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1208
diff
changeset
|
121 |
* \param mask a network mask |
979
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
122 |
*/ |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
784
diff
changeset
|
123 |
Ipv4Address CombineMask (Ipv4Mask const &mask) const; |
1318
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1250
diff
changeset
|
124 |
/** |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1250
diff
changeset
|
125 |
* \brief Generate subnet-directed broadcast address corresponding to mask |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1250
diff
changeset
|
126 |
* |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1250
diff
changeset
|
127 |
* The subnet-directed broadcast address has the host bits set to all |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
128 |
* ones. If this method is called with a mask of 255.255.255.255, |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
129 |
* (i.e., the address is a /32 address), the program will assert, since |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
130 |
* there is no subnet associated with a /32 address. |
1318
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1250
diff
changeset
|
131 |
* |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1250
diff
changeset
|
132 |
* \param mask a network mask |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1250
diff
changeset
|
133 |
*/ |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1250
diff
changeset
|
134 |
Ipv4Address GetSubnetDirectedBroadcast (Ipv4Mask const &mask) const; |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
135 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
136 |
* \brief Generate subnet-directed broadcast address corresponding to mask |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
137 |
* |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
138 |
* The subnet-directed broadcast address has the host bits set to all |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
139 |
* ones. If this method is called with a mask of 255.255.255.255, |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
140 |
* (i.e., the address is a /32 address), the program will assert, since |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
141 |
* there is no subnet associated with a /32 address. |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
142 |
* |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
143 |
* \param mask a network mask |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
144 |
* \return true if the address, when combined with the input mask, has all |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
145 |
* of its host bits set to one |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
146 |
*/ |
1318
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1250
diff
changeset
|
147 |
bool IsSubnetDirectedBroadcast (Ipv4Mask const &mask) const; |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
148 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
149 |
* \param address an address to compare type with |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
150 |
* |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
151 |
* \return true if the type of the address stored internally |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
152 |
* is compatible with the type of the input address, false otherwise. |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
153 |
*/ |
1173
06e382cadbbb
add Ipv4Address::IsMatchingType and Eui48Address::IsMatchingType
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
154 |
static bool IsMatchingType (const Address &address); |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
155 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
156 |
* Convert an instance of this class to a polymorphic Address instance. |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
157 |
* |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
158 |
* \return a new Address instance |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
159 |
*/ |
1706
0df67ef4eb96
constify more conversion operators
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1318
diff
changeset
|
160 |
operator Address () const; |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
161 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
162 |
* \param address a polymorphic address |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
163 |
* \return a new Ipv4Address from the polymorphic address |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
164 |
* |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
165 |
* This function performs a type check and asserts if the |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
166 |
* type of the input address is not compatible with an |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
167 |
* Ipv4Address. |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
168 |
*/ |
1207
a9f3610bbffa
remove implicit conversion from Address to Eui48Address, to Ipv4Address and to InetSocketAddress
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1206
diff
changeset
|
169 |
static Ipv4Address ConvertFrom (const Address &address); |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
170 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
171 |
* \return the 0.0.0.0 address |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
172 |
*/ |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
173 |
static Ipv4Address GetZero (void); |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
174 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
175 |
* \return the 0.0.0.0 address |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
176 |
*/ |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
177 |
static Ipv4Address GetAny (void); |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
178 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
179 |
* \return the 255.255.255.255 address |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
180 |
*/ |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
181 |
static Ipv4Address GetBroadcast (void); |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
182 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
183 |
* \return the 127.0.0.1 address |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
184 |
*/ |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
185 |
static Ipv4Address GetLoopback (void); |
2492
f2293afeeac1
make Ipv4Address/Ipv4Mask attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1767
diff
changeset
|
186 |
|
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
187 |
private: |
1206
7534ef3604a7
add implicit conversion to Ipv4Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1173
diff
changeset
|
188 |
Address ConvertTo (void) const; |
1158
12d68dff3353
new address types
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
784
diff
changeset
|
189 |
static uint8_t GetType (void); |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
190 |
uint32_t m_address; |
1709
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
191 |
|
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
192 |
friend bool operator == (Ipv4Address const &a, Ipv4Address const &b); |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
193 |
friend bool operator != (Ipv4Address const &a, Ipv4Address const &b); |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
194 |
friend bool operator < (Ipv4Address const &addrA, Ipv4Address const &addrB); |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
195 |
}; |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
196 |
|
3183 | 197 |
/** |
198 |
* \ingroup address |
|
199 |
* |
|
200 |
* \brief a class to represent an Ipv4 address mask |
|
201 |
*/ |
|
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
202 |
class Ipv4Mask { |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
203 |
public: |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
204 |
Ipv4Mask (); |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
205 |
Ipv4Mask (uint32_t mask); |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
206 |
Ipv4Mask (char const *mask); |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
207 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
208 |
* \param a first address to compare |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
209 |
* \param b second address to compare |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
210 |
* \return true if both addresses are equal in their masked bits, |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
211 |
* corresponding to this mask |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
212 |
*/ |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
213 |
bool IsMatch (Ipv4Address a, Ipv4Address b) const; |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
214 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
215 |
* \param other a mask to compare |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
216 |
* \return true if the mask equals the mask passed as input parameter |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
217 |
*/ |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
218 |
bool IsEqual (Ipv4Mask other) const; |
3179
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3094
diff
changeset
|
219 |
/** |
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3094
diff
changeset
|
220 |
* Get the host-order 32-bit IP mask |
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3094
diff
changeset
|
221 |
* \return the host-order 32-bit IP mask |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
222 |
*/ |
3179
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3094
diff
changeset
|
223 |
uint32_t Get (void) const; |
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3094
diff
changeset
|
224 |
/** |
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3094
diff
changeset
|
225 |
* input mask is in host order. |
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3094
diff
changeset
|
226 |
* \param mask The host order 32-bit mask |
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3094
diff
changeset
|
227 |
*/ |
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3094
diff
changeset
|
228 |
void Set (uint32_t mask); |
1318
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1250
diff
changeset
|
229 |
/** |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1250
diff
changeset
|
230 |
* \brief Return the inverse mask in host order. |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1250
diff
changeset
|
231 |
*/ |
89b78e2d521e
Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents:
1250
diff
changeset
|
232 |
uint32_t GetInverse (void) const; |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
233 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
234 |
* \brief Print this mask to the given output stream |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
235 |
* |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
236 |
* The print format is in the typical "255.255.255.0" |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
237 |
* \param os The output stream to which this Ipv4Address is printed |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
238 |
*/ |
256
8978ff0dc351
replace pointer with reference
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
234
diff
changeset
|
239 |
void Print (std::ostream &os) const; |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
240 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
241 |
* \return the 255.0.0.0 mask corresponding to a typical loopback address |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
242 |
*/ |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
243 |
static Ipv4Mask GetLoopback (void); |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
244 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
245 |
* \return the 0.0.0.0 mask |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
246 |
*/ |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
247 |
static Ipv4Mask GetZero (void); |
3956
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
248 |
/** |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
249 |
* \return the 255.255.255.255 mask |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
250 |
*/ |
0339a8ad5983
Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
251 |
static Ipv4Mask GetOnes (void); |
2492
f2293afeeac1
make Ipv4Address/Ipv4Mask attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1767
diff
changeset
|
252 |
|
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
253 |
private: |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
254 |
uint32_t m_mask; |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
255 |
}; |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
256 |
|
2969
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
257 |
/** |
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
258 |
* \class ns3::Ipv4AddressValue |
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
259 |
* \brief hold objects of type ns3::Ipv4Address |
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
260 |
*/ |
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
261 |
/** |
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
262 |
* \class ns3::Ipv4MaskValue |
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
263 |
* \brief hold objects of type ns3::Ipv4Mask |
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
264 |
*/ |
9d05d2a95dfa
improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
265 |
|
3094
6e787ec9c8aa
ATTRIBUTE_HELPER_HEADER_2 -> ATTRIBUTE_HELPER_HEADER
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3093
diff
changeset
|
266 |
ATTRIBUTE_HELPER_HEADER (Ipv4Address); |
6e787ec9c8aa
ATTRIBUTE_HELPER_HEADER_2 -> ATTRIBUTE_HELPER_HEADER
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3093
diff
changeset
|
267 |
ATTRIBUTE_HELPER_HEADER (Ipv4Mask); |
2492
f2293afeeac1
make Ipv4Address/Ipv4Mask attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1767
diff
changeset
|
268 |
|
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
269 |
std::ostream& operator<< (std::ostream& os, Ipv4Address const& address); |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
270 |
std::ostream& operator<< (std::ostream& os, Ipv4Mask const& mask); |
2492
f2293afeeac1
make Ipv4Address/Ipv4Mask attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1767
diff
changeset
|
271 |
std::istream & operator >> (std::istream &is, Ipv4Address &address); |
f2293afeeac1
make Ipv4Address/Ipv4Mask attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1767
diff
changeset
|
272 |
std::istream & operator >> (std::istream &is, Ipv4Mask &mask); |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
273 |
|
1709
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
274 |
inline bool operator == (const Ipv4Address &a, const Ipv4Address &b) |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
275 |
{ |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
276 |
return (a.m_address == b.m_address); |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
277 |
} |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
278 |
inline bool operator != (const Ipv4Address &a, const Ipv4Address &b) |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
279 |
{ |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
280 |
return (a.m_address != b.m_address); |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
281 |
} |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
282 |
inline bool operator < (const Ipv4Address &a, const Ipv4Address &b) |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
283 |
{ |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
284 |
return (a.m_address < b.m_address); |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
285 |
} |
3e0426f2c26a
Bug #88 (Ipv4Address operator ==, !=, < should be inline for performance reasons)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1706
diff
changeset
|
286 |
|
784
a3f6b5783790
Add Ipv4Address operator <, to allow Ipv4Address to be used in std::set; Closes #39.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
782
diff
changeset
|
287 |
|
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
288 |
class Ipv4AddressHash : public std::unary_function<Ipv4Address, size_t> { |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
289 |
public: |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
290 |
size_t operator()(Ipv4Address const &x) const; |
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
291 |
}; |
782
ca907fdc28fb
Add Ipv4Mask == and != operators, similarly to Ipv4Address.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
625
diff
changeset
|
292 |
|
ca907fdc28fb
Add Ipv4Mask == and != operators, similarly to Ipv4Address.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
625
diff
changeset
|
293 |
bool operator == (Ipv4Mask const &a, Ipv4Mask const &b); |
ca907fdc28fb
Add Ipv4Mask == and != operators, similarly to Ipv4Address.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
625
diff
changeset
|
294 |
bool operator != (Ipv4Mask const &a, Ipv4Mask const &b); |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
295 |
|
2492
f2293afeeac1
make Ipv4Address/Ipv4Mask attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1767
diff
changeset
|
296 |
} // namespace ns3 |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
297 |
|
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
298 |
#endif /* IPV4_ADDRESS_H */ |