Commit d2665741 authored by urbant's avatar urbant
Browse files

decoding support for call-info

parent 60c451ff
Loading
Loading
Loading
Loading
+55 −0
Original line number Diff line number Diff line
@@ -671,6 +671,7 @@ private:
		SIP_HEADER_ADD (Allow,		 ,	allow,		ALLOW_E);
		SIP_HEADER_ADD (Authentication-Info,	,	authenticationInfo,	AUTHENTICATION_INFO_E);
		SIP_HEADER_ADD (Authorization,	,	authorization,	AUTHORIZATION_E);
		SIP_HEADER_ADD (Call-Info,		,	callInfo,		CALL_INFO_E);
		{
			mEntries.push_back(Entry("", "", MessageHeader::id_undefinedHeader_List, ""));
			Entry& e = *mEntries.rbegin();
@@ -1124,6 +1125,60 @@ void OtherAuth::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
	}
}

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

void CallInfoBody::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_infoParams:
			if (reg_semicolon.Match (buffer)) {
				SetHypFieldIsPresent(id, 1);
			} else {
				SetHypFieldIsPresent(id, 0);
			}
	}
}

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

void CallInfoBody_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);