connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: matthias.gerstner@suse.de
To: connman@lists.linux.dev
Subject: [PATCH 6/7] dnsproxy-test: support command line specification of dnsproxy port
Date: Thu, 17 Feb 2022 12:31:12 +0100	[thread overview]
Message-ID: <20220217113113.24088-7-matthias.gerstner@suse.de> (raw)
In-Reply-To: <20220217113113.24088-1-matthias.gerstner@suse.de>

From: Matthias Gerstner <matthias.gerstner@suse.de>

This way a dnsproxy running on an unprivileged port can be tested.
---
 tools/dnsproxy-test.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/dnsproxy-test.c b/tools/dnsproxy-test.c
index 371e2e23..7660db71 100644
--- a/tools/dnsproxy-test.c
+++ b/tools/dnsproxy-test.c
@@ -99,6 +99,8 @@ static unsigned char msg_invalid[] = {
 	0x31, 0xC0, /* tran id */
 };
 
+static const char *dns_port = "53";
+
 static int create_tcp_socket(int family)
 {
 	int sk, err;
@@ -139,7 +141,7 @@ static int connect_tcp_socket(char *server)
 	hints.ai_socktype = SOCK_STREAM;
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_flags = AI_NUMERICSERV | AI_NUMERICHOST;
-	getaddrinfo(server, "53", &hints, &rp);
+	getaddrinfo(server, dns_port, &hints, &rp);
 
 	sk = create_tcp_socket(rp->ai_family);
 	err = sk;
@@ -201,7 +203,7 @@ static int connect_udp_socket(char *server, struct sockaddr *sa,
 	hints.ai_socktype = SOCK_DGRAM;
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_flags = AI_NUMERICSERV | AI_NUMERICHOST;
-	getaddrinfo(server, "53", &hints, &rp);
+	getaddrinfo(server, dns_port, &hints, &rp);
 
 	sk = create_udp_socket(rp->ai_family);
 	err = sk;
@@ -430,6 +432,11 @@ int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
 
+	if (argc == 2) {
+		// alternative dns port
+		dns_port = argv[1];
+	}
+
 	g_test_add_func("/dnsproxy/ipv4 udp msg",
 			test_ipv4_udp_msg);
 
-- 
2.34.1


  parent reply	other threads:[~2022-02-17 11:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-17 11:31 dnsproxy: some initial refactoring and integration test matthias.gerstner
2022-02-17 11:31 ` [PATCH 1/7] dnsproxy: remove unused domain parameter from `remove_server()` matthias.gerstner
2022-02-17 11:31 ` [PATCH 2/7] dnsproxy: remove unnecessarily shadowed variable matthias.gerstner
2022-02-17 11:31 ` [PATCH 3/7] dnsproxy: protocol_offset: remove error return case and return size_t matthias.gerstner
2022-02-21  8:49   ` Daniel Wagner
2022-02-17 11:31 ` [PATCH 4/7] .gitignore: also ignore backup configure script matthias.gerstner
2022-02-21  8:49   ` Daniel Wagner
2022-02-17 11:31 ` [PATCH 5/7] dnsproxy: support programmatic configuration of the default listen port matthias.gerstner
2022-02-17 11:31 ` matthias.gerstner [this message]
2022-02-17 11:31 ` [PATCH 7/7] dnsproxy: add standalone test version of dnsproxy and a test script for it matthias.gerstner
2022-02-21  8:48   ` Daniel Wagner
2022-02-28 13:19     ` dnsproxy: some initial refactoring and integration test matthias.gerstner
2022-02-28 13:19       ` [PATCH] dnsproxy: add standalone test version of dnsproxy and a test script for it matthias.gerstner
2022-03-04  8:50         ` Daniel Wagner
2022-02-21  8:51 ` dnsproxy: some initial refactoring and integration test Daniel Wagner

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=20220217113113.24088-7-matthias.gerstner@suse.de \
    --to=matthias.gerstner@suse.de \
    --cc=connman@lists.linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).