summaryrefslogtreecommitdiffstats
path: root/private/ntos/ndis/testprot/tpctl/cmd.c
blob: ec5ca1465ec823f5a9c38772e4a96fda19bbeb32 (plain) (blame)
1
2
3
4
5
6
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
242
243
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
459
460
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
491
492
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
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
// --------------------------------------------------------------------
// 
// Copyright (c) 1991 Microsoft Corporation
// 
// Module Name:
// 
//     cmd.c
// 
// Abstract:
// 
// 
// 
// Author:
// 
//     Tom Adams (tomad) 11-May-1991
// 
// Revision History:
// 
//     11-May-1991    tomad
// 
//     Created
// 
// 
//     Sanjeev Katariya (sanjeevk) 4-6-1993
//        Bug# 5203: The routine TpctlCopyAdapterAddress() needed modification to support
//                   the offset introduced by the Media type being returned on an Adapter Open.
//                   This was done in order to be able to correctly set the OID based on the
//                   medium
// 
//        Added support for commands DISABLE, ENABLE, SHELL, RECORDINGENABLE, RECORDINGDISABLE,
//        Tpctl Options w,c and ?, fixed multicast address accounting
// 
//    Tim Wynsma (timothyw)    4-27-94
//        Added performance testing
//                             5-18-94
//        Added setglobal command; cleanup
//                             6-08-94
//        Chgd perf test to client/server model
//
// ---------------------------------------------------------------------

#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>

#include <windows.h>

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "tpctl.h"
#include "parse.h"


extern CMD_CODE CommandCode[] = {

    { CMD_ERR,         "Unknown",                "U"  },
    { VERBOSE,         "Verbose",                "V"  },
    { SETENV,          "SetEnvironment",         "SE" },
    { READSCRIPT,      "ReadScript",             "RS" },
    { BEGINLOGGING,    "BeginLogging",           "BL" },
    { ENDLOGGING,      "EndLogging",             "EL" },
    { WAIT,            "Wait",                   "W"  },
    { GO,              "Go",                     "G"  },
    { PAUSE,           "Pause",                  "P"  },
    { LOAD,            "Load",                   "L"  },
    { UNLOAD,          "Unload",                 "U"  },
    { OPEN,            "Open",                   "O"  },
    { CLOSE,           "Close",                  "C"  },
    { SETPF,           "SetPacketFilter",        "SP" },
    { SETLA,           "SetLookAheadSize",       "LA" },
    { ADDMA,           "AddMulticastAddress",    "AM" },
    { DELMA,           "DeleteMulticastAddress", "DM" },
    { SETFA,           "SetFunctionalAddress",   "SF" },
    { SETGA,           "SetGroupAddress",        "SG" },
    { QUERYINFO,       "QueryInformation",       "QI" },
    { QUERYSTATS,      "QueryStatistics",        "QS" },
    { SETINFO,         "SetInformation",         "SI" },
    { RESET,           "Reset",                  "R"  },
    { SEND,            "Send",                   "S"  },
    { STOPSEND,        "StopSend",               "SS" },
    { WAITSEND,        "WaitSend",               "WT" },
    { RECEIVE,         "Receive",                "RC" },
    { STOPREC,         "StopReceive",            "SR" },
    { GETEVENTS,       "GetEvents",              "GE" },
    { STRESS,          "Stress",                 "ST" },
    { STRESSSERVER,    "StressServer",           "SV" },
    { ENDSTRESS,       "EndStress",              "ES" },
    { WAITSTRESS,      "WaitStress",             "WS" },
    { CHECKSTRESS,     "CheckStress",            "CS" },
    { BREAKPOINT,      "BreakPoint",             "BP" },
    { QUIT,            "Quit",                   "Q"  },
    { HELP,            "Help",                   "H"  },
    { SHELL,           "Shell",                  "SH" },
    { RECORDINGENABLE, "RecordingEnable",        "RE" },
    { RECORDINGDISABLE,"RecordingDisable",       "RD" },
    { DISABLE,         "Disable",                "DI" },
    { ENABLE,          "Enable",                 "EN" },
    { REGISTRY,        "Registry",               "RG" },
    { PERFSERVER,      "PerformServer",          "PS" },
    { PERFCLIENT,      "PerformClient",          "PC" },
    { SETGLOBAL,       "SetGlobalVar",           "SET"}
};


extern BOOL WriteThrough;
extern BOOL ContinueOnError;


DWORD
TpctlParseCommandLine(
    IN WORD argc,
    IN LPSTR argv[]
   )

// -----------------
// 
// Routine Description:
// 
//     This routine parses the command line arguments.  If there is a
//     script file and or log file they are loaded, and will be read from
//     when that test actually starts.  If there is an adapter to be loaded
//     it is written to the global var AdapterName and will be loaded
//     by a later routine.
// 
// Arguments:
// 
//     argc - the number of arguments passed in at startup.
// 
//     argv - the argument vector containing the arguments passed in
//            from the command line.
// 
// Return Value:
// 
//     DWORD - NO_ERROR if all the arguments are valid, and the
//             script and log file are opened and loaded correctly.
//             ERROR_INVALID_PARAMETER otherwise.
// 
// -------------------- 

{
    DWORD   Status;
    CHAR    *TmpArgv[4];
    CHAR    *TmpOptions = "/N";
    INT     i;

    //
    // Parameter validations
    //
    if ( ( argc < 1 ) || ( argc > 4 ) ) 
    {
        TpctlErrorLog("\n\tTpctl: Invalid Command Line Argument(s).\n",NULL);
        TpctlUsage();
        return ERROR_INVALID_PARAMETER;
    }

    //
    // Read the command line arguments into the global command buffer.
    // We are going to temporarily "fake" that we are reading commands
    // from a script so the parse agruments routine will not prompt
    // the user for any additional info if all the arguments are not
    // given.  This will be disabled immediately following the call.
    //

    ScriptIndex++;

    //
    // This is very specific to this routine. The current method of parsing
    // does not lead itself well to optionals
    //
    TmpArgv[0] = TmpArgv[1] = TmpArgv[2] = TmpArgv[3] = NULL;
    for( i = 0; i < argc; i++ ) 
    {
        TmpArgv[i] = argv[i];
    }

    if ( ( argc >= 2 ) && ( argv[1][0] != '/' ) ) 
    {
        if ( argc == 4 ) 
        {
            TpctlErrorLog("\n\tTpctl: Invalid Command Line Argument(s).\n",NULL);
            TpctlUsage();
            return ERROR_INVALID_PARAMETER;
        }

        //
        // We now shift things around. At this point we now that argc must be three
        //
        argc++;
        TmpArgv[1] = TmpOptions;
        TmpArgv[2] = argv[1];
        TmpArgv[3] = argv[2];

    } 
    else 
    {
        if ( (argc >=2 ) && (argv[1][0] == '/') && 
             (strlen( argv[1] ) > (TPCTL_OPTION_SIZE-1)) ) 
        {
            TpctlErrorLog("\n\tTpctl: Invalid Command Line Argument(s).\n",NULL);
            TpctlUsage();
            return ERROR_INVALID_PARAMETER;
        }

    }

    if ( TpctlParseArguments(   CommandLineOptions,
                                Num_CommandLine_Params,
                                argc,
                                TmpArgv ) == -1 ) 
    {
        TpctlErrorLog("\n\tTpctl: Invalid Command Line Argument(s)\n",NULL);
        TpctlUsage();
        ScriptIndex--;
        return ERROR_INVALID_PARAMETER;
    }

    ScriptIndex--;

    //
    // Check the options
    //

    _strupr( GlobalCmdArgs.TpctlOptions );

    if ( strchr( GlobalCmdArgs.TpctlOptions, '?' ) != NULL ) 
    {
        TpctlUsage();
        return ERROR_INVALID_PARAMETER;
    }

    if ( strchr( GlobalCmdArgs.TpctlOptions, 'W' ) != NULL ) 
    {
        WriteThrough = FALSE;
    }

    if ( strchr( GlobalCmdArgs.TpctlOptions, 'C' ) != NULL ) 
    {
        ContinueOnError = TRUE;
    }


    //
    // If there is a script file to be opened.
    //

    if ( GlobalCmdArgs.ARGS.FILES.ScriptFile[0] != '\0' ) 
    {
        //
        // Then open it and the log file if it exists.
        //

        Status = TpctlLoadFiles(    GlobalCmdArgs.ARGS.FILES.ScriptFile,
                                    GlobalCmdArgs.ARGS.FILES.LogFile );

        if ( Status != NO_ERROR ) 
        {
            TpctlUsage();
            return Status;
        }

    //
    // Otherwise if there is only a logfile name with no script file
    // name print the usage message and return an error.
    //

    } 
    else if ( GlobalCmdArgs.ARGS.FILES.LogFile[0] != '\0' ) 
    {
        TpctlErrorLog("\n\tTpctl: Invalid Command Line Argument(s).\n",NULL);
        TpctlUsage();
        return ERROR_INVALID_PARAMETER;
    }

    return NO_ERROR;
}



VOID
TpctlUsage (
    VOID
    )

// ------------------
// 
// Routine Description:
// 
//     This routine prints out a usage statement.
// 
// Arguments:
// 
//     None
// 
// Return Value:
// 
//     None.
// 
// -- -------------

{
    printf("\n\tUSAGE: TPCTL [/[?|W|C]] [SCRIPT_FILE_NAME [LOG_FILE_NAME]]\n\n");

    printf("\tWhere:\n\n");

    printf("\tSCRIPT_FILE_NAME - is an OPTIONAL script file containing test\n");
    printf("\t                   commands.\n\n");

    printf("\tLOG_FILE_NAME    - is an OPTIONAL log file for logging test results.\n");
    printf("\t                   Defaults to TESTPROT.LOG.  A SCRIPT_FILE_NAME must\n");
    printf("\t                   precede a LOG_FILE_NAME.\n\n");

    printf("\tOPTIONS:\n\n");
    printf("\t  W              - Disables write through which speeds up TPCTL as\n");
    printf("\t                   writes to the log files are now cached. Note that\n");
    printf("\t                   this exposes the risk of the log file not being\n");
    printf("\t                   updated should the system crash during a test.\n");
    printf("\t                   WRITE_THROUGH is enabled by default.\n\n");

    printf("\t  C              - Enables TPCTL to continue on errors encountered during\n");
    printf("\t                   script testing. TPCTL will stop script processing on\n");
    printf("\t                   script errors by default.\n\n");

    printf("\t  ?              - Access command online help.\n\n");

}




VOID
TpctlHelp(
    LPSTR Command
    )

// ------------------
// 
// Routine Description:
// 
//     This routine prints out help statements for each of the supported
//     commands.
// 
// Arguments:
// 
//     Command - The command to give the help information for.  If no command
//               is given then a list of all the commands that are supported
//               will be printed.
// 
// Return Value:
// 
//     None.
// 
// -----------------

{
    DWORD CmdCode;

    if ( GlobalCmdArgs.ARGS.CmdName[0] == '\0' ) 
    {
        CmdCode = HELP;
    } 
    else 
    {
        CmdCode = TpctlGetCommandCode( Command );
    }

    printf("\n\tThe syntax of this command is:\n\n");

    switch ( CmdCode ) 
    {
        case HELP:
            printf("\tHELP [command]\n\n");
            printf("\tHelp is available on the following FUNCTIONAL commands:\n\n");
            printf("\t  (AM) AddMulticastAddress         (C) Close\n");
            printf("\t  (DM) DeleteMulticastAddress     (GE) GetEvents\n");
            printf("\t   (O) Open                       (QI) QueryInformation\n");
            printf("\t  (QS) QueryStatistics            (RC) Receive\n");
            printf("\t   (R) Reset                       (S) Send\n");
            printf("\t  (SF) SetFunctionalAddress       (SG) SetGroupAddress\n");
            printf("\t  (SI) SetInformation             (LA) SetLookAheadSize\n");
            printf("\t  (SP) SetPacketFilter            (SR) StopReceive\n");
            printf("\t  (SS) StopSend                   (WT) WaitSend\n\n");
            printf("\tHelp is available on the following STRESS commands:\n\n");
            printf("\t  (CS) CheckStress                (ES) EndStress\n");
            printf("\t  (ST) Stress                     (SV) StressServer\n");
            printf("\t  (WS) WaitStress\n\n");
            printf("\tHelp is available on the following test control commands:\n\n");
            printf("\t  (BL) BeginLogging               (BP) BreakPoint\n");
            printf("\t  (EL) EndLogging                  (G) Go\n");
            printf("\t   (H) Help                        (P) Pause\n");
            printf("\t   (Q) Quit                       (RS) ReadScript\n");
            printf("\t  (SE) SetEnvirnoment              (V) Verbose\n");
            printf("\t   (W) Wait                       (RE) RecordingEnable\n");
            printf("\t  (RD) RecordingDisable           (SH) CommandShell\n");
            printf("\t  (DI) Disable                    (EN) Enable\n");
            printf("\t  (RG) Registry\n\n");
            printf("\tThe command may be entered in either the short form or\n");
            printf("\tthe long form.  The short form is described by the letter\n");
            printf("\tor letters in the parentheses, while the long form is the\n");
            printf("\tword or phrase following.\n\n");
            break;

        case VERBOSE:
            printf("\tVERBOSE\n\n");
            printf("\tVerbose enables and disables the output of each command and its\n");
            printf("\tresults to the screen.  Errors will be printed to the screen\n");
            printf("\tregardless of the state of the Verbose flag.\n\n");
            printf("\t\"V\" - the short form of the command.\n");
            break;

        case SETENV:
            printf("\tSETENVIRONMENT [Open_Instance] [Environment_Variable]\n\n");
            printf("\tSetEnvironment allows the user to customize environment\n");
            printf("\tvariables that effect the running of tests.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to set the environment variable\n");
            printf("\t                on.  The default value is 1.\n\n");
            printf("\tEnvironment_Variable - the variable(s) to set for a given call.\n\n");
            printf("\t                       All variables are set back to their defaults\n");
            printf("\t                       on each call unless otherwise specified.\n\n");
            printf("\tEnvironment Variable values that may be set are:\n\n");
            printf("\tWindowSize - the number of packets in the windows buffer of the\n");
            printf("\t             windowing algorithm.  The default is 10 packets.\n\n");
            printf("\tRandomBuffer - the maximum value passed to the rand routine to\n");
            printf("\t               determine the number of buffers in RAND_MAKEUP packets.\n");
            printf("\t               The default value is 5 which generates an average\n");
            printf("\t               buffer size of 1/5 of the packet size.\n\n");
            printf("\tStressAddress - the multicast or functional address that will be\n");
            printf("\t                used to initialize a stress test.  All machines in\n");
            printf("\t                a given stress test must use the same StressAddress.\n\n");
            printf("\tStressDelay - the standard number of seconds to delay ecah loopp\n");
            printf("\t              through a stress test.  The default is 1/1000 seconds.\n\n");
            printf("\tUpForAirDelay - the number of seconds to delay on the loop through\n");
            printf("\t                a stress test after DelayInterval iterations have\n");
            printf("\t                occurred.  The default is 1/100 seconds.\n");
            printf("\tDelayInterval - the number of StressDelays between each UpForAirDelay\n");
            printf("\t                during a stress test.  The default is 10 iterations.\n\n");
            printf("\t\"SE\" - the short form of the command.\n");
            break;

        case READSCRIPT:
            printf("\tREADSCRIPT [Script_File] [Log_File]\n\n");
            printf("\tReadScript reads test commands from a script file, executes\n");
            printf("\tthe commands and logs the results of the command to a log file.\n\n");
            printf("\tScript_File - the name of the file containing the test\n");
            printf("\t              commands to execute.  The default script file name is\n");
            printf("\t              \"TESTPROT.TPS\".\n\n");
            printf("\tLog_File - the name of the file to log commands and results to.  If\n");
            printf("\t           this file exists, it will be overwritten.  The default\n");
            printf("\t           log file name is \"TESTPROT.LOG\".\n\n");
            printf("\t\"RS\" - the short form of the command.\n");
            break;

        case BEGINLOGGING:
            printf("\tBEGINLOGGING [Log_File]\n\n");
            printf("\tBeginLogging enables the logging of commands and their results.\n");
            printf("\tOnce logging is started any commands entered from the command line\n");
            printf("\tare written to the Log_File.  If commands are being read from\n");
            printf("\ta script this function is disabled. (see also ENDLOGGING)\n\n");
            printf("\tLog_File - the name of the file to log the commands and results to.\n");
            printf("\t           If this file exists, it will be overwritten.  The default\n");
            printf("\t           log file name is \"CMDLINE.LOG\".\n\n");
            printf("\t\"BL\" - the short form of the command.\n");
            break;

        case ENDLOGGING:
            printf("\tENDLOGGING\n\n");
            printf("\tEndLogging disables the logging of commands and their results.\n");
            printf("\t(see also BEGINLOGGING)\n\n");
            printf("\t\"EL\" - the short form of the command.\n");
            break;

        case RECORDINGENABLE:
            printf("\tRECORDINGENABLE [ScriptFile]\n\n");
            printf("\tRecordingEnable enables the recording of commands.\n");
            printf("\tOnce recording is started any commands entered from the command line\n");
            printf("\tare written to the ScriptFile.  If commands are being read from\n");
            printf("\ta script this function is disabled. (see also RECORDINGDISABLE)\n\n");
            printf("\tScriptFile - the name of the file to record the commands and results to.\n");
            printf("\t             If this file exists, it will be overwritten.  The default\n");
            printf("\t             script file name is \"CMDLINE.TPS\".\n\n");
            printf("\t\"RE\" - the short form of the command.\n");
            break;

        case RECORDINGDISABLE:
            printf("\tRECORDINGDISABLE\n\n");
            printf("\tRecordingDisable disables the recording of commands.\n");
            printf("\t(see also RECORDINGENABLE)\n\n");
            printf("\t\"RD\" - the short form of the command.\n");
            break;

        case SHELL:
            printf("\tSHELL [Argument_1 Argument2 ... Argument_N]\n\n");
            printf("\tSHELL will from spawn a command shell from within TPCTL or execute\n");
            printf("\tthe command arguments Argument_1 through Argument_N and return back\n");
            printf("\tto the TPCTL command prompt. If using SHELL by itself, to return to\n");
            printf("\tthe TPCTL prompt simply EXIT the command shell.\n\n");
            printf("\t\"SH\" - the short form of the command.\n");
            break;


        case WAIT:
            printf("\tWAIT [Wait_Time]\n\n");
            printf("\tWait allows a script file to wait a given number of seconds prior\n");
            printf("\tto continuing with the next command.\n\n");
            printf("\tWait_Time - the time in seconds the call will wait before\n");
            printf("\t            returning control to command processing.\n\n");
            printf("\t\"W\" - the short form of the command.\n");
            break;

        case GO:
            printf("\tGO [Open_Instance] [Remote_Address] [Test_Signature]\n\n");
            printf("\tGo sends a TP_GO packet to the Remote Address signalling\n");
            printf("\ta Paused instance of the driver to continue processing its\n");
            printf("\ttest script.  Go continuously resends the packet, and will\n");
            printf("\twait, retrying, until it is acknowledged or stopped with\n");
            printf("\t<Ctrl-C>. (see also PAUSE)\n\n");
            printf("\tOpen_Instance - the open instance between the test driver and\n");
            printf("\t                the MAC adapter that will send the TP_GO Packet.\n");
            printf("\t                The default value is 1.\n\n");
            printf("\tRemote_Address - the address of a remote machine to send the TP_GO\n");
            printf("\t                 packet to.\n\n");
            printf("\tTest_Signature - a unique test signature used by both machines to\n");
            printf("\t                 determine if the correct packets have been sent and\n");
            printf("\t                 acknowledged.  This value must match the Test\n");
            printf("\t                 Signature value on the PAUSED machine.\n\n");
            printf("\t\"G\" - the short form of the command.\n");
            break;

        case PAUSE:
            printf("\tPAUSE [Open_Instance] [Remote_Address] [Test_Signature]\n\n");
            printf("\tPause waits for the receipt of a TP_GO packet wit ha matching test\n");
            printf("\tsignature and then acknowledges it6 by sending a TP_GO_ACKL packet.\n");
            printf("\tPause will wait for the receipt of the TP_GO packlet until it arrives,\n");
            printf("\tor the command is cancelled by <Ctrl-c>.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver and\n");
            printf("\t                the MAC adapter that will wait for the TP_GO Packet.\n");
            printf("\t                The default value is 1.\n\n");
            printf("\tRemote_Address - the address of a remote machine to send the TP_GO_ACK\n");
            printf("\t                 packet to.\n\n");
            printf("\tTest_Signature - a unique test signature used by both machines to\n");
            printf("\t                 determine if the correct packets have been sent and\n");
            printf("\t                 acknowledged.  This value must match the Test\n");
            printf("\t                 Signature value on the machine sending the TP_GO\n");
            printf("\t                 packet\n\n");
            printf("\t\"P\" - the short form of the command.\n");
            break;

        case LOAD:
            printf("\tLOAD [MAC_Driver_Name]\n\n");
            printf("\tLoad issues a call to NtLoadDriver to unload the driver for\n");
            printf("\tthe MAC adapter \"Adapter_Name\".\n\n");
            printf("\tMAC_Driver_Name - the MAC adapter to be loaded. There is no default\n");
            printf("\t                  value.\n\n");
            printf("\t\"L\" - the short form of the command.\n");
            break;

        case UNLOAD:
            printf("\tUNLOAD [MAC_Driver_Name]\n\n");
            printf("\tUnload issues a call to NtUnloadDriver to unload the driver for\n");
            printf("\tthe MAC adapter \"Adapter_Name\".\n\n");
            printf("\tMAC_Driver_Name - the MAC adapter to be unloaded. There is no default\n");
            printf("\t                  value.\n\n");
            printf("\t\"U\" - the short form of the command.\n");
            break;

        case OPEN:
            printf("\tOPEN [Open_Instance] [Adapter_Name]\n\n");
            printf("\tOpen issues a call to NdisOpenAdapter to open the MAC adapter\n");
            printf("\tAdapter_Name, and associates it with the given Open_Instance.\n");
            printf("\tSubsequent calls to the Open_Instance will be directed to\n");
            printf("\tthis adapter.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter this open will be associated\n");
            printf("\t                with.  The default value is 1.\n\n");
            printf("\tAdapter_Name - the MAC adapter to be unloaded. There is no default\n");
            printf("\t               value.\n\n");
            printf("\t\"O\" - the short form of the command.\n");
            break;

        case CLOSE:
            printf("\tCLOSE [Open_Instance]\n\n");
            printf("\tClose issues a call to NdisCloseAdapter to close the MAC adapter\n");
            printf("\tassociated with the given Open_Instance.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to be closed.  The default\n");
            printf("\t                value is 1.\n\n");
            printf("\t\"C\" - the short form of the command.\n");
            break;

        case SETPF:
            printf("\tSETPACKETFILTER [Open_Instance] [Packet_Filter]\n\n");
            printf("\tSetPacketFilter issues a call to the MAC using NdisRequest\n");
            printf("\tto set the card's packet filter to a given value.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to issue the request to.  The\n");
            printf("\t                default value is 1.\n\n");
            printf("\tPacket_Filter - the packet filter value to set on the MAC adapter.\n");
            printf("\t                Multiple filter values may be entered by seperating\n");
            printf("\t                each with the \"|\" character.  Valid values for\n");
            printf("\t                Packet_Filter are:\n\n");
            printf("\t                  Directed\n");
            printf("\t                  Multicast\n");
            printf("\t                  AllMulticast\n");
            printf("\t                  Broadcast\n");
            printf("\t                  SourceRouting\n");
            printf("\t                  Promiscuous\n");
            printf("\t                  Mac_Frame\n");
            printf("\t                  Functional\n");
            printf("\t                  AllFunctional\n");
            printf("\t                  Group\n");
            printf("\t                  None\n\n");
            printf("\t                The default value is \"Directed\".\n\n");
            printf("\t\"SP\" - the short form of the command.\n");
            break;

        case SETLA:
            printf("\tSETLOOKAHEADSIZE [Open_Instance] [LookAhead_Size]\n\n");
            printf("\tSetLookAheadSize issues a call to the MAC using NdisRequest\n");
            printf("\tto set the card's lookahead buffer to a given size.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to issue the request to.  The\n");
            printf("\t                default value is 1.\n\n");
            printf("\tLookAhead_Size - the new size of the card's lookahead buffer.  The\n");
            printf("\t                 default value is 100 bytes.\n\n");
            printf("\t\"LA\" - the short form of the command.\n");
            break;

        case ADDMA:
            printf("\tADDMULTICASTADDRESS [Open_Instance] [Multicast_Address]\n\n");
            printf("\tAddMulticastAddress issues a call to the MAC using NdisRequest\n");
            printf("\tto add a multicast address to the list of multicast addresses\n");
            printf("\tcurrently set on the card.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to issue the request to.  The\n");
            printf("\t                default value is 1.\n\n");
            printf("\tMulticast_Address - the multicast address to add to the list.\n\n");
            printf("\t\"AM\" - the short form of the command.\n");
            break;

        case DELMA:
            printf("\tDELETEMULTICASTADDRESS [Open_Instance] [Multicast_Address]\n\n");
            printf("\tDeleteMulticastAddress issues a call to the MAC using NdisRequest\n");
            printf("\tto delete a multicast address from the list of multicast\n");
            printf("\taddresses currently set on the card.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to issue the request to.  The\n");
            printf("\t                default value is 1.\n\n");
            printf("\tMulticast_Address - the multicast address to delete from the list.\n\n");
            printf("\t\"DM\" - the short form of the command.\n");
            break;

        case SETFA:
            printf("\tSETFUNCTIONALADDRESS [Open_Instance] [Functional_Address]\n\n");
            printf("\tSetFunctionalAddress issues a call to the MAC using NdisRequest\n");
            printf("\tto set a functional address on the card.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to issue the request to.  The\n");
            printf("\t                default value is 1.\n\n");
            printf("\tFunctional_Address - the functional address to set on the card.\n\n");
            printf("\t\"SF\" - the short form of the command.\n");
            break;

        case SETGA:
            printf("\tSETGROUPADDRESS [Open_Instance] [Group_Address]\n\n");
            printf("\tSetGroupAddress issues a call to the MAC using NdisRequest\n");
            printf("\tto set a group address on the card.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to issue the request to.  The\n");
            printf("\t                default value is 1.\n\n");
            printf("\tGroup_Address - the group address to set on the card.\n\n");
            printf("\t\"SG\" - the short form of the command.\n");
            break;

        case QUERYINFO:
            printf("\tQUERYINFORMATION [Open_Instance] [OID_Request]\n\n");
            printf("\tQueryInformation issues a call to the MAC using NdisRequest\n");
            printf("\tto query a given class of information from the MAC.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to issue the request to.  The\n");
            printf("\t                default value is 1.\n\n");
            printf("\tOID_Request - the information type to query.  The default value\n");
            printf("\t              is \"SupportedOidList\".\n");
            printf("\t\"QI\" - the short form of the command.\n");
            break;

        case QUERYSTATS:
            printf("\tQUERYSTATISTICS [Device_Name] [OID_Request]\n\n");
            printf("\tDevice_Name - the name of the device to issue the request\n");
            printf("\t              to.  There is no default value.\n\n");
            printf("\tOID_Request - the statistics type to query.  The default value\n");
            printf("\t              is \"SupportedOidList\".\n");
            printf("\t\"QS\" - the short form of the command.\n");
            break;

        case SETINFO:
            printf("\tSETINFORMATION [Open_Instance] [OID_Request] [Type_Specific]\n\n");
            printf("\tSetInformation issues a call to the MAC using NdisRequest\n");
            printf("\tto set a given class of information in the MAC.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to issue the request to.  The\n");
            printf("\t                default value is 1.\n\n");
            printf("\tOID_Request - the information type to set.  Valid values for\n");
            printf("\t              OID_Request are:\n\n");
            printf("\t                      CurrentPacketFilter\n");
            printf("\t                      CurrentLookAhead\n");
            printf("\t                      CurrentMulticastList\n");
            printf("\t                      CurrentFunctionalAddress\n");
            printf("\t                      CurrentGroupAddress\n");
            printf("\t              The default value is \"CurrentPacketFilter\".\n");
            printf("\tType_Specific - the information to set for a given OID_Request\n");
            printf("\t\"SI\" - the short form of the command.\n");
            break;

        case RESET:
            printf("\tRESET [Open_Instance]\n\n");
            printf("\tReset issues a call to the MAC using NdisReset to reset the MAC.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to issue the request to.  The\n");
            printf("\t                default value is 1.\n\n");
            printf("\t\"R\" - the short form of the command.\n");
            break;

        case SEND:
            printf("\tSEND [Open_Instance] [Destination_Address] [Packet_Size] [Number]\n");
            printf("\t     [Resend_Address]\n\n");
            printf("\tSend issues a call to the MAC using NdisSend to send packets on the\n");
            printf("\tnetwork.  Sending more then one packet causes the command to return\n");
            printf("\tasynchronously.  If a Resend_Address argument is specified, then\n");
            printf("\teach packet sent will contain a \"resend\" packet in the data field\n");
            printf("\tthat is extracted from the packet by any receiving test and\n");
            printf("\tresent to the address specified. (see also RECEIVE, STOPSEND and\n");
            printf("\tWAITSEND)\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to issue the request(s) to.  The\n");
            printf("\t                default value is 1.\n\n");
            printf("\tDestination_Address - the network address the packet(s) will be sent\n");
            printf("\t                      to.\n\n");
            printf("\tPacket_Size - the size of the packet(s) to send.\n\n");
            printf("\tNumber - the number of packets to send.  A value of \"-1\" will\n");
            printf("\t         cause the test to send packets continuously until\n");
            printf("\t         stopped by a call to STOPSEND.\n\n");
            printf("\tResend_Address - OPTIONAL: the address that will be placed in the\n");
            printf("\t                 destination address of the \"resend\" packet.\n\n");
            printf("\t\"S\" - the short form of the command.\n");
            break;

        case STOPSEND:
            printf("\tSTOPSEND [Open_Instance]\n\n");
            printf("\tStopSend stops a previously started SEND command if it is still\n");
            printf("\trunning, and prints the SEND command's results.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to stop the SEND command on.\n");
            printf("\t                The default value is 1.\n\n");
            printf("\t\"SS\" - the short form of the command.\n");
            break;

        case WAITSEND:
            printf("\tWAITSEND [Open_Instance]\n\n");
            printf("\tWaitSend waits for a send test to end, and then displays the\n");
            printf("\tsend test results.  This command may be cancelled by entering\n");
            printf("\tCtrl-C.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to wait for the send test to\n");
            printf("\t                end on.  The default value is 1.\n\n");
            printf("\t\"WT\" - the short form of the command.\n");
            break;

        case RECEIVE:
            printf("\tRECEIVE [Open_Instance]\n\n");
            printf("\tReceive sets the test up in a mode to \"expect\" to receive\n");
            printf("\tpackets from other tests.  Each packet will be inspected, and\n");
            printf("\tcounted.  If a test packet received contains a \"resend\"\n");
            printf("\tpacket, the \"resend\" packet will be extracted from the packet,\n");
            printf("\tand sent to the address contained within. (see also SEND and STOPRECEIVE)\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to set up to expect packets.\n");
            printf("\t                The default value is 1.\n\n");
            printf("\t\"RC\" - the short form of the command.\n");
            break;

        case STOPREC:
            printf("\tSTOPRECEIVE [Open_Instance]\n\n");
            printf("\tStopReceive resets a test which has previously had a\n");
            printf("\tRECEIVE commmand issued to it, to no longer \"expect\" packets.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to reset.  The default value\n");
            printf("\t                is 1.\n\n");
            printf("\t\"SR\" - the short form of the command.\n");
            break;

        case GETEVENTS:
            printf("\tGETEVENTS [Open_Instance]\n\n");
            printf("\tGetEvents queries the test for information about \"unexpected\"\n");
            printf("\tindications and completions.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to query the events from.  The\n");
            printf("\t                default value is 1.\n\n");
            printf("\t\"GE\" - the short form of the command.\n");
            break;

        case STRESS:
            printf("\tSTRESS [Open_Instance] [Member_Type] [Packets] [Iterations]\n");
            printf("\t       [Packet_Type] [Packet_Size] [Packet_MakeUp] [Response_Type]\n");
            printf("\t       [Delay_Type] [Delay_Length] [Windowing] [Data_Checking]\n");
            printf("\t       [PacketsFromPool]\n\n");
            printf("\tStress sets the test up to run a stress test.  If the test\n");
            printf("\tis started successfully the command will complete asynchronously.\n");
            printf("\tThe test will run until finished or until stopped manually.  (see also\n");
            printf("\tENDSTRESS, STOPSTRESS, WAITSTRESS, and CHECKSTRESS)\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to start a stress test on.  The\n");
            printf("\t                default value is 1.\n\n");
            printf("\tMember_Type - how the protocol will perform in the stress test; as\n");
            printf("\t              a client (CLIENT) or as a client and server (BOTH).\n");
            printf("\t              The default value is BOTH.\n\n");
            printf("\tPackets - the number of packets that will be sent to each server prior\n");
            printf("\t          to the test completing.  A value of -1 causes the test to\n");
            printf("\t          run forever unless a value is entered for Iterations.  The\n");
            printf("\t          default value for packets is -1.\n\n");
            printf("\tIterations - the number of iterations this test will run.  A value\n");
            printf("\t             of -1 causes the test to run forever unless a value is\n");
            printf("\t             entered for Packet.  The default value for Iterations\n");
            printf("\t             is -1.\n\n");
            printf("\tPacket_Type - the type of packet size algorithm used to create the\n");
            printf("\t              packets for the test; FIXEDSIZE, RANDOMSIZE or CYCLICAL.\n");
            printf("\t              The default type is FIXED.\n\n");
            printf("\tPacket_Size - with the Packet_Type value determines the size of packets\n");
            printf("\t              in the test.  The default is 512 bytes.\n\n");
            printf("\tPacket_MakeUp - the number and size of the buffers that makeup each\n");
            printf("\t                packet; RAND, SMALL, ZEROS, ONES and KNOWN.  The\n");
            printf("\t                default makeup is RAND.\n\n");
            printf("\tResponse_Type - the method the server will use when responding to test\n");
            printf("\t                packets; NO_RESPONSE, FULL_RESPONSE, ACK_EVERY,\n");
            printf("\t                or ACK_10_TIMES.  The default value is FULL_RESPONSE.\n\n");
            printf("\tDelay_Type - the method used to determine the next interpacket\n");
            printf("\t             delay; FIXEDDELAY or RANDOMDELAY.  The default value\n");
            printf("\t             is FIXEDDELAY.\n\n");
            printf("\tDelay_Length - the minimum number of iterations between two\n");
            printf("\t               consecutive sends to the same server in a test.\n");
            printf("\t               The default value is 0 iterations.\n\n");
            printf("\tWindowing - a boolean used to determine whether a simple windowing\n");
            printf("\t            algorithm will be used between the client and each server.\n");
            printf("\t            the default value is TRUE.\n\n");
            printf("\tData_Checking - a boolean used to determine whether data checking\n");
            printf("\t                will be performed on each packet received.  The\n");
            printf("\t                default value is TRUE.\n\n");
            printf("\tPacketsFromPool - a boolean used to determine whether a pool of\n");
            printf("\t                  packets will be created prior to the test.  The\n");
            printf("\t                  default value is TRUE.\n\n");
            printf("\t\"ST\" - the short form of the command.\n");
            break;

        case STRESSSERVER:
            printf("\tSTRESSSERVER [Open_Instance]\n\n");
            printf("\tStressServer sets the test up to participate in a stress\n");
            printf("\ttest as a server receiving and responding to stress packets from\n");
            printf("\tany clients running a stress test.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to start a stress server on.  The\n");
            printf("\t                default value is 1.\n\n");
            printf("\t\"SV\" - the short form of the command.\n");
            break;

        case ENDSTRESS:
            printf("\tENDSTRESS [Open_Instance]\n\n");
            printf("\tEndStress issues a command to the test to stop a currently\n");
            printf("\trunning stress test, whether the protocol is acting as a client or\n");
            printf("\tserver.  If the protocol is acting as a client, once the test has\n");
            printf("\tended, the result will be displayed.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to end the stress test on.  The\n");
            printf("\t                default value is 1.\n\n");
            printf("\t\"ES\" - the short form of the command.\n");
            break;

        case WAITSTRESS:
            printf("\tWAITSTRESS [Open_Instance]\n\n");
            printf("\tWaitStress waits for a stress test to end, and then displays the\n");
            printf("\tstress test results.  This command may be cancelled by entering\n");
            printf("\tCtrl-C.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to wait for the stress test to\n");
            printf("\t                end on.  The default value is 1.\n\n");
            printf("\t\"WS\" - the short form of the command.\n");
            break;

        case CHECKSTRESS:
            printf("\tCHECKSTRESS [Open_Instance]\n\n");
            printf("\tCheckStress checks to see if a stress test has ended, and if so\n");
            printf("\tdisplays the stress test results.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver\n");
            printf("\t                and the MAC adapter to check for the results of a\n");
            printf("\t                stress test on.  The default value is 1.\n\n");
            printf("\t\"CS\" - the short form of the command.\n");
            break;

        case BREAKPOINT:
            printf("\tBREAKPOINT\n\n");
            printf("\tBreakPoint causes an interrupt to break into the debugger.\n\n");
            printf("\t\"BP\" - the short form of the command.\n");
            break;

        case QUIT:
            printf("\tQUIT\n\n");
            printf("\tQuit exits the control application.  Any tests currently\n");
            printf("\trunning are stopped and any opens to MACs are subsequently\n");
            printf("\tclosed.\n\n");
            printf("\t\"Q\" - the short form of the command.\n");
            break;

        case DISABLE:
            printf("\tDISABLE [ENV_VAR_1] [ENV_VAR_2]...[ENV_VAR_N]\n\n");
            printf("\tDisable will prevent the test tool from executing any commands\n");
            printf("\tfollowing it UNLESS all the environment variables passed to it have\n");
            printf("\tbeen declared OR if it encounters the special command ENABLE.\n");
            printf("\tIn that event that all environments variables are set and passed as\n");
            printf("\targuments to DISABLE, the command is ignored and TPCTL remains\n");
            printf("\tactive. Disable by itself will also disable the tool\n\n");
            printf("\t\"DI\" - the short form of the command.\n");
            break;

        case ENABLE:
            printf("\tENABLE\n\n");
            printf("\tEnable will enable the tool to accept commands\n\n");
            printf("\t\"EN\" - the short form of the command.\n");
            break;

        case REGISTRY :
            printf("\tREGISTRY [Operation_Type] [Key_DataBase] [SubKey] [SubKey_Class]\n");
            printf("\t         [SubKey_Value_Name] [SubKey_Value_Type] [SubKey_Value]\n\n");
            printf("\tRegistry is responsible for adding, deleting, modifying and querying\n");
            printf("\texisting registry key entries.\n\n");
            printf("\tOperation_Type - The type of operation to be performed on the registry\n");
            printf("\t                 key\n");
            printf("\t                 Types  : ADD_KEY, DELETE_KEY, QUERY_KEY, ADD_VALUE,\n");
            printf("\t                          CHANGE_VALUE, DELETE_VALUE, QUERY_VALUE\n");
            printf("\t                 Default: QUERY_KEY\n\n");
            printf("\tKey_DataBase   - The key database to be interacted with\n");
            printf("\t                 Databases: CLASSES_ROOT, CURRENT_USER, LOCAL_MACHINE,\n");
            printf("\t                            USER\n");
            printf("\t                 Default  : LOCAL_MACHINE\n\n");
            printf("\tSubKey         - The string value(name) of the subkey being interacted\n");
            printf("\t                 with\n");
            printf("\t                 Default:\n");
            printf("\t                \"System\\CurrenControlSet\\Services\\Elnkii01\\Parameters\"\n");
            printf("\t                 NOTE   : String values must be contained within double\n");
            printf("\t                          quotes\n\n");
            printf("\tSubKey_Class   - The string value(class) to be associated with this\n");
            printf("\t                 subkey\n");
            printf("\t                 Default: \"Network Drivers\"\n");
            printf("\t                 NOTE   : String values must be contained within double\n");
            printf("\t                          quotes\n\n");
            printf("\tSubKey_Value_Name - The string value(ValueName) to be associated with\n");
            printf("\t                    this subkey\n");
            printf("\t                    Default: \"NetworkAddress\"\n");
            printf("\t                    NOTE   : String values must be contained within\n");
            printf("\t                             double quotes\n\n");
            printf("\tSubKey_Value_Type - The type of value being provided\n");
            printf("\t                    Types  : BINARY, DWORD_REGULAR,\n");
            printf("\t                             DWORD_LITTLE_ENDIAN, DWORD_BIG_ENDIAN,\n");
            printf("\t                             EXPAND_SZ, LINK, MULTI_SZ, NONE,\n");
            printf("\t                             RESOURCE_LIST, SZ\n");
            printf("\t                    Default: DWORD_REGULAR\n\n");
            printf("\tSubKey_Value   - The provided value to set the sub key to\n");
            printf("\t                 NOTE : Multiple strings must be seperated by\n");
            printf("\t                        commas. Hex values should be preceeded by 0x.\n");
            printf("\t                        Octal values are preceded by 0. Decimal values\n");
            printf("\t                        do not have a leading 0.By default the base\n");
            printf("\t                        radix is 10\n\n");
            printf("\t\"RG\" - the short form of the command.\n");
            break;

        case PERFSERVER:
            printf("\tPERFORMSERVER [Open_Instance] \n\n");
            printf("\tPerfServer starts a server to participate with the specified client in a\n");
            printf("\tperformance test.  This command always returns synchronously.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver and the MAC\n");
            printf("\t                adapter to issue the request to.  Default value is 1.\n\n");
            printf("\t\"PS\" - the short form of the command.\n");
            break;

        case PERFCLIENT:
            printf("\tPERFORMRECEIVE [Open_Instance] [Server_Address] [Send_Address] ");
            printf(" [Packet_Size] [Num_Packets] [Delay] [Mode] \n\n");
            printf("\tPerfClient starts a client to participate with the specified server in a\n");
            printf("\tperformance test.  The specific test is indicated by the mode.\n");
            printf("\tThis command always returns synchronously.\n\n");
            printf("\tOpen_Instance - the open instance between the test driver and the MAC\n");
            printf("\t                adapter to issue the request to.  Default value is 1.\n\n");
            printf("\tServer_Address - the network address of the server card\n\n");
            printf("\tSend_Address - the network address to which the server sends messages.\n\n");
            printf("\tPacket_Size - total size of the test packets to be sent\n\n");
            printf("\tNum_Packets - total number of test packets to be sent\n\n");
            printf("\tDelay - how much to delay between sends\n\n");
            printf("\tMode - which performance test to use:\n");
            printf("\t       0 = client sends to any address (performance send test)\n");
            printf("\t       1 = client sends to server (performance send test)\n");
            printf("\t       2 = client sends to server, with server ACKs\n");
            printf("\t       3 = two-way sends\n");
            printf("\t       4 = server sends to client (performance receive test)\n");
            printf("\t       5 = client sends REQ to server, server responds with sends\n");
            printf("\t       other = shut down server\n\n");
            printf("\t\"PC\" - the short form of the command.\n");
            break;

        default:
            printf("\tHELP [ ADDMULTICASTADDRESS | BEGINLOGGING | BREAKPOINT | CHECKSTRESS |\n");
            printf("\t       CLOSE | DELETEMULTICASTADDRESS  | ENDLOGGING | ENDSTRESS |\n");
            printf("\t       GETEVENTS | GO | HELP | LOAD | OPEN | PAUSE | QUERYINFORMATION |\n");
            printf("\t       QUERYSTATISTICS | QUIT | READSCRIPT | RECEIVE | RESET | SEND |\n");
            printf("\t       SETENVIRONMENT | SETFUNCTIONALADDRESS | SETGROUPADDRESS |\n");
            printf("\t       SETINFORMATION | SETLOOKAHEADSIZE | SETPACKETFILTER |\n");
            printf("\t       STOPRECEIVE | STOPSEND | STRESS | STRESSSERVER | UNLOAD |\n");
            printf("\t       VERBOSE | WAIT | WAITSEND | WAITSTRESS | SHELL |\n");
            printf("\t       RECORDINGENABLE | RECORDINGDISABLE | REGISTRY |\n");
            printf("\t       PERFSERVER | PERFCLIENT\n\n");
            printf("\tThe command \"%s\" is unknown.\n", _strupr( Command ));
            break;

    } // switch()

    printf("\n");
}



DWORD
TpctlLoadFiles(
    LPSTR ScriptFile,
    LPSTR LogFile
    )

// ---------------
// 
// Routine Description:
// 
//     This routine loads a script file into a buffer, and opens a log
//     file for logging commands and results to.
// 
// Arguments:
// 
//     IN LPSTR ScriptFile - the name of the script file to open and read.
//     IN LPSTR LogFile - the name of the log file to open.
// 
// Return Value:
// 
//     DWORD - NO_ERROR if the script and log files are opened and
//             processed correctly, otherwise the error returned on the
//             failure from the win32 api that failed.
// 
//             NOTE: if this routine returns an error, then TpctlUnLoadFiles
//                   MUST be called next to reset the script structures
//                   correctly, and deallocate any resources that were
//                   allocated during this routine.
//
// --------------- 


{
    DWORD NextScriptIndex;
    HANDLE FileHandle;
    DWORD Status;
    DWORD FileSize;

    NextScriptIndex = ScriptIndex+1;

    //
    // First set the lowest level flag(s) in the scripts field to
    // delineate which script is the lowest VALID script and should be
    // unloaded. (necessary in case the next call to load files fails we
    // will know where the high water mark is.)
    //

    if ( ScriptIndex >= 0 ) 
    {
        //
        // if this is the first script we must ignore the reset of the
        // "previous" script.
        //

        Scripts[ScriptIndex].IsLowestLevel = FALSE;
    }

    Scripts[NextScriptIndex].IsLowestLevel = TRUE;

    //
    // We have a script file, so increment the script index, and set the
    // the index into the script buffer to zero.  Make sure that we have
    // not passed the maximum number of recursion in reading scripts.
    //

    if ( NextScriptIndex == TPCTL_MAX_SCRIPT_LEVELS ) 
    {
        TpctlErrorLog("\n\tTpctl: Too many levels of script reading recursion; level 0x%lx\n",
                                    (PVOID)(NextScriptIndex+1));
        return (DWORD)STATUS_UNSUCCESSFUL;
    }

    //
    // First we allocate the memory to store the script file name in.
    //

    Scripts[NextScriptIndex].ScriptFile = GlobalAlloc(  GMEM_FIXED | GMEM_ZEROINIT,
                                                        TPCTL_MAX_PATHNAME_SIZE );

    if ( Scripts[NextScriptIndex].ScriptFile == NULL ) 
    {
        Status = GetLastError();
        TpctlErrorLog("\n\tTpctlLoadFiles: failed to alloc Script file name storage, returned 0x%lx.\n", (PVOID)Status);
        return Status;
    }

    //
    // Then determine what filename to write to it.
    //

    if ( ScriptFile[0] == '\0' ) 
    {
        //
        // If no script file name was passed, then open the default
        // script file TESTPROT.TPS.
        //

        strcpy( Scripts[NextScriptIndex].ScriptFile,TPCTL_SCRIPTFILE );
    } 
    else 
    {
        //
        // Otherwise copy the filename passed into place.
        //

        strcpy( Scripts[NextScriptIndex].ScriptFile,ScriptFile );
    }

    //
    // Open the script file, if it does not exist fail with an error msg.
    //

    FileHandle = CreateFile(Scripts[NextScriptIndex].ScriptFile,
                            GENERIC_READ,
                            FILE_SHARE_READ,
                            NULL,
                            OPEN_EXISTING,
                            FILE_ATTRIBUTE_NORMAL,
                            NULL );

    if ( FileHandle == (HANDLE)-1 ) 
    {
        Status = GetLastError();
        TpctlErrorLog("\n\tTpctl: failed to open script file \"%s\", ",
                        (PVOID)Scripts[NextScriptIndex].ScriptFile);
        TpctlErrorLog("returned 0x%lx.\n",(PVOID)Status);
        return Status;
    }

    //
    // and find its size.
    //

    FileSize = GetFileSize( FileHandle,NULL );

    if ( FileSize == -1 ) 
    {
        Status = GetLastError();
        TpctlErrorLog("\n\tTpctl: failed find file size - returned 0x%lx.\n",
                        (PVOID)Status);
        return Status;
    }

    //
    // If necessary allocate memory for the Buffer.
    //

    if ( Scripts[NextScriptIndex].Buffer == NULL ) 
    {
        Scripts[NextScriptIndex].Buffer = (LPBYTE)GlobalAlloc( GMEM_FIXED | GMEM_ZEROINIT,
                                                               FileSize );

        if ( Scripts[NextScriptIndex].Buffer == NULL ) 
        {
            Status = GetLastError();
            TpctlErrorLog("\n\tTpctlLoadFiles: failed to alloc script buffer, returned 0x%lx.\n",
                                (PVOID)Status);
            CloseHandle( FileHandle );
            return Status;
        }

    } 
    else if ( FileSize > Scripts[NextScriptIndex].Length ) 
    {
        Scripts[NextScriptIndex].Buffer = 
                    (LPBYTE)GlobalReAlloc( (HANDLE)Scripts[NextScriptIndex].Buffer,
                                            FileSize,
                                            GMEM_ZEROINIT | GMEM_MOVEABLE );

        if ( Scripts[NextScriptIndex].Buffer == NULL ) 
        {
            Status = GetLastError();
            TpctlErrorLog("\n\tTpctlLoadFiles: failed to ReAlloc script buffer, returned 0x%lx.\n",
                            (PVOID)Status);
            CloseHandle( FileHandle );
            return Status;
        }
    }

    //
    // And read the script file into it.
    //

    Status = ReadFile(  FileHandle,
                        Scripts[NextScriptIndex].Buffer,
                        FileSize,
                        &Scripts[NextScriptIndex].Length,
                        NULL );

    if ( Status != TRUE ) 
    {
        Status = GetLastError();
        TpctlErrorLog("\n\tTpctlLoadFiles: failed to read script file \"%s\", ",(PVOID)ScriptFile);
        TpctlErrorLog("returned 0x%lx.\n",(PVOID)Status);
        CloseHandle( FileHandle );
        return Status;
    }

    //
    // We are done with script file now, so close it.
    //

    if (!CloseHandle(FileHandle)) 
    {
        Status = GetLastError();
        TpctlErrorLog("\n\tTpctlLoadFiles: failed to close Script file \"%s\", ",(PVOID)ScriptFile);
        TpctlErrorLog("returned 0x%lx.\n",(PVOID)Status);
    }

    //
    // Now handle the log file.  If we are not given a log file we need
    // to determine the name of the log file we should use.
    // First we allocate the memory to store the log file name in.
    //

    Scripts[NextScriptIndex].LogFile = GlobalAlloc( GMEM_FIXED | GMEM_ZEROINIT,
                                                    TPCTL_MAX_PATHNAME_SIZE );

    if ( Scripts[NextScriptIndex].LogFile == NULL ) 
    {
        Status = GetLastError();
        TpctlErrorLog(
                    "\n\tTpctlLoadFiles: failed to alloc Log file name storage, returned 0x%lx.\n",
                        (PVOID)Status);
        return Status;
    }

    //
    // Then determine what filename to write to it.
    //

    if (( LogFile == NULL ) || ( LogFile[0] == '\0' )) 
    {
        if ( NextScriptIndex == 0 ) 
        {
            //
            // If this is the first script file and no log file name was
            // given, then use the default log file name.
            //

            strcpy( Scripts[NextScriptIndex].LogFile,TPCTL_LOGFILE );
        } 
        else 
        {
            //
            // Otherwise, since no new log file name was given, and we are
            // recursively reading script files we will use the log file
            // used by the last level of script files.
            //

            strcpy( Scripts[NextScriptIndex].LogFile,Scripts[ScriptIndex].LogFile );
            Scripts[NextScriptIndex].LogHandle = Scripts[ScriptIndex].LogHandle;
        }

    } 
    else 
    {
        //
        // We have a log file name so copy it into the scripts structure.
        //

        strcpy(Scripts[NextScriptIndex].LogFile,LogFile);
    }

    //
    // Now, if the log file has not already been opened, then we must open
    // it.  If the logfile already exists it WILL be truncated on the open.
    //

    if (( LogFile != NULL ) && ( LogFile[0] != '\0' ) ||
        ( NextScriptIndex == 0 )) 
    {
        if ( WriteThrough ) 
        {
            Scripts[NextScriptIndex].LogHandle =
                                CreateFile( Scripts[NextScriptIndex].LogFile,
                                            GENERIC_WRITE,
                                            FILE_SHARE_WRITE | FILE_SHARE_READ,
                                            NULL,
                                            CREATE_ALWAYS,
                                            FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH,
                                            NULL );
        } 
        else 
        {
            Scripts[NextScriptIndex].LogHandle =
                                CreateFile( Scripts[NextScriptIndex].LogFile,
                                            GENERIC_WRITE,
                                            FILE_SHARE_WRITE | FILE_SHARE_READ,
                                            NULL,
                                            CREATE_ALWAYS,
                                            FILE_ATTRIBUTE_NORMAL,
                                            NULL );
        }

        if ( Scripts[NextScriptIndex].LogHandle == (HANDLE)-1 ) 
        {
            Status = GetLastError();
            TpctlErrorLog("\n\tTpctl: failed to open log file \"%s\", ",
                                        (PVOID)Scripts[NextScriptIndex].LogFile);
            TpctlErrorLog("returned 0x%lx.\n",(PVOID)Status);
            return Status;
        }
    }

    //
    // We have successfully opened the script and log files, and are now
    // ready to read commands from the script buffer, set the flag stating
    // that the commands are coming from the script file, and increment the
    // scriptindex to point to the newly create script info.
    //

    CommandsFromScript = TRUE;

    ScriptIndex = NextScriptIndex;

    return NO_ERROR;
}



VOID
TpctlFreeFileBuffers(
    VOID
    )

// ---------------
// 
// Routine Description:
// 
// Arguments:
// 
//     None.
// 
// Return Value:
// 
//     None.
// 
// --------------

{
    DWORD si = 0;
    HANDLE tmpHandle;
    DWORD Status;

    for (si=0;si<TPCTL_MAX_SCRIPT_LEVELS;si++) 
    {
        if ( Scripts[si].Buffer != NULL ) 
        {
            tmpHandle = GlobalFree( (HANDLE)Scripts[si].Buffer );

            if ( tmpHandle != NULL ) 
            {
                Status = GetLastError();
                TpctlErrorLog("\n\tTpctlFreeFileBuffers: GlobalFree failed: returned 0x%lx.\n",
                    (PVOID)Status);
            }
        }

        Scripts[si].Buffer = NULL;
        Scripts[si].Length = 0;
    }
}



VOID
TpctlUnLoadFiles(
    VOID
    )

// ---------------
// 
// Routine Description:
// 
// Arguments:
// 
//     None.
// 
// Return Value:
// 
//     None.
// 
// --------------

{
    DWORD si;
    HANDLE tmpHandle;
    DWORD Status;

    //
    // TpctlUnloadFiles may be called to unload a file that is no longer
    // needed, or a file that was not successfully loaded by TpctlLoadFiles.
    // If the file to be unloaded is one that failed to load during the load
    // files routine, then the ScriptIndex does not point to the correct
    // field in the script array, so we must adjust the index pointer
    // to the next field, otherwise just unload the file pointed by the
    // ScriptIndex.
    //

    si = ScriptIndex;

    if (( ScriptIndex < 0 ) || ( Scripts[si].IsLowestLevel == FALSE )) 
    {
        si++;
    }

    //
    // Free up the memory used to store the file names, and the
    // script file commands.
    //

    if ( Scripts[si].ScriptFile != NULL ) 
    {
        tmpHandle = GlobalFree( Scripts[si].ScriptFile );

        if ( tmpHandle != NULL ) 
        {
            Status = GetLastError();
            TpctlErrorLog("\n\tTpctlUnLoadFiles: GlobalFree failed: returned 0x%lx.\n",
                                (PVOID)Status);
        }
    }

    if ( Scripts[si].LogFile != NULL ) 
    {
        tmpHandle = GlobalFree( Scripts[si].LogFile );

        if ( tmpHandle != NULL ) 
        {
            Status = GetLastError();
            TpctlErrorLog("\n\tTpctlUnLoadFiles: GlobalFree failed: returned 0x%lx.\n",
                                (PVOID)Status);
        }
    }

    //
    // Do we have a unique log file, or was the log file opened by a higher
    // order recursion of the TpctlLoadFiles routine?
    //

    if (( Scripts[si].LogHandle != (HANDLE)-1 ) &&    // log handle exists
       (( si == 0 ) ||                                // first level of recursion
        ( Scripts[si].LogHandle != Scripts[si-1].LogHandle ))) 
    {

        //
        // This level of the ReadScript command opened the log file, so
        // we must close it now.
        //

        CloseHandle( Scripts[si].LogHandle );
    }

    //
    // Now set all the fields to their intial state.
    //

    Scripts[si].ScriptFile = NULL;
    Scripts[si].BufIndex = 0;
    Scripts[si].LogHandle = (HANDLE)-1;
    Scripts[si].LogFile = NULL;
    Scripts[si].IsLowestLevel = FALSE;

    //
    // If we are simply unloading a script that we are finished with
    // then decrement the index into the Scripts array to reference the
    // next higher level, if it exists, in the ReadScript recursion.
    // If we are unloading the highest level script file then reset
    // the commandsfromscript flag to state that we no longer are
    // reading the commands from a script file.
    //

    if ( si == ScriptIndex ) 
    {
        if ( --ScriptIndex == -1 ) 
        {
            CommandsFromScript = FALSE;
            TpctlFreeFileBuffers();
        }
    }

    if ( si != 0 ) 
    {
        Scripts[si-1].IsLowestLevel = TRUE;
    }
}



HANDLE
TpctlOpenLogFile(
    VOID
    )

// -------------
// 
// Routine Description:
// 
// Arguments:
// 
// Return Value:
// 
// ------------

{
    HANDLE LogHandle;
    DWORD Status;

    if ( WriteThrough ) 
    {
        LogHandle = CreateFile( GlobalCmdArgs.ARGS.FILES.LogFile,
                                GENERIC_WRITE,
                                FILE_SHARE_WRITE | FILE_SHARE_READ,
                                NULL,
                                CREATE_ALWAYS,
                                FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH,
                                NULL );
    } 
    else 
    {
        LogHandle = CreateFile( GlobalCmdArgs.ARGS.FILES.LogFile,
                                GENERIC_WRITE,
                                FILE_SHARE_WRITE | FILE_SHARE_READ,
                                NULL,
                                CREATE_ALWAYS,
                                FILE_ATTRIBUTE_NORMAL,
                                NULL );
    }


    if ( LogHandle == (HANDLE)-1 ) 
    {
        Status = GetLastError();
        TpctlErrorLog("\n\tTpctl: failed to open log file\"%s\", ",
            (PVOID)GlobalCmdArgs.ARGS.FILES.LogFile);
        TpctlErrorLog("returned 0x%lx.\n",(PVOID)Status);
    }

    return LogHandle;
}



VOID
TpctlCloseLogFile(
    VOID
    )

{
    DWORD Status;

    if (!CloseHandle( CommandLineLogHandle )) 
    {
        Status = GetLastError();
        TpctlErrorLog("\n\tTpctlCloseLogFile: failed to close Log file; returned 0x%lx.\n",
                            (PVOID)Status);
    }

    return;
}



HANDLE
TpctlOpenScriptFile(
    VOID
    )

// ----------------
// 
// Routine Description:
// 
//    Created    Sanjeevk  7-1-93
// 
//    This is a new function defined for the purpose of opening up a file
//    to which commands will be written
// 
// Arguments:
// 
//     None
// 
// Global Arguments effected:
// 
//     RecordScriptName
// 
// Return Value:
// 
//     A HANDLE to the script file or NULL
// 
// ---------------

{
    HANDLE ScriptHandle;
    DWORD Status;


    //
    // 1. Clear the global variable and copy in the name of the file
    //    to be opened
    //

    memset( RecordScriptName, 0, (TPCTL_MAX_PATHNAME_SIZE*sizeof(CHAR)) );
    strcpy( RecordScriptName, GlobalCmdArgs.ARGS.RECORD.ScriptFile );

    if ( WriteThrough ) 
    {
        ScriptHandle = CreateFile(  GlobalCmdArgs.ARGS.RECORD.ScriptFile,
                                    GENERIC_WRITE,
                                    FILE_SHARE_WRITE | FILE_SHARE_READ,
                                    NULL,
                                    CREATE_ALWAYS,
                                    FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH,
                                    NULL );
    } 
    else 
    {
        ScriptHandle = CreateFile(  GlobalCmdArgs.ARGS.RECORD.ScriptFile,
                                    GENERIC_WRITE,
                                    FILE_SHARE_WRITE | FILE_SHARE_READ,
                                    NULL,
                                    CREATE_ALWAYS,
                                    FILE_ATTRIBUTE_NORMAL,
                                    NULL );
    }


    if ( ScriptHandle == (HANDLE)-1 ) 
    {
        Status = GetLastError();
        ZeroMemory( RecordScriptName, (TPCTL_MAX_PATHNAME_SIZE*sizeof(CHAR)) );
        TpctlErrorLog("\n\tTpctl: failed to open script recording file\"%s\", ",
            (PVOID)GlobalCmdArgs.ARGS.RECORD.ScriptFile);
        TpctlErrorLog("returned 0x%lx.\n",(PVOID)Status);
    }

    return ScriptHandle;
}



VOID
TpctlCloseScriptFile(
    VOID
    )

// ---------------
// 
// Routine Description:
// 
//    Created    Sanjeevk  7-1-93
// 
//    This is a new function defined for the purpose of closing a file
//    to which commands were being written
// 
// Arguments:
// 
//     None
// 
// Global Arguments effected:
// 
//     RecordScriptName
//     ScriptRecordHandle
// 
// Return Value:
// 
//     None
// 
// --------------- 

{
    DWORD Status;

    ZeroMemory( RecordScriptName, (TPCTL_MAX_PATHNAME_SIZE*sizeof(CHAR)) );

    if (!CloseHandle( ScriptRecordHandle )) 
    {
        Status = GetLastError();
        TpctlErrorLog(
                "\n\tTpctlCloseScriptFile: failed to close script record file; returned 0x%lx.\n",
                        (PVOID)Status);
    }

    return;
}




DWORD
TpctlReadCommand(
    IN LPSTR Prompt,
    OUT LPSTR Buffer,
    IN DWORD MaximumResponse
    )

// --------------
// 
// Routine Description:
// 
//     This routine reads from the debug port or the command file one command.
// 
// Arguments:
// 
//     IN LPSTR Prompt,
//     OUT LPSTR Buffer,
//     IN DWORD MaximumResponse,
// 
// Return Value:
// 
//     DWORD - NO_ERROR
// 
// -------------

{
    DWORD Status = NO_ERROR;
    LPSTR CmdBufPtr = Buffer;
    DWORD i, j, k;
    BYTE LineBuf[TPCTL_CMDLINE_SIZE];
    BYTE TmpBuf[TPCTL_CMDLINE_SIZE];
    LPBYTE EndOfCmd;
    LPBYTE SBuf;
    BOOL ContinueCommand = FALSE;
    BOOL InitialCommand = TRUE;
    BOOL FoundEnvVar;
    LPSTR EnvVar;

    //
    // If the ScriptIndex equals -1 we are reading commands from the
    // command line, so we will prompt the user to enter commands.
    //

    if ( ScriptIndex == -1 ) 
    {
        TpctlPrompt( Prompt,LineBuf,MaximumResponse );

        i = 0; // LineBuf index
        k = 0; // Buffer index

        while (( i < TPCTL_CMDLINE_SIZE ) &&
              (( LineBuf[i] != '\n' ) &&
               ( LineBuf[i] != '\r' ))) 
        {
            //
            // If we have found the beginning of an Environment
            // Variable argument
            //

            if ( LineBuf[i] == '%' ) 
            {
                j = (DWORD)-1;
                FoundEnvVar = FALSE;
                i++;

                //
                // Copy it into a temp buffer.
                //

                while (( LineBuf[i] != '\n' ) &&
                      (( LineBuf[i] != ' ' ) &&
                      (( LineBuf[i] != '\t' ) &&
                       ( LineBuf[i] != '\r' )))) 
                {
                    TmpBuf[++j] = LineBuf[i++];

                    if ( TmpBuf[j] == '%') 
                    {
                        TmpBuf[j] = '\0';
                        FoundEnvVar = TRUE;
                        break;
                    }
                }

                TmpBuf[j] = '\0';

                //
                // And find its true value in the process environment.
                //

                if ( FoundEnvVar == TRUE ) 
                {
                    EnvVar = getenv( _strupr( TmpBuf ));

                    if ( EnvVar == NULL ) 
                    {
                        TpctlErrorLog("\n\tTpctl: Undefined Environment Variable \"%%%s%%\".\n",
                                                    TmpBuf);
                        return ERROR_ENVVAR_NOT_FOUND;
                    }

                    //
                    // and copy the value to the line buffer.
                    //

                    do 
                    {
                        Buffer[k++] = *EnvVar++;
                    } while ( *EnvVar != '\0' );

                } 
                else 
                {
                    TmpBuf[++j] = '\0';
                    TpctlErrorLog("\n\tTpctl: Invalid Environment Variable Format \"%%%s\".\n",
                                                TmpBuf);
                    return ERROR_INVALID_PARAMETER;
                }

            //
            // Otherwise just copy the next character to the line buffer.
            //

            } 
            else 
            {
                Buffer[k++] = LineBuf[i++];
            }
        }

        //
        // and then print the commands to the log file if necessary.
        //

        TpctlCmdLneLog(" %s\n", Buffer);

    //
    // Otherwise we are reading commands from a script file, so return
    // the next command in the file.
    //

    } 
    else if ( Scripts[ScriptIndex].BufIndex >= Scripts[ScriptIndex].Length ) 
    {
        //
        // We are at the end of this script file, clean up the script
        // and log files.
        //

        TpctlUnLoadFiles();

        //
        // Set the return value in Buffer to null indicating that
        // there was no command.
        //

        *Buffer = 0x0;

    } 
    else 
    {
        //
        // Null out the Buffer buffer so that we don't use any garbage
        // laying around from the last command.
        //

        ZeroMemory(Buffer, TPCTL_CMDLINE_SIZE);

        SBuf = Scripts[ScriptIndex].Buffer;

        while ((DWORD)(CmdBufPtr - Buffer) < MaximumResponse ) 
        {
            //
            // and null out the temporary command buffer.
            //

            ZeroMemory(LineBuf, TPCTL_CMDLINE_SIZE);

            //
            // Read the next command line from the script file.
            //

            i = (DWORD)-1;

            while ( Scripts[ScriptIndex].BufIndex <
                    Scripts[ScriptIndex].Length ) 
            {
                //
                // If we have found the beginning of an Environment
                // Variable argument...
                //

                if ( SBuf[Scripts[ScriptIndex].BufIndex] == '%' ) 
                {
                    j = (DWORD)-1;
                    FoundEnvVar = FALSE;
                    Scripts[ScriptIndex].BufIndex++;

                    //
                    // Copy it into a temp buffer.
                    //

                    while (( SBuf[Scripts[ScriptIndex].BufIndex] != '\n' ) &&
                          (( SBuf[Scripts[ScriptIndex].BufIndex] != ' ' ) &&
                          (( SBuf[Scripts[ScriptIndex].BufIndex] != '\t' ) &&
                           ( SBuf[Scripts[ScriptIndex].BufIndex] != '\r' )))) 
                    {
                        TmpBuf[++j] = SBuf[Scripts[ScriptIndex].BufIndex++];

                        if ( TmpBuf[j] == '%') 
                        {
                            TmpBuf[j] = '\0';
                            FoundEnvVar = TRUE;
                            break;
                        }
                    }

                    //
                    // And find its true value in the process environment.
                    //

                    if ( FoundEnvVar == TRUE ) 
                    {
                        EnvVar = getenv( _strupr( TmpBuf ));

                        if ( EnvVar == NULL ) 
                        {
                            TpctlErrorLog("\n\tTpctl: Undefined Environment Variable \"%%%s%%\".\n",
                                                TmpBuf);
                            return ERROR_ENVVAR_NOT_FOUND;
                        }

                        //
                        // and copy the value to the line buffer.
                        //

                        do 
                        {
                            LineBuf[++i] = *EnvVar++;
                        } while ( *EnvVar != '\0' );

                    } 
                    else 
                    {
                        TmpBuf[++j] = '\0';
                        TpctlErrorLog("\n\tTpctl: Invalid Environment Variable Format \"%%%s\".\n",
                                                    TmpBuf);
                        return ERROR_INVALID_PARAMETER;
                    }

                //
                // Otherwise just copy the next character to the line buffer.
                //

                } 
                else 
                {
                    LineBuf[++i] = SBuf[Scripts[ScriptIndex].BufIndex++];
                }

                if ( LineBuf[i] == '\n' ) 
                {
                    break;
                }
            }

            LineBuf[i] = '\0';

            if ( InitialCommand == TRUE ) 
            {
                TpctlLog("%s ",Prompt);
                InitialCommand = FALSE;
            } 
            else 
            {
                TpctlLog("\t ",NULL );
            }

            TpctlLog("%s\n",LineBuf);

            if ( !Verbose ) 
            {
                if ( strstr( LineBuf,"TITLE:" ) != NULL ) 
                {
                    TpctlErrorLog("\n%s ",Prompt);
                    TpctlErrorLog("%s\n\n",LineBuf);
                }
            }

            // check for comment ending line

            ContinueCommand = FALSE;
            if ( (EndOfCmd = strchr( LineBuf, '#')) != NULL)   
            {
                //
                // We just have a comment, set the command continue
                // flag to exit the command parsing, and null the
                // command section of the string.
                //
                EndOfCmd[0] = '\0';
            }

            // check for a closing parenthesis on line.  This is the end of any SETGLOBALS
            // command that contains an expression.  No other command uses parenthesis

            if ( (EndOfCmd = strchr( LineBuf, ')' )) != NULL)
            {
                EndOfCmd[1] = '\0';     // closing parenthese is last thing on line
            }
            else if ( (EndOfCmd = strchr( LineBuf, '+' )) != NULL)
            {
                //
                // This is a Cmd Continuation, set the flag to continue
                // the while loop, and ignore the rest of the line.
                //
                ContinueCommand = TRUE;
                EndOfCmd[0] = '\0';
            } 

            i=0;

            while ( LineBuf[i] != '\0' ) 
            {
                if ((( LineBuf[i] == ' ' ) ||
                     ( LineBuf[i] == '\t' )) ||
                     ( LineBuf[i] == '\r' )) 
                {
                    *CmdBufPtr++ = ' ';

                    while ((( LineBuf[i] == ' ' ) ||
                            ( LineBuf[i] == '\t' )) ||
                            ( LineBuf[i] == '\r' )) 
                    {
                        i++;
                    }

                } 
                else 
                {
                    *CmdBufPtr++ = LineBuf[i++];
                }
            }

            if ( ContinueCommand == FALSE ) 
            {
                return Status;
            }
        }
    }

    return Status;
}



BOOL
TpctlParseCommand(
    IN LPSTR CommandLine,
    OUT LPSTR Argv[],
    OUT PDWORD Argc,
    IN DWORD MaxArgc
    )
{
    LPSTR cl = CommandLine;
    DWORD ac = 0;
    BOOL DoubleQuotesDetected, DetectedEndOfString, StartOfString;

    while ( *cl && (ac < MaxArgc) ) 
    {
        //
        // Skip to get to the lvalue
        //
        while ( *cl && (*cl <= ' ') )   // ignore leading blanks
        {
            cl++;
        }

        if ( !*cl ) 
        {
            break;
        }

        //
        // Argument detected. Initialize the Argv and increment the counter
        //

        *Argv++ = cl;
        ++ac;

        DoubleQuotesDetected = DetectedEndOfString = FALSE;
        StartOfString = TRUE;

        while( !DetectedEndOfString ) 
        {
            while ( *cl > ' ') 
            {
                if ( StartOfString && (*cl == '"') && (*(cl-1) == '=')  ) 
                {
                    DoubleQuotesDetected = TRUE;
                    StartOfString = FALSE;
                }
                cl++;
            }

            if ( DoubleQuotesDetected ) 
            {
                if ( ((*(cl-1) == '"') && (*(cl-2) != '\\')) ||
                     ( *cl != ' ' ) ) 
                {
                    DetectedEndOfString = TRUE;
                } 
                else 
                {
                    cl++;
                }
            } 
            else 
            {
                DetectedEndOfString = TRUE;
            }
        }

        if ( *cl ) 
        {
            *cl++ = '\0';
        }

    }

    if ( ac < MaxArgc ) 
    {
        *Argv++ = NULL;
    } 
    else if ( *cl ) 
    {
        TpctlErrorLog("\n\tTpctl: Too many tokens in command; \"%s\".\n",(PVOID)cl);
        return FALSE;
    }

    *Argc = ac;

    return TRUE;
}



VOID
TpctlPrompt(
    LPSTR Prompt,
    LPSTR Buffer,
    DWORD BufferSize
    )

// -----------
// 
// Routine Description:
// 
// 
// Arguments:
// 
//     Prompt -
//     Buffer -
//     BufferSize -
// 
// Return Value:
// 
//     None.
// 
// ----------

{
    LPSTR NewLine;
    DWORD ReadAmount;

    //
    // print out the prompt command, and then read the user's input.
    // We are using the TpctlErrorLog routine to print it to the
    // screen and the log files because we know that verbose mode
    //

    TpctlErrorLog("%s ",Prompt);

    ReadFile(   GetStdHandle(STD_INPUT_HANDLE),
                (LPVOID )Buffer,
                BufferSize,
                &ReadAmount,
                NULL );

    //
    //  If the user typed <CR>, then the buffer contains a single
    //  <CR> character.  We want to remove this character, and replace it with
    //  a nul character.
    //

    if ( (NewLine = strchr(Buffer, '\r')) != NULL ) 
    {
        *NewLine = '\0';
    }

}



VOID
TpctlLoadLastEnvironmentVariables(
    DWORD OpenInstance
    )

// --------------
// 
// Routine Description:
// 
// Arguments:
// 
// Return Value:
// 
//     None.
// 
// -------------

{
    GlobalCmdArgs.ARGS.ENV.WindowSize =
        Open[OpenInstance].EnvVars->WindowSize;

    GlobalCmdArgs.ARGS.ENV.RandomBufferNumber =
        Open[OpenInstance].EnvVars->RandomBufferNumber;

    GlobalCmdArgs.ARGS.ENV.StressDelayInterval =
        Open[OpenInstance].EnvVars->StressDelayInterval;

    GlobalCmdArgs.ARGS.ENV.UpForAirDelay =
        Open[OpenInstance].EnvVars->UpForAirDelay;

    GlobalCmdArgs.ARGS.ENV.StandardDelay =
        Open[OpenInstance].EnvVars->StandardDelay;

    strcpy( GlobalCmdArgs.ARGS.ENV.StressAddress,
            Open[OpenInstance].EnvVars->StressAddress );

    strcpy( GlobalCmdArgs.ARGS.ENV.ResendAddress,
            Open[OpenInstance].EnvVars->ResendAddress );
}



VOID
TpctlSaveNewEnvironmentVariables(
    DWORD OpenInstance
    )

// ---------------
// 
// Routine Description:
// 
// Arguments:
// 
//     None.
// 
// Return Value:
// 
//     None.
// 
// -------------

{
    Open[OpenInstance].EnvVars->WindowSize =
        GlobalCmdArgs.ARGS.ENV.WindowSize;

    Open[OpenInstance].EnvVars->WindowSize =
        GlobalCmdArgs.ARGS.ENV.RandomBufferNumber;

    Open[OpenInstance].EnvVars->StressDelayInterval =
        GlobalCmdArgs.ARGS.ENV.StressDelayInterval;

    Open[OpenInstance].EnvVars->UpForAirDelay =
        GlobalCmdArgs.ARGS.ENV.UpForAirDelay;

    Open[OpenInstance].EnvVars->StandardDelay =
        GlobalCmdArgs.ARGS.ENV.StandardDelay;

    strcpy( Open[OpenInstance].EnvVars->StressAddress,
            GlobalCmdArgs.ARGS.ENV.StressAddress );

    strcpy( Open[OpenInstance].EnvVars->ResendAddress,
            GlobalCmdArgs.ARGS.ENV.ResendAddress );
}


// !!check calls here for WIN32!!

