mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-01-19 14:29:34 +08:00
Compare commits
1 Commits
99e026fef4
...
0c33896a46
Author | SHA1 | Date | |
---|---|---|---|
|
0c33896a46 |
26
network.cpp
26
network.cpp
@ -2157,7 +2157,7 @@ int parse_tcp_option(char *option_begin, char *option_end, packet_info_t &recv_i
|
|||||||
recv_info.has_ts = 0;
|
recv_info.has_ts = 0;
|
||||||
recv_info.ts = 0;
|
recv_info.ts = 0;
|
||||||
|
|
||||||
tcpopt_data_t *opt = NULL;
|
bool no_found_spa_opt = true;
|
||||||
|
|
||||||
char *ptr = option_begin;
|
char *ptr = option_begin;
|
||||||
// char *option_end=tcp_begin+tcp_hdr_len;
|
// char *option_end=tcp_begin+tcp_hdr_len;
|
||||||
@ -2193,9 +2193,17 @@ int parse_tcp_option(char *option_begin, char *option_end, packet_info_t &recv_i
|
|||||||
&& g_tcp_spa && (unsigned char)*ptr == TCPOPT_SPA) {
|
&& g_tcp_spa && (unsigned char)*ptr == TCPOPT_SPA) {
|
||||||
if (ptr + sizeof(tcpopt_data_t) > option_end) {
|
if (ptr + sizeof(tcpopt_data_t) > option_end) {
|
||||||
mylog(log_trace, "ptr+8>option_end for TCPOPT_SPA\n");
|
mylog(log_trace, "ptr+8>option_end for TCPOPT_SPA\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
tcpopt_data_t *opt = (tcpopt_data_t*)ptr;
|
||||||
|
uint32_t csum = checksum(htonl(recv_info.ts), key_string);
|
||||||
|
if(opt->csum == htonl(csum)){
|
||||||
|
//mylog(log_info, "SPA csum match succeed\n");
|
||||||
|
no_found_spa_opt = false;
|
||||||
|
} else {
|
||||||
|
mylog(log_info, "SPA csum match failed\n");
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
opt = (tcpopt_data_t*)ptr;
|
|
||||||
ptr += sizeof(tcpopt_data_t);
|
ptr += sizeof(tcpopt_data_t);
|
||||||
} else {
|
} else {
|
||||||
if (ptr + 1 >= option_end) {
|
if (ptr + 1 >= option_end) {
|
||||||
@ -2214,17 +2222,9 @@ int parse_tcp_option(char *option_begin, char *option_end, packet_info_t &recv_i
|
|||||||
// printf("!");
|
// printf("!");
|
||||||
}
|
}
|
||||||
// printf("\n");
|
// printf("\n");
|
||||||
if(recv_info.syn == 1 && recv_info.ack == 0 && g_tcp_spa) {
|
if(recv_info.syn == 1 && recv_info.ack == 0 && g_tcp_spa && no_found_spa_opt) {
|
||||||
if(opt == NULL) {
|
mylog(log_info, "No found spa opt, pkt drop\n");
|
||||||
mylog(log_trace, "No found spa opt, pkt drop\n");
|
return -2;
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t csum = checksum(htonl(recv_info.ts), key_string);
|
|
||||||
if(opt->csum != htonl(csum)){
|
|
||||||
mylog(log_trace, "SPA csum match failed\n");
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user