KySdkNetCard(3)
π KySdkNetCard β the D-Bus signal class for network card info π
okay bestie, sit down, hydrate, because we're about to get to know KySdkNetCard, a little class from the KySdk Network Card Library manual (section 3 of the manuals, if you're keeping score π). It lives in <kysdkdbus.h> and it inherits from QObject. That's the whole vibe: it's the class that generates D-Bus signals so you can pull network card info without crying.
β¨ NAME β¨
KySdkNetCard β a D-Bus signal class for generating network card information. no cap, that's literally its job description π
πΈ SYNOPSIS πΈ
#include <kysdkdbus.h>
Inherits from QObject.
π¦ DESCRIPTION π¦
So KySdkNetCard is mainly there to generate D-Bus signals for network card information. And when we say network card information, we mean all of it, queen: getting the network card list, MAC address, IP address, subnet mask, gateway, DNS servers, connection status, speed, duplex mode, and other network interface information. it's giving "one class, all the tea" β
π PUBLIC SLOTS π
Nine slots. Nine chances to be that girl. Let's go π
QStringList getNetCardList () constβ Get the list of all network cards.- Return value:
QStringListβ List of network card names β¨
- Return value:
QString getNetCardMacAddress (const QString cardName) constβ Get the MAC address of the specified network card.- Parameters:
cardNameβ Network card name
- Return value:
QStringβ MAC address of the network card π
- Parameters:
QString getNetCardIpAddress (const QString cardName) constβ Get the IP address of the specified network card.- Parameters:
cardNameβ Network card name
- Return value:
QStringβ IP address of the network card π
- Parameters:
QString getNetCardSubnetMask (const QString cardName) constβ Get the subnet mask of the specified network card.- Parameters:
cardNameβ Network card name
- Return value:
QStringβ Subnet mask of the network card π¦
- Parameters:
QString getNetCardGateway (const QString cardName) constβ Get the gateway of the specified network card.- Parameters:
cardNameβ Network card name
- Return value:
QStringβ Gateway of the network card πͺβ¨
- Parameters:
QStringList getNetCardDnsServers (const QString cardName) constβ Get the DNS servers of the specified network card.- Parameters:
cardNameβ Network card name
- Return value:
QStringListβ DNS server addresses list π
- Parameters:
bool isNetCardConnected (const QString cardName) constβ Check if the specified network card is connected.- Parameters:
cardNameβ Network card name
- Return value:
boolβ Connection status (trueif connected,falseotherwise) β
- Parameters:
int getNetCardSpeed (const QString cardName) constβ Get the speed of the specified network card.- Parameters:
cardNameβ Network card name
- Return value:
intβ Speed of the network card in Mbps π₯
- Parameters:
QString getNetCardDuplexMode (const QString cardName) constβ Get the duplex mode of the specified network card.- Parameters:
cardNameβ Network card name
- Return value:
QStringβ Duplex mode ("full","half", or"unknown") π§
- Parameters:
π EXAMPLE USAGE π
here's the whole thing in action, copy-paste ready, no notes (jk there are notes, scroll down):
#include <kysdkdbus.h>
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
KySdkNetCard netCardInfo;
// Get network card list
QStringList netCards = netCardInfo.getNetCardList();
qDebug() << "Network cards:" << netCards;
// Get information of the first network card
if (!netCards.isEmpty()) {
QString cardName = netCards.first();
QString macAddr = netCardInfo.getNetCardMacAddress(cardName);
QString ipAddr = netCardInfo.getNetCardIpAddress(cardName);
QString subnetMask = netCardInfo.getNetCardSubnetMask(cardName);
QString gateway = netCardInfo.getNetCardGateway(cardName);
QStringList dnsServers = netCardInfo.getNetCardDnsServers(cardName);
bool isConnected = netCardInfo.isNetCardConnected(cardName);
int speed = netCardInfo.getNetCardSpeed(cardName);
QString duplexMode = netCardInfo.getNetCardDuplexMode(cardName);
qDebug() << "Network card:" << cardName;
qDebug() << " MAC Address:" << macAddr;
qDebug() << " IP Address:" << ipAddr;
qDebug() << " Subnet Mask:" << subnetMask;
qDebug() << " Gateway:" << gateway;
qDebug() << " DNS Servers:" << dnsServers;
qDebug() << " Connected:" << isConnected;
qDebug() << " Speed:" << speed << "Mbps";
qDebug() << " Duplex Mode:" << duplexMode;
}
return 0;
}
π NOTES π
little things to keep in your head, bestie, don't skip these:
- IP address, subnet mask, and gateway are returned as string format
- DNS servers are returned as a list of string addresses
- Speed is returned in Mbps (Megabits per second)
- Duplex mode can be
"full","half", or"unknown" - Connection status returns
trueif the network card is active and connected
fr fr, don't forget these β they're the difference between code that slays and code that's just confused π
π SEE ALSO π
QObject(3qt5), D-Bus(1), ifconfig(8), ip(8), nmcli(1) β go read those too, iykyk π«Ά
π AUTHOR π
Generated automatically by Doxygen for kysdkdbus.h from the source code. (the robots did it, not us π)
and that's a wrap on the KySdkNetCard manual page, version 1.0, dated Wed Sep 20 2023, straight from the KySdk Network Card Library. periodt. go get your network card info, icon π
β¨π¦
π¦ where this page comes from
- arch rolling: libkysdk-system 3.0.1.4-1 Β· LGPL-3.0-or-later AND LGPL-2.1-only OR LGPL-3.0-only AND LGPL-2.1-only WITH Qt-LGPL-exception-1.1 OR LGPL-3.0-only WITH Qt-LGPL-exception-1.1 AND MIT
- ubuntu resolute: libkysdk-system-dev 3.0.1.2-0ubuntu1 Β· LGPL-3.0-only
- ubuntu stonking: libkysdk-system-dev 3.0.1.3-0ubuntu1 Β· LGPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms