diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2005-09-10 00:34:21 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2005-09-10 00:34:21 +0000 |
commit | 7eaf5aa39ab4592548baeffaca65f0e490e036b1 (patch) | |
tree | 6a5a82ddb748ae9cf6454df670010880569e9017 /tools | |
parent | b42672cbb91ea35268da5f0f385f539f133b2a0e (diff) |
Add support for transient persistent storage values
Diffstat (limited to 'tools')
-rw-r--r-- | tools/csr.c | 15 | ||||
-rw-r--r-- | tools/csr.h | 6 | ||||
-rw-r--r-- | tools/hciconfig.c | 2 | ||||
-rw-r--r-- | tools/pskey.c | 20 |
4 files changed, 26 insertions, 17 deletions
diff --git a/tools/csr.c b/tools/csr.c index 5932c822..39706623 100644 --- a/tools/csr.c +++ b/tools/csr.c @@ -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; diff --git a/tools/csr.h b/tools/csr.h index 95b5c63d..dc5e1029 100644 --- a/tools/csr.h +++ b/tools/csr.h @@ -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); diff --git a/tools/hciconfig.c b/tools/hciconfig.c index 0d13542d..2a352e85 100644 --- a/tools/hciconfig.c +++ b/tools/hciconfig.c @@ -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"); } diff --git a/tools/pskey.c b/tools/pskey.c index 030a6a43..0180be59 100644 --- a/tools/pskey.c +++ b/tools/pskey.c @@ -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(); |