|
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 * This file was autogenerated by rpcgen, but should be modified by the developer. |
|
16 * Make sure you don't use the -component_mod flag in future or this file will be overwritten. |
|
17 * Wed Nov 05 16:06:20 2003 |
|
18 * System Includes |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 #include <stdio.h> |
|
26 |
|
27 |
|
28 /**************************************************************************************** |
|
29 * |
|
30 * Local Includes |
|
31 * |
|
32 ***************************************************************************************/ |
|
33 #include "CSvcUuinterface.h" |
|
34 #include "uuinterface.h" |
|
35 #include "../ProcessLibrary/proclib.h" |
|
36 #include "../include/standard_unix.h" |
|
37 #include "../include/standard_service_manager.h" |
|
38 |
|
39 /**************************************************************************************** |
|
40 * |
|
41 * File-scope variables |
|
42 * |
|
43 ***************************************************************************************/ |
|
44 static CComponentManager<CSUuinterface> *iComponentManager; |
|
45 |
|
46 |
|
47 /**************************************************************************************** |
|
48 * |
|
49 * Implementation |
|
50 * |
|
51 ***************************************************************************************/ |
|
52 |
|
53 |
|
54 /**************************************************************************************** |
|
55 * |
|
56 * PUBLIC: GetInstanceKeyFromArgs |
|
57 * |
|
58 ***************************************************************************************/ |
|
59 int CSvcUuinterface::GetInstanceKeyFromArgs( int aMethod, void *aArgs ) |
|
60 { |
|
61 // Not implemented as we will never have more that one instance |
|
62 assert( !"NOT IMPLEMENTED" ); |
|
63 return ERR_NONE; |
|
64 } |
|
65 |
|
66 |
|
67 /**************************************************************************************** |
|
68 * |
|
69 * PUBLIC: SetError |
|
70 * |
|
71 ***************************************************************************************/ |
|
72 int CSvcUuinterface::SetError( int aMethod, void *aArgs, int aError ) |
|
73 { |
|
74 TResult* result; |
|
75 TComponentList *rv_component_list; |
|
76 int rv = ERR_NONE; |
|
77 |
|
78 // Check params |
|
79 assert ( aArgs != NULL ); |
|
80 |
|
81 switch( aMethod ) { |
|
82 case LIST_DEVICES: |
|
83 SET_LIST_ERROR_CODE( TComponentList, rv_component_list ); |
|
84 |
|
85 case ST_SETDELAY: |
|
86 case ST_SETDROPPERCENTAGE: |
|
87 case ST_SETDUPLICATEPERCENTAGE: |
|
88 case ST_SETBANDWIDTH: |
|
89 case ST_SETDRD: |
|
90 case ST_CLEARSETTINGS: |
|
91 case ST_STOPSERVICE: |
|
92 case ST_RESET: |
|
93 SET_ERROR_CODE( TResult, iStandardResult, result ); |
|
94 break; |
|
95 |
|
96 default: |
|
97 rv = ERR_INVALID_METHOD; |
|
98 break; |
|
99 } |
|
100 |
|
101 return rv; |
|
102 } |
|
103 |
|
104 |
|
105 /**************************************************************************************** |
|
106 * |
|
107 * PUBLIC: GetError |
|
108 * |
|
109 ***************************************************************************************/ |
|
110 int CSvcUuinterface::GetError( int aMethod, void *aArgs ) |
|
111 { |
|
112 // Not implemented as we will never have more that one instance |
|
113 assert( !"NOT IMPLEMENTED" ); |
|
114 return ERR_NONE; |
|
115 } |
|
116 |
|
117 |
|
118 /**************************************************************************************** |
|
119 * |
|
120 * PUBLIC: StartRPCService |
|
121 * |
|
122 ***************************************************************************************/ |
|
123 int CSvcUuinterface::StartRPCService( CComponentManager<CSUuinterface> *aComponentManager, TStartupInfo *aArg ) |
|
124 { |
|
125 assert( iComponentManager == NULL ); |
|
126 iComponentManager = aComponentManager; |
|
127 return ERR_NONE; |
|
128 } |
|
129 |
|
130 |
|
131 /**************************************************************************************** |
|
132 * |
|
133 * PUBLIC: StopRPCService |
|
134 * |
|
135 ***************************************************************************************/ |
|
136 int CSvcUuinterface::StopRPCService() |
|
137 { |
|
138 iComponentManager = NULL; |
|
139 return ERR_NONE; |
|
140 } |
|
141 |
|
142 |
|
143 /**************************************************************************************** |
|
144 * |
|
145 * PUBLIC: st_setdelay |
|
146 * |
|
147 ***************************************************************************************/ |
|
148 TResult CSvcUuinterface::st_setdelay( TConfigValue aArgs ) |
|
149 { |
|
150 TResult rv; |
|
151 int ret; |
|
152 |
|
153 char commandLine[MAX_COMMANDLINE]; |
|
154 char finalSrc[TOTAL_MAX_ADDRESS_LEN]; |
|
155 char finalDst[TOTAL_MAX_ADDRESS_LEN]; |
|
156 |
|
157 // check the values in the config values structure |
|
158 ret = CheckConfigValue( aArgs, finalSrc, finalDst ); |
|
159 if ( ret == ERR_INVALIDARG ) |
|
160 { |
|
161 memset( &rv, 0, sizeof(rv) ); |
|
162 rv.iStandardResult = ERR_INVALIDARG; |
|
163 return rv; |
|
164 } |
|
165 |
|
166 // construct the command line |
|
167 snprintf( commandLine, MAX_COMMANDLINE, "./config_nistnet_add.pl -u -a %s %s --delay %d.%d %d.%d/%d.%d", |
|
168 finalSrc, |
|
169 finalDst, |
|
170 aArgs.iValueIntegerPart, |
|
171 aArgs.iValueFractionPart, |
|
172 aArgs.iSigmaIntegerPart, |
|
173 aArgs.iSigmaFractionPart, |
|
174 aArgs.iCorrelationIntegerPart, |
|
175 aArgs.iCorrelationFractionPart ); |
|
176 |
|
177 // execute the command and return the result |
|
178 ret = execute(commandLine, &rv); |
|
179 assert ( (ret == ERR_FAILEDTOEXECUTECOMMAND) || (ret == ERR_NONE) ); |
|
180 |
|
181 return rv; |
|
182 } |
|
183 |
|
184 |
|
185 /**************************************************************************************** |
|
186 * |
|
187 * PUBLIC: st_setdroppercentage |
|
188 * |
|
189 ***************************************************************************************/ |
|
190 TResult CSvcUuinterface::st_setdroppercentage( TConfigValue aArgs ) |
|
191 { |
|
192 TResult rv; |
|
193 int ret; |
|
194 |
|
195 char commandLine [MAX_COMMANDLINE]; |
|
196 char finalSrc[TOTAL_MAX_ADDRESS_LEN]; |
|
197 char finalDst[TOTAL_MAX_ADDRESS_LEN]; |
|
198 |
|
199 // check the values in the config values structure |
|
200 ret = CheckConfigValue( aArgs, finalSrc, finalDst ); |
|
201 if ( ret == ERR_INVALIDARG ) |
|
202 { |
|
203 memset( &rv, 0, sizeof(rv) ); |
|
204 rv.iStandardResult = ERR_INVALIDARG; |
|
205 return rv; |
|
206 } |
|
207 |
|
208 ret = CheckPercentage( aArgs.iValueIntegerPart ); |
|
209 if ( ret == ERR_INVALIDARG ) |
|
210 { |
|
211 memset( &rv, 0, sizeof(rv) ); |
|
212 rv.iStandardResult = ERR_INVALIDARG; |
|
213 return rv; |
|
214 } |
|
215 |
|
216 // construct the command line |
|
217 snprintf( commandLine, MAX_COMMANDLINE, "./config_nistnet_add.pl -u -a %s %s --drop %d.%d/%d.%d", |
|
218 finalSrc, |
|
219 finalDst, |
|
220 aArgs.iValueIntegerPart, |
|
221 aArgs.iValueFractionPart, |
|
222 aArgs.iCorrelationIntegerPart, |
|
223 aArgs.iCorrelationFractionPart ); |
|
224 |
|
225 // execute the command and return the result |
|
226 ret = execute(commandLine, &rv); |
|
227 assert ( (ret == ERR_FAILEDTOEXECUTECOMMAND) || (ret == ERR_NONE) ); |
|
228 |
|
229 return rv; |
|
230 } |
|
231 |
|
232 |
|
233 /**************************************************************************************** |
|
234 * |
|
235 * PUBLIC: st_setduplicatepercentage |
|
236 * |
|
237 ***************************************************************************************/ |
|
238 TResult CSvcUuinterface::st_setduplicatepercentage( TConfigValue aArgs ) |
|
239 { |
|
240 TResult rv; |
|
241 int ret; |
|
242 |
|
243 char commandLine [MAX_COMMANDLINE]; |
|
244 char finalSrc[TOTAL_MAX_ADDRESS_LEN]; |
|
245 char finalDst[TOTAL_MAX_ADDRESS_LEN]; |
|
246 |
|
247 // check the values in the config values structure |
|
248 ret = CheckConfigValue( aArgs, finalSrc, finalDst ); |
|
249 if ( ret == ERR_INVALIDARG ) |
|
250 { |
|
251 memset( &rv, 0, sizeof(rv) ); |
|
252 rv.iStandardResult = ERR_INVALIDARG; |
|
253 return rv; |
|
254 } |
|
255 |
|
256 ret = CheckPercentage( aArgs.iValueIntegerPart ); |
|
257 if ( ret == ERR_INVALIDARG ) |
|
258 { |
|
259 memset( &rv, 0, sizeof(rv) ); |
|
260 rv.iStandardResult = ERR_INVALIDARG; |
|
261 return rv; |
|
262 } |
|
263 |
|
264 // construct the command line |
|
265 snprintf( commandLine, MAX_COMMANDLINE, "./config_nistnet_add.pl -u -a %s %s --dup %d.%d/%d.%d", |
|
266 finalSrc, |
|
267 finalDst, |
|
268 aArgs.iValueIntegerPart, |
|
269 aArgs.iValueFractionPart, |
|
270 aArgs.iCorrelationIntegerPart, |
|
271 aArgs.iCorrelationFractionPart ); |
|
272 |
|
273 // execute the command and return the result |
|
274 ret = execute(commandLine, &rv); |
|
275 assert ( (ret == ERR_FAILEDTOEXECUTECOMMAND) || (ret == ERR_NONE) ); |
|
276 |
|
277 return rv; |
|
278 } |
|
279 |
|
280 |
|
281 /**************************************************************************************** |
|
282 * |
|
283 * PUBLIC: st_setbandwidth |
|
284 * |
|
285 ***************************************************************************************/ |
|
286 TResult CSvcUuinterface::st_setbandwidth( TConfigValue aArgs ) |
|
287 { |
|
288 TResult rv; |
|
289 int ret; |
|
290 |
|
291 char commandLine [MAX_COMMANDLINE]; |
|
292 char finalSrc[TOTAL_MAX_ADDRESS_LEN]; |
|
293 char finalDst[TOTAL_MAX_ADDRESS_LEN]; |
|
294 |
|
295 // check the values in the config values structure |
|
296 ret = CheckConfigValue( aArgs, finalSrc, finalDst ); |
|
297 if ( ret == ERR_INVALIDARG ) |
|
298 { |
|
299 memset( &rv, 0, sizeof(rv) ); |
|
300 rv.iStandardResult = ERR_INVALIDARG; |
|
301 return rv; |
|
302 } |
|
303 |
|
304 // construct the command line |
|
305 snprintf( commandLine, MAX_COMMANDLINE, "./config_nistnet_add.pl -u -a %s %s --bandwidth %d.%d", |
|
306 finalSrc, |
|
307 finalDst, |
|
308 aArgs.iValueIntegerPart, |
|
309 aArgs.iValueFractionPart ); |
|
310 |
|
311 // execute the command and return the result |
|
312 ret = execute(commandLine, &rv); |
|
313 assert ( (ret == ERR_FAILEDTOEXECUTECOMMAND) || (ret == ERR_NONE) ); |
|
314 |
|
315 return rv; |
|
316 } |
|
317 |
|
318 |
|
319 /**************************************************************************************** * |
|
320 * PUBLIC: st_setdrd |
|
321 * |
|
322 ***************************************************************************************/ |
|
323 TResult CSvcUuinterface::st_setdrd( TConfigValue aArgs ) |
|
324 { |
|
325 TResult rv; |
|
326 int ret; |
|
327 |
|
328 char commandLine [MAX_COMMANDLINE]; |
|
329 char finalSrc[TOTAL_MAX_ADDRESS_LEN]; |
|
330 char finalDst[TOTAL_MAX_ADDRESS_LEN]; |
|
331 |
|
332 // check the values in the config values structure |
|
333 ret = CheckConfigValue( aArgs, finalSrc, finalDst ); |
|
334 if ( ret == ERR_INVALIDARG ) |
|
335 { |
|
336 memset( &rv, 0, sizeof(rv) ); |
|
337 rv.iStandardResult = ERR_INVALIDARG; |
|
338 return rv; |
|
339 } |
|
340 |
|
341 ret = CheckDRDs( aArgs.iValueIntegerPart, aArgs.iValueFractionPart, |
|
342 aArgs.iMaximumValueIntegerPart, aArgs.iMaximumValueFractionPart, |
|
343 aArgs.iCongestionIntegerPart, aArgs.iCongestionFractionPart ); |
|
344 |
|
345 if ( ret == ERR_INVALIDARG ) |
|
346 { |
|
347 memset( &rv, 0, sizeof(rv) ); |
|
348 rv.iStandardResult = ERR_INVALIDARG; |
|
349 return rv; |
|
350 } |
|
351 |
|
352 // construct the command line |
|
353 snprintf( commandLine, MAX_COMMANDLINE, "./config_nistnet_add.pl -u -a %s %s --drd %d.%d %d.%d %d.%d", |
|
354 finalSrc, |
|
355 finalDst, |
|
356 aArgs.iValueIntegerPart, |
|
357 aArgs.iValueFractionPart, |
|
358 aArgs.iMaximumValueIntegerPart, |
|
359 aArgs.iMaximumValueFractionPart, |
|
360 aArgs.iCongestionIntegerPart, |
|
361 aArgs.iCongestionFractionPart ); |
|
362 |
|
363 // execute the command and return the result |
|
364 ret = execute(commandLine, &rv); |
|
365 assert ( (ret == ERR_FAILEDTOEXECUTECOMMAND) || (ret == ERR_NONE) ); |
|
366 |
|
367 return rv; |
|
368 } |
|
369 |
|
370 /**************************************************************************************** |
|
371 * |
|
372 * PUBLIC: st_clearsettings |
|
373 * |
|
374 ***************************************************************************************/ |
|
375 TResult CSvcUuinterface::st_clearsettings( TConfigValue aArgs ) |
|
376 { |
|
377 TResult rv; |
|
378 int ret; |
|
379 |
|
380 char commandLine [MAX_COMMANDLINE]; |
|
381 char finalSrc[TOTAL_MAX_ADDRESS_LEN]; |
|
382 char finalDst[TOTAL_MAX_ADDRESS_LEN]; |
|
383 |
|
384 // check the values in the config values structure |
|
385 ret = CheckConfigValue( aArgs, finalSrc, finalDst ); |
|
386 if ( ret == ERR_INVALIDARG ) |
|
387 { |
|
388 memset( &rv, 0, sizeof(rv) ); |
|
389 rv.iStandardResult = ERR_INVALIDARG; |
|
390 return rv; |
|
391 } |
|
392 |
|
393 // construct the command line |
|
394 snprintf( commandLine, MAX_COMMANDLINE, "./config_nistnet_add.pl -r %s %s", |
|
395 finalSrc, |
|
396 finalDst ); |
|
397 |
|
398 // execute the command and return the result |
|
399 ret = execute(commandLine, &rv); |
|
400 assert ( (ret == ERR_FAILEDTOEXECUTECOMMAND) || (ret == ERR_NONE) ); |
|
401 |
|
402 return rv; |
|
403 } |
|
404 |
|
405 |
|
406 /**************************************************************************************** |
|
407 * |
|
408 * PUBLIC: st_stopservice |
|
409 * |
|
410 ***************************************************************************************/ |
|
411 TResult CSvcUuinterface::st_stopservice( void ) |
|
412 { |
|
413 TResult rv; |
|
414 int ret; |
|
415 char commandLine [MAX_COMMANDLINE]; |
|
416 |
|
417 // construct the command line |
|
418 snprintf( commandLine, MAX_COMMANDLINE, "./config_nistnet_add.pl -d" ); |
|
419 |
|
420 // execute the command and return the result |
|
421 ret = execute(commandLine, &rv); |
|
422 assert ( (ret == ERR_FAILEDTOEXECUTECOMMAND) || (ret == ERR_NONE) ); |
|
423 |
|
424 return rv; |
|
425 } |
|
426 |
|
427 |
|
428 /**************************************************************************************** |
|
429 * |
|
430 * PUBLIC: st_reset |
|
431 * |
|
432 ***************************************************************************************/ |
|
433 TResult CSvcUuinterface::st_reset( void ) |
|
434 { |
|
435 TResult rv; |
|
436 int ret; |
|
437 char commandLine [MAX_COMMANDLINE]; |
|
438 |
|
439 // construct the command line |
|
440 snprintf( commandLine, MAX_COMMANDLINE, "./config_nistnet_reset.pl" ); |
|
441 |
|
442 // execute the command and return the result |
|
443 ret = execute(commandLine, &rv); |
|
444 assert ( (ret == ERR_FAILEDTOEXECUTECOMMAND) || (ret == ERR_NONE) ); |
|
445 |
|
446 return rv; |
|
447 } |
|
448 |
|
449 |
|
450 /**************************************************************************************** |
|
451 * |
|
452 * PRIVATE: Executes the given command line |
|
453 * |
|
454 ***************************************************************************************/ |
|
455 int CSvcUuinterface::execute(const char* aCommandLine, TResult* rv) |
|
456 { |
|
457 int errcode; |
|
458 CAProcess process; |
|
459 TCAProcessError perr; |
|
460 TProcessExitReason preason; |
|
461 |
|
462 // Check params |
|
463 assert ( aCommandLine != NULL ); |
|
464 assert ( rv != NULL ); |
|
465 |
|
466 // init the rv |
|
467 memset( rv, 0, sizeof(*rv) ); |
|
468 rv->iStandardResult = ERR_NONE; |
|
469 |
|
470 // execute the process - return any errors |
|
471 perr = process.Execute( aCommandLine, &errcode ); |
|
472 if( perr != CAE_NONE ) { |
|
473 rv->iStandardResult = ERR_PROCESSEXECUTEFAILED; |
|
474 rv->iExtendedCode = (int)perr; |
|
475 rv->iSystemError = errcode; |
|
476 } |
|
477 |
|
478 // if there was an error then return now |
|
479 if( rv->iStandardResult != ERR_NONE ) { |
|
480 return ERR_FAILEDTOEXECUTECOMMAND ; |
|
481 } |
|
482 |
|
483 // save the status, exitreason, etc |
|
484 perr = process.GetExitReason( &preason ); |
|
485 assert( perr == CAE_NONE ); |
|
486 rv->iExtendedCode = (int)preason; |
|
487 |
|
488 perr = process.GetExitCode( &errcode ); |
|
489 assert( perr == CAE_NONE ); |
|
490 rv->iSystemError = errcode; |
|
491 |
|
492 return ERR_NONE; |
|
493 } |
|
494 |
|
495 /******************************************************************************* |
|
496 * |
|
497 * INTERNAL FUNCTION: CheckConfigVals |
|
498 * |
|
499 ******************************************************************************/ |
|
500 int CSvcUuinterface::CheckConfigValue( TConfigValue aConfigValue, char* afinalSrc, char* afinalDst) |
|
501 { |
|
502 int err; |
|
503 |
|
504 assert ( afinalSrc != NULL ); |
|
505 assert ( afinalDst != NULL ); |
|
506 |
|
507 // construct valid NISTNET source/destination strings from the passed information |
|
508 err = GetSrcDstStrings( aConfigValue.iSourceAddress, aConfigValue.iDestinationAddress, |
|
509 aConfigValue.iProtocol, |
|
510 aConfigValue.iSrcPort, aConfigValue.iDstPort, |
|
511 afinalSrc, afinalDst ); |
|
512 if( err != ERR_NONE) { |
|
513 return ERR_INVALIDARG; |
|
514 } |
|
515 |
|
516 // do semantic checking of the values |
|
517 err = CheckCorrelation( aConfigValue.iCorrelationIntegerPart, aConfigValue.iCorrelationFractionPart ); |
|
518 if( err != ERR_NONE ) { |
|
519 return ERR_INVALIDARG; |
|
520 } |
|
521 |
|
522 err = CheckPositive( aConfigValue.iSigmaIntegerPart, aConfigValue.iSigmaFractionPart ); |
|
523 if( err != ERR_NONE ) { |
|
524 return ERR_INVALIDARG; |
|
525 } |
|
526 |
|
527 err = CheckPositive( aConfigValue.iValueIntegerPart, aConfigValue.iValueFractionPart ); |
|
528 if( err != ERR_NONE ) { |
|
529 return ERR_INVALIDARG; |
|
530 } |
|
531 |
|
532 err = CheckPositive( aConfigValue.iMaximumValueIntegerPart, aConfigValue.iMaximumValueFractionPart ); |
|
533 if( err != ERR_NONE ) { |
|
534 return ERR_INVALIDARG; |
|
535 } |
|
536 |
|
537 err = CheckPositive( aConfigValue.iCongestionIntegerPart, aConfigValue.iCongestionFractionPart ); |
|
538 if( err != ERR_NONE ) { |
|
539 return ERR_INVALIDARG; |
|
540 } |
|
541 |
|
542 return ERR_NONE; |
|
543 } |
|
544 |
|
545 /******************************************************************************* |
|
546 * |
|
547 * INTERNAL FUNCTION: CheckPorts |
|
548 * |
|
549 ******************************************************************************/ |
|
550 int CSvcUuinterface::CheckPorts( int aSrcPort, int aDestPort ) |
|
551 { |
|
552 |
|
553 if( !(( aSrcPort >= MIN_PORT_VAL ) && ( aSrcPort <= MAX_PORT_VAL )) ) { |
|
554 return ERR_INVALIDARG; |
|
555 } |
|
556 |
|
557 if( !(( aDestPort >= MIN_PORT_VAL ) && ( aDestPort <= MAX_PORT_VAL )) ) { |
|
558 return ERR_INVALIDARG; |
|
559 } |
|
560 |
|
561 return ERR_NONE; |
|
562 } |
|
563 |
|
564 /******************************************************************************* |
|
565 * |
|
566 * INTERNAL FUNCTION: CheckProts |
|
567 * |
|
568 ******************************************************************************/ |
|
569 int CSvcUuinterface::CheckProt( int aProtocol ) |
|
570 { |
|
571 if ( aProtocol == X_UDP ) |
|
572 return ERR_NONE; |
|
573 |
|
574 if ( aProtocol == X_TCP ) |
|
575 return ERR_NONE; |
|
576 |
|
577 return ERR_INVALIDARG; |
|
578 } |
|
579 |
|
580 |
|
581 /******************************************************************************* |
|
582 * |
|
583 * INTERNAL FUNCTION: CheckPositive |
|
584 * |
|
585 ******************************************************************************/ |
|
586 int CSvcUuinterface::CheckPositive( int aIntegerPart, int aFractionPart ) |
|
587 { |
|
588 if( aIntegerPart < 0 ) { |
|
589 return ERR_INVALIDARG; |
|
590 } |
|
591 if( aFractionPart < 0 ) { |
|
592 return ERR_INVALIDARG; |
|
593 } |
|
594 return ERR_NONE; |
|
595 } |
|
596 |
|
597 /******************************************************************************* |
|
598 * |
|
599 * INTERNAL FUNCTION: CheckCorrelation |
|
600 * |
|
601 ******************************************************************************/ |
|
602 int CSvcUuinterface::CheckCorrelation( int aIntegerPart, int aFractionPart ) |
|
603 { |
|
604 if( (aIntegerPart > -1) && (aIntegerPart < 1) ) { |
|
605 return ERR_NONE; |
|
606 } |
|
607 if( (aIntegerPart == -1) && (aFractionPart == 0) ) { |
|
608 return ERR_NONE; |
|
609 } |
|
610 if( (aIntegerPart == 1) && (aFractionPart == 0) ) { |
|
611 return ERR_NONE; |
|
612 } |
|
613 return ERR_INVALIDARG; |
|
614 } |
|
615 |
|
616 /******************************************************************************* |
|
617 * |
|
618 * INTERNAL FUNCTION: CheckDRDs |
|
619 * |
|
620 ******************************************************************************/ |
|
621 int CSvcUuinterface::CheckDRDs( const int aDRDMinInt, const int aDRDMinFrac, |
|
622 const int aDRDMaxInt, const int aDRDMaxFrac, |
|
623 const int aDRDCongestInt, const int aDRDCongestFrac ) |
|
624 { |
|
625 //Condition for drd vals is 0<=drdmin (<= drdcongest) <=drdmax |
|
626 if (!(aDRDMinInt>=0 && aDRDMinFrac>=0 && aDRDMaxInt >=0 && aDRDMaxFrac>=0 )) { |
|
627 return ERR_INVALIDARG; |
|
628 } |
|
629 if ( aDRDMinInt > aDRDMaxInt ) { |
|
630 return ERR_INVALIDARG; |
|
631 } |
|
632 if (aDRDCongestInt >= 0 && aDRDCongestFrac >=0) { |
|
633 if ( !( (aDRDMinInt < aDRDCongestInt) && (aDRDMaxInt > aDRDCongestInt) ) ) { |
|
634 return ERR_INVALIDARG; |
|
635 } |
|
636 } else { |
|
637 return ERR_INVALIDARG; |
|
638 } |
|
639 return ERR_NONE; |
|
640 } |
|
641 |
|
642 /******************************************************************************* |
|
643 * |
|
644 * INTERNAL FUNCTION: CheckPercentage |
|
645 * |
|
646 ******************************************************************************/ |
|
647 int CSvcUuinterface::CheckPercentage( const int aPercentage ) |
|
648 { |
|
649 if (aPercentage >= 0 && aPercentage < 100) |
|
650 return ERR_NONE; |
|
651 return ERR_INVALIDARG; |
|
652 } |
|
653 |
|
654 /******************************************************************************* |
|
655 * |
|
656 * GetSrcDstStrings |
|
657 * |
|
658 ******************************************************************************/ |
|
659 int CSvcUuinterface::GetSrcDstStrings( char* aSrc, char* aDst, |
|
660 int aProtocol, |
|
661 int aSrcPort, int aDstPort, |
|
662 char* finalSrc, char* finalDst ) |
|
663 { |
|
664 int err, len; |
|
665 |
|
666 // validate params |
|
667 assert(aSrc!=NULL); |
|
668 assert(aDst!=NULL); |
|
669 assert(finalSrc!=NULL); |
|
670 assert(finalDst!=NULL); |
|
671 |
|
672 // Validate the ports |
|
673 err = CheckPorts( aSrcPort,aDstPort ); |
|
674 if( err != ERR_NONE ) { |
|
675 return ERR_INVALIDARG; |
|
676 } |
|
677 |
|
678 // Validate the prots |
|
679 err = CheckProt( aProtocol ); |
|
680 if( err != ERR_NONE ) { |
|
681 return ERR_INVALIDARG; |
|
682 } |
|
683 |
|
684 // Formulate a complete source string <ip-address> + ':' + <port> + '.' + <protocol> |
|
685 len = strlen(aSrc) + 1 + 1 + 1 + 1 + 1; |
|
686 assert( len < TOTAL_MAX_ADDRESS_LEN ); |
|
687 snprintf( finalSrc, TOTAL_MAX_ADDRESS_LEN, "%s:%d.%d", aSrc, aSrcPort, aProtocol ); |
|
688 |
|
689 // Formulate a complete dest string <ip-address> + ':' + <port> + '.' + <protocol> |
|
690 len = strlen(aDst) + 1 + 1 + 1 + 1 + 1; |
|
691 assert( len < TOTAL_MAX_ADDRESS_LEN ); |
|
692 snprintf( finalDst, TOTAL_MAX_ADDRESS_LEN, "%s:%d.%d", aDst, aDstPort, aProtocol ); |
|
693 |
|
694 // done |
|
695 return ERR_NONE; |
|
696 } |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 |
|
704 |
|
705 |
|
706 |