敬告遊客:
以下內容枯燥無聊,若情非得已不建議進入。
若仍執意進入,當有頭暈嘔吐現象時請盡速離開本篇文章。


#include <sys/types.h>
#include <sys/socket.h>
#include
#include <sys/ioctl.h>
#include
#include <linux/if.h>

int main ()
{
int fd;
struct ifreq ifr;
int i;
unsigned char *j;
fd = socket (AF_INET, SOCK_DGRAM, 0);
strcpy (ifr.ifr_name, "eth0");

if (ioctl (fd, SIOCGIFHWADDR, &ifr) < 0)
{
puts ("error");
}
else
{
j = ifr.ifr_hwaddr.sa_data;
for (i = 0; i < 6; i++, j++)
printf ("%02x:", (*j));





}

arrow
arrow
    文章標籤
    get MAC
    全站熱搜

    calories 發表在 痞客邦 留言(0) 人氣()