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

📄 sipmsg.cxx

📁 SIP(Session Initiation Protocol)是由IETF定义
💻 CXX
📖 第 1 页 / 共 4 页
字号:
    myHeaderList.appendHeader(SIP_CONTACT_HDR, x, index);}    void SipMsg::setNumContact(int index){    myHeaderList.setNumHeaders(SIP_CONTACT_HDR, index);}voidSipMsg::flushContact(){    while (getNumContact())    {        removeContact(-1);    }}SipContactList SipMsg::getContactList() const{    SipContactList tmp;    myHeaderList.getHeaderList(&tmp, SIP_CONTACT_HDR);    return tmp;}    // ----------------- Date Header Methods ------------------/// Get the current Date header const SipDate&SipMsg::getDate() const{    Sptr<SipDate> date;    myHeaderList.getParsedHeader(date, SIP_DATE_HDR);    return *date;}        /// Set the Date header void SipMsg::setDate( const SipDate& newdate){    Sptr<SipDate> date;    myHeaderList.getParsedHeader(date, SIP_DATE_HDR);    *date = newdate;}/// Set the Date header void SipMsg::setDate( const Data& newdate){    Sptr<SipDate> date;    myHeaderList.getParsedHeader(date, SIP_DATE_HDR);    date->decode(newdate);}// ----------------- Encryption Header Methods ------------------/// Get the current Encryption header const SipEncryption&SipMsg::getEncryption() const{    Sptr<SipEncryption> encryption;    myHeaderList.getParsedHeader(encryption, SIP_ENCRYPTION_HDR);    return *encryption;}/// Set the Encryption header void  SipMsg::setEncryption(const SipEncryption&  newencryption){    Sptr<SipEncryption> encryption;    myHeaderList.getParsedHeader(encryption, SIP_ENCRYPTION_HDR);    *encryption = newencryption;}    /// Set the Encryption header void  SipMsg::setEncryption(const Data&  newencryption){    Sptr<SipEncryption> encryption;    myHeaderList.getParsedHeader(encryption, SIP_ENCRYPTION_HDR);    encryption->decode(newencryption);}      // ----------------- Expires Header Methods ------------------/// Get the current Expires header const SipExpires& SipMsg::getExpires() const{    Sptr<SipExpires> expires;    myHeaderList.getParsedHeader(expires, SIP_EXPIRES_HDR);    return *expires;}    /// Set the Expires header void SipMsg::setExpires( const SipExpires& newexpires){    Sptr<SipExpires> expires;    myHeaderList.getParsedHeader(expires, SIP_EXPIRES_HDR);    *expires = newexpires;}        /// Set the Expires header void SipMsg::setExpires( const Data& newexpires){    Sptr<SipExpires> expires;    myHeaderList.getParsedHeader(expires, SIP_EXPIRES_HDR);    expires->decode(newexpires);}      // ----------------- From Header Methods ------------------/// Get the current From header const SipFrom&SipMsg::getFrom() const{    Sptr<SipFrom> from;    myHeaderList.getParsedHeader(from, SIP_FROM_HDR);    return *from;}        const SipMimeVersion&SipMsg::getMimeVersion() const{    Sptr<SipMimeVersion> mimeVersion;    myHeaderList.getParsedHeader(mimeVersion, SIP_MIME_VERSION_HDR);    return *mimeVersion;}        void SipMsg::setMimeVersion( const SipMimeVersion& newmv){    Sptr<SipMimeVersion> mimeVersion;    myHeaderList.getParsedHeader(mimeVersion, SIP_MIME_VERSION_HDR);    *mimeVersion = newmv;}           void SipMsg::setMimeVersion( const Data& newmv){    Sptr<SipMimeVersion> mimeVersion;    myHeaderList.getParsedHeader(mimeVersion, SIP_MIME_VERSION_HDR);    mimeVersion->decode(newmv);}/// Set the From header void SipMsg::setFrom( const SipFrom& newfrom){    Sptr<SipFrom> from;    myHeaderList.getParsedHeader(from, SIP_FROM_HDR);    *from = newfrom;}        void SipMsg::setFrom( const Data& formData){    Sptr<SipFrom> from;    myHeaderList.getParsedHeader(from, SIP_FROM_HDR);    from->decode(formData);}// ----------------- RecordRoute Header Methods  -----------------void SipMsg::copyRecordRoute( const SipMsg& srcMsg) {    Sptr <SipRawHeader> hdr         = srcMsg.myHeaderList.getHeader(SIP_RECORD_ROUTE_HDR);    Sptr <SipRawHeader> copy;    if(hdr != 0)    {        copy = hdr->duplicate();    }    myHeaderList.replaceHeader(SIP_RECORD_ROUTE_HDR, copy);}void SipMsg::flushrecordrouteList(){    myHeaderList.setNumHeaders(SIP_RECORD_ROUTE_HDR, 0);}SipRecordRouteList SipMsg::getrecordrouteList() const{    SipRecordRouteList tmp;    myHeaderList.getHeaderList(&tmp, SIP_RECORD_ROUTE_HDR);    return tmp;}int SipMsg::getNumRecordRoute() const{    return myHeaderList.getNumHeaders(SIP_RECORD_ROUTE_HDR);}const SipRecordRoute&SipMsg::getRecordRoute( int i /*default Arguments*/) const{    Sptr<SipRecordRoute> x;    myHeaderList.getParsedHeader(x, SIP_RECORD_ROUTE_HDR, i);    return *x;}void SipMsg::setRecordRoute(const SipRecordRoute& item, int index /*Default Arguments*/){    Sptr<SipHeader> x = new SipRecordRoute(item);    myHeaderList.appendHeader(SIP_RECORD_ROUTE_HDR, x, index);}void SipMsg::setRecordRoute(const Data& item, int index /*Default Arguments*/){    Sptr<SipHeader> x = new SipRecordRoute(item);    myHeaderList.appendHeader(SIP_RECORD_ROUTE_HDR, x, index);}void SipMsg::setNumRecordRoute(int index){    myHeaderList.setNumHeaders(SIP_RECORD_ROUTE_HDR, index);}bool SipMsg::compareRecordRoute(const SipMsg& src) const{    int srcRecordRoutesize = src.getNumRecordRoute();    if ( srcRecordRoutesize != getNumRecordRoute())    {        return false;    }    else    {        for (int i = 0; i < srcRecordRoutesize; i++)	{	    if ( !(getRecordRoute(i) == src.getRecordRoute(i)) )	    {	        return false;	    }	}	return true;    }}//void SipMsg::recordRoutePushFront(const SipRecordRoute& item){    int n = getNumRecordRoute();    setRecordRoute(item, 0);    assert (getNumRecordRoute() == n+1);}const SipRecordRoute&SipMsg::recordRouteFront() const{    assert(!recordRouteEmpty());    return getRecordRoute(0);}const SipRecordRoute& SipMsg::recordRouteBack() const{    assert(!recordRouteEmpty());    return getRecordRoute(-1);}boolSipMsg::recordRouteEmpty() const{    return getNumRecordRoute() == 0;}// ----------------- Timestamp Header Methods ------------------const SipTimestamp&SipMsg::getTimestamp() const{    Sptr<SipTimestamp> timestamp;    myHeaderList.getParsedHeader(timestamp, SIP_TIMESTAMP_HDR);    return *timestamp;        }void SipMsg::setTimestamp( const SipTimestamp& newtimestamp){    Sptr<SipTimestamp> timestamp;    myHeaderList.getParsedHeader(timestamp, SIP_TIMESTAMP_HDR);    *timestamp = newtimestamp;    }    /// Set the Timestamp header void SipMsg::setTimestamp( const Data& newtimestamp){    Sptr<SipTimestamp> timestamp;    myHeaderList.getParsedHeader(timestamp, SIP_TIMESTAMP_HDR);    timestamp->decode(newtimestamp);}// ----------------- To Header Methods ------------------/// Get the current To header const SipTo&SipMsg::getTo() const{    Sptr<SipTo> to;    myHeaderList.getParsedHeader(to, SIP_TO_HDR);    return *to;}/// Set the To header void SipMsg::setTo( const SipTo& newto){    Sptr<SipTo> to;    myHeaderList.getParsedHeader(to, SIP_TO_HDR);    *to = newto;}void SipMsg::setTo( const Data& toData){    Sptr<SipTo> to;    myHeaderList.getParsedHeader(to, SIP_TO_HDR);    to->decode(toData);}// ----------------- Via Header Methods  -----------------/// get the number of Via items int SipMsg::getNumVia() const{    return myHeaderList.getNumHeaders(SIP_VIA_HDR);}/// Get the i'th Via item. If i is -1, it gets the last one const SipVia&SipMsg::getVia( int i /*default Arguments*/) const{    Sptr<SipVia> x;    myHeaderList.getParsedHeader(x, SIP_VIA_HDR, i);    return *x;}void SipMsg::removeVia(int index /*deafult Arguments*/){    myHeaderList.removeHeader(SIP_VIA_HDR, index);}/** set or add another Via item, if the index is -1, it is appended     to the current list */void SipMsg::setVia(const SipVia& item, int index /* Default Arguments*/){    Sptr<SipHeader> x = new SipVia(item);    myHeaderList.appendHeader(SIP_VIA_HDR, x, index);}void SipMsg::setVia(const Data& item, int index /* Default Arguments*/){    Sptr<SipHeader> x = new SipVia(item);    myHeaderList.appendHeader(SIP_VIA_HDR, x, index);}/** Set number of Via items.If i is less than current number then the extras are deleted. */void SipMsg::setNumVia(int index){    myHeaderList.setNumHeaders(SIP_VIA_HDR, index);}void SipMsg::flushViaList(){    myHeaderList.setNumHeaders(SIP_VIA_HDR, 0);}void SipMsg::copyViaList( const SipMsg& srcMsg) {    Sptr <SipRawHeader> hdr = srcMsg.myHeaderList.getHeader(SIP_VIA_HDR);    Sptr <SipRawHeader> copy;    if(hdr != 0)    {        copy = hdr->duplicate();    }    myHeaderList.replaceHeader(SIP_VIA_HDR, copy);}SipViaList SipMsg::getViaList()  const{    SipViaList tmp;    myHeaderList.getHeaderList(&tmp, SIP_VIA_HDR);    return tmp;}boolSipMsg::isLoopInViaList(const Data& myHost, int myPort, int limit) const{    int count = 0;  // number of times in Via    SipViaList viaList;    myHeaderList.getHeaderList(&viaList, SIP_VIA_HDR);    if ( !viaList.empty() )    {        Data hostAddress;        unsigned short port;#if defined(__SUNPRO_CC)        for( SipViaList::iterator iter = viaList.begin();             !(iter == viaList.end()); iter++ )#else        for( SipViaList::iterator iter = viaList.begin();             iter != viaList.end(); iter++ )#endif        {            hostAddress = ( *iter )->getHost();            port = ( *iter )->getPort();            if ( ( port == myPort) &&	         ( hostAddress == myHost ) )            {                // found self in list, ignore to avoid loops                cpLog( LOG_DEBUG, "found self in Via list" );                count++;		if(count >= limit) break;            }        }    }    else    {        cpLog( LOG_DEBUG, "Via list is empty" );    }    if(count >= limit) return true;    return false;}void SipMsg::viaPushFront(const SipVia& item){    setVia(item, 0);}const SipVia& SipMsg::viaFront() const{    assert(!viaEmpty());    return getVia(0);}voidSipMsg::viaPopFront() {    assert(!viaEmpty());        removeVia(0);}bool SipMsg::viaEmpty() const{    return getNumVia() == 0;}    void SipMsg::removeContact(int index /*default Arguments*/){    myHeaderList.removeHeader(SIP_CONTACT_HDR, index);}        /*-----------------------------------------------------------------------*///Diversion header details//  getNumDiversion//  removeDiversion//  addDiversion//  copyDiversionList//  getDiversionList//  flushDiversionList//  encodeDiversionList//  ltDiversionList//  compareDiversionList//  setDiversion//  setNumDiversion    int SipMsg::getNumDiversion() const{    return myHeaderList.getNumHeaders(SIP_DIVERSION_HDR);}void SipMsg::removeDiversion(int index /* Default Arguement */){    myHeaderList.removeHeader(SIP_DIVERSION_HDR, index);}SipDiversionList SipMsg::getDiversionList() const{    SipDiversionList tmp;    myHeaderList.getHeaderList(&tmp, SIP_DIVERSION_HDR);    return tmp;} void SipMsg::copyDiversionList( const SipMsg& srcMsg) {    myHeaderList.replaceHeader(        SIP_DIVERSION_HDR,         srcMsg.myHeaderList.getHeader(SIP_DIVERSION_HDR));}

⌨️ 快捷键说明

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