diff options
| author | 2009-08-19 01:39:16 +0200 | |
|---|---|---|
| committer | 2009-08-19 03:56:09 +0200 | |
| commit | acfba6464bd57bdd0549f083f83b12ff9909337f (patch) | |
| tree | 824f942e9ffef08d241d268f407c9b4ccd19f785 | |
| parent | 3a6f72edfb352ab57f58fb4fe4b6314daaddb362 (diff) | |
| download | usbmuxd-acfba6464bd57bdd0549f083f83b12ff9909337f.tar.gz usbmuxd-acfba6464bd57bdd0549f083f83b12ff9909337f.tar.bz2 | |
Remove trailing whitespace errors
| -rw-r--r-- | usbmuxd/client.c | 20 | ||||
| -rw-r--r-- | usbmuxd/device.c | 56 | ||||
| -rw-r--r-- | usbmuxd/main.c | 8 | ||||
| -rw-r--r-- | usbmuxd/usb-linux.c | 20 |
4 files changed, 52 insertions, 52 deletions
diff --git a/usbmuxd/client.c b/usbmuxd/client.c index b33d892..7a3160f 100644 --- a/usbmuxd/client.c +++ b/usbmuxd/client.c | |||
| @@ -105,11 +105,11 @@ int client_accept(int listenfd) | |||
| 105 | usbmuxd_log(LL_ERROR, "accept() failed (%s)", strerror(errno)); | 105 | usbmuxd_log(LL_ERROR, "accept() failed (%s)", strerror(errno)); |
| 106 | return cfd; | 106 | return cfd; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | struct mux_client *client; | 109 | struct mux_client *client; |
| 110 | client = malloc(sizeof(struct mux_client)); | 110 | client = malloc(sizeof(struct mux_client)); |
| 111 | memset(client, 0, sizeof(struct mux_client)); | 111 | memset(client, 0, sizeof(struct mux_client)); |
| 112 | 112 | ||
| 113 | client->fd = cfd; | 113 | client->fd = cfd; |
| 114 | client->ob_buf = malloc(REPLY_BUF_SIZE); | 114 | client->ob_buf = malloc(REPLY_BUF_SIZE); |
| 115 | client->ob_size = 0; | 115 | client->ob_size = 0; |
| @@ -119,9 +119,9 @@ int client_accept(int listenfd) | |||
| 119 | client->ib_capacity = CMD_BUF_SIZE; | 119 | client->ib_capacity = CMD_BUF_SIZE; |
| 120 | client->state = CLIENT_COMMAND; | 120 | client->state = CLIENT_COMMAND; |
| 121 | client->events = POLLIN; | 121 | client->events = POLLIN; |
| 122 | 122 | ||
| 123 | collection_add(&client_list, client); | 123 | collection_add(&client_list, client); |
| 124 | 124 | ||
| 125 | usbmuxd_log(LL_INFO, "New client on fd %d", client->fd); | 125 | usbmuxd_log(LL_INFO, "New client on fd %d", client->fd); |
| 126 | return client->fd; | 126 | return client->fd; |
| 127 | } | 127 | } |
| @@ -216,14 +216,14 @@ static int start_listen(struct mux_client *client) | |||
| 216 | struct device_info *devs; | 216 | struct device_info *devs; |
| 217 | struct device_info *dev; | 217 | struct device_info *dev; |
| 218 | int count, i; | 218 | int count, i; |
| 219 | 219 | ||
| 220 | client->state = CLIENT_LISTEN; | 220 | client->state = CLIENT_LISTEN; |
| 221 | count = device_get_count(); | 221 | count = device_get_count(); |
| 222 | if(!count) | 222 | if(!count) |
| 223 | return 0; | 223 | return 0; |
| 224 | devs = malloc(sizeof(struct device_info) * count); | 224 | devs = malloc(sizeof(struct device_info) * count); |
| 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 client_msg_dev) + sizeof(struct client_header)) + REPLY_BUF_SIZE; |
| 229 | if(client->ob_capacity < needed_buffer) { | 229 | if(client->ob_capacity < needed_buffer) { |
| @@ -246,7 +246,7 @@ static int client_command(struct mux_client *client, struct client_header *hdr, | |||
| 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); |
| 249 | 249 | ||
| 250 | if(client->state != CLIENT_COMMAND) { | 250 | if(client->state != CLIENT_COMMAND) { |
| 251 | usbmuxd_log(LL_ERROR, "Client %d command received in the wrong state", client->fd); | 251 | usbmuxd_log(LL_ERROR, "Client %d command received in the wrong state", client->fd); |
| 252 | if(send_result(client, hdr->tag, RESULT_BADCOMMAND) < 0) | 252 | if(send_result(client, hdr->tag, RESULT_BADCOMMAND) < 0) |
| @@ -254,7 +254,7 @@ static int client_command(struct mux_client *client, struct client_header *hdr, | |||
| 254 | client_close(client); | 254 | client_close(client); |
| 255 | return -1; | 255 | return -1; |
| 256 | } | 256 | } |
| 257 | 257 | ||
| 258 | struct client_msg_connect *ch; | 258 | struct client_msg_connect *ch; |
| 259 | switch(hdr->message) { | 259 | switch(hdr->message) { |
| 260 | case MESSAGE_LISTEN: | 260 | case MESSAGE_LISTEN: |
| @@ -392,7 +392,7 @@ void client_process(int fd, short events) | |||
| 392 | process_send(client); | 392 | process_send(client); |
| 393 | } | 393 | } |
| 394 | } | 394 | } |
| 395 | 395 | ||
| 396 | } | 396 | } |
| 397 | 397 | ||
| 398 | void client_device_add(struct device_info *dev) | 398 | void client_device_add(struct device_info *dev) |
| @@ -401,7 +401,7 @@ void client_device_add(struct device_info *dev) | |||
| 401 | FOREACH(struct mux_client *client, &client_list) { | 401 | FOREACH(struct mux_client *client, &client_list) { |
| 402 | if(client->state == CLIENT_LISTEN) | 402 | if(client->state == CLIENT_LISTEN) |
| 403 | notify_device(client, dev); | 403 | notify_device(client, dev); |
| 404 | } ENDFOREACH | 404 | } ENDFOREACH |
| 405 | } | 405 | } |
| 406 | void client_device_remove(int device_id) | 406 | void client_device_remove(int device_id) |
| 407 | { | 407 | { |
diff --git a/usbmuxd/device.c b/usbmuxd/device.c index cddf718..3a5883c 100644 --- a/usbmuxd/device.c +++ b/usbmuxd/device.c | |||
| @@ -142,7 +142,7 @@ static int send_packet(struct mux_device *dev, enum mux_protocol proto, void *he | |||
| 142 | unsigned char *buffer; | 142 | unsigned char *buffer; |
| 143 | int hdrlen; | 143 | int hdrlen; |
| 144 | int res; | 144 | int res; |
| 145 | 145 | ||
| 146 | switch(proto) { | 146 | switch(proto) { |
| 147 | case MUX_PROTO_VERSION: | 147 | case MUX_PROTO_VERSION: |
| 148 | hdrlen = sizeof(struct version_header); | 148 | hdrlen = sizeof(struct version_header); |
| @@ -155,14 +155,14 @@ static int send_packet(struct mux_device *dev, enum mux_protocol proto, void *he | |||
| 155 | return -1; | 155 | return -1; |
| 156 | } | 156 | } |
| 157 | usbmuxd_log(LL_SPEW, "send_packet(%d, 0x%x, %p, %p, %d)", dev->id, proto, header, data, length); | 157 | usbmuxd_log(LL_SPEW, "send_packet(%d, 0x%x, %p, %p, %d)", dev->id, proto, header, data, length); |
| 158 | 158 | ||
| 159 | int total = sizeof(struct mux_header) + hdrlen + length; | 159 | int total = sizeof(struct mux_header) + hdrlen + length; |
| 160 | 160 | ||
| 161 | if(total > USB_MTU) { | 161 | if(total > USB_MTU) { |
| 162 | usbmuxd_log(LL_ERROR, "Tried to send packet larger than USB MTU (hdr %d data %d total %d) to device %d", hdrlen, length, total, dev->id); | 162 | usbmuxd_log(LL_ERROR, "Tried to send packet larger than USB MTU (hdr %d data %d total %d) to device %d", hdrlen, length, total, dev->id); |
| 163 | return -1; | 163 | return -1; |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | buffer = malloc(total); | 166 | buffer = malloc(total); |
| 167 | struct mux_header *mhdr = (struct mux_header *)buffer; | 167 | struct mux_header *mhdr = (struct mux_header *)buffer; |
| 168 | mhdr->protocol = htonl(proto); | 168 | mhdr->protocol = htonl(proto); |
| @@ -170,7 +170,7 @@ static int send_packet(struct mux_device *dev, enum mux_protocol proto, void *he | |||
| 170 | memcpy(buffer + sizeof(struct mux_header), header, hdrlen); | 170 | memcpy(buffer + sizeof(struct mux_header), header, hdrlen); |
| 171 | if(data && length) | 171 | if(data && length) |
| 172 | memcpy(buffer + sizeof(struct mux_header) + hdrlen, data, length); | 172 | memcpy(buffer + sizeof(struct mux_header) + hdrlen, data, length); |
| 173 | 173 | ||
| 174 | if((res = usb_send(dev->usbdev, buffer, total)) < 0) { | 174 | if((res = usb_send(dev->usbdev, buffer, total)) < 0) { |
| 175 | usbmuxd_log(LL_ERROR, "usb_send failed while sending packet (len %d) to device %d: %d", total, dev->id, res); | 175 | usbmuxd_log(LL_ERROR, "usb_send failed while sending packet (len %d) to device %d: %d", total, dev->id, res); |
| 176 | free(buffer); | 176 | free(buffer); |
| @@ -183,7 +183,7 @@ static uint16_t find_sport(struct mux_device *dev) | |||
| 183 | { | 183 | { |
| 184 | if(collection_count(&dev->connections) >= 65535) | 184 | if(collection_count(&dev->connections) >= 65535) |
| 185 | return 0; //insanity | 185 | return 0; //insanity |
| 186 | 186 | ||
| 187 | while(1) { | 187 | while(1) { |
| 188 | int ok = 1; | 188 | int ok = 1; |
| 189 | FOREACH(struct mux_connection *conn, &dev->connections) { | 189 | FOREACH(struct mux_connection *conn, &dev->connections) { |
| @@ -207,7 +207,7 @@ static int send_anon_rst(struct mux_device *dev, uint16_t sport, uint16_t dport, | |||
| 207 | th.th_ack = htonl(ack); | 207 | th.th_ack = htonl(ack); |
| 208 | th.th_flags = TH_RST; | 208 | th.th_flags = TH_RST; |
| 209 | th.th_off = sizeof(th) / 4; | 209 | th.th_off = sizeof(th) / 4; |
| 210 | 210 | ||
| 211 | usbmuxd_log(LL_DEBUG, "[OUT] dev=%d sport=%d dport=%d flags=0x%x", dev->id, sport, dport, th.th_flags); | 211 | usbmuxd_log(LL_DEBUG, "[OUT] dev=%d sport=%d dport=%d flags=0x%x", dev->id, sport, dport, th.th_flags); |
| 212 | 212 | ||
| 213 | int res = send_packet(dev, MUX_PROTO_TCP, &th, NULL, 0); | 213 | int res = send_packet(dev, MUX_PROTO_TCP, &th, NULL, 0); |
| @@ -225,7 +225,7 @@ static int send_tcp(struct mux_connection *conn, uint8_t flags, const unsigned c | |||
| 225 | th.th_flags = flags; | 225 | th.th_flags = flags; |
| 226 | th.th_off = sizeof(th) / 4; | 226 | th.th_off = sizeof(th) / 4; |
| 227 | th.th_win = htons(conn->tx_win >> 8); | 227 | th.th_win = htons(conn->tx_win >> 8); |
| 228 | 228 | ||
| 229 | usbmuxd_log(LL_DEBUG, "[OUT] dev=%d sport=%d dport=%d seq=%d ack=%d flags=0x%x window=%d[%d] len=%d", | 229 | usbmuxd_log(LL_DEBUG, "[OUT] dev=%d sport=%d dport=%d seq=%d ack=%d flags=0x%x window=%d[%d] len=%d", |
| 230 | conn->dev->id, conn->sport, conn->dport, conn->tx_seq, conn->tx_ack, flags, conn->tx_win, conn->tx_win >> 8, length); | 230 | conn->dev->id, conn->sport, conn->dport, conn->tx_seq, conn->tx_ack, flags, conn->tx_win, conn->tx_win >> 8, length); |
| 231 | 231 | ||
| @@ -278,7 +278,7 @@ int device_start_connect(int device_id, uint16_t dport, struct mux_client *clien | |||
| 278 | usbmuxd_log(LL_WARNING, "Attempted to connect to nonexistent device %d", device_id); | 278 | usbmuxd_log(LL_WARNING, "Attempted to connect to nonexistent device %d", device_id); |
| 279 | return -RESULT_BADDEV; | 279 | return -RESULT_BADDEV; |
| 280 | } | 280 | } |
| 281 | 281 | ||
| 282 | uint16_t sport = find_sport(dev); | 282 | uint16_t sport = find_sport(dev); |
| 283 | if(!sport) { | 283 | if(!sport) { |
| 284 | usbmuxd_log(LL_WARNING, "Unable to allocate port for device %d", device_id); | 284 | usbmuxd_log(LL_WARNING, "Unable to allocate port for device %d", device_id); |
| @@ -288,7 +288,7 @@ int device_start_connect(int device_id, uint16_t dport, struct mux_client *clien | |||
| 288 | struct mux_connection *conn; | 288 | struct mux_connection *conn; |
| 289 | conn = malloc(sizeof(struct mux_connection)); | 289 | conn = malloc(sizeof(struct mux_connection)); |
| 290 | memset(conn, 0, sizeof(struct mux_connection)); | 290 | memset(conn, 0, sizeof(struct mux_connection)); |
| 291 | 291 | ||
| 292 | conn->dev = dev; | 292 | conn->dev = dev; |
| 293 | conn->client = client; | 293 | conn->client = client; |
| 294 | conn->state = CONN_CONNECTING; | 294 | conn->state = CONN_CONNECTING; |
| @@ -301,15 +301,15 @@ int device_start_connect(int device_id, uint16_t dport, struct mux_client *clien | |||
| 301 | conn->rx_recvd = 0; | 301 | conn->rx_recvd = 0; |
| 302 | conn->flags = 0; | 302 | conn->flags = 0; |
| 303 | conn->max_payload = USB_MTU - sizeof(struct mux_header) - sizeof(struct tcphdr); | 303 | conn->max_payload = USB_MTU - sizeof(struct mux_header) - sizeof(struct tcphdr); |
| 304 | 304 | ||
| 305 | conn->ob_buf = malloc(CONN_OUTBUF_SIZE); | 305 | conn->ob_buf = malloc(CONN_OUTBUF_SIZE); |
| 306 | conn->ob_capacity = CONN_OUTBUF_SIZE; | 306 | conn->ob_capacity = CONN_OUTBUF_SIZE; |
| 307 | conn->ib_buf = malloc(CONN_INBUF_SIZE); | 307 | conn->ib_buf = malloc(CONN_INBUF_SIZE); |
| 308 | conn->ib_capacity = CONN_INBUF_SIZE; | 308 | conn->ib_capacity = CONN_INBUF_SIZE; |
| 309 | conn->ib_size = 0; | 309 | conn->ib_size = 0; |
| 310 | 310 | ||
| 311 | int res; | 311 | int res; |
| 312 | 312 | ||
| 313 | res = send_tcp(conn, TH_SYN, NULL, 0); | 313 | res = send_tcp(conn, TH_SYN, NULL, 0); |
| 314 | if(res < 0) { | 314 | if(res < 0) { |
| 315 | usbmuxd_log(LL_ERROR, "Error sending TCP SYN to device %d (%d->%d)", dev->id, sport, dport); | 315 | usbmuxd_log(LL_ERROR, "Error sending TCP SYN to device %d (%d->%d)", dev->id, sport, dport); |
| @@ -323,12 +323,12 @@ int device_start_connect(int device_id, uint16_t dport, struct mux_client *clien | |||
| 323 | static void update_connection(struct mux_connection *conn) | 323 | static void update_connection(struct mux_connection *conn) |
| 324 | { | 324 | { |
| 325 | conn->sendable = conn->rx_win - (conn->tx_seq - conn->rx_ack); | 325 | conn->sendable = conn->rx_win - (conn->tx_seq - conn->rx_ack); |
| 326 | 326 | ||
| 327 | if(conn->sendable > conn->ob_capacity) | 327 | if(conn->sendable > conn->ob_capacity) |
| 328 | conn->sendable = conn->ob_capacity; | 328 | conn->sendable = conn->ob_capacity; |
| 329 | if(conn->sendable > conn->max_payload) | 329 | if(conn->sendable > conn->max_payload) |
| 330 | conn->sendable = conn->max_payload; | 330 | conn->sendable = conn->max_payload; |
| 331 | 331 | ||
| 332 | if(conn->sendable > 0) | 332 | if(conn->sendable > 0) |
| 333 | conn->events |= POLLIN; | 333 | conn->events |= POLLIN; |
| 334 | else | 334 | else |
| @@ -368,7 +368,7 @@ void device_client_process(int device_id, struct mux_client *client, short event | |||
| 368 | return; | 368 | return; |
| 369 | } | 369 | } |
| 370 | usbmuxd_log(LL_SPEW, "device_client_process (%d)", events); | 370 | usbmuxd_log(LL_SPEW, "device_client_process (%d)", events); |
| 371 | 371 | ||
| 372 | int res; | 372 | int res; |
| 373 | int size; | 373 | int size; |
| 374 | if(events & POLLOUT) { | 374 | if(events & POLLOUT) { |
| @@ -463,7 +463,7 @@ static void device_tcp_input(struct mux_device *dev, struct tcphdr *th, unsigned | |||
| 463 | { | 463 | { |
| 464 | usbmuxd_log(LL_DEBUG, "[IN] dev=%d sport=%d dport=%d seq=%d ack=%d flags=0x%x window=%d[%d] len=%d", | 464 | usbmuxd_log(LL_DEBUG, "[IN] dev=%d sport=%d dport=%d seq=%d ack=%d flags=0x%x window=%d[%d] len=%d", |
| 465 | dev->id, ntohs(th->th_sport), ntohs(th->th_dport), ntohl(th->th_seq), ntohl(th->th_ack), th->th_flags, ntohs(th->th_win) << 8, ntohs(th->th_win), payload_length); | 465 | dev->id, ntohs(th->th_sport), ntohs(th->th_dport), ntohl(th->th_seq), ntohl(th->th_ack), th->th_flags, ntohs(th->th_win) << 8, ntohs(th->th_win), payload_length); |
| 466 | 466 | ||
| 467 | uint16_t sport = ntohs(th->th_dport); | 467 | uint16_t sport = ntohs(th->th_dport); |
| 468 | uint16_t dport = ntohs(th->th_sport); | 468 | uint16_t dport = ntohs(th->th_sport); |
| 469 | struct mux_connection *conn = NULL; | 469 | struct mux_connection *conn = NULL; |
| @@ -473,7 +473,7 @@ static void device_tcp_input(struct mux_device *dev, struct tcphdr *th, unsigned | |||
| 473 | break; | 473 | break; |
| 474 | } | 474 | } |
| 475 | } ENDFOREACH | 475 | } ENDFOREACH |
| 476 | 476 | ||
| 477 | if(!conn) { | 477 | if(!conn) { |
| 478 | usbmuxd_log(LL_WARNING, "No connection for device %d incoming packet %d->%d", dev->id, dport, sport); | 478 | usbmuxd_log(LL_WARNING, "No connection for device %d incoming packet %d->%d", dev->id, dport, sport); |
| 479 | if(!(th->th_flags & TH_RST)) { | 479 | if(!(th->th_flags & TH_RST)) { |
| @@ -482,11 +482,11 @@ static void device_tcp_input(struct mux_device *dev, struct tcphdr *th, unsigned | |||
| 482 | } | 482 | } |
| 483 | return; | 483 | return; |
| 484 | } | 484 | } |
| 485 | 485 | ||
| 486 | conn->rx_seq = ntohl(th->th_seq); | 486 | conn->rx_seq = ntohl(th->th_seq); |
| 487 | conn->rx_ack = ntohl(th->th_ack); | 487 | conn->rx_ack = ntohl(th->th_ack); |
| 488 | conn->rx_win = ntohs(th->th_win) << 8; | 488 | conn->rx_win = ntohs(th->th_win) << 8; |
| 489 | 489 | ||
| 490 | if(th->th_flags & TH_RST) { | 490 | if(th->th_flags & TH_RST) { |
| 491 | char *buf = malloc(payload_length+1); | 491 | char *buf = malloc(payload_length+1); |
| 492 | memcpy(buf, payload, payload_length); | 492 | memcpy(buf, payload, payload_length); |
| @@ -496,7 +496,7 @@ static void device_tcp_input(struct mux_device *dev, struct tcphdr *th, unsigned | |||
| 496 | usbmuxd_log(LL_DEBUG, "RST reason: %s", buf); | 496 | usbmuxd_log(LL_DEBUG, "RST reason: %s", buf); |
| 497 | free(buf); | 497 | free(buf); |
| 498 | } | 498 | } |
| 499 | 499 | ||
| 500 | if(conn->state == CONN_CONNECTING) { | 500 | if(conn->state == CONN_CONNECTING) { |
| 501 | if(th->th_flags != (TH_SYN|TH_ACK)) { | 501 | if(th->th_flags != (TH_SYN|TH_ACK)) { |
| 502 | if(th->th_flags & TH_RST) | 502 | if(th->th_flags & TH_RST) |
| @@ -544,10 +544,10 @@ void device_data_input(struct usb_device *usbdev, unsigned char *buffer, int len | |||
| 544 | usbmuxd_log(LL_WARNING, "Cannot find device entry for RX input from USB device %p on location 0x%x", usbdev, usb_get_location(usbdev)); | 544 | usbmuxd_log(LL_WARNING, "Cannot find device entry for RX input from USB device %p on location 0x%x", usbdev, usb_get_location(usbdev)); |
| 545 | return; | 545 | return; |
| 546 | } | 546 | } |
| 547 | 547 | ||
| 548 | if(!length) | 548 | if(!length) |
| 549 | return; | 549 | return; |
| 550 | 550 | ||
| 551 | usbmuxd_log(LL_SPEW, "Mux data input for device %p: %p len %d", dev, buffer, length); | 551 | usbmuxd_log(LL_SPEW, "Mux data input for device %p: %p len %d", dev, buffer, length); |
| 552 | 552 | ||
| 553 | // handle broken up transfers | 553 | // handle broken up transfers |
| @@ -573,18 +573,18 @@ void device_data_input(struct usb_device *usbdev, unsigned char *buffer, int len | |||
| 573 | return; | 573 | return; |
| 574 | } | 574 | } |
| 575 | } | 575 | } |
| 576 | 576 | ||
| 577 | struct mux_header *mhdr = (struct mux_header *)buffer; | 577 | struct mux_header *mhdr = (struct mux_header *)buffer; |
| 578 | 578 | ||
| 579 | if(ntohl(mhdr->length) != length) { | 579 | if(ntohl(mhdr->length) != length) { |
| 580 | usbmuxd_log(LL_ERROR, "Incoming packet size mismatch (dev %d, expected %d, got %d)", dev->id, ntohl(mhdr->length), length); | 580 | usbmuxd_log(LL_ERROR, "Incoming packet size mismatch (dev %d, expected %d, got %d)", dev->id, ntohl(mhdr->length), length); |
| 581 | return; | 581 | return; |
| 582 | } | 582 | } |
| 583 | 583 | ||
| 584 | struct tcphdr *th; | 584 | struct tcphdr *th; |
| 585 | unsigned char *payload; | 585 | unsigned char *payload; |
| 586 | int payload_length; | 586 | int payload_length; |
| 587 | 587 | ||
| 588 | switch(ntohl(mhdr->protocol)) { | 588 | switch(ntohl(mhdr->protocol)) { |
| 589 | case MUX_PROTO_VERSION: | 589 | case MUX_PROTO_VERSION: |
| 590 | device_version_input(dev, (struct version_header *)(mhdr+1)); | 590 | device_version_input(dev, (struct version_header *)(mhdr+1)); |
| @@ -599,7 +599,7 @@ void device_data_input(struct usb_device *usbdev, unsigned char *buffer, int len | |||
| 599 | usbmuxd_log(LL_ERROR, "Incoming packet for device %d has unknown protocol 0x%x)", dev->id, ntohl(mhdr->protocol)); | 599 | usbmuxd_log(LL_ERROR, "Incoming packet for device %d has unknown protocol 0x%x)", dev->id, ntohl(mhdr->protocol)); |
| 600 | break; | 600 | break; |
| 601 | } | 601 | } |
| 602 | 602 | ||
| 603 | } | 603 | } |
| 604 | 604 | ||
| 605 | int device_add(struct usb_device *usbdev) | 605 | int device_add(struct usb_device *usbdev) |
diff --git a/usbmuxd/main.c b/usbmuxd/main.c index 182178f..be7451f 100644 --- a/usbmuxd/main.c +++ b/usbmuxd/main.c | |||
| @@ -126,7 +126,7 @@ int main_loop(int listenfd) | |||
| 126 | { | 126 | { |
| 127 | int to, cnt, i, dto; | 127 | int to, cnt, i, dto; |
| 128 | struct fdlist pollfds; | 128 | struct fdlist pollfds; |
| 129 | 129 | ||
| 130 | while(!should_exit) { | 130 | while(!should_exit) { |
| 131 | usbmuxd_log(LL_FLOOD, "main_loop iteration"); | 131 | usbmuxd_log(LL_FLOOD, "main_loop iteration"); |
| 132 | to = usb_get_timeout(); | 132 | to = usb_get_timeout(); |
| @@ -135,16 +135,16 @@ int main_loop(int listenfd) | |||
| 135 | usbmuxd_log(LL_FLOOD, "Device timeout is %d ms", to); | 135 | usbmuxd_log(LL_FLOOD, "Device timeout is %d ms", to); |
| 136 | if(dto < to) | 136 | if(dto < to) |
| 137 | to = dto; | 137 | to = dto; |
| 138 | 138 | ||
| 139 | fdlist_create(&pollfds); | 139 | fdlist_create(&pollfds); |
| 140 | fdlist_add(&pollfds, FD_LISTEN, listenfd, POLLIN); | 140 | fdlist_add(&pollfds, FD_LISTEN, listenfd, POLLIN); |
| 141 | usb_get_fds(&pollfds); | 141 | usb_get_fds(&pollfds); |
| 142 | client_get_fds(&pollfds); | 142 | client_get_fds(&pollfds); |
| 143 | usbmuxd_log(LL_FLOOD, "fd count is %d", pollfds.count); | 143 | usbmuxd_log(LL_FLOOD, "fd count is %d", pollfds.count); |
| 144 | 144 | ||
| 145 | cnt = poll(pollfds.fds, pollfds.count, to); | 145 | cnt = poll(pollfds.fds, pollfds.count, to); |
| 146 | usbmuxd_log(LL_FLOOD, "poll() returned %d", cnt); | 146 | usbmuxd_log(LL_FLOOD, "poll() returned %d", cnt); |
| 147 | 147 | ||
| 148 | if(cnt == -1) { | 148 | if(cnt == -1) { |
| 149 | if(errno == EINTR && should_exit) { | 149 | if(errno == EINTR && should_exit) { |
| 150 | usbmuxd_log(LL_INFO, "event processing interrupted"); | 150 | usbmuxd_log(LL_INFO, "event processing interrupted"); |
diff --git a/usbmuxd/usb-linux.c b/usbmuxd/usb-linux.c index a5fc6a0..6e99a95 100644 --- a/usbmuxd/usb-linux.c +++ b/usbmuxd/usb-linux.c | |||
| @@ -58,7 +58,7 @@ static void usb_disconnect(struct usb_device *dev) | |||
| 58 | if(!dev->dev) { | 58 | if(!dev->dev) { |
| 59 | return; | 59 | return; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | // kill the rx xfer and tx xfers and try to make sure the callbacks get called before we free the device | 62 | // kill the rx xfer and tx xfers and try to make sure the callbacks get called before we free the device |
| 63 | if(dev->rx_xfer) { | 63 | if(dev->rx_xfer) { |
| 64 | usbmuxd_log(LL_DEBUG, "usb_disconnect: cancelling RX xfer"); | 64 | usbmuxd_log(LL_DEBUG, "usb_disconnect: cancelling RX xfer"); |
| @@ -72,7 +72,7 @@ static void usb_disconnect(struct usb_device *dev) | |||
| 72 | while(dev->rx_xfer || collection_count(&dev->tx_xfers)) { | 72 | while(dev->rx_xfer || collection_count(&dev->tx_xfers)) { |
| 73 | struct timeval tv; | 73 | struct timeval tv; |
| 74 | int res; | 74 | int res; |
| 75 | 75 | ||
| 76 | tv.tv_sec = 0; | 76 | tv.tv_sec = 0; |
| 77 | tv.tv_usec = 1000; | 77 | tv.tv_usec = 1000; |
| 78 | if((res = libusb_handle_events_timeout(NULL, &tv)) < 0) { | 78 | if((res = libusb_handle_events_timeout(NULL, &tv)) < 0) { |
| @@ -218,7 +218,7 @@ static int usb_discover(void) | |||
| 218 | int cnt, i, res; | 218 | int cnt, i, res; |
| 219 | int valid_count = 0; | 219 | int valid_count = 0; |
| 220 | libusb_device **devs; | 220 | libusb_device **devs; |
| 221 | 221 | ||
| 222 | cnt = libusb_get_device_list(NULL, &devs); | 222 | cnt = libusb_get_device_list(NULL, &devs); |
| 223 | if(cnt < 0) { | 223 | if(cnt < 0) { |
| 224 | usbmuxd_log(LL_WARNING, "Could not get device list: %d", cnt); | 224 | usbmuxd_log(LL_WARNING, "Could not get device list: %d", cnt); |
| @@ -309,7 +309,7 @@ static int usb_discover(void) | |||
| 309 | collection_init(&usbdev->tx_xfers); | 309 | collection_init(&usbdev->tx_xfers); |
| 310 | 310 | ||
| 311 | collection_add(&device_list, usbdev); | 311 | collection_add(&device_list, usbdev); |
| 312 | 312 | ||
| 313 | if(device_add(usbdev) < 0) { | 313 | if(device_add(usbdev) < 0) { |
| 314 | usb_disconnect(usbdev); | 314 | usb_disconnect(usbdev); |
| 315 | continue; | 315 | continue; |
| @@ -327,14 +327,14 @@ static int usb_discover(void) | |||
| 327 | usb_disconnect(usbdev); | 327 | usb_disconnect(usbdev); |
| 328 | } | 328 | } |
| 329 | } ENDFOREACH | 329 | } ENDFOREACH |
| 330 | 330 | ||
| 331 | libusb_free_device_list(devs, 1); | 331 | libusb_free_device_list(devs, 1); |
| 332 | 332 | ||
| 333 | gettimeofday(&next_dev_poll_time, NULL); | 333 | gettimeofday(&next_dev_poll_time, NULL); |
| 334 | next_dev_poll_time.tv_usec += DEVICE_POLL_TIME * 1000; | 334 | next_dev_poll_time.tv_usec += DEVICE_POLL_TIME * 1000; |
| 335 | next_dev_poll_time.tv_sec += next_dev_poll_time.tv_usec / 1000000; | 335 | next_dev_poll_time.tv_sec += next_dev_poll_time.tv_usec / 1000000; |
| 336 | next_dev_poll_time.tv_usec = next_dev_poll_time.tv_usec % 1000000; | 336 | next_dev_poll_time.tv_usec = next_dev_poll_time.tv_usec % 1000000; |
| 337 | 337 | ||
| 338 | return valid_count; | 338 | return valid_count; |
| 339 | } | 339 | } |
| 340 | 340 | ||
| @@ -477,7 +477,7 @@ int usb_init(void) | |||
| 477 | { | 477 | { |
| 478 | int res; | 478 | int res; |
| 479 | usbmuxd_log(LL_DEBUG, "usb_init for linux / libusb 1.0"); | 479 | usbmuxd_log(LL_DEBUG, "usb_init for linux / libusb 1.0"); |
| 480 | 480 | ||
| 481 | devlist_failures = 0; | 481 | devlist_failures = 0; |
| 482 | res = libusb_init(NULL); | 482 | res = libusb_init(NULL); |
| 483 | //libusb_set_debug(NULL, 3); | 483 | //libusb_set_debug(NULL, 3); |
| @@ -485,9 +485,9 @@ int usb_init(void) | |||
| 485 | usbmuxd_log(LL_FATAL, "libusb_init failed: %d", res); | 485 | usbmuxd_log(LL_FATAL, "libusb_init failed: %d", res); |
| 486 | return -1; | 486 | return -1; |
| 487 | } | 487 | } |
| 488 | 488 | ||
| 489 | collection_init(&device_list); | 489 | collection_init(&device_list); |
| 490 | 490 | ||
| 491 | return usb_discover(); | 491 | return usb_discover(); |
| 492 | } | 492 | } |
| 493 | 493 | ||
