mirror of
https://github.com/M66B/NetGuard.git
synced 2025-02-26 16:13:01 +00:00
Native simplify logging
This commit is contained in:
parent
568a8b72bc
commit
29ed10ba7d
1 changed files with 36 additions and 54 deletions
|
@ -1164,12 +1164,24 @@ jboolean handle_tcp(const struct arguments *args, const uint8_t *buffer, uint16_
|
||||||
strstate(cur->state));
|
strstate(cur->state));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
char *msg;
|
||||||
|
static const char previous[] = "Previous";
|
||||||
|
static const char repeated[] = "Repeated";
|
||||||
|
static const char invalid[] = "Invalid";
|
||||||
|
static const char keepalive[] = "Keep alive";
|
||||||
|
|
||||||
|
// TODO proper wrap around
|
||||||
if (tcphdr->ack && ((uint32_t) ntohl(tcphdr->seq) + 1) == cur->remote_seq)
|
if (tcphdr->ack && ((uint32_t) ntohl(tcphdr->seq) + 1) == cur->remote_seq)
|
||||||
log_android(ANDROID_LOG_WARN,
|
msg = keepalive;
|
||||||
"Keep alive from %s/%u to %s/%u state %s",
|
else if (ntohl(tcphdr->seq) == cur->remote_seq &&
|
||||||
source, ntohs(tcphdr->source), dest, ntohs(cur->dest),
|
ntohl(tcphdr->ack_seq) < cur->local_seq)
|
||||||
strstate(cur->state));
|
msg = previous;
|
||||||
else {
|
else if (ntohl(tcphdr->seq) < cur->remote_seq &&
|
||||||
|
ntohl(tcphdr->ack_seq) == cur->local_seq)
|
||||||
|
msg = repeated;
|
||||||
|
else
|
||||||
|
msg = invalid;
|
||||||
|
|
||||||
char flags[10];
|
char flags[10];
|
||||||
int flen = 0;
|
int flen = 0;
|
||||||
if (tcphdr->syn)
|
if (tcphdr->syn)
|
||||||
|
@ -1180,12 +1192,9 @@ jboolean handle_tcp(const struct arguments *args, const uint8_t *buffer, uint16_
|
||||||
flags[flen++] = 'F';
|
flags[flen++] = 'F';
|
||||||
flags[flen] = 0;
|
flags[flen] = 0;
|
||||||
|
|
||||||
// TODO proper wrap around
|
|
||||||
if (ntohl(tcphdr->seq) == cur->remote_seq &&
|
|
||||||
ntohl(tcphdr->ack_seq) < cur->local_seq) {
|
|
||||||
log_android(tcphdr->fin ? ANDROID_LOG_WARN : ANDROID_LOG_INFO,
|
log_android(tcphdr->fin ? ANDROID_LOG_WARN : ANDROID_LOG_INFO,
|
||||||
"Previous %s from %s/%u to %s/%u state %s seq %u/%u ack %u/%u data %d",
|
"%s %s from %s/%u to %s/%u state %s seq %u/%u ack %u/%u data %d",
|
||||||
flags,
|
msg, flags,
|
||||||
source, ntohs(tcphdr->source),
|
source, ntohs(tcphdr->source),
|
||||||
dest, ntohs(cur->dest),
|
dest, ntohs(cur->dest),
|
||||||
strstate(cur->state),
|
strstate(cur->state),
|
||||||
|
@ -1194,33 +1203,6 @@ jboolean handle_tcp(const struct arguments *args, const uint8_t *buffer, uint16_
|
||||||
ntohl(tcphdr->ack_seq) - cur->local_start,
|
ntohl(tcphdr->ack_seq) - cur->local_start,
|
||||||
cur->local_seq - cur->local_start,
|
cur->local_seq - cur->local_start,
|
||||||
datalen);
|
datalen);
|
||||||
|
|
||||||
} else if (ntohl(tcphdr->seq) < cur->remote_seq &&
|
|
||||||
ntohl(tcphdr->ack_seq) == cur->local_seq)
|
|
||||||
log_android(tcphdr->fin ? ANDROID_LOG_WARN : ANDROID_LOG_INFO,
|
|
||||||
"Repeated %s from %s/%u to %s/%u state %s seq %u/%u ack %u/%u data %d",
|
|
||||||
flags,
|
|
||||||
source, ntohs(tcphdr->source),
|
|
||||||
dest, ntohs(cur->dest),
|
|
||||||
strstate(cur->state),
|
|
||||||
ntohl(tcphdr->seq) - cur->remote_start,
|
|
||||||
cur->remote_seq - cur->remote_start,
|
|
||||||
ntohl(tcphdr->ack_seq) - cur->local_start,
|
|
||||||
cur->local_seq - cur->local_start,
|
|
||||||
datalen);
|
|
||||||
else
|
|
||||||
log_android(ANDROID_LOG_ERROR,
|
|
||||||
"Invalid %s from %s/%u to %s/%u state %s seq %u/%u ack %u/%u data %d",
|
|
||||||
flags,
|
|
||||||
source, ntohs(tcphdr->source),
|
|
||||||
dest, ntohs(cur->dest),
|
|
||||||
strstate(cur->state),
|
|
||||||
ntohl(tcphdr->seq) - cur->remote_start,
|
|
||||||
cur->remote_seq - cur->remote_start,
|
|
||||||
ntohl(tcphdr->ack_seq) - cur->local_start,
|
|
||||||
cur->local_seq - cur->local_start,
|
|
||||||
datalen);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue