From 010288577f8b98ee87a37aade9dc521c618fc8ef Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 7 Aug 2006 18:49:10 +0000 Subject: [PATCH] Add very, very quick and dirty hello world test --- src/tests/dhcptest.c | 29 ++++++++++++++++++++++++++--- src/tests/hellotest.c | 8 +++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/tests/dhcptest.c b/src/tests/dhcptest.c index ced38a5a..4bb2e11e 100644 --- a/src/tests/dhcptest.c +++ b/src/tests/dhcptest.c @@ -13,8 +13,7 @@ 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 __unused, - char *iscsiname ) { +static int test_dhcp_iscsi_boot ( char *iscsiname ) { char *initiator_iqn = "iqn.1900-01.localdomain.localhost:initiator"; char *target_iqn; union { @@ -36,11 +35,35 @@ static int test_dhcp_iscsi_boot ( struct net_device *netdev __unused, return test_iscsiboot ( initiator_iqn, &target.st, target_iqn ); } +static int test_dhcp_hello ( char *helloname ) { + char *message; + 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 ( 80 ); + message = strchr ( helloname, ':' ); + *message++ = '\0'; + if ( ! message ) { + printf ( "Invalid hello path\n" ); + return -EINVAL; + } + inet_aton ( helloname, &target.sin.sin_addr ); + + test_hello ( &target.st, message ); + return 0; +} + 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] ); + return test_dhcp_iscsi_boot ( &filename[6] ); + } else if ( strncmp ( filename, "hello:", 6 ) == 0 ) { + return test_dhcp_hello ( &filename[6] ); } else { printf ( "Don't know how to boot %s\n", filename ); return -EPROTONOSUPPORT; diff --git a/src/tests/hellotest.c b/src/tests/hellotest.c index e38856ee..4565f13a 100644 --- a/src/tests/hellotest.c +++ b/src/tests/hellotest.c @@ -22,15 +22,17 @@ static void test_hello_callback ( char *data, size_t len ) { } } -void test_hello ( struct sockaddr_in *server, const char *message ) { +void test_hello ( struct sockaddr_tcpip *server, const char *message ) { + /* Quick and dirty hack */ + struct sockaddr_in *sin = ( struct sockaddr_in * ) server; struct hello_request hello; int rc; printf ( "Saying \"%s\" to %s:%d\n", message, - inet_ntoa ( server->sin_addr ), ntohs ( server->sin_port ) ); + inet_ntoa ( sin->sin_addr ), ntohs ( sin->sin_port ) ); memset ( &hello, 0, sizeof ( hello ) ); - hello.tcp.sin = *server; + memcpy ( &hello.tcp.peer, server, sizeof ( hello.tcp.peer ) ); hello.message = message; hello.callback = test_hello_callback;