From patchwork Thu Jun 2 09:56:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nayna X-Patchwork-Id: 629157 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rL2wc2zSlz9t0r for ; Thu, 2 Jun 2016 20:08:00 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3rL2wc2FCRzDvL5 for ; Thu, 2 Jun 2016 20:08:00 +1000 (AEST) X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3rL2hv1V5nzDqyH for ; Thu, 2 Jun 2016 19:57:51 +1000 (AEST) Received: from pps.filterd (m0075420.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u529urC1007842 for ; Thu, 2 Jun 2016 05:57:49 -0400 Received: from e23smtp09.au.ibm.com (e23smtp09.au.ibm.com [202.81.31.142]) by mx0a-001b2d01.pphosted.com with ESMTP id 23abqeb211-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 02 Jun 2016 05:57:48 -0400 Received: from localhost by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 2 Jun 2016 19:57:44 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 2 Jun 2016 19:57:44 +1000 X-IBM-Helo: d23dlp03.au.ibm.com X-IBM-MailFrom: nayna@linux.vnet.ibm.com X-IBM-RcptTo: petitboot@lists.ozlabs.org Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id F25CD3578053 for ; Thu, 2 Jun 2016 19:57:22 +1000 (EST) Received: from d23av06.au.ibm.com (d23av06.au.ibm.com [9.190.235.151]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u529vC9w7930118 for ; Thu, 2 Jun 2016 19:57:12 +1000 Received: from d23av06.au.ibm.com (localhost [127.0.0.1]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u529vC18019560 for ; Thu, 2 Jun 2016 19:57:12 +1000 Received: from c365f16u1b3.pok.stglabs.ibm.com (c365f16u1b3.pok.stglabs.ibm.com [9.47.77.42]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u529v6cQ019479; Thu, 2 Jun 2016 19:57:11 +1000 From: Nayna Jain To: petitboot@lists.ozlabs.org Subject: [PATCH 1/3] lib/types : Adds function to return struct config as string Date: Thu, 2 Jun 2016 05:56:56 -0400 X-Mailer: git-send-email 2.5.0 In-Reply-To: <1464861418-19709-1-git-send-email-nayna@linux.vnet.ibm.com> References: <1464861418-19709-1-git-send-email-nayna@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16060209-0052-0000-0000-0000019C6224 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16060209-0053-0000-0000-0000061C8121 Message-Id: <1464861418-19709-2-git-send-email-nayna@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-06-02_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1606020110 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hellerda@us.ibm.com, gcwilson@us.ibm.com MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" Two new functions added to return ipmi boot configuration and nvram boot configuration separately as string. Signed-off-by: Nayna Jain --- lib/types/types.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/types/types.h | 3 +++ 2 files changed, 78 insertions(+) diff --git a/lib/types/types.c b/lib/types/types.c index 63045e1..2f924f1 100644 --- a/lib/types/types.c +++ b/lib/types/types.c @@ -1,4 +1,6 @@ #include +#include +#include #include #include @@ -75,3 +77,76 @@ enum device_type find_device_type(const char *str) return DEVICE_TYPE_UNKNOWN; } + +unsigned char *get_ipmi_boot_policy_as_string(const struct config *config) +{ + unsigned char * input_data; + + input_data = talloc_asprintf(config, "%04x%s", config->ipmi_bootdev, + config->ipmi_bootdev_persistent ? "1" : "0"); + pb_log("Input data is %s, %d, %d\n", input_data, sizeof(input_data), + strlen(input_data)); + + return input_data; +} + +unsigned char *get_nvram_boot_policy_as_string(const struct config* config) +{ + + char * input_data = NULL; + char * autoboot_device = NULL; + unsigned int i = 0; + + input_data = talloc_asprintf(config, "%s%d%s%s%s%s", + config->autoboot_enabled ? "1": "0", + config->autoboot_timeout_sec, + config->safe_mode ? "1" : "0", + config->allow_writes ? "1" : "0", + config->disable_snapshots? "1" : "0", + config->lang ? config->lang : "0"); + for (i = 0; i < config->n_autoboot_opts; i++) + { + if (config->autoboot_opts[i].boot_type == BOOT_DEVICE_TYPE) + autoboot_device = device_type_name( + config->autoboot_opts[i].type); + else + autoboot_device = config->autoboot_opts[i].uuid; + input_data = talloc_asprintf_append(input_data, "%s", + autoboot_device); + } + + + for (i =0; i < config->network.n_interfaces; i++) + { + struct interface_config *iconf = config->network.interfaces[i]; + input_data = talloc_asprintf_append(input_data, + "%02x:%02x:%02x:%02x:%02x:%02x", + iconf->hwaddr[0], iconf->hwaddr[1], + iconf->hwaddr[2], iconf->hwaddr[3], + iconf->hwaddr[4], iconf->hwaddr[5]); + + input_data = talloc_asprintf_append(input_data,"%s", + iconf->ignore ? "1" : "0"); + if (iconf->method == CONFIG_METHOD_DHCP) { + input_data = talloc_asprintf_append(input_data, + "%s", "dhcp"); + + } else if (iconf->method == CONFIG_METHOD_STATIC) { + input_data = talloc_asprintf_append(input_data, + "%s%s%s%s", "static", + iconf->static_config.address, + iconf->static_config.gateway, + iconf->static_config.url); + } + + } + + for (i = 0; i < config->network.n_dns_servers; i++) + input_data = talloc_asprintf_append(input_data, "%s", + config->network.dns_servers[i]); + + pb_log("input data is %s, %d, %d\n", input_data, sizeof(input_data), + strlen(input_data)); + return input_data; + +} diff --git a/lib/types/types.h b/lib/types/types.h index 6ff4620..e6e1a78 100644 --- a/lib/types/types.h +++ b/lib/types/types.h @@ -167,4 +167,7 @@ struct config { bool debug; }; +unsigned char *get_ipmi_boot_policy_as_string(const struct config *conf); +unsigned char *get_nvram_boot_policy_as_string(const struct config *conf); + #endif /* _TYPES_H */