|
@@ -0,0 +1,68 @@
|
|
1
|
+#include <stdint.h>
|
|
2
|
+#include <stdlib.h>
|
|
3
|
+#include <string.h>
|
|
4
|
+#include <errno.h>
|
|
5
|
+#include <vsprintf.h>
|
|
6
|
+#include <command.h>
|
|
7
|
+#include <gpxe/nvo.h>
|
|
8
|
+#include <gpxe/dhcp.h>
|
|
9
|
+
|
|
10
|
+void nvo_cmd_req() {}
|
|
11
|
+
|
|
12
|
+extern struct nvo_block *ugly_nvo_hack;
|
|
13
|
+
|
|
14
|
+static int show_exec ( int argc, char **argv ) {
|
|
15
|
+
|
|
16
|
+ if ( ! ugly_nvo_hack ) {
|
|
17
|
+ printf ( "No non-volatile option storage available\n" );
|
|
18
|
+ return 1;
|
|
19
|
+ }
|
|
20
|
+
|
|
21
|
+ hex_dump ( ugly_nvo_hack->options->data,
|
|
22
|
+ ugly_nvo_hack->options->len );
|
|
23
|
+}
|
|
24
|
+
|
|
25
|
+struct command show_command __command = {
|
|
26
|
+ .name = "show",
|
|
27
|
+ .usage = "show\n",
|
|
28
|
+ .desc = "Show stored options",
|
|
29
|
+ .exec = show_exec,
|
|
30
|
+};
|
|
31
|
+
|
|
32
|
+static int set_exec ( int argc, char **argv ) {
|
|
33
|
+ unsigned long tag;
|
|
34
|
+ struct dhcp_option *option;
|
|
35
|
+
|
|
36
|
+ if ( ! ugly_nvo_hack ) {
|
|
37
|
+ printf ( "No non-volatile option storage available\n" );
|
|
38
|
+ return 1;
|
|
39
|
+ }
|
|
40
|
+
|
|
41
|
+ if ( argc != 3 ) {
|
|
42
|
+ printf ( "Syntax: %s <option number> <option string>\n",
|
|
43
|
+ argv[0] );
|
|
44
|
+ return 1;
|
|
45
|
+ }
|
|
46
|
+
|
|
47
|
+ tag = strtoul ( argv[1], NULL, 0 );
|
|
48
|
+ option = set_dhcp_option ( ugly_nvo_hack->options, tag, argv[2],
|
|
49
|
+ strlen ( argv[2] ) );
|
|
50
|
+ if ( ! option ) {
|
|
51
|
+ printf ( "Could not set option %ld\n", tag );
|
|
52
|
+ return 1;
|
|
53
|
+ }
|
|
54
|
+
|
|
55
|
+ if ( nvo_save ( ugly_nvo_hack ) != 0 ) {
|
|
56
|
+ printf ( "Could not save options to non-volatile storage\n" );
|
|
57
|
+ return 1;
|
|
58
|
+ }
|
|
59
|
+
|
|
60
|
+ return 0;
|
|
61
|
+}
|
|
62
|
+
|
|
63
|
+struct command set_command __command = {
|
|
64
|
+ .name = "set",
|
|
65
|
+ .usage = "set <option number> <option string>\n",
|
|
66
|
+ .desc = "Set stored option",
|
|
67
|
+ .exec = set_exec,
|
|
68
|
+};
|