From patchwork Wed May 9 05:37:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 910663 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40glrP1Rk0z9s1w for ; Wed, 9 May 2018 15:52:53 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="UqhR+70z"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="evKquckr"; 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 40glrN71V2zF26C for ; Wed, 9 May 2018 15:52:52 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="UqhR+70z"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="evKquckr"; dkim-atps=neutral X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mendozajonas.com (client-ip=66.111.4.27; helo=out3-smtp.messagingengine.com; envelope-from=sam@mendozajonas.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="UqhR+70z"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="evKquckr"; dkim-atps=neutral Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40glVX69vdzF26C for ; Wed, 9 May 2018 15:37:24 +1000 (AEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 97A4322B9C; Wed, 9 May 2018 01:37:22 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 09 May 2018 01:37:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= mendozajonas.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=0cSwR67+e8tGeoAHwoWXmxxKjCy1LTr+RXCjRKRALEA=; b=UqhR+70z SOO/ZoHDgAyPfOBhmnALhBIM6wXJe76KpyWpBrLlM4RXrU8Z+9ZgW3EFNyfiYQ+x SOMs4yNdpSoF603e1RIb03IlkdmUjiVtwPuLbAsxk20MxybkS/U6E9kEBuGlvL6B MODw536XxH6TQQBySsSGFPL70HubhuqWzkBmH3KfITivr4YCbXlzx2A8oNptWah6 xkNRygPl5Aa7DL1K/LaRRZae3eYiBJVrCknJejcPOv1gU74sGAUZiik9wkMM1M9D oCAyOSFuwuvHuF48DTlMDlGD5YXEVWBkjUJHQENbyhmvshyz87ajRgqO/tKTVeYm cPghkZafbn3MSA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=0cSwR67+e8tGeoAHwoWXmxxKjCy1LTr+RXCjRKRALEA=; b=evKquckr lq3YVoNBt5dtqmWuV9JMGeVsR+Hl9W7ffE3ED3X/wGHv1etGfGzhObG7LtVXfHpq Lg/20O36wjtxdQcmbHY0o+zjwTQ9XljdBtpCmPgYPDALjGyfHkhzcvdqiVzBB1lW qgDiZKD0uAofqISL2Z+7Eyd2G4OfkqPuHURP0vnrQrYlE++aa+7rgf1vhjNzoMoj A3DU7B2G4zh5Yhy8Lqi88O3dF/Zn4y1/0ECsLgEtgr5MJ8e/u2jfWnHmxCOnfMM5 VG9uQBFSQfajRvoBkeLkY8LVnTFgZQBvTcm3wyxYa22JpLpNUOtBYtxVdGerM5R7 o5CXUAK3EZAp1A== X-ME-Sender: Received: from v4.ozlabs.ibm.com (unknown [122.99.82.10]) by mail.messagingengine.com (Postfix) with ESMTPA id 5800B10253; Wed, 9 May 2018 01:37:21 -0400 (EDT) From: Samuel Mendoza-Jonas To: petitboot@lists.ozlabs.org Subject: [PATCH 4/7] lib/types: Add DHCP scheme to network config Date: Wed, 9 May 2018 15:37:02 +1000 Message-Id: <20180509053705.3143-5-sam@mendozajonas.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180509053705.3143-1-sam@mendozajonas.com> References: <20180509053705.3143-1-sam@mendozajonas.com> X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.26 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" Signed-off-by: Samuel Mendoza-Jonas --- lib/pb-protocol/pb-protocol.c | 9 +++++++++ lib/types/types.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c index dbbda40..74a89de 100644 --- a/lib/pb-protocol/pb-protocol.c +++ b/lib/pb-protocol/pb-protocol.c @@ -309,6 +309,8 @@ int pb_protocol_config_len(const struct config *config) for (i = 0; i < config->network.n_dns_servers; i++) len += 4 + optional_strlen(config->network.dns_servers[i]); + len += 4 /* config->network.addr_type */; + len += 4 + optional_strlen(config->http_proxy); len += 4 + optional_strlen(config->https_proxy); @@ -581,6 +583,9 @@ int pb_protocol_serialise_config(const struct config *config, config->network.dns_servers[i]); } + *(uint32_t *)pos = __cpu_to_be32(config->network.addr_type); + pos += 4; + pos += pb_protocol_serialise_string(pos, config->http_proxy); pos += pb_protocol_serialise_string(pos, config->https_proxy); @@ -1141,6 +1146,10 @@ int pb_protocol_deserialise_config(struct config *config, config->network.dns_servers[i] = str; } + if (read_u32(&pos, &len, &tmp)) + goto out; + config->network.addr_type = tmp; + if (read_string(config, &pos, &len, &str)) goto out; config->http_proxy = str; diff --git a/lib/types/types.h b/lib/types/types.h index 9ab2a43..1bf518e 100644 --- a/lib/types/types.h +++ b/lib/types/types.h @@ -162,6 +162,10 @@ struct network_config { unsigned int n_interfaces; const char **dns_servers; unsigned int n_dns_servers; + enum { + ADDR_IPV4, + ADDR_IPV6, + } addr_type; }; struct autoboot_option {