From nobody Tue Nov 11 07:26:14 2025 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1570461297; cv=none; d=zoho.com; s=zohoarc; b=S75cO8C7ZBJKX2VJHHQ+61EqUjr+ODK574O4u4VaFOOYBWNGUclBF4EITZe+i8rXdk3P4FHa5Q11zvsVM+RuGKiyVZaWFPnwPUYbq44oqu5IeKp15k7pPEwflc0y+ErOmkgnQvdRSUHqZGl8lc/nmYBKHFvsuFrxFkrVlyYYUkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570461297; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=EqCclY2glCQwpqO7wFaH7dCa2/CmXjYmkZPEqgKUPyg=; b=i4UYUWSMuyOxmKT5UPv4x6tAxvR7EIk5u1USOGdbAdHDkd+ZDV6rCUUdCzRvT2S52JtsUzebjQ2tb9n9CIw2J8+p9Gu/D0IwBt+eZFfXdifLmbMLux9FNMiXI64g1T4CotjkTrXdS6yjAoHoHT5Ij89afU7MLukkVq75rDPfFwI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1570461297000491.37509233143203; Mon, 7 Oct 2019 08:14:57 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iHUhy-0006wQ-A0; Mon, 07 Oct 2019 15:13:58 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iHUhw-0006vi-N6 for xen-devel@lists.xenproject.org; Mon, 07 Oct 2019 15:13:56 +0000 Received: from mail-qk1-x741.google.com (unknown [2607:f8b0:4864:20::741]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 02433816-e915-11e9-9bee-bc764e2007e4; Mon, 07 Oct 2019 15:13:25 +0000 (UTC) Received: by mail-qk1-x741.google.com with SMTP id u22so12880653qkk.11 for ; Mon, 07 Oct 2019 08:13:25 -0700 (PDT) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id c185sm8354313qkg.74.2019.10.07.08.13.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:13:24 -0700 (PDT) X-Inumbo-ID: 02433816-e915-11e9-9bee-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HAvGISQ6Hj/ngZwWekmPgCL2zhfgRNQEGjJgKrLszak=; b=ItZvXRStLPiJaiwubiuFCppj/IPOZ9MNMXmcKn6ljBwlV6kULoAURJ2HhKdo1jyVah mn7p3Axl9DoEoo5uXYQfQQiyaozttI6kL2xtNM2lhfrPVJkz1/wn99mxjqxcuFefo+jx gMfyjwEqlLToqCipAyIVvFCzsXR6LkXHe6brkoPyYq5Qw2j3Z/Vn8dzuQ2OW8govHRvs iVAopQt/bUjhZwTr0oDFpkBfdZJ5ow9GzFVgui0LvAFLdpEQm3tnF8JrS1wpfYmqZn3b QSp4tAeSzLA9u67WZA9A0//9fk6uMfz85WiFqGWkZBmRB/JMz87QRZvFUZn4vN1JWdGw 2lyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HAvGISQ6Hj/ngZwWekmPgCL2zhfgRNQEGjJgKrLszak=; b=nj+ttLMJDW8SQ2oiAti2BrYMugPsKWM0auQVFL/9WtBrvmwUljj7/sVud1g2neukz8 NOKy8lZS4h2Agavvh1EPXPJIjqZ9BqLVQZl/YrdyDtX2FdAw7wdjmZE4KmnuJkG25RXZ qmmFlEFAvABYZncHESRsfy+YzLS09IVzRoRbKheZNteJaQgJtzCAbapC3fHAUsDhdJY6 8eKr9vIhh0B8HWz4g2SBilDwCdC1S0AQhRIACVOw+u3tW3ZEcfAQAOCRMj5fUodJ1gpY HLBZSxrSnRctVii6I6Ju9QWIlZxUHjCIVc4zGtbQEzal07WdEF/bPJEN0VDoVYVo/l7z omag== X-Gm-Message-State: APjAAAXIuAzUeHT8L25is2P49gIqeRR7EFEG62Pp/yStQ5RUqDueDQ2a qrXB3xceVKNhDKCYWFxyEE6abBHN X-Google-Smtp-Source: APXvYqwOrh3eWMn2yfCqFXSG2w+ztOflgE+1c8MnNwX9tU/HIqErc3YMQ6CCpUv/VyMnC+nsiDqrdg== X-Received: by 2002:a37:684f:: with SMTP id d76mr8217403qkc.415.1570461204706; Mon, 07 Oct 2019 08:13:24 -0700 (PDT) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Mon, 7 Oct 2019 11:12:55 -0400 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 08/24] golang/xenlight: define Mac builtin type X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Ian Jackson , kerriganb@ainfosec.com, George Dunlap , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Define Mac as [6]byte and implement fromC, toC, and String functions. Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/xenlight.go | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index a3a1836d31..3b7824b284 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -181,6 +181,41 @@ func (d *Defbool) toC() (C.libxl_defbool, error) { return c, nil } =20 +// Mac represents a libxl_mac, or simply a MAC address. +type Mac [6]byte + +// String formats a Mac address to string representation. +func (mac Mac) String() string { + s :=3D "%x:%x:%x:%x:%x:%x" + opts :=3D make([]interface{}, 6) + + for i, v :=3D range mac { + opts[i] =3D v + } + + return fmt.Sprintf(s, opts...) +} + +func (mac *Mac) fromC(cmac *C.libxl_mac) error { + b :=3D (*[6]C.uint8_t)(unsafe.Pointer(cmac)) + + for i, v :=3D range b { + mac[i] =3D byte(v) + } + + return nil +} + +func (mac *Mac) toC() (C.libxl_mac, error) { + var cmac C.libxl_mac + + for i, v :=3D range mac { + cmac[i] =3D C.uint8_t(v) + } + + return cmac, nil +} + type Context struct { ctx *C.libxl_ctx logger *C.xentoollog_logger_stdiostream --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel