|
@@ -3,6 +3,48 @@
|
3
|
3
|
#include <byteswap.h>
|
4
|
4
|
#include <gpxe/ip.h>
|
5
|
5
|
#include <gpxe/dhcp.h>
|
|
6
|
+#include <gpxe/iscsi.h>
|
|
7
|
+
|
|
8
|
+static int test_dhcp_aoe_boot ( struct net_device *netdev,
|
|
9
|
+ char *aoename ) {
|
|
10
|
+ unsigned int drivenum;
|
|
11
|
+
|
|
12
|
+ drivenum = find_global_dhcp_num_option ( DHCP_EB_BIOS_DRIVE );
|
|
13
|
+ return test_aoeboot ( netdev, aoename, drivenum );
|
|
14
|
+}
|
|
15
|
+
|
|
16
|
+static int test_dhcp_iscsi_boot ( struct net_device *netdev __unused,
|
|
17
|
+ char *iscsiname ) {
|
|
18
|
+ char *initiator_iqn = "iqn.1900-01.localdomain.localhost:initiator";
|
|
19
|
+ char *target_iqn;
|
|
20
|
+ union {
|
|
21
|
+ struct sockaddr_in sin;
|
|
22
|
+ struct sockaddr_tcpip st;
|
|
23
|
+ } target;
|
|
24
|
+
|
|
25
|
+ memset ( &target, 0, sizeof ( target ) );
|
|
26
|
+ target.sin.sin_family = AF_INET;
|
|
27
|
+ target.sin.sin_port = htons ( ISCSI_PORT );
|
|
28
|
+ target_iqn = strchr ( iscsiname, ':' ) + 1;
|
|
29
|
+ if ( ! target_iqn ) {
|
|
30
|
+ printf ( "Invalid iSCSI DHCP path\n" );
|
|
31
|
+ return -EINVAL;
|
|
32
|
+ }
|
|
33
|
+ inet_aton ( iscsiname, &target.sin.sin_addr );
|
|
34
|
+
|
|
35
|
+ return test_iscsiboot ( initiator_iqn, &target, target_iqn );
|
|
36
|
+}
|
|
37
|
+
|
|
38
|
+static int test_dhcp_boot ( struct net_device *netdev, char *filename ) {
|
|
39
|
+ if ( strncmp ( filename, "aoe:", 4 ) == 0 ) {
|
|
40
|
+ return test_dhcp_aoe_boot ( netdev, &filename[4] );
|
|
41
|
+ } else if ( strncmp ( filename, "iscsi:", 6 ) == 0 ) {
|
|
42
|
+ return test_dhcp_iscsi_boot ( netdev, &filename[6] );
|
|
43
|
+ } else {
|
|
44
|
+ printf ( "Don't know how to boot %s\n", filename );
|
|
45
|
+ return -EPROTONOSUPPORT;
|
|
46
|
+ }
|
|
47
|
+}
|
6
|
48
|
|
7
|
49
|
int test_dhcp ( struct net_device *netdev ) {
|
8
|
50
|
struct dhcp_session dhcp;
|
|
@@ -56,16 +98,10 @@ int test_dhcp ( struct net_device *netdev ) {
|
56
|
98
|
gateway ) ) != 0 )
|
57
|
99
|
goto out_no_del_ipv4;
|
58
|
100
|
|
59
|
|
- /* Proof of concept: check for "aoe:" prefix and if found, do
|
60
|
|
- * test AoE boot with AoE options.
|
61
|
|
- */
|
62
|
|
- if ( strncmp ( filename, "aoe:", 4 ) == 0 ) {
|
63
|
|
- unsigned int drivenum;
|
64
|
|
-
|
65
|
|
- drivenum = find_global_dhcp_num_option ( DHCP_EB_BIOS_DRIVE );
|
66
|
|
- test_aoeboot ( netdev, &filename[4], drivenum );
|
67
|
|
- } else {
|
68
|
|
- printf ( "Don't know how to boot %s\n", filename );
|
|
101
|
+ /* Test boot */
|
|
102
|
+ if ( ( rc = test_dhcp_boot ( netdev, filename ) ) != 0 ) {
|
|
103
|
+ printf ( "Boot failed\n" );
|
|
104
|
+ goto out;
|
69
|
105
|
}
|
70
|
106
|
|
71
|
107
|
out:
|