|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // MacTableManager.cpp |
|
15 // Hardware address manager class implementation. |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalTechnology |
|
22 */ |
|
23 #include "dhcphwaddrmanager.h" |
|
24 |
|
25 /** |
|
26 * Constants used to compare with the received hardware address. Macro __GNUC__ is defined to |
|
27 * gccxml build error "value too large for type 'long'" avoid the error, though it can expand |
|
28 * the 'Uint64' to 'long long unsigned int' |
|
29 * |
|
30 * @internalTechnology |
|
31 */ |
|
32 #ifdef __GNUC__ |
|
33 const Uint64 KAnyMac = 0xFF; |
|
34 const Uint64 KResetMac = 0x00; |
|
35 #else |
|
36 const Uint64 KAnyMac = 0xFFFFFFFFFFFF; |
|
37 const Uint64 KResetMac = 0x000000000000; |
|
38 #endif //__GNUC__ |
|
39 |
|
40 /** |
|
41 * Constructor |
|
42 * |
|
43 * @internalTechnology |
|
44 * |
|
45 */ |
|
46 CDhcpHwAddrManager::CDhcpHwAddrManager() |
|
47 { |
|
48 |
|
49 } |
|
50 |
|
51 /** |
|
52 * Destructor frees the list |
|
53 * |
|
54 * @internalTechnology |
|
55 * |
|
56 */ |
|
57 CDhcpHwAddrManager::~CDhcpHwAddrManager() |
|
58 { |
|
59 iHardwareAddressList.Close(); |
|
60 } |
|
61 |
|
62 /** |
|
63 * Static function to create the instance of CDhcpHwAddrManager. |
|
64 * |
|
65 * @internalTechnology |
|
66 * |
|
67 */ |
|
68 CDhcpHwAddrManager* CDhcpHwAddrManager::NewL() |
|
69 { |
|
70 return new (ELeave) CDhcpHwAddrManager(); |
|
71 } |
|
72 |
|
73 /** |
|
74 * Function to check that atleast any one of the harware address is provisioned or not. |
|
75 * |
|
76 * @internalTechnology |
|
77 * @return - ETrue if the list has at least one entry, otherwise EFalse. |
|
78 */ |
|
79 TBool CDhcpHwAddrManager::IsHwAddressProvisioned() |
|
80 { |
|
81 return (iHardwareAddressList.Count() > 0) ? ETrue : EFalse; |
|
82 } |
|
83 |
|
84 /** |
|
85 * Function inserts the provided Hardware Address into RArray. If the received address (KResetMac) |
|
86 * is to reset the iHardwareAddressList, then clears the list. |
|
87 * |
|
88 * @internalTechnology |
|
89 * @param aInt - 48 bits of hardware address. |
|
90 */ |
|
91 void CDhcpHwAddrManager::Insert(const Uint64& aInt) |
|
92 { |
|
93 if(aInt == KResetMac) |
|
94 { |
|
95 iHardwareAddressList.Close(); |
|
96 return; |
|
97 } |
|
98 TInt index = iHardwareAddressList.Find(aInt, TIdentityRelation<Uint64>()); |
|
99 if(index == KErrNotFound) |
|
100 { |
|
101 iHardwareAddressList.Append(aInt); |
|
102 } |
|
103 } |
|
104 |
|
105 /** |
|
106 * Function identfies whether the received Hardware Address is Provisioned by the control |
|
107 * application or not. |
|
108 * |
|
109 * @internalTechnology |
|
110 * @param aInt - 48 bits of hardware address. |
|
111 * @return - ETrue, if the received address exists in the list, otherwise EFalse. |
|
112 */ |
|
113 TBool CDhcpHwAddrManager::Provisioned(const Uint64& aInt) |
|
114 { |
|
115 |
|
116 return ( iHardwareAddressList.Find(aInt, TIdentityRelation<Uint64>()) == KErrNotFound )? EFalse : ETrue; |
|
117 } |
|
118 |
|
119 /** |
|
120 * Function identfies whether the DHCP server shall provide IP to any client or not. |
|
121 * If the provided hardware address is KAnyMac, then DHCP assigns IP in FCFS basis. |
|
122 * |
|
123 * @internalTechnology |
|
124 * @return - ETrue if the application provides KAnyMac to DHCP server, otherwise EFlase. |
|
125 */ |
|
126 TBool CDhcpHwAddrManager::IsAnyClientAllowed() |
|
127 { |
|
128 return ( iHardwareAddressList.Find(KAnyMac, TIdentityRelation<Uint64>()) == KErrNotFound )? EFalse : ETrue; |
|
129 } |