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 |
|
---|
49 | using std::cout;
|
---|
50 | using std::map;
|
---|
51 | using std::vector;
|
---|
52 |
|
---|
53 | namespace ariba {
|
---|
54 |
|
---|
55 | // forward declarations
|
---|
56 | class Node;
|
---|
57 | class AribaModule;
|
---|
58 | namespace 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 | */
|
---|
68 | class SideportListener {
|
---|
69 |
|
---|
70 | friend class Node;
|
---|
71 | friend class AribaModule;
|
---|
72 | friend class overlay::BaseOverlay;
|
---|
73 |
|
---|
74 | public:
|
---|
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 | * Protocols for some layer, can be combined
|
---|
168 | */
|
---|
169 | enum Protocol {
|
---|
170 | undefined = 0x0,
|
---|
171 | rfcomm = 0x1,
|
---|
172 | ipv4 = 0x2,
|
---|
173 | ipv6 = 0x3
|
---|
174 | };
|
---|
175 |
|
---|
176 | /**
|
---|
177 | * Through which protocol is a node reachable.
|
---|
178 | *
|
---|
179 | * @param node The node for which to return protocol reachability
|
---|
180 | * @return Combination of protocols
|
---|
181 | */
|
---|
182 | Protocol getReachabilityProtocol(const NodeID& node);
|
---|
183 |
|
---|
184 | protected:
|
---|
185 |
|
---|
186 | /**
|
---|
187 | * Notification function when a link has gone up.
|
---|
188 | *
|
---|
189 | * @param lnk The corresponding link id.
|
---|
190 | * @param local The local node id.
|
---|
191 | * @param remote The remote node id.
|
---|
192 | * @param spovnet The SpoVNet ID.
|
---|
193 | */
|
---|
194 | virtual void onLinkUp(
|
---|
195 | const LinkID& lnk,
|
---|
196 | const NodeID& local,
|
---|
197 | const NodeID& remote,
|
---|
198 | const SpoVNetID& spovnet
|
---|
199 | );
|
---|
200 |
|
---|
201 | /**
|
---|
202 | * Notification function when a link has gone down.
|
---|
203 | *
|
---|
204 | * @param lnk The corresponding link id.
|
---|
205 | * @param local The local node id.
|
---|
206 | * @param remote The remote node id.
|
---|
207 | * @param spovnet The SpoVNet ID.
|
---|
208 | */
|
---|
209 | virtual void onLinkDown(
|
---|
210 | const LinkID& lnk,
|
---|
211 | const NodeID& local,
|
---|
212 | const NodeID& remote,
|
---|
213 | const SpoVNetID& spovnet
|
---|
214 | );
|
---|
215 |
|
---|
216 | /**
|
---|
217 | * Notification function when a link has changed
|
---|
218 | *
|
---|
219 | * @param lnk The corresponding link id.
|
---|
220 | * @param local The local node id.
|
---|
221 | * @param remote The remote node id.
|
---|
222 | * @param spovnet The SpoVNet ID.
|
---|
223 | */
|
---|
224 | virtual void onLinkChanged(
|
---|
225 | const LinkID& lnk,
|
---|
226 | const NodeID& local,
|
---|
227 | const NodeID& remote,
|
---|
228 | const SpoVNetID& spovnet
|
---|
229 | );
|
---|
230 |
|
---|
231 | /**
|
---|
232 | * Notification function when a link has failed
|
---|
233 | *
|
---|
234 | * @param lnk The corresponding link id.
|
---|
235 | * @param local The local node id.
|
---|
236 | * @param remote The remote node id.
|
---|
237 | * @param spovnet The SpoVNet ID.
|
---|
238 | */
|
---|
239 | virtual void onLinkFail(
|
---|
240 | const LinkID& lnk,
|
---|
241 | const NodeID& local,
|
---|
242 | const NodeID& remote,
|
---|
243 | const SpoVNetID& spovnet
|
---|
244 | );
|
---|
245 |
|
---|
246 | private:
|
---|
247 |
|
---|
248 | /**
|
---|
249 | * Configure the sideport with the correct base overlay.
|
---|
250 | *
|
---|
251 | * @param _overlay The BaseOverlay where to attach the sideport.
|
---|
252 | */
|
---|
253 | void configure(
|
---|
254 | overlay::BaseOverlay* _overlay
|
---|
255 | );
|
---|
256 |
|
---|
257 | /**
|
---|
258 | * The configured BaseOverlay where
|
---|
259 | * the sideport is attached to.
|
---|
260 | */
|
---|
261 | overlay::BaseOverlay* overlay;
|
---|
262 |
|
---|
263 | };
|
---|
264 |
|
---|
265 | } // namespace ariba
|
---|
266 |
|
---|
267 | #endif // SIDEPORTLISTENER_H_
|
---|