summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorMichael Brown2006-12-05 20:07:47 +0100
committerMichael Brown2006-12-05 20:07:47 +0100
commit89bcb57201d4175b08344eaf0ee4268abd7e8092 (patch)
tree372ad6b3dbccb1ab08893e7ba999b58672882d0d /src/tests
parentThe VPD engine is broken and can't actually handle placing VPD (diff)
downloadipxe-89bcb57201d4175b08344eaf0ee4268abd7e8092.tar.gz
ipxe-89bcb57201d4175b08344eaf0ee4268abd7e8092.tar.xz
ipxe-89bcb57201d4175b08344eaf0ee4268abd7e8092.zip
Update ftp.c to work with Nikhil's TCP stack.
Remove the now-totally-obsolete sockaddr_in field from tcp.h.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/dhcptest.c54
-rw-r--r--src/tests/ftptest.c7
2 files changed, 50 insertions, 11 deletions
diff --git a/src/tests/dhcptest.c b/src/tests/dhcptest.c
index d1e7a6cb..a315de09 100644
--- a/src/tests/dhcptest.c
+++ b/src/tests/dhcptest.c
@@ -14,8 +14,10 @@ static int test_dhcp_aoe_boot ( struct net_device *netdev,
return test_aoeboot ( netdev, aoename, drivenum );
}
-static int test_dhcp_iscsi_boot ( struct net_device *netdev, char *iscsiname ) {
- char *initiator_iqn = "iqn.1900-01.localdomain.localhost:initiator";
+static int test_dhcp_iscsi_boot ( struct net_device *netdev,
+ char *iscsiname ) {
+ char initiator_iqn_buf[32];
+ char *initiator_iqn = initiator_iqn_buf;
char username[32];
char password[32];
char *target_iqn;
@@ -24,6 +26,7 @@ static int test_dhcp_iscsi_boot ( struct net_device *netdev, char *iscsiname ) {
struct sockaddr_tcpip st;
} target;
unsigned int drivenum;
+ struct dhcp_option *option;
memset ( &target, 0, sizeof ( target ) );
target.sin.sin_family = AF_INET;
@@ -36,6 +39,10 @@ static int test_dhcp_iscsi_boot ( struct net_device *netdev, char *iscsiname ) {
}
inet_aton ( iscsiname, &target.sin.sin_addr );
+ dhcp_snprintf ( initiator_iqn, sizeof ( initiator_iqn ),
+ find_global_dhcp_option ( DHCP_ISCSI_INITIATOR_IQN ) );
+ if ( ! *initiator_iqn )
+ initiator_iqn = "iqn.1900-01.localdomain.localhost:initiator";
dhcp_snprintf ( username, sizeof ( username ),
find_global_dhcp_option ( DHCP_EB_USERNAME ) );
dhcp_snprintf ( password, sizeof ( password ),
@@ -89,6 +96,29 @@ static int test_dhcp_http ( struct net_device *netdev, char *url ) {
return 0;
}
+static int test_dhcp_ftp ( struct net_device *netdev, char *ftpname ) {
+ union {
+ struct sockaddr_in sin;
+ struct sockaddr_tcpip st;
+ } target;
+ char *filename;
+
+ filename = strchr ( ftpname, ':' );
+ if ( ! filename ) {
+ printf ( "Invalid FTP path \"%s\"\n", ftpname );
+ return -EINVAL;
+ }
+ *filename++ = '\0';
+
+ memset ( &target, 0, sizeof ( target ) );
+ target.sin.sin_family = AF_INET;
+ target.sin.sin_port = htons ( 21 );
+ inet_aton ( ftpname, &target.sin.sin_addr );
+
+ test_ftp ( &target, filename );
+ return 0;
+}
+
static int test_dhcp_tftp ( struct net_device *netdev, char *tftpname ) {
union {
struct sockaddr_in sin;
@@ -105,17 +135,27 @@ static int test_dhcp_tftp ( struct net_device *netdev, char *tftpname ) {
}
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 ) {
+ }
+ */
+ if ( strncmp ( filename, "iscsi:", 6 ) == 0 ) {
return test_dhcp_iscsi_boot ( netdev, &filename[6] );
- } else if ( strncmp ( filename, "hello:", 6 ) == 0 ) {
+ }
+ if ( strncmp ( filename, "ftp:", 4 ) == 0 ) {
+ return test_dhcp_ftp ( netdev, &filename[4] );
+ }
+ /*
+ if ( strncmp ( filename, "hello:", 6 ) == 0 ) {
return test_dhcp_hello ( &filename[6] );
- } else if ( strncmp ( filename, "http:", 5 ) == 0 ) {
+ }
+ if ( strncmp ( filename, "http:", 5 ) == 0 ) {
return test_dhcp_http ( netdev, filename );
- } else {
- return test_dhcp_tftp ( netdev, filename );
}
+ return test_dhcp_tftp ( netdev, filename );
+ */
+ return -EPROTONOSUPPORT;
}
int test_dhcp ( struct net_device *netdev ) {
diff --git a/src/tests/ftptest.c b/src/tests/ftptest.c
index f8208de7..6b0002fb 100644
--- a/src/tests/ftptest.c
+++ b/src/tests/ftptest.c
@@ -22,15 +22,14 @@ static void test_ftp_callback ( char *data, size_t len ) {
}
}
-void test_ftp ( struct in_addr server, const char *filename ) {
+void test_ftp ( struct sockaddr_tcpip *server, const char *filename ) {
struct ftp_request ftp;
int rc;
- printf ( "FTP fetching %s:%s\n", inet_ntoa ( server ), filename );
+ printf ( "FTP fetching %s\n", filename );
memset ( &ftp, 0, sizeof ( ftp ) );
- ftp.tcp.sin.sin_addr.s_addr = server.s_addr;
- ftp.tcp.sin.sin_port = htons ( FTP_PORT );
+ memcpy ( &ftp.tcp.peer, server, sizeof ( ftp.tcp.peer ) );
ftp.filename = filename;
ftp.callback = test_ftp_callback;