anchor.diff:      end.
   
   handle_message({CmdId,Status,SeqNum,Body}) ->
  -    if CmdId band 16#80000000 == 0 ->
  -           {reply, {CmdId bor 16#80000000, Status, SeqNum, Body}};
  -       true -> ignore
  +    case CmdId of
  +        CmdId when CmdId band 16#80000000 == 0 ->
  +            {reply, {CmdId bor 16#80000000, Status, SeqNum, Body}};
  +        ?COMMAND_ID_DELIVER_SM_RESP ->
  +            case catch ets:next(get(name),SeqNum) of
  +                {'EXIT', _} ->
  +                    true = ets:delete(get(name), SeqNum),
  +                    ignore;
  +                '$end_of_table' ->
  +                    true = ets:delete(get(name), SeqNum),
  +                    ignore;
  +                NextSeqNum ->
  +                    [{NextSeqNum, Body1}] = ets:lookup(get(name), NextSeqNum),
  +                    true = ets:delete(get(name), SeqNum),
  +                    {reply, {?COMMAND_ID_DELIVER_SM, ?ESME_ROK, NextSeqNum, Body1}}
  +            end;
  +        _ -> ignore
       end;
   handle_message(Pdu) ->
       {reply, Pdu}.
  
positive.code:         _ -> {PDUs, Buffer}
      end.
  
  handle_data(AutoResponse, Socket, {C,_,_,B} = Pdu) ->
      case lists:member(C, [?COMMAND_ID_BIND_RECEIVER,
                            ?COMMAND_ID_BIND_TRANSCEIVER,
                            ?COMMAND_ID_BIND_TRANSMITTER]) of
          true ->
              RegName = list_to_atom(
                          lists:flatten([atom_to_list(?MODULE),"_",
                                         proplists:get_value(system_id,B)])),
              erlang:register(RegName, self()),
              ?SYS_INFO("SMSC : ~p", [RegName]);
          false -> ok
      end,
      ?SYS_INFO("Req : ~p", [smpp:cmd(Pdu)]),
      if AutoResponse == true ->
  
negative.code:     {stop, normal, State};
  handle_info({'EXIT', _, Reason}, State) ->
      {stop, Reason, State};
  handle_info(check_send_deliver_sm, State) ->
      case ets:first(get(name)) of
          '$end_of_table' ->
              self() ! check_send_deliver_sm;
          SeqNum ->
              [{SeqNum, Body}] = ets:lookup(get(name), SeqNum),
              Pdu = {?COMMAND_ID_DELIVER_SM, ?ESME_ROK, SeqNum, Body},
              ?SYS_INFO("DELIVER ~p", [Pdu]),
              {ok, BinList} = smpp_operation:pack(Pdu),
              RespBin = list_to_binary(BinList),
              {ok, Reply} = smpp_operation:unpack(RespBin),
              ?SYS_INFO("Sending SMPP request: ~p", [smpp:cmd(Reply)]),
              send_low(State#state.sock, RespBin)
      end,
      {noreply, State};
  handle_info(Any, State) ->
      ?SYS_INFO("Unhandled message: ~p", [Any]),
      {noreply, State}.
  