1.1 --- a/IPAddress.h Wed Apr 29 13:29:31 2009 -0700
1.2 +++ b/IPAddress.h Wed Apr 29 13:57:10 2009 -0700
1.3 @@ -14,6 +14,7 @@
1.4 also remembers the DNS host-name. */
1.5 @interface IPAddress : NSObject <NSCoding, NSCopying>
1.6 {
1.7 + @private
1.8 UInt32 _ipv4; // In network byte order (big-endian), just like struct in_addr
1.9 UInt16 _port; // native byte order
1.10 }
1.11 @@ -75,11 +76,14 @@
1.12 An instance of HostAddress looks up its ipv4 address on the fly by calling gethostbyname. */
1.13 @interface HostAddress : IPAddress
1.14 {
1.15 + @private
1.16 NSString *_hostname;
1.17 }
1.18
1.19 - (id) initWithHostname: (NSString*)hostname port: (UInt16)port;
1.20
1.21 +/** Initializes a HostAddress from a host name, plus a sockaddr struct and a port number.
1.22 + (The port number overrides any port specified in the sockaddr struct.) */
1.23 - (id) initWithHostname: (NSString*)hostname
1.24 sockaddr: (const struct sockaddr*)sockaddr
1.25 port: (UInt16)port;
1.26 @@ -93,6 +97,7 @@
1.27 addresses for a peer that doesn't have a stable address. */
1.28 @interface RecentAddress : IPAddress
1.29 {
1.30 + @private
1.31 CFAbsoluteTime _lastSuccess;
1.32 UInt32 _successes;
1.33 }
2.1 --- a/IPAddress.m Wed Apr 29 13:29:31 2009 -0700
2.2 +++ b/IPAddress.m Wed Apr 29 13:57:10 2009 -0700
2.3 @@ -83,6 +83,15 @@
2.4 }
2.5 }
2.6
2.7 +- (id) initWithSockAddr: (const struct sockaddr*)sockaddr
2.8 + port: (UInt16)port
2.9 +{
2.10 + self = [self initWithSockAddr: sockaddr];
2.11 + if (self)
2.12 + _port = port;
2.13 + return self;
2.14 +}
2.15 +
2.16 + (IPAddress*) addressOfSocket: (CFSocketNativeHandle)socket
2.17 {
2.18 uint8_t name[SOCK_MAXADDRLEN];
2.19 @@ -241,10 +250,9 @@
2.20 [self release];
2.21 return nil;
2.22 }
2.23 - self = [super initWithSockAddr: sockaddr];
2.24 + self = [super initWithSockAddr: sockaddr port: port];
2.25 if( self ) {
2.26 _hostname = [hostname copy];
2.27 - _port = port;
2.28 }
2.29 return self;
2.30 }
2.31 @@ -278,15 +286,15 @@
2.32 NSString *addr = self.ipv4name;
2.33 if (addr)
2.34 [desc appendFormat: @"(%@)", addr];
2.35 - if( _port )
2.36 - [desc appendFormat: @":%hu",_port];
2.37 + if( self.port )
2.38 + [desc appendFormat: @":%hu",self.port];
2.39 return desc;
2.40 }
2.41
2.42
2.43 - (NSUInteger) hash
2.44 {
2.45 - return [_hostname hash] ^ _port;
2.46 + return [_hostname hash] ^ self.port;
2.47 }
2.48
2.49
3.1 --- a/PortMapper/MYDNSService.h Wed Apr 29 13:29:31 2009 -0700
3.2 +++ b/PortMapper/MYDNSService.h Wed Apr 29 13:57:10 2009 -0700
3.3 @@ -50,17 +50,25 @@
3.4 inDomain: (NSString*)domain;
3.5
3.6
3.7 +/** @name Protected
3.8 + * Methods for use only by subclasses
3.9 + */
3.10 +//@{
3.11
3.12 -// PROTECTED:
3.13 -
3.14 -
3.15 +/** Normally, all DNSService objects use a shared IPC connection to the mDNSResponder daemon.
3.16 + If an instance wants to use its own connection instead, it can set this property to YES before
3.17 + it starts. If it does so, it must NOT set the kDNSServiceFlagsShareConnection flag when creating
3.18 + its underlying DNSService.
3.19 + This functionality is only provided because MYBonjourRegistration needs it -- there's a bug
3.20 + that prevents DNSServiceUpdateRecord from working with a shared connection. */
3.21 @property BOOL usePrivateConnection;
3.22
3.23 /** Subclass must implement this abstract method to create a new DNSServiceRef.
3.24 This method is called by -open.
3.25 The implementation MUST pass the given sdRefPtr directly to the DNSService function
3.26 that creates the new ref, without setting it to NULL first.
3.27 - It MUST also set the kDNSServiceFlagsShareConnection flag. */
3.28 + It MUST also set the kDNSServiceFlagsShareConnection flag, unless it's already set the
3.29 + usePrivateConnection property. */
3.30 - (int32_t/*DNSServiceErrorType*/) createServiceRef: (struct _DNSServiceRef_t**)sdRefPtr;
3.31
3.32 /** Subclass's callback must call this method after doing its own work.
3.33 @@ -68,6 +76,7 @@
3.34 continuous. */
3.35 - (void) gotResponse: (int32_t/*DNSServiceErrorType*/)errorCode;
3.36
3.37 +/** The underlying DNSServiceRef. This will be NULL except while the service is running. */
3.38 @property (readonly) struct _DNSServiceRef_t* serviceRef;
3.39
3.40 /** Same as -stop, but does not clear the error property.
3.41 @@ -79,6 +88,7 @@
3.42 @return YES if a message is received, NO on error (or if the service isn't started) */
3.43 - (BOOL) waitForReply;
3.44
3.45 +//@}
3.46
3.47 @end
3.48