sdkcreationmw/sdkruntimes/wsock/inc/WinsockProtocol.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_PROTOCOL_H_
       
    20 #define _WSOCK_PROTOCOL_H_
       
    21 
       
    22 #include <nifif.h>
       
    23 #include <es_prot.h>
       
    24 #include <time.h>
       
    25 #include "WinsockInterface.h"
       
    26 
       
    27 // IpHlpApi.dll data structures, needed by GetAdaptersInfo
       
    28 typedef struct _WinsockIpAddressString {
       
    29     TText8 String[16];
       
    30 } WinsockIpAddressString;
       
    31 typedef struct _WinsockIpAddrString {
       
    32     struct _WinsockIpAddrString* Next;
       
    33     WinsockIpAddressString IpAddress;
       
    34     WinsockIpAddressString IpMask;
       
    35     TUint32 Context;
       
    36 } WinsockIpAddrString;
       
    37 typedef struct _WinsockIpAdapterInfo {
       
    38     struct _WinsockIpAdapterInfo* Next;
       
    39     TUint32 ComboIndex;
       
    40     TText8 AdapterName[260];
       
    41     TText8 Description[132];
       
    42     TUint AddressLength;
       
    43     TUint8 Address[8];
       
    44     TUint32 Index;
       
    45     TUint Type;
       
    46     TUint DhcpEnabled;
       
    47     WinsockIpAddrString* CurrentIpAddress;
       
    48     WinsockIpAddrString IpAddressList;
       
    49     WinsockIpAddrString GatewayList;
       
    50     WinsockIpAddrString DhcpServer;
       
    51     TBool HaveWins;
       
    52     WinsockIpAddrString PrimaryWinsServer;
       
    53     WinsockIpAddrString SecondaryWinsServer;
       
    54     time_t LeaseObtained;
       
    55     time_t LeaseExpires;
       
    56 } WinsockIpAdapterInfo;
       
    57 
       
    58 // CWinsockProtocol
       
    59 struct TWinProtocolDesc;
       
    60 class CWinsockServProvider;
       
    61 class CWinsockProtocol : public CProtocolBase, public MNifIfUser
       
    62 {
       
    63     typedef TUint (__stdcall* GetAdaptersInfoProc)
       
    64         (WinsockIpAdapterInfo* aAdapterInfo, TUint* aOutBufLen);
       
    65 
       
    66 private:
       
    67     MNifIfNotify* iIfNotify;
       
    68     CWinsockInterface* iWinsockInterface;
       
    69     const TWinProtocolDesc* iProtocolDesc;
       
    70     RPointerArray<CWinsockServProvider> iReadPending;
       
    71     void* iIpHlpApi;        // Handle to IPHLPAPI.DLL
       
    72     GetAdaptersInfoProc iGetAdapterInfo; // Pointer to GetAdaptersInfo
       
    73 
       
    74 public:
       
    75     CWinsockProtocol(const TWinProtocolDesc* aProtocolDesc);
       
    76     virtual ~CWinsockProtocol();
       
    77 
       
    78     const TWinProtocolDesc* ProtocolDesc() const;
       
    79     TBool IsStreamProtocol() const;
       
    80     TBool IsDatagramProtocol() const;
       
    81 
       
    82     void DataSent(TUint aBytes);
       
    83     void DataReceived(TUint aBytes);
       
    84     WinsockIpAdapterInfo* GetAdapterInfo();
       
    85     void SetReadPending(CWinsockServProvider* aSocket, TBool aPending);
       
    86     TBool ReadPending() const;
       
    87 
       
    88     // CProtocolBase
       
    89     virtual CServProviderBase* NewSAPL(TUint aSockType);
       
    90     virtual CHostResolvProvdBase* NewHostResolverL();
       
    91     virtual void Identify(TServerProtocolDesc* aProtocolDesc) const;
       
    92     virtual TInt GetOption(TUint aLevel,TUint aName,TDes8& aOption,CProtocolBase* aSourceProtocol);
       
    93 
       
    94     // MNifIfUser
       
    95     virtual void IfUserBindFailure(TInt aResult, TAny* aId);
       
    96     virtual void IfUserNewInterfaceL(CNifIfBase* aIf, TAny* aId);
       
    97     virtual void IfUserInterfaceDown(TInt aResult, CNifIfBase* aIf);
       
    98     virtual void IfUserOpenNetworkLayer();
       
    99     virtual void IfUserCloseNetworkLayer();
       
   100     virtual CProtocolBase* IfUserProtocol();
       
   101     virtual TBool IfUserIsNetworkLayerActive();
       
   102 };
       
   103 
       
   104 // Inline methods
       
   105 inline const TWinProtocolDesc* CWinsockProtocol::ProtocolDesc() const
       
   106     { return iProtocolDesc; }
       
   107 
       
   108 #endif // _WSOCK_PROTOCOL_H_
       
   109 
       
   110 /**
       
   111  * Local Variables:
       
   112  * mode: c++
       
   113  * c-basic-offset: 4
       
   114  * indent-tabs-mode: nil
       
   115  * End:
       
   116  */