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

File:
1 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;
Note: See TracChangeset for help on using the changeset viewer.