summaryrefslogtreecommitdiff
path: root/net/net.c
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2018-07-03 19:36:43 -0500
committerJoe Hershberger <joe.hershberger@ni.com>2018-07-26 14:08:20 -0500
commit6ab12830921c1de4eb90a0d471bf5f4677af734c (patch)
treee843a02a84a0797ab7d0dbb7e4e4cc8d3cb0a3a9 /net/net.c
parentf43308fa0c7834d9707a2c212591275d1e095e50 (diff)
downloadu-boot-6ab12830921c1de4eb90a0d471bf5f4677af734c.tar.gz
net: Consolidate the parsing of bootfile
The same basic parsing was implemented in tftp and nfs, so add a helper function to do the work once. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'net/net.c')
-rw-r--r--net/net.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/net/net.c b/net/net.c
index 1b6781d358..31cf306ae7 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1517,6 +1517,26 @@ int is_serverip_in_cmd(void)
return !!strchr(net_boot_file_name, ':');
}
+int net_parse_bootfile(struct in_addr *ipaddr, char *filename, int max_len)
+{
+ char *colon;
+
+ if (net_boot_file_name[0] == '\0')
+ return 0;
+
+ colon = strchr(net_boot_file_name, ':');
+ if (colon) {
+ if (ipaddr)
+ *ipaddr = string_to_ip(net_boot_file_name);
+ strncpy(filename, colon + 1, max_len);
+ } else {
+ strncpy(filename, net_boot_file_name, max_len);
+ }
+ filename[max_len - 1] = '\0';
+
+ return 1;
+}
+
#if defined(CONFIG_CMD_NFS) || \
defined(CONFIG_CMD_SNTP) || \
defined(CONFIG_CMD_DNS)