Commit 1e48ddba authored by urbant's avatar urbant
Browse files

decoding support for alert-info

parent 9e6c6fed
Loading
Loading
Loading
Loading
+58 −4
Original line number Diff line number Diff line
@@ -644,6 +644,7 @@ private:
		SIP_HEADER_ADD (Accept-Encoding,	,	acceptEncoding,	ACCEPT_ENCODING_E);
		SIP_HEADER_ADD (Accept-Language,	,	acceptLanguage,	ACCEPT_LANGUAGE_E);
		SIP_HEADER_ADD (Max-Forwards,	,	maxForwards,	MAX_FORWARDS_E);
		SIP_HEADER_ADD (Alert-Info,		,	alertInfo,	ALERT_INFO_E);
		{
			mEntries.push_back(Entry("", "", MessageHeader::id_undefinedHeader_List, ""));
			Entry& e = *mEntries.rbegin();
@@ -860,7 +861,7 @@ void To::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
}

void Accept::PreDecodeField (int id, Buffer& buffer) throw (DecodeError){
	static Regex reg_accept_args ("^[^;,\\r\\n]+");
	static Regex reg_accept_args ("^[^;,\\r\\n]");
	if (id == id_acceptArgs){
		if(reg_accept_args.Match(buffer)) {
			SetHypFieldIsPresent (id, 1);
@@ -903,7 +904,7 @@ void AcceptBody_List::PreDecodeField (int id, Buffer& buffer) throw (DecodeError
}

void AcceptEncoding::PreDecodeField (int id, Buffer& buffer) throw (DecodeError){
	static Regex reg_content_coding ("^[^,\\r\\n]+");
	static Regex reg_content_coding ("^[^,\\r\\n]");
	if (id == id_contentCoding){
		if(reg_content_coding.Match(buffer)) {
			SetHypFieldIsPresent (id, 1);
@@ -926,13 +927,13 @@ void ContentCoding_List::PreDecodeField (int id, Buffer& buffer) throw (DecodeEr

	if (GetSize() == 0 || bSeparated) {
		reg_content.AssertMatch(buffer, this);
		SetHypLength(reg_content.GetMatchedLength());
		SetHypFieldLength(reg_content.GetMatchedLength());
	} else
		SetHypSize(-2);
}

void AcceptLanguage::PreDecodeField (int id, Buffer& buffer) throw (DecodeError){
	static Regex reg_language_body ("^[^;,\\r\\n]+");
	static Regex reg_language_body ("^[^;,\\r\\n]");
	if (id == id_languageBody){
		if(reg_language_body.Match(buffer)) {
			SetHypFieldIsPresent (id, 1);
@@ -979,6 +980,59 @@ void MaxForwards::PreDecode (Buffer& buffer) throw (DecodeError)
	Get_forwards().SetFormat(Integer::AsciiDecimal);
}

void AlertInfo::PreDecodeField (int id, Buffer& buffer) throw (DecodeError){
	static Regex reg_alert_info ("^[^;,\\r\\n]");
	if (id == id_alertInfoBody){
		if(reg_alert_info.Match(buffer)) {
			SetHypFieldIsPresent (id, 1);
		} else {
			SetHypFieldIsPresent (id, 0);
		}
	}
}

void AlertInfoBody::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_url ("^<" SIPREG_ABSOLUTE_URI ">");
	static Regex reg_semicolon ("^" SIPREG_SEMI);
	switch (id){
		case id_url:
			reg_url.AssertMatch (buffer, this);
			buffer.SetPosition(buffer.GetPosition() + 8);
			SetHypFieldLength(id, reg_url.GetMatchedLength() - 16);
			break;
		case id_genericParams:
			if (reg_semicolon.Match (buffer)) {
				SetHypFieldIsPresent(id, 1);
			} else {
				SetHypFieldIsPresent(id, 0);
			}
	}
}

void AlertInfoBody::PostDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	switch (id){
		case id_url:
			buffer.SetPosition(buffer.GetPosition() + 8);
			break;
	}
}

void AlertInfoBody_List::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_separator ("^" SIPREG_COMMA);

	if (!buffer.GetBitsLeft())
		return;
	if (GetSize() == 0)
		return; // at least one element must be present
	else if (reg_separator.Match(buffer))
		buffer.SetPosition(buffer.GetPosition() + reg_separator.GetMatchedLength());
	else
		SetHypSize(-2);
}

void NameAddr::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_display_name ("^" SIPREG_DISPLAY_NAME);