diff options
author | David Cantrell <dcantrell@redhat.com> | 2006-05-26 15:20:36 +0000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2006-05-26 15:20:36 +0000 |
commit | 62987426f1dba21702b4713a1003d7710638ead3 (patch) | |
tree | da110390095588a7098fbe4c0c9768ee806f1ada /isys | |
parent | 4bd1ee4fa61bc3d58bc2ee9fa7ec67856516d543 (diff) | |
download | anaconda-62987426f1dba21702b4713a1003d7710638ead3.tar.gz anaconda-62987426f1dba21702b4713a1003d7710638ead3.tar.xz anaconda-62987426f1dba21702b4713a1003d7710638ead3.zip |
* isys/Makefile: Remove getmacaddr references. Add glib CFLAGS and
LDFLAGS.
* isys/getmacaddr.c: Removed.
* isys/getmacaddr.h: Removed.
* isys/isys.c: Call netlink_interfaces_mac2str() in doGetMacAddress.
* isys/nl.c (netlink_format_mac_addr): Malloc space for buf if it's
NULL when we enter the function.
* isys/nl.c (netlink_interfaces_mac2str): Return buffer malloc is
handled by netlink_format_mac_addr).
* loader2/Makefile: Add glib CFLAGS and LDFLAGS.
* loader2/net.c: Call netlink_format_mac_addr() and
netlink_interfaces_mac2str().
* loader2/urlinstall.c: Call netlink_interfaces_mac2str() instead of
getMacAddr().
Diffstat (limited to 'isys')
-rw-r--r-- | isys/Makefile | 4 | ||||
-rw-r--r-- | isys/getmacaddr.c | 81 | ||||
-rw-r--r-- | isys/getmacaddr.h | 6 | ||||
-rw-r--r-- | isys/isys.c | 5 | ||||
-rw-r--r-- | isys/nl.c | 14 |
5 files changed, 12 insertions, 98 deletions
diff --git a/isys/Makefile b/isys/Makefile index 3ebb0e9b5..36c0b530b 100644 --- a/isys/Makefile +++ b/isys/Makefile @@ -2,7 +2,7 @@ include ../Makefile.inc CFLAGS += -I$(PYTHONINCLUDE) -I.. -DHAVE_NFS -OBJECTS = nfsmount.o nfsmount_clnt.o nfsmount_xdr.o imount.o getmacaddr.o \ +OBJECTS = nfsmount.o nfsmount_clnt.o nfsmount_xdr.o imount.o \ smp.o devnodes.o cpio.o uncpio.o dasd.o \ lang.o isofs.o dns.o linkdetect.o vio.o \ ethtool.o getipaddr.o wireless.o eddsupport.o \ @@ -15,7 +15,7 @@ PYMODULES = _isys.so SUBDIRS = gzlib DIET = diet -# using glib +# glib LOADLIBES += $(shell pkg-config --libs glib-2.0) CFLAGS += $(shell pkg-config --cflags glib-2.0) diff --git a/isys/getmacaddr.c b/isys/getmacaddr.c deleted file mode 100644 index de923819f..000000000 --- a/isys/getmacaddr.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * getmacaddr.c - get mac address for ethernet interface - * - * Copyright 2003-2004 Red Hat, Inc. - * - * Michael Fulbright <msf@redhat.com> - * Jeremy Katz <katzj@redhat.com> - * - * This software may be freely redistributed under the terms of the GNU - * general public license. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#include <sys/ioctl.h> -#include <net/if.h> - -/* returns NULL or allocated string */ -char *getMacAddr(char *ifname) { - int i; - int sock; - char *rcstr; - struct ifreq ifr; - - if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - return NULL; - - /* Setup our control structures. */ - memset(&ifr, 0, sizeof(ifr)); - strcpy(ifr.ifr_name, ifname); - - if (ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) - return NULL; - - rcstr = (char *) malloc(24); - *rcstr = '\0'; - for (i=0; i<6; i++) { - char tmp[4]; - sprintf(tmp, "%02X",(unsigned char)ifr.ifr_hwaddr.sa_data[i]); - strcat(rcstr,tmp); - if (i != 5) - strcat(rcstr, ":"); - } - - return rcstr; -} - -/* returns NULL or allocated string */ -char * sanitizeMacAddr(char * hwaddr) { - char * rcstr; - int i = 0, j = 0; - - if (!hwaddr) - return NULL; - rcstr = (char *) malloc(24); - for (i = 0; hwaddr[i] && (j < 24); i++) { - if (isdigit(hwaddr[i])) - rcstr[j++] = hwaddr[i]; - else if (('A' <= hwaddr[i]) && ('F' >= hwaddr[i])) - rcstr[j++] = hwaddr[i]; - else if (('a' <= hwaddr[i]) && ('f' >= hwaddr[i])) - rcstr[j++] = toupper(hwaddr[i]); - } - rcstr[j] = '\0'; - - return rcstr; -} - -#ifdef TESTING -int main() { - - printf("%s\n", getMacAddr("eth0")); -} -#endif diff --git a/isys/getmacaddr.h b/isys/getmacaddr.h deleted file mode 100644 index a4d374559..000000000 --- a/isys/getmacaddr.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __GET_MAC_ADDR_H__ -#define __GET_MAC_ADDR_H__ -char *getMacAddr(char *ifname); -char *sanitizeMacAddr(char * hwaddr); -#endif - diff --git a/isys/isys.c b/isys/isys.c index a25d39b05..5359987d9 100644 --- a/isys/isys.c +++ b/isys/isys.c @@ -49,13 +49,12 @@ #include <signal.h> #include <execinfo.h> - +#include "nl.h" #include "imount.h" #include "isys.h" #include "net.h" #include "smp.h" #include "lang.h" -#include "getmacaddr.h" #include "wireless.h" #include "eddsupport.h" @@ -1264,7 +1263,7 @@ static PyObject * doGetMacAddress(PyObject * s, PyObject * args) { if (!PyArg_ParseTuple(args, "s", &dev)) return NULL; - ret = getMacAddr(dev); + ret = netlink_interfaces_mac2str(dev); return Py_BuildValue("s", ret); } @@ -45,6 +45,13 @@ static GSList *interfaces = NULL; char *netlink_format_mac_addr(char *buf, unsigned char *mac) { int i; + if (buf == NULL) { + if ((buf = malloc(20)) == NULL) { + perror("malloc in netlink_format_mac_addr"); + return NULL; + } + } + sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); @@ -361,7 +368,7 @@ int netlink_init_interfaces_list(void) { * on error. */ char *netlink_interfaces_mac2str(char *ifname) { - char *ret; + char *ret = NULL; GSList *e; interface_info_t *intf; @@ -380,11 +387,6 @@ char *netlink_interfaces_mac2str(char *ifname) { if (e == NULL) { return NULL; } else { - if ((ret=malloc(20)) == NULL) { - perror("malloc in netlink_interfaces_mac2str"); - return NULL; - } - intf = (interface_info_t *) e->data; ret = netlink_format_mac_addr(ret, intf->mac); return ret; |