|
1 /** @file |
|
2 * Copyright (c) 2008-2008 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 C_CUPNPIPFILTERING_H |
|
20 #define C_CUPNPIPFILTERING_H |
|
21 |
|
22 #include <e32cmn.h> |
|
23 #include <in_sock.h> |
|
24 #include <ES_SOCK.H> |
|
25 #include <CommDbConnPref.h> |
|
26 |
|
27 #include "upnpmessagehandlerengine.h" |
|
28 #include "upnpmessagehandlerengineobserver.h" |
|
29 #include "upnpconnectionmanagerproxy.h" |
|
30 |
|
31 class CUpnpIPFilteringDNSQuery; |
|
32 |
|
33 class CUpnpIPFiltering : public CBase |
|
34 { |
|
35 |
|
36 public: |
|
37 /** |
|
38 * Two-phased constructor. |
|
39 * @param aSocketServer |
|
40 * @param aIap an interface numbe which going to be use for connection |
|
41 * @param aObserver |
|
42 */ |
|
43 static CUpnpIPFiltering* NewL( RSocketServ& aSocketServer, TInt aIap, |
|
44 MMessageHandlerEngineObserver& aObserver ); |
|
45 /** |
|
46 * Two-phased constructor. |
|
47 * @param aSocketServer |
|
48 * @param aIap an interface numbe which going to be use for connection |
|
49 * @param aObserver |
|
50 */ |
|
51 static CUpnpIPFiltering* NewLC( RSocketServ& aSocketServer, TInt aIap, |
|
52 MMessageHandlerEngineObserver& aObserver ); |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 virtual ~CUpnpIPFiltering(); |
|
58 |
|
59 /** |
|
60 * Adds address to the whitelist |
|
61 * @since S60 v3.2 |
|
62 * @param aAddress anaddress which going to be addres to the list |
|
63 * @return KErrNone if succesfully added or index number if already exist on list |
|
64 */ |
|
65 TInt AddAddressL( const TInetAddr& aAddress ); |
|
66 |
|
67 /** |
|
68 * Adds address to the whitelist |
|
69 * @since S60 v3.2 |
|
70 * @param aQuery query to DNS server |
|
71 */ |
|
72 void AddAddressL( CUpnpIPFilteringDNSQuery* aQuery ); |
|
73 |
|
74 |
|
75 /** |
|
76 * Removes address from the whitelist |
|
77 * @since S60 v3.2 |
|
78 * @param aAddress anaddress which going to be removed |
|
79 * @return KErrNone if succesfully removed |
|
80 */ |
|
81 TInt RemoveAddressL( const TInetAddr& aAddress ); |
|
82 |
|
83 /** |
|
84 * Removes address from the whitelist |
|
85 * @since S60 v3.2 |
|
86 * @param aQuery query to DNS server |
|
87 * @return KErrNone if succesfully removed |
|
88 */ |
|
89 void RemoveAddressL( CUpnpIPFilteringDNSQuery* aQuery ); |
|
90 |
|
91 /** |
|
92 * Removes all addressses from the list |
|
93 * |
|
94 */ |
|
95 TInt RemoveAll( ); |
|
96 |
|
97 /** |
|
98 * Checks if address is on the whitelist |
|
99 * @since S60 v3.2 |
|
100 * @param aAddress an address to be checked |
|
101 * @return True if address is on whitelist |
|
102 */ |
|
103 TBool IsAllowed( const TInetAddr& aAddress ) const; |
|
104 |
|
105 /** |
|
106 * Counts object on the whitelist |
|
107 * @since S60 v3.2 |
|
108 * @return number of addresses on the list |
|
109 */ |
|
110 TInt Count() const; |
|
111 |
|
112 /** |
|
113 * |
|
114 * @since S60 v3.2 |
|
115 * @return list of addresses |
|
116 */ |
|
117 const TDesC8& GetIPFilterList( ); |
|
118 |
|
119 /** |
|
120 * Completes asynchronous DNS request, and removes it from the procesed list |
|
121 */ |
|
122 void RequestCompleted( CUpnpIPFilteringDNSQuery* iQuery ); |
|
123 |
|
124 |
|
125 /** |
|
126 * Callback if there are changes on the list |
|
127 */ |
|
128 void IPListChange(); |
|
129 |
|
130 private: |
|
131 |
|
132 |
|
133 CUpnpIPFiltering( RSocketServ& aSocketServer, TInt aIap, |
|
134 MMessageHandlerEngineObserver& aObserver ); |
|
135 |
|
136 void ConstructL( RSocketServ& aSocketServer ); |
|
137 |
|
138 |
|
139 TInt FindInList( const TInetAddr& aAddress ) const; |
|
140 |
|
141 void IPList2Des8L(); |
|
142 |
|
143 private: |
|
144 |
|
145 |
|
146 RArray<TInetAddr> iAllowedIPsList; //owned |
|
147 |
|
148 RSocketServ& iSockServ; //not owned |
|
149 |
|
150 CUpnpConnectionManagerProxy* iConnectionManagerProxy; //owned |
|
151 |
|
152 TInt iActiveIap; |
|
153 |
|
154 RBuf8 iListBuf; //owned |
|
155 |
|
156 RPointerArray<CUpnpIPFilteringDNSQuery> iDNSQueriesList; //owned |
|
157 |
|
158 MMessageHandlerEngineObserver& iObserver;//not owned - changes on the list |
|
159 }; |
|
160 |
|
161 #endif // C_CUPNPIPFILTERING_H |