# HG changeset patch # User Jens Alfke # Date 1241038630 25200 # Node ID b3254a2f6d6c3bd525b1ab484706819334034e24 # Parent 1d6924779df74b3d9a59f0dbc47cf4fec3dffb09 Tweaked docs diff -r 1d6924779df7 -r b3254a2f6d6c IPAddress.h --- a/IPAddress.h Wed Apr 29 13:29:31 2009 -0700 +++ b/IPAddress.h Wed Apr 29 13:57:10 2009 -0700 @@ -14,6 +14,7 @@ also remembers the DNS host-name. */ @interface IPAddress : NSObject { + @private UInt32 _ipv4; // In network byte order (big-endian), just like struct in_addr UInt16 _port; // native byte order } @@ -75,11 +76,14 @@ An instance of HostAddress looks up its ipv4 address on the fly by calling gethostbyname. */ @interface HostAddress : IPAddress { + @private NSString *_hostname; } - (id) initWithHostname: (NSString*)hostname port: (UInt16)port; +/** Initializes a HostAddress from a host name, plus a sockaddr struct and a port number. + (The port number overrides any port specified in the sockaddr struct.) */ - (id) initWithHostname: (NSString*)hostname sockaddr: (const struct sockaddr*)sockaddr port: (UInt16)port; @@ -93,6 +97,7 @@ addresses for a peer that doesn't have a stable address. */ @interface RecentAddress : IPAddress { + @private CFAbsoluteTime _lastSuccess; UInt32 _successes; } diff -r 1d6924779df7 -r b3254a2f6d6c IPAddress.m --- a/IPAddress.m Wed Apr 29 13:29:31 2009 -0700 +++ b/IPAddress.m Wed Apr 29 13:57:10 2009 -0700 @@ -83,6 +83,15 @@ } } +- (id) initWithSockAddr: (const struct sockaddr*)sockaddr + port: (UInt16)port +{ + self = [self initWithSockAddr: sockaddr]; + if (self) + _port = port; + return self; +} + + (IPAddress*) addressOfSocket: (CFSocketNativeHandle)socket { uint8_t name[SOCK_MAXADDRLEN]; @@ -241,10 +250,9 @@ [self release]; return nil; } - self = [super initWithSockAddr: sockaddr]; + self = [super initWithSockAddr: sockaddr port: port]; if( self ) { _hostname = [hostname copy]; - _port = port; } return self; } @@ -278,15 +286,15 @@ NSString *addr = self.ipv4name; if (addr) [desc appendFormat: @"(%@)", addr]; - if( _port ) - [desc appendFormat: @":%hu",_port]; + if( self.port ) + [desc appendFormat: @":%hu",self.port]; return desc; } - (NSUInteger) hash { - return [_hostname hash] ^ _port; + return [_hostname hash] ^ self.port; } diff -r 1d6924779df7 -r b3254a2f6d6c PortMapper/MYDNSService.h --- a/PortMapper/MYDNSService.h Wed Apr 29 13:29:31 2009 -0700 +++ b/PortMapper/MYDNSService.h Wed Apr 29 13:57:10 2009 -0700 @@ -50,17 +50,25 @@ inDomain: (NSString*)domain; +/** @name Protected + * Methods for use only by subclasses + */ +//@{ -// PROTECTED: - - +/** Normally, all DNSService objects use a shared IPC connection to the mDNSResponder daemon. + If an instance wants to use its own connection instead, it can set this property to YES before + it starts. If it does so, it must NOT set the kDNSServiceFlagsShareConnection flag when creating + its underlying DNSService. + This functionality is only provided because MYBonjourRegistration needs it -- there's a bug + that prevents DNSServiceUpdateRecord from working with a shared connection. */ @property BOOL usePrivateConnection; /** Subclass must implement this abstract method to create a new DNSServiceRef. This method is called by -open. The implementation MUST pass the given sdRefPtr directly to the DNSService function that creates the new ref, without setting it to NULL first. - It MUST also set the kDNSServiceFlagsShareConnection flag. */ + It MUST also set the kDNSServiceFlagsShareConnection flag, unless it's already set the + usePrivateConnection property. */ - (int32_t/*DNSServiceErrorType*/) createServiceRef: (struct _DNSServiceRef_t**)sdRefPtr; /** Subclass's callback must call this method after doing its own work. @@ -68,6 +76,7 @@ continuous. */ - (void) gotResponse: (int32_t/*DNSServiceErrorType*/)errorCode; +/** The underlying DNSServiceRef. This will be NULL except while the service is running. */ @property (readonly) struct _DNSServiceRef_t* serviceRef; /** Same as -stop, but does not clear the error property. @@ -79,6 +88,7 @@ @return YES if a message is received, NO on error (or if the service isn't started) */ - (BOOL) waitForReply; +//@} @end