A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ipv4-interface-address.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 University of Washington
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  */
19 
20 #ifndef IPV4_INTERFACE_ADDRESS_H
21 #define IPV4_INTERFACE_ADDRESS_H
22 
23 #include <stdint.h>
24 #include <ostream>
25 #include "ns3/ipv4-address.h"
26 
27 namespace ns3 {
28 
43 {
44 public:
53  };
54 
56 
68 
73  void SetLocal (Ipv4Address local);
78  Ipv4Address GetLocal (void) const;
83  void SetMask (Ipv4Mask mask);
88  Ipv4Mask GetMask (void) const;
93  void SetBroadcast (Ipv4Address broadcast);
98  Ipv4Address GetBroadcast (void) const;
99 
105 
111 
118  bool IsSecondary (void) const;
119 
123  void SetSecondary (void);
127  void SetPrimary (void);
128 
129 private:
130 
132  // Note: m_peer may be added in future when necessary
133  // Ipv4Address m_peer; // Peer destination address (in Linux: m_address)
136 
138  bool m_secondary;
139 
147  friend bool operator == (Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b);
148 
156  friend bool operator != (Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b);
157 };
158 
166 std::ostream& operator<< (std::ostream& os, const Ipv4InterfaceAddress &addr);
167 
169 {
170  return (a.m_local == b.m_local && a.m_mask == b.m_mask &&
171  a.m_broadcast == b.m_broadcast && a.m_scope == b.m_scope && a.m_secondary == b.m_secondary);
172 }
174 {
175  return (a.m_local != b.m_local || a.m_mask != b.m_mask ||
176  a.m_broadcast != b.m_broadcast || a.m_scope != b.m_scope || a.m_secondary != b.m_secondary);
177 }
178 
179 
180 } // namespace ns3
181 
182 #endif /* IPV4_ADDRESS_H */
Ipv4Mask m_mask
Network mask.
InterfaceAddressScope_e m_scope
Address scope.
Ipv4Mask GetMask(void) const
Get the network mask.
Ipv4Address GetLocal(void) const
Get the local address.
bool m_secondary
For use in multihoming.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:210
friend bool operator==(Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b)
Equal to operator.
Ipv4Address m_local
Interface address.
void SetSecondary(void)
Make the address secondary (used for multihoming)
void SetPrimary(void)
Make the address primary.
bool IsSecondary(void) const
Check if the address is a secondary address.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:43
bool operator!=(Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > a, Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > b)
Inequality test.
Definition: callback.h:1213
Ipv4Address m_broadcast
Broadcast address.
void SetBroadcast(Ipv4Address broadcast)
Set the broadcast address.
void SetMask(Ipv4Mask mask)
Set the network mask.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
Ipv4Address GetBroadcast(void) const
Get the broadcast address.
a class to store IPv4 address information on an interface
void SetScope(Ipv4InterfaceAddress::InterfaceAddressScope_e scope)
Set the scope.
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.cc:89
Ipv4InterfaceAddress::InterfaceAddressScope_e GetScope(void) const
Get address scope.
void SetLocal(Ipv4Address local)
Set local address.
friend bool operator!=(Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b)
Not equal to operator.