source: source/ariba/SideportListener.h@ 5507

Last change on this file since 5507 was 5436, checked in by Christoph Mayer, 15 years ago
File size: 6.6 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 the neighbots in the overlay structure
140 * @return A vector of NodeIDs of the neighbors
141 */
142 vector<NodeID> getOverlayNeighbors(bool deep = true);
143
144 /**
145 * Is this node acting as a relay for us
146 *
147 * @param node The node in question
148 * @return true, if this node is relaying for us
149 */
150 bool isRelayingNode(const NodeID& node);
151
152 /**
153 * Is this node only reachable for us through a relay?
154 *
155 * @param node The node in question
156 * @return true, if we reach this node only over a relay
157 */
158 bool isRelayedNode(const NodeID& node);
159
160
161 /**
162 * Protocols for some layer, can be combined
163 */
164 enum Protocol {
165 undefined = 0x0,
166 rfcomm = 0x1,
167 ipv4 = 0x2,
168 ipv6 = 0x4,
169 udp = 0x8,
170 tcp = 0x16,
171 };
172
173 /**
174 * Through which protocol is a node reachable.
175 *
176 * @param node The node for which to return protocol reachability
177 * @return Combination of protocols
178 */
179 Protocol getReachabilityProtocol(const NodeID& node);
180
181protected:
182
183 /**
184 * Notification function when a link has gone up.
185 *
186 * @param lnk The corresponding link id.
187 * @param local The local node id.
188 * @param remote The remote node id.
189 * @param spovnet The SpoVNet ID.
190 */
191 virtual void onLinkUp(
192 const LinkID& lnk,
193 const NodeID& local,
194 const NodeID& remote,
195 const SpoVNetID& spovnet
196 );
197
198 /**
199 * Notification function when a link has gone down.
200 *
201 * @param lnk The corresponding link id.
202 * @param local The local node id.
203 * @param remote The remote node id.
204 * @param spovnet The SpoVNet ID.
205 */
206 virtual void onLinkDown(
207 const LinkID& lnk,
208 const NodeID& local,
209 const NodeID& remote,
210 const SpoVNetID& spovnet
211 );
212
213 /**
214 * Notification function when a link has changed
215 *
216 * @param lnk The corresponding link id.
217 * @param local The local node id.
218 * @param remote The remote node id.
219 * @param spovnet The SpoVNet ID.
220 */
221 virtual void onLinkChanged(
222 const LinkID& lnk,
223 const NodeID& local,
224 const NodeID& remote,
225 const SpoVNetID& spovnet
226 );
227
228 /**
229 * Notification function when a link has failed
230 *
231 * @param lnk The corresponding link id.
232 * @param local The local node id.
233 * @param remote The remote node id.
234 * @param spovnet The SpoVNet ID.
235 */
236 virtual void onLinkFail(
237 const LinkID& lnk,
238 const NodeID& local,
239 const NodeID& remote,
240 const SpoVNetID& spovnet
241 );
242
243private:
244
245 /**
246 * Configure the sideport with the correct base overlay.
247 *
248 * @param _overlay The BaseOverlay where to attach the sideport.
249 */
250 void configure(
251 overlay::BaseOverlay* _overlay
252 );
253
254 /**
255 * The configured BaseOverlay where
256 * the sideport is attached to.
257 */
258 overlay::BaseOverlay* overlay;
259
260};
261
262} // namespace ariba
263
264#endif // SIDEPORTLISTENER_H_
Note: See TracBrowser for help on using the repository browser.