+++ /dev/null
-#ifdef HAVE_NET_IF_H
-# include <net/if.h>
-#endif
-extern "C" { int socket ( int addr, int type, int protocol ); }
-/* phn:20/4/94:delete:begin:because not the same signature in </sys/ioctl.h> */
-/* extern "C" { int ioctl ( int d, unsigned long request, char *argp);} */
-/* phn:20/4/94:delete:end:because not the same signature in </sys/ioctl.h> */
-extern "C" { int close ( int filedes ); }
-
-
-Standard_CString Ethernet() {
- struct ifdevea devea;
- Standard_CString result;
- static char *ether_devices[] = {
- "qe0",
- "se0",
- "ln0",
- "de0",
- "ni0",
- NULL
- };
- char name[32];
- long *eth;
- int e[6]; // For byte to int conversions
- int sock, i;
-
- /* we need a socket */
- sock = socket (AF_INET, SOCK_DGRAM, 0);
- if (sock < 0) // Error : "Socket for Ethernet device localisation"
- return(result);
-
- /* loop until we find a device or we error out */
- for (i = 0; ether_devices[i] != NULL; i++) {
- /* setup the device name */
- strcpy (&devea.ifr_name[0], ether_devices[i]);
-
- /* read the interface address */
- /* phn:20/4/94:update:begin:because not the same signature in </sys/ioctl.h> */
- if (ioctl (sock, SIOCRPHYSADDR, &devea) < 0) { // error ?
- /* if (ioctl (sock, (unsigned long)SIOCRPHYSADDR, (char*) &devea) < 0) { */ // error ?
- /* phn:20/4/94:update:end:because not the same signature in </sys/ioctl.h> */
- if (errno == ENXIO) { // doesn't exist, try next device
- continue;
- } else { // unexpected error
- //perror (&devea.ifr_name[0]);
- return(result);
- }
- } else break; // found one, break out
- } /* for ... */
-
- close (sock);
-
- if (ether_devices[i] == NULL) // Error : no Ethernet device
- return(result);
-
- // unsigned char to int conversions
-
- e[0] = (unsigned char)devea.default_pa[0];
- e[1] = (unsigned char)devea.default_pa[1];
- e[2] = (unsigned char)devea.default_pa[2];
- e[3] = (unsigned char)devea.default_pa[3];
- e[4] = (unsigned char)devea.default_pa[4];
- e[5] = (unsigned char)devea.default_pa[5];
-
- sprintf(name,"%x:%x:%x:%x:%x:%x",e[0],e[1],e[2],e[3],e[4],e[5]);
- result = name;
- return(result);
-
-}
-