summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brown2006-12-05 00:40:35 +0100
committerMichael Brown2006-12-05 00:40:35 +0100
commitd9f32726b46665165b9004797aebd58c7f2b03f4 (patch)
treece200468c58ced411949813c4ef853eb28248e9b /src
parentAdded debug statements (diff)
downloadipxe-d9f32726b46665165b9004797aebd58c7f2b03f4.tar.gz
ipxe-d9f32726b46665165b9004797aebd58c7f2b03f4.tar.xz
ipxe-d9f32726b46665165b9004797aebd58c7f2b03f4.zip
Added quick and dirty commands for testing the new NVO code.
Diffstat (limited to 'src')
-rw-r--r--src/commandline/commands/nvo_cmd.c68
-rw-r--r--src/core/main.c2
-rw-r--r--src/core/nvo.c9
-rw-r--r--src/include/cmdlist.h6
4 files changed, 81 insertions, 4 deletions
diff --git a/src/commandline/commands/nvo_cmd.c b/src/commandline/commands/nvo_cmd.c
new file mode 100644
index 000000000..3eb0059ee
--- /dev/null
+++ b/src/commandline/commands/nvo_cmd.c
@@ -0,0 +1,68 @@
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <vsprintf.h>
+#include <command.h>
+#include <gpxe/nvo.h>
+#include <gpxe/dhcp.h>
+
+void nvo_cmd_req() {}
+
+extern struct nvo_block *ugly_nvo_hack;
+
+static int show_exec ( int argc, char **argv ) {
+
+ if ( ! ugly_nvo_hack ) {
+ printf ( "No non-volatile option storage available\n" );
+ return 1;
+ }
+
+ hex_dump ( ugly_nvo_hack->options->data,
+ ugly_nvo_hack->options->len );
+}
+
+struct command show_command __command = {
+ .name = "show",
+ .usage = "show\n",
+ .desc = "Show stored options",
+ .exec = show_exec,
+};
+
+static int set_exec ( int argc, char **argv ) {
+ unsigned long tag;
+ struct dhcp_option *option;
+
+ if ( ! ugly_nvo_hack ) {
+ printf ( "No non-volatile option storage available\n" );
+ return 1;
+ }
+
+ if ( argc != 3 ) {
+ printf ( "Syntax: %s <option number> <option string>\n",
+ argv[0] );
+ return 1;
+ }
+
+ tag = strtoul ( argv[1], NULL, 0 );
+ option = set_dhcp_option ( ugly_nvo_hack->options, tag, argv[2],
+ strlen ( argv[2] ) );
+ if ( ! option ) {
+ printf ( "Could not set option %ld\n", tag );
+ return 1;
+ }
+
+ if ( nvo_save ( ugly_nvo_hack ) != 0 ) {
+ printf ( "Could not save options to non-volatile storage\n" );
+ return 1;
+ }
+
+ return 0;
+}
+
+struct command set_command __command = {
+ .name = "set",
+ .usage = "set <option number> <option string>\n",
+ .desc = "Set stored option",
+ .exec = set_exec,
+};
diff --git a/src/core/main.c b/src/core/main.c
index e1ddc9dda..4a78d7511 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -157,8 +157,8 @@ int main ( void ) {
netdev = next_netdev ();
if ( netdev ) {
+ cmdl_start();
test_dhcp ( netdev );
- //cmdl_start();
} else {
printf ( "No network device found\n" );
}
diff --git a/src/core/nvo.c b/src/core/nvo.c
index 9949a48b4..0e88b8a75 100644
--- a/src/core/nvo.c
+++ b/src/core/nvo.c
@@ -28,6 +28,9 @@
*
*/
+#warning "Temporary hack"
+struct nvo_block *ugly_nvo_hack = NULL;
+
/**
* Calculate checksum over non-volatile stored options
*
@@ -83,7 +86,7 @@ int nvo_save ( struct nvo_block *nvo ) {
int rc;
/* Recalculate checksum */
- checksum -= nvo_checksum ( nvo );
+ *checksum -= nvo_checksum ( nvo );
/* Write data a fragment at a time */
for ( fragment = nvo->fragments ; fragment->len ; fragment++ ) {
@@ -182,6 +185,8 @@ int nvo_register ( struct nvo_block *nvo ) {
nvo_init_dhcp ( nvo );
register_dhcp_options ( nvo->options );
+ ugly_nvo_hack = nvo;
+
return 0;
err:
@@ -201,4 +206,6 @@ void nvo_unregister ( struct nvo_block *nvo ) {
free_dhcp_options ( nvo->options );
nvo->options = NULL;
}
+
+ ugly_nvo_hack = NULL;
}
diff --git a/src/include/cmdlist.h b/src/include/cmdlist.h
index 623cac765..33cd349b3 100644
--- a/src/include/cmdlist.h
+++ b/src/include/cmdlist.h
@@ -4,12 +4,14 @@
void test_req();
void test2_req();
void help_req();
+void nvo_cmd_req();
void commandlist()
{
- test_req();
- test2_req();
+ // test_req();
+ // test2_req();
help_req();
+ nvo_cmd_req();
}
#endif