mirror of https://github.com/ipxe/ipxe.git
Added quick and dirty commands for testing the new NVO code.
parent
6b45947a59
commit
d9f32726b4
|
@ -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,
|
||||||
|
};
|
|
@ -157,8 +157,8 @@ int main ( void ) {
|
||||||
|
|
||||||
netdev = next_netdev ();
|
netdev = next_netdev ();
|
||||||
if ( netdev ) {
|
if ( netdev ) {
|
||||||
|
cmdl_start();
|
||||||
test_dhcp ( netdev );
|
test_dhcp ( netdev );
|
||||||
//cmdl_start();
|
|
||||||
} else {
|
} else {
|
||||||
printf ( "No network device found\n" );
|
printf ( "No network device found\n" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#warning "Temporary hack"
|
||||||
|
struct nvo_block *ugly_nvo_hack = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate checksum over non-volatile stored options
|
* Calculate checksum over non-volatile stored options
|
||||||
*
|
*
|
||||||
|
@ -83,7 +86,7 @@ int nvo_save ( struct nvo_block *nvo ) {
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Recalculate checksum */
|
/* Recalculate checksum */
|
||||||
checksum -= nvo_checksum ( nvo );
|
*checksum -= nvo_checksum ( nvo );
|
||||||
|
|
||||||
/* Write data a fragment at a time */
|
/* Write data a fragment at a time */
|
||||||
for ( fragment = nvo->fragments ; fragment->len ; fragment++ ) {
|
for ( fragment = nvo->fragments ; fragment->len ; fragment++ ) {
|
||||||
|
@ -182,6 +185,8 @@ int nvo_register ( struct nvo_block *nvo ) {
|
||||||
nvo_init_dhcp ( nvo );
|
nvo_init_dhcp ( nvo );
|
||||||
register_dhcp_options ( nvo->options );
|
register_dhcp_options ( nvo->options );
|
||||||
|
|
||||||
|
ugly_nvo_hack = nvo;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
@ -201,4 +206,6 @@ void nvo_unregister ( struct nvo_block *nvo ) {
|
||||||
free_dhcp_options ( nvo->options );
|
free_dhcp_options ( nvo->options );
|
||||||
nvo->options = NULL;
|
nvo->options = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ugly_nvo_hack = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,14 @@
|
||||||
void test_req();
|
void test_req();
|
||||||
void test2_req();
|
void test2_req();
|
||||||
void help_req();
|
void help_req();
|
||||||
|
void nvo_cmd_req();
|
||||||
|
|
||||||
void commandlist()
|
void commandlist()
|
||||||
{
|
{
|
||||||
test_req();
|
// test_req();
|
||||||
test2_req();
|
// test2_req();
|
||||||
help_req();
|
help_req();
|
||||||
|
nvo_cmd_req();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue