From 6f55c32ccb6811d2896d5a761b528f08bc9052ee Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Thu, 11 Oct 2012 01:40:29 +0200 Subject: Add service_info for a peer_ref() This allows a diameter_app callback to retrieve the corresponding configuration as passed to diameter:add_transport/2. --- lib/diameter/src/base/diameter_service.erl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/diameter/src/base/diameter_service.erl b/lib/diameter/src/base/diameter_service.erl index b4e54cc9f9..cffba4fc94 100644 --- a/lib/diameter/src/base/diameter_service.erl +++ b/lib/diameter/src/base/diameter_service.erl @@ -3051,6 +3051,19 @@ tagged_info(Item, S) undefined end; +tagged_info(TPid, #state{peerT = PT, connT = CT}) + when is_pid(TPid) -> + try + [#conn{peer = Pid}] = ets:lookup(CT, TPid), + [#peer{ref = Ref, type = Type, options = Opts}] = ets:lookup(PT, Pid), + [{ref, Ref}, + {type, Type}, + {options, Opts}] + catch + error:_ -> + [] + end; + tagged_info(Items, S) when is_list(Items) -> [T || I <- Items, T <- [tagged_info(I,S)], T /= undefined, T /= []]; -- cgit v1.2.3 From aaff2cb270d6cf13ff3cd074b3f8c212211ccb7f Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Thu, 11 Oct 2012 01:40:35 +0200 Subject: Use peer_ref() service_info in traffic suite --- lib/diameter/test/diameter_traffic_SUITE.erl | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/lib/diameter/test/diameter_traffic_SUITE.erl b/lib/diameter/test/diameter_traffic_SUITE.erl index c391ba0317..5744ff0307 100644 --- a/lib/diameter/test/diameter_traffic_SUITE.erl +++ b/lib/diameter/test/diameter_traffic_SUITE.erl @@ -626,22 +626,13 @@ pick_peer(Peers, _, ?CLIENT, _State, send_detach, Id, {_,_}) -> find(Id, Peers). find(Id, Peers) -> - [P] = lists:flatmap(fun(C) -> peer(Id, C) end, - diameter:service_info(?CLIENT, transport)), - case lists:keyfind(P, 1, Peers) of %% OTP-10470 will provide a better way. - {_,_} = TC -> - {ok, TC}; - false = No -> - No - end. + [P] = [P || P <- Peers, id(Id, P)], + {ok, P}. -peer(Id, [{ref, _}, - {type, connect}, - {options, Opts}, - {watchdog, _}, - {peer, {PeerRef, _}} - | _]) -> - [PeerRef || lists:member({id, Id}, Opts)]. +id(Id, {Pid, _Caps}) -> + [{ref, _}, {type, _}, {options, Opts} | _] + = diameter:service_info(?CLIENT, Pid), + lists:member({id, Id}, Opts). %% prepare_request/5-6 -- cgit v1.2.3 From e18806dce4e043837efb1ddd5e6e31b4237e618a Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Thu, 11 Oct 2012 02:07:00 +0200 Subject: Document peer_ref() service_info --- lib/diameter/doc/src/diameter.xml | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/lib/diameter/doc/src/diameter.xml b/lib/diameter/doc/src/diameter.xml index b7936dbacc..80863f8eff 100644 --- a/lib/diameter/doc/src/diameter.xml +++ b/lib/diameter/doc/src/diameter.xml @@ -1212,6 +1212,12 @@ DPA or timeout.

Return information about a started service. +Requesting info for an unknown service causes undefined to be +returned. +Requesting a list of items causes a tagged list to be +returned.

+ +

Item can be one of the following.

@@ -1482,13 +1488,27 @@ The Diameter-level statistics returned by transport and connections info are based upon these entries.

-
- +diameter_app:peer_ref() +

-Requesting info for an unknown service causes undefined to be -returned. -Requesting a list of items causes a tagged list to be -returned.

+Return transport configuration associated with a single peer, as +passed to add_transport/2. +The returned list is empty if the peer is unknown. +Otherwise it contains the ref, type and options +tuples as in transport and connections info above. +For example:

+ + +[{ref,#Ref<0.0.0.61>}, + {type,accept}, + {options,[{transport_module,diameter_tcp}, + {transport_config,[{reuseaddr,true}, + {ip,{127,0,0,1}}, + {port,3868}]}]}] + +
+ +
-- cgit v1.2.3