|  | @@ -39,7 +39,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
		
	
		
			
			| 39 | 39 |  #include <ipxe/test.h>
 | 
		
	
		
			
			| 40 | 40 |  
 | 
		
	
		
			
			| 41 | 41 |  /** Define inline IPv4 address */
 | 
		
	
		
			
			| 42 |  | -#define IPV4(a,b,c,d) ( ( (a) << 24 ) | ( (b) << 16 ) | ( (c) << 8 ) | (d) )
 | 
		
	
		
			
			|  | 42 | +#define IPV4(a,b,c,d) \
 | 
		
	
		
			
			|  | 43 | +	htonl ( ( (a) << 24 ) | ( (b) << 16 ) | ( (c) << 8 ) | (d) )
 | 
		
	
		
			
			| 43 | 44 |  
 | 
		
	
		
			
			| 44 | 45 |  /**
 | 
		
	
		
			
			| 45 | 46 |   * Report an inet_ntoa() test result
 | 
		
	
	
		
			
			|  | @@ -51,7 +52,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
		
	
		
			
			| 51 | 52 |   */
 | 
		
	
		
			
			| 52 | 53 |  static void inet_ntoa_okx ( uint32_t addr, const char *text, const char *file,
 | 
		
	
		
			
			| 53 | 54 |  			    unsigned int line ) {
 | 
		
	
		
			
			| 54 |  | -	struct in_addr in = { .s_addr = htonl ( addr ) };
 | 
		
	
		
			
			|  | 55 | +	struct in_addr in = { .s_addr = addr };
 | 
		
	
		
			
			| 55 | 56 |  	char *actual;
 | 
		
	
		
			
			| 56 | 57 |  
 | 
		
	
		
			
			| 57 | 58 |  	/* Format address */
 | 
		
	
	
		
			
			|  | @@ -81,7 +82,7 @@ static void inet_aton_okx ( const char *text, uint32_t addr, const char *file,
 | 
		
	
		
			
			| 81 | 82 |  	/* Parse address */
 | 
		
	
		
			
			| 82 | 83 |  	okx ( inet_aton ( text, &actual ) != 0, file, line );
 | 
		
	
		
			
			| 83 | 84 |  	DBG ( "inet_aton ( \"%s\" ) = %s\n", text, inet_ntoa ( actual ) );
 | 
		
	
		
			
			| 84 |  | -	okx ( ntohl ( actual.s_addr ) == addr, file, line );
 | 
		
	
		
			
			|  | 85 | +	okx ( actual.s_addr == addr, file, line );
 | 
		
	
		
			
			| 85 | 86 |  };
 | 
		
	
		
			
			| 86 | 87 |  #define inet_aton_ok( text, addr ) \
 | 
		
	
		
			
			| 87 | 88 |  	inet_aton_okx ( text, addr, __FILE__, __LINE__ )
 | 
		
	
	
		
			
			|  | @@ -110,23 +111,23 @@ static void inet_aton_fail_okx ( const char *text, const char *file,
 | 
		
	
		
			
			| 110 | 111 |  static void ipv4_test_exec ( void ) {
 | 
		
	
		
			
			| 111 | 112 |  
 | 
		
	
		
			
			| 112 | 113 |  	/* Address testing macros */
 | 
		
	
		
			
			| 113 |  | -	ok (   IN_CLASSA ( IPV4 ( 10, 0, 0, 1 ) ) );
 | 
		
	
		
			
			| 114 |  | -	ok ( ! IN_CLASSB ( IPV4 ( 10, 0, 0, 1 ) ) );
 | 
		
	
		
			
			| 115 |  | -	ok ( ! IN_CLASSC ( IPV4 ( 10, 0, 0, 1 ) ) );
 | 
		
	
		
			
			| 116 |  | -	ok ( ! IN_CLASSA ( IPV4 ( 172, 16, 0, 1 ) ) );
 | 
		
	
		
			
			| 117 |  | -	ok (   IN_CLASSB ( IPV4 ( 172, 16, 0, 1 ) ) );
 | 
		
	
		
			
			| 118 |  | -	ok ( ! IN_CLASSC ( IPV4 ( 172, 16, 0, 1 ) ) );
 | 
		
	
		
			
			| 119 |  | -	ok ( ! IN_CLASSA ( IPV4 ( 192, 168, 0, 1 ) ) );
 | 
		
	
		
			
			| 120 |  | -	ok ( ! IN_CLASSB ( IPV4 ( 192, 168, 0, 1 ) ) );
 | 
		
	
		
			
			| 121 |  | -	ok (   IN_CLASSC ( IPV4 ( 192, 168, 0, 1 ) ) );
 | 
		
	
		
			
			| 122 |  | -	ok ( ! IN_MULTICAST ( IPV4 ( 127, 0, 0, 1 ) ) );
 | 
		
	
		
			
			| 123 |  | -	ok ( ! IN_MULTICAST ( IPV4 ( 8, 8, 8, 8 ) ) );
 | 
		
	
		
			
			| 124 |  | -	ok ( ! IN_MULTICAST ( IPV4 ( 0, 0, 0, 0 ) ) );
 | 
		
	
		
			
			| 125 |  | -	ok ( ! IN_MULTICAST ( IPV4 ( 223, 0, 0, 1 ) ) );
 | 
		
	
		
			
			| 126 |  | -	ok ( ! IN_MULTICAST ( IPV4 ( 240, 0, 0, 1 ) ) );
 | 
		
	
		
			
			| 127 |  | -	ok (   IN_MULTICAST ( IPV4 ( 224, 0, 0, 1 ) ) );
 | 
		
	
		
			
			| 128 |  | -	ok (   IN_MULTICAST ( IPV4 ( 231, 89, 0, 2 ) ) );
 | 
		
	
		
			
			| 129 |  | -	ok (   IN_MULTICAST ( IPV4 ( 239, 6, 1, 17 ) ) );
 | 
		
	
		
			
			|  | 114 | +	ok (   IN_IS_CLASSA ( IPV4 ( 10, 0, 0, 1 ) ) );
 | 
		
	
		
			
			|  | 115 | +	ok ( ! IN_IS_CLASSB ( IPV4 ( 10, 0, 0, 1 ) ) );
 | 
		
	
		
			
			|  | 116 | +	ok ( ! IN_IS_CLASSC ( IPV4 ( 10, 0, 0, 1 ) ) );
 | 
		
	
		
			
			|  | 117 | +	ok ( ! IN_IS_CLASSA ( IPV4 ( 172, 16, 0, 1 ) ) );
 | 
		
	
		
			
			|  | 118 | +	ok (   IN_IS_CLASSB ( IPV4 ( 172, 16, 0, 1 ) ) );
 | 
		
	
		
			
			|  | 119 | +	ok ( ! IN_IS_CLASSC ( IPV4 ( 172, 16, 0, 1 ) ) );
 | 
		
	
		
			
			|  | 120 | +	ok ( ! IN_IS_CLASSA ( IPV4 ( 192, 168, 0, 1 ) ) );
 | 
		
	
		
			
			|  | 121 | +	ok ( ! IN_IS_CLASSB ( IPV4 ( 192, 168, 0, 1 ) ) );
 | 
		
	
		
			
			|  | 122 | +	ok (   IN_IS_CLASSC ( IPV4 ( 192, 168, 0, 1 ) ) );
 | 
		
	
		
			
			|  | 123 | +	ok ( ! IN_IS_MULTICAST ( IPV4 ( 127, 0, 0, 1 ) ) );
 | 
		
	
		
			
			|  | 124 | +	ok ( ! IN_IS_MULTICAST ( IPV4 ( 8, 8, 8, 8 ) ) );
 | 
		
	
		
			
			|  | 125 | +	ok ( ! IN_IS_MULTICAST ( IPV4 ( 0, 0, 0, 0 ) ) );
 | 
		
	
		
			
			|  | 126 | +	ok ( ! IN_IS_MULTICAST ( IPV4 ( 223, 0, 0, 1 ) ) );
 | 
		
	
		
			
			|  | 127 | +	ok ( ! IN_IS_MULTICAST ( IPV4 ( 240, 0, 0, 1 ) ) );
 | 
		
	
		
			
			|  | 128 | +	ok (   IN_IS_MULTICAST ( IPV4 ( 224, 0, 0, 1 ) ) );
 | 
		
	
		
			
			|  | 129 | +	ok (   IN_IS_MULTICAST ( IPV4 ( 231, 89, 0, 2 ) ) );
 | 
		
	
		
			
			|  | 130 | +	ok (   IN_IS_MULTICAST ( IPV4 ( 239, 6, 1, 17 ) ) );
 | 
		
	
		
			
			| 130 | 131 |  
 | 
		
	
		
			
			| 131 | 132 |  	/* inet_ntoa() tests */
 | 
		
	
		
			
			| 132 | 133 |  	inet_ntoa_ok ( IPV4 ( 127, 0, 0, 1 ), "127.0.0.1" );
 |