| 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 |
|
---|
| 47 | using std::map;
|
---|
| 48 | using std::vector;
|
---|
| 49 |
|
---|
| 50 | namespace ariba {
|
---|
| 51 |
|
---|
| 52 | // forward declerations
|
---|
| 53 | class Node;
|
---|
| 54 | class AribaModule;
|
---|
| 55 | namespace 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 | */
|
---|
| 65 | class SideportListener {
|
---|
| 66 |
|
---|
| 67 | friend class Node;
|
---|
| 68 | friend class AribaModule;
|
---|
| 69 | friend class overlay::BaseOverlay;
|
---|
| 70 |
|
---|
| 71 | public:
|
---|
| 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 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 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 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 | protected:
|
---|
| 152 |
|
---|
| 153 | /**
|
---|
| 154 | * Notification function when a link has gone up.
|
---|
| 155 | *
|
---|
| 156 | * @param lnk The corresponding link id.
|
---|
| 157 | * @param local The local node id.
|
---|
| 158 | * @param remote The remote node id.
|
---|
| 159 | * @param spovnet The SpoVNet ID.
|
---|
| 160 | */
|
---|
| 161 | virtual void onLinkUp(
|
---|
| 162 | const LinkID& lnk,
|
---|
| 163 | const NodeID& local,
|
---|
| 164 | const NodeID& remote,
|
---|
| 165 | const SpoVNetID& spovnet
|
---|
| 166 | );
|
---|
| 167 |
|
---|
| 168 | /**
|
---|
| 169 | * Notification function when a link has gone down.
|
---|
| 170 | *
|
---|
| 171 | * @param lnk The corresponding link id.
|
---|
| 172 | * @param local The local node id.
|
---|
| 173 | * @param remote The remote node id.
|
---|
| 174 | * @param spovnet The SpoVNet ID.
|
---|
| 175 | */
|
---|
| 176 | virtual void onLinkDown(
|
---|
| 177 | const LinkID& lnk,
|
---|
| 178 | const NodeID& local,
|
---|
| 179 | const NodeID& remote,
|
---|
| 180 | const SpoVNetID& spovnet
|
---|
| 181 | );
|
---|
| 182 |
|
---|
| 183 | /**
|
---|
| 184 | * Notification function when a link has changed
|
---|
| 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 onLinkChanged(
|
---|
| 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 failed
|
---|
| 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 onLinkFail(
|
---|
| 207 | const LinkID& lnk,
|
---|
| 208 | const NodeID& local,
|
---|
| 209 | const NodeID& remote,
|
---|
| 210 | const SpoVNetID& spovnet
|
---|
| 211 | );
|
---|
| 212 |
|
---|
| 213 | private:
|
---|
| 214 |
|
---|
| 215 | /**
|
---|
| 216 | * Configure the sideport with the correct base overlay.
|
---|
| 217 | *
|
---|
| 218 | * @param _overlay The BaseOverlay where to attach the sideport.
|
---|
| 219 | */
|
---|
| 220 | void configure(
|
---|
| 221 | overlay::BaseOverlay* _overlay
|
---|
| 222 | );
|
---|
| 223 |
|
---|
| 224 | /**
|
---|
| 225 | * The configured BaseOverlay where
|
---|
| 226 | * the sideport is attached to.
|
---|
| 227 | */
|
---|
| 228 | overlay::BaseOverlay* overlay;
|
---|
| 229 |
|
---|
| 230 | };
|
---|
| 231 |
|
---|
| 232 | } // namespace ariba
|
---|
| 233 |
|
---|
| 234 | #endif // SIDEPORTLISTENER_H_
|
---|