From patchwork Mon Mar 24 16:35:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Martin X-Patchwork-Id: 26936 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f200.google.com (mail-qc0-f200.google.com [209.85.216.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6D85A20143 for ; Mon, 24 Mar 2014 16:36:46 +0000 (UTC) Received: by mail-qc0-f200.google.com with SMTP id i17sf14265335qcy.3 for ; Mon, 24 Mar 2014 09:36:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:cc:subject :precedence:reply-to:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=VFMPbsv9ILtkKFwaKTlHaddsTyur3QF5PWAB76d7jIc=; b=WmOryb+QL0B/b2qdfobUxHpHrfoPpIZ8YD/PBpFax7fpVrfPWbARB081N0xkZo1m3R rS1058sQyG+/Y/DZf4E3vHeqMm7LGjkZCwtPFG3G6JhyWy2k7go+OxSlEA8KJIA0CBX+ JM6s8jZoMDwIxnQbHtUJ1/QcCIaV8EXZvMiU+80TPDwQTuLdbP3XTfXOSqm8BuZetjFP oJtLq+fNU7WYwocodyO8T4zc9ZuCmNp1hQAxIKJm6fpaJmmkj1I0iAF7TWHtp0ey4TTf PlxlstXZGTMIYIJN0xfC/KfZZcQJlz3biYtowZLNOdgrT8uPm82Jlsl2iY4n7JVLWNoC Xc1Q== X-Gm-Message-State: ALoCoQnSVBF5Ve8El4n2p2rZoiASU5EC4NJJW+SR/Jb7E11o96IwbYZsjhFDqmE3VeYDjX8oc92/ X-Received: by 10.58.7.134 with SMTP id j6mr17576612vea.29.1395679006199; Mon, 24 Mar 2014 09:36:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.198 with SMTP id h64ls1685951qgf.84.gmail; Mon, 24 Mar 2014 09:36:46 -0700 (PDT) X-Received: by 10.58.211.69 with SMTP id na5mr1167983vec.30.1395679006053; Mon, 24 Mar 2014 09:36:46 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id jb7si257029vec.35.2014.03.24.09.36.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Mar 2014 09:36:46 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id ij19so6044962vcb.38 for ; Mon, 24 Mar 2014 09:36:46 -0700 (PDT) X-Received: by 10.58.112.98 with SMTP id ip2mr810755veb.35.1395679005945; Mon, 24 Mar 2014 09:36:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp236516vck; Mon, 24 Mar 2014 09:36:45 -0700 (PDT) X-Received: by 10.42.121.147 with SMTP id j19mr51419819icr.13.1395679005200; Mon, 24 Mar 2014 09:36:45 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id y18si20950283igg.1.2014.03.24.09.36.14 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 24 Mar 2014 09:36:45 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1WS7r1-0006N8-RY; Mon, 24 Mar 2014 16:36:03 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1WS7r0-0006N1-AU for edk2-devel@lists.sourceforge.net; Mon, 24 Mar 2014 16:36:02 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of arm.com designates 217.140.96.21 as permitted sender) client-ip=217.140.96.21; envelope-from=olivier.martin@arm.com; helo=cam-smtp0.cambridge.arm.com; Received: from fw-tnat.cambridge.arm.com ([217.140.96.21] helo=cam-smtp0.cambridge.arm.com) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1WS7qx-0004p2-UT for edk2-devel@lists.sourceforge.net; Mon, 24 Mar 2014 16:36:02 +0000 Received: from e102605-lin.cambridge.arm.com (e102605-lin.cambridge.arm.com [10.1.193.42]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id s2OGZoLZ022538; Mon, 24 Mar 2014 16:35:50 GMT From: Olivier Martin To: feng.tian@intel.com Date: Mon, 24 Mar 2014 16:35:41 +0000 Message-Id: <1395678941-22924-1-git-send-email-olivier.martin@arm.com> X-Mailer: git-send-email 1.8.5 X-Spam-Score: -2.0 (--) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1WS7qx-0004p2-UT Cc: Brendan Jackman , edk2-devel@lists.sourceforge.net Subject: [edk2] [PATCH] Ip4ConfigDxe: Look up 'Hostname' variable when using DHCP X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: olivier.martin@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Brendan Jackman This change adds the Hostname option to the DHCP Options. See section "3.14. Host Name Option" of RFC2132 "DHCP Options and BOOTP Vendor Extensions" The Hostname DHCP option if the UEFI variable "Hostname" is defined. This UEFI variable would contain the "Hostname" value. Change-Id: I513ccf4ea9e0c1771885ced245ca893ffdb2014e Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Brendan Jackam Reviewed-by: Olivier Martin --- MdeModulePkg/Include/Guid/Hostname.h | 27 +++++++++++++++++ MdeModulePkg/MdeModulePkg.dec | 4 +++ .../Universal/Network/Ip4ConfigDxe/Ip4Config.c | 35 +++++++++++++++++++++- .../Universal/Network/Ip4ConfigDxe/Ip4Config.h | 1 + .../Network/Ip4ConfigDxe/Ip4ConfigDxe.inf | 1 + 5 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 MdeModulePkg/Include/Guid/Hostname.h diff --git a/MdeModulePkg/Include/Guid/Hostname.h b/MdeModulePkg/Include/Guid/Hostname.h new file mode 100644 index 0000000..4e79dc7 --- /dev/null +++ b/MdeModulePkg/Include/Guid/Hostname.h @@ -0,0 +1,27 @@ +/** @file +* +* Copyright (c) 2014, ARM Limited. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the BSD License +* which accompanies this distribution. The full text of the license may be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +* +**/ + +#ifndef __HOSTNAME_GUID_H__ +#define __HOSTNAME_GUID_H__ + +/* + This Variable guid is used for the UEFI variable named "Hostname". + A use case for this is Ip4ConfigDxe sending a hostname during the DHCP DORA + process. A future version of the UEFI spec might include this variable in + the list of globally defined variables. In this case this GUID would become + redundant and gEfiGlobalVariableGuid could be used instead. +*/ +extern EFI_GUID gEfiHostnameVariableGuid; + +#endif diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 9084af7..fbc144c 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -180,6 +180,10 @@ ## Include/Guid/NicIp4ConfigNvData.h gEfiNicIp4ConfigVariableGuid = {0xd8944553, 0xc4dd, 0x41f4, { 0x9b, 0x30, 0xe1, 0x39, 0x7c, 0xfb, 0x26, 0x7b }} + ## GUID for variable to save hostname + # Include/Guid/Hostname.h + gEfiHostnameVariableGuid = {0x0CA6824E, 0x989A, 0x11E3, { 0x84, 0xF9, 0x47, 0x67, 0x26, 0x2D, 0x11, 0xE1 }} + ## Include/Guid/StatusCodeCallbackGuid.h gStatusCodeCallbackGuid = {0xe701458c, 0x4900, 0x4ca5, {0xb7, 0x72, 0x3d, 0x37, 0x94, 0x9f, 0x79, 0x27}} diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c index 3eff188..be08fce 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c @@ -15,6 +15,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "Ip4Config.h" #include "NicIp4Variable.h" +#include + // // Ip4 Config Protocol // @@ -327,11 +329,14 @@ EfiIp4ConfigStart ( IP4_CONFIG_INSTANCE *Instance; EFI_DHCP4_PROTOCOL *Dhcp4; EFI_DHCP4_MODE_DATA Dhcp4Mode; - EFI_DHCP4_PACKET_OPTION *OptionList[1]; + EFI_DHCP4_PACKET_OPTION *OptionList[2]; IP4_CONFIG_DHCP4_OPTION ParaList; EFI_STATUS Status; UINT32 Source; EFI_TPL OldTpl; + CHAR8 Hostname[256]; + UINTN HostnameSize = 256; + EFI_DHCP4_PACKET_OPTION *HostnameOption = NULL; if ((This == NULL) || (DoneEvent == NULL) || (ReconfigEvent == NULL)) { return EFI_INVALID_PARAMETER; @@ -436,8 +441,36 @@ EfiIp4ConfigStart ( Dhcp4Mode.ConfigData.OptionCount = 1; Dhcp4Mode.ConfigData.OptionList = OptionList; + Status = gRT->GetVariable ( + L"Hostname", + &gEfiHostnameVariableGuid, + NULL, + &HostnameSize, + &Hostname + ); + if (!EFI_ERROR (Status) && HostnameSize != 0) { + Dhcp4Mode.ConfigData.OptionCount = 2; + + HostnameOption = AllocatePool ( + sizeof (EFI_DHCP4_PACKET_OPTION) - 1 + HostnameSize + ); + if (HostnameOption == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + HostnameOption->OpCode = DHCP_TAG_HOSTNAME; + HostnameOption->Length = (UINT8) HostnameSize; + CopyMem (HostnameOption->Data, Hostname, HostnameOption->Length); + + OptionList[1] = HostnameOption; + } + Status = Dhcp4->Configure (Dhcp4, &Dhcp4Mode.ConfigData); + if (HostnameOption) { + FreePool (HostnameOption); + } + if (EFI_ERROR (Status)) { goto ON_ERROR; } diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h index cbe8ec5..4498814 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h @@ -59,6 +59,7 @@ extern EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate; #define IP4_CONFIG_STATE_STARTED 1 #define IP4_CONFIG_STATE_CONFIGURED 2 +#define DHCP_TAG_HOSTNAME 12 #define DHCP_TAG_PARA_LIST 55 #define DHCP_TAG_NETMASK 1 #define DHCP_TAG_ROUTER 3 diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf index 83133d6..86d7002 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf @@ -67,4 +67,5 @@ [Guids] gEfiNicIp4ConfigVariableGuid ## CONSUMES ## Guid + gEfiHostnameVariableGuid ## CONSUMES ## Guid gNicIp4ConfigNvDataGuid ## PRODUCES ## Guid