anchor.diff:      Req#diameter_base_STR{'Session-Id' = diameter:session_id(OH),
                             'Origin-Host' = OH,
                             'Origin-Realm' = OR,
  -                          'Destination-Realm' = DR};
  -
  -prepare(Pkt, Caps, send_invalid_avp_bits) ->
  -    #diameter_packet{msg = Req0}
  -        = Pkt,
  -    #diameter_caps{origin_host  = {OH, _},
  -                   origin_realm = {OR, DR}}
  -        = Caps,
  -    %% Append an Origin-State-Id with an incorrect AVP Length in order
  -    %% to force 3009.
  -    Req = Req0#diameter_base_STR{'Session-Id' = diameter:session_id(OH),
  -                                 'Origin-Host' = OH,
  -                                 'Origin-Realm' = OR,
  -                                 'Destination-Realm' = DR,
  -                                 'Origin-State-Id' = [7]},
  -    #diameter_packet{bin = Bin}
  -        = diameter_codec:encode(?DICT, Pkt#diameter_packet{msg = Req}),
  -    Offset = size(Bin) - 12 + 5,
  -    <<H:Offset/binary, Len:24, T/binary>> = Bin,
  -    Pkt#diameter_packet{bin = <<H/binary, (Len + 2):24, T/binary>>};
  -
  -prepare(Pkt0, Caps, send_double_error) ->
  -    #diameter_packet{bin = Bin}
  -        = Pkt
  -        = prepare(Pkt0, Caps, send_invalid_avp_bits),
  -    %% Keep Session-Id but remove Origin-Host.
  +                          'Destination-Realm' = DR}.
  +
  +%% Strip Origin-Host.
  +dehost(#diameter_packet{bin = Bin} = Pkt) ->
       <<V, Len:24, H:16/binary, T0/binary>>
           = Bin,
       {SessionId, T1} = split_avp(T0),
  
positive.code:                   ?DICT,
                    #diameter_base_STR
                    {'Termination-Cause' = ?LOGOUT,
                     'Auth-Application-Id' = ?DIAMETER_APP_ID_COMMON,
                     'Class' = [?L(Name)]},
                    [{extra, [Name]}]).
  
  
negative.code: prepare_request(Pkt, ?CLIENT, {_Ref, Caps}, Name) ->
      {send, prepare(Pkt, Caps, Name)}.
  
  prepare(Pkt0, Caps, send_unknown_application) ->
      Req = sta(Pkt0, Caps),
      #diameter_packet{bin = <<H:8/binary, 0:32, T/binary>>}
          = Pkt
          = diameter_codec:encode(?DICT, Pkt0#diameter_packet{msg = Req}),
  
      Pkt#diameter_packet{bin = <<H/binary, 23:32, T/binary>>};
  
  prepare(Pkt0, Caps, send_unknown_command) ->
      Req = sta(Pkt0, Caps),
      #diameter_packet{bin = <<H:5/binary, 275:24, T/binary>>}
          = Pkt
          = diameter_codec:encode(?DICT, Pkt0#diameter_packet{msg = Req}),
  
      Pkt#diameter_packet{bin = <<H/binary, 572:24, T/binary>>};
  
  prepare(Pkt, Caps, T)
    when T == send_ok;
         T == send_3xxx;
         T == send_5xxx ->
      sta(Pkt, Caps);
  
  prepare(Pkt0, Caps, send_invalid_avp_bits) ->
      Req0 = sta(Pkt0, Caps),
      %% Append an Origin-State-Id with an incorrect AVP Length in order
      %% to force 3009.
      Req = Req0#diameter_base_STR{'Origin-State-Id' = [7]},
      #diameter_packet{bin = Bin}
          = Pkt
          = diameter_codec:encode(?DICT, Pkt0#diameter_packet{msg = Req}),
      Offset = size(Bin) - 12 + 5,
      <<H:Offset/binary, Len:24, T/binary>> = Bin,
      Pkt#diameter_packet{bin = <<H/binary, (Len + 2):24, T/binary>>};
  
  prepare(Pkt0, Caps, send_double_error) ->
      dehost(prepare(Pkt0, Caps, send_invalid_avp_bits));
  
  prepare(Pkt, Caps, T)
    when T == send_missing_avp;
         T == send_ignore_missing_avp ->
      Req = sta(Pkt, Caps),
      dehost(diameter_codec:encode(?DICT, Pkt#diameter_packet{msg = Req})).
  
  sta(Pkt, Caps) ->
      #diameter_packet{msg = Req}
          = Pkt,
      #diameter_caps{origin_host  = {OH, _},
  