Commit 85b0ffa3 authored by baire's avatar baire
Browse files

support decoding the payload

parent 375b5938
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -1014,4 +1014,46 @@ void ContentType::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
	
}

#define SIP_MESSAGE_CODET(msgname) \
void msgname::PreDecodeField (int id, Buffer& buffer) throw (DecodeError) \
{ \
	switch (id) { \
	case id_messageBody: \
	/* TODO: decode SDP payload in messageBody instead of payload */ \
		SetHypFieldIsPresent (id_messageBody, 0); \
		SetHypFieldIsPresent (id_payload, buffer.GetBitsLeft() ? 1 : 0); \
		break; \
	} \
}

SIP_MESSAGE_CODET (Response);
SIP_MESSAGE_CODET (Request)
SIP_MESSAGE_CODET (REGISTER_Request)
SIP_MESSAGE_CODET (INVITE_Request)
SIP_MESSAGE_CODET (OPTIONS_Request)
SIP_MESSAGE_CODET (BYE_Request)
SIP_MESSAGE_CODET (CANCEL_Request)
SIP_MESSAGE_CODET (ACK_Request)
SIP_MESSAGE_CODET (PRACK_Request)
SIP_MESSAGE_CODET (NOTIFY_Request)
SIP_MESSAGE_CODET (SUBSCRIBE_Request)
SIP_MESSAGE_CODET (PUBLISH_Request)
SIP_MESSAGE_CODET (UPDATE_Request)
SIP_MESSAGE_CODET (REFER_Request)
SIP_MESSAGE_CODET (MESSAGE_Request)
SIP_MESSAGE_CODET (INFO_Request)

void Payload::PreDecode(Buffer& buffer) throw (DecodeError)
{
	// FIXME: this is not very clean
	// 	  -> should provide a way to skip a field in the decoder
	buffer.SetPosition(buffer.GetPosition() - Get_payloadlength().GetLength());
}

void Payload::PostDecode(Buffer& buffer) throw (DecodeError)
{
	Get_payloadlength().SetValue(Get_payloadvalue().GetLength() / 8);
}


}} // namespaces