anchor.diff:    {stop, Reason :: term(), Reply :: term(), NewState :: #state{}} |
     {stop, Reason :: term(), NewState :: #state{}}).
   handle_call({handle_mapping, Mapping}, _From, State = #state{socket = Socket}) ->
  -  do_mapping(Mapping, Socket),
  +  try_mapping(Mapping, Socket),
     {reply, ok, State};
   handle_call(_Request, _From, State) ->
     {reply, ok, State}.
  
positive.code:       gen_socket:socketat(NetNs, Family, Type, Protocol)
    end.
  
  do_mapping(Mapping, Socket) ->
    Seq = erlang:time_offset() + erlang:monotonic_time(),
    Cmd = {inet, 0, 0, [
      {tuple_orig,
        [{ip, [{v4_src, Mapping#mapping.orig_src_ip}, {v4_dst, Mapping#mapping.orig_dst_ip}]},
          {proto, [{num, tcp}, {src_port, Mapping#mapping.orig_src_port}, {dst_port, Mapping#mapping.orig_dst_port}]}]},
      {tuple_reply,
        [{ip, [{v4_src, Mapping#mapping.orig_dst_ip}, {v4_dst, Mapping#mapping.orig_src_ip}]},
          {proto, [{num, tcp}, {src_port, Mapping#mapping.orig_dst_port}, {dst_port, Mapping#mapping.orig_src_port}]}]},
      {timeout, 2},
      {protoinfo, [{tcp, [{state, syn_sent}]}]},
      {nat_src,
  
negative.code:         {dst_port, [{min_port, Mapping#mapping.new_dst_port}, {max_port, Mapping#mapping.new_dst_port}]}]}
    ]},
    Msg = [#ctnetlink{type = new, flags = [create, request, ack], seq = Seq, pid = 0, msg = Cmd}],
    Msg.
  
  tuple_orig(Mapping) ->
    {tuple_orig,
      [{ip, [{v4_src, Mapping#mapping.orig_src_ip}, {v4_dst, Mapping#mapping.orig_dst_ip}]},
        {proto, [{num, tcp}, {src_port, Mapping#mapping.orig_src_port}, {dst_port, Mapping#mapping.orig_dst_port}]}]}.
  tuple_reply(Mapping) ->
    {tuple_reply,
      [{ip, [{v4_src, Mapping#mapping.orig_dst_ip}, {v4_dst, Mapping#mapping.orig_src_ip}]},
        {proto, [{num, tcp}, {src_port, Mapping#mapping.orig_dst_port}, {dst_port, Mapping#mapping.orig_src_port}]}]}.