BACKRUSH  À¯´Ð½º¸í·É  ´ÙÀ½  ÀÚ·á½Ç  Ascii Table   ¿ø°ÝÁ¢¼Ó  ´Þ·Â,½Ã°£   ÇÁ·Î¼¼½º   ½©
ÁöÇÏö³ë¼±   RFC¹®¼­   SUN FAQ   SUN FAQ1   C¸Þ´º¾ó   PHP¸Þ´º¾ó   ³Ê±¸¸®   ¾Æ½ºÅ°¿ùµå ¾ÆÀÌÇǼ­Ä¡

±Û¾´ÀÌ: mac mac address ¾Ë¾Æ³»±â Á¶È¸¼ö: 15609


http://kldp.org/KoreanDoc/html/Programming_tip-KLDP/x43.html#AEN115

#include <netinet/ether.h>
#include <net/ethernet.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <stdio.h>

int main (int argc, char *argv[])
{
struct ifreq *iflist;
struct sockaddr *sa;
int fd;
char *out;

if(argc != 2)
{
printf("Usage: progname ifname (ex: progname eth0)\n");
return -1;
}

iflist = malloc (sizeof (struct ifreq));

fd = socket (PF_INET, SOCK_STREAM, 0);

strncpy (iflist->ifr_name, argv[1], strlen (argv[1]));

if (ioctl (fd, SIOCGIFHWADDR, iflist) == -1)
{
perror ("ioctl failed");
return -1;
}

sa = &(iflist->ifr_hwaddr);

out = ether_ntoa ((struct ether_addr *) sa->sa_data);

printf ("%s\n", out);

return 0;
}


°ü·Ã±Û : ¾øÀ½ ±Û¾´½Ã°£ : 2003/02/28 9:15 from 218.154.16.38

  2.4.18-14 ¿¡¼­ sys_call_table Áú¹®ÀÌ¿ä ¸ñ·Ïº¸±â »õ±Û ¾²±â Áö¿ì±â ÀÀ´ä±Û ¾²±â ±Û ¼öÁ¤ fork Å×½ºÆ® ÇÁ·Î±×·¥  
BACKRUSH  À¯´Ð½º¸í·É  ´ÙÀ½  ÀÚ·á½Ç  Ascii Table   ¿ø°ÝÁ¢¼Ó  ´Þ·Â,½Ã°£   ÇÁ·Î¼¼½º   ½©
ÁöÇÏö³ë¼±   RFC¹®¼­   SUN FAQ   SUN FAQ1   C¸Þ´º¾ó   PHP¸Þ´º¾ó   ³Ê±¸¸®   ¾Æ½ºÅ°¿ùµå ¾ÆÀÌÇǼ­Ä¡