0
|
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 |
* which accompanies this distribution, and is available
|
|
6 |
*
|
|
7 |
* Initial Contributors:
|
|
8 |
* Nokia Corporation - initial contribution.
|
|
9 |
*
|
|
10 |
* Contributors:
|
|
11 |
*
|
|
12 |
*
|
|
13 |
*/
|
|
14 |
|
|
15 |
|
|
16 |
#ifndef _WSOCK_PROTOCOL_H_
|
|
17 |
#define _WSOCK_PROTOCOL_H_
|
|
18 |
|
|
19 |
#include <nifif.h>
|
|
20 |
#include <es_prot.h>
|
|
21 |
#include <time.h>
|
|
22 |
#include "WinsockInterface.h"
|
1
|
23 |
#include <es_prot_internal.h>
|
|
24 |
#include <nifif_internal.h>
|
|
25 |
|
0
|
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 |
*/
|