Commit 2c0c9d0b authored by urbant's avatar urbant
Browse files

decoding support for date, error-info and expires

parent cd31d895
Loading
Loading
Loading
Loading
+69 −1
Original line number Diff line number Diff line
@@ -700,8 +700,11 @@ private:
		SIP_HEADER_ADD (Authorization,	,	authorization,	AUTHORIZATION_E);
		SIP_HEADER_ADD (Call-Info,		,	callInfo,		CALL_INFO_E);
		SIP_HEADER_ADD (Content-Disposition,	,	contentDisposition,	CONTENT_DISPOSITION_E);
		SIP_HEADER_ADD (Content-Encoding,	,	contentEncoding,	CONTENT_ENCODING_E);
		SIP_HEADER_ADD (Content-Encoding,	e,	contentEncoding,	CONTENT_ENCODING_E);
		SIP_HEADER_ADD (Content-Language,	,	contentLanguage,	CONTENT_LANGUAGE_E);
		SIP_HEADER_ADD (Date,		 ,	date,		DATE_E);
		SIP_HEADER_ADD (Error-Info,		,	errorInfo,	ERROR_INFO_E);
		SIP_HEADER_ADD (Expires,	,	expires,	EXPIRES_E);
		{
			mEntries.push_back(Entry("", "", MessageHeader::id_undefinedHeader_List, ""));
			Entry& e = *mEntries.rbegin();
@@ -1186,6 +1189,63 @@ void LanguageTag_List::PreDecodeField (int id, Buffer& buffer) throw (DecodeErro
		SetHypSize(-2);
}

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

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

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

void ErrorInfoBody_List::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	if (!decode_comma_separated (this, buffer))
		SetHypSize(-2);
}

void Expires::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_delta_sec ("^[0-9]");

	switch (id) {
	case id_deltaSec: 
		reg_delta_sec.AssertMatch (buffer, this);
		SetHypFieldLength (id, reg_delta_sec.GetMatchedLength());
		break;
	}
}

void NameAddr::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_display_name ("^" SIPREG_DISPLAY_NAME);
@@ -1211,6 +1271,14 @@ void NameAddr::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
	}
}

void Date::PreDecodeField (int id, Buffer& buffer) throw (DecodeError){
	static Regex reg_date ("^[^\\r\\n]+");
	if (id == id_sipDate){
		reg_date.AssertMatch(buffer, this);
		SetHypFieldLength(id, reg_date.GetMatchedLength());
	}
}

void NameAddr::PostDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_raquot ("^>");