OpenDDS  Snapshot(2023/04/28-20:55)
NetworkConfigMonitor.h
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #ifndef OPENDDS_DCPS_NETWORKCONFIGMONITOR_H
9 #define OPENDDS_DCPS_NETWORKCONFIGMONITOR_H
10 
11 #include "dcps_export.h"
12 
13 #include "InternalTopic.h"
14 #include "NetworkAddress.h"
15 #include "PoolAllocator.h"
16 #include "RcObject.h"
17 
19 
20 namespace OpenDDS {
21 namespace DCPS {
22 
25  : can_multicast(false)
26  {}
28  bool a_can_multicast,
29  const NetworkAddress& a_address)
30  : name(a_name)
31  , can_multicast(a_can_multicast)
32  , address(a_address)
33  {}
34 
35  bool is_ipv4() const { return address.get_type() == AF_INET; }
36  bool is_ipv6() const { return address.get_type() == AF_INET6; }
37  bool exclude_from_multicast(const char* configured_interface) const;
38 
39  bool operator==(const NetworkInterfaceAddress& other) const
40  {
41  return name == other.name &&
42  can_multicast == other.can_multicast &&
43  address == other.address;
44  }
45 
46  bool operator!=(const NetworkInterfaceAddress& other) const
47  {
48  return !(*this == other);
49  }
50 
51  bool operator<(const NetworkInterfaceAddress& other) const
52  {
53  if (name != other.name) {
54  return name < other.name;
55  }
56 
57  return address < other.address;
58  }
59 
63 };
64 
67  : nia_(nia)
68  {}
69 
71  {
72  return nia_.name == other.name && nia_.address == other.address;
73  }
74 
76 };
77 
79 public:
81 
83  virtual ~NetworkConfigMonitor();
84 
86  virtual bool open() = 0;
87  virtual bool close() = 0;
88  void disconnect(RcHandle<InternalTopic<NetworkInterfaceAddress> > topic);
89 
90  protected:
91  void set(const List& list);
92  void clear();
93 
94  void set(const NetworkInterfaceAddress& nia);
95  void remove_interface(const OPENDDS_STRING& name);
96  void remove_address(const OPENDDS_STRING& name, const NetworkAddress& address);
97 
98 private:
100 
101  List list_;
102 
104 };
105 
107 
108 } // DCPS
109 } // OpenDDS
110 
112 
113 #endif // OPENDDS_DCPS_NETWORKCONFIGMONITOR_H
NetworkInterfaceAddress(const OPENDDS_STRING &a_name, bool a_can_multicast, const NetworkAddress &a_address)
bool operator==(const NetworkInterfaceAddress &other) const
bool operator()(const NetworkInterfaceAddress &other)
#define OpenDDS_Dcps_Export
Definition: dcps_export.h:24
NetworkInterfaceAddressKeyEqual(const NetworkInterfaceAddress &nia)
int close(ACE_HANDLE handle)
#define OPENDDS_STRING
ACE_HANDLE open(const char *filename, int mode, mode_t perms=ACE_DEFAULT_OPEN_PERMS, LPSECURITY_ATTRIBUTES sa=0)
#define AF_INET
bool operator!=(const NetworkInterfaceAddress &other) const
int connect(ACE_HANDLE handle, struct sockaddr *addr, int addrlen)
const char *const name
Definition: debug.cpp:60
RcHandle< InternalDataWriter< NetworkInterfaceAddress > > writer_
RcHandle< NetworkConfigMonitor > NetworkConfigMonitor_rch
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
bool operator<(const NetworkInterfaceAddress &other) const
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
typedef OPENDDS_LIST(SubsectionPair) KeyList