5 #include "utilities/timer.h" 7 #include <openssl/evp.h> 8 #include <openssl/rand.h> 11 using std::make_shared;
12 using std::shared_ptr;
15 if (sodium_init() == -1) {
16 throw std::runtime_error(
"Unable to initialize libsodium");
19 LOG_TRACE <<
"Seeding random number generator from /dev/urandom...";
22 std::ifstream urandom(
"/dev/urandom", std::ios::in | std::ios::binary);
23 urandom.read(reinterpret_cast<char *>(&seed),
sizeof(seed));
26 LOG_TRACE <<
"... seeding complete in " << timer;
28 sig_ = make_shared<boost::signals2::signal<void(shared_ptr<event::BaseEvent>)>>();
29 storage_ = INvStorage::newStorage(config_.storage);
30 storage_->importData(config_.import);
31 uptane_client_ = SotaUptaneClient::newDefaultClient(config_, storage_, sig_);
32 uptane_client_->initialize();
39 std::this_thread::sleep_for(std::chrono::seconds(config_.uptane.polling_sec));
45 uptane_client_->addNewSecondary(secondary);
60 void Aktualizr::Download(
const std::vector<Uptane::Target> &updates) { uptane_client_->downloadImages(updates); }
62 void Aktualizr::Install(
const std::vector<Uptane::Target> &updates) { uptane_client_->uptaneInstall(updates); }
65 return sig_->connect(handler);
void Install(const std::vector< Uptane::Target > &updates)
Asynchronously install targets.
void CampaignAccept(const std::string &campaign_id)
Asynchronously accept a campaign for the current device Campaigns are a concept outside of Uptane...
void Download(const std::vector< Uptane::Target > &updates)
Asynchronously download targets.
Elapsed time measurement.
void AddSecondary(const std::shared_ptr< Uptane::SecondaryInterface > &secondary)
Add new secondary to aktualizr.
boost::signals2::connection SetSignalHandler(std::function< void(std::shared_ptr< event::BaseEvent >)> &handler)
Provide a function to receive event notifications.
void CheckUpdates()
Asynchronously load already-fetched Uptane metadata from disk.
void SendDeviceData()
Asynchronously send local device data to the server.
int Run()
Launch aktualizr.
void FetchMetadata()
Asynchronously fetch Uptane metadata.
Configuration object for an aktualizr instance running on a primary ECU.
void Shutdown()
Asynchronously shutdown Aktualizr.
Aktualizr(Config &config)
Aktualizr requires a configuration object.
void CampaignCheck()
Asynchronously perform a check for campaigns.