Skip to content

Commit

Permalink
Merge pull request #235 from hannesm/fix-dnssec-ok-flag
Browse files Browse the repository at this point in the history
dns: fix #234: edns flags are 16 bit (not 32), dnssec_ok is the topmost
  • Loading branch information
hannesm authored Jul 29, 2020
2 parents 50fe8ee + bbafad7 commit df73a1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/dns.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ module Edns = struct
and len = Cstruct.BE.get_uint16 buf (off + 9)
in
let off = off + 11 in
let dnssec_ok = flags land 0x8000_0000 = 0x8000_0000 in
let dnssec_ok = flags land 0x8000 = 0x8000 in
guard (version = 0) (`Bad_edns_version version) >>= fun () ->
let payload_size =
if payload_size < min_payload_size then begin
Expand Down Expand Up @@ -1570,7 +1570,7 @@ module Edns = struct
(* it continues: the ttl is split into: 8bit extended rcode, 8bit version, 1bit dnssec_ok, 7bit 0 *)
Cstruct.set_uint8 buf (off + 5) t.extended_rcode ;
Cstruct.set_uint8 buf (off + 6) t.version ;
Cstruct.BE.set_uint16 buf (off + 7) (if t.dnssec_ok then 0x8000_0000 else 0) ;
Cstruct.BE.set_uint16 buf (off + 7) (if t.dnssec_ok then 0x8000 else 0) ;
let ext_start = off + 11 in
let ext_end = encode_extensions t.extensions buf ext_start in
Cstruct.BE.set_uint16 buf (off + 9) (ext_end - ext_start) ;
Expand Down
8 changes: 4 additions & 4 deletions test/tsig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let of_h = Cstruct.of_hex
let tsig ?(fudge = 300) algorithm signed =
let fudge = Ptime.Span.of_int_s fudge in
let signed =
match Ptime.of_float_s (float_of_int signed) with
match Ptime.of_float_s signed with
| None -> assert false
| Some x -> x
in
Expand All @@ -42,7 +42,7 @@ let example0 () =
6f c0 0c 00 ff 00 ff 00 00 00 00 00 00 03 62 61
72 c0 0c 00 01 00 01 00 00 01 2c 00 04 01 02 03
04|__}
and now = 1506887417
and now = 1506887417.
and mac = of_h {__|bf 5d 77 ba 97 ba 7b 95 9e 1b 0d 95 64 a7 5b a6
95 bf 24 15 3b 9d a2 1b bf 6f ae 61 9d 0f 28 a1|__}
in
Expand All @@ -54,7 +54,7 @@ let example1 () =
6d 50 6c 45 03 63 6f 6d 00 00 06 00 01 03 66 6f
6f 07 65 78 61 6d 70 6c 65 c0 14 00 ff 00 ff 00
00 00 00 00 00|__}
and now = 1506887742
and now = 1506887742.
and mac = of_h {__|70 67 ae 70 9e fd 22 9e ce d9 65 25 8a db 8c 96
10 95 80 89 a7 ee 4f bb 13 81 e7 38 e3 a0 78 80|__}
in
Expand All @@ -65,7 +65,7 @@ let example2 () =
let buf = of_h {__|76 8a 28 00 00 01 00 00 00 01 00 00 07 65 78 61
6d 70 6c 65 00 00 06 00 01 03 66 6f 6f c0 0c 00
ff 00 ff 00 00 00 00 00 00|__}
and now = 1506888104
and now = 1506888104.
and mac = of_h {__|e7 76 e6 df 4e 73 14 c8 eb ba 4c c7 a5 39 b3 93
a7 df 6d de 47 b6 fa cc 81 c8 47 29 20 77 40 44|__}
in
Expand Down

0 comments on commit df73a1f

Please sign in to comment.