/* The ProcessPacket () function process each inbound or outbound TLS APP packet. */
EFI_STATUS EFIAPI TlsProcessPacket(IN EFI_TLS_PROTOCOL *This, IN OUT EFI_TLS_FRAGMENT_DATA **FragmentTable, IN UINT32 *FragmentCount, IN EFI_TLS_CRYPT_MODE CryptMode)
/* The ProcessPacket () function process each inbound or outbound TLS APP packet. */
EFI_STATUS EFIAPI TlsProcessPacket(IN EFI_TLS_PROTOCOL *This, IN OUT EFI_TLS_FRAGMENT_DATA **FragmentTable, IN UINT32 *FragmentCount, IN EFI_TLS_CRYPT_MODE CryptMode)
{
  EFI_STATUS    Status;
  TLS_INSTANCE  *Instance;
  EFI_TPL  OldTpl;
  Status = EFI_SUCCESS;
  if ((This == NULL) || (FragmentTable == NULL) || (FragmentCount == NULL)) {
    return EFI_INVALID_PARAMETER;
  }
  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
  Instance = TLS_INSTANCE_FROM_PROTOCOL (This);
  if (Instance->TlsSessionState != EfiTlsSessionDataTransferring) {
    Status = EFI_NOT_READY;
    goto ON_EXIT;
  }
  switch (CryptMode) {
    case EfiTlsEncrypt:
      Status = TlsEncryptPacket (Instance, FragmentTable, FragmentCount);
      break;
    case EfiTlsDecrypt:
      Status = TlsDecryptPacket (Instance, FragmentTable, FragmentCount);
      break;
    default:
      return EFI_INVALID_PARAMETER;
  }
ON_EXIT:
  gBS->RestoreTPL (OldTpl);
  return Status;
}