Browse Source

fixed SYN IP packet crafting for debug server

master
Beau Kujath 1 year ago
parent
commit
d152d5de34
  1. 284
      NetGuard/app/src/main/jni/netguard/debug_conn.c
  2. 108
      NetGuard/app/src/main/jni/netguard/ip.c
  3. 2
      NetGuard/app/src/main/jni/netguard/netguard.c
  4. 13
      NetGuard/app/src/main/jni/netguard/netguard.h
  5. 21
      NetGuard/app/src/main/jni/netguard/session.c
  6. 43
      NetGuard/app/src/main/jni/netguard/tcp.c

284
NetGuard/app/src/main/jni/netguard/debug_conn.c

@ -7,181 +7,217 @@
struct ng_session *debug_socket;
uint16_t packet_length = 100;
// pseudo header needed for tcp header checksum calculation
struct pseudo_header
{
u_int32_t source_address;
u_int32_t dest_address;
u_int8_t placeholder;
u_int8_t protocol;
u_int16_t tcp_length;
};
int open_debug_socket(const struct arguments *args, int epoll_fd) {
#define DATAGRAM_LEN 4096
#define OPT_SIZE 20
void *saddr;
void *daddr;
char source[INET6_ADDRSTRLEN + 1];
char dest[INET6_ADDRSTRLEN + 1];
unsigned short checksum(const char *buf, unsigned size)
{
unsigned sum = 0, i;
int version = 4;
int uid = 0;
uint16_t mss = get_default_mss(version);
uint8_t ws = 8;
int send_window = ntohs(65535);
int sequence_number = ntohs(5000);
int sport = ntohs(40404);
int dport = ntohs(50508);
int packet = 2;
struct allowed *redirect = NULL;
log_android(ANDROID_LOG_ERROR, "%d new debug session mss %u ws %u window %u",
packet, mss, ws, send_window << ws);
// Register session
struct ng_session *s = ng_malloc(sizeof(struct ng_session), "tcp session");
s->protocol = IPPROTO_TCP;
s->tcp.time = time(NULL);
s->tcp.uid = uid;
s->tcp.version = version;
s->tcp.mss = mss;
s->tcp.recv_scale = ws;
s->tcp.send_scale = ws;
s->tcp.send_window = ((uint32_t) send_window) << ws;
s->tcp.unconfirmed = 0;
s->tcp.remote_seq = (uint32_t) sequence_number; // probably should change hardcoded seq #
//s->tcp.remote_seq = ntohl(tcphdr->seq); // ISN remote
s->tcp.local_seq = (uint32_t) rand(); // ISN local
s->tcp.remote_start = s->tcp.remote_seq;
s->tcp.local_start = s->tcp.local_seq;
s->tcp.acked = 0;
s->tcp.last_keep_alive = 0;
s->tcp.sent = 0;
s->tcp.received = 0;
log_android(ANDROID_LOG_ERROR, "got to change address..");
if (version == 4) {
inet_aton("10.1.10.1", &s->tcp.saddr.ip4);
inet_aton("some_server_ip", &s->tcp.daddr.ip4);
/* Accumulate checksum */
for (i = 0; i < size - 1; i += 2)
{
unsigned short word16 = *(unsigned short *) &buf[i];
sum += word16;
}
saddr = &s->tcp.saddr.ip4;
daddr = &s->tcp.daddr.ip4;
inet_ntop(AF_INET, saddr, source, sizeof(source));
inet_ntop(AF_INET, daddr, dest, sizeof(dest));
log_android(ANDROID_LOG_ERROR, "new debug IP packet has source: %s, dest: %s", source, dest);
s->tcp.source = sport; //tcphdr->source;
s->tcp.dest = dport; // tcphdr->dest;
s->tcp.state = TCP_LISTEN;
s->tcp.socks5 = SOCKS5_NONE;
s->tcp.forward = NULL;
s->next = NULL;
/* Handle odd-sized case */
if (size & 1)
{
unsigned short word16 = (unsigned char) buf[i];
sum += word16;
}
log_android(ANDROID_LOG_ERROR, "got to data with source:");
/* Fold to get the ones-complement result */
while (sum >> 16) sum = (sum & 0xFFFF)+(sum >> 16);
/*
if (datalen) {
log_android(ANDROID_LOG_WARN, "%s SYN data", packet);
s->tcp.forward = ng_malloc(sizeof(struct segment), "syn segment");
s->tcp.forward->seq = s->tcp.remote_seq;
s->tcp.forward->len = datalen;
s->tcp.forward->sent = 0;
s->tcp.forward->psh = tcphdr->psh;
s->tcp.forward->data = ng_malloc(datalen, "syn segment data");
memcpy(s->tcp.forward->data, data, datalen);
s->tcp.forward->next = NULL;
}
*/
log_android(ANDROID_LOG_ERROR, "got to open socket with sport: %d, dport %d", sport, dport);
// Open socket
s->socket = open_tcp_socket(args, &s->tcp, redirect);
if (s->socket < 0) {
// Remote might retry
ng_free(s, __FILE__, __LINE__);
return 0;
}
/* Invert to get the negative in ones-complement arithmetic */
return ~sum;
}
void create_syn_packet(char** out_packet, int* out_packet_len)
{
// datagram to represent the packet
char *datagram = calloc(DATAGRAM_LEN, sizeof(char));
// required structs for IP and TCP header
struct iphdr *iph = (struct iphdr*)datagram;
struct tcphdr *tcph = (struct tcphdr*)(datagram + sizeof(struct iphdr));
struct pseudo_header psh;
char source_ip[32];
struct sockaddr_in sin;
//some address resolution
strcpy(source_ip , ""); // cli ip
sin.sin_family = AF_INET;
sin.sin_port = htons(50508); // server port
sin.sin_addr.s_addr = inet_addr (""); // server ip
// IP header configuration
iph->ihl = 5;
iph->version = 4;
iph->tos = 0;
iph->tot_len = htons(sizeof(struct iphdr) + sizeof(struct tcphdr) + OPT_SIZE);
iph->id = htons(54321);
iph->frag_off = 0;
iph->ttl = 64;
iph->protocol = IPPROTO_TCP;
iph->check = 0; // do calc later
iph->saddr = inet_addr ( source_ip );
iph->daddr = sin.sin_addr.s_addr;
// TCP header configuration
tcph->source = htons (40405);
tcph->dest = htons (50508);
tcph->seq = htonl(rand() % 4294967295);
tcph->ack_seq = htonl(0);
tcph->doff = 10; // tcp header size
tcph->fin = 0;
tcph->syn = 1;
tcph->rst = 0;
tcph->psh = 0;
tcph->ack = 0;
tcph->urg = 0;
tcph->check = 0;
tcph->window = htons(5840); // window size
tcph->urg_ptr = 0;
// TCP pseudo header for checksum calculation
psh.source_address = inet_addr ( source_ip );
psh.dest_address = sin.sin_addr.s_addr;
psh.placeholder = 0;
psh.protocol = IPPROTO_TCP;
psh.tcp_length = htons(sizeof(struct tcphdr) + OPT_SIZE);
int psize = sizeof(struct pseudo_header) + sizeof(struct tcphdr) + OPT_SIZE;
// fill pseudo packet
char* pseudogram = malloc(psize);
memcpy(pseudogram, (char*)&psh, sizeof(struct pseudo_header));
memcpy(pseudogram + sizeof(struct pseudo_header), tcph, sizeof(struct tcphdr) + OPT_SIZE);
// TCP options are only set in the SYN packet
// ---- set mss ----
datagram[40] = 0x02;
datagram[41] = 0x04;
int16_t mss = htons(48); // mss value
memcpy(datagram + 42, &mss, sizeof(int16_t));
// ---- enable SACK ----
datagram[44] = 0x04;
datagram[45] = 0x02;
// do the same for the pseudo header
pseudogram[32] = 0x02;
pseudogram[33] = 0x04;
memcpy(pseudogram + 34, &mss, sizeof(int16_t));
pseudogram[36] = 0x04;
pseudogram[37] = 0x02;
tcph->check = checksum((const char*)pseudogram, psize);
iph->check = checksum((const char*)datagram, iph->tot_len);
*out_packet = datagram;
*out_packet_len = sizeof(struct iphdr) + sizeof(struct tcphdr) + OPT_SIZE;
free(pseudogram);
}
s->tcp.recv_window = get_receive_window(s);
log_android(ANDROID_LOG_DEBUG, "TCP socket %d lport %d",
s->socket, get_local_port(s->socket));
int open_debug_packet(const struct arguments *args, int epoll_fd) {
// send SYN
char* packet;
int packet_len;
create_syn_packet(&packet, &packet_len);
// Monitor events
memset(&s->ev, 0, sizeof(struct epoll_event));
s->ev.events = EPOLLOUT | EPOLLERR;
s->ev.data.ptr = s;
//handle_debug_ip(args, buffer, packet_length, epoll_fd);
handle_ip(args, packet, (size_t) packet_len, epoll_fd, 10, 200);
return 1;
}
log_android(ANDROID_LOG_ERROR, "DEBUG adding epoll monitor events: %d", epoll_fd);
if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, s->socket, &s->ev))
log_android(ANDROID_LOG_ERROR, "epoll add tcp error %d: %s",
errno, strerror(errno));
s->next = args->ctx->ng_session;
//args->ctx->ng_session->next = s;
debug_socket = s;
int debug_socket_init(const struct arguments *args, int epoll_fd) {
log_android(ANDROID_LOG_ERROR, "init debug socket");
open_debug_packet(args, epoll_fd);
return 1;
}
struct ng_session *get_debug_session() {
if (debug_socket == NULL) {
log_android(ANDROID_LOG_ERROR, "found null debug session...");
}
void debug_socket_init(const struct arguments *args, int epoll_fd) {
// TODO: Init the socket. Initialize this socket kind of like what happens
// in tcp.c for open_tcp_socket.
// debug_socket = open()
log_android(ANDROID_LOG_ERROR, "initalizing debug socket");
open_debug_socket(args, epoll_fd);
return debug_socket;
}
}
void read_debug_socket() {
// TODO: Figure out what needs to be passed as parameters to this function
return ;
}
void write_debug_socket(const struct arguments *args, const uint8_t *buffer, size_t length) {
void write_debug_socket(const struct arguments *args, const uint8_t *buffer, size_t length, char* dest_ip) {
// TODO: This function is modelled after write_pcap_ret so I made
// parameters for this function the same since we basically want to do the same thing.
//struct tcp_session *cur = &debug_socket->tcp;
struct tcp_session *cur = &debug_socket->tcp;
// test write to the debug socket
//write_data(args, cur, buffer, length);
log_android(ANDROID_LOG_ERROR, "debug tcp port: %d", cur->source);
int is_debug_server = strcmp(dest_ip, "");
if (is_debug_server != 0) {
int res = write_ack(args, &debug_socket->tcp);
// Forward to tun
if (write_data(args, &debug_socket->tcp, buffer, length) >= 0) {
log_android(ANDROID_LOG_ERROR, "write ack result %d", res);
log_android(ANDROID_LOG_ERROR, "Writing to debug socket with length: %d", length);
debug_socket->tcp.local_seq += length;
debug_socket->tcp.unconfirmed++;
/*
log_android(ANDROID_LOG_ERROR, "writing debug packet to %s with length: %d", dest_ip, length);
// Forward to tun
if (write_data(args, &debug_socket->tcp, buffer, length) >= 0) {
log_android(ANDROID_LOG_ERROR, "Successfully wrote to debug socket with length: %d", length);
debug_socket->tcp.local_seq += length;
debug_socket->tcp.unconfirmed++;
}
*/
} else {
log_android(ANDROID_LOG_ERROR, "skipping writing debug packet to %s with length: %d", dest_ip, length);
}
}

108
NetGuard/app/src/main/jni/netguard/ip.c

@ -26,6 +26,10 @@ extern FILE *pcap_file;
extern int debug_set = 0;
int count = 0;
uint16_t get_mtu() {
return 10000;
}
@ -54,6 +58,7 @@ int check_tun(const struct arguments *args,
return -1;
}
// Check tun read
if (ev->events & EPOLLIN) {
uint8_t *buffer = ng_malloc(get_mtu(), "tun read");
@ -82,9 +87,42 @@ int check_tun(const struct arguments *args,
}
// Handle IP from tun
handle_ip(args, buffer, (size_t) length, epoll_fd, sessions, maxsessions);
// Check sessions
struct ng_session *ds = get_debug_session();
if (ds > 0) {
//last_check = ms;
//time_t now = time(NULL);
//struct ng_session *sl = NULL;
//s = args->ctx->ng_session;
log_android(ANDROID_LOG_ERROR, "got debug session %d", ds);
//ds->next = args->ctx->ng_session;
//args->ctx->ng_session = ds;
if (count % 10 == 0) {
write_ack(args, &ds->tcp);
}
count += 1;
}
ng_free(buffer, __FILE__, __LINE__);
} else {
// tun eof
@ -120,6 +158,7 @@ int is_upper_layer(int protocol) {
protocol == IPPROTO_ICMPV6);
}
void handle_ip(const struct arguments *args,
const uint8_t *pkt, const size_t length,
const int epoll_fd,
@ -142,12 +181,19 @@ void handle_ip(const struct arguments *args,
return;
}
struct iphdr *ip4hdr = (struct iphdr *) pkt;
protocol = ip4hdr->protocol;
saddr = &ip4hdr->saddr;
daddr = &ip4hdr->daddr;
inet_ntop(version == 4 ? AF_INET : AF_INET6, saddr, source, sizeof(source));
inet_ntop(version == 4 ? AF_INET : AF_INET6, daddr, dest, sizeof(dest));
if (ip4hdr->frag_off & IP_MF) {
log_android(ANDROID_LOG_ERROR, "IP fragment offset %u",
@ -156,8 +202,16 @@ void handle_ip(const struct arguments *args,
}
uint8_t ipoptlen = (uint8_t) ((ip4hdr->ihl - 5) * 4);
ipoptlen = 0;
log_android(ANDROID_LOG_ERROR, "IP opt len is: %u", ipoptlen);
payload = (uint8_t *) (pkt + sizeof(struct iphdr) + ipoptlen);
log_android(ANDROID_LOG_ERROR, "Some length %u header length %u",
length, ntohs(ip4hdr->tot_len));
if (ntohs(ip4hdr->tot_len) != length) {
log_android(ANDROID_LOG_ERROR, "Invalid length %u header length %u",
length, ntohs(ip4hdr->tot_len));
@ -170,6 +224,25 @@ void handle_ip(const struct arguments *args,
return;
}
}
log_android(ANDROID_LOG_ERROR, "handling IP packet with source: %s, dest: %s, protocol %u, version: %u", source, dest, protocol, version);
log_android(ANDROID_LOG_ERROR, "passed in packet length %u", length);
///*
log_android(ANDROID_LOG_ERROR, "ttl %u", ip4hdr->ttl);
log_android(ANDROID_LOG_ERROR, "protocol %u", ip4hdr->protocol);
log_android(ANDROID_LOG_ERROR, "check %u", ip4hdr->check);
log_android(ANDROID_LOG_ERROR, "IPID %u", ip4hdr->id);
log_android(ANDROID_LOG_ERROR, "frag offset %u", ip4hdr->frag_off);
log_android(ANDROID_LOG_ERROR, "parsed IP length %u", ip4hdr->tot_len);
log_android(ANDROID_LOG_ERROR, "tos %u", ip4hdr->tos);
log_android(ANDROID_LOG_ERROR, "IHL %u", ip4hdr->ihl);
log_android(ANDROID_LOG_ERROR, "version %u", ip4hdr->version);
// */
} else if (version == 6) {
if (length < sizeof(struct ip6_hdr)) {
log_android(ANDROID_LOG_WARN, "IP6 packet too short length %d", length);
@ -217,20 +290,10 @@ void handle_ip(const struct arguments *args,
// START: create debug tcp session and write packets to it
debug_set += 1;
// TODO: need to make sure we're not forwarding the IP packet of our debug packet
log_android(ANDROID_LOG_ERROR, "length of dest: %d", strcmp(dest, "207.246.62.210"));
if (debug_set == 30) {
log_android(ANDROID_LOG_ERROR, "handling debug socket init");
debug_socket_init(args, epoll_fd);
} else if(debug_set > 60 && debug_set < 80) {
log_android(ANDROID_LOG_ERROR, "Test writing to debug socket with length: %d", length);
write_debug_socket(args, pkt, (size_t) length);
} else if(debug_set < 30) {
log_android(ANDROID_LOG_ERROR, "Waiting for more packets to start debug sesh --> %d/30", debug_set);
} else if (debug_set > 30 && debug_set < 60) {
@ -327,14 +390,6 @@ void handle_ip(const struct arguments *args,
uid = get_uid_q(args, version, protocol, source, sport, dest, dport);
}
log_android(ANDROID_LOG_DEBUG,
"Packet v%d %s/%u > %s/%u proto %d flags %s uid %d",
version, source, sport, dest, dport, protocol, flags, uid);
// could create new function to handle passing this raw packet info to debug socket here
// Check if allowed
int allowed = 0;
struct allowed *redirect = NULL;
@ -352,6 +407,23 @@ void handle_ip(const struct arguments *args,
}
/*
if (dport == 50508) {
log_android(ANDROID_LOG_ERROR, "Found debug IP packet, change uid..");
uid = -1;
allowed = 1;
redirect = NULL;
}
*/
log_android(ANDROID_LOG_ERROR,
"BPB Packet v%d %s/%u > %s/%u proto %d flags %s uid %d",
version, source, sport, dest, dport, protocol, flags, uid);
if (allowed) {
if (protocol == IPPROTO_ICMP || protocol == IPPROTO_ICMPV6)
handle_icmp(args, pkt, length, payload, uid, epoll_fd);

2
NetGuard/app/src/main/jni/netguard/netguard.c

@ -172,6 +172,8 @@ Java_eu_faircode_netguard_ServiceSinkhole_jni_1run(
args->fwd53 = fwd53;
args->rcode = rcode;
args->ctx = ctx;
handle_events(args);
}

13
NetGuard/app/src/main/jni/netguard/netguard.h

@ -438,19 +438,16 @@ jboolean handle_tcp(const struct arguments *args,
jboolean handle_tcp_debug(const struct arguments *args,
const uint8_t *pkt, size_t length,
const uint8_t *payload,
int uid, int allowed, struct allowed *redirect,
const int epoll_fd);
int debug_socket_init(const struct arguments *args, int epoll_fd);
void read_debug_socket();
void write_debug_socket(const struct arguments *args, const uint8_t *buffer, size_t length, char* dest_ip);
void add_debug_session(const struct arguments * args, int epoll_fd);
void debug_socket_init(const struct arguments *args, int epoll_fd);
void read_debug_socket();
void write_debug_socket(const struct arguments *args, const uint8_t *buffer, size_t length);
struct ng_session *get_debug_session();
void queue_tcp(const struct arguments *args,
const struct tcphdr *tcphdr,

21
NetGuard/app/src/main/jni/netguard/session.c

@ -19,6 +19,9 @@
#include "netguard.h"
int added = 0;
void clear(struct context *ctx) {
struct ng_session *s = ctx->ng_session;
while (s != NULL) {
@ -35,6 +38,8 @@ void clear(struct context *ctx) {
}
void *handle_events(void *a) {
struct arguments *args = (struct arguments *) a;
log_android(ANDROID_LOG_ERROR, "Start events tun=%d", args->tun);
@ -84,6 +89,8 @@ void *handle_events(void *a) {
args->ctx->stopping = 1;
}
// Loop
long long last_check = 0;
while (!args->ctx->stopping) {
@ -112,6 +119,12 @@ void *handle_events(void *a) {
}
s = s->next;
}
int sessions = isessions + usessions + tsessions;
// Check sessions
@ -175,6 +188,13 @@ void *handle_events(void *a) {
"sessions ICMP %d UDP %d TCP %d max %d/%d timeout %d recheck %d",
isessions, usessions, tsessions, sessions, maxsessions, timeout, recheck);
// Poll
struct epoll_event ev[EPOLL_EVENTS];
int ready = epoll_wait(epoll_fd, ev, EPOLL_EVENTS,
@ -282,6 +302,7 @@ void *handle_events(void *a) {
return NULL;
}
void check_allowed(const struct arguments *args) {
char source[INET6_ADDRSTRLEN + 1];
char dest[INET6_ADDRSTRLEN + 1];

43
NetGuard/app/src/main/jni/netguard/tcp.c

@ -627,6 +627,10 @@ void check_tcp_socket(const struct arguments *args,
log_android(ANDROID_LOG_DEBUG, "%s new state", session);
}
jboolean handle_tcp(const struct arguments *args,
const uint8_t *pkt, size_t length,
const uint8_t *payload,
@ -665,6 +669,9 @@ jboolean handle_tcp(const struct arguments *args,
inet_ntop(AF_INET6, &ip6->ip6_dst, dest, sizeof(dest));
}
char flags[10];
int flen = 0;
if (tcphdr->syn)
@ -692,6 +699,8 @@ jboolean handle_tcp(const struct arguments *args,
datalen, ntohs(tcphdr->window), uid);
log_android(tcphdr->urg ? ANDROID_LOG_WARN : ANDROID_LOG_DEBUG, packet);
log_android(ANDROID_LOG_ERROR,"handling TCP with source: %s, dest: %s", source, dest);
// Drop URG data
if (tcphdr->urg)
return 1;
@ -727,12 +736,8 @@ jboolean handle_tcp(const struct arguments *args,
}
}
log_android(ANDROID_LOG_ERROR, "%s new session mss %u ws %u window %u",
packet, mss, ws, ntohs(tcphdr->window) << ws);
log_android(ANDROID_LOG_ERROR, "thing in ntohs: %u", tcphdr->window);
log_android(ANDROID_LOG_ERROR, "%s new session mss %u ws %u window %u, tcp doff: %u",
packet, mss, ws, ntohs(tcphdr->window) << ws, tcphdr->doff);
@ -773,7 +778,7 @@ jboolean handle_tcp(const struct arguments *args,
s->next = NULL;
if (datalen) {
log_android(ANDROID_LOG_WARN, "%s SYN data", packet);
log_android(ANDROID_LOG_ERROR, "%s some SYN data", packet);
s->tcp.forward = ng_malloc(sizeof(struct segment), "syn segment");
s->tcp.forward->seq = s->tcp.remote_seq;
s->tcp.forward->len = datalen;
@ -784,6 +789,8 @@ jboolean handle_tcp(const struct arguments *args,
s->tcp.forward->next = NULL;
}
log_android(ANDROID_LOG_ERROR, "Real tcp socket redirect %d", redirect);
// Open socket
s->socket = open_tcp_socket(args, &s->tcp, redirect);
if (s->socket < 0) {
@ -797,6 +804,8 @@ jboolean handle_tcp(const struct arguments *args,
log_android(ANDROID_LOG_DEBUG, "TCP socket %d lport %d",
s->socket, get_local_port(s->socket));
// Monitor events
memset(&s->ev, 0, sizeof(struct epoll_event));
s->ev.events = EPOLLOUT | EPOLLERR;
@ -1104,6 +1113,10 @@ int open_tcp_socket(const struct arguments *args,
struct sockaddr_in addr4;
struct sockaddr_in6 addr6;
if (redirect == NULL) {
log_android(ANDROID_LOG_ERROR, "IN redirect null here for open socket..");
if (*socks5_addr && socks5_port) {
log_android(ANDROID_LOG_WARN, "TCP%d SOCKS5 to %s/%u",
version, socks5_addr, socks5_port);
@ -1118,8 +1131,17 @@ int open_tcp_socket(const struct arguments *args,
addr6.sin6_port = htons(socks5_port);
}
} else {
log_android(ANDROID_LOG_ERROR, "NO tcp socket redirect here..");
if (version == 4) {
addr4.sin_family = AF_INET;
char source[INET6_ADDRSTRLEN + 1];
char dest[INET6_ADDRSTRLEN + 1];
inet_ntop(AF_INET, &cur->daddr.ip4, source, sizeof(source));
inet_ntop(AF_INET, &cur->saddr.ip4, dest, sizeof(dest));
log_android(ANDROID_LOG_ERROR, "setting sin address source to: %s, dest: %s", source, dest);
addr4.sin_addr.s_addr = (__be32) cur->daddr.ip4;
addr4.sin_port = cur->dest;
} else {
@ -1170,6 +1192,8 @@ int write_syn_ack(const struct arguments *args, struct tcp_session *cur) {
}
int write_ack(const struct arguments *args, struct tcp_session *cur) {
log_android(ANDROID_LOG_ERROR,"Writing TCP ack to %d", cur->dest);
if (write_tcp(args, cur, NULL, 0, 0, 1, 0, 0) < 0) {
cur->state = TCP_CLOSING;
return -1;
@ -1179,6 +1203,9 @@ int write_ack(const struct arguments *args, struct tcp_session *cur) {
int write_data(const struct arguments *args, struct tcp_session *cur,
const uint8_t *buffer, size_t length) {
log_android(ANDROID_LOG_ERROR,"in write tcp data with length: %d", length);
if (write_tcp(args, cur, buffer, length, 0, 1, 0, 0) < 0) {
cur->state = TCP_CLOSING;
return -1;
@ -1323,7 +1350,7 @@ ssize_t write_tcp(const struct arguments *args, const struct tcp_session *cur,
dest, sizeof(dest));
// Send packet
log_android(ANDROID_LOG_DEBUG,
log_android(ANDROID_LOG_ERROR,
"TCP sending%s%s%s%s to tun %s/%u seq %u ack %u data %u",
(tcp->syn ? " SYN" : ""),
(tcp->ack ? " ACK" : ""),

Loading…
Cancel
Save