4
%% Copyright Ericsson AB 2010-2011. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
22
-include_lib("diameter/include/diameter.hrl").
23
-include_lib("diameter/src/app/diameter_gen_base_rfc3588.hrl").
35
peer_up(_SvcName, {PeerRef, _}, State) ->
36
io:format("up: ~p~n", [PeerRef]),
39
peer_down(_SvcName, {PeerRef, _}, State) ->
40
io:format("down: ~p~n", [PeerRef]),
43
%% Returning 'relay' from handle_request causes diameter to resend the
44
%% incoming request, which leads to pick_peer and prepare_request
45
%% callbacks as if sending explicitly. The 'extra' argument is
46
%% appended to the argument list for callbacks following from
47
%% resending of the request.
49
handle_request(_Pkt, _SvcName, _Peer) ->
50
{relay, [{timeout, 1000}, {extra, [relayed]}]}.
52
%% diameter will filter the sender in the Peers list.
53
pick_peer([Peer | _], _, _SvcName, _State, relayed) ->
56
prepare_request(Pkt, _SvcName, _Peer, relayed) ->
59
prepare_retransmit(Pkt, _SvcName, _Peer, relayed) ->
62
%% diameter expects handle_answer to return the diameter_packet record
63
%% containing the answer when called for a relayed request.
65
handle_answer(Pkt, _Request, _SvcName, _Peer, relayed) ->
68
handle_error(Reason, _Request, _SvcName, _Peer, relayed) ->