LCOV - code coverage report
Current view: top level - library/spdm_responder_lib - libspdm_rsp_handle_response_state.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 80.8 % 26 21
Test Date: 2025-06-29 08:09:00 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /**
       2              :  *  Copyright Notice:
       3              :  *  Copyright 2021-2022 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           50 : libspdm_return_t libspdm_responder_handle_response_state(libspdm_context_t *spdm_context,
      10              :                                                          uint8_t request_code,
      11              :                                                          size_t *response_size,
      12              :                                                          void *response)
      13              : {
      14              :     libspdm_return_t status;
      15              : 
      16           50 :     switch (spdm_context->response_state) {
      17           19 :     case LIBSPDM_RESPONSE_STATE_BUSY:
      18           19 :         return libspdm_generate_error_response(spdm_context, SPDM_ERROR_CODE_BUSY,
      19              :                                                0, response_size, response);
      20              :     /* NOTE: Need to reset status to Normal in up level*/
      21           18 :     case LIBSPDM_RESPONSE_STATE_NEED_RESYNC:
      22           18 :         status = libspdm_generate_error_response(spdm_context,
      23              :                                                  SPDM_ERROR_CODE_REQUEST_RESYNCH, 0,
      24              :                                                  response_size, response);
      25           18 :         if (LIBSPDM_STATUS_IS_ERROR(status)) {
      26            0 :             return status;
      27              :         }
      28              :         /* NOTE: Need to let SPDM_VERSION reset the State*/
      29           18 :         libspdm_set_connection_state(spdm_context,
      30              :                                      LIBSPDM_CONNECTION_STATE_NOT_STARTED);
      31           18 :         return LIBSPDM_STATUS_SUCCESS;
      32              :     #if LIBSPDM_RESPOND_IF_READY_SUPPORT
      33           13 :     case LIBSPDM_RESPONSE_STATE_NOT_READY:
      34              :         /*do not update ErrorData if a previous request has not been completed*/
      35           13 :         if(request_code != SPDM_RESPOND_IF_READY) {
      36           12 :             spdm_context->cache_spdm_request_size = spdm_context->last_spdm_request_size;
      37           12 :             libspdm_copy_mem(spdm_context->cache_spdm_request,
      38           12 :                              libspdm_get_scratch_buffer_cache_spdm_request_capacity(spdm_context),
      39           12 :                              spdm_context->last_spdm_request,
      40              :                              spdm_context->last_spdm_request_size);
      41           12 :             spdm_context->error_data.rd_exponent = 1;
      42           12 :             spdm_context->error_data.rd_tm = 1;
      43           12 :             spdm_context->error_data.request_code = request_code;
      44           12 :             spdm_context->error_data.token = spdm_context->current_token++;
      45              :         }
      46           13 :         return libspdm_generate_extended_error_response(
      47              :             spdm_context, SPDM_ERROR_CODE_RESPONSE_NOT_READY, 0,
      48              :             sizeof(spdm_error_data_response_not_ready_t),
      49           13 :             (uint8_t *)(void *)&spdm_context->error_data,
      50              :             response_size, response);
      51              :     #endif /* LIBSPDM_RESPOND_IF_READY_SUPPORT */
      52              :     /* NOTE: Need to reset status to Normal in up level*/
      53            0 :     case LIBSPDM_RESPONSE_STATE_PROCESSING_ENCAP:
      54            0 :         return libspdm_generate_error_response(spdm_context,
      55              :                                                SPDM_ERROR_CODE_REQUEST_IN_FLIGHT,
      56              :                                                0, response_size, response);
      57              :     /* NOTE: Need let SPDM_ENCAPSULATED_RESPONSE_ACK reset the State*/
      58            0 :     default:
      59            0 :         return LIBSPDM_STATUS_SUCCESS;
      60              :     }
      61              : }
        

Generated by: LCOV version 2.0-1