Mail Archives: cygwin/2000/06/16/05:12:10
--------------EC0BDEEC9BEEFE505448F653
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
I have a problem for compiling this function :
Errors :
gpublic.c: In function `get_hwaddr':
gpublic.c:943: `SIOCGIFHWADDR' undeclared (first use in this function)
gpublic.c:943: (Each undeclared identifier is reported only once
gpublic.c:943: for each function it appears in.)
gpublic.c:956: structure has no member named `ifr_hwaddr'
gpublic.c:957: structure has no member named `ifr_hwaddr'
gpublic.c:958: structure has no member named `ifr_hwaddr'
gpublic.c:959: structure has no member named `ifr_hwaddr'
gpublic.c:960: structure has no member named `ifr_hwaddr'
gpublic.c:961: structure has no member named `ifr_hwaddr'
Source code :
int get_hwaddr(char *interface, char hwaddr[]) {
int sd;
struct ifreq req;
sd = socket(AF_INET,SOCK_DGRAM,IPPROTO_IP);
if (sd == -1) {
perror("socket()");
return -1;
}
sprintf(req.ifr_name,"%s",interface);
if (ioctl(sd,SIOCGIFHWADDR,&req) == -1) {
perror("ioctl():SIOCGIFHWADDR");
return -1;
}
/*
sprintf(hwaddr,"%02x:%02x:%02x:%02x:%02x:%02x",
(int)(req.ifr_hwaddr.sa_data[0] & 0xff),
(int)(req.ifr_hwaddr.sa_data[1] & 0xff),
(int)(req.ifr_hwaddr.sa_data[2] & 0xff),
(int)(req.ifr_hwaddr.sa_data[3] & 0xff),
(int)(req.ifr_hwaddr.sa_data[4] & 0xff),
(int)(req.ifr_hwaddr.sa_data[5] & 0xff)); */
sprintf(hwaddr,"%d%d%d%d%d%d",
(int)(req.ifr_hwaddr.sa_data[0] & 0xff),
(int)(req.ifr_hwaddr.sa_data[1] & 0xff),
(int)(req.ifr_hwaddr.sa_data[2] & 0xff),
(int)(req.ifr_hwaddr.sa_data[3] & 0xff),
(int)(req.ifr_hwaddr.sa_data[4] & 0xff),
(int)(req.ifr_hwaddr.sa_data[5] & 0xff));
return 0;
How can I make a good compilation ?
--
Bertrand Bourdon - Chef de Projet Informatique
PerformanSe S.A., l'évaluation des compétences et des comportements
BP 703 - 44481 Carquefou Cedex - Tél. : 02 28 01 55 13
http://www.performanse.fr/ Mailto:bertrand DOT bourdon AT performanse DOT fr
--------------EC0BDEEC9BEEFE505448F653
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
I have a problem for compiling this function :
<p><i><u>Errors :</u></i>
<br>gpublic.c: In function `get_hwaddr':
<br>gpublic.c:943: `SIOCGIFHWADDR' undeclared (first use in this function)
<br>gpublic.c:943: (Each undeclared identifier is reported only once
<br>gpublic.c:943: for each function it appears in.)
<br>gpublic.c:956: structure has no member named `ifr_hwaddr'
<br>gpublic.c:957: structure has no member named `ifr_hwaddr'
<br>gpublic.c:958: structure has no member named `ifr_hwaddr'
<br>gpublic.c:959: structure has no member named `ifr_hwaddr'
<br>gpublic.c:960: structure has no member named `ifr_hwaddr'
<br>gpublic.c:961: structure has no member named `ifr_hwaddr'
<br><i></i> <b><i><u></u></i></b>
<p><b><i><u>Source code :</u></i></b>
<br><i>int get_hwaddr(char *interface, char hwaddr[]) {</i><i></i>
<p><i> int sd;</i><i></i>
<p><i> struct ifreq req;</i>
<br><i> sd = socket(AF_INET,SOCK_DGRAM,IPPROTO_IP);</i>
<br><i> if (sd == -1) {</i>
<br><i> perror("socket()");</i>
<br><i> return -1;</i>
<br><i> }</i>
<br><i> sprintf(req.ifr_name,"%s",interface);</i>
<br><i> if (ioctl(sd,SIOCGIFHWADDR,&req) == -1) {</i>
<br><i> perror("ioctl():SIOCGIFHWADDR");</i>
<br><i> return -1;</i>
<br><i> }</i>
<br><i>/*</i>
<br><i> sprintf(hwaddr,"%02x:%02x:%02x:%02x:%02x:%02x",</i>
<br><i>(int)(req.ifr_hwaddr.sa_data[0] & 0xff),</i>
<br><i>(int)(req.ifr_hwaddr.sa_data[1] & 0xff),</i>
<br><i>(int)(req.ifr_hwaddr.sa_data[2] & 0xff),</i>
<br><i>(int)(req.ifr_hwaddr.sa_data[3] & 0xff),</i>
<br><i>(int)(req.ifr_hwaddr.sa_data[4] & 0xff),</i>
<br><i>(int)(req.ifr_hwaddr.sa_data[5] & 0xff)); */</i>
<br><i> sprintf(hwaddr,"%d%d%d%d%d%d",</i>
<br><i> (int)(req.ifr_hwaddr.sa_data[0] & 0xff),</i>
<br><i> (int)(req.ifr_hwaddr.sa_data[1] & 0xff),</i>
<br><i> (int)(req.ifr_hwaddr.sa_data[2] & 0xff),</i>
<br><i> (int)(req.ifr_hwaddr.sa_data[3] & 0xff),</i>
<br><i> (int)(req.ifr_hwaddr.sa_data[4] & 0xff),</i>
<br><i> (int)(req.ifr_hwaddr.sa_data[5] & 0xff));</i>
<br><i> return 0;</i>
<br><i></i> <i></i>
<p><i>How can I make a good compilation ?</i>
<pre>--
Bertrand Bourdon - Chef de Projet Informatique
PerformanSe S.A., l'évaluation des compétences et des comportements
BP 703 - 44481 Carquefou Cedex - Tél. : 02 28 01 55 13
<A HREF="http://www.performanse.fr/">http://www.performanse.fr/</A> <A HREF="Mailto:bertrand DOT bourdon AT performanse DOT fr">Mailto:bertrand DOT bourdon AT performanse DOT fr</A></pre>
</html>
--------------EC0BDEEC9BEEFE505448F653--
- Raw text -