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

Changeset 4578


Ignore:
Timestamp:
Oct 19, 2009, 9:32:32 AM (8 years ago)
Author:
stud-lenk
Message:

Bugfix for network interface. IPv4 mapped IPv6 addresses can now be used for initializing an interface too.

Location:
protlib/branches/20090723-multicast
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • protlib/branches/20090723-multicast/src/networkinterface.cpp

    r4198 r4578  
    121121              break;
    122122          }
     123          if (addr.is_mapped_ip())
     124            cmp_addr.convert_to_ipv6();
    123125          if (cmp_addr == addr) {
    124126            strncpy(iface_name, ifa->ifa_name, IFNAMSIZ);
  • protlib/branches/20090723-multicast/test/test_networkinterface.cpp

    r4198 r4578  
    2626          try {
    2727            ni = new networkinterface((unsigned int)0);
     28            delete ni; ni = NULL;
    2829          } catch (invalid_argument& ia) {
    2930            ifi0_failed = true;
     
    4041            string ifi1_name(ni->get_name());
    4142            CPPUNIT_ASSERT(ifi1_name.compare("lo") == 0);
     43            delete ni; ni = NULL;
    4244          } catch (invalid_argument& ia) {
    4345            ifi1_succeeded = false;
     
    5052          try {
    5153            ni = new networkinterface(emptystring.c_str());
     54            delete ni; ni = NULL;
    5255          } catch (invalid_argument& ia) {
    5356            empty_string_failed = true;
     
    6770          CPPUNIT_ASSERT(ipv4_loopback_addr_succeeded);
    6871          CPPUNIT_ASSERT(ni->get_index() == 1);
     72          delete ni; ni = NULL;
    6973
    7074          bool ipv4_bogon_addr_failed = false;
     
    7276          try {
    7377            ni = new networkinterface(bogon_addr);
     78            delete ni; ni = NULL;
    7479          } catch (invalid_argument& ia) {
    7580            ipv4_bogon_addr_failed = true;
    7681          }
    7782          CPPUNIT_ASSERT(ipv4_bogon_addr_failed);
     83
     84          // Triage constructors by IPv4-mapped IPv6 hostaddress
     85          bool ipv4_mapped_ipv6_loopback_addr_succeeded = true;
     86          lo_addr.set_ip("::ffff:7f00:1");
     87          DLog(methodname, "Trying with IPv4 mapped IPv6 address " << lo_addr);
     88          try {
     89            ni = new networkinterface(lo_addr);
     90          } catch (invalid_argument& ia) {
     91            ipv4_mapped_ipv6_loopback_addr_succeeded = false;
     92          }
     93          CPPUNIT_ASSERT(ipv4_mapped_ipv6_loopback_addr_succeeded);
     94          CPPUNIT_ASSERT(ni->get_index() == 1);
     95          delete ni; ni = NULL;
    7896
    7997          // Triage copy constructor
Note: See TracChangeset for help on using the changeset viewer.