1.1 --- a/PortMapper/MYPortMapper.m Mon Apr 27 09:03:56 2009 -0700
1.2 +++ b/PortMapper/MYPortMapper.m Tue May 05 14:46:42 2009 -0700
1.3 @@ -94,8 +94,6 @@
1.4 errorCode = kDNSServiceErr_NATPortMappingUnsupported;
1.5 }
1.6 }
1.7 - if( errorCode != self.error )
1.8 - self.error = errorCode;
1.9
1.10 [self priv_updateLocalAddress];
1.11 IPAddress *publicAddress = makeIPAddr(rawPublicAddress,publicPort);
1.12 @@ -106,6 +104,8 @@
1.13 LogTo(PortMapper,@"%@: Public addr is %@ (mapped=%i)",
1.14 self, self.publicAddress, self.isMapped);
1.15 }
1.16 +
1.17 + [self gotResponse: errorCode];
1.18 [[NSNotificationCenter defaultCenter] postNotificationName: MYPortMapperChangedNotification
1.19 object: self];
1.20 }
1.21 @@ -135,22 +135,19 @@
1.22 }
1.23
1.24
1.25 -- (DNSServiceRef) createServiceRef
1.26 -{
1.27 +- (DNSServiceErrorType) createServiceRef: (DNSServiceRef*)sdRefPtr {
1.28 DNSServiceProtocol protocols = 0;
1.29 if( _mapTCP ) protocols |= kDNSServiceProtocol_TCP;
1.30 if( _mapUDP ) protocols |= kDNSServiceProtocol_UDP;
1.31 - DNSServiceRef serviceRef = NULL;
1.32 - self.error = DNSServiceNATPortMappingCreate(&serviceRef,
1.33 - 0 /*flags*/,
1.34 - 0 /*interfaceIndex*/,
1.35 - protocols,
1.36 - htons(_localPort),
1.37 - htons(_desiredPublicPort),
1.38 - 0 /*ttl*/,
1.39 - &portMapCallback,
1.40 - self);
1.41 - return serviceRef;
1.42 + return DNSServiceNATPortMappingCreate(sdRefPtr,
1.43 + kDNSServiceFlagsShareConnection,
1.44 + 0 /*interfaceIndex*/,
1.45 + protocols,
1.46 + htons(_localPort),
1.47 + htons(_desiredPublicPort),
1.48 + 0 /*ttl*/,
1.49 + &portMapCallback,
1.50 + self);
1.51 }
1.52
1.53