{-# LINE 1 "src/System/Socket/Option/HeaderInclude.hsc" #-}
module System.Socket.Option.HeaderInclude (
  HeaderInclude(..)
) where
import Data.Word
import System.Socket
import System.Socket.Unsafe


{-# LINE 12 "src/System/Socket/Option/HeaderInclude.hsc" #-}

import Foreign.C.Types
type HdrInclType = CInt

{-# LINE 16 "src/System/Socket/Option/HeaderInclude.hsc" #-}

-- |Represents the `IP_HDRINCL` option. 
-- It determines whether or not to assume the IP header is included in any data sent over the socket
data HeaderInclude = HeaderInclude Bool deriving (Eq, Show)
instance SocketOption HeaderInclude where
  getSocketOption s =
    HeaderInclude . ((/=0) :: HdrInclType -> Bool) <$> unsafeGetSocketOption s 0 (2)
{-# LINE 23 "src/System/Socket/Option/HeaderInclude.hsc" #-}
  setSocketOption s (HeaderInclude o) =
    unsafeSetSocketOption s 0 (2) (if o then 1 else 0 :: HdrInclType)
{-# LINE 25 "src/System/Socket/Option/HeaderInclude.hsc" #-}