Hii everyone. My name is Lieyza. I'm a master student, and i have one task to be finish. Now, I need a help on my C programming coding. I have to send the Mac Address of the Client to the Server. I already do the socket programming but there is still a problem to show up the Mac Add at the Server. Here is my coding to get the Mac Address at the Client Side:
Code:
{
int sd, i;
float a_macadd1, a_macadd2, a_macadd3, a_macadd4, a_macadd5, a_macadd6;
struct ifreq ir;
sd=socket(PF_INET, SOCK_STREAM, 0);
memset(&ir, 0, sizeof(ir));
strcpy(ir.ifr_name, "wlan0");
ioctl(sd, SIOCGIFHADDR, &ir);
printf ( "The Mac Address is = %02d : %02d : %02d : %02d : %02d : %02d : %02d \n", ir.ifr_hwaddr.sa_data[0],
ir.ifr_hwaddr.sa_data[1],
ir.ifr_hwaddr.sa_data[2],
ir.ifr_hwaddr.sa_data[3],
ir.ifr_hwaddr.sa_data[4],
ir.ifr_hwaddr.sa_data[5]);
a_macadd1=ir.ifr_hwaddr.sa_data[0];
a_macadd2=ir.ifr_hwaddr.sa_data[1];
a_macadd3=ir.ifr_hwaddr.sa_data[2];
a_macadd4=ir.ifr_hwaddr.sa_data[3];
a_macadd5=ir.ifr_hwaddr.sa_data[4];
a_macadd6=ir.ifr_hwaddr.sa_data[5];
printf ( " Want to send = %02d : %02d : %02d : %02d : %02d : %02d : %02d \n, a_macadd1, a_macadd2, a_macadd3, a_macadd4, a_macadd5, a_macadd6);
}
Then, when i run it at terminal (Client Side) the answer show is like this:
The Mac Address is 00 : 19 : 02 : 11 : 52 : 34
Want to send 00 : 00 : 00 1077084160 : 00 : 1073741824
Then, the programming to show the Mac Add of the Client at the Server is like this :
Code:
{
float a_macadd1, a_macadd2, a_macadd3, a_macadd4, a_macadd5, a_macadd6;
......................
......................
printf (" The Mac Address of the Client is %02d : %02d : %02d : %02d : %02d : %02d : %02d \n, a_macadd1, a_macadd2, a_macadd3, a_macadd4, a_macadd5, a_macadd6);
}
and at the terminal, the answer show like this :
The Mac Address of the Client is 00 : -1090542844 : -2147483648 : -1090551438 : -2147483648 : -1074489359
why this happend? and when i run it again, it give a different answer like this :
The Mac Address of the Client is 00 : -1090582268 : -2147483648 : -10906518628 : -2147483648 : -1074489171
WHY? can anybody help me? how to write a coding using C programming to send the Mac address of the client to the server? i'm really need a help.. please help me.......
Lieyza