View | Details | Raw Unified | Return to bug 245739 | Differences between
and this patch

Collapse All | Expand All

(-)usr.sbin/bluetooth/hccontrol/hccontrol.h (+1 lines)
Lines 73-78 Link Here
73
char const *	hci_lmpver2str      (int);
73
char const *	hci_lmpver2str      (int);
74
char const *	hci_manufacturer2str(int);
74
char const *	hci_manufacturer2str(int);
75
char const *	hci_features2str    (uint8_t *, char *, int);
75
char const *	hci_features2str    (uint8_t *, char *, int);
76
char const *	hci_le_features2str (uint8_t *, char *, int);
76
char const *	hci_cc2str          (int);
77
char const *	hci_cc2str          (int);
77
char const *	hci_con_state2str   (int);
78
char const *	hci_con_state2str   (int);
78
char const *	hci_status2str      (int);
79
char const *	hci_status2str      (int);
(-)usr.sbin/bluetooth/hccontrol/le.c (-6 / +25 lines)
Lines 225-242 Link Here
225
le_read_local_supported_features(int s, int argc ,char *argv[])
225
le_read_local_supported_features(int s, int argc ,char *argv[])
226
{
226
{
227
	ng_hci_le_read_local_supported_features_rp rp;
227
	ng_hci_le_read_local_supported_features_rp rp;
228
	int e;
229
	int n = sizeof(rp);
228
	int n = sizeof(rp);
230
229
231
	e = hci_simple_request(s,
230
	union {
231
		uint64_t raw;
232
		uint8_t octets[8];
233
	}	le_features;
234
235
	char	buffer[2048];
236
237
	if (hci_simple_request(s,
232
			NG_HCI_OPCODE(NG_HCI_OGF_LE,
238
			NG_HCI_OPCODE(NG_HCI_OGF_LE,
233
			NG_HCI_OCF_LE_READ_LOCAL_SUPPORTED_FEATURES), 
239
			NG_HCI_OCF_LE_READ_LOCAL_SUPPORTED_FEATURES), 
234
			(void *)&rp, &n);
240
			(void *)&rp, &n) == ERROR)
241
		return (ERROR);
235
242
236
	printf("LOCAL SUPPORTED: %d %d %jx\n", e, rp.status,
243
	if (rp.status != 0x00) {
237
	       (uintmax_t) rp.le_features);
244
		fprintf(stdout, "Status: %s [%#02x]\n", 
245
			hci_status2str(rp.status), rp.status);
246
		return (FAILED);
247
	}
238
248
239
	return 0;
249
	le_features.raw = rp.le_features;
250
251
	fprintf(stdout, "LE Features: ");
252
	for(int i = 0; i < 8; i++)
253
                fprintf(stdout, " %#02x", le_features.octets[i]);
254
	fprintf(stdout, "\n%s\n", hci_le_features2str(le_features.octets, 
255
		buffer, sizeof(buffer)));
256
        fprintf(stdout, "\n");
257
258
	return OK;
240
}
259
}
241
260
242
static int
261
static int
(-)usr.sbin/bluetooth/hccontrol/util.c (+113 lines)
Lines 371-376 Link Here
371
} /* hci_features2str */
371
} /* hci_features2str */
372
372
373
char const *
373
char const *
374
hci_le_features2str(uint8_t *features, char *buffer, int size)
375
{
376
	static char const * const	t[][8] = {
377
	{ /* byte 0 */
378
		/* 0 */ "<LE Encryption> ",
379
		/* 1 */ "<Connection Parameters Request Procedure> ",
380
		/* 2 */ "<Extended Reject Indication> ",
381
		/* 3 */ "<Slave-initiated Features Exchange> ",
382
		/* 4 */ "<LE Ping> ",
383
		/* 5 */ "<LE Data Packet Length Extension> ",
384
		/* 6 */ "<LL Privacy> ",
385
		/* 7 */ "<Extended Scanner Filter Policies> "
386
	},
387
	{ /* byte 1 */
388
		/* 0 */ "<LE 2M PHY> ",
389
		/* 1 */ "<Stable Modulation Index - Transmitter> ",
390
		/* 2 */ "<Stable Modulation Index - Receiver> ",
391
		/* 3 */ "<LE Coded PHY> ",
392
		/* 4 */ "<LE Extended Advertising> ",
393
		/* 5 */ "<LE Periodic Advertising> ",
394
		/* 6 */ "<Channel Selection Algorithm #2> ",
395
		/* 7 */ "<LE Power Class 1> "
396
	},
397
	{ /* byte 2 */
398
		/* 0 */ "<Minimum Number of Used Channels Procedure> ",
399
		/* 1 */ "<Connection CTE Request> ",
400
		/* 2 */ "<Connection CTE Response> ",
401
		/* 3 */ "<Connectionless CTE Transmitter> ",
402
		/* 4 */ "<Connectionless CTE Receiver> ",
403
		/* 5 */ "<Antenna Switching During CTE Transmission (AoD)> ",
404
		/* 6 */ "<Antenna Switching During CTE Reception (AoA)> ",
405
		/* 7 */ "<Receiving Constant Tone Extensions> "
406
	},
407
	{ /* byte 3 */
408
		/* 0 */ "<Periodic Advertising Sync Transfer - Sender> ",
409
		/* 1 */ "<Periodic Advertising Sync Transfer - Recipient> ",
410
		/* 2 */ "<Sleep Clock Accuracy Updates> ",
411
		/* 3 */ "<Remote Public Key Validation> ",
412
		/* 4 */ "<Connected Isochronous Stream - Master> ",
413
		/* 5 */ "<Connected Isochronous Stream - Slave> ",
414
		/* 6 */ "<Isochronous Broadcaster> ",
415
		/* 7 */ "<Synchronized Receiver> "
416
	},
417
	{ /* byte 4 */
418
		/* 0 */ "<Isochronous Channels (Host Support)> ",
419
		/* 1 */ "<LE Power Control Request> ",
420
		/* 2 */ "<LE Power Change Indication> ",
421
		/* 3 */ "<LE Path Loss Monitoring> ",
422
		/* 4 */ "<Reserved for future use> ",
423
		/* 5 */ "<Unknown 4.5> ",
424
		/* 6 */ "<Unknown 4.6> ",
425
		/* 7 */ "<Unknown 4.7> "
426
	},
427
	{ /* byte 5 */
428
		/* 0 */ "<Unknown 5.0> ",
429
		/* 1 */ "<Unknown 5.1> ",
430
		/* 2 */ "<Unknown 5.2> ",
431
		/* 3 */ "<Unknown 5.3> ",
432
		/* 4 */ "<Unknown 5.4> ",
433
		/* 5 */ "<Unknown 5.5> ",
434
		/* 6 */ "<Unknown 5.6> ",
435
		/* 7 */ "<Unknown 5.7> "
436
	},
437
	{ /* byte 6 */
438
		/* 0 */ "<Unknown 6.0> ",
439
		/* 1 */ "<Unknown 6.1> ",
440
		/* 2 */ "<Unknown 6.2> ",
441
		/* 3 */ "<Unknown 6.3> ",
442
		/* 4 */ "<Unknown 6.4> ",
443
		/* 5 */ "<Unknown 6.5> ",
444
		/* 6 */ "<Unknown 6.6> ",
445
		/* 7 */ "<Unknown 6.7> "
446
	},
447
	{ /* byte 7 */
448
		/* 0 */ "<Unknown 7.0> ",
449
		/* 1 */ "<Unknown 7.1> ",
450
		/* 2 */ "<Unknown 7.2> ",
451
		/* 3 */ "<Unknown 7.3> ",
452
		/* 4 */ "<Unknown 7.4> ",
453
		/* 5 */ "<Unknown 7.5> ",
454
		/* 6 */ "<Unknown 7.6> ",
455
		/* 7 */ "<Unknown 7.7> "
456
	}};
457
458
	if (buffer != NULL && size > 0) {
459
		int	n, i, len0, len1;
460
461
		memset(buffer, 0, size);
462
		len1 = 0;
463
464
		for (n = 0; n < SIZE(t); n++) {
465
			for (i = 0; i < SIZE(t[n]); i++) {
466
				len0 = strlen(buffer);
467
				if (len0 >= size)
468
					goto done;
469
470
				if (features[n] & (1 << i)) {
471
					if (len1 + strlen(t[n][i]) > 60) {
472
						len1 = 0;
473
						buffer[len0 - 1] = '\n';
474
					}
475
476
					len1 += strlen(t[n][i]);
477
					strncat(buffer, t[n][i], size - len0);
478
				}
479
			}
480
		}
481
	}
482
done:
483
	return (buffer);
484
}
485
486
char const *
374
hci_cc2str(int cc)
487
hci_cc2str(int cc)
375
{
488
{
376
	static char const * const	t[] = {
489
	static char const * const	t[] = {

Return to bug 245739