An Overlay-based
Virtual Network Substrate
SpoVNet

source: source/ariba/SideportListener.h @ 5786

Last change on this file since 5786 was 5786, checked in by Christoph Mayer, 14 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 = 0x3
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
179protected:
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
241private:
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_
Note: See TracBrowser for help on using the repository browser.