Skip to content

Commit

Permalink
Fix IPv6 enc/decoding
Browse files Browse the repository at this point in the history
Fixes #4679
  • Loading branch information
bolt12 committed Sep 26, 2023
1 parent 9f5163a commit 66cbbb9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,12 @@ encodeRemoteAddress (SockAddrInet pn w) = CBOR.encodeListLen 3
<> CBOR.encodeWord 0
<> CBOR.encodeWord32 w
<> encodePortNumber pn
encodeRemoteAddress (SockAddrInet6 pn fi (w1, w2, w3, w4) si) = CBOR.encodeListLen 8
encodeRemoteAddress (SockAddrInet6 pn _ (w1, w2, w3, w4) _) = CBOR.encodeListLen 6
<> CBOR.encodeWord 1
<> CBOR.encodeWord32 w1
<> CBOR.encodeWord32 w2
<> CBOR.encodeWord32 w3
<> CBOR.encodeWord32 w4
<> CBOR.encodeWord32 fi
<> CBOR.encodeWord32 si
<> encodePortNumber pn
encodeRemoteAddress (SockAddrUnix _) = error "Should never be encoding a SockAddrUnix!"

Expand All @@ -97,8 +95,6 @@ decodeRemoteAddress = do
w2 <- CBOR.decodeWord32
w3 <- CBOR.decodeWord32
w4 <- CBOR.decodeWord32
fi <- CBOR.decodeWord32
si <- CBOR.decodeWord32
pn <- decodePortNumber
return (SockAddrInet6 pn fi (w1, w2, w3, w4) si)
return (SockAddrInet6 pn 0 (w1, w2, w3, w4) 0)
_ -> fail ("Serialise.decode.SockAddr unexpected tok " ++ show tok)
6 changes: 2 additions & 4 deletions ouroboros-network-protocols/test-cddl/specs/peer-sharing.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ peerAddresses = [* peerAddress]

byte = 0..255

peerAddress = [0, word32, portNumber] ; ipv4 + portNumber
/ [1, word32, word32, word32, word32, flowInfo, scopeId, portNumber] ; ipv6 + portNumber
peerAddress = [0, word32, portNumber] ; ipv4 + portNumber
/ [1, word32, word32, word32, word32, portNumber] ; ipv6 + portNumber

portNumber = word16
flowInfo = word32
scopeId = word32
6 changes: 4 additions & 2 deletions ouroboros-network/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
* Less aggresive churning of established and known peers.
* Add peer sharing to wireshark dissector.

- Fix diffusion tests
* Fix diffusion tests

- Update types to accommodate `PeerSharing` data type changes.
* Update types to accommodate `PeerSharing` data type changes.

* Fix PeerSharing IPv6 enc/decoding

## 0.9.1.0 -- 2023-08-22

Expand Down

0 comments on commit 66cbbb9

Please sign in to comment.