summaryrefslogtreecommitdiffstats
path: root/usbmuxd/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'usbmuxd/client.c')
-rw-r--r--usbmuxd/client.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/usbmuxd/client.c b/usbmuxd/client.c
index 7a3160f..0e47e84 100644
--- a/usbmuxd/client.c
+++ b/usbmuxd/client.c
@@ -150,10 +150,10 @@ void client_get_fds(struct fdlist *list)
150 } ENDFOREACH 150 } ENDFOREACH
151} 151}
152 152
153static int send_pkt(struct mux_client *client, uint32_t tag, enum client_msgtype msg, void *payload, int payload_length) 153static int send_pkt(struct mux_client *client, uint32_t tag, enum usbmuxd_msgtype msg, void *payload, int payload_length)
154{ 154{
155 struct client_header hdr; 155 struct usbmuxd_header hdr;
156 hdr.version = CLIENT_PROTOCOL_VERSION; 156 hdr.version = USBMUXD_PROTOCOL_VERSION;
157 hdr.length = sizeof(hdr) + payload_length; 157 hdr.length = sizeof(hdr) + payload_length;
158 hdr.message = msg; 158 hdr.message = msg;
159 hdr.tag = tag; 159 hdr.tag = tag;
@@ -176,7 +176,7 @@ static int send_result(struct mux_client *client, uint32_t tag, uint32_t result)
176 return send_pkt(client, tag, MESSAGE_RESULT, &result, sizeof(uint32_t)); 176 return send_pkt(client, tag, MESSAGE_RESULT, &result, sizeof(uint32_t));
177} 177}
178 178
179int client_notify_connect(struct mux_client *client, enum client_result result) 179int client_notify_connect(struct mux_client *client, enum usbmuxd_result result)
180{ 180{
181 usbmuxd_log(LL_SPEW, "client_notify_connect fd %d result %d", client->fd, result); 181 usbmuxd_log(LL_SPEW, "client_notify_connect fd %d result %d", client->fd, result);
182 if(client->state == CLIENT_DEAD) 182 if(client->state == CLIENT_DEAD)
@@ -201,13 +201,13 @@ int client_notify_connect(struct mux_client *client, enum client_result result)
201 201
202static int notify_device(struct mux_client *client, struct device_info *dev) 202static int notify_device(struct mux_client *client, struct device_info *dev)
203{ 203{
204 struct client_msg_dev dmsg; 204 struct usbmuxd_device_record dmsg;
205 memset(&dmsg, 0, sizeof(dmsg)); 205 memset(&dmsg, 0, sizeof(dmsg));
206 dmsg.device_id = dev->id; 206 dmsg.device_id = dev->id;
207 strncpy(dmsg.device_serial, dev->serial, 256); 207 strncpy(dmsg.serial_number, dev->serial, 256);
208 dmsg.device_serial[255] = 0; 208 dmsg.serial_number[255] = 0;
209 dmsg.location = dev->location; 209 dmsg.location = dev->location;
210 dmsg.device_pid = dev->pid; 210 dmsg.product_id = dev->pid;
211 return send_pkt(client, 0, MESSAGE_DEVICE_ADD, &dmsg, sizeof(dmsg)); 211 return send_pkt(client, 0, MESSAGE_DEVICE_ADD, &dmsg, sizeof(dmsg));
212} 212}
213 213
@@ -225,7 +225,7 @@ static int start_listen(struct mux_client *client)
225 count = device_get_list(devs); 225 count = device_get_list(devs);
226 226
227 // going to need a larger buffer for many devices 227 // going to need a larger buffer for many devices
228 int needed_buffer = count * (sizeof(struct client_msg_dev) + sizeof(struct client_header)) + REPLY_BUF_SIZE; 228 int needed_buffer = count * (sizeof(struct usbmuxd_device_record) + sizeof(struct usbmuxd_header)) + REPLY_BUF_SIZE;
229 if(client->ob_capacity < needed_buffer) { 229 if(client->ob_capacity < needed_buffer) {
230 usbmuxd_log(LL_DEBUG, "Enlarging client %d reply buffer %d -> %d to make space for device notifications", client->fd, client->ob_capacity, needed_buffer); 230 usbmuxd_log(LL_DEBUG, "Enlarging client %d reply buffer %d -> %d to make space for device notifications", client->fd, client->ob_capacity, needed_buffer);
231 client->ob_buf = realloc(client->ob_buf, needed_buffer); 231 client->ob_buf = realloc(client->ob_buf, needed_buffer);
@@ -242,7 +242,7 @@ static int start_listen(struct mux_client *client)
242 return count; 242 return count;
243} 243}
244 244
245static int client_command(struct mux_client *client, struct client_header *hdr, const char *payload) 245static int client_command(struct mux_client *client, struct usbmuxd_header *hdr, const char *payload)
246{ 246{
247 int res; 247 int res;
248 usbmuxd_log(LL_DEBUG, "Client command in fd %d len %d ver %d msg %d tag %d", client->fd, hdr->length, hdr->version, hdr->message, hdr->tag); 248 usbmuxd_log(LL_DEBUG, "Client command in fd %d len %d ver %d msg %d tag %d", client->fd, hdr->length, hdr->version, hdr->message, hdr->tag);
@@ -255,7 +255,7 @@ static int client_command(struct mux_client *client, struct client_header *hdr,
255 return -1; 255 return -1;
256 } 256 }
257 257
258 struct client_msg_connect *ch; 258 struct usbmuxd_connect_request *ch;
259 switch(hdr->message) { 259 switch(hdr->message) {
260 case MESSAGE_LISTEN: 260 case MESSAGE_LISTEN:
261 if(send_result(client, hdr->tag, 0) < 0) 261 if(send_result(client, hdr->tag, 0) < 0)
@@ -318,8 +318,8 @@ static void process_recv(struct mux_client *client)
318{ 318{
319 int res; 319 int res;
320 int did_read = 0; 320 int did_read = 0;
321 if(client->ib_size < sizeof(struct client_header)) { 321 if(client->ib_size < sizeof(struct usbmuxd_header)) {
322 res = recv(client->fd, client->ib_buf + client->ib_size, sizeof(struct client_header) - client->ib_size, 0); 322 res = recv(client->fd, client->ib_buf + client->ib_size, sizeof(struct usbmuxd_header) - client->ib_size, 0);
323 if(res <= 0) { 323 if(res <= 0) {
324 if(res < 0) 324 if(res < 0)
325 usbmuxd_log(LL_ERROR, "Receive from client fd %d failed: %s", client->fd, strerror(errno)); 325 usbmuxd_log(LL_ERROR, "Receive from client fd %d failed: %s", client->fd, strerror(errno));
@@ -329,20 +329,20 @@ static void process_recv(struct mux_client *client)
329 return; 329 return;
330 } 330 }
331 client->ib_size += res; 331 client->ib_size += res;
332 if(client->ib_size < sizeof(struct client_header)) 332 if(client->ib_size < sizeof(struct usbmuxd_header))
333 return; 333 return;
334 did_read = 1; 334 did_read = 1;
335 } 335 }
336 struct client_header *hdr = (void*)client->ib_buf; 336 struct usbmuxd_header *hdr = (void*)client->ib_buf;
337 if(hdr->version != CLIENT_PROTOCOL_VERSION) { 337 if(hdr->version != USBMUXD_PROTOCOL_VERSION) {
338 usbmuxd_log(LL_INFO, "Client %d version mismatch: expected %d, got %d", client->fd, CLIENT_PROTOCOL_VERSION, hdr->version); 338 usbmuxd_log(LL_INFO, "Client %d version mismatch: expected %d, got %d", client->fd, USBMUXD_PROTOCOL_VERSION, hdr->version);
339 client_close(client); 339 client_close(client);
340 } 340 }
341 if(hdr->length > client->ib_capacity) { 341 if(hdr->length > client->ib_capacity) {
342 usbmuxd_log(LL_INFO, "Client %d message is too long (%d bytes)", client->fd, hdr->length); 342 usbmuxd_log(LL_INFO, "Client %d message is too long (%d bytes)", client->fd, hdr->length);
343 client_close(client); 343 client_close(client);
344 } 344 }
345 if(hdr->length < sizeof(struct client_header)) { 345 if(hdr->length < sizeof(struct usbmuxd_header)) {
346 usbmuxd_log(LL_ERROR, "Client %d message is too short (%d bytes)", client->fd, hdr->length); 346 usbmuxd_log(LL_ERROR, "Client %d message is too short (%d bytes)", client->fd, hdr->length);
347 client_close(client); 347 client_close(client);
348 } 348 }