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