File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -207,16 +207,18 @@ module Tcp = struct
207
207
(* XXX(seliopou): pseudo_header's allocated on every call. Would it be safe
208
208
* to allocate once and reuse? *)
209
209
let pseudo_header = Cstruct. create 12 in
210
+ let length = len pkt in
210
211
Cstruct.BE. set_uint32 pseudo_header 0 src;
211
212
Cstruct.BE. set_uint32 pseudo_header 4 dst;
212
213
Cstruct. set_uint8 pseudo_header 8 0 ;
213
214
Cstruct. set_uint8 pseudo_header 9 0x6 ;
214
- Cstruct.BE. set_uint16 pseudo_header 10 (len pkt) ;
215
+ Cstruct.BE. set_uint16 pseudo_header 10 length ;
215
216
set_tcp_chksum bits 0 ;
216
217
let chksum = Checksum. ones_complement_list
217
- [pseudo_header; Cstruct. sub bits 0 (len pkt)] in
218
+ (if (length mod 2 ) = 0
219
+ then [pseudo_header; Cstruct. sub bits 0 length]
220
+ else [pseudo_header; Cstruct. sub bits 0 length; Cstruct. create 0 ]) in
218
221
set_tcp_chksum bits chksum
219
-
220
222
end
221
223
222
224
module Udp = struct
You can’t perform that action at this time.
0 commit comments