📄 darwin_ipv6.patch
字号:
+ }+ }++ // Only reflect one SSRC stream at a time.+ // Pass the packet and whether it is an RTCP or RTP packet based on the port number.+ if (fFilterSSRCs)+ this->FilterInvalidSSRCs(thePacket,GetLocalPort() & 1);// thePacket->fPacketPtr.Len is set to 0 for invalid SSRCs.+ + if (thePacket->fPacketPtr.Len == 0)+ {+ //put the packet back on the free queue, because we didn't actually+ //get any data here.+ fFreeQueue.EnQueue(&thePacket->fQueueElem);+ this->RequestEvent(EV_RE);+ done = true;+ //printf("ReflectorSocket::ProcessPacket no more packets on this socket!\n");+ break;//no more packets on this socket!+ }+ + if (GetLocalPort() & 1)+ {+ //if this is a new RTCP packet, check to see if it is a sender report.+ //We should only reflect sender reports. Because RTCP packets can't have both+ //an SR & an RR, and because the SR & the RR must be the first packet in a+ //compound RTCP packet, all we have to do to determine this is look at the+ //packet type of the first packet in the compound packet.+ RTCPPacket theRTCPPacket;+ if ((!theRTCPPacket.ParsePacket((UInt8*)thePacket->fPacketPtr.Ptr, thePacket->fPacketPtr.Len)) ||+ (theRTCPPacket.GetPacketType() != RTCPSRPacket::kSRPacketType))+ {+ //pretend as if we never got this packet+ fFreeQueue.EnQueue(&thePacket->fQueueElem);+ done = true;+ break;+ }+ }+ + // Find the appropriate ReflectorSender for this packet.+ 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((struct in6_addr*)NULL, (UInt16)0); if (theSender == NULL) { @@ -1011,12 +1133,12 @@ { // 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 == 0))+ if ((theRemoteAddr != NULL) && (theSender->fStream->fDestRTCPAddr.v4 == 0)) { // If the source is multicast, this shouldn't be necessary- Assert(!SocketUtils::IsMulticastIPAddr(theSender->fStream->fStreamInfo.fDestIPAddr));+ Assert(!SocketUtils::IsMulticastIPAddr(&(theSender->fStream->fStreamInfo.fDestIPAddr.v6))); Assert(theRemotePort != 0);- theSender->fStream->fDestRTCPAddr = theRemoteAddr;+ memcpy(&(theSender->fStream->fDestRTCPAddr.v6), theRemoteAddr, sizeof(struct in6_addr)); theSender->fStream->fDestRTCPPort = theRemotePort; // RTCPs are always on odd ports, so check to see if this port is andiff -u --new-file --recursive darwin-start/APIModules/QTSSReflectorModule/ReflectorStream.h darwin/APIModules/QTSSReflectorModule/ReflectorStream.h--- darwin-start/APIModules/QTSSReflectorModule/ReflectorStream.h Mon Jun 10 17:32:49 2002+++ darwin/APIModules/QTSSReflectorModule/ReflectorStream.h Tue Jul 2 15:31:08 2002@@ -118,6 +118,7 @@ void RemoveSender(ReflectorSender* inStreamElem); Bool16 HasSender() { return (this->GetDemuxer()->GetHashTable()->GetNumEntries() > 0); } Bool16 ProcessPacket(const SInt64& inMilliseconds,ReflectorPacket* thePacket,UInt32 theRemoteAddr,UInt16 theRemotePort);+ Bool16 ProcessPacket(const SInt64& inMilliseconds,ReflectorPacket* thePacket,struct in6_addr* theRemoteAddr,UInt16 theRemotePort); ReflectorPacket* GetPacket(); virtual SInt64 Run(); void SetSSRCFilter(Bool16 state, UInt32 timeoutSecs) { fFilterSSRCs = state; fTimeoutSecs = timeoutSecs;}@@ -215,7 +216,7 @@ // A unicast broadcast can also be identified by source IP address. If // you are attempting to demux by source IP, this ID will not guarentee // uniqueness and special care should be used.- kStreamIDSize = sizeof(UInt32) + sizeof(UInt16)+ kStreamIDSize = sizeof(struct in6_addr) + sizeof(UInt16) }; // Uses a StreamInfo to generate a unique ID@@ -321,7 +322,10 @@ // This is the destination address & port for RTCP // receiver reports.- UInt32 fDestRTCPAddr;+ union {+ UInt32 v4;+ struct in6_addr v6;+ } fDestRTCPAddr; UInt16 fDestRTCPPort; diff -u --new-file --recursive darwin-start/APIModules/QTSSReflectorModule/RelayOutput.cpp darwin/APIModules/QTSSReflectorModule/RelayOutput.cpp--- darwin-start/APIModules/QTSSReflectorModule/RelayOutput.cpp Mon Jun 10 17:32:49 2002+++ darwin/APIModules/QTSSReflectorModule/RelayOutput.cpp Tue Jul 2 15:31:08 2002@@ -196,7 +196,11 @@ fClient = new RTSPClient(fClientSocket, false, RelaySession::sRelayUserAgent); // set up the outgoing socket- fClientSocket->Set(fOutputInfo.fDestAddr, rtspInfo->fAnnouncePort);+ if (fOutputInfo.family == AF_INET)+ fClientSocket->Set(fOutputInfo.fDestAddr.v4, rtspInfo->fAnnouncePort);+ else if (fOutputInfo.family == AF_INET6)+ fClientSocket->Set(&(fOutputInfo.fDestAddr.v6), rtspInfo->fAnnouncePort);+ int sndBufSize = 32 * 1024; int rcvBufSize=1024; fClientSocket->SetOptions(sndBufSize,rcvBufSize);@@ -215,7 +219,10 @@ fClient->SetPassword(rtspInfo->fPassword); UInt32 len;- fOutgoingSDP = sessionSourceInfo->GetAnnounceSDP(fOutputInfo.fDestAddr, &len);+ if (fOutputInfo.family == AF_INET)+ fOutgoingSDP = sessionSourceInfo->GetAnnounceSDP(fOutputInfo.fDestAddr.v4, &len);+ else if (fOutputInfo.family == AF_INET6)+ fOutgoingSDP = sessionSourceInfo->GetAnnounceSDP(&(fOutputInfo.fDestAddr.v6), &len); fAnnounceState = kSendingAnnounce; fCurrentSetup = 0; fAnnounceTask = new RelayAnnouncer(this); // this will now go and run the async announce@@ -231,11 +238,16 @@ static StrPtrLen sHTMLEnd("<BR>"); // First, format the destination addr as a dotted decimal string- char theIPAddrBuf[20];- StrPtrLen theIPAddr(theIPAddrBuf, 20);+ char theIPAddrBuf[40];+ StrPtrLen theIPAddr(theIPAddrBuf, 40); struct in_addr theAddr;- theAddr.s_addr = htonl(fOutputInfo.fDestAddr);- SocketUtils::ConvertAddrToString(theAddr, &theIPAddr);+ if (fOutputInfo.family == AF_INET)+ {+ theAddr.s_addr = htonl(fOutputInfo.fDestAddr.v4);+ SocketUtils::ConvertAddrToString(theAddr, &theIPAddr);+ }+ else+ SocketUtils::ConvertAddrToString(&(fOutputInfo.fDestAddr.v6), &theIPAddr); // Begin writing the HTML fFormatter.Put(sHTMLStart);@@ -249,7 +261,7 @@ fFormatter.PutSpace(); } - if (SocketUtils::IsMulticastIPAddr(inInfo->GetOutputInfo(inWhichOutput)->fDestAddr))+ if (SocketUtils::IsMulticastIPAddr(inInfo->GetOutputInfo(inWhichOutput)->fDestAddr.v4)) { // Put the time to live if this is a multicast destination fFormatter.Put(sTimeToLive);@@ -304,12 +316,12 @@ OS_Error RelayOutput::BindSocket() {- OS_Error theErr = fOutputSocket.Open();+ OS_Error theErr = fOutputSocket.Open(AF_INET); if (theErr != OS_NoErr) return theErr; // We don't care what local port we bind to- theErr = fOutputSocket.Bind(fOutputInfo.fLocalAddr, 0);+ theErr = fOutputSocket.Bind(fOutputInfo.fLocalAddr.v4, 0); if (theErr != OS_NoErr) return theErr; @@ -371,7 +383,7 @@ if (inFlags & qtssWriteFlagsIsRTCP) theDestPort++; - (void)fOutputSocket.SendTo(fOutputInfo.fDestAddr, theDestPort, + (void)fOutputSocket.SendTo(fOutputInfo.fDestAddr.v4, theDestPort, inPacket->Ptr, inPacket->Len); // Update our totals@@ -524,19 +536,30 @@ Assert(theErr == QTSS_NoErr); } - char theIPAddrBuf[20]; - StrPtrLen theIPAddr(theIPAddrBuf, 20);+ char theIPAddrBuf[40]; + StrPtrLen theIPAddr(theIPAddrBuf, 40); - struct in_addr theDestAddr; // output destination address- theDestAddr.s_addr = htonl(fOutputInfo.fDestAddr);- SocketUtils::ConvertAddrToString(theDestAddr, &theIPAddr); + if (fOutputInfo.family == AF_INET)+ {+ struct in_addr theDestAddr; // output destination address+ theDestAddr.s_addr = htonl(fOutputInfo.fDestAddr.v4);+ SocketUtils::ConvertAddrToString(theDestAddr, &theIPAddr); + }+ else if (fOutputInfo.family == AF_INET6)+ SocketUtils::ConvertAddrToString(&(fOutputInfo.fDestAddr.v6), &theIPAddr); theErr = QTSS_SetValue (fRelayOutputObject, sOutputDestAddr, 0, (void*)theIPAddr.Ptr, theIPAddr.Len); Assert(theErr == QTSS_NoErr); - struct in_addr theLocalAddr; // output local address- theLocalAddr.s_addr = htonl(fOutputInfo.fLocalAddr);- SocketUtils::ConvertAddrToString(theLocalAddr, &theIPAddr); + if (fOutputInfo.family == AF_INET)+ {+ struct in_addr theLocalAddr; // output local address+ theLocalAddr.s_addr = htonl(fOutputInfo.fLocalAddr.v4);+ SocketUtils::ConvertAddrToString(theLocalAddr, &theIPAddr); + }+ else if (fOutputInfo.family == AF_INET6)+ SocketUtils::ConvertAddrToString(&(fOutputInfo.fLocalAddr.v6), &theIPAddr); + theErr = QTSS_SetValue (fRelayOutputObject, sOutputLocalAddr, 0, (void*)theIPAddr.Ptr, theIPAddr.Len); Assert(theErr == QTSS_NoErr);diff -u --new-file --recursive darwin-start/APIModules/QTSSReflectorModule/RelaySDPSourceInfo.cpp darwin/APIModules/QTSSReflectorModule/RelaySDPSourceInfo.cpp--- darwin-start/APIModules/QTSSReflectorModule/RelaySDPSourceInfo.cpp Mon Jun 10 17:32:49 2002+++ darwin/APIModules/QTSSReflectorModule/RelaySDPSourceInfo.cpp Tue Jul 2 15:31:08 2002@@ -80,7 +80,12 @@ StringParser trackCounter(inSDPData); - UInt32 theDestIPAddr = 0;+ union {+ UInt32 v4;+ struct in6_addr v6;+ } theDestIPAddr;+ int sFamily = 0;+ UInt16 theDestTtl = 0; //@@ -100,7 +105,13 @@ // The first IP addr on this line is the destination IP addr of the // source broadcast.- theDestIPAddr = SDPSourceInfo::GetIPAddr(&relayAddrParser, ' ');+ theDestIPAddr.v4 = SDPSourceInfo::GetIPAddr(&relayAddrParser, ' ');+ sFamily = AF_INET;+ if (theDestIPAddr.v4 <= 0)+ {+ memcpy(&theDestIPAddr.v6, SDPSourceInfo::GetIPAddr6(&relayAddrParser, ' '), sizeof(struct in6_addr));+ sFamily = AF_INET6;+ } relayAddrParser.ConsumeWhitespace(); // Store this position so we can later go back to it@@ -150,15 +161,22 @@ StringParser theOutputAddrParser(&outputAddrs); for (UInt32 x = 0; x < fNumOutputs; x++) {- fOutputArray[x].fDestAddr = SDPSourceInfo::GetIPAddr(&theOutputAddrParser, ' ');- fOutputArray[x].fLocalAddr = INADDR_ANY;+ fOutputArray[x].fDestAddr.v4 = SDPSourceInfo::GetIPAddr(&theOutputAddrParser, ' ');+ fOutputArray[x].fLocalAddr.v4 = INADDR_ANY;+ fOutputArray[x].family = AF_INET;+ if (fOutputArray[x].fDestAddr.v4 <= 0)+ {+ memcpy(&(fOutputArray[x].fDestAddr.v6), SDPSourceInfo::GetIPAddr6(&theOutputAddrParser, ' '), sizeof(struct in6_addr));+ memcpy(&(fOutputArray[x].fLocalAddr.v6), &in6addr_any, sizeof(struct in6_addr));+ fOutputArray[x].family = AF_INET6;+ } fOutputArray[x].fTimeToLive = theDestTtl; fOutputArray[x].fPortArray = NEW UInt16[fNumStreams];//Each output has one port per stream fOutputArray[x].fNumPorts = fNumStreams; ::memset(fOutputArray[x].fPortArray, 0, fNumStreams * sizeof(UInt16)); fOutputArray[x].fAlreadySetup = false; theOutputAddrParser.ConsumeWhitespace();- Assert(fOutputArray[x].fDestAddr > 0);+ Assert(fOutputArray[x].fDestAddr.v4 > 0); } StringParser sdpParser(inSDPData);@@ -181,7 +199,8 @@ continue; //we only care about RTP ports // Fill in all the fields we can for this stream- fStreamArray[theStreamIndex].fDestIPAddr = theDestIPAddr;+ memcpy(&(fStreamArray[theStreamIndex].fDestIPAddr), &theDestIPAddr, sizeof(struct in6_addr));+ fStreamArray[theStreamIndex].family = sFamily; fStreamArray[theStreamIndex].fTimeToLive = theDestTtl; fStreamArray[theStreamIndex].fTrackID = theStreamIndex + 1; diff -u --new-file --recursive darwin-start/APIModules/QTSSReflectorModule/RelaySession.cpp darwin/APIModules/QTSSReflectorModule/RelaySession.cpp--- darwin-start/APIModules/QTSSReflectorModule/RelaySession.cpp Mon Jun 10 17:32:49 2002+++ darwin/APIModules/QTSSReflectorModule/RelaySession.cpp Tue Jul 2 15:31:08 2002@@ -181,19 +181,29 @@ theErr = QTSS_SetValue (fRelaySessionObject, sSourceType, 0, (void*)sourceStr.Ptr, sourceStr.Len); Assert(theErr == QTSS_NoErr); - char theIPAddrBuf[20]; - StrPtrLen theIPAddr(theIPAddrBuf, 20);+ char theIPAddrBuf[40]; + StrPtrLen theIPAddr(theIPAddrBuf, 40); - struct in_addr theSrcAddr; // source ip address- theSrcAddr.s_addr = htonl(inInfo->GetStreamInfo(0)->fSrcIPAddr);- SocketUtils::ConvertAddrToString(theSrcAddr, &theIPAddr); + if (inInfo->GetStreamInfo(0)->family == AF_INET)+ {+ struct in_addr theSrcAddr; // source ip address+ theSrcAddr.s_addr = htonl(inInfo->GetStreamInfo(0)->fSrcIPAddr.v4);+ SocketUtils::ConvertAddrToString(theSrcAddr, &theIPAddr); + }+ else if (inInfo->GetStreamInfo(0)->family == AF_INET6)+ SocketUtils::ConvertAddrToString(&(inInfo->GetStreamInfo(0)->fSrcIPAddr.v6), &theIPAddr); theErr = QTSS_SetValue (fRelaySessionObject, sSourceIPAddr, 0, (void*)theIPAddr.Ptr, theIPAddr.Len); Assert(theErr == QTSS_NoErr); - struct in_addr theDestAddr; // dest (of source) ip address- theDestAddr.s_addr = htonl(inInfo->GetStreamInfo(0)->fDestIPAddr);- SocketUtils::ConvertAddrToString(theDestAddr, &theIPAddr);+ if (inInfo->GetStreamInfo(0)->family == AF_INET)+ {+ struct in_addr theDestAddr; // dest (of source) ip address+ theDestAddr.s_addr = htonl(inInfo->GetStreamInfo(0)->fDestIPAddr.v4);+ SocketUtils::ConvertAddrToString(theDestAddr, &theIPAddr);+ }+ else if (inInfo->GetStreamInfo(0)->family == AF_INET6)+ SocketUtils::ConvertAddrToString(&(inInfo->GetStreamInfo(0)->fDestIPAddr.v6), &theIPAddr); theErr = QTSS_SetValue (fRelaySessionObject, sSourceInIPAddr, 0, (void*)theIPAddr.Ptr, theIPAddr.Len); Assert(theErr == QTSS_NoErr);diff -u --new-file --recursive darwin-start/APIModules/QTSSSpamDefenseModule.bproj/QTSSSpamDefenseModule.cpp darwin/APIModules/QTSSSpamDefenseModule.bproj/QTSSSpamDefenseModule.cpp--- darwin-start/APIModules/QTSSSpamDefenseModule.bproj/QTSSSpamDefenseModule.cpp Mon Jun 10 17:32:49 2002+++ darwin/APIModules/QTSSSpamDefenseModule.bproj/QTSSSpamDefenseModule.cpp Tue Jul 2 15:31:08 2002@@ -30,12 +30,18 @@ */ ++#ifndef __Win32__+#include <netinet/in.h>+#endif+ #incl
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -