Click here to Skip to main content
15,895,256 members
Articles / Programming Languages / Visual C++ 10.0

SIP Stack (1 of 3)

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
20 Aug 2012CPOL3 min read 30.1K   1.7K   4  
SIP Stack Implementation on the basis of RFC SIP 3261 Specification
#include "SIPParserInclude\CSIPPriorityParser.h"

namespace SIPParserFW
{
	CSIPPriorityParser::CSIPPriorityParser()
	{
		ReleaseCSIPPriorityParserData() ;
	}

	CSIPPriorityParser::CSIPPriorityParser( const CSIPPriorityParser &SIPPriorityParser )
		: ASIPParser( SIPPriorityParser )
	{
		ReleaseCSIPPriorityParserData() ;

		CopyCSIPPriorityParserData( SIPPriorityParser ) ;
	}

	CSIPPriorityParser::~CSIPPriorityParser()
	{
		ReleaseCSIPPriorityParserData() ;
	}

	CSIPPriorityParser& CSIPPriorityParser::operator=( const CSIPPriorityParser &SIPPriorityParser )
	{
		ReleaseCSIPPriorityParserData() ;

		ASIPParser::operator=( SIPPriorityParser ) ;

		CopyCSIPPriorityParserData( SIPPriorityParser ) ;

		return *this ;
	}

	void CSIPPriorityParser::ReleaseCSIPPriorityParserData()
	{
		m_strPriority.erase() ;
	}

	void CSIPPriorityParser::CopyCSIPPriorityParserData( const CSIPPriorityParser &SIPPriorityParser )
	{
		m_strPriority = SIPPriorityParser.m_strPriority ;
	}

	CSIPPriorityParser* CSIPPriorityParser::GetAvailable()
	{
		CSIPPriorityParser *pSIPPriorityParser = CPoolObject<CSIPPriorityParser>::GetAvailable() ;
		return pSIPPriorityParser ;
	}

	void CSIPPriorityParser::Release()
	{
		ReleaseParameters() ;

		CPoolObject<CSIPPriorityParser>::Release( this ) ;
	}

	void CSIPPriorityParser::ReleaseParameters()
	{
		ReleaseCSIPPriorityParserData() ;
		
		ASIPParser::ReleaseParameters() ;
	}

	ASIPParser* CSIPPriorityParser::Copy()
	{
		CSIPPriorityParser *pSIPPriorityParser = CSIPPriorityParser::GetAvailable() ;
		if( pSIPPriorityParser == NULL )
			return NULL ;

		*pSIPPriorityParser = *this ;

		return pSIPPriorityParser ;
	}

	// Grammer
	//Organization = "Organization" HCOLON [TEXT-UTF8-TRIM]

	// Please see RFC3261, Pages 174
	// Please see RFC3261, Pages from 219 to 232 for ABNF forms
	// Please see file ..\Document\SIPPriority Parsing Logic.txt for parsing algorithm

	// Page 174
		//The Priority header field indicates the urgency of the request as
		//perceived by the client. The Priority header field describes the
		//priority that the SIP request should have to the receiving human or
		//its agent. For example, it may be factored into decisions about call
		//routing and acceptance. For these decisions, a message containing no
		//Priority header field SHOULD be treated as if it specified a Priority
		//of "normal". The Priority header field does not influence the use of
		//communications resources such as packet forwarding priority in
		//routers or access to circuits in PSTN gateways. The header field can
		//have the values "non-urgent", "normal", "urgent", and "emergency",
		//but additional values can be defined elsewhere. It is RECOMMENDED
		//that the value of "emergency" only be used when life, limb, or
		//property are in imminent danger. Otherwise, there are no semantics
		//defined for this header field.
		//These are the values of RFC 2076 [38], with the addition of
		//"emergency".


	FW_RETURN_TYPE CSIPPriorityParser::Parse( const std::string &strStringToParse )
	{
		if( strStringToParse.empty() )
			return SIP_PARSE_ERR_EMPTY_STRING_TO_PARSE ;

		m_strPriority = strStringToParse ;
		
		return SIP_ERR_SUCCESS ;
	}

	std::string CSIPPriorityParser::ToString() const
	{
		std::string strSIPPriorityString = "" ;

		if( !m_strPriority.empty() )
			strSIPPriorityString = m_strPriority ;

		return strSIPPriorityString ;
	}

	std::string CSIPPriorityParser::GetHeaderName() const
	{
		return GetRuntimeHeaderName( SIP_HEADER_PRIORITY ) ;
	}
	
} // End namespace

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
India India
Hatim Haidry

VC++, Technical Architect

India

haidryhatim@gmail.com

Comments and Discussions