云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > darwin分析

darwin分析

  • 62 次阅读
  • 3 次下载
  • 2025/5/5 19:25:54

kAuthorizingRequest = 4, kPreprocessingRequest = 5, kProcessingRequest = 6, kSendingResponse = 7, kPostProcessingRequest = 8, kCleaningUp = 9,

// states that RTSP sessions that setup RTSP // through HTTP tunnels pass through

kWaitingToBindHTTPTunnel = 10, // POST or GET side waiting to be joined with it's matching half kSocketHasBeenBoundIntoHTTPTunnel = 11, // POST side after attachment by GET side (its dying) kHTTPFilteringRequest = 12, // after kReadingRequest, enter this state

kReadingFirstRequest = 13, // initial state - the only time we look for an HTTP tunnel kHaveNonTunnelMessage = 14 // we've looked at the message, and its not an HTTP tunnle message }; RTSP的消息格式: 请求消息: 方法 URI RTSP版本 CR LF 消息头 CR LF CR LF 消息体 CR LF 回应消息: RTSP版本 状态码 解释 CR LF 消息头 CR LF CR LF 消息体 CR LF (1)、构建函数 初始化成员 (2)、ParseProxyTunnelHTTP函数 检查是否是Http连接,如果是,返回true。 if it's an HTTP request parse the interesing parts from the request - check for GET or POST, set fHTTPMethod - checck for HTTP protocol, set fWasHTTPRequest - check for SessionID header, set fProxySessionID char array - check for accept \ ... ... if ( fFoundValidAccept && *fProxySessionID && fWasHTTPRequest ) isHTTPRequest = true; return isHTTPRequest; (3)、PreFilterForHTTPProxyTunnel函数 \ sessions into one, let the donor Session die. // returns true if it's an HTTP request that can tunnel if(!this->ParseProxyTunnelHTTP()) return QTSS_NoErr; 对http连接的处理,暂不做分析! (4)、Run函数 当一个RTSP端口有数据时,EventContext::ProcessEvent函数会调用Signal函数,TaskThread会调用 RTSPSession::Run函数。见TCPListenerSocket::ProcessEvent函数的分析。 OSThreadDataSetter theSetter(&fModuleState, NULL); while (this->IsLiveSession()) { // RTSP Session state machine. There are several well defined points in an RTSP // request where this session may have to return from its run function and wait

// for a new event. Because of this, we need to track our current state and return // to it.

case kReadingFirstRequest: // 初始状态 { // 返回QTSS_NoErr意味着所有数据已经从Socket中读出,但尚不能构成一个完整 // 的请求,因此必须等待更多的数据到达 // 我们从ReadRequest代码可以知道,只有当对socket端口recv返回EAGAIN时, // ReadRequest才会返回QTSS_NoErr。 if ((err = fInputStream.ReadRequest()) == QTSS_NoErr) { fInputSocketP->RequestEvent(EV_RE); // 重新申请监听 return 0; } if ((err != QTSS_RequestArrived) && (err != E2BIG)) { break; } // 注意:这里没有再申请继续监听。 if (err == QTSS_RequestArrived) fState = kHTTPFilteringRequest; // If we get an E2BIG, it means our buffer was overfilled. In that case, we // can just jump into the following state, and the code their does a check // for this error and returns an error. if (err == E2BIG) fState = kHaveNonTunnelMessage; } continue; // 注意:这里调用continue

case kHTTPFilteringRequest: { // assume it's not a tunnel setup message prefilter will set correct tunnel // state if it is. fState = kHaveNonTunnelMessage; // 对于非Http连接的情况,会返回QTSS_NoErr。但是返回QTSS_NoErr,并不表示 // 一定是非Http连接。而且对于Http连接(RTSP经过Http代理)情况, // PreFilterForHTTPProxyTunnel可能会更改fState值。 preFilterErr = this->PreFilterForHTTPProxyTunnel(); if(preFilterErr == QTSS_NoErr) continue; else return -1; }

case kHaveNonTunnelMessage: { fRequest = NEW RTSPRequest(this); fRoleParams.rtspRequestParams.inRTSPRequest = fRequest; fRoleParams.rtspRequestParams.inRTSPHeaders = fRequest->GetHeaderDictionary();

// We have an RTSP request and are about to begin processing. We need to // make sure that anyone sending interleaved data on this session won't // be allowed to do so until we are done sending our response // We also make sure that a POST session can't snarf in while we're // processing the request. // 通过锁,防止在发送请求回复过程中,有另外的数据被安插发送 fReadMutex.Lock(); fSessionMutex.Lock(); // The fOutputStream's fBytesWritten counter is used to count the # of // bytes for this RTSP response. So, at this point, reset it to 0 (we can // then just let it increment until the next request comes in) fOutputStream.ResetBytesWritten(); 如果err == E2BIG或者QTSS_BadArgument,调用SendErrorResponse, fState赋值为 kPostProcessingRequest。否则fState赋值为kFilteringRequest。 }

case kFilteringRequest: { // We received something so auto refresh, The need to auto refresh is // because the api doesn't allow a module to refresh at this point // 重置fTimeoutTask的到时时间

fTimeoutTask.RefreshTimeout();

// Before we even do this, check to see if this is a *data* packet, in // which case this isn't an RTSP request, so we don't need to go through any // of the remaining steps // 在readRequest函数里,只有碰到“$”,才会认为是interleaved packet if (fInputStream.IsDataPacket()) { // 在handleIncomingDataPacket里,除了调用RTPSession的 // ProcessIncomingInterleavedData函数外,还会调用已注册 // QTSS_RTSPIncomingData_Role模块的处理函数。(系统的 // QTSSReflectorModule模块提供该Role的处理) // 这里可以进行二次开发! this->HandleIncomingDataPacket(); fState = kCleaningUp; break; } 设置filter param block theFilterParams; 调用已注册QTSS_RTSPFilter_Role模块的处理函数(系统的QTSSRelayModule模块、 QTSSMP3StreamingModule模块(Handle ShoutCast/IceCast-style MP3 streaming.)、QTSSRefMovieModule模块(A module that serves an RTSP text ref movie from an HTTP request.)、QTSSAdminModule模块(A module that uses the information available in the server to present a web page containing that information.)、QTSSWebStatsModule模块(A module that uses the stats information available in the server to present a web page containing that information.)、QTSSWebDebugModule模块(A module that uses the debugging information available in the server to present a web page containing that information.)、QTSSDemoSMILModule模块(?)、 QTSSHttpFileModule模块(A module for HTTP file transfer of files and for on-the-fly ref movie creation.)提供该Role的处理),可以添加二次开发模块! // 根据fBytesWritten来判断,在StringFormatter::Put函数里增加了 // fBytesWritten计数,但是实际上并没有通过socket发送??? if (fRequest->HasResponseBeenSent()) { fState = kPostProcessingRequest; break; } if (fSentOptionsRequest && this->ParseOptionsResponse()) { ... ... fState = kSendingResponse; break; } else //this is a normal request,so parse it and get the RTPSession. // 建立用于管理数据传输的RTPSession类对象,根据请求消息中的方法 // 做处理。 this->SetupRequest(); if (fRequest->HasResponseBeenSent()) { fState = kPostProcessingRequest; break; } fState = kRoutingRequest; }

case kRoutingRequest: { 调用注册了QTSS_RTSPRoute_Role处理的模块的处理函数(系统的QTSSRelayModule模 块、QTSSReflectorModule模块、QTSSHomeDirectoryModule模块提供了该Role的处 理)。 // SetupAuthLocalPath must happen after kRoutingRequest and before // kAuthenticatingRequest placed here so that if the state is shifted to // kPostProcessingRequest from a response being sent then the // AuthLocalPath will still be set. if (fRequest->HasResponseBeenSent()) { fState = kPostProcessingRequest; break; } if(fRequest->SkipAuthorization()) { ... ... } else fState = kAuthenticatingRequest; }

case kAuthenticatingRequest: {

QTSS_RTSPMethod method = fRequest->GetMethod(); if (method != qtssIllegalMethod) do { ... ... } while(false); if(fRequest->GetAuthScheme() == qtssAuthNone) { ... ... } 调用二次开发的安全模块(QTSS_RTSPAuthenticate_Role),主要用于客户身份验证 以及其他规则的处理(系统的QTSSAccessModule模块(Module that handles authentication and authorization independent of the file system)、QTSSODAuthModule模块(This is a modified version of the QTSSAccessModule also released with QTSS 2.0. It has been modified to shrink the linespacing so that the code can fit on slides. Also, this module issues redirects to an error movie.)提供了该Role的处理)。 // 有两种认证策略: basic authentication、digest authentication // If authenticaton failed, set qtssUserName in the qtssRTSPReqUserProfile // attribute to NULL and clear out the password and any groups that have // been set. this->CheckAuthentication(); if (fRequest->HasResponseBeenSent()) { fState = kPostProcessingRequest; break; } fState = kAuthorizingRequest; }

case kAuthorizingRequest: { 调用注册QTSS_RTSPAuthorize_Role模块的处理函数,如果失败,则发送回复并跳出 循环(系统的QTSSSpamDefenseModule模块(Protects the server against denial- of-service attacks by only allowing X number of RTSP connections from a certain IP address)、QTSSFilePrivsModule模块(Module that handles and file system authorization)、QTSSReflectorModule模块、QTSSHomeDirectoryModule模块、 QTSSAccessModule模块、QTSSAdminModule模块、QTSSDemoModule模块(This is a modified version of the QTSSAccessModule also released with QTSS 2.0. It has been modified to shrink the linespacing so that the code can fit on slides. Also, this module issues redirects to an error movie.)、QTSSODAuthModule模块 提供了该Role的处理)。 this->SaveRequestAuthorizationParams(fRequest); if(!allowd) // 怎么会进入这个分支??? { ... ... } if (fRequest->HasResponseBeenSent()) { fState = kPostProcessingRequest; break; } fState = kPreprocessingRequest; ... ... }

case kPreprocessingRequest: { 调用注册QTSS_RTSPPreProcessor_Role模块的处理函数,注意系统也提供了支持这 些role的模块(系统的QTSSReflectorModule模块、QTSSSplitterModule模块、 QTSSRTPFileModule模块(Content source module that uses the QTFileLib to serve Hinted QuickTime files to clients.)、QTSSRawFileModule模块(A module that returns the entire contents of a file to the client. Only does this if the suffix of the file is .raw)提供了该Role的处理)。 注意:QTSSRTPFileModule和QTSSRawFileModule并没有加载进系统!!! if (fRequest->HasResponseBeenSent()) { fState = kPostProcessingRequest; break; } fState = k```; }

case kProcessingRequest: { 调用注册QTSS_RTSPRequest_Role模块的处理函数,注意系统也提供了支持这 些role的模块(系统的QTSSFileModule模块(Content source module that uses the

搜索更多关于: darwin分析 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

kAuthorizingRequest = 4, kPreprocessingRequest = 5, kProcessingRequest = 6, kSendingResponse = 7, kPostProcessingRequest = 8, kCleaningUp = 9, // states that RTSP sessions that setup RTSP // through HTTP tunnels pass through kW

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com