summaryrefslogtreecommitdiffstats
path: root/private/ntos/ndis/testprot/tpctl/tpctl.h
blob: 129562c1faafb8fada9c5cd38b3e6ad61d6d6583 (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
// -----------------------------------
//
// Copyright (c) 1990 Microsoft Corporation
//
// Module Name:
//
//     tpctl.h
//
// Abstract:
//
//     This module defines the external definitions used for the MAC Tester
//
// Author:
//
//     Tom Adams (tomad) 11-May-1991
//
// Revision History:
//
//     11-May-1991    tomad
//          Created
//
//      4-27-94     timothyw
//          Added performance test; CPP style comments
//      5-18-94
//          Added globvars; fixed warnings
//      6-08-94
//          chgs for client/server model, perf tests
//
// -----------------------------------

#include "tp_ndis.h"
#include "common.h"

//
//
//

extern CMD_ARGS GlobalCmdArgs;

extern LPSTR GlobalBuf;

extern BOOL Verbose;

extern BOOL CommandsFromScript;

extern BOOL CommandLineLogging;

extern BOOL RecordToScript;

extern HANDLE CommandLineLogHandle;

extern HANDLE ScriptRecordHandle;

extern CHAR RecordScriptName[TPCTL_MAX_PATHNAME_SIZE];

extern BOOL ExitFlag;

extern BOOL ContinueLooping;

extern INT TpctlSeed;

//
// Script Control is used to keep track of where in a script file the
// application is, and where to log the next set of results in the
// respective log file.
//

typedef struct _SCRIPTCONTROL {
    LPSTR ScriptFile;
    BOOL IsLowestLevel;
    LPBYTE Buffer;
    DWORD Length;

    DWORD BufIndex;
    HANDLE LogHandle;
    LPSTR LogFile;
} SCRIPTCONTROL, * PSCRIPTCONTROL;

//
// Scripts is an array of 10 script control structures allowing recursion
// of upto ten script files at any one time.  Any more then 10 and an error
// occurs resulting in the closing of all upper recursive levels of script
// files.
//

#define TPCTL_MAX_SCRIPT_LEVELS 10

extern SCRIPTCONTROL Scripts[TPCTL_MAX_SCRIPT_LEVELS+1];

extern DWORD ScriptIndex;

//
// Initialize the script array.
//

// ------
//
// VOID
// TpctlInitializeScripts(
//     VOID
//     );
//
// -----

#define TpctlInitializeScripts() {              \
    DWORD i;                                    \
    ScriptIndex = 0xFFFFFFFF;                   \
    for (i=0;i<TPCTL_MAX_SCRIPT_LEVELS+1;i++) { \
        Scripts[i].ScriptFile = NULL;           \
        Scripts[i].IsLowestLevel = FALSE;       \
        Scripts[i].Buffer = NULL;               \
        Scripts[i].Length = 0;                  \
        Scripts[i].BufIndex = 0;                \
        Scripts[i].LogHandle = (HANDLE)-1;      \
        Scripts[i].LogFile = NULL;              \
    }                                           \
}

//
// TPCTLCLOSESCRIPTS close any and all script files that
// are currently opened.
//

// -----
//
// VOID
// TpctlCloseScripts(
//     VOID
//     );
//
// -----

#define TpctlCloseScripts() {                   \
    if ( CommandsFromScript == TRUE ) {         \
        while ( ScriptIndex != (ULONG)-1 ) {    \
            TpctlUnLoadFiles();                 \
        }                                       \
    }                                           \
}

//
// PRINT_DIFF_FLAG will print the diff flag string S into the buffer B
// if we are printing the results to a logfile.
//

// -----
//
// VOID
// ADD_DIFF_FLAG(
//     LPSTR B
//     LPSTR S
//     );
//
// -----

#define ADD_DIFF_FLAG( B,S ) {                               \
    if (( CommandsFromScript ) || ( CommandLineLogging )) {  \
        B += (BYTE)sprintf(B,"\t%s",S);                      \
    }                                                        \
    TmpBuf += (BYTE)sprintf(TmpBuf,"\n");                    \
}

