|
1 /* |
|
2 * Copyright (c) 2005-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: IKE transaction exchange implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef IKEV1TRANS_H |
|
20 #define IKEV1TRANS_H |
|
21 |
|
22 #include "ikev1dialog.h" |
|
23 #include "ikev1payloads.h" |
|
24 |
|
25 /*--------------------------------------------------------------------------- |
|
26 * |
|
27 * Transaction exchange return codes (returned by ExecuteL() method) |
|
28 * |
|
29 *---------------------------------------------------------------------------*/ |
|
30 #define TRANSACTION_SUCCESS 0 |
|
31 #define TRANSACTION_CONTINUE 0x1 |
|
32 #define TRANSACTION_IGNORE 0x2 |
|
33 #define TRANSACTION_FAILED 0x4 |
|
34 |
|
35 #define IV_LTH 20 |
|
36 /**-------------------------------------------------------------------------- |
|
37 * |
|
38 * Structure TTransExchange |
|
39 * Contains parameter data related one ISAKMP Transaction exchange |
|
40 * |
|
41 *--------------------------------------------------------------------------*/ |
|
42 struct TTransExchange |
|
43 { |
|
44 TUint32 iMessageId; |
|
45 TUint16 iIdentifier; |
|
46 TUint16 iXauthType; |
|
47 TInt iRole; |
|
48 TBuf8<IV_LTH> iIV; |
|
49 TTransExchange() |
|
50 { |
|
51 iMessageId = 0; |
|
52 iIdentifier = 0; |
|
53 iXauthType = 0; |
|
54 iRole = 0; |
|
55 }; |
|
56 }; |
|
57 |
|
58 |
|
59 class CIkev1Negotiation; |
|
60 class ThdrISAKMP; |
|
61 class CAuthDialogInfo; |
|
62 class CInternalAddress; |
|
63 class TIkev1IsakmpStream; |
|
64 class MIkeDebug; |
|
65 class TInetAddr; |
|
66 |
|
67 /**-------------------------------------------------------------------------- |
|
68 * |
|
69 * CTransNegotiation class |
|
70 * Handles ISAKMP transaction exchange messages |
|
71 * Both the ISAKMP Configuration Method <draft-dukes-ike-mode-cfg-01.txt> and |
|
72 * Extended Authentication within IKE (XAUTH) <draft-beaulieu-ike-xauth-02.txt> |
|
73 * has been implemented using ISAKMP transaction exchange messages. |
|
74 * This class handles both the transaction exchange message handling and |
|
75 * config mode/XAUTH protocol processing. |
|
76 * |
|
77 *--------------------------------------------------------------------------*/ |
|
78 NONSHARABLE_CLASS(CTransNegotiation) : public CArrayFixFlat<TTransExchange *>, public MIkeDialogComplete |
|
79 { |
|
80 public: |
|
81 ~CTransNegotiation(); |
|
82 static CTransNegotiation* NewL( TBool aUseXauth, |
|
83 TBool aUseCfgMode, |
|
84 CIkev1PluginSession* aPluginSession, |
|
85 CIkev1Negotiation* aNegotiation, |
|
86 MIkeDebug& aDebug ); |
|
87 TInt ExecuteL( const ThdrISAKMP& aHdr, |
|
88 const TInetAddr& aSrcAddr, |
|
89 TInt aLocalPort ); |
|
90 TInt ProcessUserResponseL(CAuthDialogInfo *aDialogInfo ); |
|
91 TInt TransactionFailedL(const TNotificationISAKMP *aNotifPayload); |
|
92 TBool GetIV(TUint32 aMsgId, TDes8& aIV); |
|
93 TBool SetIV(TUint32 aMsgId, TDes8& aIV); |
|
94 CInternalAddress* GetInternalAddr() |
|
95 { |
|
96 CInternalAddress* ia = iInternalAddr; |
|
97 iInternalAddr = NULL; |
|
98 return ia; |
|
99 } |
|
100 static TUint16 GetAuthMethod(TUint16 aAuthMethod, TBool aXauthUsed, TInt aRole); |
|
101 static void BuildXauthVendorId(TIkev1IsakmpStream &aMsg); |
|
102 |
|
103 TInt DialogCompleteL(CIkev1Dialog* aDialog, TAny* aUserInfo, HBufC8* aUsername, |
|
104 HBufC8* aSecret, HBufC8* aDomain); |
|
105 TInt BuildConfigRequestL(); |
|
106 |
|
107 private: |
|
108 TTransExchange* FindExchange(TUint32 aMsgId); |
|
109 TTransExchange* AddExchangeL(TUint32 aMsgId, TUint8 aRole); |
|
110 TUint16 GetIdentifier() |
|
111 { |
|
112 iIdentifierBase --; |
|
113 if ( (iIdentifierBase & 0xffff) == 0 ) |
|
114 iIdentifierBase --; |
|
115 return (TUint16)iIdentifierBase; |
|
116 } |
|
117 TInt TransactionExchangeL(const ThdrISAKMP &aHdr); |
|
118 TInt ProcessAttributesL(const TAttributeISAKMP *aAttr); |
|
119 TInt ProcessCfgModeAttrsL(TDataISAKMP* aAttr, TInt aLth); |
|
120 TInt ProcessXauthRequestL(TDataISAKMP* aAttr, TInt aLth); |
|
121 TInt ProcessXauthStatusL(TDataISAKMP* aAttr, TInt aLth); |
|
122 TInt CheckTransactionStatusL(TInt aStatus); |
|
123 void AddAttributeData(TDes8& aAttrBfr, TInt aType, TInt aLth, TUint8* aData); |
|
124 void BuildAndSendMessageL(TDesC8& aAttrBfr, TUint8 aMsgType); |
|
125 CTransNegotiation( TInt aGranularity, |
|
126 TBool aUseXauth, |
|
127 TBool aUseCfgMode, |
|
128 CIkev1PluginSession* aPluginSession, |
|
129 CIkev1Negotiation* aNegotiation, |
|
130 MIkeDebug& aDebug ); |
|
131 void ConstructL(); |
|
132 |
|
133 private: |
|
134 CIkev1PluginSession* iPluginSession; |
|
135 CIkev1Negotiation* iNegotiation; |
|
136 CInternalAddress* iInternalAddr; |
|
137 TTransExchange* iCurrExchange; |
|
138 CIkev1Dialog* iDialog; |
|
139 CAuthDialogInfo* iDialogInfo; |
|
140 HBufC8* iUserName; // Saved for User name caching |
|
141 |
|
142 TBool iUseXauth; |
|
143 TBool iUseCfgMode; |
|
144 TUint32 iIdentifierBase; |
|
145 TUint32 iRequestFlags; |
|
146 TBool iXauthCompleted; |
|
147 TBool iCfgModeCompleted; |
|
148 TBool iUseOlderPIXXauth; // use draft-ietf-ipsec-isakmp-xauth-04.txt |
|
149 |
|
150 TLastIKEMsg iLastTransMsgInfo; |
|
151 MIkeDebug& iDebug; |
|
152 }; |
|
153 |
|
154 |
|
155 #endif // IKEV1TRANS_H |