Add support for transient persistent storage values

This commit is contained in:
Marcel Holtmann 2005-09-10 00:34:21 +00:00
parent b42672cbb9
commit 7eaf5aa39a
4 changed files with 26 additions and 17 deletions

View File

@ -598,13 +598,13 @@ int csr_read_varid_uint32(int dd, uint16_t seqnum, uint16_t varid, uint32_t *val
return 0;
}
int csr_read_pskey_complex(int dd, uint16_t seqnum, uint16_t pskey, uint8_t *value, uint16_t length)
int csr_read_pskey_complex(int dd, uint16_t seqnum, uint16_t pskey, uint16_t store, uint8_t *value, uint16_t length)
{
unsigned char cmd[] = { 0x00, 0x00, ((length / 2) + 8) & 0xff, ((length / 2) + 8) >> 8,
seqnum & 0xff, seqnum >> 8, 0x03, 0x70, 0x00, 0x00,
pskey & 0xff, pskey >> 8,
(length / 2) & 0xff, (length / 2) >> 8,
0x00, 0x00, 0x00, 0x00 };
store & 0xff, store >> 8, 0x00, 0x00 };
unsigned char cp[254], rp[254];
struct hci_request rq;
@ -640,11 +640,12 @@ int csr_read_pskey_complex(int dd, uint16_t seqnum, uint16_t pskey, uint8_t *val
return 0;
}
int csr_read_pskey_uint16(int dd, uint16_t seqnum, uint16_t pskey, uint16_t *value)
int csr_read_pskey_uint16(int dd, uint16_t seqnum, uint16_t pskey, uint16_t store, uint16_t *value)
{
unsigned char cmd[] = { 0x00, 0x00, 0x09, 0x00,
seqnum & 0xff, seqnum >> 8, 0x03, 0x70, 0x00, 0x00,
pskey & 0xff, pskey >> 8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 };
pskey & 0xff, pskey >> 8, 0x01, 0x00,
store & 0xff, store >> 8, 0x00, 0x00 };
unsigned char cp[254], rp[254];
struct hci_request rq;
@ -680,12 +681,12 @@ int csr_read_pskey_uint16(int dd, uint16_t seqnum, uint16_t pskey, uint16_t *val
return 0;
}
int csr_write_pskey_uint16(int dd, uint16_t seqnum, uint16_t pskey, uint16_t value)
int csr_write_pskey_uint16(int dd, uint16_t seqnum, uint16_t pskey, uint16_t store, uint16_t value)
{
unsigned char cmd[] = { 0x02, 0x00, 0x09, 0x00,
seqnum & 0xff, seqnum >> 8, 0x03, 0x70, 0x00, 0x00,
pskey & 0xff, pskey >> 8, 0x01, 0x00, 0x00, 0x00,
value & 0xff, value >> 8 };
pskey & 0xff, pskey >> 8, 0x01, 0x00,
store & 0xff, store >> 8, value & 0xff, value >> 8 };
unsigned char cp[254], rp[254];
struct hci_request rq;

View File

@ -81,6 +81,6 @@ int csr_write_varid_valueless(int dd, uint16_t seqnum, uint16_t varid);
int csr_read_varid_complex(int dd, uint16_t seqnum, uint16_t varid, uint8_t *value, uint16_t length);
int csr_read_varid_uint16(int dd, uint16_t seqnum, uint16_t varid, uint16_t *value);
int csr_read_varid_uint32(int dd, uint16_t seqnum, uint16_t varid, uint32_t *value);
int csr_read_pskey_complex(int dd, uint16_t seqnum, uint16_t pskey, uint8_t *value, uint16_t length);
int csr_read_pskey_uint16(int dd, uint16_t seqnum, uint16_t pskey, uint16_t *value);
int csr_write_pskey_uint16(int dd, uint16_t seqnum, uint16_t pskey, uint16_t value);
int csr_read_pskey_complex(int dd, uint16_t seqnum, uint16_t pskey, uint16_t store, uint8_t *value, uint16_t length);
int csr_read_pskey_uint16(int dd, uint16_t seqnum, uint16_t pskey, uint16_t store, uint16_t *value);
int csr_write_pskey_uint16(int dd, uint16_t seqnum, uint16_t pskey, uint16_t store, uint16_t value);

View File

@ -1225,7 +1225,7 @@ static void print_rev_csr(int dd, uint16_t rev)
if (!csr_read_varid_uint16(dd, 3, CSR_VARID_MAX_CRYPT_KEY_LENGTH, &maxkeylen))
printf("\tMax key size: %d bit\n", maxkeylen * 8);
if (!csr_read_pskey_uint16(dd, 4, CSR_PSKEY_HOSTIO_MAP_SCO_PCM, &mapsco))
if (!csr_read_pskey_uint16(dd, 4, CSR_PSKEY_HOSTIO_MAP_SCO_PCM, 0x0000, &mapsco))
printf("\tSCO mapping: %s\n", mapsco ? "PCM" : "HCI");
}

View File

@ -47,6 +47,8 @@
#define CSR_TYPE_UINT8 2
#define CSR_TYPE_UINT16 3
static int transient = 0;
static int write_pskey(int dd, uint16_t pskey, int type, int argc, char *argv[])
{
uint16_t value;
@ -67,7 +69,8 @@ static int write_pskey(int dd, uint16_t pskey, int type, int argc, char *argv[])
else
value = atoi(argv[0]);
err = csr_write_pskey_uint16(dd, 0x4711, pskey, value);
err = csr_write_pskey_uint16(dd, 0x4711, pskey,
transient ? 0x0008 : 0x0000, value);
return err;
}
@ -88,7 +91,7 @@ static int read_pskey(int dd, uint16_t pskey, int type)
}
if (type != CSR_TYPE_ARRAY) {
err = csr_read_pskey_uint16(dd, 0x4711, pskey, &value);
err = csr_read_pskey_uint16(dd, 0x4711, pskey, 0x0000, &value);
if (err < 0)
return err;
@ -97,7 +100,7 @@ static int read_pskey(int dd, uint16_t pskey, int type)
if (pskey == CSR_PSKEY_LOCAL_SUPPORTED_FEATURES)
size = 8;
err = csr_read_pskey_complex(dd, 0x4711, pskey, array, size);
err = csr_read_pskey_complex(dd, 0x4711, pskey, 0x0000, array, size);
if (err < 0)
return err;
@ -138,7 +141,7 @@ static void usage(void)
printf("pskey - Utility for changing CSR persistent storage\n\n");
printf("Usage:\n"
"\tpskey [-i <dev>] <key> [value]\n\n");
"\tpskey [-i <dev>] [-t] <key> [value]\n\n");
printf("Keys:\n\t");
for (i = 0; storage[i].pskey; i++) {
@ -153,8 +156,9 @@ static void usage(void)
}
static struct option main_options[] = {
{ "help", 0, 0, 'h' },
{ "device", 1, 0, 'i' },
{ "transient", 0, 0, 't' },
{ "help", 0, 0, 'h' },
{ 0, 0, 0, 0 }
};
@ -164,7 +168,7 @@ int main(int argc, char *argv[])
struct hci_version ver;
int i, err, dd, opt, dev = 0;
while ((opt=getopt_long(argc, argv, "+i:h", main_options, NULL)) != -1) {
while ((opt=getopt_long(argc, argv, "+i:th", main_options, NULL)) != -1) {
switch (opt) {
case 'i':
dev = hci_devid(optarg);
@ -174,6 +178,10 @@ int main(int argc, char *argv[])
}
break;
case 't':
transient = 1;
break;
case 'h':
default:
usage();