Changeset 4836 for source/ariba


Ignore:
Timestamp:
Jul 9, 2009, 1:50:37 PM (15 years ago)
Author:
Christoph Mayer
Message:

einige avahi fixes und ablauf

Location:
source/ariba
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/Makefile.am

    r4733 r4836  
    258258
    259259libariba_la_SOURCES += \
    260   overlay/BaseOverlay.cpp
    261 
    262 nobase_libariba_la_HEADERS += \
    263   overlay/BaseOverlay.h
     260  overlay/BaseOverlay.cpp \
     261  overlay/OverlayBootstrap.cpp
     262
     263nobase_libariba_la_HEADERS += \
     264  overlay/BaseOverlay.h \
     265  overlay/OverlayBootstrap.h
    264266
    265267#------------> overlay :: messages
  • source/ariba/communication/EndpointDescriptor.cpp

    r3705 r4836  
    6363}
    6464
     65EndpointDescriptor::EndpointDescriptor(const string str) {
     66        using namespace boost::xpressive;
     67        using namespace ariba::utility::string_format;
     68        using namespace ariba::utility::Helper;
     69        using namespace std;
     70
     71        locator = NULL;
     72        isUnspec = true;
     73
     74        smatch match;
     75        if (regex_search(str, match, robjects)) {
     76                regex_nav nav = match;
     77                for (int i=0; i<nav.size(); i++) {
     78                        string type = nav[i][robject_id].str();
     79                        if (type=="ip") {
     80                                string ip = nav[i][robject_data].str();
     81                                ip = ip.substr(1,ip.size()-2);
     82                                this->locator = new IPv4Locator();
     83                                this->locator->setIP(ip);
     84                                this->isUnspec = false;
     85                        } else
     86                        if (type=="tcp") {
     87                                string port = nav[i][robject_data][rfields][1].str();
     88                                port = port.substr(1,port.size()-2);
     89                                this->locator->setPort(stoi(port));
     90                        }
     91                }
     92        }
     93}
     94
    6595EndpointDescriptor::~EndpointDescriptor() {
    6696}
     
    80110
    81111EndpointDescriptor* EndpointDescriptor::fromString( string str ) {
    82         using namespace boost::xpressive;
    83         using namespace ariba::utility::string_format;
    84         using namespace ariba::utility::Helper;
    85         using namespace std;
    86 
    87         EndpointDescriptor* ep = NULL;
    88         smatch match;
    89         if (regex_search(str, match, robjects)) {
    90                 regex_nav nav = match;
    91                 for (int i=0; i<nav.size(); i++) {
    92                         string type = nav[i][robject_id].str();
    93                         if (type=="ip") {
    94                                 string ip = nav[i][robject_data].str();
    95                                 ip = ip.substr(1,ip.size()-2);
    96                                 ep = new EndpointDescriptor();
    97                                 ep->locator = new IPv4Locator();
    98                                 ep->locator->setIP(ip);
    99                                 ep->isUnspec = false;
    100                         } else
    101                         if (type=="tcp") {
    102                                 string port = nav[i][robject_data][rfields][1].str();
    103                                 port = port.substr(1,port.size()-2);
    104                                 ep->locator->setPort(stoi(port));
    105                         }
    106                 }
    107         }
    108         return ep;
     112        return new EndpointDescriptor( str );
    109113}
    110114
  • source/ariba/communication/EndpointDescriptor.h

    r4625 r4836  
    6969        EndpointDescriptor(const EndpointDescriptor& rh);
    7070        EndpointDescriptor(const Locator* _locator);
     71        EndpointDescriptor(const string str);
    7172
    7273        /**
  • source/ariba/overlay/BaseOverlay.cpp

    r4762 r4836  
    112112                        " with nodeid " << nodeId.toString());
    113113
     114        spovnetId = id;
     115        state = BaseOverlayStateJoinInitiated;
     116
     117
     118        //
     119        // start bootstrapping for spovnetid
     120        //
     121
     122        overlayBootstrap.start( this, spovnetId, nodeId );
     123        overlayBootstrap.publish( bc->getEndpointDescriptor() );
     124
    114125        //
    115126        // contact the spovnet initiator and request
     
    120131        // but first, we have to establish a link to the initiator...
    121132        //
    122 
    123         spovnetId = id;
    124         state = BaseOverlayStateJoinInitiated;
    125133
    126134        initiatorLink = bc->establishLink( bootstrapEp );
  • source/ariba/overlay/BaseOverlay.h

    r3712 r4836  
    6363#include "ariba/overlay/modules/OverlayFactory.h"
    6464#include "ariba/overlay/modules/OverlayStructureEvents.h"
     65#include "ariba/overlay/OverlayBootstrap.h"
    6566
    6667// forward declarations
    6768namespace ariba {
    68 class NodeListener;
    69 class CommunicationListener;
    70 class SideportListener;
    71 namespace utility {
    72 class OvlVis;
    73 }
     69  class NodeListener;
     70  class CommunicationListener;
     71  class SideportListener;
     72  namespace utility {
     73    class OvlVis;
     74  }
    7475}
    7576
     
    8384using std::deque;
    8485
     86// ariba interface
    8587using ariba::NodeListener;
    8688using ariba::CommunicationListener;
     89
     90// overlay
     91using ariba::overlay::OverlayBootstrap;
    8792
    8893// communication
     
    497502        JoiningNodes joiningNodes;
    498503
     504        /**
     505         * Bootstrapper for our spovnet
     506         */
     507        OverlayBootstrap overlayBootstrap;
    499508};
    500509
  • source/ariba/utility/bootstrap/BootstrapInformationCallback.h

    r4733 r4836  
    4949class BootstrapInformationCallback {
    5050public:
    51         virtual void onBootstrapServiceFound(string name, string info) = 0;
     51        virtual void onBootstrapServiceFound(string name, string info1, string info2, string info3) = 0;
    5252};
    5353
  • source/ariba/utility/bootstrap/BootstrapManager.cpp

    r4758 r4836  
    5050
    5151BootstrapManager::~BootstrapManager(){
    52 
    53         boost::mutex::scoped_lock lock( modulesMutex );
    54 
    55         while( modules.size() > 0 ){
    56                 ModuleMap::iterator i = modules.begin();
    57                 unregisterModule( i->first );
    58         }
    5952}
    6053
     
    9689}
    9790
    98 BootstrapManager::RegistrationResult BootstrapManager::unregisterModule(BootstrapManager::BootstrapType type){
     91BootstrapManager::RegistrationResult BootstrapManager::unregisterModule(
     92                BootstrapManager::BootstrapType type){
    9993
    10094        boost::mutex::scoped_lock lock( modulesMutex );
     
    113107}
    114108
    115 void BootstrapManager::onBootstrapServiceFound(string name, string info){
     109BootstrapManager::RegistrationResult BootstrapManager::registerAllModules(){
     110        RegistrationResult result = RegistrationSucceeded;
     111
     112        { // multicast dns
     113                RegistrationResult resone = RegistrationSucceeded;
     114                resone = registerModule(BootstrapTypeMulticastDns);
     115                if(resone != RegistrationSucceeded)
     116                        result = resone;
     117        }
     118
     119        { // todo
     120                /*  ...   */
     121        }
     122
     123        return result;
     124}
     125
     126BootstrapManager::RegistrationResult BootstrapManager::unregisterAllModules(){
     127        unregisterModule(BootstrapTypeMulticastDns);
     128        /*  todo  ...  */
     129
     130        return RegistrationSucceeded;
     131}
     132
     133void BootstrapManager::onBootstrapServiceFound(string name, string info1, string info2, string info3){
    116134
    117135        BOOST_FOREACH( BootstrapInformationCallback* callback, callbacks ){
    118                 callback->onBootstrapServiceFound(name, info);
     136                callback->onBootstrapServiceFound(name, info1, info2, info3);
    119137        }
    120138}
     
    132150}
    133151
    134 void BootstrapManager::publish(string name, string info){
     152void BootstrapManager::publish(string name, string info1, string info2, string info3){
    135153        boost::mutex::scoped_lock lock( modulesMutex );
    136154
     
    141159                logging_info("bootstrap manager publishing service "
    142160                                << name << " on module " << i->second->getName());
    143                 i->second->publishService(name, info);
     161                i->second->publishService(name, info1, info2, info3);
    144162        }
    145163}
    146164
    147165void BootstrapManager::revoke(string name){
     166        boost::mutex::scoped_lock lock( modulesMutex );
     167
    148168        ModuleMap::iterator i = modules.begin();
    149169        ModuleMap::iterator iend = modules.end();
  • source/ariba/utility/bootstrap/BootstrapManager.h

    r4733 r4836  
    7373
    7474        enum BootstrapType {
    75                 BootstrapTypeMulticastDns,
     75                BootstrapTypeMulticastDns,      // use mDNS bootstrapping
    7676        };
    7777
     
    8282        };
    8383
     84        RegistrationResult registerAllModules();
    8485        RegistrationResult registerModule(BootstrapType type);
     86        RegistrationResult unregisterAllModules();
    8587        RegistrationResult unregisterModule(BootstrapType type);
    8688
     
    8890        void unregisterCallback(BootstrapInformationCallback* _callback);
    8991
    90         void publish(string name, string info);
     92        void publish(string name, string info1, string info2, string info3);
    9193        void revoke(string name);
    9294
    9395protected:
    94         virtual void onBootstrapServiceFound(string name, string info);
     96        virtual void onBootstrapServiceFound(string name, string info1, string info2, string info3);
    9597
    9698private:
  • source/ariba/utility/bootstrap/modules/BootstrapModule.h

    r4758 r4836  
    5353        virtual ~BootstrapModule();
    5454
     55        // the module must run asynchronously in its own thread.
    5556        virtual void start() = 0;
    5657        virtual void stop() = 0;
     
    6061        virtual bool isFunctional() = 0;
    6162
    62         virtual void publishService(string name, string info) = 0;
     63        virtual void publishService(string name, string info1, string info2, string info3) = 0;
    6364        virtual void revokeService(string name) = 0;
    6465
  • source/ariba/utility/bootstrap/modules/multicastdns/MulticastDns.cpp

    r4758 r4836  
    4646
    4747MulticastDns::MulticastDns(BootstrapInformationCallback* _callback) : BootstrapModule(_callback) {
    48   #ifdef HAVE_LIBAVAHI_CLIENT
     48  #ifdef HAVE_AVAHI_CLIENT_CLIENT_H
    4949        avahiclient = NULL;
    5050        avahipoll = NULL;
    5151        avahibrowser = NULL;
    52   #endif // HAVE_LIBAVAHI_CLIENT
     52  #endif // HAVE_AVAHI_CLIENT_CLIENT_H
    5353}
    5454
     
    6565
    6666bool MulticastDns::isFunctional(){
    67   #ifdef HAVE_LIBAVAHI_CLIENT
     67  #ifdef HAVE_AVAHI_CLIENT_CLIENT_H
    6868        return true;
    6969  #else
     
    7373
    7474void MulticastDns::start(){
    75   #ifdef HAVE_LIBAVAHI_CLIENT
     75  #ifdef HAVE_AVAHI_CLIENT_CLIENT_H
    7676
    7777        int error = 0;
     
    110110        avahi_threaded_poll_start( avahipoll );
    111111
    112   #endif // HAVE_LIBAVAHI_CLIENT
     112  #endif // HAVE_AVAHI_CLIENT_CLIENT_H
    113113}
    114114
    115115void MulticastDns::stop(){
    116   #ifdef HAVE_LIBAVAHI_CLIENT
     116  #ifdef HAVE_AVAHI_CLIENT_CLIENT_H
    117117
    118118        //
     
    144144        avahipoll = NULL;
    145145
    146   #endif // HAVE_LIBAVAHI_CLIENT
    147 }
    148 
    149 void MulticastDns::publishService(string name, string info){
    150   #ifdef HAVE_LIBAVAHI_CLIENT
     146  #endif // HAVE_AVAHI_CLIENT_CLIENT_H
     147}
     148
     149void MulticastDns::publishService(string name, string info1, string info2, string info3){
     150  #ifdef HAVE_AVAHI_CLIENT_CLIENT_H
    151151
    152152        if(name.length() > 63){
     
    198198                        NULL,                                   // host name of our machine, let avahi find out
    199199                        3333,                                   // port number the service is on, just dummy, everything is encoded in TXT
    200                         info.c_str(),                   // arbitrary info
     200                        info1.c_str(),                  // arbitrary info
     201                        info2.c_str(),                  // arbitrary info
     202                        info3.c_str(),                  // arbitrary info
    201203                        NULL);                                  // make that this is the last info field
    202204
     
    219221        avahi_threaded_poll_unlock(avahipoll);
    220222
    221   #endif // HAVE_LIBAVAHI_CLIENT
     223  #endif // HAVE_AVAHI_CLIENT_CLIENT_H
    222224}
    223225
    224226void MulticastDns::revokeService(string name){
    225   #ifdef HAVE_LIBAVAHI_CLIENT
     227  #ifdef HAVE_AVAHI_CLIENT_CLIENT_H
    226228
    227229        avahi_threaded_poll_lock(avahipoll);
     
    239241        avahi_threaded_poll_unlock(avahipoll);
    240242
    241   #endif // HAVE_LIBAVAHI_CLIENT
    242 }
    243 
    244 #ifdef HAVE_LIBAVAHI_CLIENT
     243  #endif // HAVE_AVAHI_CLIENT_CLIENT_H
     244}
     245
     246#ifdef HAVE_AVAHI_CLIENT_CLIENT_H
    245247
    246248void MulticastDns::client_callback(AvahiClient* client, AvahiClientState state, void* userdata){
     
    395397
    396398                        char addr[AVAHI_ADDRESS_STR_MAX];
    397                         char* text = NULL;
    398399
    399400                        avahi_address_snprint(addr, sizeof(addr), address);
    400                         text = avahi_string_list_to_string(txt);
     401
     402                        string info1 = "";
     403                        string info2 = "";
     404                        string info3 = "";
     405
     406                        if(txt != NULL){
     407                                char* cinfo = avahi_string_list_to_string(txt);
     408                                info1 = cinfo;
     409                                avahi_free(cinfo);
     410                        }
     411
     412                        if(txt != NULL && avahi_string_list_get_next(txt) != NULL){
     413                                char* cinfo = avahi_string_list_to_string( avahi_string_list_get_next(txt) );
     414                                info2 = cinfo;
     415                                avahi_free(cinfo);
     416                        }
     417
     418                        if(txt != NULL && avahi_string_list_get_next(txt) != NULL){
     419                                char* cinfo = avahi_string_list_to_string( avahi_string_list_get_next(txt) );
     420                                info3 = cinfo;
     421                                avahi_free(cinfo);
     422                        }
    401423
    402424                        if(obj != NULL && obj->callback != NULL)
    403                                 obj->callback->onBootstrapServiceFound(name, text);
    404 
    405                         avahi_free( text );
     425                                obj->callback->onBootstrapServiceFound(name, info1, info2, info3);
     426
    406427                        break;
    407428        }
     
    410431}
    411432
    412 #endif // HAVE_LIBAVAHI_CLIENT
     433#endif // HAVE_AVAHI_CLIENT_CLIENT_H
    413434
    414435}} //namespace ariba, utility
  • source/ariba/utility/bootstrap/modules/multicastdns/MulticastDns.h

    r4758 r4836  
    4242#include "ariba/config.h"
    4343
    44 #ifdef HAVE_LIBAVAHI_CLIENT
     44#ifdef HAVE_AVAHI_CLIENT_CLIENT_H
    4545  #include <avahi-client/client.h>
    4646  #include <avahi-client/lookup.h>
     
    5151  #include <avahi-common/error.h>
    5252  #include <avahi-common/timeval.h>
    53 #endif
     53#endif // HAVE_AVAHI_CLIENT_CLIENT_H
    5454
    5555#include <iostream>
     
    8080        virtual string getInformation();
    8181        virtual bool isFunctional();
    82         virtual void publishService(string name, string info);
     82        virtual void publishService(string name, string info1, string info2, string info3);
    8383        virtual void revokeService(string name);
    8484
     
    8686        static const string serviceType;
    8787
    88 #ifdef HAVE_LIBAVAHI_CLIENT
     88#ifdef HAVE_AVAHI_CLIENT_CLIENT_H
    8989
    9090        AvahiClient*         avahiclient;
     
    133133                        );
    134134
    135 #endif // HAVE_LIBAVAHI_CLIENT
     135#endif // HAVE_AVAHI_CLIENT_CLIENT_H
    136136
    137137};
Note: See TracChangeset for help on using the changeset viewer.