Hi

I'm trying to get the ethernet address and from the manuals i understand that i need the ifreq structure for this. So i'm trying to request SIOCGIFMAC with ioctl on a socket of type SOCK_DGRAM.

Now i couldn't figure out from the manuals which format but i've tried PF_LOCAL, PF_INET and AF_INET. With PF_LOCAL i get the error "Operation not supported" from ioctl but with AF_INET or PF_INET i get "Invalid argument".

This is a snippet of code that i use to get the ethernet address. Earlier code has already verified the char *ifname which contains the interface name.

[..]
    int if_socket;
    struct ifreq ifr;

    memset(&ifr, 0, sizeof(ifr));
[..]
    strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));

    if((if_socket = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
        perror("socket: ");
        exit(-1);
    }

    if(ioctl(if_socket, SIOCGIFMAC, &ifr) < 0) {
        perror("ioctl: SIOCGIFMAC: ");
        exit(-1);
    }
[..]

I know the rest of the code works fine because this is something i'm adding to a working program. Also it's obviously stopping at the ioctl since i get the error "ioctl: SIOCGIFMAC: : Invalid argument".
--



Med vänliga hälsningar

Stefan Midjich aka nocturnal
[Swehack] http://swehack.se
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to