Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

ioctl :error: SIOCGARP undeclared

Hi all

I am finding MAC address of my mac mini using xcode 3.2.3 and i wonder

why my code does not build.

My code is as below.

//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////

#include <stdio.h>

#include <string.h>/* for strncpy */

#include <sys/types.h>

#include <sys/socket.h>

#include <sys/ioctl.h>

#include <netinet/in.h>

#include <net/if.h>

#include <unistd.h>

#include <stdlib.h>


int

main()

{

int fd;

struct ifreq ifr;


fd = socket(AF_INET, SOCK_DGRAM, 0);


ifr.ifr_addr.sa_family = AF_INET;

strncpy(ifr.ifr_name, "eth0", IFNAMSIZ-1);


ioctl(fd, SIOCGARP, sizeof(ifr)); "SIOCGARP " undeclared


close(fd);


/* display result */

// printf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",

// (unsigned char)ifr.ifr_hwaddr.sa_data[0],

// (unsigned char)ifr.ifr_hwaddr.sa_data[1],

// (unsigned char)ifr.ifr_hwaddr.sa_data[2],

// (unsigned char)ifr.ifr_hwaddr.sa_data[3],

// (unsigned char)ifr.ifr_hwaddr.sa_data[4],

// (unsigned char)ifr.ifr_hwaddr.sa_data[5]);

//

return0;

}

//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////

someone help me to go ahead with error free build.

Also give me advice about how to get MAC address of machine.

Thanks in advance

Dhiraj

Mac mini, Mac OS X (10.6.4)

Posted on Mar 7, 2013 1:56 AM

Reply
Question marked as Best reply

Posted on Mar 7, 2013 2:50 PM

SIOCGARP isn't declared in sockio.h; it's not a valid #define.


You could try SIOCARPIPLL, although I'm not certain taht's the right macro either.

1 reply

ioctl :error: SIOCGARP undeclared

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.