1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 // |
7 // |
8 // Initial Contributors: |
8 // Initial Contributors: |
9 // Nokia Corporation - initial contribution. |
9 // Nokia Corporation - initial contribution. |
10 // |
10 // |
11 // Contributors: |
11 // Contributors: |
54 * @released |
54 * @released |
55 */ |
55 */ |
56 class TE64Addr |
56 class TE64Addr |
57 { |
57 { |
58 public: |
58 public: |
59 IMPORT_C TE64Addr(); ///< Constructs an address with zero value |
59 IMPORT_C TE64Addr(); //< Constructs an address with zero value |
60 IMPORT_C TE64Addr(const TE64Addr& aAddr); ///< Constructs an address with given value |
60 IMPORT_C TE64Addr(const TE64Addr& aAddr); //< Constructs an address with given value |
61 IMPORT_C TE64Addr(const TInt64& aAddr); ///< Constructs an address with given value |
61 IMPORT_C TE64Addr(const TInt64& aAddr); //< Constructs an address with given value |
62 IMPORT_C TE64Addr(const TUint8* aPtr, TUint aLength); ///< Constructs an address with given value |
62 IMPORT_C TE64Addr(const TUint8* aPtr, TUint aLength); //< Constructs an address with given value |
63 |
63 |
64 IMPORT_C void SetAddr(const TE64Addr& aAddr); ///< Sets the address value |
64 IMPORT_C void SetAddr(const TE64Addr& aAddr); //< Sets the address value |
65 IMPORT_C void SetAddr(const TInt64& aAddr); ///< Sets the address value |
65 IMPORT_C void SetAddr(const TInt64& aAddr); //< Sets the address value |
66 IMPORT_C void SetAddr(const TUint8* aPtr, TUint aLength); ///< Sets the address value |
66 IMPORT_C void SetAddr(const TUint8* aPtr, TUint aLength); //< Sets the address value |
67 |
67 |
68 |
68 |
69 IMPORT_C void SetAddrZero(); ///< Creates a zero address |
69 IMPORT_C void SetAddrZero(); //< Creates a zero address |
70 |
70 |
71 /** |
71 /** |
72 * Creates a random address. |
72 * Creates a random address. |
73 * The Group bit is set to 0. |
73 * The Group bit is set to 0. |
74 * The Universal bit is set to 0. |
74 * The Universal bit is set to 0. |
88 * The Universal bit is set to 0. |
88 * The Universal bit is set to 0. |
89 */ |
89 */ |
90 IMPORT_C void SetAddrRandomNZButNot(const TE64Addr& aAddr); |
90 IMPORT_C void SetAddrRandomNZButNot(const TE64Addr& aAddr); |
91 |
91 |
92 // Really should define TE48Addr for this... -tom |
92 // Really should define TE48Addr for this... -tom |
93 IMPORT_C void SetAddrFromEUI48(const TUint8* aPtr); ///< Reads and converts a value from EUI-48 (6 bytes) |
93 IMPORT_C void SetAddrFromEUI48(const TUint8* aPtr); //< Reads and converts a value from EUI-48 (6 bytes) |
94 |
94 |
95 IMPORT_C void SetGroupBit(TBool aBit = 1); ///< Sets the Group bit to 1 by default |
95 IMPORT_C void SetGroupBit(TBool aBit = 1); //< Sets the Group bit to 1 by default |
96 IMPORT_C void SetUniversalBit(TBool aBit = 1); ///< Sets the Universal bit to 1 by default |
96 IMPORT_C void SetUniversalBit(TBool aBit = 1); //< Sets the Universal bit to 1 by default |
97 |
97 |
98 IMPORT_C TBool Match(const TE64Addr& aAddr) const; ///< TRUE if the address matches given address |
98 IMPORT_C TBool Match(const TE64Addr& aAddr) const; //< TRUE if the address matches given address |
99 IMPORT_C TBool IsZero() const; ///< TRUE if the address is a zero address |
99 IMPORT_C TBool IsZero() const; //< TRUE if the address is a zero address |
100 IMPORT_C TBool IsGroup() const; ///< TRUE if the Group bit is set in the address |
100 IMPORT_C TBool IsGroup() const; //< TRUE if the Group bit is set in the address |
101 IMPORT_C TBool IsUniversal() const; ///< TRUE if the Universal bit is set in the address |
101 IMPORT_C TBool IsUniversal() const; //< TRUE if the Universal bit is set in the address |
102 |
102 |
103 // IMPORT_C TInt Input(const TDesC& aBuf); ///< Reads a value for the address from a string |
103 // IMPORT_C TInt Input(const TDesC& aBuf); //< Reads a value for the address from a string |
104 IMPORT_C void Output(TDes& aBuf) const; ///< Writes the address into a string |
104 IMPORT_C void Output(TDes& aBuf) const; //< Writes the address into a string |
105 |
105 |
106 IMPORT_C static TUint AddrLen(); ///< Returns the size of raw KAfEui64 content format |
106 IMPORT_C static TUint AddrLen(); //< Returns the size of raw KAfEui64 content format |
107 IMPORT_C TUint8* AddrPtr(); ///< Returns a pointer to raw KAfEui64 content format |
107 IMPORT_C TUint8* AddrPtr(); //< Returns a pointer to raw KAfEui64 content format |
108 IMPORT_C const TUint8* AddrPtrC() const; ///< Returns a const pointer to raw KAfEui64 content format |
108 IMPORT_C const TUint8* AddrPtrC() const; //< Returns a const pointer to raw KAfEui64 content format |
109 |
109 |
110 private: |
110 private: |
111 union |
111 union |
112 { |
112 { |
113 TUint8 iAddr8[64 / 8]; |
113 TUint8 iAddr8[64 / 8]; |
172 /** |
172 /** |
173 * Sets the address bytes to given value. |
173 * Sets the address bytes to given value. |
174 * The other TSockAddr fields are not touched. |
174 * The other TSockAddr fields are not touched. |
175 */ |
175 */ |
176 IMPORT_C void SetAddress(const TE64Addr& aAddr); |
176 IMPORT_C void SetAddress(const TE64Addr& aAddr); |
177 IMPORT_C TE64Addr& Address() const; ///< Accesses the address bytes |
177 IMPORT_C TE64Addr& Address() const; //< Accesses the address bytes |
178 |
178 |
179 IMPORT_C TBool Match(const TEui64Addr& aAddr) const; ///< TRUE if the address bytes match the parameter's |
179 IMPORT_C TBool Match(const TEui64Addr& aAddr) const; //< TRUE if the address bytes match the parameter's |
180 IMPORT_C TBool IsZero() const; ///< TRUE if the address bytes are all zeros |
180 IMPORT_C TBool IsZero() const; //< TRUE if the address bytes are all zeros |
181 |
181 |
182 IMPORT_C static TEui64Addr& Cast(const TSockAddr& aAddr); ///< Unsafely casts a TSockAddr to TEui64Addr |
182 IMPORT_C static TEui64Addr& Cast(const TSockAddr& aAddr); //< Unsafely casts a TSockAddr to TEui64Addr |
183 IMPORT_C static TEui64Addr& Cast(const TSockAddr* aAddr); ///< Unsafely casts a TSockAddr to TEui64Addr |
183 IMPORT_C static TEui64Addr& Cast(const TSockAddr* aAddr); //< Unsafely casts a TSockAddr to TEui64Addr |
184 |
184 |
185 protected: |
185 protected: |
186 IMPORT_C SE64Addr* AddrPtr() const; ///< Returns a pointer to KAfEui64 content format |
186 IMPORT_C SE64Addr* AddrPtr() const; //< Returns a pointer to KAfEui64 content format |
187 IMPORT_C static TUint AddrLen(); ///< Returns the size of the KAfEui64 content format |
187 IMPORT_C static TUint AddrLen(); //< Returns the size of the KAfEui64 content format |
188 }; |
188 }; |
189 |
189 |
190 inline TEui64Addr::TEui64Addr(const TE64Addr& aAddr) : TSockAddr() |
190 inline TEui64Addr::TEui64Addr(const TE64Addr& aAddr) : TSockAddr() |
191 { |
191 { |
192 Init(); |
192 Init(); |