diff --git a/configure.in b/configure.in index 145e25b..8a67c05 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ -AC_INIT(libenet, 10-2-2006) -AM_INIT_AUTOMAKE(libenet.a, 10-2-2006) +AC_INIT(libenet, 12-12-2006) +AM_INIT_AUTOMAKE(libenet.a, 12-12-2006) AC_PROG_CC AC_PROG_RANLIB diff --git a/include/enet/enet.h b/include/enet/enet.h index a19640f..72e36c8 100644 --- a/include/enet/enet.h +++ b/include/enet/enet.h @@ -183,7 +183,7 @@ enum ENET_PEER_TIMEOUT_MINIMUM = 5000, ENET_PEER_TIMEOUT_MAXIMUM = 30000, ENET_PEER_PING_INTERVAL = 500, - ENET_PEER_UNSEQUENCED_WINDOW_SIZE = 4 * 32, + ENET_PEER_UNSEQUENCED_WINDOW_SIZE = 4 * 32 }; typedef struct _ENetChannel @@ -396,7 +396,17 @@ ENET_API void enet_socket_destroy (ENetSocket); */ ENET_API int enet_address_set_host (ENetAddress * address, const char * hostName); -/** Attempts to do a reserve lookup of the host field in the address parameter. +/** Gives the printable form of the ip address specified in the address parameter. + @param address address printed + @param hostName destination for name, must not be NULL + @param nameLength maximum length of hostName. + @returns the null-terminated name of the host in hostName on success + @retval 0 on success + @retval < 0 on failure +*/ +ENET_API int enet_address_get_host_ip (const ENetAddress * address, char * hostName, size_t nameLength); + +/** Attempts to do a reverse lookup of the host field in the address parameter. @param address address used for reverse lookup @param hostName destination for name, must not be NULL @param nameLength maximum length of hostName. diff --git a/include/enet/protocol.h b/include/enet/protocol.h index e5b4a32..363857b 100644 --- a/include/enet/protocol.h +++ b/include/enet/protocol.h @@ -16,7 +16,7 @@ enum ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE = 32768, ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT = 1, ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT = 255, - ENET_PROTOCOL_MAXIMUM_PEER_ID = 0x7FFF, + ENET_PROTOCOL_MAXIMUM_PEER_ID = 0x7FFF }; typedef enum @@ -35,7 +35,7 @@ typedef enum ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11, ENET_PROTOCOL_COMMAND_COUNT = 12, - ENET_PROTOCOL_COMMAND_MASK = 0x0F, + ENET_PROTOCOL_COMMAND_MASK = 0x0F } ENetProtocolCommand; typedef enum @@ -44,7 +44,7 @@ typedef enum ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 << 6), ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = (1 << 15), - ENET_PROTOCOL_HEADER_FLAG_MASK = 0x8000, + ENET_PROTOCOL_HEADER_FLAG_MASK = 0x8000 } ENetProtocolFlag; typedef struct diff --git a/peer.c b/peer.c index 1a23c4c..cab6245 100644 --- a/peer.c +++ b/peer.c @@ -116,7 +116,8 @@ enet_peer_send (ENetPeer * peer, enet_uint8 channelID, ENetPacket * packet) fragmentNumber, fragmentOffset; - packet -> flags = ENET_PACKET_FLAG_RELIABLE; + packet -> flags |= ENET_PACKET_FLAG_RELIABLE; + packet -> flags &= ~ENET_PACKET_FLAG_UNSEQUENCED; for (fragmentNumber = 0, fragmentOffset = 0; @@ -311,9 +312,6 @@ enet_peer_reset (ENetPeer * peer) peer -> outgoingPeerID = ENET_PROTOCOL_MAXIMUM_PEER_ID; peer -> sessionID = 0; - peer -> address.host = ENET_HOST_ANY; - peer -> address.port = 0; - peer -> state = ENET_PEER_STATE_DISCONNECTED; peer -> incomingBandwidth = 0; diff --git a/unix.c b/unix.c index 75385a8..b0e6ee2 100644 --- a/unix.c +++ b/unix.c @@ -106,6 +106,21 @@ enet_address_set_host (ENetAddress * address, const char * name) return 0; } +int +enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameLength) +{ +#ifdef HAS_INET_NTOP + if (inet_ntop (AF_INET, & address -> host, name, nameLength) == NULL) +#else + char * addr = inet_ntoa (* (struct in_addr *) & address -> host); + if (addr != NULL) + strncpy (name, addr, nameLength); + else +#endif + return -1; + return 0; +} + int enet_address_get_host (const ENetAddress * address, char * name, size_t nameLength) { @@ -130,18 +145,7 @@ enet_address_get_host (const ENetAddress * address, char * name, size_t nameLeng #endif if (hostEntry == NULL) - { -#ifdef HAS_INET_NTOP - if (inet_ntop (AF_INET, & address -> host, name, nameLength) == NULL) -#else - char * addr = inet_ntoa (* (struct in_addr *) & address -> host); - if (addr != NULL) - strncpy (name, addr, nameLength); - else -#endif - return -1; - return 0; - } + return enet_address_get_host_ip (address, name, nameLength); strncpy (name, hostEntry -> h_name, nameLength); diff --git a/win32.c b/win32.c index 8fdd746..5fde10d 100644 --- a/win32.c +++ b/win32.c @@ -73,6 +73,16 @@ enet_address_set_host (ENetAddress * address, const char * name) return 0; } +int +enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameLength) +{ + char * addr = inet_ntoa (* (struct in_addr *) & address -> host); + if (addr == NULL) + return -1; + strncpy (name, addr, nameLength); + return 0; +} + int enet_address_get_host (const ENetAddress * address, char * name, size_t nameLength) { @@ -83,13 +93,7 @@ enet_address_get_host (const ENetAddress * address, char * name, size_t nameLeng hostEntry = gethostbyaddr ((char *) & in, sizeof (struct in_addr), AF_INET); if (hostEntry == NULL) - { - char * addr = inet_ntoa (* (struct in_addr *) & address -> host); - if (addr == NULL) - return -1; - strncpy (name, addr, nameLength); - return 0; - } + return enet_address_get_host_ip (address, name, nameLength); strncpy (name, hostEntry -> h_name, nameLength);