sdkcreationmw/sdkruntimes/wsock/src/WinsockProtocol.cpp
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-2006 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
#define TRACE_PREFIX "WSOCK: Protocol: "
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    20
#include "wsock.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    21
#include "WinsockProtocol.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    22
#include "WinsockProtocolFamily.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    23
#include "WinsockHostResolver.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    24
#include "WinsockServProvider.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    25
#include "WinsockUtils.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    26
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    27
CWinsockProtocol::CWinsockProtocol(const TWinProtocolDesc* aProtocolDesc) :
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    28
iProtocolDesc(aProtocolDesc)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    29
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    30
    TRACE3("[%08X] created %s %S protocol",this,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    31
        (iProtocolDesc->iAddrFamily == KAfInet6) ? _S("IPv6") : _S("IPv4"),
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    32
        &iProtocolDesc->iName);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    33
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    34
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    35
CWinsockProtocol::~CWinsockProtocol()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    36
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    37
    iReadPending.Reset();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    38
    if (iIpHlpApi)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    39
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    40
        BEGIN_WIN32();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    41
        FreeLibrary((HMODULE)iIpHlpApi);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    42
        END_WIN32();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    43
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    44
    TRACE2("[%08X] deleted %S protocol",this,&iProtocolDesc->iName);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    45
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    46
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    47
TBool CWinsockProtocol::IsStreamProtocol() const
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    48
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    49
    return (iProtocolDesc->iSockType == KSockStream);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    50
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    51
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    52
TBool CWinsockProtocol::IsDatagramProtocol() const
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    53
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    54
    return (iProtocolDesc->iSockType == KSockDatagram);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    55
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    56
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    57
void CWinsockProtocol::DataSent(TUint aBytes)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    58
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    59
    if (iWinsockInterface)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    60
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    61
        iWinsockInterface->DataSent(aBytes);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    62
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    63
    else if (iIfNotify)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    64
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    65
        iIfNotify->NotifyDataSent(KNifEntireConnectionSubConnectionId,aBytes);
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
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    69
void CWinsockProtocol::DataReceived(TUint aBytes)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    70
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    71
    if (iWinsockInterface)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    72
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    73
        iWinsockInterface->DataReceived(aBytes);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    74
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    75
    else if (iIfNotify)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    76
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    77
        iIfNotify->NotifyDataReceived(KNifEntireConnectionSubConnectionId,aBytes);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    78
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    79
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    80
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    81
WinsockIpAdapterInfo* CWinsockProtocol::GetAdapterInfo()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    82
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    83
    if (!iIpHlpApi && iIpHlpApi != INVALID_HANDLE_VALUE)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    84
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    85
        BEGIN_WIN32();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    86
        iIpHlpApi = LoadLibraryA("IPHLPAPI.DLL");
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    87
        if (iIpHlpApi)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    88
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    89
            iGetAdapterInfo = (GetAdaptersInfoProc)GetProcAddress((HMODULE)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    90
                              iIpHlpApi, "GetAdaptersInfo");
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    91
            if (iGetAdapterInfo)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    92
            {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    93
                END_WIN32();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    94
            }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    95
            else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    96
            {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    97
                FreeLibrary((HMODULE)iIpHlpApi);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    98
                END_WIN32();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    99
                iIpHlpApi = INVALID_HANDLE_VALUE;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   100
                TRACE("failed to find GetAdaptersInfo in IPHLPAPI.DLL");
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   101
            }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   102
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   103
        else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   104
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   105
            END_WIN32();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   106
            iIpHlpApi = INVALID_HANDLE_VALUE;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   107
            TRACE1("failed to load IPHLPAPI.DLL, err %d",GetLastError());
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   108
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   109
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   110
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   111
    WinsockIpAdapterInfo* info = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   112
    if (iGetAdapterInfo)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   113
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   114
        TUint len = 0;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   115
        BEGIN_WIN32();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   116
        TUint err = iGetAdapterInfo(NULL, &len);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   117
        END_WIN32();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   118
        if (err == ERROR_BUFFER_OVERFLOW && len > 0)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   119
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   120
            info = (WinsockIpAdapterInfo*)User::Alloc(len);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   121
            if (info)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   122
            {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   123
                BEGIN_WIN32();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   124
                err = iGetAdapterInfo(info, &len);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   125
                END_WIN32();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   126
                if (err != ERROR_SUCCESS)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   127
                {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   128
                    TRACE1("GetAdapterInfo err %d",err);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   129
                    User::Free(info);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   130
                    info = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   131
                }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   132
            }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   133
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   134
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   135
    return info;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   136
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   137
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   138
// Notifies CWinsockProtocol that there are unread data in a particular
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   139
// socket.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   140
void CWinsockProtocol::SetReadPending(CWinsockServProvider* aSocket, 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   141
                                      TBool aPending)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   142
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   143
    TInt index = iReadPending.FindInAddressOrder(aSocket);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   144
    if (aPending)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   145
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   146
        if (index < 0)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   147
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   148
            iReadPending.InsertInAddressOrder(aSocket);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   149
            TRACE2("[%08X] %d socket(s) have unread data",this,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   150
                iReadPending.Count());
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   151
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   152
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   153
    else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   154
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   155
        if (index >= 0)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   156
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   157
            iReadPending.Remove(index);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   158
            TRACE2("[%08X] %d socket(s) have unread data",this,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   159
                iReadPending.Count());
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   160
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   161
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   162
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   163
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   164
// Checks if there are any unread data in any socket associated with this
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   165
// protocol.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   166
TBool CWinsockProtocol::ReadPending() const
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   167
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   168
    return (iReadPending.Count() > 0);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   169
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   170
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   171
// CProtocolBase
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   172
CServProviderBase* CWinsockProtocol::NewSAPL(TUint DEBUG_ONLY(aSockType))
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   173
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   174
    TRACE3("[%08X] NewSAPL(%d) for %S",this,aSockType,&iProtocolDesc->iName);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   175
    return CWinsockServProvider::NewL(this);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   176
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   177
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   178
CHostResolvProvdBase* CWinsockProtocol::NewHostResolverL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   179
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   180
    return CWinsockHostResolver::NewL(iProtocolDesc);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   181
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   182
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   183
void CWinsockProtocol::Identify(TServerProtocolDesc* aProtocolDesc) const
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   184
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   185
    *aProtocolDesc = *iProtocolDesc;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   186
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   187
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   188
TInt CWinsockProtocol::GetOption(TUint aLevel, TUint aName, TDes8& aOption, 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   189
                                 CProtocolBase* aSourceProtocol)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   190
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   191
    if(aLevel == KNifOptLevel)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   192
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   193
        if(aName == KNifOptGetNifIfUser)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   194
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   195
            TNifIfUser ifuser;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   196
            ifuser() = this;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   197
            aOption.Copy(ifuser);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   198
            return KErrNone;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   199
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   200
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   201
    return CProtocolBase::GetOption(aLevel, aName, aOption, aSourceProtocol);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   202
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   203
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   204
// MNifIfUser
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   205
void CWinsockProtocol::IfUserBindFailure(TInt /*aResult*/, TAny* /*aId*/)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   206
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   207
    TRACE1("[%08X] IfUserBindFailure",this);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   208
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   209
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   210
void CWinsockProtocol::IfUserNewInterfaceL(CNifIfBase* aIf, TAny* /*aId*/)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   211
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   212
    TRACE1("[%08X] IfUserNewInterfaceL",this);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   213
    ASSERT(aIf && aIf->Notify());
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   214
    if (aIf) 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   215
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   216
        iWinsockInterface = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   217
        iIfNotify = aIf->Notify();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   218
        CWinsockInterface* mayBeWinsockInterface = (CWinsockInterface*)aIf;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   219
        if (mayBeWinsockInterface->Signature() == KWinsockInterfaceSignature)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   220
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   221
            iWinsockInterface = mayBeWinsockInterface;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   222
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   223
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   224
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   225
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   226
void CWinsockProtocol::IfUserInterfaceDown(TInt /*aResult*/, 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   227
                                           CNifIfBase* DEBUG_ONLY(aIf))
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   228
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   229
    TRACE1("[%08X] IfUserInterfaceDown",this);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   230
    ASSERT(aIf && iIfNotify && (aIf->Notify() == iIfNotify));
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   231
    iIfNotify = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   232
    iWinsockInterface = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   233
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   234
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   235
void CWinsockProtocol::IfUserOpenNetworkLayer()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   236
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   237
    TRACE1("[%08X] IfUserOpenNetworkLayer",this);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   238
    Open();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   239
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   240
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   241
void CWinsockProtocol::IfUserCloseNetworkLayer()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   242
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   243
    TRACE1("[%08X] IfUserCloseNetworkLayer",this);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   244
    Close();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   245
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   246
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   247
CProtocolBase* CWinsockProtocol::IfUserProtocol()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   248
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   249
    return this;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   250
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   251
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   252
TBool CWinsockProtocol::IfUserIsNetworkLayerActive()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   253
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   254
    TRACE1("[%08X] IfUserIsNetworkLayerActive",this);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   255
    return ETrue;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   256
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   257
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   258
/**
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   259
 * Local Variables:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   260
 * c-basic-offset: 4
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   261
 * indent-tabs-mode: nil
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   262
 * End:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   263
 */