delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/06/16/05:12:10

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-ID: <3949E975.90737477@performanse.fr>
Date: Fri, 16 Jun 2000 10:46:45 +0200
From: Bertrand Bourdon <bertrand DOT bourdon AT performanse DOT fr>
X-Mailer: Mozilla 4.7C-SGI [en] (X11; I; IRIX 6.3 IP32)
X-Accept-Language: en
MIME-Version: 1.0
To: cygwin AT sourceware DOT cygnus DOT com,
"Remi DOT Lehn AT irin DOT univ-nantes DOT fr" <Remi DOT Lehn AT irin DOT univ-nantes DOT fr>
Subject: Pb with ioctl()

--------------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>&nbsp;<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>&nbsp;int sd;</i><i></i>
<p><i>&nbsp;struct ifreq req;</i>
<br><i>&nbsp;sd = socket(AF_INET,SOCK_DGRAM,IPPROTO_IP);</i>
<br><i>&nbsp;if (sd == -1) {</i>
<br><i>&nbsp; perror("socket()");</i>
<br><i>&nbsp; return -1;</i>
<br><i>&nbsp;}</i>
<br><i>&nbsp;sprintf(req.ifr_name,"%s",interface);</i>
<br><i>&nbsp;if (ioctl(sd,SIOCGIFHWADDR,&amp;req) == -1)&nbsp; {</i>
<br><i>&nbsp; perror("ioctl():SIOCGIFHWADDR");</i>
<br><i>&nbsp; return -1;</i>
<br><i>&nbsp;}</i>
<br><i>/*</i>
<br><i>&nbsp;sprintf(hwaddr,"%02x:%02x:%02x:%02x:%02x:%02x",</i>
<br><i>(int)(req.ifr_hwaddr.sa_data[0] &amp; 0xff),</i>
<br><i>(int)(req.ifr_hwaddr.sa_data[1] &amp; 0xff),</i>
<br><i>(int)(req.ifr_hwaddr.sa_data[2] &amp; 0xff),</i>
<br><i>(int)(req.ifr_hwaddr.sa_data[3] &amp; 0xff),</i>
<br><i>(int)(req.ifr_hwaddr.sa_data[4] &amp; 0xff),</i>
<br><i>(int)(req.ifr_hwaddr.sa_data[5] &amp; 0xff)); */</i>
<br><i>&nbsp; sprintf(hwaddr,"%d%d%d%d%d%d",</i>
<br><i>&nbsp;(int)(req.ifr_hwaddr.sa_data[0] &amp; 0xff),</i>
<br><i>&nbsp;(int)(req.ifr_hwaddr.sa_data[1] &amp; 0xff),</i>
<br><i>&nbsp;(int)(req.ifr_hwaddr.sa_data[2] &amp; 0xff),</i>
<br><i>&nbsp;(int)(req.ifr_hwaddr.sa_data[3] &amp; 0xff),</i>
<br><i>&nbsp;(int)(req.ifr_hwaddr.sa_data[4] &amp; 0xff),</i>
<br><i>&nbsp;(int)(req.ifr_hwaddr.sa_data[5] &amp; 0xff));</i>
<br><i>&nbsp;return 0;</i>
<br><i></i>&nbsp;<i></i>
<p><i>How can I make a good compilation ?</i>
<pre>--&nbsp;
Bertrand Bourdon - Chef de Projet Informatique
PerformanSe S.A., l'&eacute;valuation des comp&eacute;tences et des comportements&nbsp;
BP 703&nbsp; - 44481 Carquefou Cedex - T&eacute;l. : 02 28 01 55 13&nbsp;
<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>
&nbsp;</html>

--------------EC0BDEEC9BEEFE505448F653--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019