Changeset 7433 for code/branches/ipv6/src/external/enet
- Timestamp:
- Sep 12, 2010, 10:15:40 PM (14 years ago)
- Location:
- code/branches/ipv6/src/external/enet
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ipv6/src/external/enet/unix.c
r7397 r7433 146 146 147 147 memset(& hints, 0, sizeof (hints)); 148 hints.ai_flags = AI_ NUMERICSERV | AI_ADDRCONFIG;148 hints.ai_flags = AI_ADDRCONFIG; 149 149 hints.ai_family = AF_UNSPEC; 150 150 … … 282 282 283 283 result = accept (socket, 284 address != NULL ? (struct sockaddr *) & sin : NULL, 284 address != NULL ? (struct sockaddr *) & sin : NULL, 285 285 address != NULL ? & sinLength : NULL); 286 286 … … 294 294 295 295 return result; 296 } 297 296 } 297 298 298 void 299 299 enet_socket_destroy (ENetSocket socket) -
code/branches/ipv6/src/external/enet/win32.c
r7397 r7433 67 67 { 68 68 if (family == ENET_IPV4) 69 return sizeof ( SOCKADDR_IN);69 return sizeof (struct sockaddr_in); 70 70 if (family == ENET_IPV6) 71 return sizeof ( SOCKADDR_IN6);71 return sizeof (struct sockaddr_in6); 72 72 return 0; 73 73 } 74 74 75 75 static ENetAddressFamily 76 enet_address_set_address (ENetAddress * address, const SOCKADDR* sin)76 enet_address_set_address (ENetAddress * address, const struct sockaddr * sin) 77 77 { 78 78 memset (address, 0, sizeof (ENetAddress)); 79 79 if (sin -> sa_family == AF_INET) 80 80 { 81 address -> host = enet_address_map4 (((( SOCKADDR_IN*) sin) -> sin_addr.s_addr));81 address -> host = enet_address_map4 ((((struct sockaddr_in *) sin) -> sin_addr.s_addr)); 82 82 /* address -> scopeID = 0; */ 83 address -> port = ENET_NET_TO_HOST_16 ((( SOCKADDR_IN*) sin) -> sin_port);83 address -> port = ENET_NET_TO_HOST_16 (((struct sockaddr_in *) sin) -> sin_port); 84 84 return ENET_IPV4; 85 85 } 86 86 if (sin -> sa_family == AF_INET6) 87 87 { 88 address -> host = * (ENetHostAddress *) & (( SOCKADDR_IN6 *) sin) -> sin6_addr;89 address -> scopeID = (( SOCKADDR_IN6 *) sin) -> sin6_scope_id;90 address -> port = ENET_NET_TO_HOST_16 ((( SOCKADDR_IN6 *) sin) -> sin6_port);88 address -> host = * (ENetHostAddress *) & ((struct sockaddr_in6 *) sin) -> sin6_addr; 89 address -> scopeID = ((struct sockaddr_in6 *) sin) -> sin6_scope_id; 90 address -> port = ENET_NET_TO_HOST_16 (((struct sockaddr_in6 *) sin) -> sin6_port); 91 91 return ENET_IPV6; 92 92 } … … 95 95 96 96 static int 97 enet_address_set_sin ( SOCKADDR* sin, const ENetAddress * address, ENetAddressFamily family)97 enet_address_set_sin (struct sockaddr * sin, const ENetAddress * address, ENetAddressFamily family) 98 98 { 99 99 memset (sin, 0, enet_sa_size(family)); … … 102 102 !memcmp (& address -> host, & ENET_HOST_ANY, sizeof(ENetHostAddress)))) 103 103 { 104 (( SOCKADDR_IN*) sin) -> sin_family = AF_INET;105 (( SOCKADDR_IN *) sin) -> sin_addr = * (IN_ADDR*) & address -> host.addr[12];106 (( SOCKADDR_IN*) sin) -> sin_port = ENET_HOST_TO_NET_16 (address -> port);104 ((struct sockaddr_in *) sin) -> sin_family = AF_INET; 105 ((struct sockaddr_in *) sin) -> sin_addr = * (struct in_addr *) & address -> host.addr[12]; 106 ((struct sockaddr_in *) sin) -> sin_port = ENET_HOST_TO_NET_16 (address -> port); 107 107 return 0; 108 108 } 109 109 else if (family == ENET_IPV6) 110 110 { 111 (( SOCKADDR_IN6 *) sin) -> sin6_family = AF_INET6;112 (( SOCKADDR_IN6 *) sin) -> sin6_addr = * (IN6_ADDR*) & address -> host;113 (( SOCKADDR_IN6 *) sin) -> sin6_scope_id = address -> scopeID;114 (( SOCKADDR_IN6 *) sin) -> sin6_port = ENET_HOST_TO_NET_16 (address -> port);111 ((struct sockaddr_in6 *) sin) -> sin6_family = AF_INET6; 112 ((struct sockaddr_in6 *) sin) -> sin6_addr = * (struct in6_addr *) & address -> host; 113 ((struct sockaddr_in6 *) sin) -> sin6_scope_id = address -> scopeID; 114 ((struct sockaddr_in6 *) sin) -> sin6_port = ENET_HOST_TO_NET_16 (address -> port); 115 115 return 0; 116 116 } … … 122 122 { 123 123 enet_uint16 port = address -> port; 124 ADDRINFOhints;125 ADDRINFO* result;126 ADDRINFO* res;124 struct addrinfo hints; 125 struct addrinfo * result; 126 struct addrinfo * res; 127 127 128 128 memset(& hints, 0, sizeof (hints)); 129 hints.ai_flags = AI_ NUMERICSERV | AI_ADDRCONFIG;129 hints.ai_flags = AI_ADDRCONFIG; 130 130 hints.ai_family = AF_UNSPEC; 131 131 … … 149 149 enet_address_get_host_x (const ENetAddress * address, char * name, size_t nameLength, int flags) 150 150 { 151 SOCKADDR_STORAGEsin;152 enet_address_set_sin(( SOCKADDR*) & sin, address, ENET_IPV6);153 154 if ( getnameinfo(( SOCKADDR*) & sin, enet_sa_size (ENET_IPV6), name, nameLength, NULL, 0, flags))151 struct sockaddr_storage sin; 152 enet_address_set_sin((struct sockaddr *) & sin, address, ENET_IPV6); 153 154 if ( getnameinfo((struct sockaddr *) & sin, enet_sa_size (ENET_IPV6), name, nameLength, NULL, 0, flags)) 155 155 return -1; 156 156 … … 173 173 enet_socket_bind (ENetSocket socket, const ENetAddress * address, ENetAddressFamily family) 174 174 { 175 SOCKADDR_STORAGEsin;175 struct sockaddr_storage sin; 176 176 177 177 if (address != NULL) 178 178 { 179 enet_address_set_sin(( SOCKADDR*) & sin, address, family);179 enet_address_set_sin((struct sockaddr *) & sin, address, family); 180 180 } 181 181 else 182 182 { 183 183 ENetAddress address_ = { ENET_HOST_ANY_INIT, 0, 0 }; 184 enet_address_set_sin(( SOCKADDR*) & sin, & address_, family);185 } 186 187 return bind (socket, ( SOCKADDR*) & sin, enet_sa_size(family)) == SOCKET_ERROR ? -1 : 0;184 enet_address_set_sin((struct sockaddr *) & sin, & address_, family); 185 } 186 187 return bind (socket, (struct sockaddr *) & sin, enet_sa_size(family)) == SOCKET_ERROR ? -1 : 0; 188 188 } 189 189 … … 197 197 enet_socket_create (ENetSocketType type, ENetAddressFamily family) 198 198 { 199 return socket (enet_af (family), type == ENET_SOCKET_TYPE_DATAGRAM ? SOCK_DGRAM : SOCK_STREAM, 0); 199 ENetSocket sock = socket (enet_af (family), type == ENET_SOCKET_TYPE_DATAGRAM ? SOCK_DGRAM : SOCK_STREAM, 0); 200 return sock; 200 201 } 201 202 … … 238 239 enet_socket_connect (ENetSocket socket, const ENetAddress * address, ENetAddressFamily family) 239 240 { 240 SOCKADDR_STORAGEsin;241 enet_address_set_sin(( SOCKADDR*) & sin, address, family);242 243 return connect (socket, ( SOCKADDR *) & sin, enet_sa_size(family)) == SOCKET_ERROR ? -1 : 0;241 struct sockaddr_storage sin; 242 enet_address_set_sin((struct sockaddr *) & sin, address, family); 243 244 return connect (socket, (struct sockaddr *) & sin, enet_sa_size (family)) == SOCKET_ERROR ? -1 : 0; 244 245 } 245 246 … … 248 249 { 249 250 SOCKET result; 250 SOCKADDR_STORAGEsin;251 int sinLength = enet_sa_size (family);251 struct sockaddr_storage sin; 252 socklen_t sinLength = enet_sa_size (family); 252 253 253 254 result = accept (socket, 254 address != NULL ? ( SOCKADDR*) & sin : NULL,255 address != NULL ? (struct sockaddr *) & sin : NULL, 255 256 address != NULL ? & sinLength : NULL); 256 257 … … 260 261 if (address != NULL) 261 262 { 262 enet_address_set_address(address, ( SOCKADDR*) & sin);263 enet_address_set_address(address, (struct sockaddr *) & sin); 263 264 } 264 265 … … 279 280 ENetAddressFamily family) 280 281 { 281 SOCKADDR_STORAGEsin;282 struct sockaddr_storage sin; 282 283 DWORD sentLength; 283 284 284 285 if (address != NULL) 285 286 { 286 enet_address_set_sin(( SOCKADDR*) & sin, address, family);287 enet_address_set_sin((struct sockaddr *) & sin, address, family); 287 288 } 288 289 … … 292 293 & sentLength, 293 294 0, 294 address != NULL ? ( SOCKADDR*) & sin : 0,295 address != NULL ? (struct sockaddr *) & sin : 0, 295 296 address != NULL ? enet_sa_size (family) : 0, 296 297 NULL, … … 316 317 DWORD flags = 0, 317 318 recvLength; 318 SOCKADDR_STORAGEsin;319 struct sockaddr_storage sin; 319 320 320 321 if (WSARecvFrom (socket, … … 323 324 & recvLength, 324 325 & flags, 325 address != NULL ? ( SOCKADDR*) & sin : NULL,326 address != NULL ? (struct sockaddr *) & sin : NULL, 326 327 address != NULL ? & sinLength : NULL, 327 328 NULL, … … 343 344 if (address != NULL) 344 345 { 345 enet_address_set_address(address, ( SOCKADDR*) & sin);346 enet_address_set_address(address, (struct sockaddr *) & sin); 346 347 } 347 348
Note: See TracChangeset
for help on using the changeset viewer.