diff options
author | Nishanth Aravamudan <nacc@linux.vnet.ibm.com> | 2015-08-19 14:05:43 -0700 |
---|---|---|
committer | Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> | 2015-12-18 13:06:53 +1100 |
commit | f155a58a64c660e46e74123293482561b816a39a (patch) | |
tree | 9dd50fadc6c42cdbc0f34d28d67cac4653240946 /discover/device-handler.c | |
parent | 32d3249e252fe201eb81155cbf3b800ce5cf88e0 (diff) | |
download | talos-petitboot-f155a58a64c660e46e74123293482561b816a39a.tar.gz talos-petitboot-f155a58a64c660e46e74123293482561b816a39a.zip |
discover: extend URL in UI to support auto-discovery
The URL field currently only supports loading a particular file for
static network configurations. But it makes sense in certain static
network configurations to 'auto-discover' a file like petitboot does
with DHCP -- based off the MAC address and IP. Extend
device_handler_process_url to take those as parameters, and toggle off
the URL ending in a '/' to indicate whether to 'auto-discover' or
directly load the specified URL.
Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Diffstat (limited to 'discover/device-handler.c')
-rw-r--r-- | discover/device-handler.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c index 3804b34..5df0700 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -1125,9 +1125,8 @@ static char *device_from_addr(void *ctx, struct pb_url *url) return dev; } - void device_handler_process_url(struct device_handler *handler, - const char *url) + const char *url, const char *mac, const char *ip) { struct discover_context *ctx; struct discover_device *dev; @@ -1153,11 +1152,25 @@ void device_handler_process_url(struct device_handler *handler, event->type = EVENT_TYPE_USER; event->action = EVENT_ACTION_CONF; - event->params = talloc_array(event, struct param, 1); - param = &event->params[0]; - param->name = talloc_strdup(event, "pxeconffile"); - param->value = talloc_strdup(event, url); - event->n_params = 1; + if (url[strlen(url) - 1] == '/') { + event->params = talloc_array(event, struct param, 3); + param = &event->params[0]; + param->name = talloc_strdup(event, "pxepathprefix"); + param->value = talloc_strdup(event, url); + param = &event->params[1]; + param->name = talloc_strdup(event, "mac"); + param->value = talloc_strdup(event, mac); + param = &event->params[2]; + param->name = talloc_strdup(event, "ip"); + param->value = talloc_strdup(event, ip); + event->n_params = 3; + } else { + event->params = talloc_array(event, struct param, 1); + param = &event->params[0]; + param->name = talloc_strdup(event, "pxeconffile"); + param->value = talloc_strdup(event, url); + event->n_params = 1; + } pb_url = pb_url_parse(event, event->params->value); if (!pb_url || !pb_url->host) { |