Newer
Older
/******************************************************************************
Copyright 2016 - 2019 Intel Corporation
Copyright 2015 - 2016 Lantiq Beteiligungs-GmbH & Co. KG
Copyright 2009 - 2014 Lantiq Deutschland GmbH
Copyright 2007 - 2008 Infineon Technologies AG
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
For licensing information, see the file 'LICENSE' in the root folder of
this software module.
******************************************************************************/
/** \file
DSL CLI, access function implementation
*/
#include "dsl_cpe_control.h"
#if defined(INCLUDE_DSL_CPE_CLI_SUPPORT) && defined(INCLUDE_DSL_CPE_CLI_AUTOGEN_SUPPORT)
#include "dsl_cpe_cli.h"
#include "dsl_cpe_cli_console.h"
#include "dsl_cpe_debug.h"
#include "drv_dsl_cpe_api.h"
#include "drv_dsl_cpe_api_ioctl.h"
#if defined(INCLUDE_DSL_CPE_DTI_SUPPORT)
#include "dsl_cpe_dti.h"
#endif /* #if defined(INCLUDE_DSL_CPE_DTI_SUPPORT)*/
#undef DSL_CCA_DBG_BLOCK
#define DSL_CCA_DBG_BLOCK DSL_CCA_DBG_CLI
/* for debugging: */
#ifdef DSL_CLI_LOCAL
#undef DSL_CLI_LOCAL
#endif
#if 1
#define DSL_CLI_LOCAL
#else
#define DSL_CLI_LOCAL static
#endif
DSL_void_t DSL_CPE_CLI_AutogenCommandsRegister (DSL_void_t);
DSL_void_t DSL_CPE_CLI_DeviceCommandsRegister ( DSL_void_t );
#ifdef INCLUDE_DSL_ADSL_MIB
DSL_void_t DSL_CPE_CLI_MibCommandsRegister ( DSL_void_t );
#endif /* INCLUDE_DSL_ADSL_MIB*/
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
const char *sFailureReturn = "nReturn=%d%s";
#else
const char *sFailureReturn = "nReturn=%d";
#endif
#ifndef DSL_CPE_DEBUG_DISABLE
static const DSL_char_t g_sCcaDbgmlg[] =
"Long Form: %s" DSL_CPE_CRLF
"Short Form: %s" DSL_CPE_CRLF
DSL_CPE_CRLF
"Input Parameter" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
"- DSL_CCA_debugModules_t nCcaDbgModule (dec)" DSL_CPE_CRLF
" DSL_CCA_DBG_APP = 1" DSL_CPE_CRLF
" DSL_CCA_DBG_OS = 2" DSL_CPE_CRLF
" DSL_CCA_DBG_CLI = 3" DSL_CPE_CRLF
" DSL_CCA_DBG_PIPE = 4" DSL_CPE_CRLF
" DSL_CCA_DBG_CONSOLE = 6" DSL_CPE_CRLF
" DSL_CCA_DBG_TDPMSG = 7" DSL_CPE_CRLF
DSL_CPE_CRLF
"Output Parameter" DSL_CPE_CRLF
"- DSL_Error_t nReturn" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
"- DSL_debugLevels_t nDbgLevel (hex)" DSL_CPE_CRLF
" DSL_CCA_DBG_NONE = 0" DSL_CPE_CRLF
" DSL_CCA_DBG_PRN = 1" DSL_CPE_CRLF
" DSL_CCA_DBG_ERR = 2" DSL_CPE_CRLF
" DSL_CCA_DBG_WRN = 40" DSL_CPE_CRLF
" DSL_CCA_DBG_MSG = 80" DSL_CPE_CRLF
" DSL_CCA_DBG_LOCAL = FF" DSL_CPE_CRLF
DSL_CPE_CRLF "";
DSL_CLI_LOCAL DSL_int_t DSL_CPE_CLI_CCA_DBG_ModuleLevelGet(
DSL_int_t fd,
DSL_char_t *pCommands,
DSL_CPE_File_t *out)
{
DSL_int_t ret = 0;
DSL_CCA_debugLevels_t nDbgLvl = DSL_CCA_DBG_NONE;
DSL_CCA_debugModules_t nDbgModule = DSL_CCA_DBG_NO_BLOCK;
if (DSL_CPE_CLI_CheckParamNumber(pCommands, 1, DSL_CLI_EQUALS) == DSL_FALSE)
{
return -1;
}
sscanf (pCommands, "%d", &nDbgModule);
if ((nDbgModule > DSL_CCA_DBG_NO_BLOCK) && (nDbgModule < DSL_CCA_DBG_LAST_BLOCK))
{
nDbgLvl = DSL_CCA_g_dbgLvl[nDbgModule].nDbgLvl;
}
else
{
ret = -1;
}
DSL_CPE_FPrintf (out, DSL_CPE_RET"nDbgLevel=%x" DSL_CPE_CRLF, DSL_CPE_RET_VAL(ret), nDbgLvl);
return 0;
}
#endif
#ifndef DSL_CPE_DEBUG_DISABLE
static const DSL_char_t g_sCcaDbgmls[] =
"Long Form: %s" DSL_CPE_CRLF
"Short Form: %s" DSL_CPE_CRLF
DSL_CPE_CRLF
"Input Parameter" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
"- DSL_CCA_debugModules_t nCcaDbgModule (dec)" DSL_CPE_CRLF
" DSL_CCA_DBG_APP = 1" DSL_CPE_CRLF
" DSL_CCA_DBG_OS = 2" DSL_CPE_CRLF
" DSL_CCA_DBG_CLI = 3" DSL_CPE_CRLF
" DSL_CCA_DBG_PIPE = 4" DSL_CPE_CRLF
" DSL_CCA_DBG_CONSOLE = 6" DSL_CPE_CRLF
" DSL_CCA_DBG_TCPMSG = 7" DSL_CPE_CRLF
"- DSL_CCA_debugLevels_t nDbgLevel (hex)" DSL_CPE_CRLF
" DSL_CCA_DBG_NONE = 0" DSL_CPE_CRLF
" DSL_CCA_DBG_PRN = 1" DSL_CPE_CRLF
" DSL_CCA_DBG_ERR = 2" DSL_CPE_CRLF
" DSL_CCA_DBG_WRN = 40" DSL_CPE_CRLF
" DSL_CCA_DBG_MSG = 80" DSL_CPE_CRLF
" DSL_CCA_DBG_LOCAL = FF" DSL_CPE_CRLF
DSL_CPE_CRLF
"Output Parameter" DSL_CPE_CRLF
"- DSL_Error_t nReturn" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
DSL_CPE_CRLF "";
DSL_CLI_LOCAL DSL_int_t DSL_CPE_CLI_CCA_DBG_ModuleLevelSet(
DSL_int_t fd,
DSL_char_t *pCommands,
DSL_CPE_File_t *out)
{
DSL_int_t ret = 0;
DSL_CCA_debugLevels_t nDbgLvl = DSL_CCA_DBG_NONE;
DSL_CCA_debugModules_t nDbgModule = DSL_CCA_DBG_NO_BLOCK;
if (DSL_CPE_CLI_CheckParamNumber(pCommands, 2, DSL_CLI_EQUALS) == DSL_FALSE)
{
return -1;
}
sscanf (pCommands, "%d %x", &nDbgModule, &nDbgLvl);
if ((nDbgModule > DSL_CCA_DBG_NO_BLOCK) && (nDbgModule < DSL_CCA_DBG_LAST_BLOCK))
{
if ((nDbgLvl == DSL_CCA_DBG_PRN) || (nDbgLvl == DSL_CCA_DBG_ERR) ||
(nDbgLvl == DSL_CCA_DBG_WRN) || (nDbgLvl == DSL_CCA_DBG_MSG) ||
(nDbgLvl == DSL_CCA_DBG_LOCAL))
{
DSL_CCA_g_dbgLvl[nDbgModule].nDbgLvl = nDbgLvl;
}
else
{
ret = -1;
}
}
else
{
ret = -1;
}
DSL_CPE_FPrintf (out, DSL_CPE_RET"nDbgLevel=%x" DSL_CPE_CRLF, DSL_CPE_RET_VAL(ret), nDbgLvl);
return 0;
}
#endif
#ifdef INCLUDE_SCRIPT_NOTIFICATION
static const DSL_char_t g_sNsecs[] =
#ifndef DSL_CPE_DEBUG_DISABLE
"Long Form: %s" DSL_CPE_CRLF
"Short Form: %s" DSL_CPE_CRLF
DSL_CPE_CRLF
"Input Parameter" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
"- DSL_char_t notify_script[1-256] (Attention: Use absolute firmware path only!)"
DSL_CPE_CRLF
"Output Parameter" DSL_CPE_CRLF
"- DSL_Error_t nReturn" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
DSL_CPE_CRLF "";
#else
"";
#endif
DSL_CLI_LOCAL DSL_int_t DSL_CPE_CLI_NotificationScriptExecuteConfigSet(
DSL_int_t fd,
DSL_char_t *pCommands,
DSL_CPE_File_t *out)
{
DSL_int_t ret = 0;
DSL_char_t sNotifyScript[256] = { 0 };
if (DSL_CPE_CLI_CheckParamNumber(pCommands, 1, DSL_CLI_MIN) == DSL_FALSE)
{
return -1;
}
sscanf (pCommands, "%s", &sNotifyScript);
/* Get ADSL script file */
if ( strlen(sNotifyScript) > 0 )
{
if (DSL_CPE_IsFileExists(sNotifyScript))
{
if (g_sRcScript)
{
DSL_CPE_Free(g_sRcScript);
g_sRcScript = DSL_NULL;
}
g_sRcScript = DSL_CPE_Malloc (strlen (sNotifyScript) + 1);
if (g_sRcScript)
{
memset(g_sRcScript, 0, strlen (sNotifyScript) + 1);
cpe_control_strncpy_s(g_sRcScript, strlen (sNotifyScript) + 1, sNotifyScript, strlen (sNotifyScript));
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
}
}
else
{
ret = -1;
}
}
DSL_CPE_FPrintf (out, DSL_CPE_RET DSL_CPE_CRLF, DSL_CPE_RET_VAL(ret));
if (ret < 0)
{
DSL_CPE_FPrintf(out, " (Have you used absolute script path?)" DSL_CPE_CRLF);
}
return 0;
}
#endif /* INCLUDE_SCRIPT_NOTIFICATION*/
#ifdef INCLUDE_SCRIPT_NOTIFICATION
static const DSL_char_t g_sNsecg[] =
#ifndef DSL_CPE_DEBUG_DISABLE
"Long Form: %s" DSL_CPE_CRLF
"Short Form: %s" DSL_CPE_CRLF
DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"Input Parameter" DSL_CPE_CRLF
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
DSL_CPE_CRLF
#endif
"Output Parameter" DSL_CPE_CRLF
"- DSL_Error_t nReturn" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
"- DSL_char_t notify_script[256]" DSL_CPE_CRLF
DSL_CPE_CRLF "";
#else
"";
#endif
DSL_CLI_LOCAL DSL_int_t DSL_CPE_CLI_NotificationScriptExecuteConfigGet(
DSL_int_t fd,
DSL_char_t *pCommands,
DSL_CPE_File_t *out)
{
DSL_int_t ret = 0;
if (DSL_CPE_CLI_CheckParamNumber(pCommands, 0, DSL_CLI_EQUALS) == DSL_FALSE)
{
return -1;
}
DSL_CPE_FPrintf (out, DSL_CPE_RET, DSL_CPE_RET_VAL(ret));
if(g_sRcScript != DSL_NULL)
{
DSL_CPE_FPrintf (out, " notify_script=%s", g_sRcScript);
}
else
{
DSL_CPE_FPrintf (out, " notify_script=n/a");
}
DSL_CPE_FPrintf (out, DSL_CPE_CRLF);
return 0;
}
#endif /* INCLUDE_SCRIPT_NOTIFICATION*/
#ifdef INCLUDE_DSL_CPE_FILESYSTEM_SUPPORT
#ifdef INCLUDE_DSL_CPE_CMV_SCRIPTS_SUPPORT
static const DSL_char_t g_sAsecg[] =
#ifndef DSL_CPE_DEBUG_DISABLE
"Long Form: %s" DSL_CPE_CRLF
"Short Form: %s" DSL_CPE_CRLF
DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"Input Parameter" DSL_CPE_CRLF
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
DSL_CPE_CRLF
#endif
"Output Parameter" DSL_CPE_CRLF
"- DSL_Error_t nReturn" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
"- DSL_char_t adsl_script[256]" DSL_CPE_CRLF
#if (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 1)
"- DSL_char_t vdsl_script[256]" DSL_CPE_CRLF
#endif
DSL_CPE_CRLF "";
#else
"";
#endif
DSL_CLI_LOCAL DSL_int_t DSL_CPE_CLI_AutobootScriptExecuteConfigGet(
DSL_int_t fd,
DSL_char_t *pCommands,
DSL_CPE_File_t *out)
{
DSL_int_t ret = 0;
if (DSL_CPE_CLI_CheckParamNumber(pCommands, 0, DSL_CLI_EQUALS) == DSL_FALSE)
{
return -1;
}
DSL_CPE_FPrintf (out, DSL_CPE_RET, DSL_CPE_RET_VAL(ret));
if(g_sAdslScript != DSL_NULL)
{
DSL_CPE_FPrintf (out, " adsl_script=%s", g_sAdslScript);
}
else
{
DSL_CPE_FPrintf (out, " adsl_script=n/a");
}
#if (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 1)
if(g_sVdslScript != DSL_NULL)
{
DSL_CPE_FPrintf (out, " vdsl_script=%s", g_sVdslScript);
}
else
{
DSL_CPE_FPrintf (out, " vdsl_script=n/a");
}
#endif
DSL_CPE_FPrintf (out, DSL_CPE_CRLF);
return 0;
}
#endif
#endif
#ifdef INCLUDE_DSL_CPE_FILESYSTEM_SUPPORT
#ifdef INCLUDE_DSL_CPE_CMV_SCRIPTS_SUPPORT
static const DSL_char_t g_sAsecs[] =
#ifndef DSL_CPE_DEBUG_DISABLE
"Long Form: %s" DSL_CPE_CRLF
"Short Form: %s" DSL_CPE_CRLF
DSL_CPE_CRLF
"Input Parameter" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
"- DSL_char_t adsl_script[1-256]"
#if (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 0)
" (let empty to clear currently set value,"
" adsl_script must include the full path to the script)" DSL_CPE_CRLF
#else
" (enter '.' to let adsl script unchanged)" DSL_CPE_CRLF
"- DSL_char_t vdsl_script[1-256]"
" (enter '.' to let vdsl script unchanged, or let empty to clear currently set value,"
" let both parameters empty to clear currently set values"
" vdsl_script must include the full path to the script)" DSL_CPE_CRLF
#endif
DSL_CPE_CRLF
"Output Parameter" DSL_CPE_CRLF
"- DSL_Error_t nReturn" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
DSL_CPE_CRLF "";
#else
"";
#endif
DSL_CLI_LOCAL DSL_int_t DSL_CPE_CLI_AutobootScriptExecuteConfigSet(
DSL_int_t fd,
DSL_char_t *pCommands,
DSL_CPE_File_t *out)
{
DSL_int_t ret = 0;
DSL_char_t sAdslScript[256] = { 0 };
#if (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 1)
DSL_char_t sVdslScript[256] = { 0 };
#endif
if (DSL_CPE_CLI_CheckParamNumber(pCommands, 0, DSL_CLI_MIN) == DSL_FALSE)
{
return -1;
}
#if (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 1)
if (DSL_CPE_CLI_CheckParamNumber(pCommands, 2, DSL_CLI_MAX) == DSL_FALSE)
#else
if (DSL_CPE_CLI_CheckParamNumber(pCommands, 1, DSL_CLI_MAX) == DSL_FALSE)
#endif
{
return -1;
}
#if (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 1)
sscanf (pCommands, "%s %s", &sAdslScript, &sVdslScript);
#else
sscanf (pCommands, "%s", &sAdslScript);
#endif
/* Get ADSL script file */
if ( strlen(sAdslScript) > 0 )
{
if ( strcmp(sAdslScript, ".") != 0 )
{
if (DSL_CPE_IsFileExists(sAdslScript))
{
if (g_sAdslScript)
{
DSL_CPE_Free(g_sAdslScript);
g_sAdslScript = DSL_NULL;
}
g_sAdslScript = DSL_CPE_Malloc (strlen (sAdslScript) + 1);
if (g_sAdslScript)
{
memset(g_sAdslScript, 0, strlen (sAdslScript) + 1);
cpe_control_strncpy_s(g_sAdslScript, strlen (sAdslScript) + 1, sAdslScript, strlen (sAdslScript));
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
}
}
else
{
ret = -1;
}
}
}
else
{
DSL_CPE_Free(g_sAdslScript);
g_sAdslScript = DSL_NULL;
}
#if (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 1)
/* Get VDSL script file */
if (strlen(sVdslScript) > 0)
{
if ( strcmp(sVdslScript, ".") != 0 )
{
if (DSL_CPE_IsFileExists(sVdslScript))
{
if (g_sVdslScript)
{
DSL_CPE_Free(g_sVdslScript);
g_sVdslScript = DSL_NULL;
}
g_sVdslScript = DSL_CPE_Malloc (strlen (sVdslScript) + 1);
if (g_sVdslScript)
{
memset(g_sVdslScript, 0, strlen (sVdslScript) + 1);
cpe_control_strncpy_s(g_sVdslScript, strlen (sVdslScript) + 1, sVdslScript, strlen (sVdslScript));
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
}
}
else
{
ret = -1;
}
}
}
else
{
DSL_CPE_Free(g_sVdslScript);
g_sVdslScript = DSL_NULL;
}
#endif
DSL_CPE_FPrintf (out, DSL_CPE_RET DSL_CPE_CRLF, DSL_CPE_RET_VAL(ret));
if (ret < 0)
{
DSL_CPE_FPrintf(out, " (Have you used absolute script path?)" DSL_CPE_CRLF);
}
return 0;
}
#endif
#endif
#ifdef INCLUDE_DSL_CPE_CMV_SCRIPTS_SUPPORT
static const DSL_char_t g_sAcfgs[] =
#ifndef DSL_CPE_DEBUG_DISABLE
"Long Form: %s" DSL_CPE_CRLF
"Short Form: %s" DSL_CPE_CRLF
DSL_CPE_CRLF
"Input Parameter" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
"- DSL_boolean_t bWaitBeforeConfigWrite" DSL_CPE_CRLF
" false = 0" DSL_CPE_CRLF
" true = 1" DSL_CPE_CRLF
"- DSL_boolean_t bWaitBeforeLinkActivation" DSL_CPE_CRLF
" false = 0" DSL_CPE_CRLF
" true = 1" DSL_CPE_CRLF
"- DSL_boolean_t bWaitBeforeRestart" DSL_CPE_CRLF
" false = 0" DSL_CPE_CRLF
" true = 1" DSL_CPE_CRLF
"- DSL_boolean_t bAutoContinueWaitBeforeConfigWrite (dsl_cpe_control)" DSL_CPE_CRLF
" false = 0" DSL_CPE_CRLF
" true = 1" DSL_CPE_CRLF
"- DSL_boolean_t bAutoContinueWaitBeforeLinkActivation (dsl_cpe_control)" DSL_CPE_CRLF
" false = 0" DSL_CPE_CRLF
" true = 1" DSL_CPE_CRLF
"- DSL_boolean_t bAutoContinueWaitBeforeRestart (dsl_cpe_control)" DSL_CPE_CRLF
" false = 0" DSL_CPE_CRLF
" true = 1" DSL_CPE_CRLF
DSL_CPE_CRLF
"Output Parameter" DSL_CPE_CRLF
"- DSL_Error_t nReturn" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
DSL_CPE_CRLF "";
#else
"";
#endif
DSL_CLI_LOCAL DSL_int_t DSL_CPE_CLI_AutobootConfigOptionSet(
DSL_int_t fd,
DSL_char_t *pCommands,
DSL_CPE_File_t *out)
{
DSL_int_t ret = 0;
DSL_boolean_t bAdsl = DSL_FALSE, bVdsl = DSL_FALSE;
DSL_boolean_t bAutoContinueWaitBeforeLinkActivation = DSL_TRUE,
bAutoContinueWaitBeforeConfigWrite = DSL_TRUE,
bAutoContinueWaitBeforeRestart = DSL_TRUE,
bWaitBeforeLinkActivation = DSL_FALSE,
bWaitBeforeConfigWrite = DSL_FALSE, bWaitBeforeRestart = DSL_FALSE;
DSL_AutobootConfig_t pData;
DSL_CPE_Control_Context_t *pCtx = DSL_NULL;
DSL_uint32_t nDevice = 0;
DSL_int_t nDeviceNum = -1;
if (DSL_CPE_CLI_CheckParamNumber(pCommands, 6, DSL_CLI_EQUALS) == DSL_FALSE)
{
return -1;
}
sscanf (pCommands, "%u %u %u %u %u %u",
&bWaitBeforeConfigWrite, &bWaitBeforeLinkActivation, &bWaitBeforeRestart,
&bAutoContinueWaitBeforeConfigWrite, &bAutoContinueWaitBeforeLinkActivation,
&bAutoContinueWaitBeforeRestart);
if ((g_sAdslScript != DSL_NULL) && (strlen(g_sAdslScript) > 0))
{
bAdsl = DSL_TRUE;
}
if ((g_sVdslScript != DSL_NULL) && (strlen(g_sVdslScript) > 0))
{
bVdsl = DSL_TRUE;
}
if ( (bAdsl == DSL_TRUE) || (bVdsl == DSL_TRUE) )
{
if (!bWaitBeforeLinkActivation && !bWaitBeforeConfigWrite && !bWaitBeforeRestart)
{
DSL_CPE_FPrintf (out, "Warning: bWaitBeforeConfigWrite, bWaitBeforeLinkActivation and "
"bWaitBeforeRestart were set to false "
"but an autostart script was selected (autostart script "
"handling only works when one these settings is set to true)" DSL_CPE_CRLF);
DSL_CPE_FPrintf (out, "Set bWaitBeforeConfigWrite = DSL_TRUE, "
"bWaitBeforeLinkActivation = DSL_TRUE, bWaitBeforeRestart = DSL_TRUE!" DSL_CPE_CRLF);
bWaitBeforeConfigWrite = DSL_TRUE;
bWaitBeforeLinkActivation = DSL_TRUE;
bWaitBeforeRestart = DSL_TRUE;
}
}
if ((pCtx = DSL_CPE_GetGlobalContext()) != DSL_NULL)
{
if (pCtx->bBackwardCompMode)
{
nDeviceNum = pCtx->nDevNum;
}
else if (DSL_CPE_DSL_ENTITIES > 1)
{
for (nDevice = 0; nDevice < DSL_CPE_DSL_ENTITIES; nDevice++)
{
if(pCtx->fd[nDevice] == fd)
{
nDeviceNum = nDevice;
break;
}
}
}
}
else
{
DSL_CPE_FPrintf (out, DSL_CPE_RET DSL_CPE_CRLF, DSL_CPE_RET_VAL(-1));
return 0;
}
if (nDeviceNum == -1)
{
DSL_CPE_FPrintf (out, DSL_CPE_RET DSL_CPE_CRLF, DSL_CPE_RET_VAL(-1));
return 0;
}
g_bWaitBeforeConfigWrite[nDeviceNum] = bWaitBeforeConfigWrite;
g_bWaitBeforeLinkActivation[nDeviceNum] = bWaitBeforeLinkActivation;
g_bWaitBeforeRestart[nDeviceNum] = bWaitBeforeRestart;
g_bAutoContinueWaitBeforeConfigWrite[nDeviceNum] = bAutoContinueWaitBeforeConfigWrite;
g_bAutoContinueWaitBeforeLinkActivation[nDeviceNum] = bAutoContinueWaitBeforeLinkActivation;
g_bAutoContinueWaitBeforeRestart[nDeviceNum] = bAutoContinueWaitBeforeRestart;
pData.data.nStateMachineOptions.bWaitBeforeConfigWrite =
bWaitBeforeConfigWrite;
pData.data.nStateMachineOptions.bWaitBeforeLinkActivation =
bWaitBeforeLinkActivation;
pData.data.nStateMachineOptions.bWaitBeforeRestart =
bWaitBeforeRestart;
ret = DSL_CPE_Ioctl (fd, DSL_FIO_AUTOBOOT_CONFIG_SET, (int) &pData);
if ((ret < 0) && (pData.accessCtl.nReturn < DSL_SUCCESS))
{
DSL_CPE_FPrintf (out, DSL_CPE_RET DSL_CPE_CRLF, DSL_CPE_RET_VAL(pData.accessCtl.nReturn));
}
else
{
DSL_CPE_FPrintf (out, DSL_CPE_RET DSL_CPE_CRLF, DSL_CPE_RET_VAL(ret));
}
return 0;
}
#endif
#ifdef INCLUDE_DSL_CONFIG_GET
#ifdef INCLUDE_DSL_CPE_CMV_SCRIPTS_SUPPORT
static const DSL_char_t g_sAcfgg[] =
#ifndef DSL_CPE_DEBUG_DISABLE
"Long Form: %s" DSL_CPE_CRLF
"Short Form: %s" DSL_CPE_CRLF
DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"Input Parameter" DSL_CPE_CRLF
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
DSL_CPE_CRLF
#endif
"Output Parameter" DSL_CPE_CRLF
"- DSL_Error_t nReturn" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
"- DSL_boolean_t bWaitBeforeConfigWrite" DSL_CPE_CRLF
" false = 0" DSL_CPE_CRLF
" true = 1" DSL_CPE_CRLF
"- DSL_boolean_t bWaitBeforeLinkActivation" DSL_CPE_CRLF
" false = 0" DSL_CPE_CRLF
" true = 1" DSL_CPE_CRLF
"- DSL_boolean_t bWaitBeforeRestart" DSL_CPE_CRLF
" false = 0" DSL_CPE_CRLF
" true = 1" DSL_CPE_CRLF
"- DSL_boolean_t bAutoContinueWaitBeforeConfigWrite (dsl_cpe_control)" DSL_CPE_CRLF
" false = 0" DSL_CPE_CRLF
" true = 1" DSL_CPE_CRLF
"- DSL_boolean_t bAutoContinueWaitBeforeLinkActivation (dsl_cpe_control)" DSL_CPE_CRLF
" false = 0" DSL_CPE_CRLF
" true = 1" DSL_CPE_CRLF
"- DSL_boolean_t bAutoContinueWaitBeforeRestart (dsl_cpe_control)" DSL_CPE_CRLF
" false = 0" DSL_CPE_CRLF
" true = 1" DSL_CPE_CRLF
DSL_CPE_CRLF "";
#else
"";
#endif
DSL_CLI_LOCAL DSL_int_t DSL_CPE_CLI_AutobootConfigOptionGet(
DSL_int_t fd,
DSL_char_t *pCommands,
DSL_CPE_File_t *out)
{
DSL_int_t ret = 0;
DSL_AutobootConfig_t pData;
DSL_CPE_Control_Context_t *pCtx = DSL_NULL;
DSL_uint32_t nDevice = 0;
DSL_int_t nDeviceNum = -1;
if (DSL_CPE_CLI_CheckParamNumber(pCommands, 0, DSL_CLI_EQUALS) == DSL_FALSE)
{
return -1;
}
ret = DSL_CPE_Ioctl (fd, DSL_FIO_AUTOBOOT_CONFIG_GET, (int) &pData);
if ((ret < 0) && (pData.accessCtl.nReturn < DSL_SUCCESS))
{
DSL_CPE_FPrintf (out, DSL_CPE_RET DSL_CPE_CRLF, DSL_CPE_RET_VAL(pData.accessCtl.nReturn));
}
else
{
if ((pCtx = DSL_CPE_GetGlobalContext()) != DSL_NULL)
{
if (pCtx->bBackwardCompMode)
{
nDeviceNum = pCtx->nDevNum;
}
else if (DSL_CPE_DSL_ENTITIES > 1)
{
for (nDevice = 0; nDevice < DSL_CPE_DSL_ENTITIES; nDevice++)
{
if(pCtx->fd[nDevice] == fd)
{
nDeviceNum = nDevice;
break;
}
}
}
}
else
{
DSL_CPE_FPrintf (out, DSL_CPE_RET DSL_CPE_CRLF, DSL_CPE_RET_VAL(-1));
return 0;
}
if (nDeviceNum == -1)
{
DSL_CPE_FPrintf (out, DSL_CPE_RET DSL_CPE_CRLF, DSL_CPE_RET_VAL(-1));
return 0;
}
g_bWaitBeforeConfigWrite[nDeviceNum] =
pData.data.nStateMachineOptions.bWaitBeforeConfigWrite;
g_bWaitBeforeLinkActivation[nDeviceNum] =
pData.data.nStateMachineOptions.bWaitBeforeLinkActivation;
g_bWaitBeforeRestart[nDeviceNum] =
pData.data.nStateMachineOptions.bWaitBeforeRestart;
DSL_CPE_FPrintf (out, DSL_CPE_RET"bWaitBeforeConfigWrite=%d "
"bWaitBeforeLinkActivation=%d bWaitBeforeRestart=%d bAutoContinueWaitBeforeConfigWrite=%d "
"bAutoContinueWaitBeforeLinkActivation=%d bAutoContinueWaitBeforeRestart=%d"
DSL_CPE_CRLF, DSL_CPE_RET_VAL(pData.accessCtl.nReturn), g_bWaitBeforeConfigWrite[nDeviceNum],
g_bWaitBeforeLinkActivation[nDeviceNum], g_bWaitBeforeRestart[nDeviceNum],
g_bAutoContinueWaitBeforeConfigWrite[nDeviceNum], g_bAutoContinueWaitBeforeLinkActivation[nDeviceNum],
g_bAutoContinueWaitBeforeRestart[nDeviceNum]);
}
return 0;
}
#endif
#endif
static const DSL_char_t g_sAlf[] =
#ifndef DSL_CPE_DEBUG_DISABLE
"Long Form: %s" DSL_CPE_CRLF
"Short Form: %s" DSL_CPE_CRLF
DSL_CPE_CRLF
"Input Parameter" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
#if defined(INCLUDE_DSL_CPE_API_DANUBE)
"- DSL_char_t adsl_firmware[1-256] (Attention: Use absolute firmware path only,"
#else
"- DSL_char_t firmware1[1-256] (Attention: Use absolute firmware path only,"
#endif
#if (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 1)
" enter '.' to let empty, to specify adsl_firmware only)" DSL_CPE_CRLF
"- DSL_char_t adsl_firmware[1-256] (Attention: Use absolute firmware path only!)" DSL_CPE_CRLF
#endif
DSL_CPE_CRLF
"Output Parameter" DSL_CPE_CRLF
"- DSL_Error_t nReturn" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
DSL_CPE_CRLF "";
#else
"";
#endif
DSL_CLI_LOCAL DSL_int_t DSL_CPE_CLI_AutobootLoadFirmware(
DSL_int_t fd,
DSL_char_t *pCommands,
DSL_CPE_File_t *out)
{
DSL_int_t ret = 0;
DSL_char_t sFirmwareName1[256] = { 0 };
DSL_char_t *pcFw = DSL_NULL;
#if (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 1)
DSL_char_t *pcFw2 = DSL_NULL;
#endif /* (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 1) || !defined(INCLUDE_FW_REQUEST_SUPPORT)*/
#if (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 1)
DSL_char_t sFirmwareName2[256] = { 0 };
#endif
#ifdef INCLUDE_FW_REQUEST_SUPPORT
#endif /* INCLUDE_FW_REQUEST_SUPPORT*/
#if (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 1)
if (DSL_CPE_CLI_CheckParamNumber(pCommands, 1, DSL_CLI_MIN) == DSL_FALSE)
{
return -1;
}
if (DSL_CPE_CLI_CheckParamNumber(pCommands, 2, DSL_CLI_MAX) == DSL_FALSE)
{
return -1;
}
#else
if (DSL_CPE_CLI_CheckParamNumber(pCommands, 1, DSL_CLI_EQUALS) == DSL_FALSE)
{
return -1;
}
#endif
#if (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 1)
sscanf (pCommands, "%s %s", sFirmwareName1, sFirmwareName2);
#else
sscanf (pCommands, "%s", sFirmwareName1);
#endif
/* Get Firmware binary 1 */
if ((strlen(sFirmwareName1) > 0) && (strcmp(sFirmwareName1, ".") != 0))
{
pcFw = &sFirmwareName1[0];
}
#if (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 1)
/* Get Firmware binary 2 */
if (strlen(sFirmwareName2) > 0)
{
pcFw2 = &sFirmwareName2[0];
}
#endif
/* Update links to the FW binaries */
if (pcFw)
{
if (g_sFirmwareName1 != DSL_NULL)
{
DSL_CPE_Free(g_sFirmwareName1);
}
g_sFirmwareName1 = DSL_CPE_Malloc (strlen (pcFw) + 1);
if (g_sFirmwareName1)
{
memset(g_sFirmwareName1, 0, strlen (pcFw) + 1);
cpe_control_strncpy_s(g_sFirmwareName1, strlen (pcFw) + 1, pcFw, strlen (pcFw));
}
DSL_CPE_FwFeaturesGet(g_sFirmwareName1, &g_nFwFeatures1);
}
#if (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 1)
if (pcFw2)
{
if (g_sFirmwareName2 != DSL_NULL)
{
DSL_CPE_Free(g_sFirmwareName2);
}
g_sFirmwareName2 = DSL_CPE_Malloc (strlen (pcFw2) + 1);
if (g_sFirmwareName2)
{
memset(g_sFirmwareName2, 0, strlen (pcFw2) + 1);
cpe_control_strncpy_s(g_sFirmwareName2, strlen (pcFw2) + 1, pcFw2, strlen (pcFw2));
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
}
DSL_CPE_FwFeaturesGet(g_sFirmwareName2, &g_nFwFeatures2);
}
#endif /* (INCLUDE_DSL_CPE_API_VDSL_SUPPORT == 1)*/
#ifdef INCLUDE_FW_REQUEST_SUPPORT
#if defined(INCLUDE_DSL_CPE_API_DANUBE)
ret = DSL_CPE_DownloadFirmware(fd, DSL_FW_REQUEST_NA, pcFw, DSL_NULL);
DSL_CPE_FPrintf (out, DSL_CPE_RET, DSL_CPE_RET_VAL(ret));
if (ret < DSL_SUCCESS)
{
DSL_CPE_FPrintf(out, " (Have you used absolute firmware path?)" DSL_CPE_CRLF);
}
#else
ret = DSL_CPE_Ioctl (fd, DSL_FIO_AUTOBOOT_STATUS_GET, (int) &AutobootStatus);
if ((ret < 0) && (AutobootStatus.accessCtl.nReturn < DSL_SUCCESS))
{
DSL_CPE_FPrintf (out, sFailureReturn, DSL_CPE_RET_VAL(autobootCtrl.accessCtl.nReturn));
return 0;
}
if (AutobootStatus.data.nStatus == DSL_AUTOBOOT_STATUS_FW_WAIT)
{
ret = DSL_CPE_DownloadFirmware(fd, AutobootStatus.data.nFirmwareRequestType, pcFw, pcFw2);
DSL_CPE_FPrintf (out, DSL_CPE_RET, DSL_CPE_RET_VAL(ret));
if (ret < DSL_SUCCESS)
{
DSL_CPE_FPrintf(out, " (Have you used absolute firmware path?)" DSL_CPE_CRLF);
}
}
else
{
/* Trigger Autoboot restart sequence. FW binary will be requested
from the DSL CPE API driver later*/
autobootCtrl.data.nCommand = DSL_AUTOBOOT_CTRL_RESTART;
ret = DSL_CPE_Ioctl (fd, DSL_FIO_AUTOBOOT_CONTROL_SET, (int) &autobootCtrl);
if ((ret < 0) && (autobootCtrl.accessCtl.nReturn < DSL_SUCCESS))
{
DSL_CPE_FPrintf (out, sFailureReturn, autobootCtrl.accessCtl.nReturn);
}
else
{
DSL_CPE_FPrintf (out, DSL_CPE_RET DSL_CPE_CRLF, DSL_CPE_RET_VAL(ret));
}
}
#endif /* defined(INCLUDE_DSL_CPE_API_DANUBE) && !defined(DSL_FIRMWARE_MEMORY_FREE_ENABLED)*/
#else
ret = DSL_CPE_DownloadFirmware(fd, DSL_FW_REQUEST_NA, pcFw, pcFw2);
DSL_CPE_FPrintf (out, DSL_CPE_RET, DSL_CPE_RET_VAL(ret));
if (ret < DSL_SUCCESS)
{
DSL_CPE_FPrintf(out, " (Have you used absolute firmware path?)" DSL_CPE_CRLF);
}
#endif /* INCLUDE_FW_REQUEST_SUPPORT*/
return 0;
}
#ifdef INCLUDE_DSL_RESOURCE_STATISTICS
static const DSL_char_t g_sRusg[] =
#ifndef DSL_CPE_DEBUG_DISABLE
"Long Form: %s" DSL_CPE_CRLF
"Short Form: %s" DSL_CPE_CRLF
DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"Input Parameter" DSL_CPE_CRLF
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
DSL_CPE_CRLF
#endif
"Output Parameter" DSL_CPE_CRLF
"- DSL_Error_t nReturn" DSL_CPE_CRLF
#if (DSL_CPE_MAX_DSL_ENTITIES > 1)
"- DSL_uint32_t nDevice (optional, not used in the 'backward compatible' mode)" DSL_CPE_CRLF
#endif
"- DSL_uint32_t drvStaticMemUsage" DSL_CPE_CRLF
"- DSL_uint32_t drvDynamicMemUsage" DSL_CPE_CRLF
"- DSL_uint32_t appStaticMemUsage" DSL_CPE_CRLF
"- DSL_uint32_t appDynamicMemUsage" DSL_CPE_CRLF
DSL_CPE_CRLF "";
#else
"";
#endif
DSL_CLI_LOCAL DSL_int_t DSL_CPE_CLI_ResourceUsageStatisticsGet(
DSL_int_t fd,
DSL_char_t *pCommands,
DSL_CPE_File_t *out)
{
DSL_int_t ret = 0;
DSL_ResourceUsageStatistics_t pData;