summaryrefslogtreecommitdiffstats
path: root/src/device.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-09-19 07:45:02 +0200
committerGravatar Nikias Bassen2013-09-19 07:45:02 +0200
commitf631e8e055dfcdae440631902ed8a38eb5109cb8 (patch)
treeeeac77f6fef5eea8399160dc2ca1cb001ecfc338 /src/device.c
parent23bcddf12b520f613451705e3f85c38c40333a90 (diff)
downloadusbmuxd-f631e8e055dfcdae440631902ed8a38eb5109cb8.tar.gz
usbmuxd-f631e8e055dfcdae440631902ed8a38eb5109cb8.tar.bz2
added preflight worker implementation to handle initial device pairing
Diffstat (limited to 'src/device.c')
-rw-r--r--src/device.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/device.c b/src/device.c
index 91712be..27e25d5 100644
--- a/src/device.c
+++ b/src/device.c
@@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33#include <inttypes.h> 33#include <inttypes.h>
34#include "device.h" 34#include "device.h"
35#include "client.h" 35#include "client.h"
36#include "preflight.h"
36#include "usb.h" 37#include "usb.h"
37#include "log.h" 38#include "log.h"
38 39
@@ -106,6 +107,7 @@ struct mux_device
106 struct usb_device *usbdev; 107 struct usb_device *usbdev;
107 int id; 108 int id;
108 enum mux_dev_state state; 109 enum mux_dev_state state;
110 int visible;
109 struct collection connections; 111 struct collection connections;
110 uint16_t next_sport; 112 uint16_t next_sport;
111 unsigned char *pktbuf; 113 unsigned char *pktbuf;
@@ -461,7 +463,7 @@ static void device_version_input(struct mux_device *dev, struct version_header *
461 info.location = usb_get_location(dev->usbdev); 463 info.location = usb_get_location(dev->usbdev);
462 info.serial = usb_get_serial(dev->usbdev); 464 info.serial = usb_get_serial(dev->usbdev);
463 info.pid = usb_get_pid(dev->usbdev); 465 info.pid = usb_get_pid(dev->usbdev);
464 client_device_add(&info); 466 preflight_worker_device_add(&info);
465} 467}
466 468
467static void device_tcp_input(struct mux_device *dev, struct tcphdr *th, unsigned char *payload, uint32_t payload_length) 469static void device_tcp_input(struct mux_device *dev, struct tcphdr *th, unsigned char *payload, uint32_t payload_length)
@@ -642,6 +644,7 @@ int device_add(struct usb_device *usbdev)
642 dev->id = id; 644 dev->id = id;
643 dev->usbdev = usbdev; 645 dev->usbdev = usbdev;
644 dev->state = MUXDEV_INIT; 646 dev->state = MUXDEV_INIT;
647 dev->visible = 0;
645 dev->next_sport = 1; 648 dev->next_sport = 1;
646 dev->pktbuf = malloc(DEV_MRU); 649 dev->pktbuf = malloc(DEV_MRU);
647 dev->pktlen = 0; 650 dev->pktlen = 0;
@@ -680,11 +683,21 @@ void device_remove(struct usb_device *usbdev)
680 usbmuxd_log(LL_WARNING, "Cannot find device entry while removing USB device %p on location 0x%x", usbdev, usb_get_location(usbdev)); 683 usbmuxd_log(LL_WARNING, "Cannot find device entry while removing USB device %p on location 0x%x", usbdev, usb_get_location(usbdev));
681} 684}
682 685
686void device_set_visible(int device_id)
687{
688 FOREACH(struct mux_device *dev, &device_list) {
689 if(dev->id == device_id) {
690 dev->visible = 1;
691 break;
692 }
693 } ENDFOREACH
694}
695
683int device_get_count(void) 696int device_get_count(void)
684{ 697{
685 int count = 0; 698 int count = 0;
686 FOREACH(struct mux_device *dev, &device_list) { 699 FOREACH(struct mux_device *dev, &device_list) {
687 if(dev->state == MUXDEV_ACTIVE) 700 if((dev->state == MUXDEV_ACTIVE) && dev->visible)
688 count++; 701 count++;
689 } ENDFOREACH 702 } ENDFOREACH
690 return count; 703 return count;
@@ -694,7 +707,7 @@ int device_get_list(struct device_info *p)
694{ 707{
695 int count = 0; 708 int count = 0;
696 FOREACH(struct mux_device *dev, &device_list) { 709 FOREACH(struct mux_device *dev, &device_list) {
697 if(dev->state == MUXDEV_ACTIVE) { 710 if((dev->state == MUXDEV_ACTIVE) && dev->visible) {
698 p->id = dev->id; 711 p->id = dev->id;
699 p->serial = usb_get_serial(dev->usbdev); 712 p->serial = usb_get_serial(dev->usbdev);
700 p->location = usb_get_location(dev->usbdev); 713 p->location = usb_get_location(dev->usbdev);