Ignore:
Timestamp:
Jul 24, 2009, 3:23:11 PM (15 years ago)
Author:
mies
Message:

+ added new transport modules and adapted ariba to them
+ exchange endpoint descriptors an link establishment
+ clean up of base communication
+ link establishment with in the presence of multiple endpoints
+ local discovery for ipv6, ipv4 and bluetooth mac addresses

Location:
source/ariba/communication/networkinfo
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/communication/networkinfo/AddressInformation.cpp

    r3690 r5284  
    3939#include "AddressInformation.h"
    4040
     41#include <ifaddrs.h>
     42
     43#include <boost/asio/ip/address.hpp>
     44#include <boost/asio/ip/address_v4.hpp>
     45
    4146namespace ariba {
    4247namespace communication {
     48
     49using namespace ariba::addressing;
    4350
    4451AddressInformation::AddressInformation(){
     
    5259        AddressList retlist;
    5360
    54         //
    5561        // gather transport addresses
    56         //
    57 
    5862        struct ifaddrs* ifap;
    5963        getifaddrs( &ifap );
    6064
    6165        for( struct ifaddrs* p = ifap; p != NULL; p=p->ifa_next ){
     66
     67                // no name set? ->continue
    6268                if( interface.name.compare(string(p->ifa_name)) != 0 ) continue;
    6369
    64                 // TODO: currently only handle IPv4
     70                // handle IPv4 entry
    6571                struct sockaddr* addr = p->ifa_addr;
    66                 if( addr->sa_family != AF_INET ) continue;
     72                if( addr->sa_family == AF_INET ) {
     73                        // get address
     74                        const struct sockaddr_in& ipv4 = (const struct sockaddr_in&)*addr;
     75                        boost::asio::ip::address_v4::bytes_type bytes;
     76                        for( int i=0; i<4; i++ )
     77                                bytes[i] = (ipv4.sin_addr.s_addr >> (24-i*8)) & 0xff;
    6778
    68                 const struct sockaddr_in& ipv4 = (const struct sockaddr_in&)*addr;
    69                 boost::asio::ip::address_v4::bytes_type bytes;
    70                 for( int i=0; i<4; i++ )
    71                         bytes[i] = (ipv4.sin_addr.s_addr >> (24-i*8)) & 0xff;
    72 
    73                 boost::asio::ip::address boost_addr = boost::asio::ip::address_v4( bytes );
    74                 retlist.push_back( IPv4Locator::fromString(boost_addr.to_string()) );
     79                        // add ipv4 address
     80                        boost::asio::ip::address boost_addr = boost::asio::ip::address_v4( bytes );
     81                        retlist.push_back( vcapsule<address_v>( ip_address(boost_addr) ) );
     82                }
    7583        }
    7684
    7785        freeifaddrs( ifap );
    78 
    79         //
    80         // TODO: gather further addresses like MAC etc.
    81         //
    8286
    8387        return retlist;
  • source/ariba/communication/networkinfo/AddressInformation.h

    r3690 r5284  
    4040#define __ADDRESS_INFORMATION_H
    4141
    42 #include <ifaddrs.h>
    4342#include <vector>
    44 #include <boost/asio/ip/address.hpp>
    45 #include <boost/asio/ip/address_v4.hpp>
     43
    4644#include "ariba/communication/networkinfo/NetworkInterface.h"
    47 #include "ariba/communication/modules/network/ip/IPv4Locator.h"
    48 
    49 using std::vector;
    50 using ariba::communication::NetworkInterface;
    51 using ariba::communication::IPv4Locator;
     45#include "ariba/utility/addressing/addressing.hpp"
    5246
    5347namespace ariba {
    5448namespace communication {
    5549
    56 typedef vector<IPv4Locator> AddressList; // TODO: make more general, not only ipv4
     50using namespace std;
     51using namespace ariba::addressing;
     52
     53/// a list of addresses
     54typedef vector<address_v*> AddressList;
    5755
    5856class AddressInformation {
     
    6260
    6361        AddressList getAddresses(const NetworkInterface& interface);
    64 
    6562};
    6663
Note: See TracChangeset for help on using the changeset viewer.