|
1 /* |
|
2 * Copyright (c) 2006-2007 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 |
|
20 |
|
21 #ifndef CNATFWUNSAFXORMAPPEDADDRESSATTRIBUTE_H |
|
22 #define CNATFWUNSAFXORMAPPEDADDRESSATTRIBUTE_H |
|
23 |
|
24 // INCLUDES |
|
25 #include "natfwunsafaddressattribute.h" |
|
26 #include "natfwunsaftransactionid.h" |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 |
|
30 // CLASS DECLARATION |
|
31 /** |
|
32 * Class for XOR-MAPPED-ADDRESS attribute. |
|
33 */ |
|
34 class CNATFWUNSAFXorMappedAddressAttribute : public CNATFWUNSAFAddressAttribute |
|
35 { |
|
36 public: // Constructors and destructor |
|
37 |
|
38 /** |
|
39 * Decodes an attribute from a byte stream. |
|
40 * This version is for lookup table. |
|
41 * @param aByteStream Byte stream, containing attribute type, |
|
42 * length and value. |
|
43 * @return Decoded UNSAF attribute, ownership is transferred. |
|
44 */ |
|
45 static CNATFWUNSAFAttribute* DecodeAttributeL( |
|
46 const TDesC8& aByteStream); |
|
47 |
|
48 /** |
|
49 * Creates a new instance of CNATFWUNSAFXorMappedAddressAttribute |
|
50 * @param aAddress the address |
|
51 * @param aTransactionID transaction ID to be used when |
|
52 * encoding the attribute value. |
|
53 * @return A new instance of CNATFWUNSAFXorMappedAddressAttribute |
|
54 * ownership is transferred. |
|
55 */ |
|
56 IMPORT_C static CNATFWUNSAFXorMappedAddressAttribute* NewL( |
|
57 const TInetAddr& aAddress, |
|
58 const TNATFWUNSAFTransactionID& aTransactionID); |
|
59 |
|
60 /** |
|
61 * Creates a new instance of CNATFWUNSAFXorMappedAddressAttribute and |
|
62 * pushes it to the CleanupStack. |
|
63 * @param aAddress the address |
|
64 * @param aTransactionID transaction ID to be used when |
|
65 * encoding the attribute value. |
|
66 * @return A new instance of CNATFWUNSAFXorMappedAddressAttribute, |
|
67 * ownership is transferred. |
|
68 */ |
|
69 IMPORT_C static CNATFWUNSAFXorMappedAddressAttribute* NewLC( |
|
70 const TInetAddr& aAddress, |
|
71 const TNATFWUNSAFTransactionID& aTransactionID); |
|
72 |
|
73 /** |
|
74 * Destructor, deletes the resources of |
|
75 * CNATFWUNSAFXorMappedAddressAttribute. |
|
76 */ |
|
77 ~CNATFWUNSAFXorMappedAddressAttribute(); |
|
78 |
|
79 public: // From CNATFWUNSAFAttribute |
|
80 |
|
81 CNATFWUNSAFAttribute::TType Type() const; |
|
82 |
|
83 public: // New functions |
|
84 |
|
85 /** |
|
86 * Sets the transaction ID used when encoding the attribute value. |
|
87 * @param aTransactionID transaction ID to be used when |
|
88 * encoding the attribute value. |
|
89 */ |
|
90 void SetTransactionIdL(const TNATFWUNSAFTransactionID& aTransactionID); |
|
91 |
|
92 /** |
|
93 * Gets the transaction ID used when encoding the attribute value. |
|
94 */ |
|
95 const TNATFWUNSAFTransactionID& TransactionID() const; |
|
96 |
|
97 /** |
|
98 * Sets the transaction ID used when encoding the attribute value. |
|
99 * Modifies the address by XORing it with the new transaction ID. |
|
100 * @param aTransactionID transaction ID to be used when |
|
101 * encoding the attribute value. |
|
102 */ |
|
103 IMPORT_C void SetTransactionIDAndXorL( |
|
104 const TNATFWUNSAFTransactionID& aTransactionID); |
|
105 |
|
106 private: // From CNATFWUNSAFAddressAttribute |
|
107 |
|
108 virtual void EncodeAddressL(TDes8& aResult) const; |
|
109 |
|
110 private: // New functions |
|
111 |
|
112 TUint16 XorPort() const; |
|
113 |
|
114 TInetAddr XorAddress() const; |
|
115 |
|
116 private: // Constructors |
|
117 |
|
118 CNATFWUNSAFXorMappedAddressAttribute(); |
|
119 |
|
120 CNATFWUNSAFXorMappedAddressAttribute(const TInetAddr& aAddress); |
|
121 |
|
122 private: // Data |
|
123 |
|
124 TNATFWUNSAFTransactionID iTransactionID; |
|
125 }; |
|
126 |
|
127 #endif // CNATFWUNSAFXORMAPPEDADDRESSATTRIBUTE_H |
|
128 |
|
129 |