2 Implementation of Redfish EFI_REST_EX_PROTOCOL interfaces.
4 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include "RedfishRestExInternal.h"
13 EFI_REST_EX_PROTOCOL mRedfishRestExProtocol
= {
14 RedfishRestExSendReceive
,
15 RedfishRestExGetServiceTime
,
16 RedfishRestExGetService
,
17 RedfishRestExGetModeData
,
18 RedfishRestExConfigure
,
19 RedfishRestExAyncSendReceive
,
20 RedfishRestExEventService
24 Provides a simple HTTP-like interface to send and receive resources from a REST service.
26 The SendReceive() function sends an HTTP request to this REST service, and returns a
27 response when the data is retrieved from the service. RequestMessage contains the HTTP
28 request to the REST resource identified by RequestMessage.Request.Url. The
29 ResponseMessage is the returned HTTP response for that request, including any HTTP
32 @param[in] This Pointer to EFI_REST_EX_PROTOCOL instance for a particular
34 @param[in] RequestMessage Pointer to the HTTP request data for this resource
35 @param[out] ResponseMessage Pointer to the HTTP response data obtained for this requested.
37 @retval EFI_SUCCESS operation succeeded.
38 @retval EFI_INVALID_PARAMETER This, RequestMessage, or ResponseMessage are NULL.
39 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
40 @retval EFI_ACCESS_DENIED HTTP method is not allowed on this URL.
41 @retval EFI_BAD_BUFFER_SIZE The payload is to large to be handled on server side.
42 @retval EFI_UNSUPPORTED Unsupported HTTP response.
47 RedfishRestExSendReceive (
48 IN EFI_REST_EX_PROTOCOL
*This
,
49 IN EFI_HTTP_MESSAGE
*RequestMessage
,
50 OUT EFI_HTTP_MESSAGE
*ResponseMessage
54 RESTEX_INSTANCE
*Instance
;
55 HTTP_IO_RESPONSE_DATA
*ResponseData
;
56 UINTN TotalReceivedSize
;
58 LIST_ENTRY
*ChunkListLink
;
59 HTTP_IO_CHUNKS
*ThisChunk
;
60 BOOLEAN CopyChunkData
;
62 EFI_HTTP_HEADER
*PreservedRequestHeaders
;
64 BOOLEAN IsGetChunkedTransfer
;
65 HTTP_IO_SEND_CHUNK_PROCESS SendChunkProcess
;
66 HTTP_IO_SEND_NON_CHUNK_PROCESS SendNonChunkProcess
;
67 EFI_HTTP_MESSAGE ChunkTransferRequestMessage
;
71 IsGetChunkedTransfer
= FALSE
;
72 SendChunkProcess
= HttpIoSendChunkNone
;
73 SendNonChunkProcess
= HttpIoSendNonChunkNone
;
76 // Validate the parameters
78 if ((This
== NULL
) || (RequestMessage
== NULL
) || (ResponseMessage
== NULL
)) {
79 return EFI_INVALID_PARAMETER
;
82 Instance
= RESTEX_INSTANCE_FROM_THIS (This
);
85 // Check Media Status.
88 NetLibDetectMedia (Instance
->Service
->ControllerHandle
, &MediaPresent
);
90 DEBUG ((DEBUG_INFO
, "RedfishRestExSendReceive(): No MediaPresent.\n"));
94 DEBUG ((DEBUG_INFO
, "\nRedfishRestExSendReceive():\n"));
95 DEBUG ((DEBUG_INFO
, "*** Perform HTTP Request Method - %d, URL: %s\n", RequestMessage
->Data
.Request
->Method
, RequestMessage
->Data
.Request
->Url
));
98 // Add header "Expect" to server, only for URL write.
100 Status
= RedfishHttpAddExpectation (This
, RequestMessage
, &PreservedRequestHeaders
, &ItsWrite
);
101 if (EFI_ERROR (Status
)) {
105 if (ItsWrite
== TRUE
) {
106 if (RequestMessage
->BodyLength
> HTTP_IO_MAX_SEND_PAYLOAD
) {
108 // Send chunked transfer.
111 CopyMem ((VOID
*)&ChunkTransferRequestMessage
, (VOID
*)RequestMessage
, sizeof (EFI_HTTP_MESSAGE
));
113 SendNonChunkProcess
++;
119 // Send out the request to REST service.
121 if (ItsWrite
== TRUE
) {
123 // This is write to URI
125 if (SendChunkProcess
> HttpIoSendChunkNone
) {
127 // This is chunk transfer for writing large payload.
128 // Send request header first and then handle the
129 // following request message body using chunk transfer.
132 Status
= HttpIoSendChunkedTransfer (
135 &ChunkTransferRequestMessage
137 if (EFI_ERROR (Status
)) {
140 } while (SendChunkProcess
== HttpIoSendChunkContent
|| SendChunkProcess
== HttpIoSendChunkEndChunk
);
143 // This is the non-chunk transfer, send request header first and then
144 // handle the following request message body using chunk transfer.
146 Status
= HttpIoSendRequest (
148 (SendNonChunkProcess
== HttpIoSendNonChunkContent
) ? NULL
: RequestMessage
->Data
.Request
,
149 (SendNonChunkProcess
== HttpIoSendNonChunkContent
) ? 0 : RequestMessage
->HeaderCount
,
150 (SendNonChunkProcess
== HttpIoSendNonChunkContent
) ? NULL
: RequestMessage
->Headers
,
151 (SendNonChunkProcess
== HttpIoSendNonChunkHeaderZeroContent
) ? 0 : RequestMessage
->BodyLength
,
152 (SendNonChunkProcess
== HttpIoSendNonChunkHeaderZeroContent
) ? NULL
: RequestMessage
->Body
157 // This is read from URI.
159 Status
= HttpIoSendRequest (
161 RequestMessage
->Data
.Request
,
162 RequestMessage
->HeaderCount
,
163 RequestMessage
->Headers
,
164 RequestMessage
->BodyLength
,
169 if (EFI_ERROR (Status
)) {
174 // ResponseMessage->Data.Response is to indicate whether to receive the HTTP header or not.
175 // ResponseMessage->BodyLength/ResponseMessage->Body are to indicate whether to receive the response body or not.
176 // Clean the previous buffers and all of them will be allocated later according to the actual situation.
178 if (ResponseMessage
->Data
.Response
!= NULL
) {
179 FreePool (ResponseMessage
->Data
.Response
);
180 ResponseMessage
->Data
.Response
= NULL
;
183 ResponseMessage
->BodyLength
= 0;
184 if (ResponseMessage
->Body
!= NULL
) {
185 FreePool (ResponseMessage
->Body
);
186 ResponseMessage
->Body
= NULL
;
190 // Use zero BodyLength to only receive the response headers.
192 ResponseData
= AllocateZeroPool (sizeof (HTTP_IO_RESPONSE_DATA
));
193 if (ResponseData
== NULL
) {
194 Status
= EFI_OUT_OF_RESOURCES
;
198 DEBUG ((DEBUG_INFO
, "Receiving HTTP response and headers...\n"));
199 Status
= RedfishCheckHttpReceiveStatus (
207 if (Status
== EFI_NOT_READY
) {
209 } else if (Status
== EFI_DEVICE_ERROR
) {
214 // Restore the headers if it ever changed in RedfishHttpAddExpectation().
216 if (RequestMessage
->Headers
!= PreservedRequestHeaders
) {
217 FreePool (RequestMessage
->Headers
);
218 RequestMessage
->Headers
= PreservedRequestHeaders
; // Restore headers before we adding "Expect".
219 RequestMessage
->HeaderCount
--; // Minus one header count for "Expect".
222 DEBUG ((DEBUG_INFO
, "HTTP Response StatusCode - %d:", ResponseData
->Response
.StatusCode
));
223 if (ResponseData
->Response
.StatusCode
== HTTP_STATUS_200_OK
) {
224 DEBUG ((DEBUG_INFO
, "HTTP_STATUS_200_OK\n"));
226 if (SendChunkProcess
== HttpIoSendChunkHeaderZeroContent
) {
227 DEBUG ((DEBUG_INFO
, "This is chunk transfer, start to send all chunks."));
231 } else if (ResponseData
->Response
.StatusCode
== HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE
) {
232 DEBUG ((DEBUG_INFO
, "HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE\n"));
234 Status
= EFI_BAD_BUFFER_SIZE
;
236 } else if (ResponseData
->Response
.StatusCode
== HTTP_STATUS_405_METHOD_NOT_ALLOWED
) {
237 DEBUG ((DEBUG_ERROR
, "HTTP_STATUS_405_METHOD_NOT_ALLOWED\n"));
239 Status
= EFI_ACCESS_DENIED
;
241 } else if (ResponseData
->Response
.StatusCode
== HTTP_STATUS_400_BAD_REQUEST
) {
242 DEBUG ((DEBUG_INFO
, "HTTP_STATUS_400_BAD_REQUEST\n"));
243 if (SendChunkProcess
== HttpIoSendChunkHeaderZeroContent
) {
244 DEBUG ((DEBUG_INFO
, "Bad request may caused by zero length chunk. Try to send all chunks...\n"));
248 } else if (ResponseData
->Response
.StatusCode
== HTTP_STATUS_100_CONTINUE
) {
249 DEBUG ((DEBUG_INFO
, "HTTP_STATUS_100_CONTINUE\n"));
250 if (SendChunkProcess
== HttpIoSendChunkHeaderZeroContent
) {
252 // We get HTTP_STATUS_100_CONTINUE to send the body using chunk transfer.
254 DEBUG ((DEBUG_INFO
, "HTTP_STATUS_100_CONTINUE for chunk transfer...\n"));
259 if (SendNonChunkProcess
== HttpIoSendNonChunkHeaderZeroContent
) {
260 DEBUG ((DEBUG_INFO
, "HTTP_STATUS_100_CONTINUE for non chunk transfer...\n"));
261 SendNonChunkProcess
++;
266 // It's the REST protocol's responsibility to handle the interim HTTP response (e.g. 100 Continue Informational),
267 // and return the final response content to the caller.
269 if ((ResponseData
->Headers
!= NULL
) && (ResponseData
->HeaderCount
!= 0)) {
270 FreePool (ResponseData
->Headers
);
273 ZeroMem (ResponseData
, sizeof (HTTP_IO_RESPONSE_DATA
));
274 Status
= HttpIoRecvResponse (
279 if (EFI_ERROR (Status
)) {
283 DEBUG ((DEBUG_ERROR
, "This HTTP Status is not handled!\n"));
284 Status
= EFI_UNSUPPORTED
;
289 // Ready to return the StatusCode, Header info and BodyLength.
291 ResponseMessage
->Data
.Response
= AllocateZeroPool (sizeof (EFI_HTTP_RESPONSE_DATA
));
292 if (ResponseMessage
->Data
.Response
== NULL
) {
293 Status
= EFI_OUT_OF_RESOURCES
;
297 ResponseMessage
->Data
.Response
->StatusCode
= ResponseData
->Response
.StatusCode
;
298 ResponseMessage
->HeaderCount
= ResponseData
->HeaderCount
;
299 ResponseMessage
->Headers
= ResponseData
->Headers
;
302 // Get response message body.
304 if (ResponseMessage
->HeaderCount
> 0) {
305 Status
= HttpIoGetContentLength (ResponseMessage
->HeaderCount
, ResponseMessage
->Headers
, &ResponseMessage
->BodyLength
);
306 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
310 if (Status
== EFI_NOT_FOUND
) {
311 ASSERT (ResponseMessage
->BodyLength
== 0);
314 if (ResponseMessage
->BodyLength
== 0) {
316 // Check if Chunked Transfer Coding.
318 Status
= HttpIoGetChunkedTransferContent (
320 ResponseMessage
->HeaderCount
,
321 ResponseMessage
->Headers
,
323 &ResponseMessage
->BodyLength
325 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
329 if ((Status
== EFI_SUCCESS
) &&
330 (ChunkListLink
!= NULL
) &&
331 !IsListEmpty (ChunkListLink
) &&
332 (ResponseMessage
->BodyLength
!= 0))
334 IsGetChunkedTransfer
= TRUE
;
336 // Copy data to Message body.
338 CopyChunkData
= TRUE
;
339 ResponseMessage
->Body
= AllocateZeroPool (ResponseMessage
->BodyLength
);
340 if (ResponseMessage
->Body
== NULL
) {
341 Status
= EFI_OUT_OF_RESOURCES
;
342 CopyChunkData
= FALSE
;
346 while (!IsListEmpty (ChunkListLink
)) {
347 ThisChunk
= (HTTP_IO_CHUNKS
*)GetFirstNode (ChunkListLink
);
349 CopyMem (((UINT8
*)ResponseMessage
->Body
+ Index
), (UINT8
*)ThisChunk
->Data
, ThisChunk
->Length
);
350 Index
+= ThisChunk
->Length
;
353 RemoveEntryList (&ThisChunk
->NextChunk
);
354 FreePool ((VOID
*)ThisChunk
->Data
);
355 FreePool ((VOID
*)ThisChunk
);
358 FreePool ((VOID
*)ChunkListLink
);
362 Status
= EFI_SUCCESS
;
366 // Ready to return the Body from REST service if have any.
368 if ((ResponseMessage
->BodyLength
> 0) && !IsGetChunkedTransfer
) {
369 ResponseData
->HeaderCount
= 0;
370 ResponseData
->Headers
= NULL
;
372 ResponseMessage
->Body
= AllocateZeroPool (ResponseMessage
->BodyLength
);
373 if (ResponseMessage
->Body
== NULL
) {
374 Status
= EFI_OUT_OF_RESOURCES
;
379 // Only receive the Body.
381 TotalReceivedSize
= 0;
382 while (TotalReceivedSize
< ResponseMessage
->BodyLength
) {
383 ResponseData
->BodyLength
= ResponseMessage
->BodyLength
- TotalReceivedSize
;
384 ResponseData
->Body
= (CHAR8
*)ResponseMessage
->Body
+ TotalReceivedSize
;
385 Status
= HttpIoRecvResponse (
390 if (EFI_ERROR (Status
)) {
394 TotalReceivedSize
+= ResponseData
->BodyLength
;
397 DEBUG ((DEBUG_INFO
, "Total of lengh of Response :%d\n", TotalReceivedSize
));
400 DEBUG ((DEBUG_INFO
, "RedfishRestExSendReceive()- EFI_STATUS: %r\n", Status
));
404 if (ResponseData
!= NULL
) {
405 FreePool (ResponseData
);
408 if (EFI_ERROR (Status
)) {
409 if (ResponseMessage
->Data
.Response
!= NULL
) {
410 FreePool (ResponseMessage
->Data
.Response
);
411 ResponseMessage
->Data
.Response
= NULL
;
414 if (ResponseMessage
->Body
!= NULL
) {
415 FreePool (ResponseMessage
->Body
);
416 ResponseMessage
->Body
= NULL
;
424 Obtain the current time from this REST service instance.
426 The GetServiceTime() function is an optional interface to obtain the current time from
427 this REST service instance. If this REST service does not support to retrieve the time,
428 this function returns EFI_UNSUPPORTED. This function must returns EFI_UNSUPPORTED if
429 EFI_REST_EX_SERVICE_TYPE returned in EFI_REST_EX_SERVICE_INFO from GetService() is
430 EFI_REST_EX_SERVICE_UNSPECIFIC.
432 @param[in] This Pointer to EFI_REST_EX_PROTOCOL instance for a particular
434 @param[out] Time A pointer to storage to receive a snapshot of the current time of
437 @retval EFI_SUCCESS operation succeeded.
438 @retval EFI_INVALID_PARAMETER This or Time are NULL.
439 @retval EFI_UNSUPPORTED The RESTful service does not support returning the time.
440 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
441 @retval EFI_NOT_READY The configuration of this instance is not set yet. Configure() must
442 be executed and returns successfully prior to invoke this function.
447 RedfishRestExGetServiceTime (
448 IN EFI_REST_EX_PROTOCOL
*This
,
452 return EFI_UNSUPPORTED
;
456 This function returns the information of REST service provided by this EFI REST EX driver instance.
458 The information such as the type of REST service and the access mode of REST EX driver instance
459 (In-band or Out-of-band) are described in EFI_REST_EX_SERVICE_INFO structure. For the vendor-specific
460 REST service, vendor-specific REST service information is returned in VendorSpecifcData.
461 REST EX driver designer is well know what REST service this REST EX driver instance intends to
462 communicate with. The designer also well know this driver instance is used to talk to BMC through
463 specific platform mechanism or talk to REST server through UEFI HTTP protocol. REST EX driver is
464 responsible to fill up the correct information in EFI_REST_EX_SERVICE_INFO. EFI_REST_EX_SERVICE_INFO
465 is referred by EFI REST clients to pickup the proper EFI REST EX driver instance to get and set resource.
466 GetService() is a basic and mandatory function which must be able to use even Configure() is not invoked
469 @param[in] This Pointer to EFI_REST_EX_PROTOCOL instance for a particular
471 @param[out] RestExServiceInfo Pointer to receive a pointer to EFI_REST_EX_SERVICE_INFO structure. The
472 format of EFI_REST_EX_SERVICE_INFO is version controlled for the future
473 extension. The version of EFI_REST_EX_SERVICE_INFO structure is returned
474 in the header within this structure. EFI REST client refers to the correct
475 format of structure according to the version number. The pointer to
476 EFI_REST_EX_SERVICE_INFO is a memory block allocated by EFI REST EX driver
477 instance. That is caller's responsibility to free this memory when this
478 structure is no longer needed. Refer to Related Definitions below for the
479 definitions of EFI_REST_EX_SERVICE_INFO structure.
481 @retval EFI_SUCCESS EFI_REST_EX_SERVICE_INFO is returned in RestExServiceInfo. This function
482 is not supported in this REST EX Protocol driver instance.
483 @retval EFI_UNSUPPORTED This function is not supported in this REST EX Protocol driver instance.
488 RedfishRestExGetService (
489 IN EFI_REST_EX_PROTOCOL
*This
,
490 OUT EFI_REST_EX_SERVICE_INFO
**RestExServiceInfo
494 RESTEX_INSTANCE
*Instance
;
495 EFI_REST_EX_SERVICE_INFO
*ServiceInfo
;
499 if ((This
== NULL
) || (RestExServiceInfo
== NULL
)) {
500 return EFI_INVALID_PARAMETER
;
503 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
505 Instance
= RESTEX_INSTANCE_FROM_THIS (This
);
507 ServiceInfo
= AllocateZeroPool (sizeof (EFI_REST_EX_SERVICE_INFO
));
508 if (ServiceInfo
== NULL
) {
509 return EFI_OUT_OF_RESOURCES
;
512 CopyMem (ServiceInfo
, &(Instance
->Service
->RestExServiceInfo
), sizeof (EFI_REST_EX_SERVICE_INFO
));
514 *RestExServiceInfo
= ServiceInfo
;
516 gBS
->RestoreTPL (OldTpl
);
522 This function returns operational configuration of current EFI REST EX child instance.
524 This function returns the current configuration of EFI REST EX child instance. The format of
525 operational configuration depends on the implementation of EFI REST EX driver instance. For
526 example, HTTP-aware EFI REST EX driver instance uses EFI HTTP protocol as the undying protocol
527 to communicate with REST service. In this case, the type of configuration is
528 EFI_REST_EX_CONFIG_TYPE_HTTP returned from GetService(). EFI_HTTP_CONFIG_DATA is used as EFI REST
529 EX configuration format and returned to EFI REST client. User has to type cast RestExConfigData
530 to EFI_HTTP_CONFIG_DATA. For those non HTTP-aware REST EX driver instances, the type of configuration
531 is EFI_REST_EX_CONFIG_TYPE_UNSPECIFIC returned from GetService(). In this case, the format of
532 returning data could be non industrial. Instead, the format of configuration data is system/platform
533 specific definition such as BMC mechanism used in EFI REST EX driver instance. EFI REST client and
534 EFI REST EX driver instance have to refer to the specific system /platform spec which is out of UEFI scope.
536 @param[in] This This is the EFI_REST_EX_PROTOCOL instance.
537 @param[out] RestExConfigData Pointer to receive a pointer to EFI_REST_EX_CONFIG_DATA.
538 The memory allocated for configuration data should be freed
539 by caller. See Related Definitions for the details.
541 @retval EFI_SUCCESS EFI_REST_EX_CONFIG_DATA is returned in successfully.
542 @retval EFI_UNSUPPORTED This function is not supported in this REST EX Protocol driver instance.
543 @retval EFI_NOT_READY The configuration of this instance is not set yet. Configure() must be
544 executed and returns successfully prior to invoke this function.
549 RedfishRestExGetModeData (
550 IN EFI_REST_EX_PROTOCOL
*This
,
551 OUT EFI_REST_EX_CONFIG_DATA
*RestExConfigData
554 return EFI_UNSUPPORTED
;
558 This function is used to configure EFI REST EX child instance.
560 This function is used to configure the setting of underlying protocol of REST EX child
561 instance. The type of configuration is according to the implementation of EFI REST EX
562 driver instance. For example, HTTP-aware EFI REST EX driver instance uses EFI HTTP protocol
563 as the undying protocol to communicate with REST service. The type of configuration is
564 EFI_REST_EX_CONFIG_TYPE_HTTP and RestExConfigData is the same format with EFI_HTTP_CONFIG_DATA.
565 Akin to HTTP configuration, REST EX child instance can be configure to use different HTTP
566 local access point for the data transmission. Multiple REST clients may use different
567 configuration of HTTP to distinguish themselves, such as to use the different TCP port.
568 For those non HTTP-aware REST EX driver instance, the type of configuration is
569 EFI_REST_EX_CONFIG_TYPE_UNSPECIFIC. RestExConfigData refers to the non industrial standard.
570 Instead, the format of configuration data is system/platform specific definition such as BMC.
571 In this case, EFI REST client and EFI REST EX driver instance have to refer to the specific
572 system/platform spec which is out of the UEFI scope. Besides GetService()function, no other
573 EFI REST EX functions can be executed by this instance until Configure()is executed and returns
574 successfully. All other functions must returns EFI_NOT_READY if this instance is not configured
575 yet. Set RestExConfigData to NULL means to put EFI REST EX child instance into the unconfigured
578 @param[in] This This is the EFI_REST_EX_PROTOCOL instance.
579 @param[in] RestExConfigData Pointer to EFI_REST_EX_CONFIG_DATA. See Related Definitions in
580 GetModeData() protocol interface.
582 @retval EFI_SUCCESS EFI_REST_EX_CONFIG_DATA is set in successfully.
583 @retval EFI_DEVICE_ERROR Configuration for this REST EX child instance is failed with the given
584 EFI_REST_EX_CONFIG_DATA.
585 @retval EFI_UNSUPPORTED This function is not supported in this REST EX Protocol driver instance.
590 RedfishRestExConfigure (
591 IN EFI_REST_EX_PROTOCOL
*This
,
592 IN EFI_REST_EX_CONFIG_DATA RestExConfigData
597 RESTEX_INSTANCE
*Instance
;
599 EFI_HTTP_CONFIG_DATA
*HttpConfigData
;
601 Status
= EFI_SUCCESS
;
602 HttpConfigData
= NULL
;
605 return EFI_INVALID_PARAMETER
;
608 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
610 Instance
= RESTEX_INSTANCE_FROM_THIS (This
);
612 if (RestExConfigData
== NULL
) {
614 // Set RestExConfigData to NULL means to put EFI REST EX child instance into the unconfigured state.
616 HttpIoDestroyIo (&(Instance
->HttpIo
));
618 if (Instance
->ConfigData
!= NULL
) {
619 if (((EFI_REST_EX_HTTP_CONFIG_DATA
*)Instance
->ConfigData
)->HttpConfigData
.AccessPoint
.IPv4Node
!= NULL
) {
620 FreePool (((EFI_REST_EX_HTTP_CONFIG_DATA
*)Instance
->ConfigData
)->HttpConfigData
.AccessPoint
.IPv4Node
);
623 FreePool (Instance
->ConfigData
);
624 Instance
->ConfigData
= NULL
;
627 Instance
->State
= RESTEX_STATE_UNCONFIGED
;
629 HttpConfigData
= &((EFI_REST_EX_HTTP_CONFIG_DATA
*)RestExConfigData
)->HttpConfigData
;
630 Status
= Instance
->HttpIo
.Http
->Configure (Instance
->HttpIo
.Http
, HttpConfigData
);
631 if (EFI_ERROR (Status
)) {
635 Instance
->HttpIo
.Timeout
= ((EFI_REST_EX_HTTP_CONFIG_DATA
*)RestExConfigData
)->SendReceiveTimeout
;
637 Instance
->ConfigData
= AllocateZeroPool (sizeof (EFI_REST_EX_HTTP_CONFIG_DATA
));
638 if (Instance
->ConfigData
== NULL
) {
639 Status
= EFI_OUT_OF_RESOURCES
;
643 CopyMem (Instance
->ConfigData
, RestExConfigData
, sizeof (EFI_REST_EX_HTTP_CONFIG_DATA
));
644 if (HttpConfigData
->LocalAddressIsIPv6
== TRUE
) {
645 ((EFI_REST_EX_HTTP_CONFIG_DATA
*)Instance
->ConfigData
)->HttpConfigData
.AccessPoint
.IPv6Node
= AllocateZeroPool (sizeof (EFI_HTTPv6_ACCESS_POINT
));
646 if (((EFI_REST_EX_HTTP_CONFIG_DATA
*)Instance
->ConfigData
)->HttpConfigData
.AccessPoint
.IPv6Node
== NULL
) {
647 Status
= EFI_OUT_OF_RESOURCES
;
652 ((EFI_REST_EX_HTTP_CONFIG_DATA
*)Instance
->ConfigData
)->HttpConfigData
.AccessPoint
.IPv6Node
,
653 HttpConfigData
->AccessPoint
.IPv6Node
,
654 sizeof (EFI_HTTPv6_ACCESS_POINT
)
657 ((EFI_REST_EX_HTTP_CONFIG_DATA
*)Instance
->ConfigData
)->HttpConfigData
.AccessPoint
.IPv4Node
= AllocateZeroPool (sizeof (EFI_HTTPv4_ACCESS_POINT
));
658 if (((EFI_REST_EX_HTTP_CONFIG_DATA
*)Instance
->ConfigData
)->HttpConfigData
.AccessPoint
.IPv4Node
== NULL
) {
659 Status
= EFI_OUT_OF_RESOURCES
;
664 ((EFI_REST_EX_HTTP_CONFIG_DATA
*)Instance
->ConfigData
)->HttpConfigData
.AccessPoint
.IPv4Node
,
665 HttpConfigData
->AccessPoint
.IPv4Node
,
666 sizeof (EFI_HTTPv4_ACCESS_POINT
)
670 Instance
->State
= RESTEX_STATE_CONFIGED
;
674 gBS
->RestoreTPL (OldTpl
);
679 This function sends REST request to REST service and signal caller's event asynchronously when
680 the final response is received by REST EX Protocol driver instance.
682 The essential design of this function is to handle asynchronous send/receive implicitly according
683 to REST service asynchronous request mechanism. Caller will get the notification once the response
684 is returned from REST service.
686 @param[in] This This is the EFI_REST_EX_PROTOCOL instance.
687 @param[in] RequestMessage This is the HTTP request message sent to REST service. Set RequestMessage
688 to NULL to cancel the previous asynchronous request associated with the
689 corresponding RestExToken. See descriptions for the details.
690 @param[in] RestExToken REST EX token which REST EX Protocol instance uses to notify REST client
691 the status of response of asynchronous REST request. See related definition
692 of EFI_REST_EX_TOKEN.
693 @param[in] TimeOutInMilliSeconds The pointer to the timeout in milliseconds which REST EX Protocol driver
694 instance refers as the duration to drop asynchronous REST request. NULL
695 pointer means no timeout for this REST request. REST EX Protocol driver
696 signals caller's event with EFI_STATUS set to EFI_TIMEOUT in RestExToken
697 if REST EX Protocol can't get the response from REST service within
698 TimeOutInMilliSeconds.
700 @retval EFI_SUCCESS Asynchronous REST request is established.
701 @retval EFI_UNSUPPORTED This REST EX Protocol driver instance doesn't support asynchronous request.
702 @retval EFI_TIMEOUT Asynchronous REST request is not established and timeout is expired.
703 @retval EFI_ABORT Previous asynchronous REST request has been canceled.
704 @retval EFI_DEVICE_ERROR Otherwise, returns EFI_DEVICE_ERROR for other errors according to HTTP Status Code.
705 @retval EFI_NOT_READY The configuration of this instance is not set yet. Configure() must be executed
706 and returns successfully prior to invoke this function.
711 RedfishRestExAyncSendReceive (
712 IN EFI_REST_EX_PROTOCOL
*This
,
713 IN EFI_HTTP_MESSAGE
*RequestMessage OPTIONAL
,
714 IN EFI_REST_EX_TOKEN
*RestExToken
,
715 IN UINTN
*TimeOutInMilliSeconds OPTIONAL
718 return EFI_UNSUPPORTED
;
722 This function sends REST request to a REST Event service and signals caller's event
723 token asynchronously when the URI resource change event is received by REST EX
724 Protocol driver instance.
726 The essential design of this function is to monitor event implicitly according to
727 REST service event service mechanism. Caller will get the notification if certain
730 @param[in] This This is the EFI_REST_EX_PROTOCOL instance.
731 @param[in] RequestMessage This is the HTTP request message sent to REST service. Set RequestMessage
732 to NULL to cancel the previous event service associated with the corresponding
733 RestExToken. See descriptions for the details.
734 @param[in] RestExToken REST EX token which REST EX Protocol driver instance uses to notify REST client
735 the URI resource which monitored by REST client has been changed. See the related
736 definition of EFI_REST_EX_TOKEN in EFI_REST_EX_PROTOCOL.AsyncSendReceive().
738 @retval EFI_SUCCESS Asynchronous REST request is established.
739 @retval EFI_UNSUPPORTED This REST EX Protocol driver instance doesn't support asynchronous request.
740 @retval EFI_ABORT Previous asynchronous REST request has been canceled or event subscription has been
742 @retval EFI_DEVICE_ERROR Otherwise, returns EFI_DEVICE_ERROR for other errors according to HTTP Status Code.
743 @retval EFI_NOT_READY The configuration of this instance is not set yet. Configure() must be executed
744 and returns successfully prior to invoke this function.
749 RedfishRestExEventService (
750 IN EFI_REST_EX_PROTOCOL
*This
,
751 IN EFI_HTTP_MESSAGE
*RequestMessage OPTIONAL
,
752 IN EFI_REST_EX_TOKEN
*RestExToken
755 return EFI_UNSUPPORTED
;