VOID
TpctlPerformRegistryOperation(
                    IN PCMD_ARGS CmdArgs
                             )
{
    DWORD          Status,ValueType,ValueSize  ;
    DWORD          ReadValueType, ReadValueSize;
    DWORD          Disposition  , BytesWritten ;
    PUCHAR         ReadValue = NULL      ;
    UCHAR          PrintStringBuffer[10], TmpChar;
    HKEY           DbaseHKey, KeyHandle  ;
    REGSAM         SamDesired         ;
    LPSTR          TmpBuf = GlobalBuf, StopString ;
    LPSTR          SubKeyName = &CmdArgs->ARGS.REGISTRY_ENTRY.SubKey[1]        ;
    LPSTR          ValueName = &CmdArgs->ARGS.REGISTRY_ENTRY.SubKeyValueName[1];
    LPSTR          Value = CmdArgs->ARGS.REGISTRY_ENTRY.SubKeyValue            ;
    LPSTR          DbaseName = KeyDbaseTable[CmdArgs->ARGS.REGISTRY_ENTRY.OperationType].FieldName;
    LPSTR          ClassName = &CmdArgs->ARGS.REGISTRY_ENTRY.SubKeyClass[1]    ;
    LPSTR          Tmp = NULL;
    BOOL           CompleteQueryStatus;
    INT            i,j,k,Radix = 16,CopyLength = 2;


    TmpBuf += (BYTE)sprintf(TmpBuf,"\n\tCommandCode    = %s\n", 
                            TpctlGetCmdCode( CmdArgs->CmdCode ));

    //
    // Initialize and allocate resources
    //

    if ( (ReadValue = calloc( 2, MAX_VALUE_LENGTH )) == NULL ) 
    {
        TpctlErrorLog( "\n\tTpctl: TpctlPeformRegistryOperation: Unable to allocate memory resources\n", NULL );
        return;
    }

    //
    // Clear and write the buffer responsible for extracting the values
    //

    ZeroMemory ( PrintStringBuffer, sizeof( PrintStringBuffer ) );
    sprintf( PrintStringBuffer, "%%%d.%dx", sizeof(DWORD), sizeof(DWORD) );

    //
    // Set the appropriate DataBase key
    //

    switch(  CmdArgs->ARGS.REGISTRY_ENTRY.KeyDatabase ) 
    {
        case CLASSES_ROOT : 
            DbaseHKey = HKEY_CLASSES_ROOT;
            break;

        case CURRENT_USER : 
            DbaseHKey = HKEY_CURRENT_USER;
            break;

        case LOCAL_MACHINE: 
            DbaseHKey = HKEY_LOCAL_MACHINE;
            break;

        case USERS: 
            DbaseHKey = HKEY_USERS;
            break;

        default: 
            TpctlErrorLog("\n\tTpctl: %d not a valid Key DataBase",
                            (PVOID)CmdArgs->ARGS.REGISTRY_ENTRY.KeyDatabase );
            return;
    }

    //
    // The SubKey Name
    // The Value name
    // The Class Name
    //
    if ( (Tmp = strrchr( SubKeyName, '"' ))  != NULL ) 
    {
        *Tmp = '\0';
    }
    if ( (Tmp = strrchr( ValueName, '"' ))  != NULL ) 
    {
        *Tmp = '\0';
    }
    if ( (Tmp = strrchr( ClassName, '"' ))  != NULL ) 
    {
        *Tmp = '\0';
    }

    //
    // The value type and the associated value
    //
    
    switch( CmdArgs->ARGS.REGISTRY_ENTRY.ValueType ) 
    {
        case BINARY :
            ValueType = REG_BINARY;
            i         = 0;
            j         = 0;  // Default begin extraction from String[j=0]:Value buffer starting point
            k         = 0;  // Default:Input Value is in hex or binary - designator. 
                            // 0 is HEX, 1 is BINARY
            ValueSize = strlen( Value );
            if( ValueSize >= 2 ) 
            {
                if ( toupper( Value[1] ) == 'B' ) 
                {
                    j          = 2;
                    k          = 1;
                    Radix      = 2;
                    CopyLength = 8;
                }
            }
            {
                UCHAR  BitStream[9];
                PUCHAR PTmpChar;
                DWORD  BytesToCopy;

                while( j < (INT)ValueSize ) 
                {
                    memset( BitStream, '\0', sizeof( BitStream ) );
                    memset( BitStream, '0' , sizeof(UCHAR)*CopyLength );
                    BytesToCopy = min( strlen( &Value[j] ), (DWORD)CopyLength );
                    memcpy( BitStream, &Value[j], BytesToCopy );
                    Value[i] = (UCHAR)strtoul( BitStream,&PTmpChar, Radix );
                    i++;
                    j += BytesToCopy;
                }
                ValueSize = i;
            }
            break;

        case DWORD_REGULAR :
            ValueType = REG_DWORD;
            ValueSize = sizeof( DWORD );
            *(LPDWORD)Value = strtoul( Value, &StopString, 0 );
            break;

        case DWORD_LITTLE_ENDIAN :
            ValueType = REG_DWORD_LITTLE_ENDIAN;
            ValueSize = sizeof( DWORD );
            {
                DWORD TmpValue =  strtoul( Value, &StopString, 0 );
                sprintf( Value, PrintStringBuffer, TmpValue );
            }
            // Reverse the array since this is Big Endian

            for( i = 0, j = ValueSize-1; i < (INT)ValueSize; i++,j-- ) 
            {
                Value[i] -= '0';
                Value[j] -= '0';
                TmpChar = Value[i];
                Value[i] = Value[j];
                Value[j] = TmpChar;
            }
            break;

        case DWORD_BIG_ENDIAN :
            ValueType = REG_DWORD_BIG_ENDIAN;
            ValueSize = sizeof( DWORD );
            {
                DWORD TmpValue =  strtoul( Value, &StopString, 0 );
                sprintf( Value, PrintStringBuffer, TmpValue );
            }
            break;

        case EXPAND_SZ :
            ValueType = REG_EXPAND_SZ;
            ValueSize = strlen( Value );
            break;

        case LINK :
            ValueType = REG_LINK;
            ValueSize = strlen( Value );
            break;

        case MULTI_SZ :
            ValueType = REG_MULTI_SZ;
          
            //
            // The string Value needs to be readjusted. Use ReadValue as a temporary
            // buffer

            memset( ReadValue, 0, 2*MAX_VALUE_LENGTH );
            {
                UCHAR CanCopy  = 0x0;
                BOOL  IgnoreNext = FALSE;

                for( i = 0, j = 0 ; i < (INT)strlen( Value ); i++ ) 
                {
                    if ( ( Value[i] == '"' ) && ( IgnoreNext == FALSE ) ) 
                    {
                        CanCopy = ~CanCopy;
                        if ( !CanCopy ) 
                        {
                            ReadValue[j++] = '\0';
                        }
                    }
                    if (  Value[i] == '\\' ) 
                    {
                        IgnoreNext = TRUE;
                    } 
                    else 
                    {
                        IgnoreNext = FALSE;
                    }
                    if ( CanCopy ) 
                    {
                        ReadValue[j++] = Value[i];
                    }
                }
            }

            //
            // Fill the 2 nulls at the end of the array
            //

            ReadValue[j++] = '\0';ReadValue[j++] = '\0';
            ValueSize = j;
            memcpy( Value, ReadValue, j );
            memset( ReadValue, 0, 2*MAX_VALUE_LENGTH );
            break;

        case NONE :
            ValueType = REG_NONE;
            ValueSize = strlen( Value );
            break;

        case RESOURCE_LIST :
            ValueType = REG_RESOURCE_LIST;
            ValueSize = strlen( Value );
            break;

        case SZ :
            ValueType = REG_SZ;
            ValueSize = strlen( Value );
            break;

        default : 
            break;

    }

    //
    // Switch to the demanded operation
    //

    switch ( CmdArgs->ARGS.REGISTRY_ENTRY.OperationType ) 
    {
        case ADD_KEY:
            TmpBuf += (BYTE)sprintf( TmpBuf, "\tSubCommandCode = ADD_KEY\n" );

            SamDesired = KEY_ALL_ACCESS;

            Status = RegCreateKeyEx( DbaseHKey, SubKeyName, (DWORD)0,
                                     ClassName, REG_OPTION_NON_VOLATILE,
                                     SamDesired, NULL, &KeyHandle, &Disposition );

            if ( Status != ERROR_SUCCESS ) 
            {
                TmpBuf += (BYTE)sprintf( TmpBuf, "\tStatus         = %ldL\n", Status );
                TmpBuf += (BYTE)sprintf( TmpBuf,
                "\n\tTpctl: Unable to create\n\tSubkey   : %s\n\tClassName: %s\n\tDatabase : %s\n",
                                       SubKeyName, ClassName, DbaseName );
                break;

            }

            TmpBuf += (BYTE)sprintf( TmpBuf, "\tStatus         = SUCCESS\n" );
            TmpBuf += (BYTE)sprintf( TmpBuf, "\tDisposition    = " );

            if ( Disposition == REG_CREATED_NEW_KEY ) 
            {
                TmpBuf += (BYTE)sprintf( TmpBuf, "CREATED A NEW KEY\n" );
            } 
            else 
            {
                TmpBuf += (BYTE)sprintf( TmpBuf, "KEY ALREADY EXISTS\n" );
            }
            break;

        case DELETE_KEY:
            TmpBuf += (BYTE)sprintf( TmpBuf, "\tSubCommandCode = DELETE_KEY\n" );

            Status = RegDeleteKey( DbaseHKey, SubKeyName );
            if ( Status != ERROR_SUCCESS ) {

                TmpBuf += (BYTE)sprintf( TmpBuf, "\tStatus         = %ldL\n", Status );
                TmpBuf += (BYTE)sprintf( TmpBuf,
                "\n\tTpctl: Unable to delete\n\tSubkey   : %s\n\tClassName: %s\n\tDatabase : %s\n",
                                       SubKeyName, ClassName, DbaseName );
                 break;

            }

            TmpBuf += (BYTE)sprintf( TmpBuf, "\tStatus         = SUCCESS\n" );
            break;


        case QUERY_KEY:

            CompleteQueryStatus = TRUE;

            TmpBuf += (BYTE)sprintf( TmpBuf, "\tSubCommandCode = QUERY_KEY\n" );

            //
            // Open the Registry Key
            //

            SamDesired = KEY_READ;

            Status = RegOpenKeyEx( DbaseHKey, SubKeyName, (DWORD)0, SamDesired, &KeyHandle );
            if ( Status != ERROR_SUCCESS ) 
            {
                TmpBuf += (BYTE)sprintf( TmpBuf, "\tStatus         = %ldL\n", Status );
                TmpBuf += (BYTE)sprintf( TmpBuf,
                "\n\tTpctl: Unable to open\n\tSubkey   : %s\n\tClassName: %s\n\tDatabase : %s\n",
                                       SubKeyName, ClassName, DbaseName );
                 break;

            }

            {
                LPSTR       TmpKeyClassName = NULL, TmpSubKeyName   = NULL, TmpValueName = NULL;
                DWORD       NumberOfSubKeys, NumberOfValues, TmpValueType, ClassNameSize;
                DWORD       TmpDwordVar, LongestSubKeyNameSize, LongestSubKeyClassNameSize;
                DWORD       LongestValueNameSize;
                FILETIME    LastWriteTime;
                SYSTEMTIME  SystemTime;
                CHAR        *DayOfWeek[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
                                           "Friday", "Saturday" };

                if ( (TmpKeyClassName = calloc( 1, MAX_PATH+1 )) == NULL ) 
                {
                    TpctlErrorLog( 
        "\n\tTpctl: TpctlPeformRegistryOperation: QueryKey unable to allocate memory resources\n", 
                                    NULL );
                    return;
                }

                ClassNameSize = MAX_PATH+1;
                Status = RegQueryInfoKey( KeyHandle, TmpKeyClassName, &ClassNameSize,
                                          NULL, &NumberOfSubKeys, &LongestSubKeyNameSize,
                                          &LongestSubKeyClassNameSize, &NumberOfValues, 
                                          &LongestValueNameSize,
                                          &TmpDwordVar, &TmpDwordVar, &LastWriteTime );

                if ( (Status == ERROR_MORE_DATA) || (Status == ERROR_INSUFFICIENT_BUFFER) ) 
                {
                    free( TmpKeyClassName );
                    if ( (TmpKeyClassName = calloc( 1, ClassNameSize+2 )) == NULL ) 
                    {
                        TpctlErrorLog( "\n\tTpctl: TpctlPeformRegistryOperation: QueryKey unable to allocate memory resources\n", NULL );
                        return;
                    }
                    Status = RegQueryInfoKey( KeyHandle, TmpKeyClassName, &ClassNameSize,
                                              NULL, &NumberOfSubKeys, &LongestSubKeyNameSize,
                                              &LongestSubKeyClassNameSize, &NumberOfValues, 
                                              &LongestValueNameSize,
                                              &TmpDwordVar, &TmpDwordVar, &LastWriteTime );
                }
                if ( Status != ERROR_SUCCESS ) 
                {
                    TmpBuf += (BYTE)sprintf( TmpBuf,"\tStatus         = %ldL\n", Status );
                    TmpBuf += (BYTE)sprintf( TmpBuf,
          "\n\tTpctl: Unable to QueryInfo on\n\tSubkey   : %s\n\tClassName: %s\n\tDatabase : %s\n",
                                           SubKeyName, ClassName, DbaseName );
                     break;
                }

                TmpBuf += sprintf( TmpBuf, 
                    "\tKey Class Name = %s\n\tNumber Of SubKeys = %ld\n\tNumber of Values  = %ld\n",
                                        TmpKeyClassName, NumberOfSubKeys, NumberOfValues );

                if ( FileTimeToSystemTime( &LastWriteTime, &SystemTime ) ) 
                {
                    TmpBuf += sprintf( TmpBuf, 
                            "\tLast Write Time   = %s %2.2d-%2.2d-%4.4d at %2.2d:%2.2d:%2.2d %s\n",
                                        DayOfWeek[SystemTime.wDayOfWeek],
                                        SystemTime.wMonth,
                                        SystemTime.wDay,
                                        SystemTime.wYear,
                                        ((SystemTime.wHour > 12) ? (SystemTime.wHour-12) 
                                                                 : SystemTime.wHour),
                                        SystemTime.wMinute,
                                        SystemTime.wSecond,
                                        ((SystemTime.wHour > 12) ? "AM" : "PM") );
                } 
                else 
                {
                    TmpBuf += sprintf( TmpBuf, "\tLast Write Time   = Undefined\n" );
                }

                free( TmpKeyClassName );

                if ( (TmpSubKeyName = calloc( 1, LongestSubKeyNameSize+2 )) == NULL ) 
                {
                    TpctlErrorLog( "\n\tTpctl: TpctlPeformRegistryOperation: QueryKey unable to allocate memory resources\n", NULL );
                    return;
                }

                TmpBuf += sprintf( TmpBuf, "\tSub Key Name(s)\n" );

                for( i = 0; i < (INT)NumberOfSubKeys; i++ ) 
                {
                    memset( TmpSubKeyName, 0, LongestSubKeyNameSize+2 );
                    Status = RegEnumKey( KeyHandle, i, TmpSubKeyName, LongestSubKeyNameSize+2 );
                    if ( Status != ERROR_SUCCESS ) 
                    {
                        TmpBuf += (BYTE)sprintf( TmpBuf,"\tStatus         = %ldL\n", Status );
                        TmpBuf += (BYTE)sprintf( TmpBuf,
                                  "\n\tTpctl: Unable to Enumerate Key Index %d from\n\tSubkey   : %s\n\tClassName: %s\n\tDatabase : %s\n",
                                               i, SubKeyName, ClassName, DbaseName );
                        CompleteQueryStatus = FALSE;
                    } 
                    else 
                    {
                        TmpBuf += sprintf( TmpBuf, "\t%2d.\t%s\n", i, TmpSubKeyName );
                    }
                }

                free( TmpSubKeyName );

                if ( (TmpValueName = calloc( 1, LongestValueNameSize+2 )) == NULL ) 
                {
                    TpctlErrorLog( "\n\tTpctl: TpctlPeformRegistryOperation: QueryKey unable to allocate memory resources\n", NULL );
                    return;
                }

                TmpBuf += sprintf( TmpBuf, "\tSub Key Value Name(s) and Associated Type(s)\n" );

                for( i = 0; i < (INT)NumberOfValues; i++ ) 
                {
                    memset( TmpValueName, 0, LongestValueNameSize+2 );
                    TmpDwordVar = LongestValueNameSize+2;
                    Status = RegEnumValue( KeyHandle, i, TmpValueName, &TmpDwordVar, NULL,  
                                           &TmpValueType, NULL, NULL );
                    if ( Status != ERROR_SUCCESS ) 
                    {
                        TmpBuf += (BYTE)sprintf( TmpBuf,"\tStatus         = %ldL\n", Status );
                        TmpBuf += (BYTE)sprintf( TmpBuf,
                                  "\n\tTpctl: Unable to Enumerate Value Index %d from\n\tSubkey   : %s\n\tClassName: %s\n\tDatabase : %s\n",
                                               i, SubKeyName, ClassName, DbaseName );
                        CompleteQueryStatus = FALSE;
                    } 
                    else 
                    {
                        TmpBuf += sprintf( TmpBuf, 
                    "\t%2d.\t%-30s%-15s\n", i, TmpValueName, TpctlGetValueType( TmpValueType ) );

                    }
                }

                free( TmpValueName );

            }

            if ( CompleteQueryStatus ) 
            {
                TmpBuf += (BYTE)sprintf( TmpBuf, "\tComplete Query Status = SUCCESS\n" );
            } 
            else 
            {
                TmpBuf += (BYTE)sprintf( TmpBuf, "\tComplete Query Status = FAILURE\n" );
            }
            break;

        case ADD_VALUE:
        case CHANGE_VALUE:
            if ( CmdArgs->ARGS.REGISTRY_ENTRY.OperationType == CHANGE_VALUE ) 
            {
                TmpBuf += (BYTE)sprintf( TmpBuf, "\tSubCommandCode = CHANGE_VALUE\n" );
                SamDesired = KEY_WRITE|KEY_READ;
            } 
            else 
            {
                TmpBuf += (BYTE)sprintf( TmpBuf, "\tSubCommandCode = ADD_VALUE\n" );
                SamDesired = KEY_ALL_ACCESS;
            }


            Status = RegOpenKeyEx( DbaseHKey, SubKeyName, (DWORD)0, SamDesired, &KeyHandle );
            if ( Status != ERROR_SUCCESS ) 
            {
                TmpBuf += (BYTE)sprintf( TmpBuf,"\tStatus         = %ldL\n", Status );
                TmpBuf += (BYTE)sprintf( TmpBuf,
                "\n\tTpctl: Unable to open\n\tSubkey   : %s\n\tClassName: %s\n\tDatabase : %s\n",
                                       SubKeyName, ClassName, DbaseName );
                break;

            }

            //
            // If this is a request to change a value, make sure that the value exists
            //

            if ( CmdArgs->ARGS.REGISTRY_ENTRY.OperationType == CHANGE_VALUE ) 
            {
                //
                // Make sure the ValueName exist since this is a change request
                //
                ReadValueSize = 2*MAX_VALUE_LENGTH;
                ReadValueType = ValueType;
                Status = RegQueryValueEx( KeyHandle, ValueName, (DWORD)0, &ReadValueType, 
                                          ReadValue, &ReadValueSize );
                if ( (Status != ERROR_SUCCESS) && 
                     (Status != ERROR_MORE_DATA) && 
                     (Status != ERROR_INSUFFICIENT_BUFFER) ) 
                {
                    TmpBuf += (BYTE)sprintf( TmpBuf,"\tStatus         = %ldL\n", Status );
                    TmpBuf += (BYTE)sprintf( TmpBuf,
"\n\tTpctl: Unable to access\n\tValue    : %s\n\tSubkey   : %s\n\tClassName: %s\n\tDatabase : %s\n",
                                           ValueName, SubKeyName, ClassName, DbaseName );
                    break;

                }
            }

            //
            // Now set the values as expected
            //
            Status = RegSetValueEx( KeyHandle, ValueName, (DWORD)0, ValueType, Value, ValueSize );
            if ( Status != ERROR_SUCCESS ) 
            {
                TmpBuf += (BYTE)sprintf( TmpBuf,"\tStatus         = %ldL\n", Status );
                TmpBuf += (BYTE)sprintf( TmpBuf,
"\n\tTpctl: Unable to change\n\tValue    : %s\n\tSubkey   : %s\n\tClassName: %s\n\tDatabase : %s\n",
                                       ValueName, SubKeyName, ClassName, DbaseName );
                break;

            }
            TmpBuf += (BYTE)sprintf( TmpBuf, "\tStatus         = SUCCESS\n" );
            break;


        case DELETE_VALUE:
            TmpBuf += (BYTE)sprintf( TmpBuf, "\tSubCommandCode = DELETE_VALUE\n" );

            //
            // Open the Registry Key
            //
            SamDesired = KEY_SET_VALUE;

            Status = RegOpenKeyEx( DbaseHKey, SubKeyName, (DWORD)0, SamDesired, &KeyHandle );
            if ( Status != ERROR_SUCCESS ) 
            {
                TmpBuf += (BYTE)sprintf( TmpBuf,"\tStatus         = %ldL\n", Status );
                TmpBuf += (BYTE)sprintf( TmpBuf,
                "\n\tTpctl: Unable to open\n\tSubkey   : %s\n\tClassName: %s\n\tDatabase : %s\n",
                                       SubKeyName, ClassName, DbaseName );
                break;

            }

            Status = RegDeleteValue( KeyHandle, ValueName );
            if ( Status != ERROR_SUCCESS ) 
            {
                TmpBuf += (BYTE)sprintf( TmpBuf,"\tStatus         = %ldL\n", Status );
                TmpBuf += (BYTE)sprintf( TmpBuf,
"\n\tTpctl: Unable to delete\n\tValue    : %s\n\tSubkey   : %s\n\tClassName: %s\n\tDatabase : %s\n",
                                       ValueName, SubKeyName, ClassName, DbaseName );
                break;

            }

            TmpBuf += (BYTE)sprintf( TmpBuf, "\tStatus         = SUCCESS\n" );
            break;

        case QUERY_VALUE:
            TmpBuf += (BYTE)sprintf( TmpBuf, "\tSubCommandCode = QUERY_VALUE\n" );

            //
            // Open the Registry Key
            //
            SamDesired = KEY_QUERY_VALUE;

            Status = RegOpenKeyEx( DbaseHKey, SubKeyName, (DWORD)0, SamDesired, &KeyHandle );
            if ( Status != ERROR_SUCCESS ) 
            {
                TmpBuf += (BYTE)sprintf( TmpBuf,"\tStatus         = %ldL\n", Status );
                TmpBuf += (BYTE)sprintf( TmpBuf,
                "\n\tTpctl: Unable to open\n\tSubkey   : %s\n\tClassName: %s\n\tDatabase : %s\n",
                                       SubKeyName, ClassName, DbaseName );
                 break;
            }

            //
            // Make sure the ValueName exist since this is a change request
            //

            ReadValueSize = 2*MAX_VALUE_LENGTH;
            Status = RegQueryValueEx( KeyHandle, ValueName, (DWORD)0, &ReadValueType, 
                                      ReadValue, &ReadValueSize );

            if ( (Status == ERROR_MORE_DATA) || (Status == ERROR_INSUFFICIENT_BUFFER) ) 
            {
                free( ReadValue );
                ReadValue = NULL;
                ReadValue = calloc( 1, ReadValueSize+1 );
                if ( ReadValue == NULL ) 
                {
                    TpctlErrorLog( 
        "\n\tTpctl: TpctlPeformRegistryOperation: QueryValue unable to allocate memory resources\n",
                                  NULL );
                    return;
                }
                Status = RegQueryValueEx( KeyHandle, ValueName, (DWORD)0, &ReadValueType, 
                                          ReadValue, &ReadValueSize );
            }

            if ( Status != ERROR_SUCCESS ) 
            {
                TmpBuf += (BYTE)sprintf( TmpBuf,"\tStatus         = %ldL\n", Status );
                TmpBuf += (BYTE)sprintf( TmpBuf,
"\n\tTpctl: Unable to access\n\tValue    : %s\n\tSubkey   : %s\n\tClassName: %s\n\tDatabase : %s\n",
                                       ValueName, SubKeyName, ClassName, DbaseName );
                break;

            }

            TmpBuf += (BYTE)sprintf( TmpBuf, "\tStatus         = SUCCESS\n" );
            TmpBuf = TpctlEnumerateRegistryInfo( TmpBuf, DbaseName, SubKeyName, ValueName,
                                               ReadValueType, ReadValue, ReadValueSize );
            break;


        default: 
            break;

    }

    //
    // Close any open keys and deallocate any allocated resources
    //

    RegCloseKey( KeyHandle );
    free( ReadValue );


    //
    // Print the buffer
    //

    if ( Verbose ) 
    {
        if ( !WriteFile(GetStdHandle( STD_OUTPUT_HANDLE ),
                        GlobalBuf,
                        TmpBuf-GlobalBuf,
                        &BytesWritten,
                        NULL )) 
        {
            Status = GetLastError();
            TpctlErrorLog("\n\tTpctl: WriteFile to screen failed, returned 0x%lx\n",(PVOID)Status);
        }
    }

    if ( CommandsFromScript ) 
    {
        if ( !WriteFile(Scripts[ScriptIndex].LogHandle,
                        GlobalBuf,
                        TmpBuf-GlobalBuf,
                        &BytesWritten,
                        NULL )) 
        {
            Status = GetLastError();
            TpctlErrorLog("\n\tTpctl: WriteFile to logfile failed, returned 0x%lx\n",(PVOID)Status);
        }

    } 
    else if ( CommandLineLogging ) 
    {
        if ( !WriteFile(CommandLineLogHandle,
                        GlobalBuf,
                        TmpBuf-GlobalBuf,
                        &BytesWritten,
                        NULL )) 
        {
            Status = GetLastError();
            TpctlErrorLog("\n\tTpctl: WriteFile to logfile failed, returned 0x%lx\n",(PVOID)Status);
        }
    }

    //
    // Free up resources
    //
    free( ReadValue );

}



BOOL
TpctlInitCommandBuffer(
    OUT PCMD_ARGS CmdArgs,
    IN DWORD CmdCode
    )

// -------------------
// 
// Routine Description:
// 
//     Initialize the cmd buffer to be passed to the driver with the arguments
//     read from the command line or the script file.
// 
// Arguments:
// 
//     CmdArgs - The buffer to store the arguments in.
// 
//     CmdCode - The command that is being issued, and therefore the command
//               to write the arguments for into the buffer.
// Return Value:
// 
//     BOOL - TRUE if the OpenInstance is valid and all the arguments are
//            written to the buffer, FALSE otherwise.
// 
// ----------------

