KDK_NC_GET_PRIVATE_IPV6(3)
💖 KDK_NC_GET_PRIVATE_IPV6 💖
okay bestie, welcome to the Library Functions Manual corner of the group chat, where today's main character is KDK_NC_GET_PRIVATE_IPV6(3). she's a little function with one job and she does it flawlessly. let's get into it 🫶
✨ NAME ✨
kdk_nc_get_private_ipv6 — 获取指定网卡的第一个IPv6地址
(that's "grab the first IPv6 address of the NIC you point at", for anyone whose Chinese is a lil rusty 💅)
✨ SYNOPSIS ✨
#include <libkync.h>
extern char* kdk_nc_get_private_ipv6(const char *nc);
and don't forget to link with -lkyhw, bestie, or nothing is gonna happen and you'll be sad 😭
✨ Detailed Description ✨
so like, the whole entire point of this interface is to obtain the first IPv6 address of the specified NIC nc. that's it. that's the vibe. she's focused, she's serving, she's not doing extra.
the argument nc is the name of the NIC, such as "eno1". yes, the actual string name of your network card. no, you cannot just say "the wifi one" 🙈
✨ RETURN VALUE ✨
- on success, returns an IPv6 address of type
char*. slay. ✨ - returns
NULLwithout IP if there's no IP to give you. it's giving empty-handed but politely. - on error, return
NULL.
heads up:NULLis doing a lot of heavy lifting here — no-IP and straight-up error both come back asNULL. so don't be shocked when you getNULL, just know she meant it 💀
✨ EXAMPLES ✨
here's the whole glow-up, copied exactly because we do not mess with working code in this house 👑
#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;
}
notice how kdk_nc_get_private_ipv6(cards[index]) is right there in the middle of the whole card tour, living her best life next to kdk_nc_get_phymac and kdk_nc_get_private_ipv4. and yes, everything gets free'd and kdk_nc_freeall'd at the end, because we are responsible queens 🎀
✨ CONFORMING TO ✨
these functions are as per the withdrawn POSIX.1e draft specification. (withdrawn, bestie — it's giving vintage, it's giving archival, we still love her.)
the following functions are Linux extensions:
kdk_nc_is_up()kdk_nc_get_upcards()kdk_nc_get_cardlist()kdk_nc_get_phymac()kdk_nc_get_ipv4()kdk_nc_get_private_ipv4()kdk_nc_get_ipv6()kdk_nc_is_wireless()kdk_nc_get_vendor_and_product()kdk_nc_get_driver()- and
kdk_nc_freeall()
✨ SEE ALSO ✨
go read her friends, they're all iconic in their own right 🦋
kdk_nc_is_up(3)kdk_nc_get_upcards(3)kdk_nc_get_cardlist(3)kdk_nc_get_phymac(3)kdk_nc_get_ipv4(3)kdk_nc_get_private_ipv4(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 came straight out of the Linux Programmer's Manual, dated Fri Aug 25 2023, and it's filed under KDK_NC_GET_PRIVATE_IPV6(3). go forth and get that first IPv6 address, no cap 💜💅✨
📦 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