1.1 --- a/IPAddress.m Tue Jul 15 09:37:15 2008 -0700
1.2 +++ b/IPAddress.m Wed Apr 22 16:45:39 2009 -0700
1.3 @@ -160,7 +160,7 @@
1.4 }
1.5
1.6
1.7 -+ (IPAddress*) localAddress
1.8 ++ (IPAddress*) localAddressWithPort: (UInt16)port
1.9 {
1.10 // getifaddrs returns a linked list of interface entries;
1.11 // find the first active non-loopback interface with IPv4:
1.12 @@ -179,7 +179,12 @@
1.13 }
1.14 freeifaddrs(interfaces);
1.15 }
1.16 - return [[[self alloc] initWithIPv4: address] autorelease];
1.17 + return [[[self alloc] initWithIPv4: address port: port] autorelease];
1.18 +}
1.19 +
1.20 ++ (IPAddress*) localAddress
1.21 +{
1.22 + return [self localAddressWithPort: 0];
1.23 }
1.24
1.25
1.26 @@ -339,7 +344,7 @@
1.27 TestCase(IPAddress) {
1.28 RequireTestCase(CollectionUtils);
1.29 IPAddress *addr = [[IPAddress alloc] initWithIPv4: htonl(0x0A0001FE) port: 8080];
1.30 - CAssertEq(addr.ipv4,htonl(0x0A0001FE));
1.31 + CAssertEq(addr.ipv4,(UInt32)htonl(0x0A0001FE));
1.32 CAssertEq(addr.port,8080);
1.33 CAssertEqual(addr.hostname,@"10.0.1.254");
1.34 CAssertEqual(addr.description,@"10.0.1.254:8080");
1.35 @@ -347,7 +352,7 @@
1.36
1.37 addr = [[IPAddress alloc] initWithHostname: @"66.66.0.255" port: 123];
1.38 CAssertEq(addr.class,[IPAddress class]);
1.39 - CAssertEq(addr.ipv4,htonl(0x424200FF));
1.40 + CAssertEq(addr.ipv4,(UInt32)htonl(0x424200FF));
1.41 CAssertEq(addr.port,123);
1.42 CAssertEqual(addr.hostname,@"66.66.0.255");
1.43 CAssertEqual(addr.description,@"66.66.0.255:123");
1.44 @@ -355,8 +360,8 @@
1.45
1.46 addr = [[IPAddress alloc] initWithHostname: @"www.apple.com" port: 80];
1.47 CAssertEq(addr.class,[HostAddress class]);
1.48 - Log(@"www.apple.com = 0x%08X", addr.ipv4);
1.49 - CAssertEq(addr.ipv4,htonl(0x1195A00A));
1.50 + Log(@"www.apple.com = %@ [0x%08X]", addr.ipv4name, ntohl(addr.ipv4));
1.51 + CAssertEq(addr.ipv4,(UInt32)htonl(0x11FBC820));
1.52 CAssertEq(addr.port,80);
1.53 CAssertEqual(addr.hostname,@"www.apple.com");
1.54 CAssertEqual(addr.description,@"www.apple.com:80");