{
    LPBYTE p, q, s, t;
    DWORD i, j;
    DWORD OidIndex;

    //
    // If the OpenInstance is invalid return immediately.
    //
    switch ( CmdCode ) 
    {
        case SETENV      :
        case GO          :
        case PAUSE       :
        case OPEN        :
        case CLOSE       :
        case QUERYINFO   :
        case SETPF       :
        case SETLA       :
        case ADDMA       :
        case DELMA       :
        case SETFA       :
        case SETGA       :
        case SETINFO     :
        case RESET       :
        case STOPSEND    :
        case WAITSEND    :
        case RECEIVE     :
        case STOPREC     :
        case GETEVENTS   :
        case STRESSSERVER:
        case ENDSTRESS   :
        case WAITSTRESS  :
        case CHECKSTRESS :
        case SEND        :
        case STRESS      :
        case PERFSERVER:
        case PERFCLIENT: 
            if (( GlobalCmdArgs.OpenInstance < 1 ) ||
                ( GlobalCmdArgs.OpenInstance > NUM_OPEN_INSTANCES )) 
            {
                TpctlErrorLog("\n\tTpctl: %d not a valid Open Instance Value ",
                              (PVOID)GlobalCmdArgs.OpenInstance);
                TpctlErrorLog("(1-%d).\n", (PVOID)NUM_OPEN_INSTANCES);
                return FALSE;
            }

        default: 
            break;

    }


    //
    // Otherwise let's stuff the arguments into the buffer.
    //

    CmdArgs->CmdCode = CmdCode;
    CmdArgs->OpenInstance = GlobalCmdArgs.OpenInstance;

    //
    // Now do the command dependant stuff.
    //

    switch( CmdCode ) 
    {
        case SETENV:

            CmdArgs->ARGS.ENV.WindowSize =
                GlobalCmdArgs.ARGS.ENV.WindowSize;

            CmdArgs->ARGS.ENV.RandomBufferNumber =
                GlobalCmdArgs.ARGS.ENV.RandomBufferNumber;

            CmdArgs->ARGS.ENV.StressDelayInterval =
                GlobalCmdArgs.ARGS.ENV.StressDelayInterval;

            CmdArgs->ARGS.ENV.UpForAirDelay =
                GlobalCmdArgs.ARGS.ENV.UpForAirDelay;

            CmdArgs->ARGS.ENV.StandardDelay =
                GlobalCmdArgs.ARGS.ENV.StandardDelay;

            p = CmdArgs->ARGS.ENV.StressAddress;
            q = GlobalCmdArgs.ARGS.ENV.StressAddress;

            s = CmdArgs->ARGS.ENV.ResendAddress;
            t = GlobalCmdArgs.ARGS.ENV.ResendAddress;

            for( i=0;i<ADDRESS_LENGTH;i++ ) 
            {
                *p++ = *q++;
                *s++ = *t++;
            }
            break;

        case BEGINLOGGING:
            strcpy( CmdArgs->ARGS.FILES.LogFile,GlobalCmdArgs.ARGS.FILES.LogFile );
            break;

        case RECORDINGENABLE:
            strcpy( CmdArgs->ARGS.RECORD.ScriptFile,GlobalCmdArgs.ARGS.RECORD.ScriptFile );
            break;

        case GO:
        case PAUSE:
            p = CmdArgs->ARGS.PAUSE_GO.RemoteAddress;
            q = GlobalCmdArgs.ARGS.PAUSE_GO.RemoteAddress;

            for( i=0;i<ADDRESS_LENGTH;i++ ) 
            {
                *p++ = *q++;
            }

            CmdArgs->ARGS.PAUSE_GO.TestSignature =
                GlobalCmdArgs.ARGS.PAUSE_GO.TestSignature;

            srand(TpctlSeed);
            CmdArgs->ARGS.PAUSE_GO.UniqueSignature = TpctlSeed = rand();
            break;

        case OPEN:
            strcpy( CmdArgs->ARGS.OPEN_ADAPTER.AdapterName,
                    GlobalCmdArgs.ARGS.OPEN_ADAPTER.AdapterName );
            CmdArgs->ARGS.OPEN_ADAPTER.NoArcNet = 0;
            if (getenv( "NOARCNET" ))
            {
                CmdArgs->ARGS.OPEN_ADAPTER.NoArcNet = 1;
            }
            break;

        case QUERYINFO:
            OidIndex = TpLookUpOidInfo( GlobalCmdArgs.ARGS.TPQUERY.OID );

            if (( OidIndex == -1 ) || ( OidArray[OidIndex].QueryInfo != TRUE )) 
            {
                TpctlErrorLog("\n\tTpctl: 0x%08lX not a valid NdisRequestQueryInformation OID.\n",
                    (PVOID)GlobalCmdArgs.ARGS.TPQUERY.OID);
                return FALSE;
            }
            CmdArgs->ARGS.TPQUERY.OID = GlobalCmdArgs.ARGS.TPQUERY.OID;
            break;

        case SETPF:
        case SETLA:
        case ADDMA:
        case SETFA:
        case SETGA:
        case SETINFO:
            CmdArgs->ARGS.TPSET.OID = 0x0;

            //
            // Sanjeevk: Performed a scrub on the multiple if. Bug #5203
            //

            switch ( CmdCode ) 
            {
                case SETINFO: 
                    CmdArgs->ARGS.TPSET.OID = GlobalCmdArgs.ARGS.TPSET.OID;
                    break;
    
                case SETPF: 
                    CmdArgs->ARGS.TPSET.OID = OID_GEN_CURRENT_PACKET_FILTER;
                    break;

                case SETLA: 
                    CmdArgs->ARGS.TPSET.OID = OID_GEN_CURRENT_LOOKAHEAD;
                    break;
                case ADDMA: 
                    if ( Open[CmdArgs->OpenInstance-1].MediumType == NdisMedium802_3 ) 
                    {
                        CmdArgs->ARGS.TPSET.OID = OID_802_3_MULTICAST_LIST;
                    } 
                    else 
                    {
                        //
                        // Only FDDI and 802.3 permit multicast addressing. Since the
                        // medium is not 802.3, it must be FDDI
                        //
                        CmdArgs->ARGS.TPSET.OID = OID_FDDI_LONG_MULTICAST_LIST;
                    }
                    break;

                case SETFA: 
                    CmdArgs->ARGS.TPSET.OID = OID_802_5_CURRENT_FUNCTIONAL;
                    break;

                case SETGA: 
                    CmdArgs->ARGS.TPSET.OID = OID_802_5_CURRENT_GROUP;
                    break;

                default: 
                    break;
            }

            switch ( CmdArgs->ARGS.TPSET.OID ) 
            {
                case OID_GEN_CURRENT_PACKET_FILTER:
                    CmdArgs->ARGS.TPSET.U.PacketFilter =
                        GlobalCmdArgs.ARGS.TPSET.U.PacketFilter;
                    break;

                case OID_GEN_CURRENT_LOOKAHEAD:
                    CmdArgs->ARGS.TPSET.U.LookaheadSize =
                        GlobalCmdArgs.ARGS.TPSET.U.LookaheadSize;
                    break;

                case OID_802_3_MULTICAST_LIST:
                case OID_FDDI_LONG_MULTICAST_LIST:
                {
                    PMULT_ADDR NextMultAddr;
                    DWORD OI = GlobalCmdArgs.OpenInstance - 1;

                    p = CmdArgs->ARGS.TPSET.U.MulticastAddress[0];
                    q = GlobalCmdArgs.ARGS.TPSET.U.MulticastAddress[0];

                    for ( i=0;i<ADDRESS_LENGTH;i++ ) 
                    {
                        *p++ = *q++;
                    }

                    NextMultAddr = Open[OI].MulticastAddresses;

                    //
                    // XXX: Should the stress tests be required to add and
                    // delete the stress multicast address to/from this list?
                    //

                    j = 1;

                    while ( NextMultAddr != NULL ) 
                    {
                        p = CmdArgs->ARGS.TPSET.U.MulticastAddress[j++];

                        for ( i=0;i<ADDRESS_LENGTH;i++ ) 
                        {
                            *p++ = NextMultAddr->MulticastAddress[i];
                        }

                        NextMultAddr = NextMultAddr->Next;
                    }
                    CmdArgs->ARGS.TPSET.NumberMultAddrs = Open[OI].NumberMultAddrs + 1;
                    break;
                }

                case OID_802_5_CURRENT_FUNCTIONAL:
                case OID_802_5_CURRENT_GROUP:
                    p = CmdArgs->ARGS.TPSET.U.FunctionalAddress;
                    q = GlobalCmdArgs.ARGS.TPSET.U.FunctionalAddress;

                    for ( i=0;i<FUNCTIONAL_ADDRESS_LENGTH;i++ ) 
                    {
                        *p++ = *q++;
                    }
                    break;

                default:
                    TpctlErrorLog("\n\tTpctl: 0x%08lX not a valid NdisRequestSetInformation OID.\n",
                                        (PVOID)GlobalCmdArgs.ARGS.TPSET.OID);
                    return FALSE;
            }
            break;

        case DELMA:
        {
            PMULT_ADDR NextMultAddr;
            DWORD OI = CmdArgs->OpenInstance - 1;
            BOOL AddressFound = FALSE;

            j = 0;

            //
            // Copy the addresses that do not match the one to be deleted into
            // the multicast list buffer to be reset.
            //

            //
            // Sanjeevk: Another change point. Bug #5203
            //
            if ( Open[CmdArgs->OpenInstance-1].MediumType == NdisMedium802_3 ) 
            {
                CmdArgs->ARGS.TPSET.OID = OID_802_3_MULTICAST_LIST;
            } 
            else 
            {
                //
                // Only FDDI and 802.3 permit multicast addressing. Since the
                // medium is not 802.3, it must be FDDI
                //
                CmdArgs->ARGS.TPSET.OID = OID_FDDI_LONG_MULTICAST_LIST;
            }

            CmdArgs->ARGS.TPSET.NumberMultAddrs = 0;
            NextMultAddr = Open[OI].MulticastAddresses;

            while ( NextMultAddr != NULL ) 
            {
                if ( memcmp(GlobalCmdArgs.ARGS.TPSET.U.MulticastAddress[0],
                            NextMultAddr->MulticastAddress,
                            ADDRESS_LENGTH) != 0 ) 
                {
                    p = CmdArgs->ARGS.TPSET.U.MulticastAddress[j++];

                    for ( i=0;i<ADDRESS_LENGTH;i++ ) 
                    {
                        *p++ = NextMultAddr->MulticastAddress[i];
                    }

                    CmdArgs->ARGS.TPSET.NumberMultAddrs++;

                } 
                else 
                {
                    AddressFound = TRUE;
                }

                NextMultAddr = NextMultAddr->Next;
            }

            if ( AddressFound == FALSE ) 
            {
                TpctlErrorLog("\n\tTpctl: The multicast address %02X",
                    (PVOID)GlobalCmdArgs.ARGS.TPSET.U.MulticastAddress[0][0]);
                TpctlErrorLog("-%02X",
                    (PVOID)GlobalCmdArgs.ARGS.TPSET.U.MulticastAddress[0][1]);
                TpctlErrorLog("-%02X",
                    (PVOID)GlobalCmdArgs.ARGS.TPSET.U.MulticastAddress[0][2]);
                TpctlErrorLog("-%02X",
                    (PVOID)GlobalCmdArgs.ARGS.TPSET.U.MulticastAddress[0][3]);
                TpctlErrorLog("-%02X",
                    (PVOID)GlobalCmdArgs.ARGS.TPSET.U.MulticastAddress[0][4]);
                TpctlErrorLog("-%02X has not been added.\n",
                    (PVOID)GlobalCmdArgs.ARGS.TPSET.U.MulticastAddress[0][5]);

                //
                // We will let the call go thru since we expect the driver to agree
                // with our findings which is the MA which is being deleted is not present
                //
                //
            }
            break;
        }

        case SEND:
            p = CmdArgs->ARGS.TPSEND.DestAddress;
            q = GlobalCmdArgs.ARGS.TPSEND.DestAddress;
            s = CmdArgs->ARGS.TPSEND.ResendAddress;
            t = GlobalCmdArgs.ARGS.TPSEND.ResendAddress;

            for ( i=0;i<ADDRESS_LENGTH;i++ ) 
            {
                *p++ = *q++;
                *s++ = *t++;
            }

            CmdArgs->ARGS.TPSEND.PacketSize =
                GlobalCmdArgs.ARGS.TPSEND.PacketSize;

            CmdArgs->ARGS.TPSEND.NumberOfPackets =
                GlobalCmdArgs.ARGS.TPSEND.NumberOfPackets;

            break;

        case STRESS:

            CmdArgs->ARGS.TPSTRESS.MemberType =
                GlobalCmdArgs.ARGS.TPSTRESS.MemberType;

            CmdArgs->ARGS.TPSTRESS.PacketType =
                GlobalCmdArgs.ARGS.TPSTRESS.PacketType;

            CmdArgs->ARGS.TPSTRESS.PacketSize =
                GlobalCmdArgs.ARGS.TPSTRESS.PacketSize;

            CmdArgs->ARGS.TPSTRESS.PacketMakeUp =
                GlobalCmdArgs.ARGS.TPSTRESS.PacketMakeUp;

            CmdArgs->ARGS.TPSTRESS.ResponseType =
                GlobalCmdArgs.ARGS.TPSTRESS.ResponseType;

            CmdArgs->ARGS.TPSTRESS.DelayType =
                GlobalCmdArgs.ARGS.TPSTRESS.DelayType;

            CmdArgs->ARGS.TPSTRESS.DelayLength =
                GlobalCmdArgs.ARGS.TPSTRESS.DelayLength;

            CmdArgs->ARGS.TPSTRESS.TotalIterations =
                GlobalCmdArgs.ARGS.TPSTRESS.TotalIterations;

            CmdArgs->ARGS.TPSTRESS.TotalPackets =
                GlobalCmdArgs.ARGS.TPSTRESS.TotalPackets;

            CmdArgs->ARGS.TPSTRESS.WindowEnabled =
                GlobalCmdArgs.ARGS.TPSTRESS.WindowEnabled;

            CmdArgs->ARGS.TPSTRESS.DataChecking =
                GlobalCmdArgs.ARGS.TPSTRESS.DataChecking;

            CmdArgs->ARGS.TPSTRESS.PacketsFromPool =
                GlobalCmdArgs.ARGS.TPSTRESS.PacketsFromPool;

            break;


        case REGISTRY :
            CmdArgs->ARGS.REGISTRY_ENTRY.OperationType = 
                GlobalCmdArgs.ARGS.REGISTRY_ENTRY.OperationType ;
            CmdArgs->ARGS.REGISTRY_ENTRY.KeyDatabase   = 
                GlobalCmdArgs.ARGS.REGISTRY_ENTRY.KeyDatabase   ;
            CmdArgs->ARGS.REGISTRY_ENTRY.ValueType     = 
                GlobalCmdArgs.ARGS.REGISTRY_ENTRY.ValueType     ;

            strcpy( CmdArgs->ARGS.REGISTRY_ENTRY.SubKey      , 
                    GlobalCmdArgs.ARGS.REGISTRY_ENTRY.SubKey );
            strcpy( CmdArgs->ARGS.REGISTRY_ENTRY.SubKeyClass , 
                    GlobalCmdArgs.ARGS.REGISTRY_ENTRY.SubKeyClass );

            strcpy( CmdArgs->ARGS.REGISTRY_ENTRY.SubKeyValueName, 
                    GlobalCmdArgs.ARGS.REGISTRY_ENTRY.SubKeyValueName );
            strcpy( CmdArgs->ARGS.REGISTRY_ENTRY.SubKeyValue, 
                    GlobalCmdArgs.ARGS.REGISTRY_ENTRY.SubKeyValue );

            break;


        case PERFCLIENT:
            p = CmdArgs->ARGS.TPPERF.PerfServerAddr;
            q = GlobalCmdArgs.ARGS.TPPERF.PerfServerAddr;
            s = CmdArgs->ARGS.TPPERF.PerfSendAddr;
            t = GlobalCmdArgs.ARGS.TPPERF.PerfSendAddr;

            for ( i=0;i<ADDRESS_LENGTH;i++ ) 
            {
                *p++ = *q++;
                *s++ = *t++;
            }
            CmdArgs->ARGS.TPPERF.PerfPacketSize = GlobalCmdArgs.ARGS.TPPERF.PerfPacketSize;
            CmdArgs->ARGS.TPPERF.PerfNumPackets = GlobalCmdArgs.ARGS.TPPERF.PerfNumPackets;
            CmdArgs->ARGS.TPPERF.PerfDelay = GlobalCmdArgs.ARGS.TPPERF.PerfDelay;
            CmdArgs->ARGS.TPPERF.PerfMode = GlobalCmdArgs.ARGS.TPPERF.PerfMode;
            break;

        case CLOSE:
        case RESET:
        case STOPSEND:
        case WAITSEND:
        case RECEIVE:
        case STOPREC:
        case GETEVENTS:
        case STRESSSERVER:
        case ENDSTRESS:
        case WAITSTRESS:
        case CHECKSTRESS:
        case WAIT:
        case VERBOSE:
        case BREAKPOINT:
        case QUIT:
        case HELP:
        case SHELL:
        case RECORDINGDISABLE:
        case DISABLE:
        case ENABLE:
        case PERFSERVER:
            break;

        default:
            TpctlErrorLog("TpctlInitCommandBuffer: Invalid Command code.\n",NULL);
            break;

    } // switch();

    return TRUE;
}



LPSTR
TpctlGetEventType(
    TP_EVENT_TYPE TpEventType
    )
{
    static TP_EVENT_TYPE Event[] = {
        CompleteOpen,
        CompleteClose,
        CompleteSend,
        CompleteTransferData,
        CompleteReset,
        CompleteRequest,
        IndicateReceive,
        IndicateReceiveComplete,
        IndicateStatus,
        IndicateStatusComplete,
        Unknown
    };

#define EventCount (sizeof(Event)/sizeof(TP_EVENT_TYPE))

    static LPSTR EventString[] = {  // BUGUBUG Add new events open close...
        "NdisCompleteOpen",
        "NdisCompleteClose",
        "NdisCompleteSend",
        "NdisCompleteTransferData",
        "NdisCompleteReset",
        "NdisCompleteRequest",
        "NdisIndicateReceive",
        "NdisIndicateReceiveComplete",
        "NdisIndicateStatus",
        "NdisIndicateStatusComplete",
        "Unknown Function"
    };

    static BYTE BadEvent[] = "UNDEFINED";
    DWORD i;


    for (i=0; i<EventCount; i++) 
    {
        if (TpEventType == Event[i]) 
        {
            return EventString[i];
        }
    }

    return BadEvent;

#undef StatusCount
}