#define ADD_SKIP_FLAG( B,S )    ADD_DIFF_FLAG( B,S )

//
// Reset all opens to their initial state.
//

// -----
//
// VOID
// TpctlResetAllOpenStates(
//     HANDLE fh
//     );
//
// -----

#define TpctlResetAllOpenStates( fh ) {                \
    DWORD i;                                           \
    if ( CommandsFromScript ) {                        \
        TpctlErrorLog("\n\tTpctl: Resetting the state of all Open Instances.\n",NULL); \
        for ( i = 0 ; i < NUM_OPEN_INSTANCES ; i++ ) { \
            TpctlResetOpenState( &Open[i],fh );        \
        }                                              \
    }                                                  \
}

//
// Parse Tables are the structures used to contain each of the possible
// argument names for a given command, and their value.
//

typedef struct _ParsedIntTable {
    LPSTR    FieldName;
    DWORD  FieldValue;
} PARSETABLE, *PPARSETABLE;

//
// Paramtypes are the different types of parameters that may be parsed
// by the ParseOptions routine for each command.
//

//
// STARTCHANGE
//
typedef enum {
    Integer,
    String,
    ParsedInteger,
//    Address2,        // Accomodate 802.3, 802.4, 802.5, FDDI addresses
    Address4,        // Accomodate 802.4, 802.5 addresses
    Address6,        // Accomodate 802.3, 802.4, 802.5, FDDI addresses
//    Address2or6      // Conjugate type in which addresses can be 2 or 6 octets
} PARAMTYPES;
//
// STOPCHANGE
//


//
// The Test Options structures is used by the ParseOptions routine to
// load the default value for a given argument, set up the prompt for
// the argument and prompt the user for the argument.  If the command is
// entered from a script file the Test Options structures is used to
// determine the Argument names or abbreviations and then stores the
// values in their proper destinations.
//

typedef struct _TestOptions {
    DWORD       OptionNumber;
    LPSTR       TestPrompt;
    LPSTR       ArgName;
    LPSTR       ArgNameAbbr;
    BOOL        ArgValueSet;
    PARAMTYPES  TestType;
    DWORD       IntegerDefault;
    LPSTR       StringDefault;
    PPARSETABLE ParsedIntTable;
    DWORD       ParsedIntTableSize;
    PVOID       Destination;
} TESTPARAMS, *PTESTPARAMS;

//
// Array entries for the Events in the Open Block
//

typedef enum {
    TPCONTROL,
    TPSTRESS,
    TPSEND,
    TPRECEIVE,
    TPPERF
} TPEVENT_TYPE;

//
// Multicast Address struct used to create a list of all the
// address set on a given open.
//

typedef struct _MULT_ADDR {
    struct _MULT_ADDR *Next;
    BYTE MulticastAddress[ADDRESS_LENGTH];
} MULT_ADDR, *PMULT_ADDR;

//
// the Open Block holding the info about the state of the open,
// particulars about the card opened, and the control structs for
// each of the given test types.
//

