aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/tftp
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2016-03-07 11:14:35 +0100
committerRaimo Niskanen <[email protected]>2016-03-07 11:14:35 +0100
commitcbc122135a638da7b8bd74c6725b12da786c93f3 (patch)
tree5f53377bbee7187e1b145d75b1ce3b7e3fd6aa81 /lib/inets/src/tftp
parent870ff4c7935032df00ef49746d70583d504fcd7c (diff)
parentc5ef73b4a587bf8f2e7b7b3d74fe917fdbe6153f (diff)
downloadotp-cbc122135a638da7b8bd74c6725b12da786c93f3.tar.gz
otp-cbc122135a638da7b8bd74c6725b12da786c93f3.tar.bz2
otp-cbc122135a638da7b8bd74c6725b12da786c93f3.zip
Merge branch 'maint'
Diffstat (limited to 'lib/inets/src/tftp')
-rw-r--r--lib/inets/src/tftp/tftp_engine.erl36
1 files changed, 7 insertions, 29 deletions
diff --git a/lib/inets/src/tftp/tftp_engine.erl b/lib/inets/src/tftp/tftp_engine.erl
index 79203fd1a4..22dd2f3336 100644
--- a/lib/inets/src/tftp/tftp_engine.erl
+++ b/lib/inets/src/tftp/tftp_engine.erl
@@ -657,22 +657,11 @@ common_read(Config, Callback, Req, _LocalAccess, ExpectedBlockNo, ActualBlockNo,
do_common_read(Config, Callback, Req, LocalAccess, BlockNo, Data, Prepared)
when is_binary(Data), is_record(Prepared, prepared) ->
- NextBlockNo = BlockNo + 1,
- case NextBlockNo =< 65535 of
- true ->
- Reply = #tftp_msg_data{block_no = NextBlockNo, data = Data},
- {Config2, Callback2, TransferRes} =
- transfer(Config, Callback, Req, Reply, LocalAccess, NextBlockNo, Prepared),
- ?MODULE:common_loop(Config2, Callback2, Req, TransferRes, LocalAccess, NextBlockNo);
- false ->
- Code = badblk,
- Text = "Too big transfer ID = " ++
- integer_to_list(NextBlockNo) ++ " > 65535",
- {undefined, Error} =
- callback({abort, {Code, Text}}, Config, Callback, Req),
- send_msg(Config, Req, Error),
- terminate(Config, Req, ?ERROR(read, Code, Text, Req#tftp_msg_req.filename))
- end.
+ NextBlockNo = (BlockNo + 1) rem 65536,
+ Reply = #tftp_msg_data{block_no = NextBlockNo, data = Data},
+ {Config2, Callback2, TransferRes} =
+ transfer(Config, Callback, Req, Reply, LocalAccess, NextBlockNo, Prepared),
+ ?MODULE:common_loop(Config2, Callback2, Req, TransferRes, LocalAccess, NextBlockNo).
-spec common_write(#config{}, #callback{}, _, 'write', integer(), integer(), _, #prepared{}) -> no_return().
@@ -716,21 +705,10 @@ common_write(Config, Callback, Req, _, ExpectedBlockNo, ActualBlockNo, Data, Pre
common_ack(Config, Callback, Req, LocalAccess, BlockNo, Prepared)
when is_record(Prepared, prepared) ->
Reply = #tftp_msg_ack{block_no = BlockNo},
- NextBlockNo = BlockNo + 1,
+ NextBlockNo = (BlockNo + 1) rem 65536,
{Config2, Callback2, TransferRes} =
transfer(Config, Callback, Req, Reply, LocalAccess, NextBlockNo, Prepared),
- case NextBlockNo =< 65535 of
- true ->
- ?MODULE:common_loop(Config2, Callback2, Req, TransferRes, LocalAccess, NextBlockNo);
- false ->
- Code = badblk,
- Text = "Too big transfer ID = " ++
- integer_to_list(NextBlockNo) ++ " > 65535",
- {undefined, Error} =
- callback({abort, {Code, Text}}, Config, Callback2, Req),
- send_msg(Config, Req, Error),
- terminate(Config, Req, ?ERROR(read, Code, Text, Req#tftp_msg_req.filename))
- end.
+ ?MODULE:common_loop(Config2, Callback2, Req, TransferRes, LocalAccess, NextBlockNo).
pre_terminate(Config, Req, Result) ->
if