Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7433


Ignore:
Timestamp:
Sep 12, 2010, 10:15:40 PM (14 years ago)
Author:
adrfried
Message:

use the structs itself instead of typedefs

also dropped the superfluous AI_NUMERICSERV

Location:
code/branches/ipv6/src/external/enet
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ipv6/src/external/enet/unix.c

    r7397 r7433  
    146146
    147147    memset(& hints, 0, sizeof (hints));
    148     hints.ai_flags = AI_NUMERICSERV | AI_ADDRCONFIG;
     148    hints.ai_flags = AI_ADDRCONFIG;
    149149    hints.ai_family = AF_UNSPEC;
    150150
     
    282282
    283283    result = accept (socket,
    284                      address != NULL ? (struct sockaddr *) & sin : NULL, 
     284                     address != NULL ? (struct sockaddr *) & sin : NULL,
    285285                     address != NULL ? & sinLength : NULL);
    286286
     
    294294
    295295    return result;
    296 } 
    297    
     296}
     297
    298298void
    299299enet_socket_destroy (ENetSocket socket)
  • code/branches/ipv6/src/external/enet/win32.c

    r7397 r7433  
    6767{
    6868    if (family == ENET_IPV4)
    69         return sizeof (SOCKADDR_IN);
     69        return sizeof (struct sockaddr_in);
    7070    if (family == ENET_IPV6)
    71         return sizeof (SOCKADDR_IN6);
     71        return sizeof (struct sockaddr_in6);
    7272    return 0;
    7373}
    7474
    7575static ENetAddressFamily
    76 enet_address_set_address (ENetAddress * address, const SOCKADDR * sin)
     76enet_address_set_address (ENetAddress * address, const struct sockaddr * sin)
    7777{
    7878    memset (address, 0, sizeof (ENetAddress));
    7979    if (sin -> sa_family == AF_INET)
    8080    {
    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));
    8282        /* 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);
    8484        return ENET_IPV4;
    8585    }
    8686    if (sin -> sa_family == AF_INET6)
    8787    {
    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);
    9191        return ENET_IPV6;
    9292    }
     
    9595
    9696static int
    97 enet_address_set_sin (SOCKADDR * sin, const ENetAddress * address, ENetAddressFamily family)
     97enet_address_set_sin (struct sockaddr * sin, const ENetAddress * address, ENetAddressFamily family)
    9898{
    9999    memset (sin, 0, enet_sa_size(family));
     
    102102      !memcmp (& address -> host, & ENET_HOST_ANY, sizeof(ENetHostAddress))))
    103103    {
    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);
    107107        return 0;
    108108    }
    109109    else if (family == ENET_IPV6)
    110110    {
    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);
    115115        return 0;
    116116    }
     
    122122{
    123123    enet_uint16 port = address -> port;
    124     ADDRINFO hints;
    125     ADDRINFO * result;
    126     ADDRINFO * res;
     124    struct addrinfo hints;
     125    struct addrinfo * result;
     126    struct addrinfo * res;
    127127
    128128    memset(& hints, 0, sizeof (hints));
    129     hints.ai_flags = AI_NUMERICSERV | AI_ADDRCONFIG;
     129    hints.ai_flags = AI_ADDRCONFIG;
    130130    hints.ai_family = AF_UNSPEC;
    131131
     
    149149enet_address_get_host_x (const ENetAddress * address, char * name, size_t nameLength, int flags)
    150150{
    151     SOCKADDR_STORAGE sin;
    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))
    155155        return -1;
    156156
     
    173173enet_socket_bind (ENetSocket socket, const ENetAddress * address, ENetAddressFamily family)
    174174{
    175     SOCKADDR_STORAGE sin;
     175    struct sockaddr_storage sin;
    176176
    177177    if (address != NULL)
    178178    {
    179         enet_address_set_sin((SOCKADDR *) & sin, address, family);
     179        enet_address_set_sin((struct sockaddr *) & sin, address, family);
    180180    }
    181181    else
    182182    {
    183183        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;
    188188}
    189189
     
    197197enet_socket_create (ENetSocketType type, ENetAddressFamily family)
    198198{
    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;
    200201}
    201202
     
    238239enet_socket_connect (ENetSocket socket, const ENetAddress * address, ENetAddressFamily family)
    239240{
    240     SOCKADDR_STORAGE sin;
    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;
    244245}
    245246
     
    248249{
    249250    SOCKET result;
    250     SOCKADDR_STORAGE sin;
    251     int sinLength = enet_sa_size (family);
     251    struct sockaddr_storage sin;
     252    socklen_t sinLength = enet_sa_size (family);
    252253
    253254    result = accept (socket,
    254                      address != NULL ? (SOCKADDR *) & sin : NULL,
     255                     address != NULL ? (struct sockaddr *) & sin : NULL,
    255256                     address != NULL ? & sinLength : NULL);
    256257
     
    260261    if (address != NULL)
    261262    {
    262         enet_address_set_address(address, (SOCKADDR *) & sin);
     263        enet_address_set_address(address, (struct sockaddr *) & sin);
    263264    }
    264265
     
    279280                  ENetAddressFamily family)
    280281{
    281     SOCKADDR_STORAGE sin;
     282    struct sockaddr_storage sin;
    282283    DWORD sentLength;
    283284
    284285    if (address != NULL)
    285286    {
    286         enet_address_set_sin((SOCKADDR *) & sin, address, family);
     287        enet_address_set_sin((struct sockaddr *) & sin, address, family);
    287288    }
    288289
     
    292293                   & sentLength,
    293294                   0,
    294                    address != NULL ? (SOCKADDR *) & sin : 0,
     295                   address != NULL ? (struct sockaddr *) & sin : 0,
    295296                   address != NULL ? enet_sa_size (family) : 0,
    296297                   NULL,
     
    316317    DWORD flags = 0,
    317318          recvLength;
    318     SOCKADDR_STORAGE sin;
     319    struct sockaddr_storage sin;
    319320
    320321    if (WSARecvFrom (socket,
     
    323324                     & recvLength,
    324325                     & flags,
    325                      address != NULL ? (SOCKADDR *) & sin : NULL,
     326                     address != NULL ? (struct sockaddr *) & sin : NULL,
    326327                     address != NULL ? & sinLength : NULL,
    327328                     NULL,
     
    343344    if (address != NULL)
    344345    {
    345         enet_address_set_address(address, (SOCKADDR *) & sin);
     346        enet_address_set_address(address, (struct sockaddr *) & sin);
    346347    }
    347348
Note: See TracChangeset for help on using the changeset viewer.