mirror of
https://github.com/M66B/NetGuard.git
synced 2025-02-26 08:02:47 +00:00
Native skip TCP options
This commit is contained in:
parent
af04ece071
commit
e1eb6342ba
1 changed files with 15 additions and 8 deletions
|
@ -548,11 +548,13 @@ void handle_ip(const struct arguments *args, const uint8_t *buffer, const uint16
|
||||||
saddr = &ip4hdr->saddr;
|
saddr = &ip4hdr->saddr;
|
||||||
daddr = &ip4hdr->daddr;
|
daddr = &ip4hdr->daddr;
|
||||||
|
|
||||||
if (ip4hdr->frag_off & IP_MF)
|
if (ip4hdr->frag_off & IP_MF) {
|
||||||
|
log_android(ANDROID_LOG_ERROR, "IP fragment");
|
||||||
flags[flen++] = '+';
|
flags[flen++] = '+';
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t optlen = (ip4hdr->ihl - 5) * 4;
|
uint8_t ipoptlen = (ip4hdr->ihl - 5) * 4;
|
||||||
payload = buffer + 20 + optlen;
|
payload = buffer + sizeof(struct iphdr) + ipoptlen;
|
||||||
|
|
||||||
if (ntohs(ip4hdr->tot_len) != length) {
|
if (ntohs(ip4hdr->tot_len) != length) {
|
||||||
log_android(ANDROID_LOG_ERROR, "Invalid length %u header length %u",
|
log_android(ANDROID_LOG_ERROR, "Invalid length %u header length %u",
|
||||||
|
@ -682,13 +684,16 @@ void handle_tcp(const struct arguments *args, const uint8_t *buffer, uint16_t le
|
||||||
|
|
||||||
// Get headers
|
// Get headers
|
||||||
struct iphdr *iphdr = buffer;
|
struct iphdr *iphdr = buffer;
|
||||||
uint8_t optlen = (iphdr->ihl - 5) * 4;
|
uint8_t ipoptlen = (iphdr->ihl - 5) * 4;
|
||||||
struct tcphdr *tcphdr = buffer + sizeof(struct iphdr) + optlen;
|
struct tcphdr *tcphdr = buffer + sizeof(struct iphdr) + ipoptlen;
|
||||||
if (optlen)
|
uint8_t tcpoptlen = (tcphdr->doff - 5) * 4;
|
||||||
log_android(ANDROID_LOG_INFO, "optlen %d", optlen);
|
if (tcpoptlen) {
|
||||||
|
// TODO handle TCP options
|
||||||
|
log_android(ANDROID_LOG_INFO, "optlen %d", tcpoptlen);
|
||||||
|
}
|
||||||
|
|
||||||
// Get data
|
// Get data
|
||||||
uint16_t dataoff = sizeof(struct iphdr) + optlen + sizeof(struct tcphdr);
|
uint16_t dataoff = sizeof(struct iphdr) + ipoptlen + sizeof(struct tcphdr) + tcpoptlen;
|
||||||
uint16_t datalen = length - dataoff;
|
uint16_t datalen = length - dataoff;
|
||||||
|
|
||||||
// Search session
|
// Search session
|
||||||
|
@ -1157,6 +1162,8 @@ int write_tcp(const struct session *cur,
|
||||||
ntohl(tcp->seq) - cur->local_start,
|
ntohl(tcp->seq) - cur->local_start,
|
||||||
ntohl(tcp->ack_seq) - cur->remote_start,
|
ntohl(tcp->ack_seq) - cur->remote_start,
|
||||||
datalen, confirm);
|
datalen, confirm);
|
||||||
|
|
||||||
|
// TODO non blocking
|
||||||
int res = write(tun, buffer, len);
|
int res = write(tun, buffer, len);
|
||||||
|
|
||||||
#ifdef PROFILE
|
#ifdef PROFILE
|
||||||
|
|
Loading…
Reference in a new issue