Commit 69a87201 authored by urbant's avatar urbant
Browse files

decoding support for unsupported, user-agent, warning, www-authenticate

parent 307c635e
Loading
Loading
Loading
Loading
+69 −0
Original line number Diff line number Diff line
@@ -726,6 +726,10 @@ private:
		SIP_HEADER_ADD (Supported,	,	supported,	SUPPORTED_E);
		SIP_HEADER_ADD (Subject,	s,	subject,	SUBJECT_E);
		SIP_HEADER_ADD (Timestamp,	,	timestamp,	TIMESTAMP_E);
		SIP_HEADER_ADD (Unsupported,	,	unsupported,	UNSUPPORTED_E);
		SIP_HEADER_ADD (User-Agent,	,	userAgent,	USER_AGENT_E);
		SIP_HEADER_ADD (Warning,	,	warning,	WARNING_E);
		SIP_HEADER_ADD (WWW-Authenticate,		,	wwwAuthenticate,	WWW_AUTHENTICATE_E);
		{
			mEntries.push_back(Entry("", "", MessageHeader::id_undefinedHeader_List, ""));
			Entry& e = *mEntries.rbegin();
@@ -790,6 +794,7 @@ void MessageHeader::PreDecodeField (Buffer& buffer) throw (DecodeError)
			case id_supported:
			case id_unsupported:
			case id_via:
			case id_warning:
			case id_undefinedHeader_List:
				// these fields can appear multiple times
				break;
@@ -1919,4 +1924,68 @@ void TimeValue::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
	}
}

void WarningValue_List::PreDecode (Buffer& buffer) throw (DecodeError)
{
	SetHypSize (GetSize() + 1);
	SetHypAppend (1);
}

void WarningValue_List::PostDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	if (detect_comma (buffer))
		SetHypSize (GetSize() + 1);
	else
		SetHypSize (-2);
}

void WarningValue::PreDecode (Buffer& buffer) throw (DecodeError)
{
	Get_warnCode().SetFormat(Integer::AsciiDecimal);
}

void WarningValue::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_separator ("^[ ]");
	static Regex reg_text ("^" SIPREG_QUOTED_STRING);
	switch (id) { 
		case id_warnAgent:
			reg_separator.AssertMatch (buffer, this);
			reg_separator.MovePast (buffer);
			break;
		case id_WarnText:
			reg_separator.AssertMatch (buffer, this);
			reg_separator.MovePast (buffer);
			reg_text.AssertMatch (buffer, this);
			buffer.SetPosition(buffer.GetPosition() + 8); // remove starting quota
			SetHypFieldLength (id, reg_text.GetMatchedLength() - 16);
			break;
	}
}

void WarningValue::PostDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	switch (id) { 
		case id_WarnText:
			buffer.SetPosition(buffer.GetPosition() + 8); // remove ending quota
			break;
	}
}

void WarnAgent::PreDecode (Buffer& buffer) throw (DecodeError)
{
	static Regex reg_host ("^" SIPREG_HOST "([:][0-9]+)?");
	static Regex reg_pseudonym ("^" SIPREG_TOKEN);
	int nLen1 = -1;
	int nLen2 = -1;
	if (reg_host.Match (buffer))
		nLen1 = reg_host.GetMatchedLength();
	if (reg_pseudonym.Match (buffer))
		nLen2 = reg_pseudonym.GetMatchedLength();
	if (nLen2 > nLen1) {
		SetHypChosenId (id_pseudonym);
		SetHypFieldLength (id_pseudonym, nLen2);
	} else
		SetHypChosenId (id_hostPort);
}

}} // namespaces