summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2022-12-27 14:12:42 +0800
committerluwenpeng <[email protected]>2022-12-27 14:12:42 +0800
commitee9f66a19605839a742409a7fb8abf74bbb4411d (patch)
treeae23221ed1e04d3732a1a6218af4b795ed2bb68d
parentfdf203b25e73e8a6290733c5bd91f6cc8c0d4ad4 (diff)
TSG-13175 Decrypted Traffic Steering构造的SYN/SYN ACK支持MSS选项
-rw-r--r--platform/src/acceptor_kni_v3.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/platform/src/acceptor_kni_v3.cpp b/platform/src/acceptor_kni_v3.cpp
index 05628d9..03f19ad 100644
--- a/platform/src/acceptor_kni_v3.cpp
+++ b/platform/src/acceptor_kni_v3.cpp
@@ -278,13 +278,19 @@ static void tcp_restore_info_parse_from_pkt(struct pkt_info *pktinfo, struct tcp
}
}
-struct tcp_option_window_scale{
+struct tcp_option_mss {
+ uint8_t kind;
+ uint8_t length;
+ uint16_t mss_value;
+};
+
+struct tcp_option_window_scale {
uint8_t kind;
uint8_t length;
uint8_t shift_count;
};
-struct tcp_option_sack{
+struct tcp_option_sack {
uint8_t kind;
uint8_t length;
};
@@ -316,7 +322,29 @@ static int fake_tcp_handshake(struct tfe_proxy *proxy, struct tcp_restore_info *
uint32_t s_seq = server->seq - 1;
/*
- * Window Scale option (WSopt): Kind: 3, Length: 3
+ * Maximum segment size: Kind: 2, Length: 4
+ * +---------+---------+---------+
+ * | Kind=2 |Length=4 |mss.value|
+ * +---------+---------+---------+
+ * 1 1 2
+ */
+ if (client->mss && server->mss)
+ {
+ struct tcp_option_mss *option_c = (struct tcp_option_mss *)(tcp_option_buffer_c + tcp_option_length_c);
+ option_c->kind = 2;
+ option_c->length = 4;
+ option_c->mss_value = htons(client->mss);
+ tcp_option_length_c += sizeof(struct tcp_option_mss);
+
+ struct tcp_option_mss *option_s = (struct tcp_option_mss *)(tcp_option_buffer_s + tcp_option_length_s);
+ option_s->kind = 2;
+ option_s->length = 4;
+ option_s->mss_value = htons(server->mss);
+ tcp_option_length_s += sizeof(struct tcp_option_mss);
+ }
+
+ /*
+ * Window Scale option: Kind: 3, Length: 3
* +---------+---------+---------+
* | Kind=3 |Length=3 |shift.cnt|
* +---------+---------+---------+