source: source/ariba/SideportListener.h@ 10752

Last change on this file since 10752 was 10653, checked in by Michael Tänzer, 12 years ago

Merge the ASIO branch back into trunk

File size: 6.7 KB
Line 
1// [License]
2// The Ariba-Underlay Copyright
3//
4// Copyright (c) 2008-2009, Institute of Telematics, UniversitÀt Karlsruhe (TH)
5//
6// Institute of Telematics
7// UniversitÀt Karlsruhe (TH)
8// Zirkel 2, 76128 Karlsruhe
9// Germany
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
22// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OF TELEMATICS OR
25// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32//
33// The views and conclusions contained in the software and documentation
34// are those of the authors and should not be interpreted as representing
35// official policies, either expressed or implied, of the Institute of
36// Telematics.
37// [License]
38
39#ifndef SIDEPORTLISTENER_H_
40#define SIDEPORTLISTENER_H_
41
42#include <vector>
43#include <map>
44#include <iostream>
45#include <boost/foreach.hpp>
46#include "Identifiers.h"
47#include "CommunicationListener.h"
48
49using std::map;
50using std::vector;
51
52namespace ariba {
53
54// forward declarations
55class Node;
56class AribaModule;
57namespace overlay {
58 class BaseOverlay;
59}
60
61/**
62 * \addtogroup public
63 * @{
64 *
65 * A sideport class to gather advanced information about nodes, links,
66 * their endpoints and get information about all link activity on a node.
67 *
68 * @author Christoph Mayer <mayer@tm.uka.de>
69 */
70class SideportListener {
71
72 friend class Node;
73 friend class AribaModule;
74 friend class overlay::BaseOverlay;
75
76public:
77
78 /**
79 * A default object of the SideportListener that has empty
80 * event functions and will return invalid information.
81 */
82 static SideportListener DEFAULT;
83
84 /**
85 * Constructor of the SideportListener.
86 */
87 SideportListener();
88
89 /**
90 * Virtual Desctructor for the SideportListener.
91 */
92 virtual ~SideportListener();
93
94 /**
95 * Get a descriptive string that identifies
96 * the remote endpoint for the given link.
97 *
98 * @param link The link to query endpoint information for.
99 * @return A descriptive endpoint information.
100 */
101 string getEndpointDescription(
102 const LinkID& link
103 ) const;
104
105 /**
106 * Get a descriprive string that identifiers the remote node.
107 *
108 * @param node The node id to query endpoint information.
109 * @return A descriptive endpoint information.
110 */
111 string getEndpointDescription(
112 const NodeID& node = NodeID::UNSPECIFIED
113 ) const;
114
115 /**
116 * Get the remote endpoint node id for the given string,
117 * or the local nodeid for an unspecified link.
118 *
119 * @param link The link to get the remote node.
120 * @return The nodeid of the remote end of the link
121 * or the local nodeid for an unspecified link.
122 */
123 const NodeID& getNodeID(
124 const LinkID& link = LinkID::UNSPECIFIED
125 ) const;
126
127 /**
128 * Get all links that end at the specified node id.
129 * Or all links from the local node when the node id
130 * is set to unspecified.
131 *
132 * @param node The remote node to query all links or unspecified
133 * for all local starting links
134 * @return A vector of link ids.
135 */
136 vector<LinkID> getLinkIDs(
137 const NodeID& node = NodeID::UNSPECIFIED
138 ) const;
139
140 /**
141 * Get html presentation of the links.
142 * @return html of links
143 */
144 string getHtmlLinks();
145
146 /**
147 * Get the neighbots in the overlay structure
148 * @return A vector of NodeIDs of the neighbors
149 */
150 vector<NodeID> getOverlayNeighbors(bool deep = true);
151
152 /**
153 * Is this node acting as a relay for us
154 *
155 * @param node The node in question
156 * @return true, if this node is relaying for us
157 */
158 bool isRelayingNode(const NodeID& node);
159
160 /**
161 * Is this node only reachable for us through a relay?
162 *
163 * @param node The node in question
164 * @return true, if we reach this node only over a relay
165 */
166 bool isRelayedNode(const NodeID& node);
167
168 /**
169 * Protocols for some layer, can be combined
170 */
171 enum Protocol {
172 undefined = 0x0,
173 rfcomm = 0x1,
174 ipv4 = 0x2,
175 ipv6 = 0x3
176 };
177
178 /**
179 * Through which protocol is a node reachable.
180 *
181 * @param node The node for which to return protocol reachability
182 * @return Combination of protocols
183 */
184 Protocol getReachabilityProtocol(const NodeID& node);
185
186protected:
187
188 /**
189 * Notification function when a link has gone up.
190 *
191 * @param lnk The corresponding link id.
192 * @param local The local node id.
193 * @param remote The remote node id.
194 * @param spovnet The SpoVNet ID.
195 */
196 virtual void onLinkUp(
197 const LinkID& lnk,
198 const NodeID& local,
199 const NodeID& remote,
200 const SpoVNetID& spovnet
201 );
202
203 /**
204 * Notification function when a link has gone down.
205 *
206 * @param lnk The corresponding link id.
207 * @param local The local node id.
208 * @param remote The remote node id.
209 * @param spovnet The SpoVNet ID.
210 */
211 virtual void onLinkDown(
212 const LinkID& lnk,
213 const NodeID& local,
214 const NodeID& remote,
215 const SpoVNetID& spovnet
216 );
217
218 /**
219 * Notification function when a link has changed
220 *
221 * @param lnk The corresponding link id.
222 * @param local The local node id.
223 * @param remote The remote node id.
224 * @param spovnet The SpoVNet ID.
225 */
226 virtual void onLinkChanged(
227 const LinkID& lnk,
228 const NodeID& local,
229 const NodeID& remote,
230 const SpoVNetID& spovnet
231 );
232
233 /**
234 * Notification function when a link has failed
235 *
236 * @param lnk The corresponding link id.
237 * @param local The local node id.
238 * @param remote The remote node id.
239 * @param spovnet The SpoVNet ID.
240 */
241 virtual void onLinkFail(
242 const LinkID& lnk,
243 const NodeID& local,
244 const NodeID& remote,
245 const SpoVNetID& spovnet
246 );
247
248private:
249
250 /**
251 * Configure the sideport with the correct base overlay.
252 *
253 * @param _overlay The BaseOverlay where to attach the sideport.
254 */
255 void configure(
256 overlay::BaseOverlay* _overlay
257 );
258
259 /**
260 * The configured BaseOverlay where
261 * the sideport is attached to.
262 */
263 overlay::BaseOverlay* overlay;
264
265};
266
267} // namespace ariba
268
269/** @} */
270
271#endif // SIDEPORTLISTENER_H_
Note: See TracBrowser for help on using the repository browser.