PATCH: Re: [Bug 1572] Malformed else, use of obsolete ifreq structure/union and missing getInterfaceAddrByName in ifenum.c

Marcus Meissner marcus at jet.franken.de
Sat Jan 3 15:27:12 CST 2004


On Sat, Jan 03, 2004 at 11:06:17PM +1100, Alan Hargreaves wrote:
> I believe that I sent in a patch to the alias quite some time ago....

It was never applied... Rediffed against current CVS...

Alexandre?

Ciao, Marcus

> Wine Bugs wrote:
> >http://bugs.winehq.com/show_bug.cgi?id=1572

> Patch redone with diff -u.
> 
> alan.
> 
> 
> This is to fix a number of build problems under Solaris. There still
> appears to be a problem with ptrace in the server code that is
> preventing a build. I am looking at this.
> 
> I am using defined(__sun) as for the most part thes patches go into code 
> which is already inside a defined(__sun) || defined(something else) || 
> defined(something else again).
> 
> alan.
> =========
> 
> 
> Alan Hargreaves - Alan.Hargreaves at Sun.COM
> 
> wine/dlls/ntdll/signal_i386.c
>     Bug 1569
>     - Cast needed for FAULT_ADDRESS in Solaris
> 
> wine/dlls/iphlpapi/ifenum.c
>     Bug 1572
>     - Brace in incorrect place makes an if else clause malformed
>     - struct ifreq has been deprecated in Solaris and also does
>       not have an element for ifr_mtu. Inserted a replacement
>       getInterfaceMtuByName if __sun is defined. This version uses
>       struct lifreq.
>     - Solaris does not implement getInterfaceAddrByName. Added this
>       routine to be used if __sun is defined.
> 

Index: dlls/ntdll/signal_i386.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/signal_i386.c,v
retrieving revision 1.82
diff -u -r1.82 signal_i386.c
--- dlls/ntdll/signal_i386.c	8 Dec 2003 21:58:55 -0000	1.82
+++ dlls/ntdll/signal_i386.c	3 Jan 2004 21:25:48 -0000
@@ -370,7 +370,11 @@
 #define TRAP_sig(context)     ((context)->uc_mcontext.gregs[TRAPNO])
 #endif
 
+#ifdef __sun
+#define FAULT_ADDRESS         (((k_siginfo_t *)__siginfo)->si_addr)
+#else
 #define FAULT_ADDRESS         (__siginfo->si_addr)
+#endif
 
 #endif  /* svr4 || SCO_DS */
 
Index: dlls/iphlpapi/ifenum.c
===================================================================
RCS file: /home/wine/wine/dlls/iphlpapi/ifenum.c,v
retrieving revision 1.8
diff -u -r1.8 ifenum.c
--- dlls/iphlpapi/ifenum.c	30 Nov 2003 06:03:21 -0000	1.8
+++ dlls/iphlpapi/ifenum.c	3 Jan 2004 21:25:49 -0000
@@ -646,6 +646,34 @@
   return ret;
 }
 #elif defined (SIOCGARP)
+#ifdef __sun
+
+/* Solaris does not define getInterfaceAddrByName */
+
+uint32_t getInterfaceAddrByName(const char * name)
+{
+  int fd;
+  struct ifreq ifr;
+  struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr;
+  uint32_t ret = (uint32_t)NULL;
+
+  fd = socket(PF_INET, SOCK_DGRAM, 0);
+
+  if (fd < 0) {
+    return ret;
+  }
+
+  memset(&ifr, 0, sizeof(struct ifreq));
+  strncpy(ifr.ifr_name, name, IFNAMSIZ);
+  ifr.ifr_name[IFNAMSIZ-1] = '\0';
+  if ((ioctl(fd, SIOCGIFADDR, &ifr))>=0) {
+    ret = ntohl(sin->sin_addr.s_addr);
+  }
+  close(fd);
+  return ret;
+}
+#endif /* __sun */
+
 DWORD getInterfacePhysicalByName(const char *name, PDWORD len, PBYTE addr,
  PDWORD type)
 {
@@ -694,10 +722,8 @@
       }
     }
     close(fd);
-  }
-    else
+  } else
       ret = ERROR_NO_MORE_FILES;
-
   return ret;
 }
 #elif defined (HAVE_SYS_SYSCTL_H) && defined (HAVE_NET_IF_DL_H)
@@ -802,6 +828,38 @@
     return ERROR_INVALID_DATA;
 }
 
+#if defined(__sun)
+
+DWORD getInterfaceMtuByName(const char *name, PDWORD mtu)
+{
+  DWORD ret;
+  int fd;
+
+  if (!name)
+    return ERROR_INVALID_PARAMETER;
+  if (!mtu)
+    return ERROR_INVALID_PARAMETER;
+
+  fd = socket(PF_INET, SOCK_DGRAM, 0);
+  if (fd != -1) {
+    struct lifreq ifr;
+
+    strncpy(ifr.lifr_name, name, IFNAMSIZ);
+    ifr.lifr_name[IFNAMSIZ-1] = '\0';
+    if ((ioctl(fd, SIOCGIFMTU, &ifr)))
+      ret = ERROR_INVALID_DATA;
+    else {
+      *mtu = ifr.lifr_mtu;
+      ret = NO_ERROR;
+    }
+  }
+  else
+    ret = ERROR_NO_MORE_FILES;
+  return ret;
+}
+
+#else /* defined(__sun) */
+
 DWORD getInterfaceMtuByName(const char *name, PDWORD mtu)
 {
   DWORD ret;
@@ -829,6 +887,7 @@
     ret = ERROR_NO_MORE_FILES;
   return ret;
 }
+#endif
 
 DWORD getInterfaceMtuByIndex(DWORD index, PDWORD mtu)
 {



More information about the wine-bugs mailing list