Skip to content

Commit 1e219db

Browse files
committed
ready for basic functions
1 parent 187d563 commit 1e219db

11 files changed

+143
-323
lines changed

CHANGELOG.md

-11
This file was deleted.

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
# tlvmmt
1+
# MMT/TLV Parser
2+
3+
This package provides the parser for MMT/TLV transport file (mmts) according to
4+
[ARIB STD-B60](https://www.arib.or.jp/english/std_tr/broadcasting/std-b60.html) and
5+
[ARIB STD-B32](https://www.arib.or.jp/english/std_tr/broadcasting/std-b32.html) Fascicle 3.

app/Main.hs

+90-252
Large diffs are not rendered by default.

tlvmmt.cabal mmttlv.cabal

+21-24
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ cabal-version: 2.2
44
--
55
-- see: https://github.com/sol/hpack
66

7-
name: tlvmmt
7+
name: mmttlv
88
version: 0.1.0.0
9-
description: Please see the README on GitHub at <https://github.com/superfashi/tlvmmt#readme>
10-
homepage: https://github.com/superfashi/tlvmmt#readme
11-
bug-reports: https://github.com/superfashi/tlvmmt/issues
9+
description: Please see the README on GitHub at <https://github.com/superfashi/mmttlv#readme>
10+
homepage: https://github.com/superfashi/mmttlv#readme
11+
bug-reports: https://github.com/superfashi/mmttlv/issues
1212
author: SuperFashi
1313
maintainer: [email protected]
1414
copyright: 2023 SuperFashi
@@ -17,24 +17,23 @@ license-file: LICENSE
1717
build-type: Simple
1818
extra-source-files:
1919
README.md
20-
CHANGELOG.md
2120

2221
source-repository head
2322
type: git
24-
location: https://github.com/superfashi/tlvmmt
23+
location: https://github.com/superfashi/mmttlv
2524

2625
library
2726
exposed-modules:
28-
Common
29-
Descriptor
30-
Lib
31-
Message
32-
Net
33-
Table
27+
Data.MMTTLV
28+
Data.MMTTLV.Descriptor
29+
Data.MMTTLV.Internal
30+
Data.MMTTLV.Message
31+
Data.MMTTLV.Net
32+
Data.MMTTLV.Table
3433
other-modules:
35-
Paths_tlvmmt
34+
Paths_mmttlv
3635
autogen-modules:
37-
Paths_tlvmmt
36+
Paths_mmttlv
3837
hs-source-dirs:
3938
src
4039
default-extensions:
@@ -47,15 +46,14 @@ library
4746
, binary
4847
, bytestring
4948
, extra
50-
, pretty-hex
5149
default-language: Haskell2010
5250

53-
executable tlvmmt-exe
51+
executable mmttlv-exe
5452
main-is: Main.hs
5553
other-modules:
56-
Paths_tlvmmt
54+
Paths_mmttlv
5755
autogen-modules:
58-
Paths_tlvmmt
56+
Paths_mmttlv
5957
hs-source-dirs:
6058
app
6159
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
@@ -64,25 +62,24 @@ executable tlvmmt-exe
6462
, binary
6563
, bytestring
6664
, containers
65+
, mmttlv
6766
, pretty-show
6867
, streamly-core
69-
, tlvmmt
70-
, transformers
7168
default-language: Haskell2010
7269

73-
test-suite tlvmmt-test
70+
test-suite mmttlv-test
7471
type: exitcode-stdio-1.0
7572
main-is: Spec.hs
7673
other-modules:
77-
Paths_tlvmmt
74+
Paths_mmttlv
7875
autogen-modules:
79-
Paths_tlvmmt
76+
Paths_mmttlv
8077
hs-source-dirs:
8178
test
8279
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
8380
build-depends:
8481
base >=4.15 && <5
8582
, binary
8683
, bytestring
87-
, tlvmmt
84+
, mmttlv
8885
default-language: Haskell2010

package.yaml

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
name: tlvmmt
1+
name: mmttlv
22
version: 0.1.0.0
3-
github: "superfashi/tlvmmt"
3+
github: "superfashi/mmttlv"
44
license: 0BSD
55
author: "SuperFashi"
66
maintainer: "[email protected]"
77
copyright: "2023 SuperFashi"
88

99
extra-source-files:
1010
- README.md
11-
- CHANGELOG.md
1211

1312
# Metadata used when publishing your package
1413
# synopsis: Short description of your package
@@ -17,7 +16,7 @@ extra-source-files:
1716
# To avoid duplicated efforts in documentation and dealing with the
1817
# complications of embedding Haddock markup inside cabal files, it is
1918
# common to point users to the README.md file.
20-
description: Please see the README on GitHub at <https://github.com/superfashi/tlvmmt#readme>
19+
description: Please see the README on GitHub at <https://github.com/superfashi/mmttlv#readme>
2120

2221
dependencies:
2322
- base >= 4.15 && < 5
@@ -42,30 +41,28 @@ library:
4241
- NumericUnderscores
4342
dependencies:
4443
- extra
45-
- pretty-hex
4644

4745
executables:
48-
tlvmmt-exe:
46+
mmttlv-exe:
4947
main: Main.hs
5048
source-dirs: app
5149
ghc-options:
5250
- -threaded
5351
- -rtsopts
5452
- -with-rtsopts=-N
5553
dependencies:
56-
- tlvmmt
54+
- mmttlv
5755
- streamly-core
58-
- transformers
5956
- pretty-show
6057
- containers
6158

6259
tests:
63-
tlvmmt-test:
60+
mmttlv-test:
6461
main: Spec.hs
6562
source-dirs: test
6663
ghc-options:
6764
- -threaded
6865
- -rtsopts
6966
- -with-rtsopts=-N
7067
dependencies:
71-
- tlvmmt
68+
- mmttlv

src/Lib.hs src/Data/MMTTLV.hs

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
module Lib where
1+
module Data.MMTTLV (module Data.MMTTLV) where
22

3-
import Common (FragmentationIndicator, consumeAll, repeatRead)
43
import Control.Monad (guard, when)
54
import Control.Monad.Extra (whenMaybe)
65
import Data.Binary (Binary (..), Word16, Word32, Word8)
@@ -14,13 +13,11 @@ import Data.Binary.Get
1413
lookAhead,
1514
)
1615
import Data.Bits (shiftR, testBit, (.&.))
17-
import Data.ByteString.Lazy (ByteString, toStrict)
16+
import Data.ByteString.Lazy (ByteString)
1817
import qualified Data.ByteString.Lazy as L
19-
import Debug.Trace (traceShow)
20-
import Hexdump (prettyHex)
21-
import Message (ControlMessages)
22-
import Net (IPv6Addr, IPv6Header (..), NetworkTimeProtocolData, PartialIPv6Header, PartialUDPHeader, UDPHeader (..))
23-
import Numeric (showHex)
18+
import Data.MMTTLV.Internal (FragmentationIndicator, consumeAll, repeatRead)
19+
import Data.MMTTLV.Message (ControlMessages)
20+
import Data.MMTTLV.Net (IPv6Addr, IPv6Header (..), NetworkTimeProtocolData, PartialIPv6Header, PartialUDPHeader, UDPHeader (..))
2421

2522
data MPUFragment
2623
= MPUFragmentMPUMetadata ByteString
@@ -266,7 +263,7 @@ instance Binary IPv6Packet where
266263

267264
parsePayload :: IPv6Addr -> Word16 -> Get (Either ByteString NetworkTimeProtocolData)
268265
parsePayload (_, _, _, _, _, _, _, 0x101) 123 = Right <$> get
269-
parsePayload _ _ = error "somthing else"
266+
parsePayload _ _ = fail "Unknown IPv6 packet"
270267

271268
put = undefined
272269

@@ -287,10 +284,10 @@ instance Binary TLVPacket where
287284
l <- getWord16be
288285
d <- getLazyByteString $ fromIntegral l
289286
case t of
290-
0x01 -> error "TODO: IPv4"
287+
0x01 -> fail "TODO: IPv4"
291288
0x02 -> TLVPacketIPv6 <$> consumeAll get d
292289
0x03 -> TLVPacketHeaderCompressedIP <$> consumeAll get d
293-
0xFE -> error "TODO: TCS"
290+
0xFE -> fail "TODO: TCS"
294291
0xFF ->
295292
TLVPacketNull l
296293
<$ when (L.any (/= 0xFF) d) (fail "TLV Null packet is not null")

src/Descriptor.hs src/Data/MMTTLV/Descriptor.hs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
module Descriptor where
1+
module Data.MMTTLV.Descriptor (module Data.MMTTLV.Descriptor) where
22

3-
import Common (ISO639LanguageCode, consumeAll, readN, repeatRead)
43
import Control.Monad (when)
54
import Control.Monad.Extra (whenMaybe)
65
import Data.Binary (Binary (..), Word16, Word32, Word64, Word8)
@@ -16,7 +15,7 @@ import Data.Binary.Get
1615
)
1716
import Data.Bits (Bits (testBit), shiftR, (.&.))
1817
import Data.ByteString.Lazy (ByteString)
19-
import Debug.Trace (traceShow)
18+
import Data.MMTTLV.Internal (ISO639LanguageCode, consumeAll, readN, repeatRead)
2019

