anchor.diff:                               {'Origin-Realm', OR}],
       {reply, Ans};
   
  -request(#diameter_base_ASR{'Session-Id' = SId,
  -                           'AVP' = Avps},
  +request(#{':name' := 'ASR',
  +          'Session-Id' := SId}
  +        = Req,
           #diameter_caps{origin_host = {OH, _},
                          origin_realm = {OR, _}}) ->
       {reply, ['ASA', {'Result-Code', ?SUCCESS},
                       {'Session-Id', SId},
                       {'Origin-Host', OH},
                       {'Origin-Realm', OR},
  -                    {'AVP', Avps}]};
  +                    {'AVP', maps:get('AVP', Req, [])}]};
   
   %% send_invalid_reject
  -request(#diameter_base_STR{'Termination-Cause' = ?USER_MOVED},
  +request(#{':name' := 'STR',
  +          'Termination-Cause' := ?USER_MOVED},
           _Caps) ->
       {protocol_error, ?TOO_BUSY};
   
   %% send_noreply
  -request(#diameter_base_STR{'Termination-Cause' = T},
  +request(#{':name' := 'STR',
  +          'Termination-Cause' := T},
           _Caps)
     when T /= ?LOGOUT ->
       discard;
   
   %% send_destination_5
  -request(#diameter_base_STR{'Destination-Realm' = R},
  +request(#{':name' := 'STR',
  +          'Destination-Realm' := R},
           #diameter_caps{origin_realm = {OR, _}})
     when R /= undefined, R /= OR ->
       {protocol_error, ?REALM_NOT_SERVED};
   
   %% send_destination_6
  -request(#diameter_base_STR{'Destination-Host' = [H]},
  +request(#{':name' := 'STR',
  +          'Destination-Host' := [H]},
           #diameter_caps{origin_host = {OH, _}})
     when H /= OH ->
       {protocol_error, ?UNABLE_TO_DELIVER};
   
  -request(#diameter_base_STR{'Session-Id' = SId},
  +request(#{':name' := 'STR',
  +          'Session-Id' := SId},
           #diameter_caps{origin_host  = {OH, _},
                          origin_realm = {OR, _}}) ->
       {reply, ['STA', {'Result-Code', ?SUCCESS},
  
positive.code: %% Sequence mask for End-to-End and Hop-by-Hop identifiers.
  -define(CLIENT_MASK, {1,26}).  %% 1 in top 6 bits
  
  %% How to construct messages, as record, list, or map.
  -define(ENCODINGS, [list, record, map]).
  
  %% How to send answers, in a diameter_packet or not.
  -define(CONTAINERS, [pkt, msg]).
  
negative.code:                   msg(Req, ReqEncoding, Dict0),
                    [{extra, [{Name, Group}, diameter_lib:now()]} | Opts]).
  
  origin({D,E,C}) ->
      8*decode(D) + 2*encode(E) + container(C);
  
  origin(N) ->
      {decode(N bsr 3), encode((N bsr 1) rem 4), container(N rem 2)}.
  
  %% Map atoms. The atoms are part of (constructed) group names, so it's
  %% good that they're readable.
  
  decode(true)   -> 0;  %% record
  decode(list)   -> 1;
  decode(map)    -> 2;
  decode(false)  -> 3;
  decode(0) -> true;
  decode(1) -> list;
  decode(2) -> map;
  decode(3) -> false.
  
  encode(record) -> 0;
  encode(list)   -> 1;
  encode(map)    -> 2;
  encode(0) -> record;
  encode(1) -> list;
  encode(2) -> map.
  
  container(pkt) -> 0;
  container(msg) -> 1;
  