|
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 |
|
19 #include "ikev2identity.h" |
|
20 |
|
21 static const TUint16 KHeaderLength = 4; |
|
22 |
|
23 CIkeV2Identity* CIkeV2Identity::NewL(TUint8 aIdType, const TDesC8& aIdentity) |
|
24 { |
|
25 CIkeV2Identity* self = new (ELeave) CIkeV2Identity; |
|
26 CleanupStack::PushL(self); |
|
27 self->ConstructL(aIdType, aIdentity); |
|
28 CleanupStack::Pop(self); |
|
29 |
|
30 return self; |
|
31 } |
|
32 |
|
33 |
|
34 void CIkeV2Identity::ConstructL(TUint8 aIdType, const TDesC8& aIdentity) |
|
35 { |
|
36 _LIT8(KReserverField, "\0\0\0"); |
|
37 |
|
38 iIdPayloadData = HBufC8::NewL(KHeaderLength + aIdentity.Length()); |
|
39 TPtr8 idPayloadDataPtr = iIdPayloadData->Des(); |
|
40 |
|
41 idPayloadDataPtr.Append(&aIdType, sizeof(aIdType)); |
|
42 idPayloadDataPtr.Append(KReserverField); |
|
43 idPayloadDataPtr.Append(aIdentity); |
|
44 } |
|
45 |
|
46 |
|
47 CIkeV2Identity::~CIkeV2Identity() |
|
48 { |
|
49 delete iIdPayloadData; |
|
50 } |
|
51 |
|
52 |
|
53 TUint8 CIkeV2Identity::IdType() const |
|
54 { |
|
55 return (*iIdPayloadData)[0]; |
|
56 } |
|
57 |
|
58 |
|
59 TPtrC8 CIkeV2Identity::Identity() const |
|
60 { |
|
61 return iIdPayloadData->Mid(KHeaderLength); |
|
62 } |
|
63 |
|
64 TPtrC8 CIkeV2Identity::PayloadData() const |
|
65 { |
|
66 return *iIdPayloadData; |
|
67 } |