diff options
author | eihrul <eihrul> | 2006-12-13 04:36:07 +0000 |
---|---|---|
committer | eihrul <eihrul> | 2006-12-13 04:36:07 +0000 |
commit | 92f904f56a5c0f3f7f81dc37645648d9c4368bd7 (patch) | |
tree | 25012a9539552eaded9b8f97e9c6f057e466e2b5 | |
parent | df636cc8f79fac3c665a9740c5803ee71f965d16 (diff) | |
download | enet-92f904f56a5c0f3f7f81dc37645648d9c4368bd7.tar.gz enet-92f904f56a5c0f3f7f81dc37645648d9c4368bd7.zip |
*** empty log message ***
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | include/enet/enet.h | 14 | ||||
-rw-r--r-- | include/enet/protocol.h | 6 | ||||
-rw-r--r-- | peer.c | 6 | ||||
-rw-r--r-- | unix.c | 28 | ||||
-rw-r--r-- | win32.c | 18 |
6 files changed, 46 insertions, 30 deletions
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 @@ -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; @@ -107,6 +107,21 @@ enet_address_set_host (ENetAddress * address, const char * name) } 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) { struct in_addr in; @@ -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); @@ -74,6 +74,16 @@ enet_address_set_host (ENetAddress * address, const char * name) } 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) { struct in_addr in; @@ -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); |