forked from teto/mptcpanalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Constants.chs
53 lines (42 loc) · 1.4 KB
/
Constants.chs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{-# LANGUAGE ForeignFunctionInterface #-}
{-|
Module : Net.Mptcp.Constants
Description : A module to bridge the haskell code to underlying C code
I consider this module internal.
The documentation may be a bit sparse.
Inspired by:
https://stackoverflow.com/questions/6689969/how-does-one-interface-with-a-c-enum-using-haskell-and-ffi
TODO might be best to just use the netlink script and adapt it
https://github.com/Ongy/netlink-hs/issues/7
-}
module Net.Mptcp.V0.Constants (
MptcpAttr(..)
, MptcpGenlEvent(..)
, mptcpGenlVer
, mptcpGenlName
, mptcpGenlCmdGrpName
, mptcpGenlEvGrpName
)
where
import Data.Word (Word8)
-- import System.Linux.Netlink.Constants (MessageType)
import Data.Bits ()
-- from include/uapi/linux/mptcp.h
#include <linux/mptcp_v0.h>
-- {underscoreToCase}
-- add prefix = "e"
{#enum MPTCP_ATTR_UNSPEC as MptcpAttr {} omit (__MPTCP_ATTR_AFTER_LAST) deriving (Eq, Show, Ord)#}
-- {underscoreToCase}
-- can also be seen as a command
{#enum MPTCP_CMD_UNSPEC as MptcpGenlEvent {} deriving (Eq, Show)#}
-- |Generic netlink MPTCP version
mptcpGenlVer :: Word8
mptcpGenlVer = {#const MPTCP_GENL_VER #}
mptcpGenlName :: String
mptcpGenlName = {#const MPTCP_GENL_NAME #}
mptcpGenlCmdGrpName :: String
mptcpGenlCmdGrpName = {#const MPTCP_GENL_CMD_GRP_NAME #}
mptcpGenlEvGrpName :: String
mptcpGenlEvGrpName = {#const MPTCP_GENL_EV_GRP_NAME #}
-- toEvent :: MptcpGenlEvent -> MptcpEvent
-- toEvent