Changeset 3374 for source


Ignore:
Timestamp:
May 7, 2009, 4:51:31 PM (16 years ago)
Author:
Christoph Mayer
Message:

-Integration of Branch 20090424-mayer-sideport

Location:
source/ariba
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/AribaModule.cpp

    r3037 r3374  
    4444
    4545// ariba includes
     46#include "ariba/SideportListener.h"
    4647#include "ariba/utility/misc/Helper.h"
    4748#include "ariba/utility/misc/StringFormat.h"
     
    5657namespace ariba {
    5758
    58 AribaModule::AribaModule() {
     59AribaModule::AribaModule()
     60        : base_comm(NULL), sideport_sniffer(NULL),
     61                ip_addr(NULL), started(false) {
    5962
    6063        // init with default values
    61         this->base_comm = NULL;
    62         this->ip_addr = NULL;
     64
    6365        this->tcp_port = 41402;
    6466        this->udp_port = 41402;
    65         this->started = false;
    6667}
    6768
     
    145146}
    146147
     148void AribaModule::registerSideportListener(SideportListener* sideport){
     149        sideport_sniffer = sideport;
     150}
     151
    147152// @see Module.h
    148153void AribaModule::initialize() {
  • source/ariba/AribaModule.h

    r3055 r3374  
    4444#include <boost/foreach.hpp>
    4545
    46 // usings
    4746using std::vector;
    4847using std::string;
     
    5049// forward declaration
    5150namespace ariba {
    52 class AribaModule;
     51        class AribaModule;
     52        class SideportListener;
    5353}
    5454
     
    5959namespace ariba {
    6060
    61 // forward declarations of old interface
    6261namespace communication {
    6362class EndpointDescriptor;
     
    119118        void addBootstrapHints(string bootinfo);
    120119
     120        /**
     121         * Register a sideport for sniffing on communication events
     122         * and get advanced information. The sniffer is attached to
     123         * every node that is created on the module. Only one such
     124         * sniffer can be active system-wide, a new call to this
     125         * register function will only attach the sniffer to nodes
     126         * created after the registration call.
     127         *
     128         * @param sideport The SideportListener to integrate
     129         */
     130        void registerSideportListener(SideportListener* sideport);
     131
    121132        // --- module implementation ---
    122133
     
    185196
    186197        communication::BaseCommunication* base_comm;
     198        SideportListener* sideport_sniffer;
    187199
    188200        // TODO: use "abstract" representations here!
  • source/ariba/CommunicationListener.cpp

    r3071 r3374  
    4141namespace ariba {
    4242
     43CommunicationListener CommunicationListener::DEFAULT;
     44
    4345CommunicationListener::CommunicationListener() {
    4446}
     
    6870}
    6971
     72bool CommunicationListener::onEnableSideportListener() {
     73        return true;
     74}
     75
    7076// --- extended message functionality ---
    7177//void CommunicationListener::onLinkQoSChanged(const LinkID& l, const NodeID& r,
  • source/ariba/CommunicationListener.h

    r3071 r3374  
    5656 */
    5757class CommunicationListener {
     58
    5859        friend class ariba::overlay::BaseOverlay;
     60        friend class Node;
     61
     62        static CommunicationListener DEFAULT;
     63
    5964protected:
     65
    6066        CommunicationListener();
    6167        virtual ~CommunicationListener();
     
    7884                        const LinkID& lnk = LinkID::UNSPECIFIED);
    7985
     86        // --- sniffing related method ---
     87        virtual bool onEnableSideportListener();
     88
    8089        // --- extended message functionality ---
    8190        // virtual void onLinkQoSChanged(const LinkID& lnk, const NodeID& remote,
  • source/ariba/Makefile.am

    r3055 r3374  
    7373  Node.cpp \
    7474  NodeListener.cpp \
     75  SideportListener.cpp \
    7576  SpoVNetProperties.cpp
    7677
     
    8788  Node.h \
    8889  NodeListener.h \
     90  SideportListener.h \
    8991  SpoVNetProperties.h
    9092
  • source/ariba/Node.cpp

    r3071 r3374  
    146146
    147147bool Node::bind(CommunicationListener* listener, const ServiceID& sid) {
    148         return base_overlay->bind(listener, sid);
     148        // bind the listener
     149        bool ret = base_overlay->bind(listener, sid);
     150
     151        // now that we have a listener, we can ask if sniffing is ok
     152        if( ariba_mod.sideport_sniffer != NULL ){
     153                bool allow = listener->onEnableSideportListener();
     154                base_overlay->registerSidePort(ariba_mod.sideport_sniffer);
     155        }
     156
     157        return ret;
    149158}
    150159
  • source/ariba/Node.h

    r3071 r3374  
    5757#include "CommunicationListener.h"
    5858#include "DataMessage.h"
     59#include "SideportListener.h"
    5960
    6061using std::vector;
  • source/ariba/ariba.h

    r3055 r3374  
    5454#include "Node.h"
    5555#include "NodeListener.h"
     56#include "SideportListener.h"
    5657#include "SpoVNetProperties.h"
    5758
  • source/ariba/overlay/BaseOverlay.cpp

    r3071 r3374  
    4242#include "ariba/NodeListener.h"
    4343#include "ariba/CommunicationListener.h"
     44#include "ariba/SideportListener.h"
    4445
    4546namespace ariba {
     
    4950
    5051BaseOverlay::BaseOverlay()
    51         : bc(NULL), overlayInterface(NULL),
    52                 nodeId(NodeID::UNSPECIFIED), spovnetId(SpoVNetID::UNSPECIFIED),
    53                 initiatorLink(LinkID::UNSPECIFIED), state(BaseOverlayStateInvalid){
     52        : bc(NULL), overlayInterface(NULL), nodeId(NodeID::UNSPECIFIED),
     53                spovnetId(SpoVNetID::UNSPECIFIED), initiatorLink(LinkID::UNSPECIFIED),
     54                state(BaseOverlayStateInvalid), sideport(&SideportListener::DEFAULT){
    5455}
    5556
     
    230231
    231232        CommunicationListener* receiver = communicationListeners.get( service );
     233        assert( receiver != NULL );
     234
    232235        LinkItem item (link, NodeID::UNSPECIFIED, service, receiver);
    233236        linkMapping.insert( make_pair(link, item) );
     
    251254        bc->dropLink( link );
    252255
    253         if( item.interface != NULL )
    254                 item.interface->onLinkDown( link, item.node );
     256        item.interface->onLinkDown( link, item.node );
     257        sideport->onLinkDown(link, this->nodeId, item.node, this->spovnetId );
    255258}
    256259
     
    352355        communicationListeners.registerItem( listener, sid );
    353356        return true;
     357}
     358
     359bool BaseOverlay::registerSidePort(SideportListener* _sideport){
     360        sideport = _sideport;
     361        _sideport->configure( this );
     362}
     363
     364bool BaseOverlay::unregisterSidePort(SideportListener* _sideport){
     365        sideport = &SideportListener::DEFAULT;
    354366}
    355367
     
    442454        if( i == linkMapping.end() ){
    443455
    444                 LinkItem item (id, NodeID::UNSPECIFIED, ServiceID::UNSPECIFIED, NULL );
     456                LinkItem item (id, NodeID::UNSPECIFIED, ServiceID::UNSPECIFIED, &CommunicationListener::DEFAULT );
    445457                linkMapping.insert( make_pair(id, item) );
    446458
     
    487499        }
    488500
    489         if( i->second.interface != NULL )
    490                 i->second.interface->onLinkDown( id, i->second.node );
     501        i->second.interface->onLinkDown( id, i->second.node );
     502        sideport->onLinkDown( id, this->nodeId, i->second.node, this->spovnetId );
    491503
    492504        linkMapping.erase( i );
     
    504516        if( i == linkMapping.end() ) return;
    505517
    506         if( i->second.interface != NULL ){
    507                 i->second.interface->onLinkChanged( id, i->second.node );
    508                 // call onLinkQoSChanged?
    509         }
     518        i->second.interface->onLinkChanged( id, i->second.node );
     519        sideport->onLinkChanged( id, this->nodeId, i->second.node, this->spovnetId );
     520
     521        // TODO call onLinkQoSChanged?
    510522
    511523        i->second.markused();
     
    523535        if( i == linkMapping.end() ) return;
    524536
    525         if( i->second.interface != NULL )
    526                 i->second.interface->onLinkFail( id, i->second.node );
     537        i->second.interface->onLinkFail( id, i->second.node );
     538        sideport->onLinkFail( id, this->nodeId, i->second.node, this->spovnetId );
    527539
    528540        i->second.markused();
     
    541553
    542554        // TODO: convert QoSParameterSet to the LinkProperties properties
    543         if( i->second.interface != NULL ){
    544                 // TODO: currently not in the interface: i->second.interface->onLinkQoSChanged( id, i->second.node, LinkProperties::DEFAULT );
    545         }
     555        // TODO: currently not in the interface: i->second.interface->onLinkQoSChanged( id, i->second.node, LinkProperties::DEFAULT );
    546556
    547557        i->second.markused();
     
    799809
    800810                CommunicationListener* iface = communicationListeners.get( service );
    801                 if( iface == NULL ){
     811                if( iface == NULL || iface == &CommunicationListener::DEFAULT ){
    802812                        logging_warn( "linkup event for service that has been registered with a NULL interface" );
    803813                        return true;
     
    812822
    813823                if( iface->onLinkRequest(sourcenode) ){
     824
     825                        // call the notification functions
    814826                        iface->onLinkUp( link, sourcenode );
     827                        sideport->onLinkUp( link, nodeId, sourcenode, this->spovnetId );
     828
    815829                } else {
    816830                        // prevent onLinkDown calls to the service
    817                         i->second.interface = NULL;
     831                        i->second.interface = &CommunicationListener::DEFAULT;
    818832                        // drop the link
    819833                        dropLink( link );
     
    950964}
    951965
     966vector<LinkID> BaseOverlay::getLinkIDs( const NodeID& nid ) const {
     967
     968        vector<LinkID> linkvector;
     969
     970        BOOST_FOREACH( LinkPair item, linkMapping ){
     971                if( item.second.node == nid || nid == NodeID::UNSPECIFIED ){
     972                        linkvector.push_back( item.second.link );
     973                }
     974        }
     975
     976        return linkvector;
     977}
     978
    952979void BaseOverlay::incomingRouteMessage(Message* msg){
    953980        // gets handled as normal data message
  • source/ariba/overlay/BaseOverlay.h

    r3071 r3374  
    7070        class NodeListener;
    7171        class CommunicationListener;
     72        class SideportListener;
    7273        namespace utility {
    7374                class OvlVis;
     
    220221
    221222        /**
     223         * TODO
     224         */
     225        bool registerSidePort(SideportListener* _sideport);
     226
     227        /**
     228         * TODO
     229         */
     230        bool unregisterSidePort(SideportListener* _sideport);
     231
     232        /**
    222233         * Returns the own nodeID or the NodeID of the specified link
    223234         *
     
    226237         */
    227238        const NodeID& getNodeID( const LinkID& lid = LinkID::UNSPECIFIED ) const ;
     239
     240        /**
     241         * Return all Links for the specified remote nodeid, or all links when
     242         * the node id given is set to unspecified
     243         *
     244         * @param nid The node id to request links for, or unspecified for all links
     245         * @return a vector that contains all the link ids requested
     246         */
     247        vector<LinkID> getLinkIDs( const NodeID& nid = NodeID::UNSPECIFIED ) const;
    228248
    229249        /**
     
    342362
    343363        /**
     364         * TODO
     365         */
     366        SideportListener* sideport;
     367
     368        /**
    344369         * The abstract overlay interface that implements
    345370         * the overlay specific functionality.
     
    387412                static const LinkItem UNSPECIFIED;
    388413
     414                LinkItem()
     415                        : link(LinkID::UNSPECIFIED), node(NodeID::UNSPECIFIED),
     416                                service(ServiceID::UNSPECIFIED), interface(&CommunicationListener::DEFAULT),
     417                                autolink(false), lastuse(0){
     418                }
     419
    389420                LinkItem( const LinkID& _link, const NodeID& _node,
    390421                                const ServiceID& _service, CommunicationListener* _interface )
    391422                        : link( _link ), node( _node ), service( _service ), interface( _interface ),
    392423                                autolink( false ), lastuse( time(NULL) ) {
     424
     425                        assert( _interface != NULL );
    393426                }
    394427
Note: See TracChangeset for help on using the changeset viewer.