diff options
author | Michael Brown <mcb30@etherboot.org> | 2006-08-07 16:48:24 +0000 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2006-08-07 16:48:24 +0000 |
commit | d0e4f198d62348b76abf4a70180160cc2f25d235 (patch) | |
tree | a4bd51985a81212d9ec986b4cc9ae286967f36a5 /src/tests | |
parent | 6714ec745a73639c5b473b7d37ca9ddd796a4d03 (diff) | |
download | ipxe-d0e4f198d62348b76abf4a70180160cc2f25d235.zip ipxe-d0e4f198d62348b76abf4a70180160cc2f25d235.tar.gz ipxe-d0e4f198d62348b76abf4a70180160cc2f25d235.tar.bz2 |
Add iSCSI to the DHCP tests.
Start updating iscsi.c to use Nikhil's TCP API.
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/dhcptest.c | 56 | ||||
-rw-r--r-- | src/tests/iscsiboot.c | 7 |
2 files changed, 50 insertions, 13 deletions
diff --git a/src/tests/dhcptest.c b/src/tests/dhcptest.c index 3661d66..a4e8d10 100644 --- a/src/tests/dhcptest.c +++ b/src/tests/dhcptest.c @@ -3,6 +3,48 @@ #include <byteswap.h> #include <gpxe/ip.h> #include <gpxe/dhcp.h> +#include <gpxe/iscsi.h> + +static int test_dhcp_aoe_boot ( struct net_device *netdev, + char *aoename ) { + unsigned int drivenum; + + drivenum = find_global_dhcp_num_option ( DHCP_EB_BIOS_DRIVE ); + return test_aoeboot ( netdev, aoename, drivenum ); +} + +static int test_dhcp_iscsi_boot ( struct net_device *netdev __unused, + char *iscsiname ) { + char *initiator_iqn = "iqn.1900-01.localdomain.localhost:initiator"; + char *target_iqn; + union { + struct sockaddr_in sin; + struct sockaddr_tcpip st; + } target; + + memset ( &target, 0, sizeof ( target ) ); + target.sin.sin_family = AF_INET; + target.sin.sin_port = htons ( ISCSI_PORT ); + target_iqn = strchr ( iscsiname, ':' ) + 1; + if ( ! target_iqn ) { + printf ( "Invalid iSCSI DHCP path\n" ); + return -EINVAL; + } + inet_aton ( iscsiname, &target.sin.sin_addr ); + + return test_iscsiboot ( initiator_iqn, &target, target_iqn ); +} + +static int test_dhcp_boot ( struct net_device *netdev, char *filename ) { + if ( strncmp ( filename, "aoe:", 4 ) == 0 ) { + return test_dhcp_aoe_boot ( netdev, &filename[4] ); + } else if ( strncmp ( filename, "iscsi:", 6 ) == 0 ) { + return test_dhcp_iscsi_boot ( netdev, &filename[6] ); + } else { + printf ( "Don't know how to boot %s\n", filename ); + return -EPROTONOSUPPORT; + } +} int test_dhcp ( struct net_device *netdev ) { struct dhcp_session dhcp; @@ -56,16 +98,10 @@ int test_dhcp ( struct net_device *netdev ) { gateway ) ) != 0 ) goto out_no_del_ipv4; - /* Proof of concept: check for "aoe:" prefix and if found, do - * test AoE boot with AoE options. - */ - if ( strncmp ( filename, "aoe:", 4 ) == 0 ) { - unsigned int drivenum; - - drivenum = find_global_dhcp_num_option ( DHCP_EB_BIOS_DRIVE ); - test_aoeboot ( netdev, &filename[4], drivenum ); - } else { - printf ( "Don't know how to boot %s\n", filename ); + /* Test boot */ + if ( ( rc = test_dhcp_boot ( netdev, filename ) ) != 0 ) { + printf ( "Boot failed\n" ); + goto out; } out: diff --git a/src/tests/iscsiboot.c b/src/tests/iscsiboot.c index ef1c4a1..a02deb0 100644 --- a/src/tests/iscsiboot.c +++ b/src/tests/iscsiboot.c @@ -8,14 +8,15 @@ static struct iscsi_device test_iscsidev; int test_iscsiboot ( const char *initiator_iqn, - struct in_addr target, + struct sockaddr_tcpip *target, const char *target_iqn ) { + struct sockaddr_in *sin; struct int13_drive drive; int rc; memset ( &test_iscsidev, 0, sizeof ( test_iscsidev ) ); - test_iscsidev.iscsi.tcp.sin.sin_addr = target; - test_iscsidev.iscsi.tcp.sin.sin_port = htons ( ISCSI_PORT ); + memcpy ( &test_iscsidev.iscsi.tcp.peer, target, + sizeof ( test_iscsidev.iscsi.tcp.peer ) ); test_iscsidev.iscsi.initiator = initiator_iqn; test_iscsidev.iscsi.target = target_iqn; |