anchor.diff:          Port::inet:port_number()
       } 
       |
  -    {instance, Instance::binary(), RegId::binary()}.
  -
  +    {ob, Instance::binary(), RegId::binary()}.
  +
  +-type reg_info() :: 
  +    {
  +        Index::index(), 
  +        Uri::nksip:uri(), 
  +        Expire::nksip_lib:timestamp(), 
  +        Q::float()
  +    }.
   
   
   %% ===================================================================
  
positive.code:     ok.
  
  
  %% @private
  -spec make_updates(integer(), integer(), integer(), nksip_lib:timestamp(), [#uri{}], 
                      [{index(), nksip:uri(), nksip_lib:timestamp(), float()}]) ->
      [{index(), nksip:uri(), nksip_lib:timestamp(), float()}].               
  
  make_updates(Min, Max, Default, Now,
                  [#uri{scheme=Scheme, user=User, ext_opts=Opts}=Contact|Rest], 
                  Acc) ->
      Exp1 = case nksip_lib:get_list(<<"expires">>, Opts) of
          [] ->
              Default;
          Exp1List ->
  
negative.code:                     end
              end
      end,
      ExpireBin = list_to_binary(integer_to_list(Expire)),
      Opts1 = nksip_lib:store_value(<<"expires">>, ExpireBin, Opts),
      {Proto, Domain, Port} = nksip_parse:transport(Contact),
      Instance = nksip_lib:get_value(<<"+sip.instance">>, Opts),
      RegId = case nksip_lib:get_value(<<"reg-id">>, Opts) of
          undefined -> undefined;
          _ when ObProc==unsupported -> undefined;
          _ when ObProc==false -> throw(no_outbound);
          _ when Instance==undefined -> undefined;
          RegId0 -> RegId0
      end,
      % TODO: If Instance and no reg_id -> creation of gruu
      Index = case RegId of
          undefined -> {Scheme, Proto, User, Domain, Port};
          _ -> {ob, Instance, RegId}
      end,
      RegContact = Base#reg_contact{
          index = Index,
          contact = Contact#uri{ext_opts=Opts1},
          expire = Expire, 
          q = Q
      },
      gen_regcontacts(Rest, Base, Times, ObProc, [RegContact|Acc]);
  
  gen_regcontacts([], _Base, _Times, _ObProc, Acc) ->
      Acc.
  
  
  %% @private
  -spec update_regcontacts([reg_info()], [reg_info()]) ->
      [reg_info()].
  
  update_regcontacts([RegContact|Rest], Acc) ->
      % A new registration will overwite an old Contact if it has the same index
      #reg_contact{index=Index, expire=Expire, cseq=CSeq, call_id=CallId} = RegContact,
      Acc1 = case lists:keytake(Index, #reg_contact.index, Acc) of
          false when Expire==0 ->
              Acc;
          false ->
              [RegContact|Acc];
          {value, #reg_contact{call_id=CallId, cseq=OldCSeq}, _} when OldCSeq >= CSeq -> 
              throw({invalid_request, "Rejected Old CSeq"});
          {value, _, Acc0} when Expire==0 ->
              Acc0;
          {value, _, Acc0} ->
              [RegContact|Acc0]
      end,
      update_regcontacts(Rest, Acc1);
          
  update_regcontacts([], Acc) ->
      lists:reverse(lists:keysort(#reg_contact.updated, Acc)).
  
  
  
  
  
  %% @private Generates a contact value including Path
  make_contact(#reg_contact{contact=Contact, path=[]}) ->
  