From patchwork Mon Dec 19 04:18:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 706919 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3thnlN2T4Cz9s65 for ; Mon, 19 Dec 2016 15:20:32 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="kfEM54/q"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3thnlN1Qc1zDwHJ for ; Mon, 19 Dec 2016 15:20:32 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="kfEM54/q"; dkim-atps=neutral X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Received: from mendozajonas.com (mendozajonas.com [188.166.185.233]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3thnkW0ljpzDw9n for ; Mon, 19 Dec 2016 15:19:47 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="kfEM54/q"; dkim-atps=neutral Received: from skellige.ozlabs.ibm.com (unknown [122.99.82.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: sam@mendozajonas.com) by mendozajonas.com (Postfix) with ESMTPSA id 4CA63143F6E; Mon, 19 Dec 2016 12:19:43 +0800 (SGT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mendozajonas.com; s=mail; t=1482121184; bh=DuU5aBcJmj+RgXwRvNiaNvo3vuMsfCHJ78MY+1jso2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kfEM54/qzREDQsdzja9Y1lizTjMm7on3lmRVOtzMB1FpKfUQaka+4IyVPuryH7EcN NIiTe7Z+vi78yNDRUZxDGy3vqSz/6DCBg1xZO0a3DghOsIDkCx6ePxIvh46b7Cz3Du 23AOyjHyxrii9GG2mKEFJq7tNpPqshAzgv0oeRVY= From: Samuel Mendoza-Jonas To: petitboot@lists.ozlabs.org Subject: [PATCH 10/29] discover: add handler reference to struct discover_context Date: Mon, 19 Dec 2016 15:18:56 +1100 Message-Id: <20161219041915.30497-11-sam@mendozajonas.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161219041915.30497-1-sam@mendozajonas.com> References: <20161219041915.30497-1-sam@mendozajonas.com> X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Mendoza-Jonas MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" From: Jeremy Kerr Since the device handler provides the status message functions, we need a pointer to it for device discovery (which we use a struct discover_context for). This change adds a 'handler' member to struct discover_context, to allow status reporting. Since we now have a handler, there's no need for the network pointer, so provide an accessor function instead. Signed-off-by: Jeremy Kerr Signed-off-by: Samuel Mendoza-Jonas --- discover/device-handler.c | 8 +++++++- discover/device-handler.h | 4 +++- discover/pxe-parser.c | 6 ++++-- test/parser/utils.c | 1 + 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/discover/device-handler.c b/discover/device-handler.c index a9a24ae..fd9b155 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -114,6 +114,12 @@ const struct discover_device *device_handler_get_device( return handler->devices[index]; } +struct network *device_handler_get_network( + const struct device_handler *handler) +{ + return handler->network; +} + struct discover_boot_option *discover_boot_option_create( struct discover_context *ctx, struct discover_device *device) @@ -787,8 +793,8 @@ struct discover_context *device_handler_discover_context_create( struct discover_context *ctx; ctx = talloc_zero(handler, struct discover_context); + ctx->handler = handler; ctx->device = device; - ctx->network = handler->network; list_init(&ctx->boot_options); return ctx; diff --git a/discover/device-handler.h b/discover/device-handler.h index fe8a3b0..874133d 100644 --- a/discover/device-handler.h +++ b/discover/device-handler.h @@ -54,12 +54,12 @@ struct discover_boot_option { struct discover_context { + struct device_handler *handler; struct parser *parser; struct event *event; struct discover_device *device; struct list boot_options; struct pb_url *conf_url; - struct network *network; void *test_data; }; @@ -79,6 +79,8 @@ void device_handler_destroy(struct device_handler *devices); int device_handler_get_device_count(const struct device_handler *handler); const struct discover_device *device_handler_get_device( const struct device_handler *handler, unsigned int index); +struct network *device_handler_get_network( + const struct device_handler *handler); struct discover_device *discover_device_create(struct device_handler *handler, const char *uuid, const char *id); diff --git a/discover/pxe-parser.c b/discover/pxe-parser.c index 8237c4b..cd5f149 100644 --- a/discover/pxe-parser.c +++ b/discover/pxe-parser.c @@ -11,6 +11,7 @@ #include #include +#include "device-handler.h" #include "parser.h" #include "parser-conf.h" #include "parser-utils.h" @@ -108,8 +109,9 @@ static void pxe_process_sysappend(struct discover_context *ctx, return; if (val & 0x2) { - uint8_t *mac = find_mac_by_name(ctx, ctx->network, - event->device); + uint8_t *mac = find_mac_by_name(ctx, + device_handler_get_network(ctx->handler), + event->device); str = pxe_sysappend_mac(ctx, mac); if (str) { pxe_append_string(opt, str); diff --git a/test/parser/utils.c b/test/parser/utils.c index f0796fd..6bc7cc5 100644 --- a/test/parser/utils.c +++ b/test/parser/utils.c @@ -93,6 +93,7 @@ static struct discover_context *test_create_context(struct parser_test *test) list_init(&ctx->boot_options); ctx->device = test_create_device_simple(test); ctx->test_data = test; + ctx->handler = test->handler; device_handler_add_device(test->handler, ctx->device); return ctx;