anchor.diff:  			error_logger:warning_report(["Unable to process DIAMETER request",
   					{origin_host, OHost}, {origin_realm, ORealm},
   					{request, Request}, {error, Reason1}]),
  -			diameter_error(SId, ?'DIAMETER_BASE_RESULT-CODE_UNABLE_TO_COMPLY', OHost,
  -					ORealm, RequestType, RequestNum)
  +			diameter_error(SessionId, ?'DIAMETER_BASE_RESULT-CODE_UNABLE_TO_COMPLY',
  +					OHost, ORealm, RequestType, RequestNum)
  +	end;
  +process_request1(?'3GPP_CC-REQUEST-TYPE_UPDATE_REQUEST' = RequestType,
  +		#'3gpp_ro_CCR'{'Multiple-Services-Credit-Control' = MSCC1,
  +		'Service-Information' = ServiceInformation,
  +		'Service-Context-Id' = SvcContextId,
  +		'Event-Timestamp' = EventTimestamp} = Request, SessionId,
  +		RequestNum, Subscriber, OHost, _DHost, ORealm, _DRealm,
  +		IpAddress, Port) when length(MSCC1) > 0 ->
  +	try
  +		{Direction, Address} = direction_address(ServiceInformation),
  +		ServiceType = service_type(SvcContextId),
  +		ServiceNetwork = service_network(ServiceInformation),
  +		Server = {IpAddress, Port},
  +		Timestamp = case EventTimestamp of
  +			[{{_, _, _}, {_, _, _}} = TS] ->
  +				TS;
  +			_ ->
  +				calendar:universal_time()
  +		end,
  +		Amounts = get_mscc(MSCC1),
  +		case rate(ServiceType, ServiceNetwork, Subscriber,
  +				Timestamp, Address, Direction, interim, SessionId,
  +				Amounts) of
  +			{MSCC2, ResultCode} when is_list(MSCC2) ->
  +				Reply = diameter_answer(SessionId, MSCC2,
  +						ResultCode, OHost, ORealm, RequestType, RequestNum),
  +				ok = ocs_log:acct_log(diameter, Server,
  +						accounting_event_type(RequestType), Request, Reply, undefined),
  +				Reply;
  +			{error, Reason} ->
  +				error_logger:error_report(["Rating Error",
  +						{module, ?MODULE}, {error, Reason},
  +						{origin_host, OHost}, {origin_realm, ORealm},
  +						{type, interim}, {subscriber, Subscriber},
  +						{address, Address}, {direction, Direction},
  +						{amounts, Amounts}]),
  +				Reply = diameter_error(SessionId,
  +						?'DIAMETER_CC_APP_RESULT-CODE_RATING_FAILED',
  +						OHost, ORealm, RequestType, RequestNum),
  +				ok = ocs_log:acct_log(diameter, Server,
  +						accounting_event_type(RequestType), Request, Reply, undefined),
  +				Reply
  +		end
  +	catch
  +		_:Reason1 ->
  +			error_logger:warning_report(["Unable to process DIAMETER request",
  +					{origin_host, OHost}, {origin_realm, ORealm},
  +					{request, Request}, {error, Reason1}]),
  +			diameter_error(SessionId, ?'DIAMETER_BASE_RESULT-CODE_UNABLE_TO_COMPLY',
  +					OHost, ORealm, RequestType, RequestNum)
  +	end;
  +process_request1(?'3GPP_CC-REQUEST-TYPE_TERMINATION_REQUEST' = RequestType,
  +		#'3gpp_ro_CCR'{'Multiple-Services-Credit-Control' = MSCC1,
  +		'Service-Information' = ServiceInformation,
  +		'Service-Context-Id' = SvcContextId,
  +		'Event-Timestamp' = EventTimestamp} = Request, SessionId,
  +		RequestNum, Subscriber, OHost, _DHost, ORealm, _DRealm,
  +		IpAddress, Port) when length(MSCC1) > 0 ->
  +	try
  +		{Direction, Address} = direction_address(ServiceInformation),
  +		ServiceType = service_type(SvcContextId),
  +		ServiceNetwork = service_network(ServiceInformation),
  +		Server = {IpAddress, Port},
  +		Timestamp = case EventTimestamp of
  +			[{{_, _, _}, {_, _, _}} = TS] ->
  +				TS;
  +			_ ->
  +				calendar:universal_time()
  +		end,
  +		Amounts = get_mscc(MSCC1),
  +		case rate(ServiceType, ServiceNetwork, Subscriber,
  +				Timestamp, Address, Direction, final, SessionId,
  +				Amounts) of
  +			{MSCC2, ResultCode} ->
  +				Reply = diameter_answer(SessionId, MSCC2,
  +						ResultCode, OHost, ORealm, RequestType, RequestNum),
  +				ok = ocs_log:acct_log(diameter, Server,
  +						accounting_event_type(RequestType), Request, Reply, undefined),
  +				Reply;
  +			{MSCC2, ResultCode, Rated} when is_list(Rated) ->
  +				Reply = diameter_answer(SessionId, MSCC2,
  +						ResultCode, OHost, ORealm, RequestType, RequestNum),
  +				ok = ocs_log:acct_log(diameter, Server,
  +						accounting_event_type(RequestType), Request, Reply, Rated),
  +				Reply;
  +			{error, Reason} ->
  +				error_logger:error_report(["Rating Error",
  +						{module, ?MODULE}, {error, Reason},
  +						{origin_host, OHost}, {origin_realm, ORealm},
  +						{type, final}, {subscriber, Subscriber},
  +						{address, Address}, {direction, Direction},
  +						{amounts, amounts}]),
  +				Reply = diameter_error(SessionId, ?'DIAMETER_CC_APP_RESULT-CODE_RATING_FAILED',
  +						OHost, ORealm, RequestType, RequestNum),
  +				ok = ocs_log:acct_log(diameter, Server,
  +						accounting_event_type(RequestType), Request, Reply, undefined),
  +				Reply
  +		end
  +	catch
  +		_:Reason1 ->
  +			error_logger:warning_report(["Unable to process DIAMETER request",
  +					{origin_host, OHost}, {origin_realm, ORealm},
  +					{request, Request}, {error, Reason1}]),
  +			diameter_error(SessionId, ?'DIAMETER_BASE_RESULT-CODE_UNABLE_TO_COMPLY',
  +					OHost, ORealm, RequestType, RequestNum)
   	end;
   process_request1(?'3GPP_CC-REQUEST-TYPE_TERMINATION_REQUEST' = RequestType,
   		#'3gpp_ro_CCR'{'Multiple-Services-Credit-Control' = []} = Request,
  -		SId, RequestNum, _Subscriber, OHost, _DHost,
  +		SessionId, RequestNum, _Subscriber, OHost, _DHost,
   		ORealm, _DRealm, IpAddress, Port) ->
  -	Reply = diameter_answer(SId, [], [], undefined,
  +	Reply = diameter_answer(SessionId, [],
   			?'DIAMETER_BASE_RESULT-CODE_SUCCESS',
   			OHost, ORealm, RequestType, RequestNum),
   	ok = ocs_log:acct_log(diameter, {IpAddress, Port},
   			accounting_event_type(RequestType), Request, Reply, undefined),
   	Reply.
   
  --spec diameter_answer(SessionId, ServiceIdentifier, RatingGroup, GrantedUnits,
  -		ResultCode, OriginHost, OriginRealm, RequestType, RequestNum) -> Result
  -			when
  -				SessionId :: string(),
  -				ServiceIdentifier :: [non_neg_integer()],
  -				RatingGroup :: [non_neg_integer()],
  -				GrantedUnits :: undefined | #'3gpp_ro_Granted-Service-Unit'{},
  -				ResultCode :: integer(),
  -				OriginHost :: string(),
  -				OriginRealm :: string(),
  -				RequestType :: integer(),
  -				RequestNum :: integer(),
  -				Result :: #'3gpp_ro_CCA'{}.
  +-spec diameter_answer(SessionId, MSCC, ResultCode,
  +		OriginHost, OriginRealm, RequestType, RequestNum) -> Result
  +	when
  +		SessionId :: binary(),
  +		MSCC :: [#'3gpp_ro_Multiple-Services-Credit-Control'{}],
  +		ResultCode :: pos_integer(),
  +		OriginHost :: string(),
  +		OriginRealm :: string(),
  +		RequestType :: integer(),
  +		RequestNum :: integer(),
  +		Result :: #'3gpp_ro_CCA'{}.
   %% @doc Build CCA response.
   %% @hidden
  -diameter_answer(SId, _ServiceIdentifier, _RatingGroup, undefined,
  -		ResultCode, OHost, ORealm, RequestType, RequestNum) ->
  -	#'3gpp_ro_CCA'{'Session-Id' = SId, 'Result-Code' = ResultCode,
  +diameter_answer(SessionId, MSCC, ResultCode,
  +		OHost, ORealm, RequestType, RequestNum) ->
  +	#'3gpp_ro_CCA'{'Session-Id' = SessionId,
   			'Origin-Host' = OHost, 'Origin-Realm' = ORealm,
  -			'Auth-Application-Id' = ?RO_APPLICATION_ID, 'CC-Request-Type' = RequestType,
  -			'CC-Request-Number' = RequestNum};
  -diameter_answer(SId, ServiceIdentifier, RatingGroup, GrantedUnits,
  -		ResultCode, OHost, ORealm, RequestType, RequestNum) ->
  -	MultiServices_CC = #'3gpp_ro_Multiple-Services-Credit-Control'{
  -			'Service-Identifier' = ServiceIdentifier,
  -			'Result-Code' = [ResultCode],
  -			'Rating-Group' = RatingGroup,
  -			'Granted-Service-Unit' = [GrantedUnits]},
  -	#'3gpp_ro_CCA'{'Session-Id' = SId, 'Result-Code' = ResultCode,
  -			'Origin-Host' = OHost, 'Origin-Realm' = ORealm,
  -			'Auth-Application-Id' = ?RO_APPLICATION_ID, 'CC-Request-Type' = RequestType,
  +			'Auth-Application-Id' = ?RO_APPLICATION_ID,
  +			'CC-Request-Type' = RequestType,
   			'CC-Request-Number' = RequestNum,
  -			'Multiple-Services-Credit-Control' = [MultiServices_CC]}.
  +			'Multiple-Services-Credit-Control' = MSCC,
  +			'Result-Code' = ResultCode}.
   
   -spec diameter_error(SessionId, ResultCode, OriginHost,
   		OriginRealm, RequestType, RequestNum) -> Reply
   	when
  -		SessionId :: string(),
  -		ResultCode :: integer(),
  +		SessionId :: binary(),
  +		ResultCode :: pos_integer(),
   		OriginHost :: string(),
   		OriginRealm :: string(),
   		RequestType :: integer(),
  
positive.code: 				error_logger:error_report(["Rating Error",
  						{module, ?MODULE}, {error, Reason},
  						{origin_host, OHost}, {origin_realm, ORealm},
  						{type, final}, {subscriber, Subscriber},
  						{address, Address}, {direction, Direction},
  						{used, DebitAmount}]),
  				Reply = diameter_error(SId, ?'DIAMETER_CC_APP_RESULT-CODE_RATING_FAILED',
  						OHost, ORealm, RequestType, RequestNum),
  				ok = ocs_log:acct_log(diameter, Server,
  						accounting_event_type(RequestType), Request, Reply, undefined),
  
negative.code: 		Reply :: #'3gpp_ro_CCA'{}.
  %% @doc Send CCA to DIAMETER client indicating an operation failure.
  %% @hidden
  diameter_error(SessionId, ResultCode, OHost, ORealm, RequestType, RequestNum) ->
  	#'3gpp_ro_CCA'{'Session-Id' = SessionId, 'Result-Code' = ResultCode,
  			'Origin-Host' = OHost, 'Origin-Realm' = ORealm,
  			'Auth-Application-Id' = ?RO_APPLICATION_ID, 'CC-Request-Type' = RequestType,
  			'CC-Request-Number' = RequestNum}.
  