diff options
author | Baruch Siach <baruch@tkos.co.il> | 2020-05-20 13:31:41 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-06-12 13:17:23 -0400 |
commit | f1d925d9c39628d346b3809408695cd5c8b8faa2 (patch) | |
tree | 48fcd8954ca5d99a1b0e834d24031fbc353bf762 /net | |
parent | 0813921042c363a9c591454144226e67ed21a223 (diff) |
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 <baruch@tkos.co.il>
Diffstat (limited to 'net')
-rw-r--r-- | net/dns.c | 10 | ||||
-rw-r--r-- | net/net.c | 14 |
2 files changed, 10 insertions, 14 deletions
@@ -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; @@ -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); |