mirror of
https://github.com/xcat2/xNBA.git
synced 2024-12-24 12:11:33 +00:00
Add very, very quick and dirty hello world test
This commit is contained in:
parent
885a630ddf
commit
010288577f
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user