⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 darwin_ipv6.patch

📁 使Darwin服务器能够支持IPv6的补丁
💻 PATCH
📖 第 1 页 / 共 5 页
字号:
 		 		char* GetAnnounceURL() { return fAnnounceURL; }-		UInt32 GetAnnounceIP() { return fAnnounceIP; }-		-		UInt32 GetAnnounceActualIP() { return fAnnounceActualIP; }-		void   SetAnnounceActualIP(UInt32 inActualIP) { fAnnounceActualIP = inActualIP; }-		-		UInt32 GetHostAddr() { return fHostAddr; }-       	UInt32 GetHostPort() { return fHostPort; }+		UInt32 GetAnnounceIP() { return fAnnounceIP.v4; }+		struct in6_addr* GetAnnounceIP6() { return &fAnnounceIP.v6; }++		UInt32 GetAnnounceActualIP() { return fAnnounceActualIP.v4; }+		struct in6_addr* GetAnnounceActualIP6() { return &fAnnounceActualIP.v6; }++		void   SetAnnounceActualIP(UInt32 inActualIP) { fAnnounceActualIP.v4 = inActualIP; }+		void   SetAnnounceActualIP(struct in6_addr* inActualIP) { memcpy(&(fAnnounceActualIP.v6), inActualIP, sizeof(struct in6_addr)); }+		UInt32 GetHostAddr() { return fHostAddr.v4; }++		//IPv6 support, added by aileen+		struct in6_addr *GetHostAddr6() { return &fHostAddr.v6; }+ +		UInt32 GetHostPort() { return fHostPort; }        	-       	char* GetUsername() { return fUserName; }+		char* GetUsername() { return fUserName; } 		char* GetPassword() { return fPassword; } 		 		RelaySession* GetRelaySession() { return fSession; } 		 		void SetSourceParameters(UInt32 inHostAddr, UInt16 inHostPort, StrPtrLen& inURL); +		void SetSourceParameters(struct in6_addr* inHostAddr, UInt16 inHostPort, StrPtrLen& inURL); 		 		void StartSessionCreatorTask(OSQueue* inSessionQueue, OSQueue* inSourceQueue); 		@@ -203,9 +219,19 @@ 		}; 		 		char* 					fSourceURL;-		UInt32					fHostAddr;+		+		union {+		  struct in6_addr v6;+		  UInt32          v4;+		}fHostAddr;+		 		UInt16					fHostPort;-		UInt32					fLocalAddr;+		+		union {+		  struct in6_addr v6;+		  UInt32	  v4;+		}fLocalAddr;+	 		char*					fUserName; 		char*					fPassword; 		RTSPOutputInfo*			fRTSPInfoArray;@@ -217,8 +243,17 @@ 		 		Bool16					fAnnounce; 		char*					fAnnounceURL;-		UInt32					fAnnounceIP;-		UInt32					fAnnounceActualIP;+		+		union {+		  struct in6_addr v6;+		  UInt32	  v4;+		}fAnnounceIP;++		union {+		  struct in6_addr v6;+		  UInt32	  v4;+		}fAnnounceActualIP;+ 		RelaySessionCreator*	fRelaySessionCreatorTask; 		 		enum	// relay session creation statesdiff -u --new-file --recursive darwin-start/APIModules/QTSSReflectorModule/ReflectorSession.cpp darwin/APIModules/QTSSReflectorModule/ReflectorSession.cpp--- darwin-start/APIModules/QTSSReflectorModule/ReflectorSession.cpp	Mon Jun 10 17:32:49 2002+++ darwin/APIModules/QTSSReflectorModule/ReflectorSession.cpp	Tue Jul  2 15:31:08 2002@@ -273,11 +273,17 @@ 	if (inURL == NULL) 	{	 		// If no URL is provided, format the source IP addr as a string.-		char theIPAddrBuf[20];-		StrPtrLen theIPAddr(theIPAddrBuf, 20);+		char theIPAddrBuf[40];+		StrPtrLen theIPAddr(theIPAddrBuf, 40); 		struct in_addr theAddr;-		theAddr.s_addr = htonl(fSourceInfo->GetStreamInfo(0)->fSrcIPAddr);-		SocketUtils::ConvertAddrToString(theAddr, &theIPAddr);+		if (fSourceInfo->GetStreamInfo(0)->family == AF_INET)+		  {+		    theAddr.s_addr = htonl(fSourceInfo->GetStreamInfo(0)->fSrcIPAddr.v4);+		    SocketUtils::ConvertAddrToString(theAddr, &theIPAddr);+		  }+		else+		  SocketUtils::ConvertAddrToString(&(fSourceInfo->GetStreamInfo(0)->fSrcIPAddr.v6), &theIPAddr);+ 		fFormatter.Put(theIPAddr); 	} 	elsediff -u --new-file --recursive darwin-start/APIModules/QTSSReflectorModule/ReflectorStream.cpp darwin/APIModules/QTSSReflectorModule/ReflectorStream.cpp--- darwin-start/APIModules/QTSSReflectorModule/ReflectorStream.cpp	Mon Jun 10 17:32:49 2002+++ darwin/APIModules/QTSSReflectorModule/ReflectorStream.cpp	Tue Jul  2 15:31:08 2002@@ -87,8 +87,8 @@ void	ReflectorStream::GenerateSourceID(SourceInfo::StreamInfo* inInfo, char* ioBuffer) { 	-	::memcpy(ioBuffer, &inInfo->fSrcIPAddr, sizeof(inInfo->fSrcIPAddr));-	::memcpy(&ioBuffer[sizeof(inInfo->fSrcIPAddr)], &inInfo->fPort, sizeof(inInfo->fPort));+	::memcpy(ioBuffer, &inInfo->fSrcIPAddr, sizeof(inInfo->fSrcIPAddr.v6));+	::memcpy(&ioBuffer[sizeof(inInfo->fSrcIPAddr.v6)], &inInfo->fPort, sizeof(inInfo->fPort)); }  @@ -101,7 +101,6 @@ 	fNumElements(0), 	fBucketMutex(), 	-	fDestRTCPAddr(0), 	fDestRTCPPort(0), 	 	fCurrentBitRate(0),@@ -111,6 +110,7 @@ 	fRTPChannel(-1), 	fRTCPChannel(-1) {+        bzero(&fDestRTCPAddr, sizeof(struct in6_addr)); 	fStreamInfo.Copy(*inInfo); 	 	// ALLOCATE BUCKET ARRAY@@ -157,9 +157,14 @@ 	 	// If the source is a multicast, we should send our receiver reports 	// to the multicast address-	if (SocketUtils::IsMulticastIPAddr(fStreamInfo.fDestIPAddr))+	if (fStreamInfo.family == AF_INET && SocketUtils::IsMulticastIPAddr(fStreamInfo.fDestIPAddr.v4)) 	{-		fDestRTCPAddr = fStreamInfo.fDestIPAddr;+		fDestRTCPAddr.v4 = fStreamInfo.fDestIPAddr.v4;+		fDestRTCPPort = fStreamInfo.fPort + 1;+	}+	else if (fStreamInfo.family == AF_INET6 && SocketUtils::IsMulticastIPAddr(&fStreamInfo.fDestIPAddr.v6))+	{+		memcpy(&fDestRTCPAddr, &fStreamInfo.fDestIPAddr,sizeof(struct in6_addr)); 		fDestRTCPPort = fStreamInfo.fPort + 1; 	} }@@ -179,10 +184,10 @@ 		 		//leave the multicast group. Because this socket is shared amongst several 		//potential multicasts, we don't want to remain a member of a stale multicast-		if (SocketUtils::IsMulticastIPAddr(fStreamInfo.fDestIPAddr))+		if (SocketUtils::IsMulticastIPAddr(fStreamInfo.fDestIPAddr.v4)) 		{-			fSockets->GetSocketA()->LeaveMulticast(fStreamInfo.fDestIPAddr);-			fSockets->GetSocketB()->LeaveMulticast(fStreamInfo.fDestIPAddr);+			fSockets->GetSocketA()->LeaveMulticast(fStreamInfo.fDestIPAddr.v4);+			fSockets->GetSocketB()->LeaveMulticast(fStreamInfo.fDestIPAddr.v4); 		} 		//now release the socket pair 		sSocketPool.ReleaseUDPSocketPair(fSockets);@@ -345,11 +350,11 @@ 	// specified by the source info, we can use that to demultiplex separate broadcasts on 	// the same port. If the src IP addr is 0, we cannot do this and must dedicate 1 port per 	// broadcast-	fSockets = sSocketPool.GetUDPSocketPair(INADDR_ANY, fStreamInfo.fPort, fStreamInfo.fSrcIPAddr, 0);+	fSockets = sSocketPool.GetUDPSocketPair((UInt32)INADDR_ANY, fStreamInfo.fPort, (UInt32)(fStreamInfo.fSrcIPAddr.v4), 0); 	if ((fSockets == NULL) && fStreamInfo.fSetupToReceive) 	{ 		fStreamInfo.fPort = 0;-		fSockets = sSocketPool.GetUDPSocketPair(INADDR_ANY, fStreamInfo.fPort, fStreamInfo.fSrcIPAddr, 0);+		fSockets = sSocketPool.GetUDPSocketPair((UInt32)INADDR_ANY, fStreamInfo.fPort, (UInt32)fStreamInfo.fSrcIPAddr.v4, 0); 	} 	if (fSockets == NULL) 		return QTSSModuleUtils::SendErrorResponse(inRequest, qtssServerInternal,@@ -359,7 +364,7 @@ 	// on the same port by that source IP address. If we don't know the source IP addr, 	// it is impossible for us to demux, and therefore we shouldn't allow multiple 	// broadcasts on the same port.- 	if (((ReflectorSocket*)fSockets->GetSocketA())->HasSender() && (fStreamInfo.fSrcIPAddr == 0))+ 	if (((ReflectorSocket*)fSockets->GetSocketA())->HasSender() && (fStreamInfo.fSrcIPAddr.v4 == 0)) 		return QTSSModuleUtils::SendErrorResponse(inRequest, qtssServerInternal, 													sCantBindReflectorSocketErr); 	@@ -379,11 +384,11 @@ 	 	//If the broadcaster is sending RTP directly to us, we don't 	//need to join a multicast group because we're not using multicast-	if (SocketUtils::IsMulticastIPAddr(fStreamInfo.fDestIPAddr))+	if (SocketUtils::IsMulticastIPAddr(fStreamInfo.fDestIPAddr.v4)) 	{-		QTSS_Error err = fSockets->GetSocketA()->JoinMulticast(fStreamInfo.fDestIPAddr);+		QTSS_Error err = fSockets->GetSocketA()->JoinMulticast(fStreamInfo.fDestIPAddr.v4); 		if (err == QTSS_NoErr)-			err = fSockets->GetSocketB()->JoinMulticast(fStreamInfo.fDestIPAddr);+			err = fSockets->GetSocketB()->JoinMulticast(fStreamInfo.fDestIPAddr.v4); 		// If we get an error when setting the TTL, this isn't too important (TTL on 		// these sockets is only useful for RTCP RRs. 		if (err == QTSS_NoErr)@@ -413,7 +418,7 @@ { 	// Check to see if our destination RTCP addr & port are setup. They may 	// not be if the source is unicast and we haven't gotten any incoming packets yet-	if (fDestRTCPAddr == 0)+	if (fDestRTCPAddr.v4 == 0) 		return; 	 	UInt32 theEyeCount = fNumElements;@@ -428,7 +433,7 @@ 	*theEyeWriter = htonl(0) & 0x7fffffff; 	 	//send the packet to the multicast RTCP addr & port for this stream-	(void)fSockets->GetSocketB()->SendTo(fDestRTCPAddr, fDestRTCPPort, fReceiverReportBuffer, fReceiverReportSize);+	(void)fSockets->GetSocketB()->SendTo(fDestRTCPAddr.v4, fDestRTCPPort, fReceiverReportBuffer, fReceiverReportSize); }  void ReflectorStream::PushPacket(char *packet, UInt32 packetLen, Bool16 isRTCP)@@ -447,7 +452,7 @@ 			 			OSMutexLocker locker( ((ReflectorSocket*)(fSockets->GetSocketB()) )->GetDemuxer()->GetMutex()); 			thePacket->SetPacketData(packet, packetLen);-			((ReflectorSocket*)fSockets->GetSocketB())->ProcessPacket(OS::Milliseconds(),thePacket,0,0);+			((ReflectorSocket*)fSockets->GetSocketB())->ProcessPacket(OS::Milliseconds(),thePacket,(UInt32)0,0); 			//((ReflectorSocket*)fSockets->GetSocketB())->Run(); 			((ReflectorSocket*)fSockets->GetSocketB())->Signal(Task::kIdleEvent); 		}@@ -461,7 +466,7 @@ 	 			OSMutexLocker locker(((ReflectorSocket*)(fSockets->GetSocketA()))->GetDemuxer()->GetMutex()); 			thePacket->SetPacketData(packet, packetLen);-			 ((ReflectorSocket*)fSockets->GetSocketA())->ProcessPacket(OS::Milliseconds(),thePacket,0,0);+			 ((ReflectorSocket*)fSockets->GetSocketA())->ProcessPacket(OS::Milliseconds(),thePacket,(UInt32)0,0); 			//((ReflectorSocket*)fSockets->GetSocketA())->Run(); 			((ReflectorSocket*)fSockets->GetSocketA())->Signal(Task::kIdleEvent); 		}@@ -832,7 +837,7 @@ void	ReflectorSocket::AddSender(ReflectorSender* inSender) { 	OSMutexLocker locker(this->GetDemuxer()->GetMutex());-	QTSS_Error err = this->GetDemuxer()->RegisterTask(inSender->fStream->fStreamInfo.fSrcIPAddr, 0, inSender);+	QTSS_Error err = this->GetDemuxer()->RegisterTask(inSender->fStream->fStreamInfo.fSrcIPAddr.v4, 0, inSender); 	Assert(err == QTSS_NoErr); 	fSenderQueue.EnQueue(&inSender->fSocketQueueElem); }@@ -841,7 +846,7 @@ { 	OSMutexLocker locker(this->GetDemuxer()->GetMutex()); 	fSenderQueue.Remove(&inSender->fSocketQueueElem);-	QTSS_Error err = this->GetDemuxer()->UnregisterTask(inSender->fStream->fStreamInfo.fSrcIPAddr, 0, inSender);+	QTSS_Error err = this->GetDemuxer()->UnregisterTask(inSender->fStream->fStreamInfo.fSrcIPAddr.v4, 0, inSender); 	Assert(err == QTSS_NoErr); } @@ -985,7 +990,124 @@ 		ReflectorSender* theSender = (ReflectorSender*)this->GetDemuxer()->GetTask(theRemoteAddr, 0); 		// If there is a generic sender for this socket, use it. 		if (theSender == NULL)-			theSender = (ReflectorSender*)this->GetDemuxer()->GetTask(0, 0);+			theSender = (ReflectorSender*)this->GetDemuxer()->GetTask((UInt32)0, (UInt16)0);+		+		if (theSender == NULL)+		{	+			//UInt16* theSeqNumberP = (UInt16*)thePacket->fPacketPtr.Ptr;+			//printf("ReflectorSocket::ProcessPacket no sender found for packet! sequence number=%d\n",ntohs(theSeqNumberP[1]));+			fFreeQueue.EnQueue(&thePacket->fQueueElem); // don't process the packet+			done = true;+			break;+		}+			+		Assert(theSender != NULL); // at this point we have a sender+			+		if (!(this->GetLocalPort() & 1))+		{+			// don't check for duplicate packets, they may be needed to keep in sync.+			// Because this is an RTP packet make sure to atomic add this because+			// multiple sockets can be adding to this variable simultaneously+			(void)atomic_add(&theSender->fStream->fBytesSentInThisInterval, thePacket->fPacketPtr.Len);+		}++		const UInt32 maxQSize = 4000;+		if (theSender->fPacketQueue.GetLength() < maxQSize) //don't grow memory too big+		{	+			// Check to see if we need to set the remote RTCP address+			// for this stream. This will be necessary if the source is unicast.+			if ((theRemoteAddr != 0) && (theSender->fStream->fDestRTCPAddr.v4 == 0))+			{+				// If the source is multicast, this shouldn't be necessary+				Assert(!SocketUtils::IsMulticastIPAddr(theSender->fStream->fStreamInfo.fDestIPAddr.v4));+				Assert(theRemotePort != 0);+				theSender->fStream->fDestRTCPAddr.v4 = theRemoteAddr;+				theSender->fStream->fDestRTCPPort = theRemotePort;+				+				// RTCPs are always on odd ports, so check to see if this port is an+				// RTP port, and if so, just add 1.+				if (!(theRemotePort & 1))+					theSender->fStream->fDestRTCPPort++;				+			}++			thePacket->fBucketsSeenThisPacket = 0;+			thePacket->fTimeArrived = inMilliseconds;+			theSender->fPacketQueue.EnQueue(&thePacket->fQueueElem);			+			if ( theSender->fFirstNewPacketInQueue == NULL )+				theSender->fFirstNewPacketInQueue = &thePacket->fQueueElem;					+			theSender->fHasNewPackets = true;+			+			//printf("ReflectorSocket::GetIncomingData has packet from time=%qd src addr=%lu src port=%u packetlen=%lu\n",inMilliseconds, theRemoteAddr,theRemotePort,thePacket->fPacketPtr.Len);+		}+		else+		{	char outMessage[256];+			sprintf(outMessage,"Packet Queue for port=%d hit max qSize=%lu", theRemotePort,maxQSize);+			WarnV(false, outMessage); ++			//UInt16* theSeqNumberP = (UInt16*)thePacket->fPacketPtr.Ptr;+			//printf("ReflectorSocket::ProcessPacket the reflector fPacketQueue is full drop packet sequence number=%d\n",ntohs(theSeqNumberP[1]));+			fFreeQueue.EnQueue(&thePacket->fQueueElem);+			done = true;+			break;+		}+++	} while(false);+	+	return done;+}++Bool16 ReflectorSocket::ProcessPacket(const SInt64& inMilliseconds,ReflectorPacket* thePacket,struct in6_addr* theRemoteAddr,UInt16 theRemotePort)+{	+	Bool16 done = false; // stop when result is true+	if (thePacket != NULL) do+	{+		if (fBroadcasterClientSession != NULL) // alway refresh timeout even if we are filtering.+		{	if ( (inMilliseconds - fLastBroadcasterTimeOutRefresh) > kRefreshBroadcastSessionIntervalMilliSecs)+			{	QTSS_RefreshTimeOut(fBroadcasterClientSession);+				fLastBroadcasterTimeOutRefresh = inMilliseconds;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -