sdkcreationmw/sdkruntimes/wsock/inc/WinsockUtils.h
author rajpuroh
Wed, 21 Apr 2010 09:56:53 +0530
changeset 1 ac50fd48361b
parent 0 b26acd06ea60
permissions -rw-r--r--
Second Contribution
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
* which accompanies this distribution, and is available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     6
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     7
* Initial Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     8
* Nokia Corporation - initial contribution.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     9
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    10
* Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    11
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    12
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    13
*/
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    14
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    15
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    16
#ifndef _WSOCK_UTILS_H_
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    17
#define _WSOCK_UTILS_H_
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    18
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    19
#include <in_sock.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    20
#include <winsock2.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    21
#include <ws2tcpip.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    22
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    23
// SetPort is defined somewhere in Windows headers as SetPortW.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    24
// Undo the damage.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    25
#undef SetPort
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    26
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    27
/* 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    28
 * The right sockaddr_in6 structure. Some Microsoft's SDKs contain wrong
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    29
 * definition of sockaddr_in6 in ws2tcpip.h (without sin6_scope_id field)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    30
 */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    31
struct SockaddrIn6 {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    32
    short   sin6_family;        /* AF_INET6 */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    33
    u_short sin6_port;          /* Transport level port number */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    34
    u_long  sin6_flowinfo;      /* IPv6 flow information */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    35
    struct in_addr6 sin6_addr;  /* IPv6 address */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    36
    u_long sin6_scope_id;       /* set of interfaces for a scope */
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    37
};
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    38
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    39
typedef union _WSockAddr {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    40
    struct sockaddr Address;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    41
    struct sockaddr_in AddressIn;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    42
    struct SockaddrIn6 AddressIn6;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    43
} WSockAddr;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    44
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    45
#define SOCKADDR_SIZE sizeof(WSockAddr)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    46
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    47
#ifdef EKA2
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    48
#  define BEGIN_WIN32() Emulator::Escape()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    49
#  define END_WIN32() Emulator::Reenter()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    50
#  include <emulator.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    51
#else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    52
#  define BEGIN_WIN32() ((void)0)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    53
#  define END_WIN32() ((void)0)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    54
#endif // EKA2
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    55
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    56
namespace WinsockUtils
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    57
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    58
    int ToSockAddr(WSockAddr* aToAddr, const TSockAddr* aFromAddr);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    59
    TBool ToInetAddr(TSockAddr* aToAddr, const WSockAddr* aFromAddr);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    60
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    61
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    62
#endif // _WSOCK_UTILS_H_
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
 * Local Variables:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    66
 * mode: c++
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    67
 * c-basic-offset: 4
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    68
 * indent-tabs-mode: nil
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    69
 * End:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    70
 */