From patchwork Thu Apr 16 17:54:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel M. Weeks" X-Patchwork-Id: 1271826 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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4936Qd6GzQz9sWM for ; Fri, 17 Apr 2020 03:58:17 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=rpi.edu Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4936Qc09H2zDsMK for ; Fri, 17 Apr 2020 03:58:16 +1000 (AEST) X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=rpi.edu (client-ip=128.113.2.229; helo=smtp9.server.rpi.edu; envelope-from=weeksd2@rpi.edu; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=rpi.edu Received: from smtp9.server.rpi.edu (smtp9.server.rpi.edu [128.113.2.229]) (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 4936M03YJvzDrR2 for ; Fri, 17 Apr 2020 03:55:08 +1000 (AEST) Received: from smtp-auth3.server.rpi.edu (smtp-auth3.server.rpi.edu [128.113.2.233]) by smtp9.server.rpi.edu (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 03GHsrc3115906 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Apr 2020 13:54:56 -0400 Received: from smtp-auth3.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth3.server.rpi.edu (Postfix) with ESMTP id B1EB5580E0 for ; Thu, 16 Apr 2020 13:54:52 -0400 (EDT) Received: from dev.danweeks.net (cpe-74-70-107-6.nycap.res.rr.com [74.70.107.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: weeksd2) by smtp-auth3.server.rpi.edu (Postfix) with ESMTPSA id 71874580DF for ; Thu, 16 Apr 2020 13:54:52 -0400 (EDT) Date: Thu, 16 Apr 2020 13:54:48 -0400 From: "Daniel M. Weeks" To: petitboot@lists.ozlabs.org Subject: [PATCH 05/11] Add hwaddr length field to interface config Message-ID: <851952481e8176e31ded29bb696a050f2797b1a1.1587059210.git.weeksd2@rpi.edu> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Virus-Scanned: ClamAV using ClamSMTP X-Bayes-Prob: 0.0001 (Score 0, tokens from: outgoing, @@RPTN) X-Spam-Score: 0.00 () [Hold at 10.10] X-CanIt-Incident-Id: 022rtSRat X-CanIt-Geo: ip=74.70.107.6; country=US; region=New York; city=Troy; latitude=42.7273; longitude=-73.6696; http://maps.google.com/maps?q=42.7273,-73.6696&z=6 X-CanItPRO-Stream: outgoing X-Canit-Stats-ID: Bayes signature not available X-Scanned-By: CanIt (www . roaringpenguin . com) on 128.113.2.229 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" This field allows hardware addresses of different lengths to be stored in in the fixed-size field hwaddr. The pb interface_config (de)serialize functions are updated to include this new field. Signed-off-by: Daniel M. Weeks --- lib/pb-protocol/pb-protocol.c | 8 +++++++- lib/types/types.h | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c index dbbda40..b5186ad 100644 --- a/lib/pb-protocol/pb-protocol.c +++ b/lib/pb-protocol/pb-protocol.c @@ -273,7 +273,7 @@ static int pb_protocol_interface_config_len(struct interface_config *conf) { unsigned int len; - len = sizeof(conf->hwaddr) + + len = 4 + sizeof(conf->hwaddr) + 4 /* conf->ignore */; if (conf->ignore) @@ -524,6 +524,9 @@ static int pb_protocol_serialise_config_interface(char *buf, { char *pos = buf; + *(uint32_t *)pos = __cpu_to_be32(conf->hwaddr_len); + pos += 4; + memcpy(pos, conf->hwaddr, sizeof(conf->hwaddr)); pos += sizeof(conf->hwaddr); @@ -1058,6 +1061,9 @@ static int pb_protocol_deserialise_config_interface(const char **buf, { unsigned int tmp; + if (read_u32(buf, len, &iface->hwaddr_len)) + return -1; + if (*len < sizeof(iface->hwaddr)) return -1; diff --git a/lib/types/types.h b/lib/types/types.h index 9ab2a43..719332a 100644 --- a/lib/types/types.h +++ b/lib/types/types.h @@ -139,8 +139,9 @@ struct system_info { #define HWADDR_SIZE 6 struct interface_config { - uint8_t hwaddr[HWADDR_SIZE]; - bool ignore; + unsigned int hwaddr_len; + uint8_t hwaddr[HWADDR_SIZE]; + bool ignore; enum { CONFIG_METHOD_DHCP, CONFIG_METHOD_STATIC,