From nobody Mon Apr 29 07:18:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+78283+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+78283+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1627473503; cv=none; d=zohomail.com; s=zohoarc; b=TYVapp+Ms4WYw8WyGLqipxZKxhmSmImJTyDJGMIxrEWkMhDMIGfu7Da45IxTV6cMsVIFuAMsDQQa6TUSD70l8uy8fq+NIoCK63iChBb+6B2EkV0gS4QeDhL6SjOL3I8PZrXeoKil5KEDfWitIF3xg1rj3PAYBac0U/49FrgN6Zc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627473503; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=pWV0XOaYqySuJpATkpmOIR/t+dyKvAJLf+a8DBGqkqw=; b=HcCCkiyVmuxWzSLGxDXu2Y27zIk3RBP29DntZsq5C30yW0tLhZaLwk6EfBT4QnSl+HvG3cSz7fo8Fql6kUOCnW53hPdFViwadMVyvzo1H/T9aZ4+JffR8pWDNVyD6vMYSBzu+Bja9uoG4a5LaqRhda9JsWsmFkN69Hp1+nj+E3w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+78283+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1627473502984868.6106303036747; Wed, 28 Jul 2021 04:58:22 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id VxS5YY1788612xXDoyyWMrlQ; Wed, 28 Jul 2021 04:58:22 -0700 X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web12.3810.1627473502026789916 for ; Wed, 28 Jul 2021 04:58:22 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10058"; a="273727584" X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="273727584" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 04:58:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="475727206" X-Received: from hengluo-dev.ccr.corp.intel.com ([10.239.153.158]) by fmsmga008.fm.intel.com with ESMTP; 28 Jul 2021 04:58:18 -0700 From: "Heng Luo" To: devel@edk2.groups.io Cc: Maciej Rabeda , Jiaxin Wu , Siyuan Fu Subject: [edk2-devel] [Patch V3] NetworkPkg: Add HTTP Additional Event Notifications Date: Wed, 28 Jul 2021 19:58:05 +0800 Message-Id: <20210728115805.2218-1-heng.luo@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,heng.luo@intel.com X-Gm-Message-State: FJu35XYfnr97l79Zq4bRaz5bx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1627473502; bh=5Lme9KerfWwtpxHb+xzkiqBN3w1Esf8CVEK03w5MHX0=; h=Cc:Date:From:Reply-To:Subject:To; b=YGITTJc9Vu4tF95KblKjRtqLyt234kdOb6pCLob7EDtHwGSJLABBVF9njYq5+MGnVuh 0vD1+lr5e2O9v+juiXPV9IhE35RADsa3erchNqTOd49RZCLmXupsO7OtLIZl5JgpsfuB+ 1Qxz+1Q3mMmRCdCAef5q42K/hAM+4R+ubIg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1627473504427100002 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3496 Add new EDKII_HTTP_CALLBACK_PROTOCOL in NetworkPkg, Send HTTP Events via EDKII_HTTP_CALLBACK_PROTOCOL when Dns/ConnectTcp/TlsConnectSession/InitSession occurs. Signed-off-by: Heng Luo Cc: Maciej Rabeda Cc: Jiaxin Wu Cc: Siyuan Fu Reviewed-by: Maciej Rabeda --- NetworkPkg/HttpDxe/HttpDriver.h | 3 ++- NetworkPkg/HttpDxe/HttpDxe.inf | 3 ++- NetworkPkg/HttpDxe/HttpImpl.c | 4 +++- NetworkPkg/HttpDxe/HttpProto.c | 58 ++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++- NetworkPkg/HttpDxe/HttpProto.h | 15 ++++++++++++++- NetworkPkg/Include/Protocol/HttpCallback.h | 85 ++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ NetworkPkg/NetworkPkg.dec | 3 +++ 7 files changed, 166 insertions(+), 5 deletions(-) diff --git a/NetworkPkg/HttpDxe/HttpDriver.h b/NetworkPkg/HttpDxe/HttpDrive= r.h index 5fe8c5b5e9..b701b80858 100644 --- a/NetworkPkg/HttpDxe/HttpDriver.h +++ b/NetworkPkg/HttpDxe/HttpDriver.h @@ -1,7 +1,7 @@ /** @file The header files of the driver binding and service binding protocol for = HttpDxe driver. =20 - Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -47,6 +47,7 @@ #include #include #include +#include =20 #include // diff --git a/NetworkPkg/HttpDxe/HttpDxe.inf b/NetworkPkg/HttpDxe/HttpDxe.inf index 35fe31af18..23fb9ec394 100644 --- a/NetworkPkg/HttpDxe/HttpDxe.inf +++ b/NetworkPkg/HttpDxe/HttpDxe.inf @@ -1,7 +1,7 @@ ## @file # Implementation of EFI HTTP protocol interfaces. # -# Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -65,6 +65,7 @@ gEfiTlsServiceBindingProtocolGuid ## SOMETIMES_CONSUMES gEfiTlsProtocolGuid ## SOMETIMES_CONSUMES gEfiTlsConfigurationProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiHttpCallbackProtocolGuid ## SOMETIMES_CONSUMES =20 [Guids] gEfiTlsCaCertificateGuid ## SOMETIMES_CONSUMES = ## Variable:L"TlsCaCertificate" diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index 5a6ecbc9d9..97f15d229f 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -1,7 +1,7 @@ /** @file Implementation of EFI_HTTP_PROTOCOL protocol interfaces. =20 - Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -527,6 +527,7 @@ EfiHttpRequest ( } else { Status =3D HttpDns6 (HttpInstance, HostNameStr, &HttpInstance->Rem= oteIpv6Addr); } + HttpNotify (HttpEventDns, Status); =20 FreePool (HostNameStr); if (EFI_ERROR (Status)) { @@ -588,6 +589,7 @@ EfiHttpRequest ( Configure || ReConfigure, TlsConfigure ); + HttpNotify (HttpEventInitSession, Status); if (EFI_ERROR (Status)) { goto Error2; } diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c index afc7db5a72..affa916bd6 100644 --- a/NetworkPkg/HttpDxe/HttpProto.c +++ b/NetworkPkg/HttpDxe/HttpProto.c @@ -1,7 +1,7 @@ /** @file Miscellaneous routines for HttpDxe driver. =20 -Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -966,6 +966,7 @@ HttpCreateConnection ( HttpInstance->IsTcp4ConnDone =3D FALSE; HttpInstance->Tcp4ConnToken.CompletionToken.Status =3D EFI_NOT_READY; Status =3D HttpInstance->Tcp4->Connect (HttpInstance->Tcp4, &HttpInsta= nce->Tcp4ConnToken); + HttpNotify (HttpEventConnectTcp, Status); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "HttpCreateConnection: Tcp4->Connect() =3D %r\n= ", Status)); return Status; @@ -981,6 +982,7 @@ HttpCreateConnection ( HttpInstance->IsTcp6ConnDone =3D FALSE; HttpInstance->Tcp6ConnToken.CompletionToken.Status =3D EFI_NOT_READY; Status =3D HttpInstance->Tcp6->Connect (HttpInstance->Tcp6, &HttpInsta= nce->Tcp6ConnToken); + HttpNotify (HttpEventConnectTcp, Status); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "HttpCreateConnection: Tcp6->Connect() =3D %r\n= ", Status)); return Status; @@ -1277,6 +1279,7 @@ HttpConnectTcp4 ( } =20 Status =3D TlsConnectSession (HttpInstance, HttpInstance->TimeoutEvent= ); + HttpNotify (HttpEventTlsConnectSession, Status); =20 gBS->SetTimer (HttpInstance->TimeoutEvent, TimerCancel, 0); =20 @@ -1369,6 +1372,7 @@ HttpConnectTcp6 ( } =20 Status =3D TlsConnectSession (HttpInstance, HttpInstance->TimeoutEvent= ); + HttpNotify (HttpEventTlsConnectSession, Status); =20 gBS->SetTimer (HttpInstance->TimeoutEvent, TimerCancel, 0); =20 @@ -2195,3 +2199,55 @@ HttpTcpTokenCleanup ( } =20 } + +/** + Send Events via EDKII_HTTP_CALLBACK_PROTOCOL. + + @param[in] Event The event that occurs in the current sta= te. + @param[in] EventStatus The Status of Event, EFI_SUCCESS or othe= r errors. + +**/ +VOID +HttpNotify ( + IN EDKII_HTTP_CALLBACK_EVENT Event, + IN EFI_STATUS EventStatus + ) +{ + EFI_STATUS Status; + EFI_HANDLE *Handles; + UINTN Index; + UINTN HandleCount; + EFI_HANDLE Handle; + EDKII_HTTP_CALLBACK_PROTOCOL *HttpCallback; + + DEBUG ((DEBUG_INFO, "HttpNotify: Event - %d, EventStatus - %r\n", Event,= EventStatus)); + + Handles =3D NULL; + HandleCount =3D 0; + Status =3D gBS->LocateHandleBuffer ( + ByProtocol, + &gEdkiiHttpCallbackProtocolGuid, + NULL, + &HandleCount, + &Handles + ); + if (Status =3D=3D EFI_SUCCESS) { + for (Index =3D 0; Index < HandleCount; Index++) { + Handle =3D Handles[Index]; + Status =3D gBS->HandleProtocol ( + Handle, + &gEdkiiHttpCallbackProtocolGuid, + (VOID **) &HttpCallback + ); + if (Status =3D=3D EFI_SUCCESS) { + DEBUG ((DEBUG_INFO, "HttpNotify: Notifying %p\n", HttpCallback)); + HttpCallback->Callback ( + HttpCallback, + Event, + EventStatus + ); + } + } + FreePool (Handles); + } +} diff --git a/NetworkPkg/HttpDxe/HttpProto.h b/NetworkPkg/HttpDxe/HttpProto.h index 00ba26aca4..5b90a6b074 100644 --- a/NetworkPkg/HttpDxe/HttpProto.h +++ b/NetworkPkg/HttpDxe/HttpProto.h @@ -1,7 +1,7 @@ /** @file The header files of miscellaneous routines for HttpDxe driver. =20 -Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -609,4 +609,17 @@ HttpResponseWorker ( IN HTTP_TOKEN_WRAP *Wrap ); =20 +/** + Send Events via EDKII_HTTP_CALLBACK_PROTOCOL. + + @param[in] Event The event that occurs in the current sta= te. + @param[in] EventStatus The Status of Event, EFI_SUCCESS or othe= r errors. + +**/ +VOID +HttpNotify ( + IN EDKII_HTTP_CALLBACK_EVENT Event, + IN EFI_STATUS EventStatus + ); + #endif diff --git a/NetworkPkg/Include/Protocol/HttpCallback.h b/NetworkPkg/Includ= e/Protocol/HttpCallback.h new file mode 100644 index 0000000000..d036a8a4be --- /dev/null +++ b/NetworkPkg/Include/Protocol/HttpCallback.h @@ -0,0 +1,85 @@ +/** @file + This file defines the EDKII HTTP Callback Protocol interface. + + Copyright (c) 2021, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef __EDKII_HTTP_CALLBACK_H__ +#define __EDKII_HTTP_CALLBACK_H__ + +#define EDKII_HTTP_CALLBACK_PROTOCOL_GUID \ + { \ + 0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2,= 0x40} \ + } + +typedef struct _EDKII_HTTP_CALLBACK_PROTOCOL EDKII_HTTP_CALLBACK_PROTOCOL; + +/// +/// EDKII_HTTP_CALLBACK_EVENT +/// +typedef enum { + /// + /// The Status of DNS Event to retrieve the host address. + /// EventStatus: + /// EFI_SUCCESS Operation succeeded. + /// EFI_OUT_OF_RESOURCES Failed to allocate needed resources. + /// EFI_DEVICE_ERROR An unexpected network error occurred. + /// Others Other errors as indicated. + /// + HttpEventDns, + + /// + /// The Status of Event to initiate a nonblocking TCP connection request. + /// EventStatus: + /// EFI_SUCCESS The connection request is successfully initia= ted. + /// EFI_NOT_STARTED This EFI TCP Protocol instance has not been c= onfigured. + /// EFI_DEVICE_ERROR An unexpected system or network error occurre= d. + /// Others Other errors as indicated. + /// + HttpEventConnectTcp, + + /// + /// The Status of Event to connect one TLS session by finishing the TLS = handshake process. + /// EventStatus: + /// EFI_SUCCESS The TLS session is established. + /// EFI_OUT_OF_RESOURCES Can't allocate memory resources. + /// EFI_ABORTED TLS session state is incorrect. + /// Others Other error as indicated. + /// + HttpEventTlsConnectSession, + + /// + /// The Status of Event to initialize Http session + /// EventStatus: + /// EFI_SUCCESS The initialization of session is done. + /// Others Other error as indicated. + /// + HttpEventInitSession +} EDKII_HTTP_CALLBACK_EVENT; + +/** + Callback function that is invoked when HTTP event occurs. + + @param[in] This Pointer to the EDKII_HTTP_CALLBACK_PROTO= COL instance. + @param[in] Event The event that occurs in the current sta= te. + @param[in] EventStatus The Status of Event, EFI_SUCCESS or othe= r errors. +**/ +typedef +VOID +(EFIAPI * EDKII_HTTP_CALLBACK) ( + IN EDKII_HTTP_CALLBACK_PROTOCOL *This, + IN EDKII_HTTP_CALLBACK_EVENT Event, + IN EFI_STATUS EventStatus + ); + +/// +/// EFI HTTP Callback Protocol is invoked when HTTP event occurs. +/// +struct _EDKII_HTTP_CALLBACK_PROTOCOL { + EDKII_HTTP_CALLBACK Callback; +}; + +extern EFI_GUID gEdkiiHttpCallbackProtocolGuid; + +#endif diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec index b81f10ef6e..0f9f7bb15e 100644 --- a/NetworkPkg/NetworkPkg.dec +++ b/NetworkPkg/NetworkPkg.dec @@ -88,6 +88,9 @@ ## Include/Protocol/Dpc.h gEfiDpcProtocolGuid =3D {0x480f8ae9, 0xc46, 0x4aa9, { 0xbc, 0= x89, 0xdb, 0x9f, 0xba, 0x61, 0x98, 0x6 }} =20 + ## Include/Protocol/HttpCallback.h + gEdkiiHttpCallbackProtocolGuid =3D {0x611114f1, 0xa37b, 0x4468, {0xa4, = 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}} + [PcdsFixedAtBuild] ## The max attempt number will be created by iSCSI driver. # @Prompt Max attempt number. --=20 2.31.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#78283): https://edk2.groups.io/g/devel/message/78283 Mute This Topic: https://groups.io/mt/84503285/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-