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