mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-01-19 06:19:31 +08:00
Compare commits
2 Commits
0c33896a46
...
99e026fef4
Author | SHA1 | Date | |
---|---|---|---|
|
99e026fef4 | ||
|
9045264d37 |
24
network.cpp
24
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;
|
||||||
|
|
||||||
bool no_found_spa_opt = true;
|
tcpopt_data_t *opt = NULL;
|
||||||
|
|
||||||
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,17 +2193,9 @@ 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) {
|
||||||
@ -2222,10 +2214,18 @@ 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 && no_found_spa_opt) {
|
if(recv_info.syn == 1 && recv_info.ack == 0 && g_tcp_spa) {
|
||||||
mylog(log_info, "No found spa opt, pkt drop\n");
|
if(opt == NULL) {
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
int recv_raw_tcp(raw_info_t &raw_info, char *&payload, int &payloadlen) {
|
int recv_raw_tcp(raw_info_t &raw_info, char *&payload, int &payloadlen) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user