forked from qca/sigma-dut
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ftm.c
702 lines (628 loc) · 19.3 KB
/
ftm.c
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
/*
* Sigma Control API DUT (FTM LOC functionality)
* Copyright (c) 2016, Qualcomm Atheros, Inc.
* All Rights Reserved.
* Licensed under the Clear BSD license. See README for more details.
*/
#include "sigma_dut.h"
#include <sys/stat.h>
#include <regex.h>
#include "wpa_helpers.h"
static const char LOC_XML_FILE_PATH[] = "./data/sigma-dut-target.xml";
static const char LOC_LOWI_TEST_DISCOVERY[] = "lowi_test -a -b 2 -n 1";
static const char LOC_LOWI_TEST_RANGING[] =
"lowi_test -r ./data/sigma-dut-target.xml -n 1";
static const char LOC_LOWI_TEST_NEIGHBOR_RPT_REQ[] = "lowi_test -nrr";
static const char LOC_LOWI_TEST_ANQP_REQ[] = "lowi_test -anqp -mac ";
static const char WPA_INTERWORKING_ENABLE[] =
"SET interworking 1";
static const char WPA_INTERWORKING_DISABLE[] =
"SET interworking 0";
static const char WPA_RM_ENABLE[] =
"VENDOR 1374 74 08000400BD000000";
static const char WPA_RM_DISABLE[] =
"VENDOR 1374 74 0800040000000000";
static const char WPA_ADDRESS_3_ENABLE[] =
"SET gas_address3 1";
static const char WPA_ADDRESS_3_DISABLE[] =
"SET gas_address3 0";
#ifndef ETH_ALEN
#define ETH_ALEN 6
#endif
#define LOC_MAX_RM_FLAGS 10
#define LOC_RM_FLAG_VAL_ARRAY 2
enum lowi_tst_cmd {
LOWI_TST_RANGING = 0,
LOWI_TST_NEIGHBOR_REPORT_REQ = 1,
LOWI_TST_ANQP_REQ = 2,
};
struct capi_loc_cmd {
unsigned int chan;
unsigned int burstExp;
unsigned int burstDur;
unsigned int minDeltaFtm;
unsigned int ptsf;
unsigned int asap;
unsigned int ftmsPerBurst;
unsigned int fmtbw;
unsigned int burstPeriod;
unsigned int locCivic;
unsigned int lci;
};
static int loc_write_xml_file(struct sigma_dut *dut, const char *dst_mac_str,
struct capi_loc_cmd *loc_cmd)
{
FILE *xml;
unsigned int band, bw, preamble, primary_ch, center_freq;
xml = fopen(LOC_XML_FILE_PATH, "w");
if (!xml) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Unable to create the XML file", __func__);
return -1;
}
/* Using this following defaults:
* default value of band 1
*/
band = 1;
#define FMT_BW_NO_PREF 0
#define FMT_BW_HT_20 9
#define FMT_BW_VHT_20 10
#define FMT_BW_HT_40 11
#define FMT_BW_VHT_40 12
#define FMT_BW_VHT_80 13
#define LOC_BW_20 0
#define LOC_BW_40 1
#define LOC_BW_80 2
#define LOC_PREAMBLE_HT 1
#define LOC_PREAMBLE_VHT 2
switch (loc_cmd->fmtbw) {
case FMT_BW_NO_PREF:
case FMT_BW_HT_20:
bw = LOC_BW_20;
preamble = LOC_PREAMBLE_HT;
primary_ch = 36;
center_freq = 5180;
break;
case FMT_BW_VHT_20:
bw = LOC_BW_20;
preamble = LOC_PREAMBLE_VHT;
primary_ch = 36;
center_freq = 5180;
break;
case FMT_BW_HT_40:
bw = LOC_BW_40;
preamble = LOC_PREAMBLE_HT;
primary_ch = 36;
center_freq = 5190;
break;
case FMT_BW_VHT_40:
bw = LOC_BW_40;
preamble = LOC_PREAMBLE_VHT;
primary_ch = 36;
center_freq = 5190;
break;
case FMT_BW_VHT_80:
bw = LOC_BW_80;
preamble = LOC_PREAMBLE_VHT;
primary_ch = 36;
center_freq = 5210;
break;
default:
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Bad Format/BW received", __func__);
fclose(xml);
return -1;
}
#define LOC_CAPI_DEFAULT_FTMS_PER_BURST 5
#define LOC_CAPI_DEFAULT_BURST_DUR 10
fprintf(xml, "<body>\n");
fprintf(xml, " <ranging>\n");
fprintf(xml, " <ap>\n");
fprintf(xml, " <band>%u</band>\n", band);
fprintf(xml, " <rttType>3</rttType>\n");
fprintf(xml, " <numFrames>%u</numFrames>\n",
LOC_CAPI_DEFAULT_FTMS_PER_BURST);
fprintf(xml, " <bw>%u</bw>\n", bw);
fprintf(xml, " <preamble>%u</preamble>\n", preamble);
fprintf(xml, " <asap>%u</asap>\n", loc_cmd->asap);
fprintf(xml, " <lci>%u</lci>\n", loc_cmd->lci);
fprintf(xml, " <civic>%u</civic>\n", loc_cmd->locCivic);
fprintf(xml, " <burstsexp>%u</burstsexp>\n", loc_cmd->burstExp);
fprintf(xml, " <burstduration>%u</burstduration>\n",
LOC_CAPI_DEFAULT_BURST_DUR);
fprintf(xml, " <burstperiod>%u</burstperiod>\n", 0);
/* Use parameters from LOWI cache */
fprintf(xml, " <paramControl>%u</paramControl>\n", 0);
fprintf(xml, " <ptsftimer>%u</ptsftimer>\n", 0);
fprintf(xml, " <center_freq1>%u</center_freq1>\n", center_freq);
fprintf(xml, " <center_freq2>0</center_freq2>\n");
fprintf(xml, " <ch>%u</ch>\n", primary_ch);
fprintf(xml, " <mac>%s</mac>\n", dst_mac_str);
fprintf(xml, " </ap>\n");
fprintf(xml, " </ranging>\n");
fprintf(xml, " <summary>\n");
fprintf(xml, " <mac>%s</mac>\n", dst_mac_str);
fprintf(xml, " </summary>\n");
fprintf(xml, "</body>\n");
fclose(xml);
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - Successfully created XML file", __func__);
return 0;
}
static int pass_request_to_ltest(struct sigma_dut *dut, enum lowi_tst_cmd cmd,
const char *params)
{
#define MAX_ANQP_CMND_SIZE 256
int ret;
const char *cmd_str;
char lowi_anqp_query[MAX_ANQP_CMND_SIZE];
switch (cmd) {
case LOWI_TST_RANGING:
cmd_str = LOC_LOWI_TEST_RANGING;
break;
case LOWI_TST_NEIGHBOR_REPORT_REQ:
cmd_str = LOC_LOWI_TEST_NEIGHBOR_RPT_REQ;
break;
case LOWI_TST_ANQP_REQ:
if (!params) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - No Destination Mac provided for ANQP Query",
__func__);
return -1;
}
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - Destination Mac provided for ANQP Query: %s",
__func__, params);
snprintf(lowi_anqp_query, MAX_ANQP_CMND_SIZE, "%s%s",
LOC_LOWI_TEST_ANQP_REQ, params);
cmd_str = lowi_anqp_query;
break;
default:
cmd_str = LOC_LOWI_TEST_DISCOVERY;
break;
}
sigma_dut_print(dut, DUT_MSG_INFO, "%s - 1 - Running command: %s",
__func__, LOC_LOWI_TEST_DISCOVERY);
ret = system(LOC_LOWI_TEST_DISCOVERY);
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - Finished Performing Discovery Scan through LOWI_test: ret: %d",
__func__, ret);
sleep(1);
sigma_dut_print(dut, DUT_MSG_INFO, "%s - 2 - Running command: %s",
__func__, cmd_str);
ret = system(cmd_str);
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - Finished Performing command: %s, got ret: %d",
__func__, cmd_str, ret);
return ret;
}
int loc_cmd_sta_exec_action(struct sigma_dut *dut, struct sigma_conn *conn,
struct sigma_cmd *cmd)
{
const char *params = NULL;
enum lowi_tst_cmd cmnd = LOWI_TST_RANGING;
const char *program = get_param(cmd, "prog");
const char *loc_op = get_param(cmd, "Trigger");
const char *interface = get_param(cmd, "interface");
const char *destMacStr = get_param(cmd, "destmac");
const char *burstExp = get_param(cmd, "burstsexponent");
const char *asap = get_param(cmd, "ASAP");
const char *fmtbw = get_param(cmd, "formatbwftm");
const char *locCivic = get_param(cmd, "askforloccivic");
const char *lci = get_param(cmd, "askforlci");
struct capi_loc_cmd loc_cmd;
memset(&loc_cmd, 0, sizeof(loc_cmd));
if (!loc_op) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - No Operation! - Aborting", __func__);
return -1;
}
cmnd = strcasecmp(loc_op, "ANQPQuery") == 0 ?
LOWI_TST_ANQP_REQ : LOWI_TST_RANGING;
sigma_dut_print(dut, DUT_MSG_INFO, "%s - Going to perform: %s",
__func__, loc_op);
if (!program) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - No Program in Command! - Aborting",
__func__);
return -1;
}
if (!interface) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Incomplete command in LOC CAPI request",
__func__);
send_resp(dut, conn, SIGMA_ERROR,
"ErrMsg,Incomplete Loc CAPI command - missing interface");
return 0;
}
if (!destMacStr) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Incomplete command in LOC CAPI request",
__func__);
send_resp(dut, conn, SIGMA_ERROR,
"ErrMsg,Incomplete Loc CAPI command - missing MAC");
return 0;
}
if (cmnd == LOWI_TST_RANGING) {
sigma_dut_print(dut, DUT_MSG_INFO, "%s - LOWI_TST_RANGING",
__func__);
if (!burstExp) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Incomplete command in LOC CAPI request",
__func__);
send_resp(dut, conn, SIGMA_ERROR,
"ErrMsg,Incomplete Loc CAPI command - missing Burst Exp");
return 0;
}
if (!asap) {
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - Incomplete command in LOC CAPI request",
__func__);
send_resp(dut, conn, SIGMA_ERROR,
"ErrMsg,Incomplete Loc CAPI command - missing ASAP");
return 0;
}
if (!fmtbw) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Incomplete command in LOC CAPI request",
__func__);
send_resp(dut, conn, SIGMA_ERROR,
"ErrMsg,Incomplete Loc CAPI command - missing Format & BW");
return 0;
}
if (!locCivic) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Incomplete command in LOC CAPI request",
__func__);
send_resp(dut, conn, SIGMA_ERROR,
"ErrMsg,Incomplete Loc CAPI command - missing Location Civic");
return 0;
}
if (!lci) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Incomplete command in LOC CAPI request",
__func__);
send_resp(dut, conn, SIGMA_ERROR,
"ErrMsg,Incomplete Loc CAPI command - missing LCI");
return 0;
}
if (strcasecmp(program, "loc") != 0) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Unsupported Program: %s",
__func__, program);
send_resp(dut, conn, SIGMA_ERROR,
"ErrMsg,Unsupported program");
return 0;
}
if (strcasecmp(interface, "wlan0") != 0) {
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - Unsupported Interface Type: %s",
__func__, interface);
send_resp(dut, conn, SIGMA_ERROR,
"ErrMsg,Unsupported Interface Type");
return 0;
}
sscanf(burstExp, "%u", &loc_cmd.burstExp);
sigma_dut_print(dut, DUT_MSG_INFO, "%s - burstExp: %u",
__func__, loc_cmd.burstExp);
sscanf(asap, "%u", &loc_cmd.asap);
sigma_dut_print(dut, DUT_MSG_INFO, "%s - asap: %u",
__func__, loc_cmd.asap);
sscanf(fmtbw, "%u", &loc_cmd.fmtbw);
sigma_dut_print(dut, DUT_MSG_INFO, "%s - fmtbw: %u",
__func__, loc_cmd.fmtbw);
sscanf(locCivic, "%u", &loc_cmd.locCivic);
sigma_dut_print(dut, DUT_MSG_INFO, "%s - locCivic: %u",
__func__, loc_cmd.locCivic);
sscanf(lci, "%u", &loc_cmd.lci);
sigma_dut_print(dut, DUT_MSG_INFO, "%s - lci: %u",
__func__, loc_cmd.lci);
if (loc_write_xml_file(dut, destMacStr, &loc_cmd) < 0) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Failed to write to XML file because of bad command",
__func__);
send_resp(dut, conn, SIGMA_ERROR,
"ErrMsg,Bad CAPI command");
return 0;
}
} else {
/* ANQP Query */
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - LOWI_TST_ANQP_REQ", __func__);
params = destMacStr;
}
if (pass_request_to_ltest(dut, cmnd, params) < 0) {
/* Loc operation been failed. */
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Failed to initiate Loc command",
__func__);
send_resp(dut, conn, SIGMA_ERROR,
"ErrMsg,Failed to initiate Loc command");
return 0;
}
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - Succeeded to initiate Loc command", __func__);
send_resp(dut, conn, SIGMA_COMPLETE, NULL);
return 0;
}
int loc_cmd_sta_send_frame(struct sigma_dut *dut, struct sigma_conn *conn,
struct sigma_cmd *cmd)
{
const char *address3Cmnd = WPA_ADDRESS_3_DISABLE;
enum lowi_tst_cmd cmnd = LOWI_TST_NEIGHBOR_REPORT_REQ; /* Default */
/* Mandatory arguments */
const char *interface = get_param(cmd, "interface");
const char *program = get_param(cmd, "program");
const char *destMacStr = get_param(cmd, "destmac");
const char *frameName = get_param(cmd, "FrameName");
/* Optional Arguments */
const char *locCivic = get_param(cmd, "askforloccivic");
const char *lci = get_param(cmd, "askforlci");
const char *fqdn = get_param(cmd, "AskForPublicIdentifierURI-FQDN");
const char *address3 = get_param(cmd, "address3");
const char *params = NULL;
if (!program) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - No Program in Command! - Aborting",
__func__);
return -1;
}
if (!interface) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Incomplete command in LOC CAPI request",
__func__);
send_resp(dut, conn, SIGMA_ERROR, NULL);
return 0;
}
if (!frameName) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Incomplete command in LOC CAPI request",
__func__);
send_resp(dut, conn, SIGMA_ERROR, NULL);
return 0;
}
if (strcasecmp(frameName, "AnqpQuery") == 0 && !destMacStr) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Incomplete command in LOC CAPI request",
__func__);
send_resp(dut, conn, SIGMA_ERROR, NULL);
return 0;
}
if (!locCivic)
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Command missing LocCivic", __func__);
if (!lci)
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Command missing LCI", __func__);
if (!fqdn)
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Command missing FQDN", __func__);
if (!address3) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Command missing address3", __func__);
} else {
sigma_dut_print(dut, DUT_MSG_DEBUG, "%s - address3: %s",
__func__, address3);
if (strcasecmp(address3, "FF:FF:FF:FF:FF:FF") == 0)
address3Cmnd = WPA_ADDRESS_3_ENABLE;
else
address3Cmnd = WPA_ADDRESS_3_DISABLE;
}
if (strcasecmp(program, "loc") != 0) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Unsupported Program: %s", __func__,
program);
send_resp(dut, conn, SIGMA_ERROR, NULL);
return 0;
}
sigma_dut_print(dut, DUT_MSG_INFO, "%s - Triggering Frame: %s",
__func__, frameName);
if (strcasecmp(frameName, "AnqpQuery") == 0) {
cmnd = LOWI_TST_ANQP_REQ;
params = destMacStr;
} else {
cmnd = LOWI_TST_NEIGHBOR_REPORT_REQ;
}
if (cmnd == LOWI_TST_ANQP_REQ) {
sigma_dut_print(dut, DUT_MSG_DEBUG, "%s - Executing command %s",
__func__, address3Cmnd);
if (wpa_command(get_station_ifname(dut), address3Cmnd) < 0) {
send_resp(dut, conn, SIGMA_ERROR, NULL);
return -1;
}
}
if (pass_request_to_ltest(dut, cmnd, params) < 0) {
/* Loc operation has failed. */
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - Failed to initiate Loc command",
__func__);
send_resp(dut, conn, SIGMA_ERROR, NULL);
return 0;
}
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - Succeeded to initiate Loc command", __func__);
send_resp(dut, conn, SIGMA_COMPLETE, NULL);
return 0;
}
enum e_rm_parse_states {
LOC_LOOKING_FOR_BIT = 0,
LOC_LOOKING_FOR_VAL,
LOC_MAX
};
void parse_rm_bits(struct sigma_dut *dut, const char *rmFlags,
char rmBitFlags[LOC_MAX_RM_FLAGS][LOC_RM_FLAG_VAL_ARRAY])
{
unsigned int bitPos = 0;
unsigned int bitVal = 0;
unsigned int idx = 0;
unsigned int i = 0;
enum e_rm_parse_states rmParseStates = LOC_LOOKING_FOR_BIT;
char temp = '\0';
if (!rmFlags) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - NULL pointer for rmFlags - Aborting", __func__);
return;
}
sigma_dut_print(dut, DUT_MSG_INFO, "%s - rmFlags: %s",
__func__, rmFlags);
while (*rmFlags != '\0' && idx < LOC_MAX_RM_FLAGS) {
temp = *rmFlags;
rmFlags++;
switch (rmParseStates) {
case LOC_LOOKING_FOR_BIT:
if (temp >= '0' && temp <= '9') {
/* Parse Digit for bit Position */
bitPos = (bitPos * 10) + (temp - '0');
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - LOC_LOOKING_FOR_BIT - parsing: %c, bitPos: %u",
__func__, temp, bitPos);
} else if (temp == ':') {
/* move to Parsing Bit Value */
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - LOC_LOOKING_FOR_BIT - processing: %c, bitPos: %u",
__func__, temp, bitPos);
rmBitFlags[idx][0] = bitPos;
rmParseStates = LOC_LOOKING_FOR_VAL;
} else if (temp == ';') {
/* End of Bit-Value Pair, reset and look for New Bit Position */
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - LOC_LOOKING_FOR_BIT - processing: %c",
__func__, temp);
rmBitFlags[idx][0] = bitPos;
/* rmBitFlags[idx][1] = bitVal; */
bitPos = 0;
bitVal = 0;
idx++;
} else { /* Ignore */
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - LOC_LOOKING_FOR_BIT - ignoring: %c",
__func__, temp);
}
break;
case LOC_LOOKING_FOR_VAL:
if (temp == '0' || temp == '1') {
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - LOC_LOOKING_FOR_VAL - processing: %c",
__func__, temp);
bitVal = temp - '0';
rmBitFlags[idx][1] = bitVal;
} else if (temp == ';') {
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - LOC_LOOKING_FOR_VAL - processing: %c, bitPos: %u, bitVal: %u",
__func__, temp, bitPos, bitVal);
/* rmBitFlags[idx][0] = bitPos; */
/* rmBitFlags[idx][1] = bitVal; */
bitPos = 0;
bitVal = 0;
idx++;
rmParseStates = LOC_LOOKING_FOR_BIT;
} else { /* Ignore */
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - LOC_LOOKING_FOR_VAL - ignoring: %c",
__func__, temp);
}
break;
default: /* Ignore */
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - default - ignoring: %c",
__func__, temp);
break;
}
}
for (i = 0; i < LOC_MAX_RM_FLAGS; i++) {
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - Bit Pos: %u : Bit Val: %u",
__func__, rmBitFlags[i][0],
rmBitFlags[i][1]);
}
}
int loc_cmd_sta_preset_testparameters(struct sigma_dut *dut,
struct sigma_conn *conn,
struct sigma_cmd *cmd)
{
const char *rmFTMRFlagStr = get_param(cmd, "RMEnabledCapBitmap");
const char *interworkingEn = get_param(cmd, "Interworking");
unsigned int rmFTMRFlag = 0;
unsigned int i, interworking = 0;
char rmBitFlags[LOC_MAX_RM_FLAGS][LOC_RM_FLAG_VAL_ARRAY];
sigma_dut_print(dut, DUT_MSG_INFO, "%s", __func__);
memset(rmBitFlags, 0, sizeof(rmBitFlags));
sigma_dut_print(dut, DUT_MSG_INFO, "%s - 1", __func__);
/*
* This function is used to configure the RM capability bits and
* the Interworking bit only.
* If these parameters are not present just returning COMPLETE
* because all other parameters are ignored.
*/
if (!rmFTMRFlagStr && !interworkingEn) {
sigma_dut_print(dut, DUT_MSG_INFO, "%s - 2", __func__);
sigma_dut_print(dut, DUT_MSG_ERROR, "%s - Did not get %s",
__func__, "RMEnabledCapBitmap");
send_resp(dut, conn, SIGMA_COMPLETE, NULL);
return 0;
}
if (rmFTMRFlagStr) {
rmFTMRFlag = 25; /* Default invalid */
sigma_dut_print(dut, DUT_MSG_INFO, "%s - rmFTMRFlagStr: %s",
__func__, rmFTMRFlagStr);
parse_rm_bits(dut, rmFTMRFlagStr, rmBitFlags);
for (i = 0; i < LOC_MAX_RM_FLAGS; i++) {
if (rmBitFlags[i][0] == 34)
rmFTMRFlag = rmBitFlags[i][1];
}
sigma_dut_print(dut, DUT_MSG_INFO, "%s - rmFTMRFlag %u",
__func__, rmFTMRFlag);
if (rmFTMRFlag == 0) { /* Disable RM - FTMRR capability */
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - Disabling RM - FTMRR",
__func__);
if (wpa_command(get_station_ifname(dut),
WPA_RM_DISABLE) < 0) {
send_resp(dut, conn, SIGMA_ERROR, NULL);
return -1;
}
} else if (rmFTMRFlag == 1) { /* Enable RM - FTMRR capability */
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - Enabling RM - FTMRR",
__func__);
if (wpa_command(get_station_ifname(dut),
WPA_RM_ENABLE) < 0) {
send_resp(dut, conn, SIGMA_ERROR, NULL);
return 0;
}
} else {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - No Setting for - FTMRR",
__func__);
}
sigma_dut_print(dut, DUT_MSG_INFO,
"%s - Succeeded in Enabling/Disabling RM Capability for FTMRR",
__func__);
}
if (interworkingEn) {
sscanf(interworkingEn, "%u", &interworking);
sigma_dut_print(dut, DUT_MSG_INFO, "%s - interworking: %u",
__func__, interworking);
if (interworking)
wpa_command(get_station_ifname(dut),
WPA_INTERWORKING_ENABLE);
else
wpa_command(get_station_ifname(dut),
WPA_INTERWORKING_DISABLE);
}
send_resp(dut, conn, SIGMA_COMPLETE, NULL);
return 0;
}
int lowi_cmd_sta_reset_default(struct sigma_dut *dut, struct sigma_conn *conn,
struct sigma_cmd *cmd)
{
#ifdef ANDROID_WIFI_HAL
if (wifi_hal_initialize(dut)) {
sigma_dut_print(dut, DUT_MSG_ERROR,
"%s - wifihal init failed for - LOC",
__func__);
return -1;
}
#endif /* ANDROID_WIFI_HAL */
return 0;
}