anchor.diff:  
   %% incr/4
   %%
  -%% Increment a stats counter for an incoming or outgoing message.
  +%% Increment a stats counter for result codes in incoming and outgoing
  +%% answers.
   
   %% Outgoing message as binary: don't count. (Sending binaries is only
   %% partially supported.)
   incr(_, #diameter_packet{msg = undefined}, _, _) ->
       ok;
   
  +%% Incoming with decode errors.
   incr(recv = D, #diameter_packet{header = H, errors = [_|_]}, _, TPid) ->
       incr(TPid, {diameter_codec:msg_id(H), D, error});
   
  +%% Incoming without errors or outgoing. Outgoing with encode errors
  +%% never gets here since encode fails.
   incr(Dir, Pkt, Dict, TPid) ->
       #diameter_packet{header = #diameter_header{is_error = E}
                               = Hdr,
  
positive.code: 
  answer(Pkt, SvcName, Dict, App, #request{transport = TPid} = Req) ->
      try
          incr(recv, Pkt, Dict, TPid)
      of
          _ -> answer(Pkt, SvcName, App, Req)
      catch
          exit: {invalid_error_bit, _} = E ->
              answer(Pkt#diameter_packet{errors = [E]}, SvcName, App, Req)
      end.
  
  answer(Pkt,
  
negative.code:     RC = int(get_avp_value(Dict, 'Result-Code', Rec)),
      PE = is_protocol_error(RC),
  
      %% Check that Result-Code matches E-bit.
      (not (E orelse PE))        %% non-3xxx answer without E-bit
          orelse (E andalso PE)  %% 3xxx answer with E-bit
          orelse x({invalid_error_bit, RC}, answer, [Dir, Pkt]),
  
      irc(TPid, Hdr, Dir, rc_counter(Dict, Rec, RC)).
  