+++ /dev/null
-#include <net/if.h>
-#include <net/raw.h>
- Standard_CString Ethernet() {
- Standard_CString result;
- static char *ether_devices[]={
- "ec0",
- "enp0",
- "et0",
- "fxp0",
- NULL
- };
- int sock,i;
- int e[6];
- struct ifreq ifreq;
- static char buffer[16];
-
- sock = socket(AF_RAW,SOCK_RAW,RAWPROTO_DRAIN);
- if (sock < 0) /* Error : "drain_open:could not open socket" */
- return(result);
-
- for (i=0; ether_devices[i] != NULL; i++){
- strcpy(ifreq.ifr_name, ether_devices[i]); /* Puts name */
-
- if (ioctl(sock, SIOCGIFADDR, (char *) &ifreq) < 0)
- if (errno == ENXIO) continue;
- else /* Error : "drain:getmyaddr:cannot get raw address" */
- return(result);
- }
-
- e[0] = (unsigned char)ifreq.ifr_addr.sa_data[0];
- e[1] = (unsigned char)ifreq.ifr_addr.sa_data[1];
- e[2] = (unsigned char)ifreq.ifr_addr.sa_data[2];
- e[3] = (unsigned char)ifreq.ifr_addr.sa_data[3];
- e[4] = (unsigned char)ifreq.ifr_addr.sa_data[4];
- e[5] = (unsigned char)ifreq.ifr_addr.sa_data[5];
-
- sprintf(buffer,"%x:%x:%x:%x:%x:%x", e[0],e[1],e[2],e[3],e[4],e[5]);
- close(sock);
-
- result = buffer;
- return(result);
-}
-