Commit 437e3c18 authored by urbant's avatar urbant
Browse files

decoding support for RFC 3455 and 3515

parent 0e57d1c3
Loading
Loading
Loading
Loading
+121 −5
Original line number Diff line number Diff line
@@ -371,10 +371,14 @@ void HostPort::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
void SemicolonParam_List::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_separator ("^" SIPREG_SEMI);
	if (!buffer.GetBitsLeft())
		return;
	if (reg_separator.Match(buffer))
		buffer.SetPosition(buffer.GetPosition() + reg_separator.GetMatchedLength());
	if (reg_separator.Match(buffer)) // the separator can be in the beginning
		reg_separator.MovePast(buffer);
}

void SemicolonParam_List::PostDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	if (detect_semi (buffer))
		SetHypSize (GetSize() + 1);
	else
		SetHypSize (-2);
}
@@ -760,6 +764,13 @@ private:
		SIP_HEADER_ADD (Security-Client,		,	securityClient,		SECURITY_CLIENT_E);
		SIP_HEADER_ADD (Security-Server,		,	securityServer,		SECURITY_SERVER_E);
		SIP_HEADER_ADD (Security-Verify,		,	securityVerify,		SECURITY_VERIFY_E);
		SIP_HEADER_ADD (P-Associated-URI,		,	pAssociatedURI,		P_ASSOCIATED_URI_E);
		SIP_HEADER_ADD (P-Called-Party-ID,		,	pCalledPartyID,		P_CALLED_PARTY_E);
		SIP_HEADER_ADD (P-Visited-Network-ID,	,	pVisitedNetworkID,	P_VISITED_NETWORK_E);
		SIP_HEADER_ADD (P-Access-Network-Info,	,	pAccessNetworkInfo,	P_ACCESS_NETWORK_INFO_E);
		SIP_HEADER_ADD (P-Charging-Function-Addresses,	,	pChargingFunctionAddresses,		P_CHARGING_FUNCTION_ADDRESSES_E);
		SIP_HEADER_ADD (P-Charging-Vector,		,	pChargingVector,	P_CHARGING_VECTOR_E);
		SIP_HEADER_ADD (ReferTo,	r,	referTo,	P_REFER_TO_E);
		{
			mEntries.push_back(Entry("", "", MessageHeader::id_undefinedHeader_List, ""));
			Entry& e = *mEntries.rbegin();
@@ -834,6 +845,9 @@ void MessageHeader::PreDecodeField (Buffer& buffer) throw (DecodeError)
			case id_securityClient:
			case id_securityServer:
			case id_securityVerify:
			case id_pAssociatedURI:
			case id_pCalledPartyID:
			case id_pVisitedNetworkID:
			case id_undefinedHeader_List:
				// these fields can appear multiple times
				break;
@@ -2259,4 +2273,106 @@ void SecurityMechanism_List::PostDecodeField (int id, Buffer& buffer) throw (Dec
		SetHypSize (-2);
}

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

	switch (id) { 
		case id_genericParams:
			SetHypFieldIsPresent (id, reg_separator.Match (buffer) ? 1 : 0);
			break;
	}
}

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

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

void VnetworkSpec::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_token ("^(" SIPREG_TOKEN ")|(" SIPREG_QUOTED_STRING ")");
	static Regex reg_separator ("^" SIPREG_SEMI);

	switch (id) { 
		case id_vNetworkSpecToken:
			reg_token.AssertMatch (buffer, this);
			SetHypFieldLength (id, reg_token.GetMatchedLength());
			break;
		case id_genericParams:
			SetHypFieldIsPresent (id, reg_separator.Match (buffer) ? 1 : 0);
			break;
	}
}

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

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

void PAccessNetworkInfo::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_token ("^" SIPREG_TOKEN);
	static Regex reg_separator ("^" SIPREG_SEMI);

	switch (id) { 
		case id_accessType:
			reg_token.AssertMatch (buffer, this);
			SetHypFieldLength (id, reg_token.GetMatchedLength());
			break;
		case id_genericParams:
			SetHypFieldIsPresent (id, reg_separator.Match (buffer) ? 1 : 0);
			break;
	}
}

void PChargingFunctionAddresses::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_token ("^" SIPREG_TOKEN);
	switch (id) { 
		case id_chargeAddrParams:
			SetHypFieldIsPresent (id, reg_token.Match (buffer) ? 1 : 0);
			break;
	}
}

void PChargingVector::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_token ("^" SIPREG_TOKEN);
	switch (id) { 
		case id_chargeParams:
			SetHypFieldIsPresent (id, reg_token.Match (buffer) ? 1 : 0);
			break;
	}
}

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

	switch (id) {
		case id_referToParams:
			SetHypFieldIsPresent (id, reg_separator.Match (buffer) ? 1 : 0);
			break;
	}
}

}} // namespaces