Browse Source

Add very, very quick and dirty hello world test

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
010288577f
2 changed files with 31 additions and 6 deletions
  1. 26
    3
      src/tests/dhcptest.c
  2. 5
    3
      src/tests/hellotest.c

+ 26
- 3
src/tests/dhcptest.c View File

13
 	return test_aoeboot ( netdev, aoename, drivenum );
13
 	return test_aoeboot ( netdev, aoename, drivenum );
14
 }
14
 }
15
 
15
 
16
-static int test_dhcp_iscsi_boot ( struct net_device *netdev __unused,
17
-				  char *iscsiname ) {
16
+static int test_dhcp_iscsi_boot ( char *iscsiname ) {
18
 	char *initiator_iqn = "iqn.1900-01.localdomain.localhost:initiator";
17
 	char *initiator_iqn = "iqn.1900-01.localdomain.localhost:initiator";
19
 	char *target_iqn;
18
 	char *target_iqn;
20
 	union {
19
 	union {
36
 	return test_iscsiboot ( initiator_iqn, &target.st, target_iqn );
35
 	return test_iscsiboot ( initiator_iqn, &target.st, target_iqn );
37
 }
36
 }
38
 
37
 
38
+static int test_dhcp_hello ( char *helloname ) {
39
+	char *message;
40
+	union {
41
+		struct sockaddr_in sin;
42
+		struct sockaddr_tcpip st;
43
+	} target;
44
+
45
+	memset ( &target, 0, sizeof ( target ) );
46
+	target.sin.sin_family = AF_INET;
47
+	target.sin.sin_port = htons ( 80 );
48
+	message = strchr ( helloname, ':' );
49
+	*message++ = '\0';
50
+	if ( ! message ) {
51
+		printf ( "Invalid hello path\n" );
52
+		return -EINVAL;
53
+	}
54
+	inet_aton ( helloname, &target.sin.sin_addr );	
55
+
56
+	test_hello ( &target.st, message );
57
+	return 0;
58
+}
59
+
39
 static int test_dhcp_boot ( struct net_device *netdev, char *filename ) {
60
 static int test_dhcp_boot ( struct net_device *netdev, char *filename ) {
40
 	if ( strncmp ( filename, "aoe:", 4 ) == 0 ) {
61
 	if ( strncmp ( filename, "aoe:", 4 ) == 0 ) {
41
 		return test_dhcp_aoe_boot ( netdev, &filename[4] );
62
 		return test_dhcp_aoe_boot ( netdev, &filename[4] );
42
 	} else if ( strncmp ( filename, "iscsi:", 6 ) == 0 ) {
63
 	} else if ( strncmp ( filename, "iscsi:", 6 ) == 0 ) {
43
-		return test_dhcp_iscsi_boot ( netdev, &filename[6] );
64
+		return test_dhcp_iscsi_boot ( &filename[6] );
65
+	} else if ( strncmp ( filename, "hello:", 6 ) == 0 ) {
66
+		return test_dhcp_hello ( &filename[6] );
44
 	} else {
67
 	} else {
45
 		printf ( "Don't know how to boot %s\n", filename );
68
 		printf ( "Don't know how to boot %s\n", filename );
46
 		return -EPROTONOSUPPORT;
69
 		return -EPROTONOSUPPORT;

+ 5
- 3
src/tests/hellotest.c View File

22
 	}
22
 	}
23
 }
23
 }
24
 
24
 
25
-void test_hello ( struct sockaddr_in *server, const char *message ) {
25
+void test_hello ( struct sockaddr_tcpip *server, const char *message ) {
26
+	/* Quick and dirty hack */
27
+	struct sockaddr_in *sin = ( struct sockaddr_in * ) server;
26
 	struct hello_request hello;
28
 	struct hello_request hello;
27
 	int rc;
29
 	int rc;
28
 
30
 
29
 	printf ( "Saying \"%s\" to %s:%d\n", message,
31
 	printf ( "Saying \"%s\" to %s:%d\n", message,
30
-		 inet_ntoa ( server->sin_addr ), ntohs ( server->sin_port ) );
32
+		 inet_ntoa ( sin->sin_addr ), ntohs ( sin->sin_port ) );
31
 	
33
 	
32
 	memset ( &hello, 0, sizeof ( hello ) );
34
 	memset ( &hello, 0, sizeof ( hello ) );
33
-	hello.tcp.sin = *server;
35
+	memcpy ( &hello.tcp.peer, server, sizeof ( hello.tcp.peer ) );
34
 	hello.message = message;
36
 	hello.message = message;
35
 	hello.callback = test_hello_callback;
37
 	hello.callback = test_hello_callback;
36
 
38
 

Loading…
Cancel
Save