anchor.diff:      rc([Dict:rec2msg(element(1, Rec))], RC, Dict).
   
   %% failed_avp/3
  +
  +failed_avp(_, [] = No, _) ->
  +    No;
   
   failed_avp(Msg, [_|_] = Avps, Dict) ->
       [failed(Msg, [{'AVP', Avps}], Dict)].
  
positive.code: %% select_error/3
  %%
  %% Extract the first appropriate RC or {RC, #diameter_avp{}}
  %% pair from an errors list.
  %%
  %% RFC 6733:
  %%
  
negative.code: %% 3xxx can only be set in an answer setting the E-bit. RFC 6733 also
  %% allows 5xxx, RFC 3588 doesn't.
  
  select_error(E, Es, Dict0) ->
      select(E, Es, Dict0, []).
  
  %% select/4
  
  select(E, [{RC, _} = T | Es], Dict0, Avps) ->
      select(E, RC, T, Es, Dict0, Avps);
  
  select(E, [#diameter_avp{} = A | Es], Dict0, Avps) ->
      select(E, Es, Dict0, [A | Avps]);
  
  select(E, [RC | Es], Dict0, Avps) ->
      select(E, RC, RC, Es, Dict0, Avps);
  
  select(_, [], _, Avps) ->
      Avps.
  
  %% select/6
  
  select(E, RC, T, _, Dict0, Avps)
    when E, 3000 =< RC, RC < 4000;                 %% E-bit with 3xxx
         E, ?BASE /= Dict0, 5000 =< RC, RC < 6000; %% E-bit with 5xxx
         not E, RC < 3000 orelse 4000 =< RC ->     %% no E-bit
      [T | Avps];
  
  select(E, _, _, Es, Dict0, Avps) ->
      select(E, Es, Dict0, Avps).
  
  %% eval_packet/2
  
  