void device_handler_status(struct device_handler *handler,
struct status *status)
{
+ pb_debug("%s: %s\n", __func__, status->message);
discover_server_notify_boot_status(handler->server, status);
}
}
if (!update) {
- pb_log("%s: failed to allocate new status\n", __func__);
+ pb_log_fn("failed to allocate new status\n");
} else {
device_handler_status_info(handler, "%s\n", update);
talloc_free(update);
default_timeout(handler);
}
+static char *autoboot_option_desc(void *ctx, const struct autoboot_option *opt)
+{
+ const char *type, *val;
+
+ if (opt->boot_type == BOOT_DEVICE_TYPE) {
+ type = _("device type");
+ val = device_type_display_name(opt->type);
+ } else if (opt->boot_type == BOOT_DEVICE_UUID) {
+ type = _("device UUID");
+ val = opt->uuid;
+ } else {
+ type = _("unknown specifier");
+ val = NULL;
+ }
+
+ return talloc_asprintf(ctx, "%s = %s", type, val);
+}
+
void device_handler_apply_temp_autoboot(struct device_handler *handler,
struct autoboot_option *opt)
{
unsigned int i;
+ char *desc;
handler->temp_autoboot = talloc_steal(handler, opt);
+ desc = autoboot_option_desc(handler, opt);
+ device_handler_status_info(handler,
+ _("Applying temporary autoboot override: %s"),
+ desc);
+ talloc_free(desc);
+
if (!handler->autoboot_enabled)
return;
struct discover_device *dev, struct event *event)
{
struct discover_context *ctx;
+ const char *ip;
+
+ if (event_get_param(event, "ipv6"))
+ ip = event_get_param(event, "ipv6");
+ else
+ ip = event_get_param(event, "ip");
device_handler_status_dev_info(handler, dev,
- _("Processing DHCP lease response (ip: %s)"),
- event_get_param(event, "ip"));
+ _("Processing DHCP lease response (ip: %s)"), ip);
pending_network_jobs_start();
static char *device_from_addr(void *ctx, struct pb_url *url)
{
char *ipaddr, *buf, *tok, *dev = NULL;
+ bool ipv6_route;
const char *delim = " ";
- struct sockaddr_in *ip;
- struct sockaddr_in si;
+ struct sockaddr_in *ipv4;
+ struct sockaddr_in6 *ipv6;
struct addrinfo *res;
struct process *p;
int rc;
- /* Note: IPv4 only */
- rc = inet_pton(AF_INET, url->host, &(si.sin_addr));
- if (rc > 0) {
- ipaddr = url->host;
- } else {
- /* need to turn hostname into a valid IP */
- rc = getaddrinfo(url->host, NULL, NULL, &res);
- if (rc) {
- pb_debug("%s: Invalid URL\n",__func__);
- return NULL;
- }
+ /* Confirm url->host is either a valid hostname, or a
+ * valid IPv4 or IPv6 address */
+ rc = getaddrinfo(url->host, NULL, NULL, &res);
+ if (rc) {
+ pb_debug("%s: Invalid URL\n",__func__);
+ return NULL;
+ }
+
+ switch (res->ai_family) {
+ case AF_INET: /* ipv4 */
ipaddr = talloc_array(ctx,char,INET_ADDRSTRLEN);
- ip = (struct sockaddr_in *) res->ai_addr;
- inet_ntop(AF_INET, &(ip->sin_addr), ipaddr, INET_ADDRSTRLEN);
+ ipv4 = (struct sockaddr_in *) res->ai_addr;
+ inet_ntop(AF_INET, &(ipv4->sin_addr), ipaddr, INET_ADDRSTRLEN);
+ ipv6_route = false;
+ break;
+ case AF_INET6: /* ipv6 */
+ ipaddr = talloc_array(ctx,char,INET6_ADDRSTRLEN);
+ ipv6 = (struct sockaddr_in6 *) res->ai_addr;
+ inet_ntop(AF_INET6, &(ipv6->sin6_addr), ipaddr, INET6_ADDRSTRLEN);
+ ipv6_route = true;
+ break;
+ default: /* error */
freeaddrinfo(res);
+ return NULL;
}
+ freeaddrinfo(res);
const char *argv[] = {
pb_system_apps.ip,
+ ipv6_route ? "-6" : "-4",
"route", "show", "to", "match",
ipaddr,
NULL
const char *mac;
if (result->status != LOAD_OK) {
- pb_log("%s: Load failed for %s\n", __func__, result->url->full);
+ pb_log_fn("Load failed for %s\n", result->url->full);
return;
}
struct device_handler *handler = process->data;
if (!handler) {
- pb_log("%s: Missing data!\n", __func__);
+ pb_log_fn("Missing data!\n");
return;
}
struct device_handler *handler __attribute__((unused)),
struct discover_context *ctx __attribute__((unused)))
{
- pb_log("%s stubbed out for test cases\n", __func__);
+ pb_log_fn("stubbed out for test cases\n");
}
static void device_handler_update_lang(const char *lang __attribute__((unused)))