]> Creatis software - gdcm.git/commitdiff
STYLE: Fix some comment also rework the include stuff
authormalaterre <malaterre>
Sat, 15 Jan 2005 22:40:23 +0000 (22:40 +0000)
committermalaterre <malaterre>
Sat, 15 Jan 2005 22:40:23 +0000 (22:40 +0000)
CMakeLists.txt
gdcmConfigure.h.in
src/gdcmUtil.cxx

index 12d11f997f8dca69ca2cae8d5a04212593018d0c..af56a03a3629481ef5ac0acba85bdbef23a46669 100644 (file)
@@ -108,6 +108,7 @@ CHECK_INCLUDE_FILE("sys/sockio.h"   CMAKE_HAVE_SYS_SOCKIO_H)
 CHECK_INCLUDE_FILE("net/if.h"       CMAKE_HAVE_NET_IF_H)
 CHECK_INCLUDE_FILE("netinet/in.h"   CMAKE_HAVE_NETINET_IN_H)
 CHECK_INCLUDE_FILE("net/if_dl.h"    CMAKE_HAVE_NET_IF_DL_H)
+CHECK_INCLUDE_FILE("net/if_arp.h"   CMAKE_HAVE_NET_IF_ARP_H)
 
 CONFIGURE_FILE(${GDCM_SOURCE_DIR}/gdcmConfigure.h.in
                ${GDCM_BINARY_DIR}/gdcmConfigure.h @ONLY IMMEDIATE)
index 83297de2f3fe866c4df58bf9ed6b40c3f47ab0c4..061b6072c1ce60af0b1e1156e96d23ec5f0fc131 100644 (file)
@@ -47,6 +47,7 @@
 #cmakedefine CMAKE_HAVE_NET_IF_H
 #cmakedefine CMAKE_HAVE_NETINET_IN_H
 #cmakedefine CMAKE_HAVE_NET_IF_DL_H
+#cmakedefine CMAKE_HAVE_NET_IF_ARP_H
 
 
 /*--------------------------------------------------------------------------*/
index 559b21ee0be8ab6ab5fc2f11f28799d73b1844c3..d5be4c01b57447c901280546bcc9e1cf12e48e72 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/15 22:19:10 $
-  Version:   $Revision: 1.95 $
+  Date:      $Date: 2005/01/15 22:40:23 $
+  Version:   $Revision: 1.96 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include <sys/types.h>
 #endif
 
-#ifdef __sun
-//#include <time.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#include <net/if_arp.h>
-#else
-//#include <fcntl.h>
-//#include <errno.h>
-//#include <sys/time.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#endif //__sun
-
 // How do I do that in CMake ?
 #ifdef __APPLE__
 #define HAVE_SA_LEN
 #ifdef CMAKE_HAVE_NET_IF_DL_H
 #include <net/if_dl.h>
 #endif
-
+#if defined(CMAKE_HAVE_NET_IF_ARP_H) && defined(__sun)
+// This is absolutely necesseray on SunOS
+#include <net/if_arp.h>
+#endif
 
 namespace gdcm 
 {
@@ -626,6 +616,11 @@ long GetMacAddrSys ( unsigned char *addr)
       a = (unsigned char *) &ifr.ifr_hwaddr.sa_data;
 #else
 #ifdef SIOCGENADDR
+      // In theory this call should also work on Sun Solaris, but apparently
+      // SIOCGENADDR is not implemented properly thus the call 
+      // ioctl(sd, SIOCGENADDR, &ifr) always returns errno=2 
+      // (No such file or directory)
+      // Furthermore the DLAPI seems to require full root access
       if (ioctl(sd, SIOCGENADDR, &ifr) < 0)
          continue;
       a = (unsigned char *) ifr.ifr_enaddr;
@@ -663,10 +658,11 @@ long GetMacAddrSys ( unsigned char *addr)
 
 std::string Util::GetMACAddress()
 {
-   // This is a rip from: http://cplus.kompf.de/macaddr.html for Linux/CYGWIN, HPUX and AIX 
-   // and http://tangentsoft.net/wskfaq/examples/src/snmpmac.cpp for windows version
-   // and http://groups-beta.google.com/group/sol.lists.freebsd.hackers/msg/0d0f862e05fce6c0 for the FreeBSD version
-   // and http://developer.apple.com/samplecode/GetPrimaryMACAddress/GetPrimaryMACAddress.html for MacOSX version
+   // This code is the result of a long internet search to find something
+   // as compact as possible (not OS independant). We only have to separate
+   // 3 OS: Win32, SunOS and 'real' POSIX
+   // http://groups-beta.google.com/group/comp.unix.solaris/msg/ad36929d783d63be
+   // http://bdn.borland.com/article/0,1410,26040,00.html
    u_char addr[6];
    std::string macaddr;