diff options
Diffstat (limited to 'usbmuxd/device.c')
| -rw-r--r-- | usbmuxd/device.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/usbmuxd/device.c b/usbmuxd/device.c index 9296ea2..cddf718 100644 --- a/usbmuxd/device.c +++ b/usbmuxd/device.c | |||
| @@ -198,6 +198,22 @@ static uint16_t find_sport(struct mux_device *dev) | |||
| 198 | } | 198 | } |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | static int send_anon_rst(struct mux_device *dev, uint16_t sport, uint16_t dport, uint32_t ack) | ||
| 202 | { | ||
| 203 | struct tcphdr th; | ||
| 204 | memset(&th, 0, sizeof(th)); | ||
| 205 | th.th_sport = htons(sport); | ||
| 206 | th.th_dport = htons(dport); | ||
| 207 | th.th_ack = htonl(ack); | ||
| 208 | th.th_flags = TH_RST; | ||
| 209 | th.th_off = sizeof(th) / 4; | ||
| 210 | |||
| 211 | usbmuxd_log(LL_DEBUG, "[OUT] dev=%d sport=%d dport=%d flags=0x%x", dev->id, sport, dport, th.th_flags); | ||
| 212 | |||
| 213 | int res = send_packet(dev, MUX_PROTO_TCP, &th, NULL, 0); | ||
| 214 | return res; | ||
| 215 | } | ||
| 216 | |||
| 201 | static int send_tcp(struct mux_connection *conn, uint8_t flags, const unsigned char *data, int length) | 217 | static int send_tcp(struct mux_connection *conn, uint8_t flags, const unsigned char *data, int length) |
| 202 | { | 218 | { |
| 203 | struct tcphdr th; | 219 | struct tcphdr th; |
| @@ -460,6 +476,10 @@ static void device_tcp_input(struct mux_device *dev, struct tcphdr *th, unsigned | |||
| 460 | 476 | ||
| 461 | if(!conn) { | 477 | if(!conn) { |
| 462 | 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)) { | ||
| 480 | if(send_anon_rst(dev, sport, dport, ntohl(th->th_seq)) < 0) | ||
| 481 | usbmuxd_log(LL_ERROR, "Error sending TCP RST to device %d (%d->%d)", conn->dev->id, sport, dport); | ||
| 482 | } | ||
| 463 | return; | 483 | return; |
| 464 | } | 484 | } |
| 465 | 485 | ||
