Re: net kickstarts using HW address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



While I think it is the case that I'll always be on the same subnet as the
boot server, I'm not sure that I want to depend on this.  Also, I'm currently
still only using RH7.1, and I didn't think I saw anything in the 7.1 code to
support http (though I haven't tried it yet).

Anyway, I came up with some sample code to print my hardware address, and it
should drop right into loader.c.  Here it is, for anyone who's interested:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
#include <sys/ioctl.h>
#include <net/ethernet.h>
#include <linux/if.h>

main() {
  int fd = socket(AF_INET, SOCK_DGRAM, 0);
  int i=0;
  struct ifreq ifr;
  memset(&ifr, 0, sizeof(ifr));
  strncpy(ifr.ifr_name, "eth0", sizeof(ifr.ifr_name));
  ioctl(fd, SIOCGIFHWADDR, (char*)&ifr);
  close(fd);
  while (i < ETHER_ADDR_LEN)
    printf("%02X", (unsigned char) ifr.ifr_hwaddr.sa_data[i++]);
  printf("\n");
}





[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux