anchor.diff:  
   
   %% @private
  -do_stun_timeout(#stun{dest={Ip, Port}, from=From}, #state{conns=Conns}=State) ->
  +do_stun_timeout(Stun, #state{app_id=AppId, conns=Conns}=State) ->
  +    #stun{dest={Ip, Port}, from=From} = Stun,
  +    ?notice(AppId, "STUN request to ~p timeout", [{Ip, Port}]),
       case From of
           undefined -> ok;
           _ -> gen_server:reply(From, error)
  
positive.code: 
  %% @private
  do_stun_response(TransId, Attrs, State) ->
      #state{app_id=AppId, stuns=Stuns, conns=Conns} = State,
      case lists:keytake(TransId, #stun.id, Stuns) of
          {value, #stun{dest={Ip, Port}, retrans_timer=Retrans, from=From}, Stuns1} ->
              cancel_timer(Retrans),
              case From of
                  undefied -> ok;
                  _ -> gen_server:reply(From, {ok, Attrs})
              end,
              State1 = State#state{stuns=Stuns1},
              case lists:keytake({Ip, Port}, #conn.dest, Conns) of
                  {value, Conn, Conns1} -> 
                      case nksip_lib:get_value(xor_mapped_address, Attrs) of
                          {StunIp, StunPort} -> 
                              ok;
                          _ ->
                              case nksip_lib:get_value(mapped_address, Attrs) of
                                  {StunIp, StunPort} -> ok;
                                  _ -> StunIp = StunPort = undefined
                              end
                      end,
                      State2 = State1#state{conns=Conns1},
                      do_connect_response(Conn, {StunIp, StunPort}, State2);
                  false ->
                      State1
              end;
          false ->
              ?notice(AppId, "received unexpected STUN response", []),
              State
  
negative.code: 
  
  %% @private
  do_connect_response(Dest, StunDest, #state{conns=Conns}=State) ->
      case lists:keyfind(Dest, #conn.dest, Conns) of
          #conn{timeout_timer=undefined, remote_dest=RemDest, time=Time}=Conn ->
              case RemDest==undefined orelse RemDest==StunDest of
                  true ->
                      Conn1 = Conn#conn{
                          remote_dest = StunDest,
                          refresh_timer = start_timer(Time, conn_refresh)
                      },
                      Conns1 = lists:keystore(Dest, #conn.dest, Conns, Conn1),
                      State#state{conns=Conns1};
                  _ ->
                      do_connect_timeout(Conn, State)
              end;
          _ ->
              State
      end.
  
  
  