My issue is that I want to select from a new group of destinations only when a particular failure status has been received, so I can't simply only call ds_next_dst() in failure_route.
Anyways, the problem is not in the initial group selection, but rather in the subsequent calls to ds_next_dst(). I changed the logic to how you recommended, with ds_select_dst() being called only in request_route, and ds_next_dst()
only called by failure_route. The problem is exactly the same: ds_next_dst() starts selecting destinations that are not in the group that was initially selected with ds_select_dst().
dispatcher [dispatch.c:2097]: ds_manage_routes(): set [2]
dispatcher [dispatch.c:2213]: ds_manage_routes(): using alg [8] hash [0]
dispatcher [dispatch.c:2260]: ds_manage_routes(): selected [8-2-0/0] <sip:127.0.0.1:5072;transport=udp>
dispatcher [dispatch.c:2281]: ds_manage_routes(): using first entry [2/0]
dispatcher [dispatch.c:2057]: ds_select_dst_limit(): selected target destinations: 1
<script>: REQUEST ROUTE: Relayed to [sip:127.0.0.1:5072;transport=udp] via forced socket [udp:127.0.0.1:5074]
<script>: FAILURE ROUTE: 400 Bad Request, trying next available gateway...
<script>: FAILURE ROUTE: Selecting next destination from: [grp=2;uri=sip:127.0.0.1:5072;transport=udp;]
dispatcher [dispatch.c:2357]: ds_update_dst(): updating dst
dispatcher [dispatch.c:2373]: ds_update_dst(): updating dst with next record
dispatcher [dispatch.c:2403]: ds_update_dst(): using next dst uri [sip:127.0.0.1:5072;transport=udp]
<script>: FAILURE ROUTE: Next destination selected: [sip:127.0.0.1:5072;transport=udp] from [grp=2;uri=sip:127.0.0.1:5072;transport=udp;]
<script>: FAILURE ROUTE: 400 Bad Request, trying next available gateway...
<script>: FAILURE ROUTE: Selecting next destination from: [grp=2;uri=sip:127.0.0.1:5072;transport=udp;]
dispatcher [dispatch.c:2357]: ds_update_dst(): updating dst
dispatcher [dispatch.c:2373]: ds_update_dst(): updating dst with next record
dispatcher [dispatch.c:2403]: ds_update_dst(): using next dst uri [sip:127.0.0.1:5071;transport=udp]
<script>: FAILURE ROUTE: Next destination selected: [sip:127.0.0.1:5071;transport=udp] from [grp=1;uri=sip:127.0.0.1:5071;transport=udp;]
It happens in this order:
1. Request_route ds_select_dst() selects group=2 destination=sip:127.0.0.1:5072;transport=udp
2. Failure_route ds_next_dst() selects group=2 destination=sip:127.0.0.1:5072;transport=udp (again?)
3. Failure_route
ds_next_dst() selects group=1 destination=sip:127.0.0.1:5071;transport=udp
I don't understand what I'm doing incorrectly for it to select a destination from group 1.
One thing that is standing out to me is the log line showing "ds_select_dst_limit(): selected target destinations: 1" when ds_select_dst() is called. Based on the readme for ds_select_dst(), all addresses from the group are stored
in the XAVP if bit 2 of the 'flags' parameter is set (which it is) unless otherwise limited by the 'limit' parameter (it is not). However, when I print out the XAVP with xavp_params_implode, the XAVP only ever contains a single destination.