LCOV - code coverage report
Current view: top level - spdm_responder_lib - libspdm_rsp_encap_respond_if_ready.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 87.5 % 16 14
Test Date: 2026-10-01 20:56:25 Functions: 100.0 % 1 1
Branches: 66.7 % 6 4

             Branch data     Line data    Source code
       1                 :             : /**
       2                 :             :  *  Copyright Notice:
       3                 :             :  *  Copyright 2026 DMTF. All rights reserved.
       4                 :             :  *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
       5                 :             :  **/
       6                 :             : 
       7                 :             : #include "internal/libspdm_responder_lib.h"
       8                 :             : 
       9                 :             : #if (LIBSPDM_ENABLE_CAPABILITY_ENCAP_CAP) && (LIBSPDM_RESPOND_IF_READY_SUPPORT)
      10                 :             : 
      11                 :           4 : libspdm_return_t libspdm_get_encap_request_respond_if_ready(void *context,
      12                 :             :                                                             const uint32_t *session_id,
      13                 :             :                                                             size_t *encap_request_size,
      14                 :             :                                                             void *encap_request)
      15                 :             : {
      16                 :             :     libspdm_context_t *spdm_context;
      17                 :             :     libspdm_encap_context_t *encap_context;
      18                 :             :     spdm_response_if_ready_request_t *spdm_request;
      19                 :             : 
      20                 :           4 :     spdm_context = context;
      21                 :             : 
      22                 :           4 :     encap_context = libspdm_get_encap_context(spdm_context, session_id);
      23         [ -  + ]:           4 :     if (encap_context == NULL) {
      24                 :             :         /* session_id does not refer to an existing session. */
      25                 :           0 :         return LIBSPDM_STATUS_INVALID_STATE_LOCAL;
      26                 :             :     }
      27                 :             : 
      28         [ +  + ]:           4 :     if (encap_context->last_encap_request_size == 0) {
      29                 :             :         /* There is no outstanding encapsulated request to ask about. */
      30                 :           1 :         return LIBSPDM_STATUS_INVALID_STATE_LOCAL;
      31                 :             :     }
      32                 :             : 
      33         [ -  + ]:           3 :     if (*encap_request_size < sizeof(spdm_response_if_ready_request_t)) {
      34                 :           0 :         return LIBSPDM_STATUS_INVALID_MSG_SIZE;
      35                 :             :     }
      36                 :           3 :     *encap_request_size = sizeof(spdm_response_if_ready_request_t);
      37                 :             : 
      38                 :           3 :     spdm_request = encap_request;
      39                 :           3 :     spdm_request->header.spdm_version = libspdm_get_connection_version(spdm_context);
      40                 :           3 :     spdm_request->header.request_response_code = SPDM_RESPOND_IF_READY;
      41                 :           3 :     spdm_request->header.param1 = encap_context->response_not_ready_data.request_code;
      42                 :           3 :     spdm_request->header.param2 = encap_context->response_not_ready_data.token;
      43                 :             : 
      44                 :             :     /* last_encap_request_header is deliberately left alone. It still identifies the request that
      45                 :             :      * this RESPOND_IF_READY is asking about, so that the response, when it arrives, is dispatched
      46                 :             :      * to the correct handler. */
      47                 :             : 
      48                 :           3 :     return LIBSPDM_STATUS_SUCCESS;
      49                 :             : }
      50                 :             : 
      51                 :             : #endif /* (LIBSPDM_ENABLE_CAPABILITY_ENCAP_CAP) && (LIBSPDM_RESPOND_IF_READY_SUPPORT) */
        

Generated by: LCOV version 2.0-1