diff options
| author | Adriano Cordova <[email protected]> | 2024-12-04 00:05:16 -0300 |
|---|---|---|
| committer | Heinrich Schuchardt <[email protected]> | 2024-12-04 12:24:37 +0100 |
| commit | 9bab7d2a7c37b486ed6c368cfdfb42575ab112e4 (patch) | |
| tree | 0c0a7b87f9963d4cb93b15f6a2582ad33fbd4eef /net | |
| parent | dc7c8a2532925fa526ca6bd35b0519d5e3e97aed (diff) | |
net: wget: let wget_with_dns work with dns disabled
This was marked as TODO in the code:
- Enable use of wget_with_dns even if CMD_DNS is disabled if
the given uri has the ip address for the http server.
- Move the check for CMD_DNS inside wget_with_dns.
- Rename wget_with_dns to wget_do_request
Signed-off-by: Adriano Cordova <[email protected]>
Reviewed-by: Heinrich Schuchardt <[email protected]>
Reviewed-by: Jerome Forissier <[email protected]>
Diffstat (limited to 'net')
| -rw-r--r-- | net/lwip/wget.c | 4 | ||||
| -rw-r--r-- | net/net-common.c | 2 | ||||
| -rw-r--r-- | net/wget.c | 34 |
3 files changed, 23 insertions, 17 deletions
diff --git a/net/lwip/wget.c b/net/lwip/wget.c index 263d6dab26c..669eded0f38 100644 --- a/net/lwip/wget.c +++ b/net/lwip/wget.c @@ -353,7 +353,7 @@ static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri) return -1; } -int wget_with_dns(ulong dst_addr, char *uri) +int wget_do_request(ulong dst_addr, char *uri) { eth_set_current(); @@ -387,7 +387,7 @@ int do_wget(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) return CMD_RET_FAILURE; wget_info = &default_wget_info; - if (wget_with_dns(dst_addr, nurl)) + if (wget_do_request(dst_addr, nurl)) return CMD_RET_FAILURE; return CMD_RET_SUCCESS; diff --git a/net/net-common.c b/net/net-common.c index 45288fe5f80..e01b0da7d7b 100644 --- a/net/net-common.c +++ b/net/net-common.c @@ -23,5 +23,5 @@ struct wget_http_info *wget_info; int wget_request(ulong dst_addr, char *uri, struct wget_http_info *info) { wget_info = info ? info : &default_wget_info; - return wget_with_dns(dst_addr, uri); + return wget_do_request(dst_addr, uri); } diff --git a/net/wget.c b/net/wget.c index 5d70b7a82e0..f3b43b06b8b 100644 --- a/net/wget.c +++ b/net/wget.c @@ -535,8 +535,7 @@ void wget_start(void) wget_send(TCP_SYN, 0, 0, 0); } -#if (IS_ENABLED(CONFIG_CMD_DNS)) -int wget_with_dns(ulong dst_addr, char *uri) +int wget_do_request(ulong dst_addr, char *uri) { int ret; char *s, *host_name, *file_name, *str_copy; @@ -555,24 +554,32 @@ int wget_with_dns(ulong dst_addr, char *uri) s = str_copy + strlen("http://"); host_name = strsep(&s, "/"); if (!s) { - log_err("Error: invalied uri, no file path\n"); ret = -EINVAL; goto out; } file_name = s; - /* TODO: If the given uri has ip address for the http server, skip dns */ - net_dns_resolve = host_name; - net_dns_env_var = "httpserverip"; - if (net_loop(DNS) < 0) { - log_err("Error: dns lookup of %s failed, check setup\n", net_dns_resolve); - ret = -EINVAL; - goto out; - } - s = env_get("httpserverip"); - if (!s) { + host_name = strsep(&host_name, ":"); + + if (string_to_ip(host_name).s_addr) { + s = host_name; + } else { +#if IS_ENABLED(CONFIG_CMD_DNS) + net_dns_resolve = host_name; + net_dns_env_var = "httpserverip"; + if (net_loop(DNS) < 0) { + ret = -EINVAL; + goto out; + } + s = env_get("httpserverip"); + if (!s) { + ret = -EINVAL; + goto out; + } +#else ret = -EINVAL; goto out; +#endif } strlcpy(net_boot_file_name, s, sizeof(net_boot_file_name)); @@ -586,7 +593,6 @@ out: return ret < 0 ? ret : 0; } -#endif /** * wget_validate_uri() - validate the uri for wget |
