[Orxonox-commit 2706] r7411 - in code/branches/ipv6/src/libraries/network: . packet
adrfried at orxonox.net
adrfried at orxonox.net
Sat Sep 11 16:14:14 CEST 2010
Author: adrfried
Date: 2010-09-11 16:14:13 +0200 (Sat, 11 Sep 2010)
New Revision: 7411
Modified:
code/branches/ipv6/src/libraries/network/LANDiscoverable.cc
code/branches/ipv6/src/libraries/network/LANDiscovery.cc
code/branches/ipv6/src/libraries/network/packet/ServerInformation.cc
code/branches/ipv6/src/libraries/network/packet/ServerInformation.h
Log:
more debug output added
Modified: code/branches/ipv6/src/libraries/network/LANDiscoverable.cc
===================================================================
--- code/branches/ipv6/src/libraries/network/LANDiscoverable.cc 2010-09-11 13:17:39 UTC (rev 7410)
+++ code/branches/ipv6/src/libraries/network/LANDiscoverable.cc 2010-09-11 14:14:13 UTC (rev 7411)
@@ -99,6 +99,7 @@
case ENET_EVENT_TYPE_RECEIVE:
if( strcmp( LAN_DISCOVERY_MESSAGE, (char*)event.packet->data ) == 0 ) // check for a suitable orxonox client
{
+ COUT(4) << "Received LAN discovery message from " << event.peer->host << std::endl;
packet::ServerInformation info;
info.setServerName("Orxonox Server");
info.send(event.peer);
Modified: code/branches/ipv6/src/libraries/network/LANDiscovery.cc
===================================================================
--- code/branches/ipv6/src/libraries/network/LANDiscovery.cc 2010-09-11 13:17:39 UTC (rev 7410)
+++ code/branches/ipv6/src/libraries/network/LANDiscovery.cc 2010-09-11 14:14:13 UTC (rev 7411)
@@ -79,7 +79,7 @@
{
case ENET_EVENT_TYPE_CONNECT:
{
- //COUT(0) << "connect from server: " << event.peer->address.host << endl; FIXME
+ COUT(4) << "connect from server: " << event.peer->address << endl;
ENetPacket* packet = enet_packet_create(LAN_DISCOVERY_MESSAGE, strlen(LAN_DISCOVERY_MESSAGE)+1, ENET_PACKET_FLAG_RELIABLE);
enet_peer_send(event.peer, 0, packet);
break;
@@ -87,7 +87,7 @@
case ENET_EVENT_TYPE_RECEIVE:
{
packet::ServerInformation info(&event);
- COUT(0) << "received server information; name: " << info.getServerName() << ", IP: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl;
+ COUT(3) << "received server information; Name: " << info.getServerName() << ", Address: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl;
std::vector<packet::ServerInformation>::iterator it;
for( it=this->servers_.begin(); it!=this->servers_.end(); ++it )
{
Modified: code/branches/ipv6/src/libraries/network/packet/ServerInformation.cc
===================================================================
--- code/branches/ipv6/src/libraries/network/packet/ServerInformation.cc 2010-09-11 13:17:39 UTC (rev 7410)
+++ code/branches/ipv6/src/libraries/network/packet/ServerInformation.cc 2010-09-11 14:14:13 UTC (rev 7411)
@@ -46,10 +46,11 @@
ServerInformation::ServerInformation(ENetEvent* event)
{
+ char serverIP[64];
+
// Save Server Round Trip Time
this->serverRTT_ = event->peer->roundTripTime;
- // Save Server IP, leave some space for scope ID
- char* serverIP = new char[64];
+ // Save Server Address, leave some space for scope ID
enet_address_get_host_ip(&event->peer->address, serverIP, 64);
this->serverIP_ = std::string(serverIP);
// Save ACK
@@ -80,5 +81,13 @@
}
} // namespace packet
+
+ std::ostream& operator<<(std::ostream& out, const ENetAddress& address)
+ {
+ char addr[64];
+ if (!enet_address_get_host_ip(&address, addr, 64))
+ out << addr;
+ return out;
+ }
} // namespace orxonox
Modified: code/branches/ipv6/src/libraries/network/packet/ServerInformation.h
===================================================================
--- code/branches/ipv6/src/libraries/network/packet/ServerInformation.h 2010-09-11 13:17:39 UTC (rev 7410)
+++ code/branches/ipv6/src/libraries/network/packet/ServerInformation.h 2010-09-11 14:14:13 UTC (rev 7411)
@@ -58,6 +58,8 @@
};
}
+
+ _UtilExport std::ostream& operator<<(std::ostream& out, const ENetAddress& address);
}
#endif // SERVERINFORMATION_H
More information about the Orxonox-commit
mailing list