NSIS-ka
A free C++ implementation of NSIS protocols

Changeset 4218


Ignore:
Timestamp:
Aug 6, 2009, 5:56:36 PM (8 years ago)
Author:
stud-lenk
Message:

Rewrite of automatic multicast interface selection code using the new AddressList? stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ntlp/branches/20090723-multicast/src/ntlp_starter.cpp

    r4212 r4218  
    426426  networkinterfacelist_t& mcastifs = gconf.getparref< networkinterfacelist_t >(gistconf_multicast_interfaces);
    427427  hostaddresslist_t& mcastgroups= gconf.getparref< hostaddresslist_t >(gistconf_multicast_groups);
    428   if (mcastifs.empty() && (mcastgroups.empty() == false)) {
    429     set<unsigned int> configured_interfaces;
    430     DLog(param.name, "No multicast interfaces specified. Deriving interfaces from configured addresses");
    431     // iterate through all configured IPv4 addresses and insert corresponding network interface indices
    432     hostaddresslist_t::iterator it = localaddrv4.begin();
    433     while (it != localaddrv4.end()) {
    434       try {
    435         networkinterface a_netif(*it);
    436         // DLog(param.name, "Got network interface " << a_netif << " for configured IP address " << *it);
    437         configured_interfaces.insert(a_netif.get_index());
    438       } catch (std::invalid_argument e) {
    439         DLog(param.name, "No network interface found for configured address " << *it);
     428  if (mcastgroups.empty() == true) {
     429    DLog(param.name, "No multicast groups configured. Nothing to join.");
     430  } else {
     431    if (mcastifs.empty()) {
     432      DLog(param.name, "No multicast interfaces specified. Deriving interfaces from configured addresses");
     433      set<unsigned int> configured_interfaces;
     434      AddressList::addrlist_t *alist = addresses->get_addrs(AddressList::ConfiguredAddr_P);
     435      if (alist != 0) {
     436        // iterate through all configured addresses and insert corresponding network interface indices
     437        AddressList::addrlist_t::iterator it;
     438        for (it = alist->begin(); it != alist->end(); it++) {
     439          try {
     440            networkinterface a_netif(*it);
     441            // DLog(param.name, "Got network interface " << a_netif << " for configured IP address " << *it);
     442            configured_interfaces.insert(a_netif.get_index());
     443          } catch (std::invalid_argument e) {
     444            WLog(param.name, "No network interface found for configured address " << *it);
     445          }
     446        }
    440447      }
    441       it++;
    442     }
    443     // iterate through all configured IPv6 addresses and insert corresponding network interface indices
    444     it = localaddrv6.begin();
    445     while (it != localaddrv6.end()) {
    446       try {
    447         networkinterface a_netif(*it);
    448         // DLog(param.name, "Got network interface " << a_netif << " for configured IP address " << *it);
    449         configured_interfaces.insert(a_netif.get_index());
    450       } catch (std::invalid_argument e) {
    451         DLog(param.name, "No network interface found for configured address " << *it);
    452       }
    453       it++;
    454     }
    455     // iterate through all interface indices and fill networkinterfacelist_t
    456     for( set<unsigned int>::const_iterator ifiter = configured_interfaces.begin();
    457          ifiter != configured_interfaces.end(); ++ifiter ) {
    458       try {
    459         networkinterface a_mcast_if(*ifiter);
    460         // DLog(param.name, "Adding network interface " << a_mcast_if << " to list of multicast interfaces");
    461         mcastifs.push_back(a_mcast_if);
    462       } catch (std::invalid_argument ia)
    463       {
    464         ERRLog(param.name, "Adding network interface " << *ifiter << " to list of multicast interfaces failed");
     448      delete alist;
     449      // iterate through all interface indices and fill networkinterfacelist_t
     450      for( set<unsigned int>::const_iterator ifiter = configured_interfaces.begin();
     451           ifiter != configured_interfaces.end(); ++ifiter ) {
     452        try {
     453          networkinterface a_mcast_if(*ifiter);
     454          // DLog(param.name, "Adding network interface " << a_mcast_if << " to list of multicast interfaces");
     455          mcastifs.push_back(a_mcast_if);
     456        } catch (std::invalid_argument ia)
     457        {
     458          ERRLog(param.name, "Adding network interface " << *ifiter << " to list of multicast interfaces failed");
     459        }
    465460      }
    466461    }
Note: See TracChangeset for help on using the changeset viewer.