Fix broken tests (padding)

parent ddc04d67
...@@ -55,14 +55,18 @@ try_decode_packet(<<Len:32/little, PktSeqNo:32/signed-little, Tail/binary>>, ...@@ -55,14 +55,18 @@ try_decode_packet(<<Len:32/little, PktSeqNo:32/signed-little, Tail/binary>>,
PacketCrc = erlang:crc32([<<Len:32/little, PktSeqNo:32/little>> | Body]), PacketCrc = erlang:crc32([<<Len:32/little, PktSeqNo:32/little>> | Body]),
(CRC == PacketCrc) (CRC == PacketCrc)
orelse error({wrong_checksum, CRC, PacketCrc}), orelse error({wrong_checksum, CRC, PacketCrc}),
%% TODO: can we drop padding in-advance? %% TODO: predict padding size from padding_size(Len)
{ok, Body, Rest, S#full_st{dec_seq_no = SeqNo + 1}}; {ok, Body, trim_padding(Rest), S#full_st{dec_seq_no = SeqNo + 1}};
_ -> _ ->
{incomplete, S} {incomplete, S}
end; end;
try_decode_packet(_, S) -> try_decode_packet(_, S) ->
{incomplete, S}. {incomplete, S}.
trim_padding(<<4:32/little, Tail/binary>>) ->
trim_padding(Tail);
trim_padding(Bin) -> Bin.
encode_packet(Bin, #full_st{enc_seq_no = SeqNo} = S) -> encode_packet(Bin, #full_st{enc_seq_no = SeqNo} = S) ->
BodySize = iolist_size(Bin), BodySize = iolist_size(Bin),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment