#include "core/host.h"

#include "core/error.h"

namespace dofs {

Host::Host(Simulator *const sim, NodeId id) noexcept
        : Node(sim, id, NodeType::HOST), _nic(nullptr) {
        // Hosts start in OK unless caller overrides later.
        Node::set_status(NodeStatus::OK);
}

void Host::attach_nic(NetworkNic* nic) noexcept {
        if (_nic && _nic != nic) {
                log_error("ERROR", "Host::attach_nic called while NIC already attached");
        }

        _nic = nic;
}

void Host::detach_nic(NetworkNic* nic) noexcept {
        if (_nic && _nic != nic) {
                log_error("ERROR", "Host::detach_nic called with non-matching NIC pointer");
                return;
        }

        _nic = nullptr;
}

} // namespace dofs
