diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/usbmux.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/usbmux.c b/src/usbmux.c index d7f0710..1d6497e 100644 --- a/src/usbmux.c +++ b/src/usbmux.c | |||
| @@ -28,7 +28,6 @@ | |||
| 28 | 28 | ||
| 29 | #define BULKIN 0x85 | 29 | #define BULKIN 0x85 |
| 30 | #define BULKOUT 0x04 | 30 | #define BULKOUT 0x04 |
| 31 | #define HEADERLEN 28 | ||
| 32 | 31 | ||
| 33 | static const uint8_t TCP_FIN = 1; | 32 | static const uint8_t TCP_FIN = 1; |
| 34 | static const uint8_t TCP_SYN = 1 << 1; | 33 | static const uint8_t TCP_SYN = 1 << 1; |
| @@ -570,7 +569,7 @@ usbmux_tcp_header *new_mux_packet(uint16_t s_port, uint16_t d_port) | |||
| 570 | usbmux_tcp_header *conn = | 569 | usbmux_tcp_header *conn = |
| 571 | (usbmux_tcp_header *) malloc(sizeof(usbmux_tcp_header)); | 570 | (usbmux_tcp_header *) malloc(sizeof(usbmux_tcp_header)); |
| 572 | conn->type = htonl(6); | 571 | conn->type = htonl(6); |
| 573 | conn->length = HEADERLEN; | 572 | conn->length = sizeof(usbmux_tcp_header); |
| 574 | conn->sport = htons(s_port); | 573 | conn->sport = htons(s_port); |
| 575 | conn->dport = htons(d_port); | 574 | conn->dport = htons(d_port); |
| 576 | conn->scnt = 0; | 575 | conn->scnt = 0; |
| @@ -578,7 +577,7 @@ usbmux_tcp_header *new_mux_packet(uint16_t s_port, uint16_t d_port) | |||
| 578 | conn->offset = 0x50; | 577 | conn->offset = 0x50; |
| 579 | conn->window = htons(0x0200); | 578 | conn->window = htons(0x0200); |
| 580 | conn->nullnull = 0x0000; | 579 | conn->nullnull = 0x0000; |
| 581 | conn->length16 = HEADERLEN; | 580 | conn->length16 = sizeof(usbmux_tcp_header); |
| 582 | return conn; | 581 | return conn; |
| 583 | } | 582 | } |
| 584 | 583 | ||
| @@ -879,7 +878,7 @@ int usbmux_send(usbmux_client_t client, const char *data, uint32_t datalen, | |||
| 879 | return sendresult; | 878 | return sendresult; |
| 880 | } else if ((uint32_t) sendresult == blocksize) { | 879 | } else if ((uint32_t) sendresult == blocksize) { |
| 881 | // actual number of data bytes sent. | 880 | // actual number of data bytes sent. |
| 882 | *sent_bytes = sendresult - HEADERLEN; | 881 | *sent_bytes = sendresult - sizeof(usbmux_tcp_header); |
| 883 | return 0; | 882 | return 0; |
| 884 | } else { | 883 | } else { |
| 885 | fprintf(stderr, | 884 | fprintf(stderr, |
| @@ -903,9 +902,9 @@ uint32_t append_receive_buffer(usbmux_client_t client, char *packet) | |||
| 903 | return 0; | 902 | return 0; |
| 904 | 903 | ||
| 905 | usbmux_tcp_header *header = (usbmux_tcp_header *) packet; | 904 | usbmux_tcp_header *header = (usbmux_tcp_header *) packet; |
| 906 | char *data = &packet[HEADERLEN]; | 905 | char *data = &packet[sizeof(usbmux_tcp_header)]; |
| 907 | uint32_t packetlen = ntohl(header->length); | 906 | uint32_t packetlen = ntohl(header->length); |
| 908 | uint32_t datalen = packetlen - HEADERLEN; | 907 | uint32_t datalen = packetlen - sizeof(usbmux_tcp_header); |
| 909 | 908 | ||
| 910 | int dobroadcast = 0; | 909 | int dobroadcast = 0; |
| 911 | 910 | ||
| @@ -1114,7 +1113,7 @@ int usbmux_pullbulk(usbmux_device_t device) | |||
| 1114 | cursor = device->usbReceive.buffer; | 1113 | cursor = device->usbReceive.buffer; |
| 1115 | while (1) { | 1114 | while (1) { |
| 1116 | // check if there's even sufficient data to decode a header | 1115 | // check if there's even sufficient data to decode a header |
| 1117 | if (device->usbReceive.leftover < HEADERLEN) | 1116 | if (device->usbReceive.leftover < sizeof(usbmux_tcp_header)) |
| 1118 | break; | 1117 | break; |
| 1119 | usbmux_tcp_header *header = (usbmux_tcp_header *) cursor; | 1118 | usbmux_tcp_header *header = (usbmux_tcp_header *) cursor; |
| 1120 | 1119 | ||
