From b66bb4e5a4829e544917b29a5bdfa7af87dafa80 Mon Sep 17 00:00:00 2001 From: Rafael Zenaro Date: Sat, 24 Aug 2024 18:12:28 -0300 Subject: [PATCH 1/7] Initial test to change port 25 to 587 --- commands.c | 5 +++++ debug.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/commands.c b/commands.c index bcb9767..f4e18de 100644 --- a/commands.c +++ b/commands.c @@ -922,6 +922,11 @@ static struct mobile_packet *command_tcp_connect_connecting(struct mobile_adapte }; memcpy(addr.host, packet->data, 4); + if (addr.port == 25){ + // printf("Port 25 detected. Replacing to 587\n"); + addr.port=587; + } + int rc = mobile_cb_sock_connect(adapter, conn, (struct mobile_addr *)&addr); if (rc == 0) return NULL; diff --git a/debug.c b/debug.c index a610b28..9dc617b 100644 --- a/debug.c +++ b/debug.c @@ -324,7 +324,7 @@ void mobile_debug_command(struct mobile_adapter *adapter, const struct mobile_pa debug_print(": %u.%u.%u.%u:%u", packet->data[0], packet->data[1], packet->data[2], packet->data[3], - packet->data[4] << 8 | packet->data[5]); + ((packet->data[4] << 8 | packet->data[5]) == 25) ? 587 : (packet->data[4] << 8 | packet->data[5])); packet_end(adapter, packet, 6); } else { if (packet->length < 1) break; From e4dcd4ce3fa77067d31421b8d939ac93c9b0543c Mon Sep 17 00:00:00 2001 From: Rafael Zenaro Date: Sat, 24 Aug 2024 20:58:52 -0300 Subject: [PATCH 2/7] Update debug.c --- debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug.c b/debug.c index 9dc617b..a610b28 100644 --- a/debug.c +++ b/debug.c @@ -324,7 +324,7 @@ void mobile_debug_command(struct mobile_adapter *adapter, const struct mobile_pa debug_print(": %u.%u.%u.%u:%u", packet->data[0], packet->data[1], packet->data[2], packet->data[3], - ((packet->data[4] << 8 | packet->data[5]) == 25) ? 587 : (packet->data[4] << 8 | packet->data[5])); + packet->data[4] << 8 | packet->data[5]); packet_end(adapter, packet, 6); } else { if (packet->length < 1) break; From abee92acecd3b8ae12b6d38c8742a5b7ab83fe5f Mon Sep 17 00:00:00 2001 From: Rafael Zenaro Date: Sat, 24 Aug 2024 21:11:01 -0300 Subject: [PATCH 3/7] Update commands.c --- commands.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/commands.c b/commands.c index f4e18de..fc1381e 100644 --- a/commands.c +++ b/commands.c @@ -736,6 +736,8 @@ static struct mobile_packet *command_change_clock(struct mobile_adapter *adapter // Replying with a different command in the header tricks the official GBA // library into never changing its serial mode. Using the REINIT command // forces it to set its serial mode to 8-bit. + mobile_debug_print(adapter,PSTR(" Forcing adapter to keep using 8-bit mode!")); + mobile_debug_endl(adapter); packet->command = MOBILE_COMMAND_REINIT; s->mode_32bit = false; #endif @@ -923,7 +925,8 @@ static struct mobile_packet *command_tcp_connect_connecting(struct mobile_adapte memcpy(addr.host, packet->data, 4); if (addr.port == 25){ - // printf("Port 25 detected. Replacing to 587\n"); + mobile_debug_print(adapter,PSTR(" Replacing port 25 to 587!")); + mobile_debug_endl(adapter); addr.port=587; } From 7f3f9e6ab38cb692466859c3341336d8f57df973 Mon Sep 17 00:00:00 2001 From: Rafael Zenaro Date: Sun, 25 Aug 2024 15:34:27 -0300 Subject: [PATCH 4/7] Update commands.c --- commands.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/commands.c b/commands.c index fc1381e..3ffdc55 100644 --- a/commands.c +++ b/commands.c @@ -906,6 +906,11 @@ static struct mobile_packet *command_tcp_connect_begin(struct mobile_adapter *ad } s->connections[conn] = true; + if ((packet->data[4] << 8 | packet->data[5]) == 25){ + mobile_debug_print(adapter,PSTR(" Replacing port 25 to 587!")); + mobile_debug_endl(adapter); + } + b->processing_data[PROCDATA_TCP_CONNECT_CONN] = conn; b->processing = PROCESS_TCP_CONNECT_CONNECTING; return NULL; @@ -920,16 +925,10 @@ static struct mobile_packet *command_tcp_connect_connecting(struct mobile_adapte struct mobile_addr4 addr = { .type = MOBILE_ADDRTYPE_IPV4, - .port = packet->data[4] << 8 | packet->data[5], + .port = ((packet->data[4] << 8 | packet->data[5]) == 25 ? 587 : (packet->data[4] << 8 | packet->data[5])), }; memcpy(addr.host, packet->data, 4); - if (addr.port == 25){ - mobile_debug_print(adapter,PSTR(" Replacing port 25 to 587!")); - mobile_debug_endl(adapter); - addr.port=587; - } - int rc = mobile_cb_sock_connect(adapter, conn, (struct mobile_addr *)&addr); if (rc == 0) return NULL; From 1fbafafedb5ee08474876a9610881292db76affc Mon Sep 17 00:00:00 2001 From: Rafael Zenaro Date: Sun, 25 Aug 2024 21:27:14 -0300 Subject: [PATCH 5/7] Update commands.c --- commands.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/commands.c b/commands.c index 3ffdc55..248a9dc 100644 --- a/commands.c +++ b/commands.c @@ -925,8 +925,10 @@ static struct mobile_packet *command_tcp_connect_connecting(struct mobile_adapte struct mobile_addr4 addr = { .type = MOBILE_ADDRTYPE_IPV4, - .port = ((packet->data[4] << 8 | packet->data[5]) == 25 ? 587 : (packet->data[4] << 8 | packet->data[5])), + .port = packet->data[4] << 8 | packet->data[5], }; + if (addr.port == 25) addr.port = 587; + memcpy(addr.host, packet->data, 4); int rc = mobile_cb_sock_connect(adapter, conn, From 5284afc2cfe2fcd12b81ff5ad81ae6bd92bc1cc9 Mon Sep 17 00:00:00 2001 From: Rafael Zenaro Date: Sun, 25 Aug 2024 21:28:12 -0300 Subject: [PATCH 6/7] Update commands.c --- commands.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands.c b/commands.c index 248a9dc..a06ab24 100644 --- a/commands.c +++ b/commands.c @@ -736,7 +736,7 @@ static struct mobile_packet *command_change_clock(struct mobile_adapter *adapter // Replying with a different command in the header tricks the official GBA // library into never changing its serial mode. Using the REINIT command // forces it to set its serial mode to 8-bit. - mobile_debug_print(adapter,PSTR(" Forcing adapter to keep using 8-bit mode!")); + mobile_debug_print(adapter, PSTR(" Forcing adapter to keep using 8-bit mode!")); mobile_debug_endl(adapter); packet->command = MOBILE_COMMAND_REINIT; s->mode_32bit = false; @@ -907,7 +907,7 @@ static struct mobile_packet *command_tcp_connect_begin(struct mobile_adapter *ad s->connections[conn] = true; if ((packet->data[4] << 8 | packet->data[5]) == 25){ - mobile_debug_print(adapter,PSTR(" Replacing port 25 to 587!")); + mobile_debug_print(adapter, PSTR(" Replacing port 25 to 587!")); mobile_debug_endl(adapter); } From 6ea19a8de92116c18144679293b5e9f59604c1a5 Mon Sep 17 00:00:00 2001 From: Rafael Zenaro Date: Sun, 25 Aug 2024 21:28:50 -0300 Subject: [PATCH 7/7] Update commands.c --- commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands.c b/commands.c index a06ab24..f948144 100644 --- a/commands.c +++ b/commands.c @@ -906,7 +906,7 @@ static struct mobile_packet *command_tcp_connect_begin(struct mobile_adapter *ad } s->connections[conn] = true; - if ((packet->data[4] << 8 | packet->data[5]) == 25){ + if ((packet->data[4] << 8 | packet->data[5]) == 25) { mobile_debug_print(adapter, PSTR(" Replacing port 25 to 587!")); mobile_debug_endl(adapter); }