source: source/ariba/SideportListener.h@ 4948

Last change on this file since 4948 was 4751, checked in by Christoph Mayer, 15 years ago

sideport protocol information

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