3 Standard_CString Ethernet() {
4 Standard_CString result;
5 static char *ether_devices[]={
15 static char buffer[16];
17 sock = socket(AF_RAW,SOCK_RAW,RAWPROTO_DRAIN);
18 if (sock < 0) /* Error : "drain_open:could not open socket" */
21 for (i=0; ether_devices[i] != NULL; i++){
22 strcpy(ifreq.ifr_name, ether_devices[i]); /* Puts name */
24 if (ioctl(sock, SIOCGIFADDR, (char *) &ifreq) < 0)
25 if (errno == ENXIO) continue;
26 else /* Error : "drain:getmyaddr:cannot get raw address" */
30 e[0] = (unsigned char)ifreq.ifr_addr.sa_data[0];
31 e[1] = (unsigned char)ifreq.ifr_addr.sa_data[1];
32 e[2] = (unsigned char)ifreq.ifr_addr.sa_data[2];
33 e[3] = (unsigned char)ifreq.ifr_addr.sa_data[3];
34 e[4] = (unsigned char)ifreq.ifr_addr.sa_data[4];
35 e[5] = (unsigned char)ifreq.ifr_addr.sa_data[5];
37 sprintf(buffer,"%x:%x:%x:%x:%x:%x", e[0],e[1],e[2],e[3],e[4],e[5]);