Changeset 7459 for code/trunk
- Timestamp:
- Sep 17, 2010, 12:48:29 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 13 edited
- 36 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/ipv6 (added) merged: 7293-7295,7320,7322,7328-7330,7376-7378,7381-7382,7384-7387,7389-7394,7396-7397,7402,7411,7414,7433,7435,7437-7438,7442-7443,7453-7454
- Property svn:mergeinfo changed
-
code/trunk/cmake/LibraryConfig.cmake
r7449 r7459 94 94 95 95 FIND_PACKAGE(OGRE 1.4 REQUIRED) 96 FIND_PACKAGE(ENet 1.1 REQUIRED)96 #FIND_PACKAGE(ENet 1.1 REQUIRED) 97 97 FIND_PACKAGE(Ogg REQUIRED) 98 98 FIND_PACKAGE(Vorbis REQUIRED) … … 177 177 OPTION(LINK_BOOST_DYNAMIC "Link Boost dynamically on Windows" TRUE) 178 178 OPTION(LINK_CEGUI_DYNAMIC "Link CEGUI dynamicylly on Windows" TRUE) 179 OPTION(LINK_ENET_DYNAMIC "Link ENet dynamically on Windows" TRUE)179 #OPTION(LINK_ENET_DYNAMIC "Link ENet dynamically on Windows" TRUE) 180 180 OPTION(LINK_OGRE_DYNAMIC "Link OGRE dynamically on Windows" TRUE) 181 181 OPTION(LINK_TCL_DYNAMIC "Link TCL dynamically on Windows" TRUE) … … 190 190 IF(DEPENDENCY_PACKAGE_ENABLE) 191 191 MARK_AS_ADVANCED( 192 LINK_BOOST_DYNAMIC LINK_CEGUI_DYNAMIC LINK_ENET_DYNAMIC192 LINK_BOOST_DYNAMIC LINK_CEGUI_DYNAMIC #LINK_ENET_DYNAMIC 193 193 LINK_OGRE_DYNAMIC LINK_TCL_DYNAMIC LINK_ZLIB_DYNAMIC 194 194 LINK_LUA_DYNAMIC -
code/trunk/cmake/PackageConfig.cmake
r7449 r7459 83 83 SET(ENV{DBGHELP_DIR} ${DEP_INCLUDE_DIR}/dbghelp) 84 84 SET(ENV{DXSDK_DIR} ${DEP_INCLUDE_DIR}/directx) 85 SET(ENV{ENETDIR} ${DEP_INCLUDE_DIR}/enet)85 #SET(ENV{ENETDIR} ${DEP_INCLUDE_DIR}/enet) 86 86 SET(ENV{LUA_DIR} ${DEP_INCLUDE_DIR}/lua) 87 87 SET(ENV{OGGDIR} ${DEP_INCLUDE_DIR}/libogg) -
code/trunk/src/CMakeLists.txt
r7451 r7459 38 38 # If no defines are specified, these libs get linked statically 39 39 ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" WIN32 LINK_BOOST_DYNAMIC) 40 ADD_COMPILER_FLAGS("-DENET_DLL" WIN32 LINK_ENET_DYNAMIC)40 #ADD_COMPILER_FLAGS("-DENET_DLL" WIN32 LINK_ENET_DYNAMIC) 41 41 ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL" WIN32 LINK_LUA_DYNAMIC) 42 42 ADD_COMPILER_FLAGS("-DZLIB_DLL" WIN32 LINK_ZLIB_DYNAMIC) … … 61 61 # If no defines are specified, these libs get linked dynamically 62 62 ADD_COMPILER_FLAGS("-DCEGUILUA_STATIC" WIN32 NOT _external_shared_link) 63 ADD_COMPILER_FLAGS("-DENET_DLL" WIN32 _external_shared_link) 63 64 ADD_COMPILER_FLAGS("-DOGRE_GUIRENDERER_STATIC_LIB" WIN32 NOT _external_shared_link) 64 65 ADD_COMPILER_FLAGS("-DOIS_STATIC_LIB" WIN32 NOT _external_shared_link) … … 72 73 ${OGRE_INCLUDE_DIR} 73 74 ${CEGUI_INCLUDE_DIR} 74 ${ENET_INCLUDE_DIR}75 #${ENET_INCLUDE_DIR} 75 76 ${Boost_INCLUDE_DIRS} 76 77 ${POCO_INCLUDE_DIR} -
code/trunk/src/external/CMakeLists.txt
r7266 r7459 34 34 ADD_SUBDIRECTORY(bullet) 35 35 ADD_SUBDIRECTORY(cpptcl) 36 ADD_SUBDIRECTORY(enet) 36 37 ADD_SUBDIRECTORY(loki) 37 38 ADD_SUBDIRECTORY(ogreceguirenderer) -
code/trunk/src/libraries/network/CMakeLists.txt
r7163 r7459 71 71 LINK_LIBRARIES 72 72 ${ZLIB_LIBRARY} 73 ${ENET_LIBRARY} 73 #${ENET_LIBRARY} 74 enet_orxonox 74 75 ${Boost_THREAD_LIBRARY} 75 76 util -
code/trunk/src/libraries/network/ClientConnection.cc
r7284 r7459 48 48 this->serverAddress_ = new ENetAddress(); 49 49 //set standard address and port 50 enet_address_set_host(this->serverAddress_, "127.0.0.1"); 50 enet_address_set_host(this->serverAddress_, "127.0.0.1"); // TODO: check for IPv6 and connect to ::1 instead 51 51 serverAddress_->port = NETWORK_PORT; 52 52 } … … 59 59 60 60 void ClientConnection::setServerAddress( const std::string& serverAddress ) { 61 enet_address_set_host (this->serverAddress_, serverAddress.c_str()); 61 if (enet_address_set_host (this->serverAddress_, serverAddress.c_str()) < 0) 62 COUT(1) << "Error: Could not resolve \"" << serverAddress << "\"." << std::endl; 62 63 } 63 64 … … 70 71 ENetEvent event; 71 72 72 this->host_ = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0 );73 this->host_ = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0, 0); 73 74 if ( this->host_ == NULL ) 74 75 { 75 COUT( 2) << "ClientConnection: host_ == NULL" << std::endl;76 COUT(1) << "ClientConnection: host_ == NULL" << std::endl; 76 77 // error handling 77 78 return false; 78 79 } 79 this->server_ = enet_host_connect(this->host_, serverAddress_, NETWORK_CLIENT_CHANNELS); 80 assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL ); 81 if (this->host_->socket4 == ENET_SOCKET_NULL) 82 COUT(2) << "Warning: IPv4 Socket failed." << std::endl; 83 else if (this->host_->socket6 == ENET_SOCKET_NULL) 84 COUT(2) << "Warning: IPv6 Socket failed." << std::endl; 85 else 86 COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl; 87 88 this->server_ = enet_host_connect(this->host_, serverAddress_, NETWORK_CLIENT_CHANNELS, 0); 80 89 if ( this->server_==NULL ) 81 90 { 82 COUT( 2) << "ClientConnection: server== NULL" << std::endl;91 COUT(1) << "ClientConnection: server_ == NULL" << std::endl; 83 92 // error handling 84 93 return false; -
code/trunk/src/libraries/network/ClientInformation.cc
r7401 r7459 216 216 ClientInformation *temp = head_; 217 217 while(temp!=0){ 218 if( temp->getPeer()->address.host==peer->address.host && temp->getPeer()->address.port==peer->address.port)218 if(!memcmp(& temp->getPeer()->address, & peer->address, sizeof(peer->address))) 219 219 break; 220 220 temp = temp->next(); … … 252 252 ClientInformation *temp = head_; 253 253 while(temp!=0){ 254 if( temp->getPeer()->address.host==address->host && temp->getPeer()->address.port == address->port)254 if(!memcmp(& temp->getPeer()->address, address, sizeof(*address))) 255 255 break; 256 256 temp = temp->next(); -
code/trunk/src/libraries/network/LANDiscoverable.cc
r7163 r7459 64 64 if( bActive ) 65 65 { 66 ENetAddress bindAddress = { ENET_HOST_ANY, LAN_DISCOVERY_PORT }; 66 ENetAddress bindAddress; 67 memset(& bindAddress, 0, sizeof(ENetAddress)); 68 bindAddress.host = ENET_HOST_ANY; 69 bindAddress.port = LAN_DISCOVERY_PORT; 67 70 assert( this->host_ == 0 ); 68 this->host_ = enet_host_create( &bindAddress, 10, 0, 0 ); 71 this->host_ = enet_host_create( &bindAddress, 10, 0, 0, 0 ); 72 if ( this->host_ == NULL ) 73 COUT(1) << "LANDiscoverable: host_ == NULL" << std::endl; 69 74 } 70 75 else … … 89 94 { 90 95 case ENET_EVENT_TYPE_CONNECT: 96 COUT(4) << "Received LAN discovery connect from client " << event.peer->host->receivedAddress << std::endl; 97 break; 91 98 case ENET_EVENT_TYPE_DISCONNECT: 92 99 case ENET_EVENT_TYPE_NONE: … … 95 102 if( strcmp( LAN_DISCOVERY_MESSAGE, (char*)event.packet->data ) == 0 ) // check for a suitable orxonox client 96 103 { 104 COUT(3) << "Received LAN discovery message from client " << event.peer->host->receivedAddress << std::endl; 97 105 packet::ServerInformation info; 98 106 info.setServerName("Orxonox Server"); -
code/trunk/src/libraries/network/LANDiscovery.cc
r7284 r7459 42 42 LANDiscovery::LANDiscovery() 43 43 { 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; 45 47 } 46 48 … … 53 55 { 54 56 this->servers_.clear(); 57 ENetPeer* peer; 55 58 ENetAddress address; 56 enet_address_set_host(&address, "255.255.255.255");59 memset(&address, 0, sizeof(ENetAddress)); 57 60 address.port = LAN_DISCOVERY_PORT; 58 61 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; 61 74 62 75 ENetEvent event; … … 67 80 case ENET_EVENT_TYPE_CONNECT: 68 81 { 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; 70 83 ENetPacket* packet = enet_packet_create(LAN_DISCOVERY_MESSAGE, strlen(LAN_DISCOVERY_MESSAGE)+1, ENET_PACKET_FLAG_RELIABLE); 71 84 enet_peer_send(event.peer, 0, packet); … … 75 88 { 76 89 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; 78 91 std::vector<packet::ServerInformation>::iterator it; 79 92 for( it=this->servers_.begin(); it!=this->servers_.end(); ++it ) -
code/trunk/src/libraries/network/ServerConnection.cc
r7163 r7459 44 44 { 45 45 this->bindAddress_ = new ENetAddress(); 46 memset(this->bindAddress_, 0, sizeof(ENetAddress)); 46 47 this->bindAddress_->host = ENET_HOST_ANY; 47 48 this->bindAddress_->port = NETWORK_PORT; … … 55 56 56 57 void ServerConnection::setBindAddress( const std::string& bindAddress ) { 57 enet_address_set_host (this->bindAddress_, bindAddress.c_str()); 58 if (enet_address_set_host (this->bindAddress_, bindAddress.c_str()) < 0) 59 COUT(1) << "Error: Could not resolve \"" << bindAddress << "\"." << std::endl; 58 60 } 59 61 … … 63 65 64 66 bool ServerConnection::openListener() { 65 this->host_ = enet_host_create(this->bindAddress_, NETWORK_MAX_CONNECTIONS, 0, 0 );67 this->host_ = enet_host_create(this->bindAddress_, NETWORK_MAX_CONNECTIONS, 0, 0, 0); 66 68 if ( this->host_ == NULL ) 67 return false; 69 { 70 COUT(1) << "ServerConnection: host_ == NULL" << std::endl; 71 return false; 72 } 73 assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL ); 74 if (this->host_->socket4 == ENET_SOCKET_NULL) 75 COUT(2) << "Warning: IPv4 Socket failed." << std::endl; 76 else if (this->host_->socket6 == ENET_SOCKET_NULL) 77 COUT(2) << "Warning: IPv6 Socket failed." << std::endl; 68 78 else 69 return true; 79 COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl; 80 81 return true; 70 82 } 71 83 -
code/trunk/src/libraries/network/packet/ServerInformation.cc
r7321 r7459 47 47 ServerInformation::ServerInformation(ENetEvent* event) 48 48 { 49 char serverIP[64]; 50 49 51 // Save Server Round Trip Time 50 52 this->serverRTT_ = event->peer->roundTripTime; 51 // Save Server IP 52 char* serverIP = new char[16]; 53 enet_address_get_host_ip(&event->peer->address, serverIP, 16); 53 // Save Server Address, leave some space for scope ID 54 enet_address_get_host_ip(&event->peer->address, serverIP, 64); 54 55 this->serverIP_ = std::string(serverIP); 55 56 // Save ACK … … 83 84 84 85 } // namespace packet 86 87 std::ostream& operator<<(std::ostream& out, const ENetAddress& address) 88 { 89 char addr[64]; 90 if (!enet_address_get_host_ip(&address, addr, 64)) 91 out << addr; 92 return out; 93 } 85 94 } // namespace orxonox 86 95 -
code/trunk/src/libraries/network/packet/ServerInformation.h
r7163 r7459 59 59 60 60 } 61 62 _NetworkExport std::ostream& operator<<(std::ostream& out, const ENetAddress& address); 61 63 } 62 64
Note: See TracChangeset
for help on using the changeset viewer.