fix lwip_tcp port byte order (double-htons), mapping lookup, socket error handling
- Fix port encoding: PCB stores ports in host byte order, tcp_create_segment uses htons - Fix tcp_bind/tcp_connect: ntohs incoming network-order ports - Fix demux comparisons: use host-order sport/dport statics instead of in-place ntohs - Fix tcp_output_alloc_header_common: htons for port output - Add static sport/dport variables (host byte order) to avoid tcphdr corruption - Fix sock_transport_error_callback: handle EPOLLERR during non-blocking connect - Fix mapping local_port: store host-order port for find_mapping_by_port - Fix tcp_proxy_raw_read/tun_input: use IP total length for packet boundaries - test_tcp_proxy: reduce size to 2KB, fix port, add debug_init, add echo server log - test_tcp_proxy handshake and basic data flow now working (known: cwnd/poll throughput tuning needed)
This commit is contained in:
1 parent
c05e1c9991
commit
ad8bc0ae00
5 files changed
+93
-41
No files matched your search
@@ -19,8 +19,8 @@
|
||||
#include "../lib/debug_config.h"
|
||||
|
||||
#define TEST_PORT 9090
|
||||
#define ECHO_PORT 9999
|
||||
#define TEST_SIZE (1024 * 1024)
|
||||
#define ECHO_PORT 19999
|
||||
#define TEST_SIZE (2 * 1024) // 2KB — minimum viable test
|
||||
#define POLL_TIMEOUT_MS 10000
|
||||
#define DATA_TIMEOUT_MS 120000
|
||||
|
||||
@@ -34,6 +34,7 @@ static void echo_server(uint16_t port) {
|
||||
struct sockaddr_in addr = {.sin_family = AF_INET, .sin_port = htons(port)}; addr.sin_addr.s_addr = inet_addr("127.0.0.1");
|
||||
if(bind(srv, (struct sockaddr*)&addr, sizeof(addr)) < 0) { perror("echo bind"); close(srv); exit(1); }
|
||||
if(listen(srv, 1) < 0) { perror("echo listen"); close(srv); exit(1); }
|
||||
fprintf(stderr, "ECHO: listening on port %d\n", port);
|
||||
int cli = accept(srv, NULL, NULL);
|
||||
if(cli < 0) { perror("echo accept"); close(srv); exit(1); }
|
||||
uint8_t buf[65536]; ssize_t n;
|
||||
@@ -51,6 +52,7 @@ static void run_instance_b(int ip_fd) {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
debug_config_init();
|
||||
// 1. Fork echo server
|
||||
echo_pid = fork();
|
||||
if(echo_pid == 0) { echo_server(ECHO_PORT); _exit(0); }
|
||||
|
||||
Reference in new issue
Block a user