sdkcreationmw/sdkruntimes/wsock/inc/WinsockUtils.h
changeset 0 b26acd06ea60
child 1 ac50fd48361b
equal deleted inserted replaced
-1:000000000000 0:b26acd06ea60
       
     1 /*
       
     2 * Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef _WSOCK_UTILS_H_
       
    20 #define _WSOCK_UTILS_H_
       
    21 
       
    22 #include <in_sock.h>
       
    23 #include <winsock2.h>
       
    24 #include <ws2tcpip.h>
       
    25 
       
    26 // SetPort is defined somewhere in Windows headers as SetPortW.
       
    27 // Undo the damage.
       
    28 #undef SetPort
       
    29 
       
    30 /* 
       
    31  * The right sockaddr_in6 structure. Some Microsoft's SDKs contain wrong
       
    32  * definition of sockaddr_in6 in ws2tcpip.h (without sin6_scope_id field)
       
    33  */
       
    34 struct SockaddrIn6 {
       
    35     short   sin6_family;        /* AF_INET6 */
       
    36     u_short sin6_port;          /* Transport level port number */
       
    37     u_long  sin6_flowinfo;      /* IPv6 flow information */
       
    38     struct in_addr6 sin6_addr;  /* IPv6 address */
       
    39     u_long sin6_scope_id;       /* set of interfaces for a scope */
       
    40 };
       
    41 
       
    42 typedef union _WSockAddr {
       
    43     struct sockaddr Address;
       
    44     struct sockaddr_in AddressIn;
       
    45     struct SockaddrIn6 AddressIn6;
       
    46 } WSockAddr;
       
    47 
       
    48 #define SOCKADDR_SIZE sizeof(WSockAddr)
       
    49 
       
    50 #ifdef EKA2
       
    51 #  define BEGIN_WIN32() Emulator::Escape()
       
    52 #  define END_WIN32() Emulator::Reenter()
       
    53 #  include <emulator.h>
       
    54 #else
       
    55 #  define BEGIN_WIN32() ((void)0)
       
    56 #  define END_WIN32() ((void)0)
       
    57 #endif // EKA2
       
    58 
       
    59 namespace WinsockUtils
       
    60 {
       
    61     int ToSockAddr(WSockAddr* aToAddr, const TSockAddr* aFromAddr);
       
    62     TBool ToInetAddr(TSockAddr* aToAddr, const WSockAddr* aFromAddr);
       
    63 }
       
    64 
       
    65 #endif // _WSOCK_UTILS_H_
       
    66 
       
    67 /*
       
    68  * Local Variables:
       
    69  * mode: c++
       
    70  * c-basic-offset: 4
       
    71  * indent-tabs-mode: nil
       
    72  * End:
       
    73  */