Thread: Implement get HWAddress

  1. #1
    Registered User
    Join Date
    Mar 2011

    Exclamation Implement get HWAddress

    Hi, I'm new here, I need some little help here, I have this code and I need get the MAC ADDRESS too, I tried few ways, but I dont had lucky.

    #include <sys/ioctl.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <net/if.h>
    int main()
      struct ifconf conf;
      struct sockaddr_in *s_in;
      int sock, i, count;
      // Abrir um socket nulo
      if ((sock = socket(PF_INET, SOCK_DGRAM, 0)) == -1)
         perror("erro ao abrir o socket.");
         return -1;
      // Pega lista de interfaces de rede, so os 10 primeiros.
      memset(&conf, 0, sizeof(conf));
      conf.ifc_len = sizeof(struct ifreq) * 10;
      conf.ifc_buf = (char*) malloc(conf.ifc_len);
      if (ioctl(sock, SIOCGIFCONF, &conf) == -1)
         perror("falha ao pegar a lista de interfaces de rede");
         return -1;
      count = conf.ifc_len / sizeof(struct ifreq);
      for (i = 0; i < count; i++)
         s_in = (struct sockaddr_in*) &conf.ifc_req[i].ifr_addr;
         printf("%s %s\n", conf.ifc_req[i].ifr_name,
      return 0;
    thanks in advance.

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Searching for an answer is out of the question?
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 09-02-2010, 01:26 PM
  2. Replies: 4
    Last Post: 12-20-2007, 06:55 PM
  3. Implement "Whats This" using Win32
    By hemanth.balaji in forum Windows Programming
    Replies: 1
    Last Post: 05-29-2005, 06:03 AM
  4. implement hash program
    By Abdi in forum C Programming
    Replies: 2
    Last Post: 05-18-2002, 11:22 PM
  5. Can't Implement Tabbing
    By Invincible in forum Windows Programming
    Replies: 10
    Last Post: 02-27-2002, 04:09 AM
Website Security Test