LPSTR
TpctlGetStatus(
    NDIS_STATUS GeneralStatus
    )
{

    static NDIS_STATUS Status[] = {
        NDIS_STATUS_SUCCESS,
        NDIS_STATUS_PENDING,
        NDIS_STATUS_NOT_RECOGNIZED,
        NDIS_STATUS_NOT_COPIED,
        NDIS_STATUS_ONLINE,
        NDIS_STATUS_RESET_START,
        NDIS_STATUS_RESET_END,
        NDIS_STATUS_RING_STATUS,
        NDIS_STATUS_CLOSED,

        NDIS_STATUS_WAN_LINE_UP,
        NDIS_STATUS_WAN_LINE_DOWN,
        NDIS_STATUS_WAN_FRAGMENT,

        NDIS_STATUS_NOT_RESETTABLE,
        NDIS_STATUS_SOFT_ERRORS,
        NDIS_STATUS_HARD_ERRORS,
        NDIS_STATUS_FAILURE,
        NDIS_STATUS_RESOURCES,
        NDIS_STATUS_CLOSING,
        NDIS_STATUS_BAD_VERSION,
        NDIS_STATUS_BAD_CHARACTERISTICS,
        NDIS_STATUS_ADAPTER_NOT_FOUND,
        NDIS_STATUS_OPEN_FAILED,
        NDIS_STATUS_DEVICE_FAILED,
        NDIS_STATUS_MULTICAST_FULL,
        NDIS_STATUS_MULTICAST_EXISTS,
        NDIS_STATUS_MULTICAST_NOT_FOUND,
        NDIS_STATUS_REQUEST_ABORTED,
        NDIS_STATUS_RESET_IN_PROGRESS,
        NDIS_STATUS_CLOSING_INDICATING,
        NDIS_STATUS_NOT_SUPPORTED,
        NDIS_STATUS_INVALID_PACKET,
        NDIS_STATUS_OPEN_LIST_FULL,
        NDIS_STATUS_ADAPTER_NOT_READY,
        NDIS_STATUS_ADAPTER_NOT_OPEN,
        NDIS_STATUS_NOT_INDICATING,
        NDIS_STATUS_INVALID_LENGTH,
        NDIS_STATUS_INVALID_DATA,
        NDIS_STATUS_BUFFER_TOO_SHORT,
        NDIS_STATUS_INVALID_OID,
        NDIS_STATUS_ADAPTER_REMOVED,
        NDIS_STATUS_UNSUPPORTED_MEDIA,
        NDIS_STATUS_GROUP_ADDRESS_IN_USE,
        NDIS_STATUS_FILE_NOT_FOUND,
        NDIS_STATUS_ERROR_READING_FILE,
        NDIS_STATUS_ALREADY_MAPPED,
        NDIS_STATUS_RESOURCE_CONFLICT,
        NDIS_STATUS_TOKEN_RING_OPEN_ERROR,
        TP_STATUS_NO_SERVERS,
        TP_STATUS_NO_EVENTS
    };

#define StatusCount (sizeof(Status)/sizeof(NDIS_STATUS))

    static PUCHAR String[] = {
        "NDIS_STATUS_SUCCESS",
        "NDIS_STATUS_PENDING",
        "NDIS_STATUS_NOT_RECOGNIZED",
        "NDIS_STATUS_NOT_COPIED",
        "NDIS_STATUS_ONLINE",
        "NDIS_STATUS_RESET_START",
        "NDIS_STATUS_RESET_END",
        "NDIS_STATUS_RING_STATUS",
        "NDIS_STATUS_CLOSED",
        "NDIS_STATUS_WAN_LINE_UP",
        "NDIS_STATUS_WAN_LINE_DOWN",
        "NDIS_STATUS_WAN_FRAGMENT",
        "NDIS_STATUS_NOT_RESETTABLE",
        "NDIS_STATUS_SOFT_ERRORS",
        "NDIS_STATUS_HARD_ERRORS",
        "NDIS_STATUS_FAILURE",
        "NDIS_STATUS_RESOURCES",
        "NDIS_STATUS_CLOSING",
        "NDIS_STATUS_BAD_VERSION",
        "NDIS_STATUS_BAD_CHARACTERISTICS",
        "NDIS_STATUS_ADAPTER_NOT_FOUND",
        "NDIS_STATUS_OPEN_FAILED",
        "NDIS_STATUS_DEVICE_FAILED",
        "NDIS_STATUS_MULTICAST_FULL",
        "NDIS_STATUS_MULTICAST_EXISTS",
        "NDIS_STATUS_MULTICAST_NOT_FOUND",
        "NDIS_STATUS_REQUEST_ABORTED",
        "NDIS_STATUS_RESET_IN_PROGRESS",
        "NDIS_STATUS_CLOSING_INDICATING",
        "NDIS_STATUS_NOT_SUPPORTED",
        "NDIS_STATUS_INVALID_PACKET",
        "NDIS_STATUS_OPEN_LIST_FULL",
        "NDIS_STATUS_ADAPTER_NOT_READY",
        "NDIS_STATUS_ADAPTER_NOT_OPEN",
        "NDIS_STATUS_NOT_INDICATING",
        "NDIS_STATUS_INVALID_LENGTH",
        "NDIS_STATUS_INVALID_DATA",
        "NDIS_STATUS_BUFFER_TOO_SHORT",
        "NDIS_STATUS_INVALID_OID",
        "NDIS_STATUS_ADAPTER_REMOVED",
        "NDIS_STATUS_UNSUPPORTED_MEDIA",
        "NDIS_STATUS_GROUP_ADDRESS_IN_USE",
        "NDIS_STATUS_FILE_NOT_FOUND",
        "NDIS_STATUS_ERROR_READING_FILE",
        "NDIS_STATUS_ALREADY_MAPPED",
        "NDIS_STATUS_RESOURCE_CONFLICT",
        "NDIS_STATUS_TOKEN_RING_OPEN_ERROR",
        "TP_STATUS_NO_SERVERS",
        "TP_STATUS_NO_EVENTS"
    };

    static BYTE BadStatus[] = "UNDEFINED";
    DWORD i;

    for (i=0; i<StatusCount; i++) 
    {
        if (GeneralStatus == Status[i]) 
        {
            return String[i];
        }
    }
    return BadStatus;

#undef StatusCount
}



DWORD
TpctlGetCommandCode(
    LPSTR Argument
    )

{
    DWORD i;

    for ( i=1;i<NUM_COMMANDS;i++ ) 
    {
        if (_stricmp(  Argument, CommandCode[i].CmdAbbr ) == 0 ) 
        {
            return CommandCode[i].CmdCode;
        }

        if (_stricmp( Argument, CommandCode[i].CmdName ) == 0 ) 
        {
            return CommandCode[i].CmdCode;
        }
    }
    return CMD_ERR;
}



LPSTR
TpctlGetCommandName(
    LPSTR Command
    )

{
    DWORD i;

    for ( i=1;i<NUM_COMMANDS;i++ ) 
    {
        if (_stricmp(Command,CommandCode[i].CmdAbbr) == 0 ) 
        {
            return CommandCode[i].CmdName;
        }
        if (_stricmp(Command,CommandCode[i].CmdName) == 0 ) 
        {
            return CommandCode[i].CmdName;
        }
    }
    return CommandCode[CMD_ERR].CmdName;
}



LPSTR
TpctlGetCmdCode(
    DWORD CmdCode
    )
{
    static BYTE BadCmdCode[] = "UNDEFINED";

    DWORD i;

    for(i=1; i<NUM_COMMANDS; i++) 
    {
        if ( CmdCode == CommandCode[i].CmdCode ) 
        {
            return(CommandCode[i].CmdName);
        }
    }
    return BadCmdCode;
}



VOID
TpctlCopyAdapterAddress(
    DWORD OpenInstance,
    PREQUEST_RESULTS Results
    )
{
    DWORD i;
    PUCHAR Source, Destination;

    //
    // Sanjeevk: Bug# 5203: This routine needed modification to support
    //                      the additional NDIS_MEDIUM information sent
    //                      back
    //

    Source      =  (PUCHAR)( Results->InformationBuffer + sizeof( NDIS_MEDIUM ) );
    Destination =  (PUCHAR)( Open[OpenInstance].AdapterAddress );

    for (i=0;i<ADDRESS_LENGTH;i++) 
    {
        *Destination++ = *Source++;
    }
}



VOID
TpctlRecordArguments(
    IN TESTPARAMS Options[],
    IN DWORD      OptionTableSize,
    IN DWORD      argc,
    IN LPSTR      argv[TPCTL_MAX_ARGC]
    )

// -----------------
// 
// Routine Description:
// 
//     Create   Sanjeevk  7-1-93
// 
//     This function is responsible for creating the command in parts and records
//     it to the file accessed by ScriptRecordHandle
// 
// Arguments:
// 
//     Options          The TestParameter options from which the command is created
// 
//     OptionTableSize  The size of the table for the option under consideration
// 
//     argc             The number of arguments passed on the TPCTL command line
//                      prompt
// 
//     argv             The arguments passed on the TPCTL command line prompt
// 
// 
// Return Value:
// 
//     None
// 
// -------------------


{
    DWORD  i;
    CHAR   TmpBuffer[256];
    DWORD  BytesWritten,Status  ;
    DWORD  CmdCode = TpctlGetCommandCode( argv[0] );


    //
    // 1. Clear the temporary buffer which will be used to construct an option
    //    one at a time
    //
    ZeroMemory ( TmpBuffer, 256 );

    //
    // 2. Attempt to access the complete name of the command code.
    //
    if ( CmdCode == CMD_ERR ) 
    {
        sprintf( TmpBuffer, "%s", argv[0] );
    } 
    else 
    {
        sprintf( TmpBuffer, "%s", TpctlGetCommandName(argv[0]) );
    }

    //
    // 3. Write the first argument accessed into the script file
    //

    if ( !WriteFile(ScriptRecordHandle,
                    TmpBuffer,
                    strlen( TmpBuffer ),
                    &BytesWritten,
                    NULL )) 
    {
        Status = GetLastError();
        printf("\n\tTpctlRecordArguments: write to script record file failed, returned 0x%lx\n",
                Status);
        return;
    }

    //
    // 4. Set up the buffer for reuse
    //
    ZeroMemory ( TmpBuffer, 256 );

    //
    // 5. Now for the number of argument passed on the TPCTL command prompt, reconstruct
    //    each sub option one at a time
    //
    for( i = 1; i < argc; i++ ) 
    {
        //
        // 5.a Check if a valid Option Table has been provided and if so get the
        //     the lvalue and rvalue and combine them to form an expression
        //
    
        if ( Options != NULL ) 
        {
            sprintf( TmpBuffer, "\t+\n  %s=%s", Options[i-1].ArgName, argv[i] );
        } 
        else 
        {
            if ( CmdCode != CMD_ERR ) 
            {
                sprintf( TmpBuffer, "\t+\n  %s", argv[i] );
            } 
            else 
            {
                sprintf( TmpBuffer, " %s", argv[i] );
            }
        }

        //
        // 5.b Write this reconstructed string which now signifies the complete
        //     sub-option into the script file
        //
    
        if ( !WriteFile(ScriptRecordHandle,
                        TmpBuffer,
                        strlen( TmpBuffer ),
                        &BytesWritten,
                        NULL )) 
        {
            Status = GetLastError();
            printf("\n\tTpctlRecordArguments: write to script record file failed, returned 0x%lx\n",
                        Status);
            return;
        }

        //
        // 5.c And clear the buffer for reuse(next sub-option)
        //
        ZeroMemory ( TmpBuffer, 256 );

    }

    //
    // 6. Since it is possible to specifiy one or more suboptions and the command prompt
    //    we must dteremine all of the lvalues and rvalues of the current option
    //    Since we can also specify a semicolon to accept default values, we must
    //    carefully consider the various types of data associated with the rvalues
    //
    for( i = argc; i <= OptionTableSize; i++ ) 
    {
        PUCHAR p;

        switch ( Options[i-1].TestType ) 
        {
            case Integer :
                sprintf( TmpBuffer, "\t+\n  %s=%ld", Options[i-1].ArgName, 
                                                     *(PDWORD)Options[i-1].Destination );
                break;

            case String :
                sprintf(TmpBuffer, "\t+\n  %s=%s", Options[i-1].ArgName, Options[i-1].Destination);
                break;

            case Address4 :
                p = Options[i-1].Destination;
                sprintf( TmpBuffer, "\t+\n  %s=%02x-%02x-%02x-%02x", Options[i-1].ArgName,
                         *p, *(p+1), *(p+2), *(p+3) );
                break;

            case Address6 :
                p = Options[i-1].Destination;
                sprintf( TmpBuffer, "\t+\n  %s=%02x-%02x-%02x-%02x-%02x-%02x", Options[i-1].ArgName,
                         *p, *(p+1), *(p+2), *(p+3), *(p+4), *(p+5) );
                break;

            case ParsedInteger :
                p = Options[i-1].Destination;
                sprintf( TmpBuffer, "\t+\n  %s=0x%4.4x", Options[i-1].ArgName, *(LPDWORD)p );
                break;
        }

        if ( !WriteFile(ScriptRecordHandle,
                        TmpBuffer,
                        strlen( TmpBuffer ),
                        &BytesWritten,
                        NULL )) 
        {
            Status = GetLastError();
            printf("\n\tTpctlRecordArguments: write to script record file failed, returned 0x%lx\n",                    Status);
            return;
        }

        ZeroMemory ( TmpBuffer, 256 );

    }

    //
    // 7. Finally add the newline to end the command
    //
    sprintf( TmpBuffer, "\n\n" );
    if ( !WriteFile(ScriptRecordHandle,
                    TmpBuffer,
                    strlen( TmpBuffer ),
                    &BytesWritten,
                    NULL )) 
    {
        Status = GetLastError();
        printf("\n\tTpctlRecordArguments: write to script record file failed, returned 0x%lx\n",
                Status);
    }

}


LPSTR
TpctlEnumerateRegistryInfo(
     IN PUCHAR TmpBuf,
     IN PUCHAR DbaseName,
     IN PUCHAR SubKeyName,
     IN PUCHAR ValueName,
     IN DWORD  ReadValueType,
     IN PUCHAR ReadValue,
     IN DWORD  ReadValueSize )
{

    INT     i;

    TmpBuf += sprintf( TmpBuf, 
                        "\tDataBase Name  = %s\n\tSub Key Name   = %s\n\tValue Name     = %s\n",
                        DbaseName, SubKeyName, ValueName );

    TmpBuf += sprintf( TmpBuf, "\tValue Type     = %s\n", TpctlGetValueType( ReadValueType ) );

    switch( ReadValueType ) 
    {
        case REG_BINARY :
            TmpBuf += sprintf( TmpBuf, "\tValue(IN HEX)  = ");
            for( i = 0; i < (INT)ReadValueSize; i++ ) 
            {
                if ( i%6 || (i == 0) ) 
                {
                    TmpBuf += sprintf( TmpBuf, "%2.2x ", ReadValue[i] );
                } 
                else 
                {
                    TmpBuf += sprintf( TmpBuf, "\n\t                 %2.2x ", ReadValue[i] );
                }
            }
            TmpBuf += sprintf( TmpBuf, "\n" );
            break;

        case REG_DWORD :
            TmpBuf += sprintf( TmpBuf, "\tValue          = 0x%lx\n", *(LPDWORD)ReadValue );
            break;

            //
            // This code section had to be commented out because the idiot who defined
            // the types made LITTLE_ENDIAN = DWORD. If we were to port over to a
            // BIG_ENDIAN system, we would have to comment out the code for BIG_ENDIAN
            //
            //  case REG_DWORD_LITTLE_ENDIAN :
            //      TmpBuf += sprintf( TmpBuf, "\tValue = LITTLE_ENDIAN 0x" );
            //      for( i = 0 ; i < ReadValueSize ; i++ ) 
            //      {
            //          TmpBuf += sprintf( TmpBuf, "%2.2x", ReadValue[i] );
            //      }
            //      TmpBuf += sprintf( TmpBuf, " DWORD VALUE 0x%lx\n",  *(LPDWORD)ReadValue );
            //      break;

        case REG_DWORD_BIG_ENDIAN:
            TmpBuf += sprintf( TmpBuf, "\tValue          = BIG_ENDIAN 0x" );
            for( i =  0 ; i < (INT)ReadValueSize ; i++ ) 
            {
                TmpBuf += sprintf( TmpBuf, "%2.2x", ReadValue[i] );
            }
            TmpBuf += sprintf( TmpBuf, " DWORD VALUE 0x" );
            for( i =  0 ; i < (INT)ReadValueSize ; i++ ) 
            {
                TmpBuf += sprintf( TmpBuf, "%2.2x", ReadValue[i] );
            }
            TmpBuf += sprintf( TmpBuf, "\n" );
            break;

        case REG_LINK:
        case REG_EXPAND_SZ:
            TmpBuf += sprintf( TmpBuf, "\tValue          = %s\n", ReadValue );
            break;

        case REG_MULTI_SZ:
            TmpBuf += sprintf( TmpBuf, "\tValue(s)\n" );
            {
                PUCHAR Tmp1 = ReadValue;

                while ( strlen( Tmp1 ) != 0 ) 
                {
                    TmpBuf += sprintf( TmpBuf, "\t\t%s\n", Tmp1 );
                    Tmp1   += (strlen( Tmp1 ) + 1);
                }
            }
            break;

        case REG_NONE:
            TmpBuf += sprintf( TmpBuf, "\tValue          = %s\n", ReadValue );
            break;

        case REG_RESOURCE_LIST:
            TmpBuf += sprintf( TmpBuf, "\tValue          = %s\n", ReadValue );
            break;

        case REG_SZ:
            TmpBuf += sprintf( TmpBuf, "\tValue          = %s\n", ReadValue );
            break;

        default:
            TmpBuf += sprintf( TmpBuf, "\tValue          = UNKNOWN\n" );
            break;

    }

    return TmpBuf;

}


LPSTR
TpctlGetValueType(
    IN DWORD ValueType
                 )
{
    static UCHAR ValueTypeString[20];

    ZeroMemory( ValueTypeString, 20 );

    switch ( ValueType ) 
    {
        case REG_BINARY :
            strcpy( ValueTypeString, "REG_BINARY" );
            break;

        case REG_DWORD :
            strcpy( ValueTypeString, "REG_DWORD" );
            break;
            //
            // This code section had to be commented out because the idiot who defined
            // the types made LITTLE_ENDIAN = DWORD. If we were to port over to a
            // BIG_ENDIAN system, we would have to comment out the code for BIG_ENDIAN
            //
            //  case REG_DWORD_LITTLE_ENDIAN :
            //      strcpy( ValueTypeString, "REG_DWORD_LITTLE_ENDIAN" );
            //      break;
            //

        case REG_DWORD_BIG_ENDIAN :
            strcpy( ValueTypeString, "REG_DWORD_BIG_ENDIAN" );
            break;

        case REG_EXPAND_SZ :
            strcpy( ValueTypeString, "REG_EXPAND_SZ" );
            break;

        case REG_LINK :
            strcpy( ValueTypeString, "REG_LINK" );
            break;

        case REG_MULTI_SZ :
            strcpy( ValueTypeString, "REG_MULTI_SZ" );
            break;

        case REG_NONE :
            strcpy( ValueTypeString, "REG_NONE" );
            break;

        case REG_RESOURCE_LIST :
            strcpy( ValueTypeString, "REG_RESOURCE_LIST" );
            break;

        case REG_SZ :
            strcpy( ValueTypeString, "REG_SZ" );
            break;

        default :
            strcpy( ValueTypeString, "UNDEFINED" );
            break;
    }

    return ValueTypeString;

}