|
1 /* |
|
2 * Copyright (c) 2009 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 #include "ikev2ipsecsarekeydata.h" |
|
19 |
|
20 _LIT8(KZeroDescriptor, ""); |
|
21 |
|
22 CIpsecSARekeyData* CIpsecSARekeyData::NewL(const TInt aReplayWindow, |
|
23 const TIpsecSALifetime* aHard, |
|
24 const TIpsecSALifetime* aSoft, |
|
25 const CArrayFix<TIkeV2TrafficSelector>& aTS_i, |
|
26 const CArrayFix<TIkeV2TrafficSelector>& aTS_r, |
|
27 const TDesC8& aLocalId, const TDesC8& aRemoteId) |
|
28 { |
|
29 CIpsecSARekeyData* self = |
|
30 new (ELeave)CIpsecSARekeyData(aReplayWindow, aHard, aSoft); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(aTS_i, aTS_r, aLocalId, aRemoteId); |
|
33 CleanupStack::Pop(); |
|
34 return self; |
|
35 } |
|
36 |
|
37 |
|
38 CIpsecSARekeyData::CIpsecSARekeyData(const TInt aReplayWindow, |
|
39 const TIpsecSALifetime* aHard, |
|
40 const TIpsecSALifetime* aSoft) |
|
41 :iReplayWindow(aReplayWindow), iHard(*aHard), iSoft(*aSoft), |
|
42 iTS_i(0), iTS_r(0), iLocalId(0), iRemoteId(0) |
|
43 { |
|
44 } |
|
45 |
|
46 |
|
47 void CIpsecSARekeyData::ConstructL(const CArrayFix<TIkeV2TrafficSelector>& aTS_i, |
|
48 const CArrayFix<TIkeV2TrafficSelector>& aTS_r, |
|
49 const TDesC8& aLocalId, const TDesC8& aRemoteId) |
|
50 { |
|
51 |
|
52 iTS_i = new (ELeave) CArrayFixFlat<TIkeV2TrafficSelector>(aTS_i.Count()); |
|
53 for (TInt i = 0; i < aTS_i.Count(); i++) |
|
54 { |
|
55 iTS_i->AppendL(aTS_i[i]); |
|
56 } |
|
57 |
|
58 iTS_r = new (ELeave) CArrayFixFlat<TIkeV2TrafficSelector>(aTS_r.Count()); |
|
59 for (TInt i = 0; i < aTS_r.Count(); i++) |
|
60 { |
|
61 iTS_r->AppendL(aTS_r[i]); |
|
62 } |
|
63 |
|
64 iLocalId = aLocalId.AllocL(); |
|
65 iRemoteId = aRemoteId.AllocL(); |
|
66 } |
|
67 |
|
68 |
|
69 CIpsecSARekeyData::~CIpsecSARekeyData() |
|
70 { |
|
71 delete iTS_i; |
|
72 delete iTS_r; |
|
73 delete iLocalId; |
|
74 delete iRemoteId; |
|
75 } |
|
76 |
|
77 |
|
78 TInt CIpsecSARekeyData::ReplayWindow() const |
|
79 { |
|
80 return iReplayWindow; |
|
81 } |
|
82 |
|
83 |
|
84 TIpsecSALifetime CIpsecSARekeyData::HardLifetime() const |
|
85 { |
|
86 return iHard; |
|
87 } |
|
88 |
|
89 |
|
90 TIpsecSALifetime CIpsecSARekeyData::SoftLifetime() const |
|
91 { |
|
92 return iSoft; |
|
93 } |
|
94 |
|
95 const TPtrC8 CIpsecSARekeyData::LocalId() const |
|
96 { |
|
97 if (iLocalId == NULL) |
|
98 { |
|
99 return KZeroDescriptor(); |
|
100 } |
|
101 else |
|
102 { |
|
103 return TPtrC8(*iLocalId); |
|
104 } |
|
105 } |
|
106 |
|
107 |
|
108 const TPtrC8 CIpsecSARekeyData::RemoteId() const |
|
109 { |
|
110 if (iRemoteId == NULL) |
|
111 { |
|
112 return KZeroDescriptor(); |
|
113 } |
|
114 else |
|
115 { |
|
116 return TPtrC8(*iRemoteId); |
|
117 } |
|
118 } |
|
119 |
|
120 |
|
121 CArrayFix<TIkeV2TrafficSelector>* CIpsecSARekeyData::TsIL() const |
|
122 { |
|
123 __ASSERT_DEBUG(iTS_i != NULL, User::Invariant()); |
|
124 return CopyTsL(*iTS_i); |
|
125 } |
|
126 |
|
127 |
|
128 CArrayFix<TIkeV2TrafficSelector>* CIpsecSARekeyData::TsRL() const |
|
129 { |
|
130 __ASSERT_DEBUG(iTS_r != NULL, User::Invariant()); |
|
131 return CopyTsL(*iTS_r); |
|
132 } |
|
133 |
|
134 |
|
135 CArrayFix<TIkeV2TrafficSelector>* CIpsecSARekeyData::CopyTsL(const CArrayFix<TIkeV2TrafficSelector>& aTS) const |
|
136 { |
|
137 CArrayFix<TIkeV2TrafficSelector>* selectorList = new (ELeave) CArrayFixFlat<TIkeV2TrafficSelector>(2); |
|
138 CleanupStack::PushL(selectorList); |
|
139 |
|
140 for (TInt i = 0; i < aTS.Count(); ++i) |
|
141 { |
|
142 TIkeV2TrafficSelector selectorCopy(aTS[i]); |
|
143 selectorList->AppendL(selectorCopy); |
|
144 } |
|
145 CleanupStack::Pop(selectorList); |
|
146 return selectorList; |
|
147 } |
|
148 |