source: source/ariba/SideportListener.h@ 6919

Last change on this file since 6919 was 5920, checked in by Christoph Mayer, 15 years ago
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::cout;
50using std::map;
51using std::vector;
52
53namespace ariba {
54
55// forward declerations
56class Node;
57class AribaModule;
58namespace overlay {
59 class BaseOverlay;
60}
61
62/**
63 * A sideport class to gather advanced information about nodes, links,
64 * their endpoints and get information about all link activity on a node.
65 *
66 * @author Christoph Mayer <mayer@tm.uka.de>
67 */
68class SideportListener {
69
70 friend class Node;
71 friend class AribaModule;
72 friend class overlay::BaseOverlay;
73
74public:
75
76 /**
77 * A default object of the SideportListener that has empty
78 * event functions and will return invalid information.
79 */
80 static SideportListener DEFAULT;
81
82 /**
83 * Constructor of the SideportListener.
84 */
85 SideportListener();
86
87 /**
88 * Virtual Desctructor for the SideportListener.
89 */
90 virtual ~SideportListener();
91
92 /**
93 * Get a descriptive string that identifies
94 * the remote endpoint for the given link.
95 *
96 * @param link The link to query endpoint information for.
97 * @return A descriptive endpoint information.
98 */
99 string getEndpointDescription(
100 const LinkID& link
101 ) const;
102
103 /**
104 * Get a descriprive string that identifiers the remote node.
105 *
106 * @param node The node id to query endpoint information.
107 * @return A descriptive endpoint information.
108 */
109 string getEndpointDescription(
110 const NodeID& node = NodeID::UNSPECIFIED
111 ) const;
112
113 /**
114 * Get the remote endpoint node id for the given string,
115 * or the local nodeid for an unspecified link.
116 *
117 * @param link The link to get the remote node.
118 * @return The nodeid of the remote end of the link
119 * or the local nodeid for an unspecified link.
120 */
121 const NodeID& getNodeID(
122 const LinkID& link = LinkID::UNSPECIFIED
123 ) const;
124
125 /**
126 * Get all links that end at the specified node id.
127 * Or all links from the local node when the node id
128 * is set to unspecified.
129 *
130 * @param node The remote node to query all links or unspecified
131 * for all local starting links
132 * @return A vector of link ids.
133 */
134 vector<LinkID> getLinkIDs(
135 const NodeID& node = NodeID::UNSPECIFIED
136 ) const;
137
138 /**
139 * Get html presentation of the links.
140 * @return html of links
141 */
142 string getHtmlLinks();
143
144 /**
145 * Get the neighbots in the overlay structure
146 * @return A vector of NodeIDs of the neighbors
147 */
148 vector<NodeID> getOverlayNeighbors(bool deep = true);
149
150 /**
151 * Is this node acting as a relay for us
152 *
153 * @param node The node in question
154 * @return true, if this node is relaying for us
155 */
156 bool isRelayingNode(const NodeID& node);
157
158 /**
159 * Is this node only reachable for us through a relay?
160 *
161 * @param node The node in question
162 * @return true, if we reach this node only over a relay
163 */
164 bool isRelayedNode(const NodeID& node);
165
166
167 /**
168 * Protocols for some layer, can be combined
169 */
170 enum Protocol {
171 undefined = 0x0,
172 rfcomm = 0x1,
173 ipv4 = 0x2,
174 ipv6 = 0x3
175 };
176
177 /**
178 * Through which protocol is a node reachable.
179 *
180 * @param node The node for which to return protocol reachability
181 * @return Combination of protocols
182 */
183 Protocol getReachabilityProtocol(const NodeID& node);
184
185protected:
186
187 /**
188 * Notification function when a link has gone up.
189 *
190 * @param lnk The corresponding link id.
191 * @param local The local node id.
192 * @param remote The remote node id.
193 * @param spovnet The SpoVNet ID.
194 */
195 virtual void onLinkUp(
196 const LinkID& lnk,
197 const NodeID& local,
198 const NodeID& remote,
199 const SpoVNetID& spovnet
200 );
201
202 /**
203 * Notification function when a link has gone down.
204 *
205 * @param lnk The corresponding link id.
206 * @param local The local node id.
207 * @param remote The remote node id.
208 * @param spovnet The SpoVNet ID.
209 */
210 virtual void onLinkDown(
211 const LinkID& lnk,
212 const NodeID& local,
213 const NodeID& remote,
214 const SpoVNetID& spovnet
215 );
216
217 /**
218 * Notification function when a link has changed
219 *
220 * @param lnk The corresponding link id.
221 * @param local The local node id.
222 * @param remote The remote node id.
223 * @param spovnet The SpoVNet ID.
224 */
225 virtual void onLinkChanged(
226 const LinkID& lnk,
227 const NodeID& local,
228 const NodeID& remote,
229 const SpoVNetID& spovnet
230 );
231
232 /**
233 * Notification function when a link has failed
234 *
235 * @param lnk The corresponding link id.
236 * @param local The local node id.
237 * @param remote The remote node id.
238 * @param spovnet The SpoVNet ID.
239 */
240 virtual void onLinkFail(
241 const LinkID& lnk,
242 const NodeID& local,
243 const NodeID& remote,
244 const SpoVNetID& spovnet
245 );
246
247private:
248
249 /**
250 * Configure the sideport with the correct base overlay.
251 *
252 * @param _overlay The BaseOverlay where to attach the sideport.
253 */
254 void configure(
255 overlay::BaseOverlay* _overlay
256 );
257
258 /**
259 * The configured BaseOverlay where
260 * the sideport is attached to.
261 */
262 overlay::BaseOverlay* overlay;
263
264};
265
266} // namespace ariba
267
268#endif // SIDEPORTLISTENER_H_
Note: See TracBrowser for help on using the repository browser.