K2InformaticsGmbH / smpp_parser

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

erlang:list_to_binary failed Reason: badarg: broadcast_sm #88

Closed walter-weinmann closed 6 years ago

walter-weinmann commented 6 years ago
Command: broadcast_sm
PDU: "00 00 00 99 00 00 01 11 00 00 00 00 00 00 00 01 00 01 08 31 36 38 2E 30 2E 30 2E 31 00 74 68 69 73 5F 63 6F 75 6C 64 5F 62 65 5F 61 5F 6D 65 73 73 61 67 65 5F 69 64 00 04 39 39 30 38 32 33 31 36 35 33 34 33 30 30 30 52 00 39 39 30 39 32 32 31 35 35 32 34 32 30 30 30 52 00 01 FF 03 06 06 00 23 01 6D 79 5F 62 72 6F 61 64 63 61 73 74 5F 61 72 65 61 5F 69 64 65 6E 74 69 66 69 65 72 5F 30 30 30 31 30 06 01 00 03 00 01 00 06 04 00 02 00 00 06 05 00 03 0D 00 03"

00 00 00 99 # command_length
00 00 01 11 # command_id
00 00 00 00 # command_status
00 00 00 01 # sequence_number
00 # service_type
01 # source_addr_ton
08 # source_addr_npi
31 36 38 2E 30 2E 30 2E 31 00 # source_addr
74 68 69 73 5F 63 6F 75 6C 64 5F 62 65 5F 61 5F 6D 65 73 73 61 67 65 5F 69 64 00  message_id
04 # priority_flag
39 39 30 38 32 33 31 36 35 33 34 33 30 30 30 52 00 # schedule_delivery_time
39 39 30 39 32 32 31 35 35 32 34 32 30 30 30 52 00 # validity_period
01 # replace_if_present_flag
FF # data_coding
03 # sm_default_mesg_id
TLV broadcast_area_identifier
06 06 
00 23 
01 6D 79 5F 62 72 6F 61 64 63 61 73 74 5F 61 72 65 61 5F 69 64 65 6E 74 69 66 69 65 72 5F 30 30 30 31 30 
TLV broadcat_content_type 
06 01 
00 03 
00 01 00 
TLV broadcat_rep_num
06 04 
00 02 
00 00 
TLV broadcast_frequency_interval
06 05 
00 03 
0D 00 03
c-bik commented 6 years ago

@walter-weinmann unable to reproduce

walter-weinmann commented 6 years ago

Error with unpack_map_pack

*** User 2018-06-04 04:47:37.286 ***
smpp_test_utils:unpack_map_pack:54 ===> unbind
#{broadcast_area_identifier =>
      [#{details => "my_broadcast_area_identifier_00010",format => 1}],
  broadcast_content_type => #{network_type => 0,service => 256},
  broadcast_frequency_interval => #{number => 3,time_unit => 13},
  broadcast_rep_num => 0,command_id => 273,command_length => 153,
  command_status => 0,data_coding => 255,
  message_id => "this_could_be_a_message_id",priority_flag => 4,
  replace_if_present_flag => 1,schedule_delivery_time => "990823165343000R",
  sequence_number => 1,service_type => [],sm_default_msg_id => 3,
  source_addr => "168.0.0.1",source_addr_npi => 8,source_addr_ton => 1,
  validity_period => "990922155242000R"}
{
  "broadcast_area_identifier": [
    {
      "details": "my_broadcast_area_identifier_00010",
      "format": 1
    }
  ],
  "broadcast_content_type": {
    "network_type": 0,
    "service": 256
  },
  "broadcast_frequency_interval": {
    "number": 3,
    "time_unit": 13
  },
  "broadcast_rep_num": 0,
  "command_id": 273,
  "command_length": 153,
  "command_status": 0,
  "data_coding": 255,
  "message_id": "this_could_be_a_message_id",
  "priority_flag": 4,
  "replace_if_present_flag": 1,
  "schedule_delivery_time": "990823165343000R",
  "sequence_number": 1,
  "service_type": "",
  "sm_default_msg_id": 3,
  "source_addr": "168.0.0.1",
  "source_addr_npi": 8,
  "source_addr_ton": 1,
  "validity_period": "990922155242000R"
}

*** User 2018-06-04 04:47:37.287 ***
smpp_test_utils:unpack_map_pack:57 ===> 
Expected : <<0,0,0,153,0,0,1,17,0,0,0,0,0,0,0,1,0,1,8,49,54,56,46,48,46,48,46,
             49,0,116,104,105,115,95,99,111,117,108,100,95,98,101,95,97,95,109,
             101,115,115,97,103,101,95,105,100,0,4,57,57,48,56,50,51,49,54,53,
             51,52,51,48,48,48,82,0,57,57,48,57,50,50,49,53,53,50,52,50,48,48,
             48,82,0,1,255,3,6,6,0,35,1,109,121,95,98,114,111,97,100,99,97,115,
             116,95,97,114,101,97,95,105,100,101,110,116,105,102,105,101,114,
             95,48,48,48,49,48,6,1,0,3,0,1,0,6,4,0,2,0,0,6,5,0,3,13,0,3>>
