|
|
@ -8,6 +8,13 @@ |
|
|
|
struct ng_session *debug_socket; |
|
|
|
|
|
|
|
|
|
|
|
const char* debug_src_ip=""; // Android wlan IP |
|
|
|
const char* debug_dest_ip=""; // Debug server pub IP |
|
|
|
|
|
|
|
const uint16_t sport = 40408; // local port |
|
|
|
const uint16_t dport = 50508; // server port |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// pseudo header needed for tcp header checksum calculation |
|
|
|
struct pseudo_header |
|
|
@ -62,10 +69,10 @@ void create_data_packet(char** out_packet, int* out_packet_len, struct tcp_sessi |
|
|
|
struct sockaddr_in sin; |
|
|
|
|
|
|
|
//some address resolution |
|
|
|
strcpy(source_ip , ""); // cli wifi ip |
|
|
|
strcpy(source_ip , debug_src_ip); // cli ip |
|
|
|
sin.sin_family = AF_INET; |
|
|
|
sin.sin_port = htons(50508); // server port |
|
|
|
sin.sin_addr.s_addr = inet_addr (""); // server public ip |
|
|
|
sin.sin_port = htons(dport); // server port |
|
|
|
sin.sin_addr.s_addr = inet_addr (debug_dest_ip); // server ip |
|
|
|
|
|
|
|
|
|
|
|
// IP header configuration |
|
|
@ -82,8 +89,8 @@ void create_data_packet(char** out_packet, int* out_packet_len, struct tcp_sessi |
|
|
|
iph->daddr = sin.sin_addr.s_addr; |
|
|
|
|
|
|
|
// TCP header configuration |
|
|
|
tcph->source = htons (40408); |
|
|
|
tcph->dest = htons (50508); |
|
|
|
tcph->source = htons (sport); |
|
|
|
tcph->dest = htons (dport); |
|
|
|
tcph->seq = htonl(rand() % 4294967295); |
|
|
|
tcph->ack_seq = htonl(0); |
|
|
|
tcph->doff = 10; // tcp header size |
|
|
@ -110,6 +117,7 @@ void create_data_packet(char** out_packet, int* out_packet_len, struct tcp_sessi |
|
|
|
memcpy(pseudogram, (char*)&psh, sizeof(struct pseudo_header)); |
|
|
|
memcpy(pseudogram + sizeof(struct pseudo_header), tcph, sizeof(struct tcphdr) + OPT_SIZE); |
|
|
|
|
|
|
|
// TODO: change options to PA |
|
|
|
// TCP options are only set in the SYN packet |
|
|
|
// ---- set mss ---- |
|
|
|
datagram[40] = 0x02; |
|
|
@ -153,10 +161,10 @@ void create_syn_packet(char** out_packet, int* out_packet_len) |
|
|
|
struct sockaddr_in sin; |
|
|
|
|
|
|
|
//some address resolution |
|
|
|
strcpy(source_ip , ""); // cli ip |
|
|
|
strcpy(source_ip , debug_src_ip); // cli ip |
|
|
|
sin.sin_family = AF_INET; |
|
|
|
sin.sin_port = htons(50508); // server port |
|
|
|
sin.sin_addr.s_addr = inet_addr (""); // server ip |
|
|
|
sin.sin_port = htons(dport); // server port |
|
|
|
sin.sin_addr.s_addr = inet_addr (debug_dest_ip); // server ip |
|
|
|
|
|
|
|
|
|
|
|
// IP header configuration |
|
|
@ -173,8 +181,9 @@ void create_syn_packet(char** out_packet, int* out_packet_len) |
|
|
|
iph->daddr = sin.sin_addr.s_addr; |
|
|
|
|
|
|
|
// TCP header configuration |
|
|
|
tcph->source = htons (40408); |
|
|
|
tcph->dest = htons (50508); |
|
|
|
tcph->source = htons (sport); |
|
|
|
tcph->dest = htons (dport); |
|
|
|
|
|
|
|
tcph->seq = htonl(rand() % 4294967295); |
|
|
|
tcph->ack_seq = htonl(0); |
|
|
|
tcph->doff = 10; // tcp header size |
|
|
|