summaryrefslogtreecommitdiffstats
path: root/testclient.c
diff options
context:
space:
mode:
Diffstat (limited to 'testclient.c')
-rw-r--r--testclient.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/testclient.c b/testclient.c
index 679b6d0..dc2dd28 100644
--- a/testclient.c
+++ b/testclient.c
@@ -44,12 +44,12 @@ int main(int argc, char **argv)
44{ 44{
45 int sfd; 45 int sfd;
46 int recv_len = 0; 46 int recv_len = 0;
47 int hello_done; 47 int scan_done;
48 int connected; 48 int connected;
49 uint32_t pktlen; 49 uint32_t pktlen;
50 unsigned char *buf; 50 unsigned char *buf;
51 struct usbmuxd_hello hello; 51 struct usbmuxd_scan_request scan;
52 struct usbmuxd_device_info device_info; 52 struct am_device_info device_info;
53 53
54 sfd = connect_unix_socket(USBMUXD_SOCKET_FILE); 54 sfd = connect_unix_socket(USBMUXD_SOCKET_FILE);
55 if (sfd < 0) { 55 if (sfd < 0) {
@@ -57,31 +57,31 @@ int main(int argc, char **argv)
57 return -1; 57 return -1;
58 } 58 }
59 59
60 // send hello 60 // send scan
61 hello.header.length = sizeof(struct usbmuxd_hello); 61 scan.header.length = sizeof(struct usbmuxd_scan_request);
62 hello.header.reserved = 0; 62 scan.header.reserved = 0;
63 hello.header.type = USBMUXD_HELLO; 63 scan.header.type = USBMUXD_SCAN;
64 hello.header.tag = 2; 64 scan.header.tag = 2;
65 65
66 hello_done = 0; 66 scan_done = 0;
67 connected = 0; 67 connected = 0;
68 68
69 fprintf(stdout, "sending Hello packet\n"); 69 fprintf(stdout, "sending scan packet\n");
70 if (send(sfd, &hello, hello.header.length, 0) == hello.header.length) { 70 if (send(sfd, &scan, scan.header.length, 0) == scan.header.length) {
71 uint32_t res = -1; 71 uint32_t res = -1;
72 // get response 72 // get response
73 if (usbmuxd_get_result(sfd, hello.header.tag, &res) && (res==0)) { 73 if (usbmuxd_get_result(sfd, scan.header.tag, &res) && (res==0)) {
74 fprintf(stdout, "Got Hello Response!\n"); 74 fprintf(stdout, "Got response to scan request!\n");
75 hello_done = 1; 75 scan_done = 1;
76 } else { 76 } else {
77 fprintf(stderr, "Did not get Hello response (with result=0)...\n"); 77 fprintf(stderr, "Did not get response to scan request (with result=0)...\n");
78 close(sfd); 78 close(sfd);
79 return -1; 79 return -1;
80 } 80 }
81 81
82 device_info.device_id = 0; 82 device_info.device_id = 0;
83 83
84 if (hello_done) { 84 if (scan_done) {
85 // get all devices 85 // get all devices
86 while (1) { 86 while (1) {
87 if (recv_buf_timeout(sfd, &pktlen, 4, MSG_PEEK, 1000) == 4) { 87 if (recv_buf_timeout(sfd, &pktlen, 4, MSG_PEEK, 1000) == 4) {