public inbox for gwml@vger.gnuweeb.org
 help / color / mirror / Atom feed
From: Ahmad Gani <reyuki@gnuweeb.org>
To: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Cc: Ahmad Gani <reyuki@gnuweeb.org>,
	Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>,
	GNU/Weeb Mailing List <gwml@vger.gnuweeb.org>
Subject: [PATCH gwproxy v3 2/9] dnslookup: Add a new parameter, default_port.
Date: Tue,  5 Aug 2025 13:49:22 +0700	[thread overview]
Message-ID: <20250805064933.109080-3-reyuki@gnuweeb.org> (raw)
In-Reply-To: <20250805064933.109080-1-reyuki@gnuweeb.org>

default_port as parameter in convert_str_to_ssaddr function is needed
when separator ':' does not exists in the provided address string.

Signed-off-by: Ahmad Gani <reyuki@gnuweeb.org>
---
 src/gwproxy/net.c | 10 +++++-----
 src/gwproxy/net.h |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/gwproxy/net.c b/src/gwproxy/net.c
index c65f124a30af..2397f7e3f55d 100644
--- a/src/gwproxy/net.c
+++ b/src/gwproxy/net.c
@@ -10,7 +10,7 @@
 #include <gwproxy/common.h>
 
 __cold
-int convert_str_to_ssaddr(const char *str, struct gwp_sockaddr *gs, uint16_t prt)
+int convert_str_to_ssaddr(const char *str, struct gwp_sockaddr *gs, uint16_t default_port)
 {
 	static const struct addrinfo hints = {
 		.ai_family = AF_UNSPEC,
@@ -29,9 +29,9 @@ int convert_str_to_ssaddr(const char *str, struct gwp_sockaddr *gs, uint16_t prt
 			return -EINVAL;
 		l = p - str;
 		p++;
-		if (*p != ':' && !prt)
+		if (*p != ':' && !default_port)
 			return -EINVAL;
-	} else if (!prt) {
+	} else if (!default_port) {
 		p = strchr(str, ':');
 		if (!p)
 			return -EINVAL;
@@ -43,8 +43,8 @@ int convert_str_to_ssaddr(const char *str, struct gwp_sockaddr *gs, uint16_t prt
 
 	strncpy(host, str, l);
 	host[l] = '\0';
-	if (prt) {
-		snprintf(port, 6, "%u", prt);
+	if (default_port) {
+		snprintf(port, 6, "%u", default_port);
 	} else {
 		strncpy(port, p + 1, sizeof(port) - 1);
 		port[sizeof(port) - 1] = '\0';
diff --git a/src/gwproxy/net.h b/src/gwproxy/net.h
index 113b176def74..3ef40d5ecfb3 100644
--- a/src/gwproxy/net.h
+++ b/src/gwproxy/net.h
@@ -19,10 +19,10 @@ struct gwp_sockaddr {
  *
  * @param str source
  * @param gs destination
- * @param prt default port, fill it with zero if unspecified
+ * @param default_port fill it with zero if unspecified
  * @return zero on success and a negative integer on failure.
  */
-int convert_str_to_ssaddr(const char *str, struct gwp_sockaddr *gs, uint16_t prt);
+int convert_str_to_ssaddr(const char *str, struct gwp_sockaddr *gs, uint16_t default_port);
 
 /*
  * Convert network address to string format
-- 
Ahmad Gani


  parent reply	other threads:[~2025-08-05  6:50 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-05  6:49 [PATCH gwproxy v3 0/9] Initial work for DNS lookup implementation Ahmad Gani
2025-08-05  6:49 ` [PATCH gwproxy v3 1/9] dnslookup: Split common functionality and struct into net.h and net.c Ahmad Gani
2025-08-05  9:26   ` Ammar Faizi
2025-08-05  6:49 ` Ahmad Gani [this message]
2025-08-05  9:26   ` [PATCH gwproxy v3 2/9] dnslookup: Add a new parameter, default_port Ammar Faizi
2025-08-05 10:15     ` reyuki
2025-08-05 10:26       ` Ammar Faizi
2025-08-05 10:43         ` Ahmad Gani
2025-08-05 10:46           ` Ammar Faizi
2025-08-05 12:45             ` Ahmad Gani
2025-08-05  6:49 ` [PATCH gwproxy v3 3/9] dnslookup: Allow only port string number Ahmad Gani
2025-08-05  6:49 ` [PATCH gwproxy v3 4/9] dnslookup: Initial work for implementation of C-ares-like getaddrinfo function Ahmad Gani
2025-08-05  6:49 ` [PATCH gwproxy v3 5/9] dnsparser: Update unit test of dns parser Ahmad Gani
2025-08-05  9:27   ` Ammar Faizi
2025-08-05  6:49 ` [PATCH gwproxy v3 6/9] dnsparser: Fix serialize_answ function Ahmad Gani
2025-08-05  9:26   ` Ammar Faizi
2025-08-05 12:47     ` Ahmad Gani
2025-08-05 13:04       ` Ammar Faizi
2025-08-05 13:12         ` Ahmad Gani
2025-08-05 13:51         ` Ahmad Gani
2025-08-05 14:02           ` Ammar Faizi
2025-08-05  6:49 ` [PATCH gwproxy v3 7/9] dnsparser: Transaction id creation is delegated to caller Ahmad Gani
2025-08-05  6:49 ` [PATCH gwproxy v3 8/9] dnslookup: Make gw_ares_getaddrinfo asynchronous Ahmad Gani
2025-08-05  6:49 ` [PATCH gwproxy v3 9/9] dnslookup: code style changes Ahmad Gani
2025-08-05  9:26   ` Ammar Faizi
2025-08-05 13:22 ` [PATCH gwproxy v3 0/9] Initial work for DNS lookup implementation Ammar Faizi
2025-08-05 13:28   ` Ahmad Gani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250805064933.109080-3-reyuki@gnuweeb.org \
    --to=reyuki@gnuweeb.org \
    --cc=alviro.iskandar@gnuweeb.org \
    --cc=ammarfaizi2@gnuweeb.org \
    --cc=gwml@vger.gnuweeb.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox