2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FNet_LocalDhcpServerImpl.h
19 * @brief This is the header file for the LocalDhcpServerImpl class.
21 * This header file contains declaration of the LocalDhcpServerImpl class.
24 #ifndef _FNET_INTERNAL_LOCAL_DHCP_SERVER_IMPL_H_
25 #define _FNET_INTERNAL_LOCAL_DHCP_SERVER_IMPL_H_
27 #include <tethering.h>
28 #include <wifi-direct.h>
29 #include <FBaseDataType.h>
30 #include <FBaseObject.h>
31 #include <FNetWifiIWifiDirectGroupOwnerListener.h>
32 #include "FNet_NetUtility.h"
34 namespace Tizen { namespace Base
39 namespace Tizen { namespace Base { namespace Collection
42 } } } // Tizen::Base::Collection
44 namespace Tizen { namespace Net { namespace Wifi
46 class WifiDirectDevice;
47 class WifiDirectDeviceInfo;
48 } } } // Tizen::Net::Wifi
50 namespace Tizen { namespace Net
52 class ILocalDhcpServerEventListener;
55 class LocalDhcpServer;
56 class _LocalDhcpServerEvent;
57 class _DhcpNetConnectionEventListenerImpl;
60 * @class _LocalDhcpServerImpl
61 * @brief This class provides methods for managing local DHCP server.
64 * The LocalDhcpServer class provides methods for managing local DHCP server.
65 * The Wi-Fi Direct or USB NDIS required DHCP server for data communication.
67 class _LocalDhcpServerImpl
68 : public Tizen::Base::Object
69 , public Tizen::Net::Wifi::IWifiDirectGroupOwnerListener
74 * This is the constructor for this class.
77 _LocalDhcpServerImpl(void);
80 * This is the destructor for this class.
83 virtual ~_LocalDhcpServerImpl(void);
86 * @see LocalDhcpServer::Construct()
88 result Construct(const LocalDhcpServer* pLocalDhcpServer, const NetConnection& netConnection);
92 * @see LocalDhcpServer::GetLocalDhcpServer()
94 static LocalDhcpServer* GetLocalDhcpServer(const Tizen::Base::Collection::IList* pLocalDhcpServerList,
95 const NetConnection& netConnection);
98 * @see LocalDhcpServer::SetLocalDhcpServerEventListener()
100 result SetLocalDhcpServerEventListener(ILocalDhcpServerEventListener* pListener);
103 * GetDhcpClientInfoListN(), all = true includes local server details, all = false is only connected peers
105 Tizen::Base::Collection::IList* GetDhcpClientInfoListN(bool all = true);
109 * Gets the Impl instance.
112 * @return The pointer to _LocalDhcpServerImpl
113 * @param[in] localDhcpServer An instance of LocalDhcpServer
115 static _LocalDhcpServerImpl* GetInstance(LocalDhcpServer& localDhcpServer);
118 * Gets the Impl instance.
121 * @return The pointer to _LocalDhcpServerImpl
122 * @param[in] localDhcpServer An instance of LocalDhcpServer
124 static const _LocalDhcpServerImpl* GetInstance(const LocalDhcpServer& localDhcpServer);
128 virtual void OnWifiDirectClientAssociated(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, const Tizen::Net::Wifi::WifiDirectDeviceInfo& wifiDirectClientInfo);
129 virtual void OnWifiDirectClientDisassociated(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, const Tizen::Net::Wifi::WifiDirectDeviceInfo& wifiDirectClientInfo, Tizen::Net::Wifi::WifiDirectAssociationTerminationReason reason);
130 virtual void OnWifiDirectGroupDestroyed(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, result r);
131 virtual void OnWifiDirectGroupMemberInfoServiceStarted(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, const NetConnection* pNetConnection, result r);
132 virtual void OnWifiDirectGroupMemberInfoServiceStopped(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, result r);
137 * Callback received for wifi-direct connected peer devices
139 * @return true to continue next loop, false to exit the loop
140 * @param[in] pInfo The information of connected peer
141 * @param[in] pUserData The user data passed on callback registration
143 static bool OnWifiDirectPeerConnected(wifi_direct_connected_peer_info_s* pPeerInfo, void* pUserData);
146 * Callback received for USB connected peer devices
148 * @param[in] client The client of which connection is changed
149 * @param[in] pUserData The user data passed on callback registration
151 static bool OnUsbPeerConnected(tethering_client_h client, void* pUserdata);
154 * Converts wifi_direct_connected_peer_info_s to DhcpClientInfo
156 static result ConvertDhcpClientInfo(const wifi_direct_connected_peer_info_s* pPeerInfo, DhcpClientInfo& dhcpClientInfo);
159 * Convert MAC address to formatted address
161 static Tizen::Base::String ConvertMacAddress(char* pMacAddress);
164 * Gets Local dHCP server info
166 result GetLocalDhcpServerInfo(DhcpClientInfo& dhcpClientInfo);
169 * Get usb connected Client info
172 static result ConvertDhcpClientInfo(tethering_client_h clientHandle, DhcpClientInfo& dhcpClientInfo);
175 * Converts WifiDirectDeviceInfo to DhcpClientInfo
178 result ConvertDhcpClientInfo(const Tizen::Net::Wifi::WifiDirectDeviceInfo& wifiDirectdeviceInfo, DhcpClientInfo& dhcpClientInfo);
181 * Get peer info from local list based on mac-address
184 DhcpClientInfo* GetDhcpConnectedPeerInfo(const Tizen::Base::String& macAddress, bool remove = false);
187 * Add connected peer info into local dhcp info list
189 result AddDhcpConnectedPeerInfo(const DhcpClientInfo& dhcpClientInfo);
192 * Set connected peer local dhcp info list
194 void SetDhcpConnectedPeerInfoList(Tizen::Base::Collection::IList* pList);
197 * Get connected peer local dhcp info list
199 Tizen::Base::Collection::IList* GetDhcpConnectedPeerInfoList();
203 * This is the copy constructor for this class. @n
204 * Do @b not use directly.
206 * @param[in] rhs An instance of _LocalDhcpServerImpl
208 _LocalDhcpServerImpl(const _LocalDhcpServerImpl& rhs);
211 * This is the assignment operator. Do @b not use directly.
213 * @param[in] rhs An instance of _LocalDhcpServerImpl
215 _LocalDhcpServerImpl& operator =(const _LocalDhcpServerImpl& rhs);
218 std::unique_ptr<_LocalDhcpServerEvent> __pLocalDhcpServerEvent; // event pointer
219 NetConnection* __pNetConnection; // refernce, no ownership
220 std::unique_ptr<NetConnection> __pNetConnectionClone; // cloned net connection, for events
221 std::unique_ptr<_DhcpNetConnectionEventListenerImpl> __pNetConnectionListener; // Net Conncetion event Listener
222 tethering_h __pUsbTetheringHandle; // access point handle
223 std::unique_ptr<Tizen::Base::Collection::ArrayList, _CollectionDeleter> __pDhcpConnectedPeerInfoList; // list of connected peer info
224 Tizen::Net::Wifi::WifiDirectDevice* __pDevice;
226 bool __isConstructed; // status
227 bool __isConnectedNetwork;
229 friend class _DhcpNetConnectionEventListenerImpl;
230 }; // _LocalDhcpServerImpl
234 #endif // _FNET_INTERNAL_LOCAL_DHCP_SERVER_IMPL_H_