diff options
Diffstat (limited to 'src/device.c')
| -rw-r--r-- | src/device.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/device.c b/src/device.c index b6cc32a..1e3cc83 100644 --- a/src/device.c +++ b/src/device.c | |||
| @@ -112,6 +112,7 @@ struct mux_device | |||
| 112 | uint16_t next_sport; | 112 | uint16_t next_sport; |
| 113 | unsigned char *pktbuf; | 113 | unsigned char *pktbuf; |
| 114 | uint32_t pktlen; | 114 | uint32_t pktlen; |
| 115 | void *preflight_cb_data; | ||
| 115 | }; | 116 | }; |
| 116 | 117 | ||
| 117 | static struct collection device_list; | 118 | static struct collection device_list; |
| @@ -648,6 +649,7 @@ int device_add(struct usb_device *usbdev) | |||
| 648 | dev->next_sport = 1; | 649 | dev->next_sport = 1; |
| 649 | dev->pktbuf = malloc(DEV_MRU); | 650 | dev->pktbuf = malloc(DEV_MRU); |
| 650 | dev->pktlen = 0; | 651 | dev->pktlen = 0; |
| 652 | dev->preflight_cb_data = NULL; | ||
| 651 | struct version_header vh; | 653 | struct version_header vh; |
| 652 | vh.major = htonl(1); | 654 | vh.major = htonl(1); |
| 653 | vh.minor = htonl(0); | 655 | vh.minor = htonl(0); |
| @@ -674,6 +676,9 @@ void device_remove(struct usb_device *usbdev) | |||
| 674 | client_device_remove(dev->id); | 676 | client_device_remove(dev->id); |
| 675 | collection_free(&dev->connections); | 677 | collection_free(&dev->connections); |
| 676 | } | 678 | } |
| 679 | if (dev->preflight_cb_data) { | ||
| 680 | preflight_device_remove_cb(dev->preflight_cb_data); | ||
| 681 | } | ||
| 677 | collection_remove(&device_list, dev); | 682 | collection_remove(&device_list, dev); |
| 678 | free(dev->pktbuf); | 683 | free(dev->pktbuf); |
| 679 | free(dev); | 684 | free(dev); |
| @@ -690,7 +695,17 @@ void device_set_visible(int device_id) | |||
| 690 | dev->visible = 1; | 695 | dev->visible = 1; |
| 691 | break; | 696 | break; |
| 692 | } | 697 | } |
| 693 | } ENDFOREACH | 698 | } ENDFOREACH |
| 699 | } | ||
| 700 | |||
| 701 | void device_set_preflight_cb_data(int device_id, void* data) | ||
| 702 | { | ||
| 703 | FOREACH(struct mux_device *dev, &device_list) { | ||
| 704 | if(dev->id == device_id) { | ||
| 705 | dev->preflight_cb_data = data; | ||
| 706 | break; | ||
| 707 | } | ||
| 708 | } ENDFOREACH | ||
| 694 | } | 709 | } |
| 695 | 710 | ||
| 696 | int device_get_count(int include_hidden) | 711 | int device_get_count(int include_hidden) |
