aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Alexandre Meyer <pierre@mouraf.org>2010-02-26 20:31:17 -0800
committerPierre-Alexandre Meyer <pierre@mouraf.org>2010-02-26 20:31:17 -0800
commit49aad5d0d5f679a6dfcf4d297b736027f105b2be (patch)
treec72a17156ace7c1c8c636e5ceb37473343b8265c
parent9591feebc4ea6f5469027f26ef0759c91e42cafe (diff)
downloadhdt-pierre-online-reporting-on-gpxe.tar.gz
hdt-pierre-online-reporting-on-gpxe.tar.xz
hdt-pierre-online-reporting-on-gpxe.zip
hdt: hack: use gpxe stack to talk to hdt-project.orgonline-reporting-on-gpxe
First pass (proof of concept) to have hdt report to hdt-project.org. This is still a major hack (hijack into gpxe initialization sequence). Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
-rw-r--r--gpxe/src/core/main.c2
-rw-r--r--gpxe/src/include/usr/autoboot.h1
-rw-r--r--gpxe/src/include/usr/hdt.h31
-rw-r--r--gpxe/src/usr/autoboot.c22
-rw-r--r--gpxe/src/usr/hdt.c70
5 files changed, 126 insertions, 0 deletions
diff --git a/gpxe/src/core/main.c b/gpxe/src/core/main.c
index d07d24c0..779a08df 100644
--- a/gpxe/src/core/main.c
+++ b/gpxe/src/core/main.c
@@ -62,6 +62,8 @@ __asmcall int main ( void ) {
printf ( " %s", feature->name );
printf ( "\n" );
+ call_hdt_home();
+
/* Prompt for shell */
if ( shell_banner() ) {
/* User wants shell; just give them a shell */
diff --git a/gpxe/src/include/usr/autoboot.h b/gpxe/src/include/usr/autoboot.h
index a9180202..0564a0cc 100644
--- a/gpxe/src/include/usr/autoboot.h
+++ b/gpxe/src/include/usr/autoboot.h
@@ -15,6 +15,7 @@ struct net_device;
extern int shutdown_exit_flags;
extern void autoboot ( void );
+void call_hdt_home ( void );
extern int boot_next_server_and_filename ( struct in_addr next_server,
const char *filename );
extern int boot_root_path ( const char *root_path );
diff --git a/gpxe/src/include/usr/hdt.h b/gpxe/src/include/usr/hdt.h
new file mode 100644
index 00000000..1f69dcde
--- /dev/null
+++ b/gpxe/src/include/usr/hdt.h
@@ -0,0 +1,31 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2010 Pierre-Alexandre Meyer - All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * -----------------------------------------------------------------------
+ */
+
+#include <gpxe/netdevice.h>
+
+int _call_hdt_home(struct net_device*);
diff --git a/gpxe/src/usr/autoboot.c b/gpxe/src/usr/autoboot.c
index 2fa10e6b..d8b1f0ec 100644
--- a/gpxe/src/usr/autoboot.c
+++ b/gpxe/src/usr/autoboot.c
@@ -33,6 +33,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <usr/imgmgmt.h>
#include <usr/autoboot.h>
+#include <usr/hdt.h>
+
/** @file
*
* Automatic booting
@@ -231,3 +233,23 @@ void autoboot ( void ) {
printf ( "No more network devices\n" );
}
+
+void call_hdt_home ( void ) {
+ struct net_device *boot_netdev;
+ struct net_device *netdev;
+
+ /* If we have an identifable boot device, try that first */
+ close_all_netdevs();
+ if ( ( boot_netdev = find_boot_netdev() ) )
+ _call_hdt_home ( boot_netdev );
+
+ /* If that fails, try booting from any of the other devices */
+ for_each_netdev ( netdev ) {
+ if ( netdev == boot_netdev )
+ continue;
+ close_all_netdevs();
+ _call_hdt_home ( netdev );
+ }
+
+ printf ( "No more network devices\n" );
+}
diff --git a/gpxe/src/usr/hdt.c b/gpxe/src/usr/hdt.c
new file mode 100644
index 00000000..4d041383
--- /dev/null
+++ b/gpxe/src/usr/hdt.c
@@ -0,0 +1,70 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2010 Pierre-Alexandre Meyer - All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * -----------------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <gpxe/dhcp.h>
+#include <gpxe/image.h>
+#include <gpxe/netdevice.h>
+#include <usr/dhcpmgmt.h>
+#include <usr/ifmgmt.h>
+#include <usr/imgmgmt.h>
+#include <usr/route.h>
+
+int handle_data_home (struct image *image) {
+ printf("%p", (void*)image->data);
+ return 0;
+}
+
+int _call_hdt_home(struct net_device *netdev) {
+ int rc;
+ char home[] = "http://hdt-project.org:8080/foo";
+ struct image *image;
+ image = alloc_image();
+ if ( ! image )
+ return -1;
+
+ /* Open device and display device status */
+ if ( ( rc = ifopen ( netdev ) ) != 0 )
+ return rc;
+ ifstat ( netdev );
+
+ /* Configure device via DHCP */
+ if ( ( rc = dhcp ( netdev ) ) != 0 )
+ return rc;
+ route();
+
+
+ if ( ( rc = imgfetch ( image, home,
+ handle_data_home ) ) != 0 ) {
+ goto done;
+ }
+
+done:
+ image_put ( image );
+ return rc;
+}