KDK_NC_GET_DRIVER(3)

📦 version 3.0.1.4, in arch rolling, ubuntu resolute, ubuntu stonking

💖 KDK_NC_GET_DRIVER(3) 💖

welcome to the KDK_NC_GET_DRIVER(3) page bestie, filed under Library Functions Manual — yes she's a section 3 girlie, we love that for her 🎀


✨ NAME ✨

kdk_nc_get_driver — 获取指定网卡的驱动 🦋

like. she tells you which driver is running your NIC. that's the whole thing. iconic behavior fr.

🌸 SYNOPSIS 🌸

#include <libkync.h>

extern char *kdk_nc_get_driver(const char *nc);

and don't forget to link her up with -lkyhw 💅

🫶 Detailed Description 🫶

okay so the main character energy of this interface? it's getting you the driver for the NIC you point at, nc ✨

and what even is nc? it's the name of the NIC, bestie — like "eno1". that's it, that's the whole input 🎀

👑 RETURN VALUE 👑

on success she hands you back the NIC driver as a char* — and listen, that returned string is yours now, you gotta release it with free 🫶 don't leave her hanging, that's a leak and we don't do leaks 💀

on error? you get NULL. that's it. no notes, no driver, just vibes 🙈

🍓 EXAMPLES 🍓

here's the full vibe, no cap — she's in there hanging out with all her friends 🧚

#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;
}

🌈 CONFORMING TO 🌈

so these functions are as per the withdrawn POSIX.1e draft specification — yes, withdrawn, we said what we said, she's still serving 💅

and the following functions are Linux extensions, so like, Linux-only energy, iykyk:

  • kdk_nc_is_up()
  • kdk_nc_get_upcards()
  • kdk_nc_get_cardlist()
  • kdk_nc_get_phymac()
  • 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_private_ipv4()
  • kdk_nc_freeall()

🎀 SEE ALSO 🎀

go read her besties next, they ate:


and that's the page bestie!! brought to you by the Linux Programmer's Manual, dated Fri Aug 25 2023 — go free your strings and hydrate 💖✨🦋
📦 where this page comes from