2120
data Descriptor
2221
= MPUTimestamp MPUTimestampDescriptor

src/Common.hs src/Data/MMTTLV/Internal.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Common where
1+
module Data.MMTTLV.Internal (module Data.MMTTLV.Internal) where
22

33
import Control.Monad.Extra (ifM)
44
import Data.Binary (Binary (..), Get, Word8)

src/Message.hs src/Data/MMTTLV/Message.hs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
module Message where
1+
module Data.MMTTLV.Message (module Data.MMTTLV.Message) where
22

3-
import Common (FragmentationIndicator, consumeAll, readN, repeatRead)
43
import Control.Monad (when)
54
import Data.Binary (Binary (..), Word16, Word32, Word8)
65
import Data.Binary.Get
@@ -12,11 +11,11 @@ import Data.Binary.Get
1211
getWord8,
1312
lookAhead,
1413
)
15-
import Data.Bits (Bits (testBit), shiftR, (.&.))
14+
import Data.Bits (shiftR, testBit, (.&.))
1615
import Data.ByteString.Lazy (ByteString)
1716
import qualified Data.ByteString.Lazy as L (length, splitAt)
18-
import Debug.Trace (traceShow)
19-
import Table (Table)
17+
import Data.MMTTLV.Internal (FragmentationIndicator, consumeAll, readN, repeatRead)
18+
import Data.MMTTLV.Table (Table)
2019

2120
data PAMessageTableInfo = PAMessageTableInfo
2221
{ tableId :: Word8,

src/Net.hs src/Data/MMTTLV/Net.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Net where
1+
module Data.MMTTLV.Net (module Data.MMTTLV.Net) where
22

33
import Data.Binary (Binary (..), Word16, Word32, Word64, Word8)
44
import Data.Binary.Get (getWord16be, getWord32be, getWord64be, getWord8)

src/Table.hs src/Data/MMTTLV/Table.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
module Table where
1+
module Data.MMTTLV.Table where
22

3-
import Common (consumeAll, readN, repeatRead)
43
import Control.Monad (when)
54
import Data.Binary (Binary (..), Word16, Word32, Word8)
65
import Data.Binary.Get (Get, getLazyByteString, getRemainingLazyByteString, getWord16be, getWord32be, getWord8, lookAhead)
76
import Data.Bits (Bits (testBit), (.&.))
87
import Data.ByteString.Lazy (ByteString)
9-
import Descriptor (Descriptor)
10-
import Net (IPv4Addr, IPv6Addr)
8+
import Data.MMTTLV.Descriptor (Descriptor)
9+
import Data.MMTTLV.Internal (consumeAll, readN, repeatRead)
10+
import Data.MMTTLV.Net (IPv4Addr, IPv6Addr)
1111

1212
data Table
1313
= MPT MMTPackageTable

0 commit comments

Comments
 (0)