Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 17, 2010, 12:48:29 AM (15 years ago)
Author:
adrfried
Message:

Merged ipv6 branch

Orxonox now includes a modified version of ENet 1.3.0

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/network/LANDiscovery.cc

    r7284 r7459  
    4242  LANDiscovery::LANDiscovery()
    4343  {
    44     this->host_ = enet_host_create(NULL, 10, 0, 0 );
     44    this->host_ = enet_host_create(NULL, 10, 0, 0, 0 );
     45    if ( this->host_ == NULL )
     46        COUT(1) << "LANDiscovery: host_ == NULL" << std::endl;
    4547  }
    4648
     
    5355  {
    5456    this->servers_.clear();
     57    ENetPeer* peer;
    5558    ENetAddress address;
    56     enet_address_set_host(&address, "255.255.255.255");
     59    memset(&address, 0, sizeof(ENetAddress));
    5760    address.port = LAN_DISCOVERY_PORT;
    5861
    59     ENetPeer* peer;
    60     peer = enet_host_connect(this->host_, &address, 0);
     62    /* TODO: check for availability of each protocol */
     63    /* IPv4 */
     64    address.host = ENET_HOST_BROADCAST;
     65    peer = enet_host_connect(this->host_, &address, 0, 0);
     66    if (peer == NULL)
     67        COUT(1) << "Error: Could not send LAN discovery to IPv4 Broadcast." << std::endl;
     68
     69    /* IPv6 */
     70    enet_address_set_host(&address, "ff02::1"); // TODO: use a multicast group
     71    peer = enet_host_connect(this->host_, &address, 0, 0);
     72    if (peer == NULL)
     73        COUT(1) << "Error: Could not send LAN discovery to IPv6 Multicast." << std::endl;
    6174
    6275    ENetEvent event;
     
    6780        case ENET_EVENT_TYPE_CONNECT:
    6881        {
    69           COUT(0) << "connect from server: " << event.peer->address.host << endl;
     82          COUT(4) << "Received LAN discovery connect from server " << event.peer->host->receivedAddress << std::endl;
    7083          ENetPacket* packet = enet_packet_create(LAN_DISCOVERY_MESSAGE, strlen(LAN_DISCOVERY_MESSAGE)+1, ENET_PACKET_FLAG_RELIABLE);
    7184          enet_peer_send(event.peer, 0, packet);
     
    7588          {
    7689            packet::ServerInformation info(&event);
    77             COUT(0) << "received server information; name: " << info.getServerName() << ", IP: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl;
     90            COUT(3) << "Received LAN discovery server information; Name: " << info.getServerName() << ", Address: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl;
    7891            std::vector<packet::ServerInformation>::iterator it;
    7992            for( it=this->servers_.begin(); it!=this->servers_.end(); ++it )
Note: See TracChangeset for help on using the changeset viewer.