KDK_NC_GET_CARDLIST(3)
💖 KDK_NC_GET_CARDLIST(3) 💖
okay bestie, so this is a page from the Library Functions Manual and honestly? it's giving "let me show you every single network card in your whole system" energy. no cap. let's go 🦋
✨ NAME ✨
kdk_nc_get_cardlist — 获取系统中所有的网卡 (that's "grab every single NIC in the system", fr fr 💅)
🎀 SYNOPSIS 🎀
#include <libkync.h>
extern char** kdk_nc_get_cardlist();
Link with -lkyhw.
🌸 Detailed Description 🌸
The main function of the interface is to obtain all NICs in the system. like, all of them. every single one. the whole roster 👑
🌈 RETURN VALUE 🌈
- On success, returns a list of NIC names, ending with a
NULLstring; Generated byallocand needs to be recycled bykdk_nc_freeall. - On error, return
NULL.
bestie do NOT forget the kdk_nc_freeall part. it's literally the recycling bin for this list and the planet is begging you 🙈
⭐ EXAMPLES ⭐
okay this example is a whole mood — it walks every card and prints basically everything about it:
#include "libkync.h"
#include <stdio.h>
#include <stdlib.h>
int main()
{
char **cards = kdk_nc_get_cardlist();
size_t index = 0;
printf("所有网卡:\n");
while (cards[index])
{
char *mac = kdk_nc_get_phymac(cards[index]);
char *ipv4 = kdk_nc_get_private_ipv4(cards[index]);
char *ipv6 = kdk_nc_get_private_ipv6(cards[index]);
char *driver = kdk_nc_get_driver(cards[index]);
char vendor[256] = " ", product[256] = " ";
kdk_nc_get_vendor_and_product(cards[index], vendor, product);
printf("Card %zd: %sStatus: %sMac: %sIPv4: %sIPv6: %s Vendor: %s Product: %s Type: %s driver: %s\n",
index + 1, cards[index], kdk_nc_is_up(cards[index]) == 1 ? "Up" : "Down",
mac, ipv4, ipv6, vendor, product,
kdk_nc_is_wireless(cards[index]) ? "wireless" : "ethernet", driver);
char **list4 = kdk_nc_get_ipv4(cards[index]);
int i = 0;
printf("AllIpV4: ");
while (list4 && list4[i])
{
printf("%s", list4[i++]);
}
printf("\n");
char **list6 = kdk_nc_get_ipv6(cards[index]);
printf("AllIpV6: ");
i = 0;
while (list6 && list6[i])
{
printf("%s", list6[i++]);
}
printf("\n");
free(mac);
free(ipv4);
free(ipv6);
free(list4);
free(list6);
free(driver);
index++;
}
kdk_nc_freeall(cards);
char **upcards = kdk_nc_get_upcards();
index = 0;
printf("工作网卡:\n");
while (upcards[index])
{
printf("Card %zd: %s\n", index + 1, upcards[index]);
index++;
}
kdk_nc_freeall(upcards);
return 0;
}
see how it frees mac, ipv4, ipv6, list4, list6 and driver inside the loop, and kdk_nc_freealls cards and upcards when it's done? that's the self-care routine ✨ don't skip it.
💜 CONFORMING TO 💜
These functions are as per the withdrawn POSIX.1e draft specification. The following functions are Linux extensions: kdk_nc_is_up(), kdk_nc_get_upcards(), kdk_nc_get_phymac(), kdk_nc_get_private_ipv4(), kdk_nc_get_ipv4(), kdk_nc_get_private_ipv6(), kdk_nc_get_ipv6(), kdk_nc_is_wireless(), kdk_nc_get_vendor_and_product(), kdk_nc_get_driver(), and kdk_nc_freeall().
so like, the POSIX.1e part is withdrawn — it's the vintage piece — and everything in that list is a Linux-only extra 🐧
👑 SEE ALSO 👑
kdk_nc_is_up(3), kdk_nc_get_upcards(3), kdk_nc_get_phymac(3), kdk_nc_get_private_ipv4(3), kdk_nc_get_ipv4(3), kdk_nc_get_private_ipv6(3), kdk_nc_get_ipv6(3), kdk_nc_is_wireless(3), kdk_nc_get_vendor_and_product(3), kdk_nc_get_driver(3), and kdk_nc_freeall(3).
and that's the whole page, bestie 🫶 this one comes from the Linux Programmer's Manual, dated Fri Aug 25 2023, and yeah — it's the KDK_NC_GET_CARDLIST(3) page, so now you know her name, her date, and her whole lore. mwah 💅💖
📦 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