|
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 for UDP data |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_SENDER_H |
|
20 #define C_SENDER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <in_sock.h> |
|
24 |
|
25 // FORWARD DECLARATIONS |
|
26 |
|
27 class MIkeDebug; |
|
28 |
|
29 /** |
|
30 * Sender callback interface. |
|
31 * |
|
32 * Callback interface for informing completion of sending. |
|
33 * |
|
34 * @lib ikesocket.lib |
|
35 */ |
|
36 NONSHARABLE_CLASS( MSenderCallback ) |
|
37 { |
|
38 public: |
|
39 /** |
|
40 * Notifies about completed sending. |
|
41 * |
|
42 * @param aStatus Completion status |
|
43 */ |
|
44 virtual void SendCompleted( const TInt aStatus ) = 0; |
|
45 }; |
|
46 |
|
47 /** |
|
48 * Sender of UDP data. |
|
49 * |
|
50 * This class provides functionality for sending UDP data. Completion of |
|
51 * sending is notified via MSenderCallback callback interface. |
|
52 * |
|
53 * @lib ikesocket.lib |
|
54 */ |
|
55 NONSHARABLE_CLASS( CSender ) : public CActive |
|
56 { |
|
57 public: |
|
58 /** |
|
59 * Two-phased constructor. |
|
60 * @param aSocket Socket for local port 500 |
|
61 * @param aSocketNAT Socket for local port 4500 |
|
62 * @param aSocketNokiaNAT Socket for Nokia NAT port |
|
63 * @param aCallback Callback interface |
|
64 * @param aDebug Debug trace interface |
|
65 */ |
|
66 static CSender* NewL( RSocket& aSocket, |
|
67 RSocket& aSocketNAT, |
|
68 RSocket& aSocketNokiaNAT, |
|
69 MSenderCallback& aCallback, |
|
70 MIkeDebug& aDebug ); |
|
71 |
|
72 /** |
|
73 * Destructor. |
|
74 */ |
|
75 ~CSender(); |
|
76 |
|
77 /** |
|
78 * Sends UDP data. |
|
79 * |
|
80 * @param aLocalPort Local port |
|
81 * @param aDestAddr Destination IP address/port |
|
82 * @param aUdpData UDP data |
|
83 * @param aDscp DSCP value |
|
84 * @return Error value |
|
85 */ |
|
86 TInt SendUdpData( const TInt aLocalPort, |
|
87 const TInetAddr& aDestAddr, |
|
88 const TDesC8& aUdpData, |
|
89 const TUint aDscp ); |
|
90 |
|
91 // from base class CActive |
|
92 |
|
93 /** |
|
94 * From CActive. |
|
95 * Handles an active object's request completion event about sending. |
|
96 */ |
|
97 void RunL(); |
|
98 |
|
99 /** |
|
100 * From CActive. |
|
101 * Implements cancellation of sending. |
|
102 */ |
|
103 void DoCancel(); |
|
104 |
|
105 private: |
|
106 |
|
107 CSender( RSocket& aSocket, |
|
108 RSocket& aSocketNAT, |
|
109 RSocket& aSocketNokiaNAT, |
|
110 MSenderCallback& aCallback, |
|
111 MIkeDebug& aDebug ); |
|
112 |
|
113 void ConstructL(); |
|
114 |
|
115 |
|
116 private: // data |
|
117 |
|
118 /** |
|
119 * Socket for port 500. |
|
120 * Not own. |
|
121 */ |
|
122 RSocket& iSocket; |
|
123 |
|
124 /** |
|
125 * Socket for port 4500. |
|
126 * Not own. |
|
127 */ |
|
128 RSocket& iSocketNAT; |
|
129 |
|
130 /** |
|
131 * Socket for Nokia NAT port. |
|
132 * Not own. |
|
133 */ |
|
134 RSocket& iSocketNokiaNAT; |
|
135 |
|
136 /** |
|
137 * Local port used for sending. |
|
138 * Own. |
|
139 */ |
|
140 TInt iLocalPort; |
|
141 |
|
142 /** |
|
143 * Destination address used for sending. |
|
144 * Own. |
|
145 */ |
|
146 TInetAddr iDestAddr; |
|
147 |
|
148 /** |
|
149 * Sender callback for completing sending. |
|
150 * Not own. |
|
151 */ |
|
152 MSenderCallback& iCallback; |
|
153 |
|
154 /** |
|
155 * Debug trace interface. |
|
156 * Not own. |
|
157 */ |
|
158 MIkeDebug& iDebug; |
|
159 }; |
|
160 |
|
161 #endif // C_SENDER_H |