|
1 /* |
|
2 * Copyright (c) 2007-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: Keepalive object for Nokia IPsec over NAT |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "ikedebug.h" |
|
21 #include "ikev1pluginsession.h" |
|
22 #include <commdbconnpref.h> // TCommDbConnPref |
|
23 #include "ikev1nokianattkeepalive.h" // CIkev1NokiaNattKeepAlive |
|
24 |
|
25 _LIT8(KMsgContent, "\xff"); |
|
26 |
|
27 CIkev1NokiaNattKeepAlive* CIkev1NokiaNattKeepAlive::NewL( CIkev1PluginSession& aPluginSession, |
|
28 TInetAddr& aDestAddr, |
|
29 TUint16 aPort, |
|
30 TUint aInterval, |
|
31 MIkeDebug& aDebug ) |
|
32 { |
|
33 CIkev1NokiaNattKeepAlive *self = new (ELeave) CIkev1NokiaNattKeepAlive( aPluginSession, |
|
34 aDestAddr, |
|
35 aPort, |
|
36 aDebug ); |
|
37 CleanupStack::PushL(self); |
|
38 self->ConstructL(aInterval); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 CIkev1NokiaNattKeepAlive::~CIkev1NokiaNattKeepAlive() |
|
44 { |
|
45 if (iTimer) |
|
46 { |
|
47 iTimer->Cancel(); |
|
48 delete iTimer; |
|
49 iTimer = NULL; |
|
50 } |
|
51 |
|
52 } |
|
53 |
|
54 CIkev1NokiaNattKeepAlive::CIkev1NokiaNattKeepAlive( CIkev1PluginSession& aPluginSession, |
|
55 TInetAddr& aDestAddr, |
|
56 TUint16 aPort, |
|
57 MIkeDebug& aDebug ) |
|
58 : iPluginSession(aPluginSession), |
|
59 iDestAddr(aDestAddr), |
|
60 iPort(aPort), |
|
61 iMsg(KMsgContent), |
|
62 iDebug(aDebug) |
|
63 { |
|
64 iDestAddr.SetPort(iPort); |
|
65 } |
|
66 |
|
67 |
|
68 void CIkev1NokiaNattKeepAlive::ConstructL(TUint aInterval) |
|
69 { |
|
70 /* |
|
71 * Set up periodic timer |
|
72 */ |
|
73 |
|
74 // Interval and initial delay |
|
75 TTimeIntervalMicroSeconds32 interval(aInterval * 1000000); |
|
76 |
|
77 iTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
|
78 iTimer->Start(interval, interval, |
|
79 TCallBack(CIkev1NokiaNattKeepAlive::PeriodicCallback, this)); |
|
80 DEBUG_LOG(_L("CIkev1NokiaNattKeepAlive::ConstructL(aInterval) Constructed")); |
|
81 } |
|
82 |
|
83 void CIkev1NokiaNattKeepAlive::Send() |
|
84 { |
|
85 TRAPD( err, iPluginSession.SendNokiaNatKeepAliveL( iDestAddr, iMsg, 0 ) ); |
|
86 err = err; |
|
87 DEBUG_LOG1(_L("CIkev1NokiaNattKeepAlive::Send() Request sending of keepalive packet, err=%d"), err); |
|
88 } |
|
89 |
|
90 TInt CIkev1NokiaNattKeepAlive::PeriodicCallback(TAny *aPtr) |
|
91 { |
|
92 CIkev1NokiaNattKeepAlive *self = static_cast<CIkev1NokiaNattKeepAlive*>(aPtr); |
|
93 self->Send(); |
|
94 return KErrNone; |
|
95 } |
|
96 |