From f1d925d9c39628d346b3809408695cd5c8b8faa2 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Wed, 20 May 2020 13:31:41 +0300 Subject: net: move random_port() to dns The random_port() routine is not used anywhere else. Make it local to dns.c to reduce code clutter, and shrink generated code a little. Signed-off-by: Baruch Siach --- net/dns.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'net/dns.c') diff --git a/net/dns.c b/net/dns.c index e35c4dca7c..5b1fe5b010 100644 --- a/net/dns.c +++ b/net/dns.c @@ -36,6 +36,16 @@ char *net_dns_env_var; /* The envvar to store the answer in */ static int dns_our_port; +/* + * make port a little random (1024-17407) + * This keeps the math somewhat trivial to compute, and seems to work with + * all supported protocols/clients/servers + */ +static unsigned int random_port(void) +{ + return 1024 + (get_timer(0) % 0x4000); +} + static void dns_send(void) { struct header *header; -- cgit v1.2.1