Got      : <<0,0,0,153,0,0,1,17,0,0,0,0,0,0,0,1,0,1,8,49,54,56,46,48,46,48,46,
             49,0,116,104,105,115,95,99,111,117,108,100,95,98,101,95,97,95,109,
             101,115,115,97,103,101,95,105,100,0,4,57,57,48,56,50,51,49,54,53,
             51,52,51,48,48,48,82,0,57,57,48,57,50,50,49,53,53,50,52,50,48,48,
             48,82,0,1,255,3,6,4,0,2,0,0,6,5,0,3,13,0,3,6,1,0,3,0,1,0,6,6,0,35,
             1,109,121,95,98,114,111,97,100,99,97,115,116,95,97,114,101,97,95,
             105,100,101,110,116,105,102,105,101,114,95,48,48,48,49,48>>

*** CT Error Notification 2018-06-04 04:47:37.287 ***
smpp_test_utils:'-unpack_map_pack/1-fun-1-' failed on line 60
Reason: assertEqual
walter-weinmann commented 6 years ago

Error with unpack_pack

*** CT Error Notification 2018-06-04 04:47:37.703 ***
erlang:list_to_binary failed
Reason: badarg
c-bik commented 6 years ago

@walter-weinmann assuming this issue is still valid (from your point-of-view), here is my analysis:

The binary comparison problem

image

1> PDU1 = <<0,0,0,153,0,0,1,17,0,0,0,0,0,0,0,1,0,1,8,49,54,56,46,48,46,48,46,
1> 
1>              49,0,116,104,105,115,95,99,111,117,108,100,95,98,101,95,97,95,109,
1> 
1>              101,115,115,97,103,101,95,105,100,0,4,57,57,48,56,50,51,49,54,53,
1> 
1>              51,52,51,48,48,48,82,0,57,57,48,57,50,50,49,53,53,50,52,50,48,48,
1> 
1>              48,82,0,1,255,3,6,6,0,35,1,109,121,95,98,114,111,97,100,99,97,115,
1> 
1>              116,95,97,114,101,97,95,105,100,101,110,116,105,102,105,101,114,
1> 
1>              95,48,48,48,49,48,6,1,0,3,0,1,0,6,4,0,2,0,0,6,5,0,3,13,0,3>>.
<<0,0,0,153,0,0,1,17,0,0,0,0,0,0,0,1,0,1,8,49,54,56,46,48,
  46,48,46,49,0,...>>
2> PDU2 = <<0,0,0,153,0,0,1,17,0,0,0,0,0,0,0,1,0,1,8,49,54,56,46,48,46,48,46,
2> 
2>              49,0,116,104,105,115,95,99,111,117,108,100,95,98,101,95,97,95,109,
2> 
2>              101,115,115,97,103,101,95,105,100,0,4,57,57,48,56,50,51,49,54,53,
2> 
2>              51,52,51,48,48,48,82,0,57,57,48,57,50,50,49,53,53,50,52,50,48,48,
2> 
2>              48,82,0,1,255,3,6,4,0,2,0,0,6,5,0,3,13,0,3,6,1,0,3,0,1,0,6,6,0,35,
2> 
2>              1,109,121,95,98,114,111,97,100,99,97,115,116,95,97,114,101,97,95,
2> 
2>              105,100,101,110,116,105,102,105,101,114,95,48,48,48,49,48>>
2> 
2> .
<<0,0,0,153,0,0,1,17,0,0,0,0,0,0,0,1,0,1,8,49,54,56,46,48,
  46,48,46,49,0,...>>

3> PDU1 == PDU2.
false

5> MAP1 = smpp:unpack_map(PDU1).
#{broadcast_area_identifier =>
      [#{details => "my_broadcast_area_identifier_00010",
         format => 1}],
  broadcast_content_type =>
      #{network_type => 0,service => 256},
  broadcast_frequency_interval =>
      #{number => 3,time_unit => 13},
  broadcast_rep_num => 0,command_id => 273,
  command_length => 153,command_status => 0,
  data_coding => 255,
  message_id => "this_could_be_a_message_id",
  priority_flag => 4,replace_if_present_flag => 1,
  schedule_delivery_time => "990823165343000R",
  sequence_number => 1,service_type => [],
  sm_default_msg_id => 3,source_addr => "168.0.0.1",
  source_addr_npi => 8,source_addr_ton => 1,
  validity_period => "990922155242000R"}

6> MAP2 = smpp:unpack_map(PDU2).
#{broadcast_area_identifier =>
      [#{details => "my_broadcast_area_identifier_00010",
         format => 1}],
  broadcast_content_type =>
      #{network_type => 0,service => 256},
  broadcast_frequency_interval =>
      #{number => 3,time_unit => 13},
  broadcast_rep_num => 0,command_id => 273,
  command_length => 153,command_status => 0,
  data_coding => 255,
  message_id => "this_could_be_a_message_id",
  priority_flag => 4,replace_if_present_flag => 1,
  schedule_delivery_time => "990823165343000R",
  sequence_number => 1,service_type => [],
  sm_default_msg_id => 3,source_addr => "168.0.0.1",
  source_addr_npi => 8,source_addr_ton => 1,
  validity_period => "990922155242000R"}

7> MAP1 == MAP2.
true

As you can see (also what I was trying to explain in flowdock and mails) though the binaries are different the parsed PDUs are the same. This means you should remove this "Expected ... Got..." comparison (and ?dbgFmt) from your test cases as well.

The erlang:list_to_binary problem

image Can you give a stacktrace as wo where in smpp.erl is this happening?

_I am maintaining not reproducable untill I understand that the problem is still in smpp_parser and NOT in test code!_

walter-weinmann commented 6 years ago

Fixed with latest version.