K2InformaticsGmbH / smpp_parser

A parser for SMPP protocol PDUs
Apache License 2.0
3 stars 1 forks source link

Optional TLV not supported #25

Closed walter-weinmann closed 6 years ago

walter-weinmann commented 6 years ago

Example bind_receiver_resp:

 {"bind_receiver_resp",  
  "00 00 00 1A 80 00 00 01 00 00 00 01 71 F2 14 67 53 4D 50 50 33 54 45 53 54 "  
  "00"}
f().
D = <<"00 00 00 1A 80 00 00 01 00 00 00 01 71 F2 14 67 53 4D 50 50 33 54 45 53 54 00">>.
{ok, DStr} = smpp:decode(D).
smpp:encode(DStr).
DStr == D.

Example bind_transeiver_resp:

 {"bind_transceiver_resp",
  "00 00 00 1A 80 00 00 09 00 00 00 01 88 DF 7C 11 53 4D 50 50 33 54 45 53 54 "
  "00"}
f().
D = <<"00 00 00 1A 80 00 00 09 00 00 00 01 88 DF 7C 11 53 4D 50 50 33 54 45 53 54 00">>.
{ok, DStr} = smpp:decode(D).
smpp:encode(DStr).
DStr == D.

Example bind_transmitter_resp:

 {"bind_transmitter_resp",
  "00 00 00 1A 80 00 00 02 00 00 00 01 0C 55 8D C1 53 4D 50 50 33 54 45 53 54 "
  "00"}
f().
D = <<"00 00 00 1A 80 00 00 02 00 00 00 01 0C 55 8D C1 53 4D 50 50 33 54 45 53 54 00">>.
{ok, DStr} = smpp:decode(D).
smpp:encode(DStr).
DStr == D.
c-bik commented 6 years ago

It seems like this parser doesn't parse the body if command_status is not ESME_ROK (as ovserbed in this partcular case)

f().
D = <<"00 00 00 1F 80 00 00 01 00 00 00 01 71 F2 14 67 53 4D 50 50 33 54 45 53 54 00 02 10 00"
      " 01 01">>.
{ok, DStr} = smpp:decode(D).
{ok,#{command_id => <<"bind_receiver_resp">>,command_length => 31,
      command_status => <<"ESME_RINVMSGLEN">>,
      sequence_number => 1911690343}}

% Expected
#{command_id => <<"bind_receiver_resp">>,command_length => 31,
      command_status => <<"ESME_RINVMSGLEN">>,sc_interface_version => 1,
      sequence_number => 1911690343,system_id => <<"SMPP3TEST">>}

Works if command status is ESME_ROK

f().
D = <<"00 00 00 1F 80 00 00 00 00 00 00 01 71 F2 14 67 53 4D 50 50 33 54 45 53 54 00 02 10 00"
      " 01 01">>.
{ok, DStr} = smpp:decode(D).
{ok, D1} = smpp:encode(DStr).
D1 == D.
true

@walter-weinmann I think the issue definition requires update and the issue requires re validation as per my comment above.

c-bik commented 6 years ago

@walter-weinmann I put a temporarily wontfix to help me filter. Please feel to remove it when you update the info and the issue is still valid after your re-validation.

walter-weinmann commented 6 years ago

The solution with the test data generator is to use command_status 0x00000000 with all response operations.

create_operation(Rule, _CommandStatus, PDUBody) ->
    PDU = lists:append(
        [
            integer_2_octet(length(PDUBody) div 2 + 16, 4),
            integer_2_octet(?COMMAND_ID(Rule), 4),
%% not used because of issue #25 (https://github.com/K2InformaticsGmbH/smpp_parser/issues/25)
%%            CommandStatus,
            "00000000",
            integer_2_octet(rand:uniform(4294967296), 4),
            PDUBody
        ]),

    ?assertEqual(0, length(PDU) rem 2, "PDU=" ++ PDU),
    create_byte_string(PDU, []).