typedef struct _OPEN_BLOCK {
    DWORD Signature;
    UCHAR OpenInstance;
    BOOL AdapterOpened;
    NDIS_MEDIUM MediumType;
    DWORD NdisVersion;

    LPBYTE AdapterName;
    BYTE AdapterAddress[ADDRESS_LENGTH];
    PENVIRONMENT_VARIABLES EnvVars;

    BOOL EventThreadStarted;
    HANDLE Events[5];

    BOOL Stressing;
    PCMD_ARGS StressArgs;
    IO_STATUS_BLOCK StressStatusBlock;
    HANDLE StressEvent;
    PSTRESS_RESULTS StressResults;
    BOOL StressResultsCompleted;
    BOOL StressClient;
    BOOL Ack10;

    BOOL Sending;
    PCMD_ARGS SendArgs;
    IO_STATUS_BLOCK SendStatusBlock;
    HANDLE SendEvent;
    PSEND_RECEIVE_RESULTS SendResults;
    BOOL SendResultsCompleted;

    BOOL Receiving;
    IO_STATUS_BLOCK ReceiveStatusBlock;
    HANDLE ReceiveEvent;
    PSEND_RECEIVE_RESULTS ReceiveResults;
    BOOL ReceiveResultsCompleted;

    IO_STATUS_BLOCK PerfStatusBlock;
    HANDLE PerfEvent;
    PPERF_RESULTS PerfResults;
    BOOL   PerfResultsCompleted;

    DWORD PacketFilter;

    DWORD LookaheadSize;
    PMULT_ADDR MulticastAddresses;
    ULONG NumberMultAddrs;
    BYTE FunctionalAddress[FUNCTIONAL_ADDRESS_LENGTH];

    BYTE GroupAddress[FUNCTIONAL_ADDRESS_LENGTH];
} OPEN_BLOCK, *POPEN_BLOCK;

extern OPEN_BLOCK Open[NUM_OPEN_INSTANCES];

#define OPEN_BLOCK_SIGNATURE 0x12121212

//
// TPCTL.C function prototypes
//

DWORD
TpctlInitializeOpenArray(
    VOID
    );

VOID
TpctlFreeOpenArray(
    VOID
    );

DWORD
TpctlOpenTpdrvr(
    IN OUT PHANDLE lphFileHandle
    );

VOID
TpctlCloseTpdrvr(
    IN HANDLE hFileHandle
    );

DWORD
TpctlStartEventHandlerThread(
    IN POPEN_BLOCK Open
    );

VOID
TpctlStopEventHandlerThread(
    IN POPEN_BLOCK Open
    );

DWORD
TpctlEventHandler(
    IN LPVOID Open
    );

BOOL
TpctlCtrlCHandler(
    IN DWORD CtrlType
    );

//
//
//

DWORD
TpctlRunTest(
    IN HANDLE hFileHandle
    );

VOID
TpctlGetEvents(
    IN HANDLE FileHandle,
    IN HANDLE InputBuffer,
    IN DWORD InputBufferSize
    );

VOID
TpctlPauseGo(
    IN HANDLE FileHandle,
    IN HANDLE InputBuffer,
    IN DWORD InputBufferSize,
    IN DWORD CmdCode
    );

DWORD
TpctlResetOpenState(
    IN POPEN_BLOCK Open,
    IN HANDLE FileHandle
    );

VOID
TpctlLoadUnload(
    IN DWORD CmdCode
    );

VOID
TpctlQueryStatistics(
    IN PUCHAR DriverName,
    IN NDIS_OID OID,
    IN PUCHAR StatsBuffer,
    IN DWORD BufLen
    );

BOOL
Disable(
    IN DWORD argc,
    IN LPSTR argv[]
       );

//
//
//


VOID
TpctlPrintResults(
    PREQUEST_RESULTS Results,
    DWORD CmdCode,
    NDIS_OID OID
    );

VOID
TpctlPrintQueryInfoResults(
    PREQUEST_RESULTS Results,
    DWORD CmdCode,
    NDIS_OID OID
    );

VOID
TpctlPrintSetInfoResults(
    PREQUEST_RESULTS Results,
    DWORD CmdCode,
    NDIS_OID OID
    );

VOID
TpctlPrintSendResults(
    PSEND_RECEIVE_RESULTS Results
    );

VOID
TpctlPrintReceiveResults(
    PSEND_RECEIVE_RESULTS Results
    );

VOID
TpctlPrintPerformResults(
    PPERF_RESULTS Results
    );

VOID
TpctlPrintStressResults1(
    IN PSTRESS_RESULTS Results,
    IN BOOL Ack10
    );

VOID
TpctlPrintStressResults(
    PSTRESS_RESULTS Results,
    IN BOOL Ack10
    );

VOID
TpctlPrintEventResults(
    PEVENT_RESULTS Event
    );

VOID
TpctlZeroStressStatistics(
    PSTRESS_RESULTS Results
    );

DWORD
TpctlLog(
    LPSTR String,
    PVOID Input
    );

DWORD
TpctlErrorLog(
    LPSTR String,
    PVOID Input
    );

DWORD
TpctlScriptLog(
    LPSTR String,
    PVOID Input
    );

DWORD
TpctlCmdLneLog(
    LPSTR String,
    PVOID Input
    );

//
// CMD.C function prototypes
//

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

VOID
TpctlUsage(
    VOID
    );

VOID
TpctlHelp(
    LPSTR Command
    );

DWORD
TpctlLoadFiles(
    IN LPSTR ScriptFile,
    IN LPSTR LogFile
    );


VOID
TpctlUnLoadFiles(
    VOID
    );


HANDLE
TpctlOpenLogFile(
    VOID
    );


VOID
TpctlCloseLogFile(
    VOID
    );


HANDLE
TpctlOpenScriptFile(
    VOID
    );


VOID
TpctlCloseScriptFile(
    VOID
    );

DWORD
TpctlReadCommand(
    IN LPSTR Prompt,
    OUT LPSTR Response,
    IN DWORD MaximumResponse
    );


BOOL
TpctlParseCommand(
    IN LPSTR CommandLine,
    OUT LPSTR Argv[],
    OUT PDWORD Argc,
    IN DWORD MaxArgc
    );


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


VOID
TpctlLoadLastEnvironmentVariables(
    DWORD OpenInstance
    );


VOID
TpctlSaveNewEnvironmentVariables(
    DWORD OpenInstance
    );

VOID
TpctlPerformRegistryOperation(
                    IN PCMD_ARGS CmdArgs
                             );
BOOL
TpctlInitCommandBuffer(
    IN OUT PCMD_ARGS CmdArgs,
    IN DWORD CmdType
    );


LPSTR
TpctlGetEventType(
    TP_EVENT_TYPE TpEventType
    );


LPSTR
TpctlGetStatus(
    NDIS_STATUS GeneralStatus
    );


DWORD
TpctlGetCommandCode(
    LPSTR Argument
    );


LPSTR
TpctlGetCommandName(
    LPSTR Command
    );

LPSTR
TpctlGetCmdCode(
    DWORD CmdCode
    );


VOID
TpctlCopyAdapterAddress(
    DWORD OpenInstance,
    PREQUEST_RESULTS Results
    );

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

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

LPSTR
TpctlGetValueType(
    IN DWORD ValueType
    );


//
// PARSE.C Function Prototypes
//

DWORD
TpctlParseArguments(
    IN TESTPARAMS Options[],
    IN DWORD TestSize,
    IN DWORD ArgC,
    IN LPSTR ArgV[]
    );


BOOL
TpctlParseSetInfoArguments(
    IN OUT DWORD *ArgC,
    IN OUT LPSTR ArgV[],
    IN OUT DWORD *tmpArgC,
    IN OUT LPSTR tmpArgV[]
    );


DWORD
TpctlParseAddress(
    IN BYTE Buffer[],
    OUT PDWORD Ret,
    IN DWORD OpenInstance,
    IN DWORD AddressLength
    );


VOID
Dump_Desired_PacketFilter(
    LPSTR Buffer,
    DWORD PacketFilter
    );


VOID
Dump_Information_Class(
    LPSTR Buffer,
    DWORD InfoClass
    );


VOID
Dump_Ndis_Medium(
    LPSTR Buffer,
    DWORD Medium
    );

//
// GLOBALS.C Function Prototypes
//


PVOID
TpctlParseGlobalVariable(
    IN BYTE         Buffer[],
    IN PARAMTYPES   reqtype
    );

VOID
TpctlInitGlobalVariables(
    VOID
    );


DWORD
TpctlParseSet(
    IN DWORD ArgC,
    IN LPSTR ArgV[]
    );


// functions from cpuperf.c


VOID     CpuUsageInit(VOID);


ULONG    CpuUsageGetData(PULONG *KernPercent,
                         ULONG  NumCpus);