Native FIN+ACK on local close

This commit is contained in:
M66B 2016-01-20 20:07:35 +01:00
parent 3b1e5446d5
commit ad0445676c
2 changed files with 15 additions and 3 deletions

View File

@ -594,7 +594,7 @@ void check_tcp_sockets(const struct arguments *args, fd_set *rfds, fd_set *wfds,
log_android(ANDROID_LOG_DEBUG, "recv empty lport %u state %s",
cur->lport, strstate(cur->state));
if (write_fin(args, cur, args->tun) >= 0) {
if (write_fin_ack(args, cur, 0, args->tun) >= 0) {
cur->local_seq++; // local FIN
if (cur->state == TCP_SYN_RECV || cur->state == TCP_ESTABLISHED)
@ -1098,8 +1098,8 @@ jboolean handle_tcp(const struct arguments *args, const uint8_t *buffer, uint16_
}
}
else {
if (write_ack(args, cur, confirm, args->tun) >= 0)
cur->remote_seq += 1;
// if (write_ack(args, cur, confirm, args->tun) >= 0)
// cur->remote_seq += 1;
}
}
else {
@ -1336,6 +1336,16 @@ int write_data(const struct arguments *args, struct tcp_session *cur, const uint
}
int write_fin_ack(const struct arguments *args, struct tcp_session *cur, int bytes, int tun) {
if (write_tcp(args, cur, NULL, 0, bytes, 0, 1, 1, 0, tun) < 0) {
log_android(ANDROID_LOG_ERROR, "write FIN+ACK error %d: %s",
errno, strerror((errno)));
cur->state = TCP_TIME_WAIT;
return -1;
}
return 0;
}
int write_fin(const struct arguments *args, struct tcp_session *cur, int tun) {
if (write_tcp(args, cur, NULL, 0, 0, 0, 0, 1, 0, tun) < 0) {
log_android(ANDROID_LOG_ERROR,

View File

@ -117,6 +117,8 @@ int write_ack(const struct arguments *args, struct tcp_session *cur, int bytes,
int write_data(const struct arguments *args, struct tcp_session *cur,
const uint8_t *buffer, uint16_t length, int tun);
int write_fin_ack(const struct arguments *args, struct tcp_session *cur, int bytes, int tun);
int write_fin(const struct arguments *args, struct tcp_session *cur, int tun);
void write_rst(const struct arguments *args, struct tcp_session *cur, int tun);