|
1 /* |
|
2 * Copyright (c) 2008 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: Sender of UDP datagrams |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <in_sock.h> |
|
20 |
|
21 #include "ikedatainterface.h" |
|
22 |
|
23 // CLASS HEADER |
|
24 #include "ikev2sender.h" |
|
25 |
|
26 |
|
27 // ======== MEMBER FUNCTIONS ======== |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // Two-phased constructor. |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CIkev2Sender* CIkev2Sender::NewL( MIkeDataInterface& aDataInterface, |
|
34 MIkev2SenderCallback& aCallback ) |
|
35 { |
|
36 CIkev2Sender* self = new (ELeave) CIkev2Sender( aDataInterface, |
|
37 aCallback ); |
|
38 return self; |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // Destructor. |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CIkev2Sender::~CIkev2Sender() |
|
46 { |
|
47 Cancel(); |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // Constructor. |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CIkev2Sender::CIkev2Sender( MIkeDataInterface& aDataInterface, |
|
55 MIkev2SenderCallback& aCallback ) |
|
56 : CActive( EPriorityStandard ), |
|
57 iDataInterface( aDataInterface ), |
|
58 iCallback( aCallback ) |
|
59 { |
|
60 CActiveScheduler::Add( this ); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // Sends IKE message. |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 void CIkev2Sender::SendIkeMsg( TInt aLocalPort, |
|
68 TInetAddr& aDestAddr, |
|
69 TUint8 aDscp, |
|
70 const TDesC8& aIkeMsg ) |
|
71 { |
|
72 Cancel(); |
|
73 iDataInterface.SendUdpData( aLocalPort, |
|
74 aDestAddr, |
|
75 aIkeMsg, |
|
76 aDscp, |
|
77 iStatus ); |
|
78 SetActive(); |
|
79 } |
|
80 |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // From class CActive |
|
84 // Handles completion of sending. |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void CIkev2Sender::RunL() |
|
88 { |
|
89 iCallback.SendIkeMsgCompleted( iStatus.Int() ); |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // From class CActive |
|
94 // Handles cancellation of sending. |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 void CIkev2Sender::DoCancel() |
|
98 { |
|
99 iDataInterface.CancelSend(); |
|
100 } |
|
101 |