0
|
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:
|
|
15 |
* CDynamicsCommand
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#ifndef __CDYNAMICSCOMMAND_H__
|
|
22 |
#define __CDYNAMICSCOMMAND_H__
|
|
23 |
|
|
24 |
|
|
25 |
/****************************************************************************************
|
|
26 |
*
|
|
27 |
* System Includes
|
|
28 |
*
|
|
29 |
***************************************************************************************/
|
|
30 |
#include <string>
|
|
31 |
using namespace std;
|
|
32 |
|
|
33 |
|
|
34 |
/****************************************************************************************
|
|
35 |
*
|
|
36 |
* Constants
|
|
37 |
*
|
|
38 |
***************************************************************************************/
|
|
39 |
#define MAXIMUMERRORSTRINGLENGTH 128
|
|
40 |
#define MAXCOMMANDLINE 256
|
|
41 |
#define MAXINTERFACENAME 64
|
|
42 |
#define MAXNAILEN 128
|
|
43 |
#define MAXINFOLEN 128
|
|
44 |
#define MAXERRORSTRING 256
|
|
45 |
|
|
46 |
|
|
47 |
/****************************************************************************************
|
|
48 |
*
|
|
49 |
* Types - General
|
|
50 |
*
|
|
51 |
***************************************************************************************/
|
|
52 |
typedef enum {
|
|
53 |
DC_SUCCESS,
|
|
54 |
DC_COMMAND_TOOL_NOT_FOUND,
|
|
55 |
DC_INVALID_ARGUMENTS,
|
|
56 |
DC_CSH_FAILED,
|
|
57 |
DC_CALL_FAILED,
|
|
58 |
DC_EXECUTE_FAILED,
|
|
59 |
DC_UNEXPECTED_OUTPUT,
|
|
60 |
} TDynamicsCallResult;
|
|
61 |
|
|
62 |
typedef enum {
|
|
63 |
DCF_UNKNOWN,
|
|
64 |
DCF_FUNCTION_NOT_PERMITTED,
|
|
65 |
DCF_AGENT_UNREACHABLE
|
|
66 |
} TDynamicsCallFailedReason;
|
|
67 |
|
|
68 |
typedef struct {
|
|
69 |
TDynamicsCallResult iResult;
|
|
70 |
int iErrorCode;
|
|
71 |
int iErrorDetail;
|
|
72 |
char iDynamicsErrorString[MAXIMUMERRORSTRINGLENGTH];
|
|
73 |
} TDynamicsCallInfo;
|
|
74 |
|
|
75 |
|
|
76 |
/****************************************************************************************
|
|
77 |
*
|
|
78 |
* Types - For Foreign Agent Calls
|
|
79 |
*
|
|
80 |
***************************************************************************************/
|
|
81 |
typedef struct {
|
|
82 |
int iTunnelCount;
|
|
83 |
int iPendingRegistrationRequests;
|
|
84 |
int iRequestsRejected;
|
|
85 |
int iRequestsAccepted;
|
|
86 |
int iReplysAccepted;
|
|
87 |
int iReplysRejected;
|
|
88 |
int iDiscardedUnknownExtension;
|
|
89 |
int iDiscardedMalformed;
|
|
90 |
int iDiscardedVendor;
|
|
91 |
int iAdvertisementsSent;
|
|
92 |
} TForeignAgentStatusInfo;
|
|
93 |
|
|
94 |
typedef struct {
|
|
95 |
unsigned int iMobileNodeAddress;
|
|
96 |
unsigned int iHomeAgentAddress;
|
|
97 |
int iTunnelID;
|
|
98 |
} TTunnelID;
|
|
99 |
|
|
100 |
typedef struct {
|
|
101 |
unsigned int iMobileNodeAddress;
|
|
102 |
unsigned int iCareofAddress;
|
|
103 |
unsigned int iHomeAgentAddress;
|
|
104 |
int iPrivateHomeAgentID;
|
|
105 |
int iCreationTime;
|
|
106 |
int iExpirationTime;
|
|
107 |
int iRefreshTime;
|
|
108 |
int iLastTimestamp;
|
|
109 |
int iSPI;
|
|
110 |
int iTimeout;
|
|
111 |
} TForeignAgentTunnelInfo;
|
|
112 |
|
|
113 |
|
|
114 |
/****************************************************************************************
|
|
115 |
*
|
|
116 |
* Types - For Home Agent Calls
|
|
117 |
*
|
|
118 |
***************************************************************************************/
|
|
119 |
typedef struct {
|
|
120 |
int iTunnelCount;
|
|
121 |
int iRequestsRejected;
|
|
122 |
int iRequestsAccepted;
|
|
123 |
int iDiscardedUnknownExtension;
|
|
124 |
int iDiscardedMalformed;
|
|
125 |
int iDiscardedVendor;
|
|
126 |
int iAdvertisementsSent;
|
|
127 |
} THomeAgentStatusInfo;
|
|
128 |
|
|
129 |
typedef struct {
|
|
130 |
unsigned int iMobileNodeAddress;
|
|
131 |
unsigned int iCareofAddress;
|
|
132 |
unsigned int iHomeAgentAddress;
|
|
133 |
int iCreationTime;
|
|
134 |
int iExpirationTime;
|
|
135 |
int iRefreshTime;
|
|
136 |
int iLastTimestamp;
|
|
137 |
int iSPI;
|
|
138 |
int iTimeout;
|
|
139 |
} THomeAgentTunnelInfo;
|
|
140 |
|
|
141 |
|
|
142 |
/****************************************************************************************
|
|
143 |
*
|
|
144 |
* Types - For Mobile Node Agent Calls
|
|
145 |
*
|
|
146 |
***************************************************************************************/
|
|
147 |
typedef struct {
|
|
148 |
int iConnected;
|
|
149 |
int iTunnelUp;
|
|
150 |
unsigned int iLocalAddress;
|
|
151 |
unsigned int iColocatedAddress;
|
|
152 |
unsigned int iForeignAgentAddress;
|
|
153 |
unsigned int iHomeAgentAddress;
|
|
154 |
unsigned int iHomeAddress;
|
|
155 |
int iLifetimeRemaining;
|
|
156 |
int iTunnelMode;
|
|
157 |
int iSecondsSinceLastRequest;
|
|
158 |
int iSecondsSinceLastReply;
|
|
159 |
int iReplyCode;
|
|
160 |
char iInfoText[MAXINFOLEN];
|
|
161 |
char iLastErrorString[MAXERRORSTRING];
|
|
162 |
} TMobileNodeAgentStatusInfo;
|
|
163 |
|
|
164 |
typedef struct {
|
|
165 |
unsigned int iForeignAgentAddress;
|
|
166 |
char iInterfaceName[MAXINTERFACENAME];
|
|
167 |
int iPriority;
|
|
168 |
int iInUse;
|
|
169 |
int iInterfaceIndex;
|
|
170 |
int iLastAdvertisement;
|
|
171 |
char iNAI[MAXNAILEN];
|
|
172 |
} TMobileNodeForeignAgentInfo;
|
|
173 |
|
|
174 |
|
|
175 |
/****************************************************************************************
|
|
176 |
*
|
|
177 |
* CDynamicsCommand Class Definition
|
|
178 |
*
|
|
179 |
***************************************************************************************/
|
|
180 |
class CDynamicsCommand
|
|
181 |
{
|
|
182 |
public:
|
|
183 |
// General
|
|
184 |
CDynamicsCommand();
|
|
185 |
~CDynamicsCommand();
|
|
186 |
void SetPipePath( string aPipePath );
|
|
187 |
void SetTimeout( int aTimeoutInMilliseconds );
|
|
188 |
|
|
189 |
// Foreign Agent Calls
|
|
190 |
TDynamicsCallInfo ForeignAgentGetStatus( TForeignAgentStatusInfo *aForeignAgentInfo );
|
|
191 |
TDynamicsCallInfo ForeignAgentDestroyTunnel( unsigned int aMobileNodeAddress );
|
|
192 |
TDynamicsCallInfo ForeignAgentGetTunnels( int *aTunnelCount, TTunnelID *aTunnelIDArray );
|
|
193 |
TDynamicsCallInfo ForeignAgentGetTunnelInfo( unsigned int aMobileNodeAddress, TForeignAgentTunnelInfo *aTunnelInfo );
|
|
194 |
|
|
195 |
// Home Agent Calls
|
|
196 |
TDynamicsCallInfo HomeAgentGetStatus( THomeAgentStatusInfo *aHomeAgentInfo );
|
|
197 |
TDynamicsCallInfo HomeAgentDestroyTunnel( unsigned int aMobileNodeAddress , unsigned int aHomeAgentAddress = 0, int aTunnelID = 0);
|
|
198 |
TDynamicsCallInfo HomeAgentGetTunnels( int *aTunnelCount, unsigned int *aMobileNodeAddresses );
|
|
199 |
TDynamicsCallInfo HomeAgentGetTunnelInfo( unsigned int aMobileNodeAddress, THomeAgentTunnelInfo *aTunnelInfo );
|
|
200 |
|
|
201 |
// Mobile Node Calls
|
|
202 |
TDynamicsCallInfo MobileNodeAgentGetCareofAddress( struct in_addr *aCareofAddress );
|
|
203 |
TDynamicsCallInfo MobileNodeAgentGetStatus( TMobileNodeAgentStatusInfo *aMobileNodeAgentInfo );
|
|
204 |
TDynamicsCallInfo MobileNodeAgentConnect();
|
|
205 |
TDynamicsCallInfo MobileNodeAgentDisconnect();
|
|
206 |
TDynamicsCallInfo MobileNodeAgentConfirm();
|
|
207 |
TDynamicsCallInfo MobileNodeAgentRescan();
|
|
208 |
TDynamicsCallInfo MobileNodeAgentSetPolicy( int aPolicyVector );
|
|
209 |
TDynamicsCallInfo MobileNodeAgentGetPolicy( int *aPolicyVector );
|
|
210 |
TDynamicsCallInfo MobileNodeAgentGetForeignAgentList( int *aListCount, TMobileNodeForeignAgentInfo *aForeignAgentInfoList );
|
|
211 |
TDynamicsCallInfo MobileNodeAgentGetForeignAgentInfo( unsigned int aFAAddress, TMobileNodeForeignAgentInfo *aForeignAgentInfo );
|
|
212 |
|
|
213 |
private:
|
|
214 |
// Helper functions
|
|
215 |
TDynamicsCallInfo DynamicsCall( char *aExecutable, char *aCommand, char *aParams, string *aStandardOutput,
|
|
216 |
string *aStandardError );
|
|
217 |
|
|
218 |
int GetIntegerEntry( const char *aOutput, const char *aLabel, int *aValue );
|
|
219 |
int GetDateEntry( const char *aOutput, const char *aLabel, int *aValue );
|
|
220 |
int GetAddressEntry( const char *aOutput, const char *aLabel, unsigned int *aValue );
|
|
221 |
int GetPolicyEntry( const char *aOutput, const char *aLabel, int *aValue );
|
|
222 |
int GetStringEntry( const char *aOutput, const char *aLabel, char *aValue, int aBufferSize );
|
|
223 |
|
|
224 |
TDynamicsCallFailedReason GetCallFailedReason( const char *aOutput );
|
|
225 |
|
|
226 |
TDynamicsCallInfo ParseForeignAgentListOutput( string aOutput, int aListSize, TTunnelID *aTunnelIDArray, int *aListCount );
|
|
227 |
TDynamicsCallInfo ParseHomeAgentListOutput( string aOutput, int aListSize, unsigned int *aTunnelList, int *aListCount );
|
|
228 |
TDynamicsCallInfo ParseMobileNodeAgentListOutput( string aOutput, int aListSize, TMobileNodeForeignAgentInfo *aForeignAgentList,
|
|
229 |
int *aListCount );
|
|
230 |
|
|
231 |
int ConvertTunnelStringToInteger( char *aTunnelMode, int *aValue );
|
|
232 |
int CheckMatchAsBoolean( char *aInput, char *aTrue, int *aValue );
|
|
233 |
int strstrbeforedelim( const char *aSearchSpace, const char *aToken, char aDelim );
|
|
234 |
|
|
235 |
// Members
|
|
236 |
int iTimeout;
|
|
237 |
string iPipePath;
|
|
238 |
char iCommandLine[MAXCOMMANDLINE];
|
|
239 |
};
|
|
240 |
|
|
241 |
|
|
242 |
#endif //__CDYNAMICSCOMMAND_H__
|