mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-20 21:43:12 -07:00
Add HostMAC in Discovery
This commit is contained in:
parent
875e8b413e
commit
1a4634f3c2
4 changed files with 14 additions and 1 deletions
|
@ -18,6 +18,8 @@
|
||||||
#ifndef CHIAKI_DISCOVERYMANAGER_H
|
#ifndef CHIAKI_DISCOVERYMANAGER_H
|
||||||
#define CHIAKI_DISCOVERYMANAGER_H
|
#define CHIAKI_DISCOVERYMANAGER_H
|
||||||
|
|
||||||
|
#include "host.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
|
@ -30,6 +32,8 @@ struct DiscoveryHost
|
||||||
#define STRING_MEMBER(name) QString name;
|
#define STRING_MEMBER(name) QString name;
|
||||||
CHIAKI_DISCOVERY_HOST_STRING_FOREACH(STRING_MEMBER)
|
CHIAKI_DISCOVERY_HOST_STRING_FOREACH(STRING_MEMBER)
|
||||||
#undef STRING_MEMBER
|
#undef STRING_MEMBER
|
||||||
|
|
||||||
|
HostMAC GetHostMAC() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(DiscoveryHost)
|
Q_DECLARE_METATYPE(DiscoveryHost)
|
||||||
|
|
|
@ -32,6 +32,7 @@ class HostMAC
|
||||||
HostMAC() { memset(mac, 0, sizeof(mac)); }
|
HostMAC() { memset(mac, 0, sizeof(mac)); }
|
||||||
explicit HostMAC(const uint8_t mac[6]) { memcpy(this->mac, mac, sizeof(this->mac)); }
|
explicit HostMAC(const uint8_t mac[6]) { memcpy(this->mac, mac, sizeof(this->mac)); }
|
||||||
const uint8_t *GetMAC() const { return mac; }
|
const uint8_t *GetMAC() const { return mac; }
|
||||||
|
QString ToString() const { return QByteArray((const char *)mac, sizeof(mac)).toHex(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool operator==(const HostMAC &a, const HostMAC &b) { return memcmp(a.GetMAC(), b.GetMAC(), 6) == 0; }
|
static bool operator==(const HostMAC &a, const HostMAC &b) { return memcmp(a.GetMAC(), b.GetMAC(), 6) == 0; }
|
||||||
|
|
|
@ -25,6 +25,14 @@
|
||||||
#define HOSTS_MAX 16
|
#define HOSTS_MAX 16
|
||||||
#define DROP_PINGS 3
|
#define DROP_PINGS 3
|
||||||
|
|
||||||
|
HostMAC DiscoveryHost::GetHostMAC() const
|
||||||
|
{
|
||||||
|
QByteArray data = QByteArray::fromHex(host_id.toUtf8());
|
||||||
|
if(data.size() != 6)
|
||||||
|
return HostMAC();
|
||||||
|
return HostMAC((uint8_t *)data.constData());
|
||||||
|
}
|
||||||
|
|
||||||
static void DiscoveryServiceHostsCallback(ChiakiDiscoveryHost *hosts, size_t hosts_count, void *user);
|
static void DiscoveryServiceHostsCallback(ChiakiDiscoveryHost *hosts, size_t hosts_count, void *user);
|
||||||
|
|
||||||
DiscoveryManager::DiscoveryManager(QObject *parent) : QObject(parent)
|
DiscoveryManager::DiscoveryManager(QObject *parent) : QObject(parent)
|
||||||
|
|
|
@ -72,7 +72,7 @@ void ServerItemWidget::Update(const DisplayServer &display_server)
|
||||||
icon_widget->SetState(display_server.discovery_host.state);
|
icon_widget->SetState(display_server.discovery_host.state);
|
||||||
top_label->setText(tr("%1\nID: %2\nAddress: %3").arg(
|
top_label->setText(tr("%1\nID: %2\nAddress: %3").arg(
|
||||||
display_server.discovery_host.host_name,
|
display_server.discovery_host.host_name,
|
||||||
display_server.discovery_host.host_id,
|
display_server.discovery_host.GetHostMAC().ToString(),
|
||||||
display_server.discovery_host.host_addr));
|
display_server.discovery_host.host_addr));
|
||||||
bottom_label->setText(tr("State: %1").arg(chiaki_discovery_host_state_string(display_server.discovery_host.state)));
|
bottom_label->setText(tr("State: %1").arg(chiaki_discovery_host_state_string(display_server.discovery_host.state)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue