[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[PATCH] Add the ibft routines
- From: Martin Sivak <msivak redhat com>
- To: anaconda-devel-list redhat com
- Cc:
- Subject: [PATCH] Add the ibft routines
- Date: Tue, 2 Sep 2008 18:20:56 +0200
---
loader2/ibft.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
loader2/ibft.h | 43 ++++++++++++++++++++++
2 files changed, 150 insertions(+), 0 deletions(-)
create mode 100644 loader2/ibft.c
create mode 100644 loader2/ibft.h
diff --git a/loader2/ibft.c b/loader2/ibft.c
new file mode 100644
index 0000000..1699bfe
--- /dev/null
+++ b/loader2/ibft.c
@@ -0,0 +1,107 @@
+/*
+ File name: ibft.c
+ Date: 2008/09/02
+ Author: Martin Sivak <msivak redhat com>
+
+ Copyright (C) 2008 Red Hat
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ in a file called COPYING along with this program; if not, write to
+ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
+ 02139, USA.
+*/
+
+
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <fw_context.h>
+#include <fwparam_ibft.h>
+
+#include "ibft.h"
+
+struct boot_context ibft_context;
+int ibft_present = 0;
+int ibft_initialized = 0;
+
+int ibft_init(void)
+{
+ int ret;
+
+ memset(&ibft_context, 0, sizeof(ibft_context));
+
+ ret = fwparam_ibft_sysfs(&ibft_context, NULL);
+
+ /* ret == 0 -> OK */
+ ibft_present = !ret;
+ ibft_initialized = 1;
+
+ return ibft_initialized;
+}
+
+/* Is iBFT available on this system */
+int ibft_present()
+{
+ if(!ibft_initialized)
+ ibft_init();
+
+ return ibft_present;
+}
+
+/* Is the iBFT network configured to use DHCP */
+int ibft_iface_dhcp()
+{
+ if(!ibft_initialized)
+ ibft_init();
+
+ if(!ibft_present)
+ return -1;
+
+ return (strlen(ibft_context->dhcp) && strcmp(ibft_context->dhcp, "0.0.0.0"));
+}
+
+#define ibft_iface_charfunc(name, var) char* ibft_iface_##name()\
+{\
+ if(!ibft_initialized)\
+ ibft_init();\
+\
+ if(!ibft_present)\
+ return NULL;\
+\
+ if(!strlen(ibft_context->var))\
+ return NULL;\
+\
+ return ibft_context->var;\
+}
+
+
+/* Get the iBFT MAC address */
+ibft_iface_charfunc(mac, mac)
+
+/* Get the iBFT ip address */
+ibft_iface_charfunc(ip, ipaddress)
+
+/* Get the iBFT subnet mask */
+ibft_iface_charfunc(mask, subnet_mask)
+
+/* Get the iBFT gateway */
+ibft_iface_charfunc(gw, gateway)
+
+/* Get the iBFT iface name */
+ibft_iface_charfunc(iface, iface)
+
+/* Get the iBFT dns servers */
+ibft_iface_charfunc(dns1, primary_dns)
+ibft_iface_charfunc(dns2, secondary_dns)
+
diff --git a/loader2/ibft.h b/loader2/ibft.h
new file mode 100644
index 0000000..b35626b
--- /dev/null
+++ b/loader2/ibft.h
@@ -0,0 +1,43 @@
+/*
+ File name: ibft.h
+ Date: 2008/09/02
+ Author: Martin Sivak
+
+ Copyright (C) 2008 Red Hat
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ in a file called COPYING along with this program; if not, write to
+ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
+ 02139, USA.
+*/
+
+
+#ifndef __IBFT_H__
+#define __IBFT_H__
+
+
+int ibft_init();
+int ibft_present();
+
+char* ibft_iface_mac();
+char* ibft_iface_ip();
+char* ibft_iface_mask();
+char* ibft_iface_gw();
+char* ibft_iface_iface();
+char* ibft_iface_dns1();
+char* ibft_iface_dns2();
+
+
+#endif
+
+/* end of ibft.h */
--
1.5.4.1
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]