This repository has been archived by the owner on Nov 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_flag.js
executable file
·132 lines (116 loc) · 2.84 KB
/
get_flag.js
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
#!/usr/bin/env node
// Tx flag generator!
// Only for IWLWIFI 5300 card!
// ? Configuration Part
/* High-throughput (HT) mode [20|40] */
let HTMode = process.argv[2];
/* HT rate format
* 0) 6 Mbps
* 1) 12 Mbps
* 2) 18 Mbps
* 3) 24 Mbps
* 4) 36 Mbps
* 5) 48 Mbps
* 6) 54 Mbps
* 7) 60 Mbps
*/
let DataRateCode = process.argv[3];
/* The number of Antennas [1-3] */
let AntennaCount = process.argv[4];
// ! Assertion & Generation Part
/* Check inputs */
let AntennaSelection = Number(AntennaCount);
let DataRate = Number(DataRateCode);
if (process.argv.length !== 5) {
const sep = process.argv[1].indexOf('\\') >= 0 ? '\\' : '/';
const file = process.argv[1].substring(process.argv[1].lastIndexOf(sep) + 1);
console.info(`Usage: ${file} HT_MODE DATA_RATE ANTENNA_COUNT\n`);
console.info(' HT_MODE = [20|40]');
console.info(' DATA_RATE = [0-7]');
console.info(' ANTENNA_COUNT = [1-3]\n');
return;
} else if (
Number.isNaN(AntennaSelection)
|| AntennaSelection < 1
|| AntennaSelection > 3
) {
console.error(`Check antenna. It must be [1-3] : ${AntennaSelection}`);
return;
} else if (
Number.isNaN(DataRate)
|| DataRate > 7
|| DataRate < 0
) {
console.error(`Check data rate. It must be [0-7] : ${DataRateCode}`);
return;
} else if (
Number.isNaN(HTMode)
|| (HTMode !== '20' && HTMode !== '40')
) {
console.error(`Check ht mode. It must be [20|40] : ${HTMode}`);
return;
}
/* Streams
* 0) Single (SISO)
* 1) Dual (MIMO)
* 2) Triple (MIMO)
*/
let StreamCount = AntennaSelection - 1;
/* HT Duplicate Data
* 0) Off
* 1) On
*/
let HTDuplicateSelection = 0;
let HTDuplicate = HTMode === '40' ? HTDuplicateSelection : 0;
/* Use High Throughput
* 0) Legacy Mode
* 1) HT Mode
*/
let UseHT = 1;
/* CCK or OFDM
* 0) OFDM
* 1) CCK
*/
let UseCCKSelect = 0;
let UseCCK = UseHT === 1 ? 0 : UseCCKSelect;
/* Use Greenfield Preamble
* 0) No
* 1) Use
*/
let UseGFP = 1;
/* HT Channel
* 0) 20 MHz (legacy)
* 1) 40 MHz
*/
let HTChannel = HTMode === '20' ? 0 : 1;
/* Duplicate 20MHz channels in HT40
* 0) No
* 1) Yes
*/
let DuplicateSelection = 0;
let Duplicate = HTMode === 1 ? DuplicateSelection : 0;
/* Use Short Guard Interval
* 0) Normal Guard Interval (0.8 us)
* 1) Short Guard Interval (0.4 us)
*/
let ShortGuardInterval = 0;
/* Antenna */
let UseAntenna1 = AntennaSelection >= 1;
let UseAntenna2 = AntennaSelection >= 2;
let UseAntenna3 = AntennaSelection >= 3;
// NOTE : shift has higher priority than bitwise OR operation.
let RateFlags = (0b00000000000000000
| DataRate
| StreamCount << 3
| HTDuplicate << 5
| UseHT << 8
| UseCCK << 9
| UseGFP << 10
| HTChannel << 11
| Duplicate << 12
| ShortGuardInterval << 13
| UseAntenna1 << 14
| UseAntenna2 << 15
| UseAntenna3 << 16
);
console.log(`monitor_tx_rate: 0x${RateFlags.toString(16)} (0b${RateFlags.toString(2)})`);