summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaruch Siach <baruch@tkos.co.il>2020-05-20 13:31:41 +0300
committerTom Rini <trini@konsulko.com>2020-06-12 13:11:43 -0400
commitc3a3aa80f6e7409650058106d8db816dcf6a57ae (patch)
treed9e01a029d888499ca1e98df0181941f5ad4ccc8
parent573f70f16f122ee15c4172b27264d758b23053dc (diff)
downloadu-boot-WIP/2020-06-12-next-net.tar.gz
net: move random_port() to dnsWIP/2020-06-12-next-net
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 <baruch@tkos.co.il>
-rw-r--r--include/net.h3
-rw-r--r--net/dns.c10
-rw-r--r--net/net.c14
3 files changed, 10 insertions, 17 deletions
diff --git a/include/net.h b/include/net.h
index 00a8ec0c78..1bf9867f8c 100644
--- a/include/net.h
+++ b/include/net.h
@@ -897,9 +897,6 @@ int is_serverip_in_cmd(void);
*/
int net_parse_bootfile(struct in_addr *ipaddr, char *filename, int max_len);
-/* get a random source port */
-unsigned int random_port(void);
-
/**
* update_tftp - Update firmware over TFTP (via DFU)
*
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;
diff --git a/net/net.c b/net/net.c
index 11683dd6d0..1e7f633cb6 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1564,20 +1564,6 @@ int net_parse_bootfile(struct in_addr *ipaddr, char *filename, int max_len)
return 1;
}
-#if defined(CONFIG_CMD_NFS) || \
- defined(CONFIG_CMD_SNTP) || \
- defined(CONFIG_CMD_DNS)
-/*
- * 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
- */
-unsigned int random_port(void)
-{
- return 1024 + (get_timer(0) % 0x4000);
-}
-#endif
-
void ip_to_string(struct in_addr x, char *s)
{
x.s_addr = ntohl(x.s_addr);