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
#include <inttypes.h>
#include "device.h"
#include "client.h"
+#include "preflight.h"
#include "usb.h"
#include "log.h"
@@ -106,6 +107,7 @@ struct mux_device
struct usb_device *usbdev;
int id;
enum mux_dev_state state;
+ int visible;
struct collection connections;
uint16_t next_sport;
unsigned char *pktbuf;
@@ -461,7 +463,7 @@ static void device_version_input(struct mux_device *dev, struct version_header *
info.location = usb_get_location(dev->usbdev);
info.serial = usb_get_serial(dev->usbdev);
info.pid = usb_get_pid(dev->usbdev);
- client_device_add(&info);
+ preflight_worker_device_add(&info);
}
static 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)
dev->id = id;
dev->usbdev = usbdev;
dev->state = MUXDEV_INIT;
+ dev->visible = 0;
dev->next_sport = 1;
dev->pktbuf = malloc(DEV_MRU);
dev->pktlen = 0;
@@ -680,11 +683,21 @@ void device_remove(struct usb_device *usbdev)
usbmuxd_log(LL_WARNING, "Cannot find device entry while removing USB device %p on location 0x%x", usbdev, usb_get_location(usbdev));
}
+void device_set_visible(int device_id)
+{
+ FOREACH(struct mux_device *dev, &device_list) {
+ if(dev->id == device_id) {
+ dev->visible = 1;
+ break;
+ }
+ } ENDFOREACH
+}
+
int device_get_count(void)
{
int count = 0;
FOREACH(struct mux_device *dev, &device_list) {
- if(dev->state == MUXDEV_ACTIVE)
+ if((dev->state == MUXDEV_ACTIVE) && dev->visible)
count++;
} ENDFOREACH
return count;
@@ -694,7 +707,7 @@ int device_get_list(struct device_info *p)
{
int count = 0;
FOREACH(struct mux_device *dev, &device_list) {
- if(dev->state == MUXDEV_ACTIVE) {
+ if((dev->state == MUXDEV_ACTIVE) && dev->visible) {
p->id = dev->id;
p->serial = usb_get_serial(dev->usbdev);
p->location = usb_get_location(dev->usbdev);