Commit 243fe66a authored by urbant's avatar urbant
Browse files

Decoding support for contact ant to fields

parent b2f5366f
Loading
Loading
Loading
Loading
+51 −1
Original line number Diff line number Diff line
@@ -628,6 +628,8 @@ private:
		SIP_HEADER_ADD (CSeq,		 ,	cSeq,		CSEQ_E);
		SIP_HEADER_ADD (Content-Length,	l,	contentLength,	CONTENT_LENGTH_E);
		SIP_HEADER_ADD (Content-Type,	c,	contentType,	CONTENT_TYPE_E);
		SIP_HEADER_ADD (Contact,	m,	contact,		CONTACT_E);
		SIP_HEADER_ADD (To,			t,	toField,		TO_E);
		{
			mEntries.push_back(Entry("", "", MessageHeader::id_undefinedHeader_List, ""));
			Entry& e = *mEntries.rbegin();
@@ -777,12 +779,60 @@ void Addr_Union::PreDecode (Buffer& buffer) throw (DecodeError)
	);
}

void ContactBody::PreDecode (Buffer& buffer) throw (DecodeError)
{
	static Regex reg_asterisk ("^[*]");
	if (reg_asterisk.Match (buffer)) {
		SetHypChosenId (id_wildcard);
		SetHypFieldLength(id_wildcard, 8);
	} else {
		SetHypChosenId (id_contactAddresses);
	}
}

void ContactAddress_List::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_separator ("^" SIPREG_SWS "[,]" SIPREG_SWS);

	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 ContactAddress::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_semicolon ("^;");
	if (id == id_contactParams) {
		if(reg_semicolon.Match(buffer)) {
			SetHypFieldIsPresent (id, 1);
		} else {
			SetHypFieldIsPresent (id, 0);
		}
	}
}

void From::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_semicolon ("^;");
	if (id == id_fromParams) {
		if(reg_semicolon.Match(buffer)) {
			Unsigned(8).Decode(buffer);
			SetHypFieldIsPresent (id, 1);
		} else {
			SetHypFieldIsPresent (id, 0);
		}
	}
}

void To::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_semicolon ("^;");
	if (id == id_toParams) {
		if(reg_semicolon.Match(buffer)) {
			SetHypFieldIsPresent (id, 1);
		} else {
			SetHypFieldIsPresent (id, 0);