Skip to content
This repository has been archived by the owner on Nov 10, 2021. It is now read-only.

Commit

Permalink
adding tcp flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthieu Coudron committed May 17, 2021
1 parent d23a28f commit e4efb51
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .nvimrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
let g:loaded_airline=1
autocmd FileType hs let b:airline_disable_statusline = 1
set statusline=%!StatusLSP()
" let g:loaded_airline=1
" autocmd FileType hs let b:airline_disable_statusline = 1
" set statusline=%!StatusLSP()
36 changes: 36 additions & 0 deletions Net/Tcp/Constants.chs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Net.Tcp.Constants
where

import Data.Bits ()
import Data.Word (Word8, Word32)

-- copy from include/net/tcp_states since it's not part of the user API
#include <tcp_states.h>
Expand All @@ -26,4 +27,39 @@ import Data.Bits ()
-- http://www.yonch.com/tech/linux-tcp-congestion-control-internals
#include <linux/tcp.h>


{#enum TCP_CA_Open as TcpCAState {underscoreToCase} deriving (Eq, Show)#}

-- GenBind.evalCCast: Casts are implemented only for integral constants
-- {#enum define TcpFlag {TCP_FLAG_SYN as TcpFlagSyn} deriving (Eq, Show)#}

data TcpFlag = TcpFlagSyn | TcpFlagFin | TcpFlagAck

-- {#const TCP_FLAG_SYN#}
tcpFlagSynVal :: Word32
tcpFlagSynVal = 2

tcpFlagFinVal :: Word32
tcpFlagFinVal = 1

tcpFlagAckVal :: Word32
tcpFlagAckVal = 8
-- tcpFlagAck :: Word8
-- tcpFlagAck = {#const TCP_FLAG_ACK #}


-- TCP_FLAG_CWR = __constant_cpu_to_be32(0x00800000),
-- TCP_FLAG_ECE = __constant_cpu_to_be32(0x00400000),
-- TCP_FLAG_URG = __constant_cpu_to_be32(0x00200000),
-- TCP_FLAG_ACK = __constant_cpu_to_be32(0x00100000),
-- TCP_FLAG_PSH = __constant_cpu_to_be32(0x00080000),
-- TCP_FLAG_RST = __constant_cpu_to_be32(0x00040000),
-- TCP_FLAG_SYN = __constant_cpu_to_be32(0x00020000),
-- TCP_FLAG_FIN = __constant_cpu_to_be32(0x00010000),

-- #define TH_FIN 0x0001
-- #define TH_SYN 0x0002
-- #define TH_RST 0x0004
-- #define TH_PUSH 0x0008
-- #define TH_ACK 0x0010

0 comments on commit e4efb51

Please sign in to comment.