Skip to content

Commit

Permalink
Merge pull request #477 from dinosaure/missing-cstruct-len
Browse files Browse the repository at this point in the history
Remove missing deprecated usage of Cstruct.len
  • Loading branch information
dinosaure authored Mar 22, 2022
2 parents be68b09 + 9a7858c commit 727531a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/tcp/segment.ml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ module Rx(Time:Mirage_time.S) = struct
"RX seg seq=%a acknum=%a ack=%b rst=%b syn=%b fin=%b win=%d len=%d"
Sequence.pp header.sequence Sequence.pp header.ack_number
header.ack header.rst header.syn header.fin
header.window (Cstruct.len payload)
header.window (Cstruct.length payload)

let len seg =
Sequence.of_int ((Cstruct.len seg.payload) +
Sequence.of_int ((Cstruct.length seg.payload) +
(if seg.header.fin then 1 else 0) +
(if seg.header.syn then 1 else 0))

Expand Down Expand Up @@ -194,7 +194,7 @@ module Rx(Time:Mirage_time.S) = struct
let urx_inform =
(* TODO: deal with overlapping fragments *)
let elems_r, winadv = S.fold (fun seg (acc_l, acc_w) ->
(if Cstruct.len seg.payload > 0 then seg.payload :: acc_l else acc_l),
(if Cstruct.length seg.payload > 0 then seg.payload :: acc_l else acc_l),
(Sequence.add (len seg) acc_w)
) ready ([], Sequence.zero) in
let elems = List.rev elems_r in
Expand Down Expand Up @@ -261,7 +261,7 @@ module Tx (Time:Mirage_time.S) (Clock:Mirage_clock.MCLOCK) = struct
((match seg.flags with
| No_flags | Psh | Rst -> 0
| Syn | Fin -> 1) +
(Cstruct.len seg.data))
(Cstruct.length seg.data))

(* Queue of pre-transmission segments *)
type ('a, 'b) q = {
Expand Down
10 changes: 5 additions & 5 deletions src/tcp/user_buffer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module Rx = struct
let seglen s =
match s with
| None -> 0
| Some b -> Cstruct.len b
| Some b -> Cstruct.length b

let add_r t s =
if t.cur_size > t.max_size then
Expand Down Expand Up @@ -131,13 +131,13 @@ module Tx(Time:Mirage_time.S)(Clock:Mirage_clock.MCLOCK) = struct
{ wnd; writers; txq; buffer; max_size; bufbytes }

let len data =
Int32.of_int (Cstruct.len data)
Int32.of_int (Cstruct.length data)

let lenv datav =
match datav with
|[] -> 0l
|[d] -> Int32.of_int (Cstruct.len d)
|ds -> Int32.of_int (List.fold_left (fun a b -> Cstruct.len b + a) 0 ds)
|[d] -> Int32.of_int (Cstruct.length d)
|ds -> Int32.of_int (List.fold_left (fun a b -> Cstruct.length b + a) 0 ds)

(* Check how many bytes are available to write to output buffer *)
let available t =
Expand Down Expand Up @@ -243,7 +243,7 @@ module Tx(Time:Mirage_time.S)(Clock:Mirage_clock.MCLOCK) = struct
end
|hd::tl ->
let curlen = Cstruct.lenv acc in
let tlen = Cstruct.len hd + curlen in
let tlen = Cstruct.length hd + curlen in
if tlen > mss then begin
let a,b = Cstruct.split hd (mss - curlen) in
transmit (a::acc) >>= fun () ->
Expand Down

0 comments on commit 727531a

Please sign in to comment.