From 794e6507b6d5f7049dc1816ec90d9b89d11908e0 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 21 Jan 2026 21:50:06 -0600 Subject: [PATCH] Progress: Begin addressing existing todo comments and other tasks. Remove `gpgme` from `modes_default` in `data/build/tacocat/settings.tacocat`. The `// @todo port here.` seems to not be needed. There is random selecting of `host.h_addr_list` does not seem to be used. Remove this dead code. Remove redundant allocation increase. Call `f_network_from_host_short()` rather than directly calling `htons()`. Add port number in network address printing messages. --- data/build/tacocat/settings.tacocat | 2 +- .../c/program/kevux/tools/tacocat/main/common.c | 30 ++++++---------------- .../kevux/tools/tacocat/main/print/message.c | 6 +++++ 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/data/build/tacocat/settings.tacocat b/data/build/tacocat/settings.tacocat index 702f9d6..799ef88 100644 --- a/data/build/tacocat/settings.tacocat +++ b/data/build/tacocat/settings.tacocat @@ -31,7 +31,7 @@ version_file micro version_target minor modes android clang coverage debug fanalyzer flex_arrays gcc gpgme individual individual_thread level monolithic pinephone test thread threadless -modes_default debug gcc gpgme monolithic thread +modes_default debug gcc monolithic thread build_compiler gcc build_compiler-clang clang diff --git a/sources/c/program/kevux/tools/tacocat/main/common.c b/sources/c/program/kevux/tools/tacocat/main/common.c index 3f762f4..b38d4f9 100644 --- a/sources/c/program/kevux/tools/tacocat/main/common.c +++ b/sources/c/program/kevux/tools/tacocat/main/common.c @@ -449,8 +449,6 @@ extern "C" { main->setting.state.status = f_network_from_ip_string(address, &family); macro_kt_tacocat_handle_load_send_receive_error_continue_2(); - - // @todo port here. } else { main->setting.state.status = f_network_from_ip_name(address, &host); @@ -475,24 +473,6 @@ extern "C" { macro_kt_tacocat_handle_load_send_receive_error_continue_2(); - // Randomly select one of the addresses when there are more than one. - if (host.h_addr_list[1]) { - k = 2; - - while (host.h_addr_list[k++]); - - // Real randomness or security is not needed here, so fiddle with predictable but somewhat dynamic numbers. - srand(main->program.pid + j + host.h_addr_list[0][0]); - k = rand() % (k - 1); - } - else { - k = 0; - } - - main->setting.state.status = f_memory_array_increase_by(INET6_ADDRSTRLEN + 1, sizeof(f_char_t), (void **) &sets[i]->array[j].network.string, &sets[i]->array[j].network.used, &sets[i]->array[j].network.size); - - macro_kt_tacocat_handle_load_send_receive_error_continue_2(); - main->setting.state.status = f_network_to_ip_string(family, &sets[i]->array[j].network); if (main->setting.state.status == F_data_not || !host.h_addr_list || !host.h_addr_list[0]) { @@ -518,14 +498,20 @@ extern "C" { if (host.h_addrtype == f_socket_address_family_inet4_e) { sets[i]->array[j].socket.domain = f_socket_protocol_family_inet4_e; sets[i]->array[j].socket.address.inet4.sin_family = f_socket_address_family_inet4_e; - sets[i]->array[j].socket.address.inet4.sin_port = htons((in_port_t) sets[i]->array[j].port); sets[i]->array[j].socket.address.inet4.sin_addr.s_addr = family.address.v4.s_addr; + + main->setting.state.status = f_network_from_host_short(sets[i]->array[j].port, &sets[i]->array[j].socket.address.inet4.sin_port); + + macro_kt_tacocat_handle_load_send_receive_error_continue_2(); } else if (host.h_addrtype == f_socket_address_family_inet6_e) { sets[i]->array[j].socket.domain = f_socket_protocol_family_inet6_e; sets[i]->array[j].socket.address.inet4.sin_family = f_socket_address_family_inet6_e; - sets[i]->array[j].socket.address.inet6.sin6_port = htons((in_port_t) sets[i]->array[j].port); sets[i]->array[j].socket.address.inet6.sin6_addr = family.address.v6; + + main->setting.state.status = f_network_from_host_short(sets[i]->array[j].port, &sets[i]->array[j].socket.address.inet6.sin6_port); + + macro_kt_tacocat_handle_load_send_receive_error_continue_2(); } } else { diff --git a/sources/c/program/kevux/tools/tacocat/main/print/message.c b/sources/c/program/kevux/tools/tacocat/main/print/message.c index 9295919..febe2ab 100644 --- a/sources/c/program/kevux/tools/tacocat/main/print/message.c +++ b/sources/c/program/kevux/tools/tacocat/main/print/message.c @@ -109,6 +109,8 @@ extern "C" { fl_print_format("%rPacket from ", print->to, f_string_eol_s); fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, set.network, print->set->notable); + fl_print_format(" port ", print->to); + fl_print_format(f_string_format_ul_single_s.string, print->to, print->set->notable, set.port, print->set->notable); fl_print_format(" is complete.%r", print->to, f_string_eol_s); f_file_stream_unlock(print->to); @@ -127,6 +129,8 @@ extern "C" { fl_print_format("%rPacket from ", print->to, f_string_eol_s); fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, set.network, print->set->notable); + fl_print_format(" port ", print->to); + fl_print_format(f_string_format_ul_single_s.string, print->to, print->set->notable, set.port, print->set->notable); fl_print_format(" is %[%ul%] Bytes.%r", print->to, print->set->notable, set.packet.size, print->set->notable, f_string_eol_s); f_file_stream_unlock(print->to); @@ -145,6 +149,8 @@ extern "C" { fl_print_format("%rReceived packet from ", print->to, f_string_eol_s); fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, set.network, print->set->notable); + fl_print_format(" port ", print->to); + fl_print_format(f_string_format_ul_single_s.string, print->to, print->set->notable, set.port, print->set->notable); if (print->verbosity > f_console_verbosity_normal_e) { fl_print_format(" (appending to file '", print->to); -- 1.8.3.1