int kernel_active;
};
-libusb_device_handle *
+static libusb_device_handle *
chaoskey_match(libusb_device *dev, char *match_serial)
{
struct libusb_device_descriptor desc;
return 0;
}
-struct chaoskey *
+static struct chaoskey *
chaoskey_open(char *serial)
{
struct chaoskey *ck;
return NULL;
}
-void
-chaoskey_close(struct chaoskey *ck)
-{
- libusb_release_interface(ck->handle, 0);
- if (ck->kernel_active)
- libusb_attach_kernel_driver(ck->handle, 0);
- libusb_close(ck->handle);
- libusb_exit(ck->ctx);
- free(ck);
-}
-
#define COOKED_ENDPOINT 0x85
#define RAW_ENDPOINT 0x86
+#define FLASH_ENDPOINT 0x87
-int
+static int
chaoskey_read(struct chaoskey *ck, int endpoint, void *buffer, int len)
{
uint8_t *buf = buffer;
{ .name = "bytes", .has_arg = 0, .val = 'b' },
{ .name = "cooked", .has_arg = 0, .val = 'c' },
{ .name = "raw", .has_arg = 0, .val = 'r' },
+ { .name = "flash", .has_arg = 0, .val = 'f' },
{ 0, 0, 0, 0},
};
static void usage(char *program)
{
- fprintf(stderr, "usage: %s [--serial=<serial>] [--length=<length>[kMG]] [--infinite] [--bytes] [--cooked] [--raw]\n", program);
+ fprintf(stderr, "usage: %s [--serial=<serial>] [--length=<length>[kMG]] [--infinite] [--bytes] [--cooked] [--raw] [--flash]\n", program);
exit(1);
}
int bytes = 0;
int endpoint = RAW_ENDPOINT;
- while ((c = getopt_long(argc, argv, "s:l:ibcr", options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "s:l:ibcrf", options, NULL)) != -1) {
switch (c) {
case 's':
serial = optarg;
case 'r':
endpoint = RAW_ENDPOINT;
break;
+ case 'f':
+ endpoint = FLASH_ENDPOINT;
+ break;
default:
usage(argv[0]);
break;