Skip to content

Commit

Permalink
Merge PR #522
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Jan 18, 2022
2 parents cb5362e + 5a427c5 commit e11132d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Network/Socket/Win32/Cmsg.hsc
Expand Up @@ -148,25 +148,26 @@ instance ControlMessage IPv6TClass where

----------------------------------------------------------------

-- | Network interface ID and local IPv4 address.
data IPv4PktInfo = IPv4PktInfo ULONG HostAddress deriving (Eq)
-- | Network interface ID and local IPv4 address. The second member is
-- redundant to be the same as Unix's one and is always 0.0.0.0.
data IPv4PktInfo = IPv4PktInfo Int HostAddress HostAddress deriving (Eq)

instance Show IPv4PktInfo where
show (IPv4PktInfo n ha) = "IPv4PktInfo " ++ show n ++ " " ++ show (hostAddressToTuple ha)
show (IPv4PktInfo n sa ha) = "IPv4PktInfo " ++ show n ++ " " ++ show (hostAddressToTuple sa) ++ " " ++ show (hostAddressToTuple ha)

instance ControlMessage IPv4PktInfo where
controlMessageId = CmsgIdIPv4PktInfo

instance Storable IPv4PktInfo where
sizeOf _ = #{size IN_PKTINFO}
alignment _ = #alignment IN_PKTINFO
poke p (IPv4PktInfo n ha) = do
poke p (IPv4PktInfo n _ ha) = do
(#poke IN_PKTINFO, ipi_ifindex) p (fromIntegral n :: CInt)
(#poke IN_PKTINFO, ipi_addr) p ha
peek p = do
n <- (#peek IN_PKTINFO, ipi_ifindex) p
ha <- (#peek IN_PKTINFO, ipi_addr) p
return $ IPv4PktInfo n ha
return $ IPv4PktInfo n 0 ha

----------------------------------------------------------------

Expand Down

0 comments on commit e11132d

Please sign in to comment.