Hello Misc,

  I try to detect hwaddr from my nic via libnet 1.1
  But my program detect incorrect hwaddr like this ca:0a:00:00:00:00
  where i take mistake ??? OpenBSD 4.4-current (Generic)
hwaddr.c
------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

#ifdef __OpenBSD__
# include <net/if.h>
# include <net/if_arp.h>
#endif  /* __OpenBSD__ */


#include <libnet.h>

int main(int argc, char *argv[]) {
    libnet_t *ln;
    struct ether_addr *ha = NULL;
    char ebuf[LIBNET_ERRBUF_SIZE] = "\0";

    if (!(ln = libnet_init(LIBNET_LINK_ADV, argv[1], ebuf))) {
        fprintf(stderr, "%s", ebuf);
        exit(EXIT_FAILURE);
    }

    if ((ha = (struct ether_addr *) libnet_get_hwaddr(ln)) == NULL) {
        fprintf(stderr, "%s", libnet_geterror(ln));
        exit(EXIT_FAILURE);
    }

    printf("hwaddr: %s\n", ether_ntoa(ha));

    libnet_destroy(ln);

    return 0;
}

-----------------------------------------------

-- 
Best regards,
 irix                          mailto:[EMAIL PROTECTED]

Reply via email to