From 4038e65c38573e9b5c50058cb64662886205a20a Mon Sep 17 00:00:00 2001 From: fey Date: Fri, 24 Jul 2026 21:54:06 +0200 Subject: [PATCH] Reworked the Recorded Samples test. --- Documentation/storage_system_ids.md | 1 + .../SkyscrapersTestingFramework.cs | 11 +- .../SkyscrapersTestingHarness.cs | 13 ++ skyscraper8.Tests/TestLog4NetAppender.cs | 2 +- .../Tests/RecordedSamplesTests.cs | 195 ++++++++++++++++-- .../ResourceTests/SkyscraperResourceTests.cs | 2 +- skyscraper8.sln.DotSettings.user | 1 + .../MultiprotocolEncapsulationDecoder.cs | 2 +- skyscraper8/GS/POC/Pts2Bbf.cs | 2 +- skyscraper8/GS/POC/Pts2Bbf2.cs | 2 +- skyscraper8/Ietf/Rfc2460_IPv6/Ipv6Header.cs | 4 + skyscraper8/Program.cs | 2 +- .../Net/BlackholeIpTrafficHandler.cs | 179 ++++++++++++++++ .../Skyscraper/Net/IpTrafficHandler.cs | 2 +- .../Skyscraper/Scraper/SkyscraperContext.cs | 11 +- ...ctStorage.cs => BlackholeObjectStorage.cs} | 153 ++++++++------ 16 files changed, 490 insertions(+), 92 deletions(-) create mode 100644 skyscraper8.Tests/SkyscrapersTestingHarness.cs create mode 100644 skyscraper8/Skyscraper/Net/BlackholeIpTrafficHandler.cs rename skyscraper8/Skyscraper/Scraper/Storage/{NullObjectStorage.cs => BlackholeObjectStorage.cs} (60%) diff --git a/Documentation/storage_system_ids.md b/Documentation/storage_system_ids.md index a957999..c701942 100644 --- a/Documentation/storage_system_ids.md +++ b/Documentation/storage_system_ids.md @@ -19,6 +19,7 @@ These will have IP packets forwarded to. |--|-----------| | 1|PCAP Writer| | 2|Discard | +| 3|Blackhole | #Network Types These identify sources from which a network packet may come from. diff --git a/skyscraper8.Tests/SkyscrapersTestingFramework.cs b/skyscraper8.Tests/SkyscrapersTestingFramework.cs index 628c99b..7ab800d 100644 --- a/skyscraper8.Tests/SkyscrapersTestingFramework.cs +++ b/skyscraper8.Tests/SkyscrapersTestingFramework.cs @@ -1,5 +1,6 @@ using System.Reflection; using log4net; +using log4net.Core; using log4net.Repository.Hierarchy; using Newtonsoft.Json; @@ -122,7 +123,6 @@ public class SkyscrapersTestingFramework [SetUp] public void Setup() { - Console.WriteLine("Setup"); if (_testTimes == null) _testTimes = new Dictionary(); @@ -136,8 +136,6 @@ public class SkyscrapersTestingFramework [TearDown] public void TearDown() { - Console.WriteLine("TearDown"); - TestContext currentContext = TestContext.CurrentContext; VoileOnlineTestResult voileOnlineTestResult = new VoileOnlineTestResult(); @@ -216,4 +214,11 @@ public class SkyscrapersTestingFramework return logText; } + + protected IReadOnlyList GetCapturedLogEvents() + { + if (_testLogAppender == null) + return new List(); + return _testLogAppender.Events; + } } diff --git a/skyscraper8.Tests/SkyscrapersTestingHarness.cs b/skyscraper8.Tests/SkyscrapersTestingHarness.cs new file mode 100644 index 0000000..4ae3ae0 --- /dev/null +++ b/skyscraper8.Tests/SkyscrapersTestingHarness.cs @@ -0,0 +1,13 @@ +using log4net.Core; +using skyscraper8.Skyscraper.Net; +using skyscraper8.Skyscraper.Scraper.Storage; + +namespace skyscraper8.Tests.NUnit; + +public class SkyscrapersTestingHarness +{ + public DataStorage DataStorage { get; set; } + public ObjectStorage ObjectStorage { get; set; } + public IReadOnlyList Events { get; set; } + public BlackholeIpTrafficHandler IpTrafficHandler { get; set; } +} \ No newline at end of file diff --git a/skyscraper8.Tests/TestLog4NetAppender.cs b/skyscraper8.Tests/TestLog4NetAppender.cs index 5e81a49..8a34546 100644 --- a/skyscraper8.Tests/TestLog4NetAppender.cs +++ b/skyscraper8.Tests/TestLog4NetAppender.cs @@ -27,6 +27,6 @@ public class TestLog4NetAppender : AppenderSkeleton public string GetText() { - return String.Join("\n", Events.Select(e => e.RenderedMessage)); + return String.Join("\n", Events.Select(e => String.Format("[{0}] {1}", e.LoggerName, e.RenderedMessage))); } } diff --git a/skyscraper8.Tests/Tests/RecordedSamplesTests.cs b/skyscraper8.Tests/Tests/RecordedSamplesTests.cs index 8ee73d6..c80aabb 100644 --- a/skyscraper8.Tests/Tests/RecordedSamplesTests.cs +++ b/skyscraper8.Tests/Tests/RecordedSamplesTests.cs @@ -1,6 +1,7 @@ using skyscraper5.Mpeg2; using skyscraper5.Skyscraper.Scraper; using skyscraper5.Skyscraper.Scraper.Storage.InMemory; +using skyscraper8.Skyscraper.Net; using skyscraper8.Skyscraper.Scraper.Storage; using skyscraper8.Tests.NUnit; @@ -13,26 +14,30 @@ public class RecordedSamplesTests : SkyscrapersTestingFramework public void RussianT2Mi() { FileStream streamSample = GetStreamSample("express_3928L_t2mi.ts"); - ProcessSample(streamSample); + SkyscrapersTestingHarness result = ProcessSample(streamSample); streamSample.Close(); //42931 uncovered + Assert.True(result.DataStorage.TestForCaSystem(1, 1, 1453)); } [Test] public void Simmin() { FileStream streamSample = GetStreamSample("thor_11049v_simmin-radiomidun.ts"); - ProcessSample(streamSample); + SkyscrapersTestingHarness result = ProcessSample(streamSample); streamSample.Close(); //36611 uncovered + Assert.True(result.DataStorage.TestForTerminalBurstTimePlan2(1326, 1, 0)); + Assert.True(result.DataStorage.TestForBroadcastConfiguration(1326, 2)); } [Test] public void GseDab() { FileStream streamSample = GetStreamSample("thor_10717v_gse-dab.ts"); - ProcessSample(streamSample); + SkyscrapersTestingHarness result = ProcessSample(streamSample); streamSample.Close(); + Assert.IsTrue(result.IpTrafficHandler.TestForUdpTraffic("192.168.1.4", "239.199.2.4", 1234, 1234)); //36446 uncovered } @@ -40,17 +45,94 @@ public class RecordedSamplesTests : SkyscrapersTestingFramework public void EarlyBrazilianNip() { FileStream streamSample = GetStreamSample("brazilian-dvb-nip-000000.ts"); - ProcessSample(streamSample); + SkyscrapersTestingHarness result = ProcessSample(streamSample); streamSample.Close(); //35222 + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://10.10.10.24:8888/live/diskb/NIP_9/HLS_OUT/NIP_9-mp4a_140800=20000-begin=3403218160093331-dur=40106667-seq=85080456.m4s")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://usd.xxxoperatorxxx.com/fragments/envelope.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://10.10.10.24:8888/live/diskb/NIP_4/HLS_OUT/NIP_4-mp4a_140800=20000-begin=3403218170199998-dur=39893334-seq=85080456.m4s")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("envelope.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://www.enensys.com/usd_bid274499940_cid274499942.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://10.10.10.24:8888/live/diskb/NIP_6/HLS_OUT/NIP_6-hvc1_1761664=10000-p=335204011000000-init.mp4")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://www.enensys.com/usd_bid274499949_cid274499951.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://10.10.10.24:8888/live/diskb/NIP_9/HLS_OUT/NIP_9-hvc1_1761664=10000-p=330114634000000-init.mp4")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://www.enensys.com/usd_bid274499913_cid274499915.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://10.10.10.24:8888/live/diskb/NIP_1/HLS_OUT/NIP_1-hvc1_1761664=10000-p=330114493000000-init.mp4")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://www.enensys.com/usd_bid274499968_cid274499970.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://10.10.10.24:8888/live/diskb/NIP_4/HLS_OUT/NIP_4-hvc1_1761664=10000-p=330030655000000-init.mp4")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://www.enensys.com/usd_bid274499922_cid274499924.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://10.10.10.24:8888/live/diskb/NIP_2/HLS_OUT/NIP_2-hvc1_1761664=10000-p=330114509000000-init.mp4")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://www.enensys.com/usd_bid244303386_cid244303388.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://10.10.10.24:8888/live/diskb/NIP_0/HLS_OUT/NIP_0-hvc1_1761664=10000-p=330114463000000-init.mp4")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://www.enensys.com/usd_bid274499958_cid274499960.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://10.10.10.24:8888/live/diskb/NIP_6/HLS_OUT/NIP_6-mp4a_140800=20000-begin=3403218200093333-dur=40106667-seq=85080457.m4s")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("urn:dvb:metadata:nativeip:NetworkInformationFile")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://10.10.10.24:8888/live/diskb/NIP_4/HLS_OUT/NIP_4-mp4a_140800=20000-begin=3403218210093332-dur=40106667-seq=85080457.m4s")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://10.10.10.22:80/1/images.tar")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://10.10.10.24:8888/live/diskb/NIP_2/HLS_OUT/NIP_2-mp4a_140800=20000-begin=3403218240093332-dur=40106667-seq=85080458.m4s")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://10.10.10.22:80/pages.tar")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://10.10.10.24:8888/live/diskb/NIP_0/HLS_OUT/NIP_0-hvc1_1761664=10000-begin=3403218250000000-dur=40000000-seq=85080458.m4s")); } [Test] public void GseNip() { FileStream streamSample = GetStreamSample("astra1_12441v_gse-nip.ts"); - ProcessSample(streamSample); + SkyscrapersTestingHarness result = ProcessSample(streamSample); streamSample.Close(); + Assert.True(result.ObjectStorage.DvbNipTestForFile("urn:dvb:metadata:cs:MulticastTransportObjectTypeCS:2021:gateway-configuration")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/sgc/tva_schedule_20251123100000_PT3H15M_CoreSet.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s2/5G-EMERGE/Live/hls/RaiScuola/RaiScuola_v_1000.m3u8")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("urn:dvb:metadata:cs:NativeIPMulticastTransportObjectTypeCS:2023:bootstrap")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/sge/MorningNews.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s2/5G-EMERGE/Live/hls/RaiScuola/RaiScuola_v_4500.m3u8")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/sge/PoliticalInsight.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s2/5G-EMERGE/Live/hls/RaiScuola/RaiScuola.m3u8")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/sge/ScienceFictionShowcase.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s1/5G-EMERGE/Live/hls/RaiStoria/RaiStoria_v_1000_6287140.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/sge/SportsHighlights.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s2/5G-EMERGE/Live/hls/RaiScuola/RaiScuola_v_1000_6287143.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/sge/TravelAdventures.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/vod2/5G-Emerge_v_1000_00006.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s2/5G-EMERGE/Live/hls/RaiScuola/RaiScuola_v_2000_6287143.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/sge/ComedyHour.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s2/5G-EMERGE/Live/hls/RaiScuola/RaiScuola_v_4500_6287143.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/vod2/5G-Emerge_v_1000_00005.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/sge/FitnessHour.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s0/5G-EMERGE/Live/hls/crits_linear/crits_linear_v_1000_556702.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("urn:dvb:metadata:nativeip:NetworkInformationFile")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/cg/manifest.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("urn:dvb:metadata:nativeip:ServiceGuide")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/vod1/5G-MAG_v_4500_00004.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/sge/KidsFunTime.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/vod2/5G-Emerge_v_1000_00009.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s1/5G-EMERGE/Live/hls/RaiStoria/RaiStoria_v_1000_6287141.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/sge/RomanticEvenings.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s2/5G-EMERGE/Live/hls/RaiScuola/RaiScuola_v_1000_6287144.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/data/IMG_1007.jpeg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/vod2/5G-Emerge_v_1000_00013.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/data/IMG_1009.jpeg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/sge/TechTalk.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s1/5G-EMERGE/Live/hls/RaiStoria/RaiStoria_v_4500_6287141.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/data/IMG_1005.jpeg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s2/5G-EMERGE/Live/hls/RaiScuola/RaiScuola_v_2000_6287144.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/sge/DocumentaryWorld.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/vod2/5G-Emerge_v_1000_00017.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/data/Astronomy-2e.pdf")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/sge/MysteryTheater.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/vod2/5G-Emerge_v_1000_00021.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s0/5G-EMERGE/Live/hls/crits_linear/crits_linear_v_1000_556703.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/data/IMG_1006.jpeg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/sge/WildlifeWonders.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s1/5G-EMERGE/Live/hls/RaiStoria/RaiStoria_v_1000_6287142.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/vod1/5G-MAG_v_4500_00011.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s0/5G-EMERGE/Live/hls/crits_linear/crits_linear_v_2000_556703.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/data/IMG_1000.jpeg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s1/5G-EMERGE/Live/hls/RaiStoria/RaiStoria_v_4500_6287142.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/data/IMG_1011.jpeg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/s2/5G-EMERGE/Live/hls/RaiScuola/RaiScuola_v_4500_6287145.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/inverto.tv/data/IMG_1012.jpeg")); + //34545 } @@ -58,76 +140,157 @@ public class RecordedSamplesTests : SkyscrapersTestingFramework public void GseNip2() { FileStream streamSample = GetStreamSample("astra1_11141h_gse_nip.ts"); - ProcessSample(streamSample); + SkyscrapersTestingHarness result = ProcessSample(streamSample); streamSample.Close(); //34462 + Assert.True(result.ObjectStorage.DvbNipTestForFile("urn:dvb:metadata:cs:MulticastTransportObjectTypeCS:2021:gateway-configuration")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/hbbtv/xml.aitx")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/livesim2/C1/fr-sub/1763893122.m4s")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/hbbtv/main.js")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/livesim2/B2/playlist-audio.m3u8")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/live/channel1/manifest.mpd")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/livesim2/C1/audio/1763893122.m4s")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/hbbtv/img/dvbnip.png")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/livesim2/C1/playlist-audio2.m3u8")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/hbbtv/style.css")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/private/dvbi/service_list_ses_private.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/hbbtv/button.js")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("urn:dvb:metadata:cs:NativeIPMulticastTransportObjectTypeCS:2023:bootstrap")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/livesim2/B1/audio/881946560.m4s")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/hbbtv/index.html")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/private/vod_small/covers/A%20Better%20Super%20Bowl.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/dvbi/service_list_full.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/livesim2/C1/audio2/1763893123.m4s")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/dvbi/cg/CoreSetRelatedMaterials/programm-api.ard.de/images/MjAyNS0xMC0wMQ==/68ddba3f8ace97dd375c961b_1759361599632.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("urn:dvb:metadata:nativeip:dvb-i-slep")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/private/vod_small/covers/HDplus_ExtraScreen.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/hbbtv/img/WTqW6FTJ2.jpeg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/livesim2/B2/audio/881946561.m4s")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/live/channel1/1-2025940.m4s")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/livesim2/C1/audio/1763893124.m4s")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/materials/b1.png")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/private/vod_small/covers/2017_SES_4K_trailer_IBC.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/dvbi/service_list_tp1045.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/livesim2/B1/audio/881946561.m4s")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/dvbi/cg/manifest.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/private/vod_small/covers/SES_BS.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/materials/5G-EMERGE.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/private/vod_small/covers/AIT_VF-10-08-15_French.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/livesim2/C1/audio/1763893125.m4s")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/dvbi/sg/CoreSetRelatedMaterial/programm-api.ard.de/images/MjAyNS0wOS0xMA==/68c20b38bc0414230a56325d_1757547321028.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/materials/b2.png")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/private/vod_small/covers/Welcome%20to%20Luxembourg.jpg")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/ses.com/livesim2/B2/audio/881946562.m4s")); + } [Test] public void TsNipIncludingLegacyChannel() { FileStream streamSample = GetStreamSample("hotbird_12380v_nip.ts"); - ProcessSample(streamSample); + SkyscrapersTestingHarness result = ProcessSample(streamSample); streamSample.Close(); //33518 + Assert.IsTrue(result.DataStorage.TestForCaSystem(318, 8400, 7104)); + Assert.IsTrue(result.IpTrafficHandler.TestForUdpTraffic("0.0.0.0", "224.1.1.103", 0, 16301)); + Assert.IsTrue(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/rai.it/s0/5G-EMERGE/Live/dash/crits_linear/crits_linear_v_4500_001114520.mp4")); } [Test] public void TsNip() { FileStream streamSample = GetStreamSample("hotbird_12226v_nip.ts"); - ProcessSample(streamSample); + SkyscrapersTestingHarness result = ProcessSample(streamSample); streamSample.Close(); //33518 + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/ts_corp/73_tamazight_tccybxt/playlist.m3u8")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/corp/73_arryadia_k2tgcj0_480p/playlist.m3u8")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/bpk-tv/orp01-ten999-ch009/hls-sb/index.m3u8")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/ts_corp/73_arrabia_hthcj4p/playlist.m3u8")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/bpk-tv/orp01-ten999-ch008/hls-sb/index.m3u8")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/ts_corp/73_almaghribia_83tz85q/corp/73_almaghribia_83tz85q_240p/l_43709_87687000_23699.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/corp/73_aloula_w1dqfwm/playlist.m3u8")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/ts_corp/73_tamazight_tccybxt/corp/73_tamazight_tccybxt_480p/l_22569_7413000_17779.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("urn:dvb:metadata:cs:NativeIPMulticastTransportObjectTypeCS:2023:bootstrap")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/ts_corp/73_almaghribia_83tz85q/corp/73_almaghribia_83tz85q_240p/l_43709_87690000_23700.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("urn:dvb:metadata:cs:MulticastTransportObjectTypeCS:2021:gateway-configuration")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/bpk-tv/orp01-ten999-ch007/hls-sb/keyframes/orp01-ten999-ch007-video=2580000-440974019.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/ts_corp/73_almaghribia_83tz85q/corp/73_almaghribia_83tz85q_360p/l_43705_87690000_23700.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/bpk-tv/orp01-ten999-ch009/hls-sb/keyframes/orp01-ten999-ch009-video=2600000-440974020.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/ts_corp/73_arrabia_hthcj4p/corp/73_arrabia_hthcj4p_480p/l_43737_7398000_23696.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/corp/73_aloula_w1dqfwm/l_43669_7389881_23706.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/ts_corp/73_almaghribia_83tz85q/corp/73_almaghribia_83tz85q_480p/l_43701_87690000_23700.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/corp/73_arryadia_k2tgcj0_480p/l_22601_52377000_17770.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/ts_corp/73_almaghribia_83tz85q/corp/73_almaghribia_83tz85q_240p/l_43709_87693000_23701.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("envelope.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://www.enensys.com/usd_bid8331_cid8335.xml")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/ts_corp/73_almaghribia_83tz85q/corp/73_almaghribia_83tz85q_480p/l_43701_87693000_23701.ts")); + Assert.True(result.ObjectStorage.DvbNipTestForFile("http://dvb.gw/eutelsat/bpk-tv/orp01-ten999-ch009/hls-sb/orp01-ten999-ch009-audio_133600_eng=131600-video=2600000-440974020.ts")); } [Test] public void GseRcs2() { FileStream streamSample = GetStreamSample("telstar12v-bfbs-000000.ts"); - ProcessSample(streamSample); + SkyscrapersTestingHarness result = ProcessSample(streamSample); streamSample.Close(); //32559 + Assert.True(result.DataStorage.TestForTerminalBurstTimePlan2(65281, 5, 0)); + Assert.True(result.DataStorage.TestForBroadcastConfiguration(65281, 2)); + Assert.True(result.IpTrafficHandler.TestForUdpTraffic("192.168.19.50", "238.1.1.1", 1024, 4000)); } [Test] public void BadrDvbSis() { FileStream streamSample = GetStreamSample("badr_12563v_dvb-sis.ts"); - ProcessSample(streamSample); + SkyscrapersTestingHarness result = ProcessSample(streamSample); streamSample.Close(); + Assert.True(result.ObjectStorage.TestForSisDsaci(136, 26, 1, 13)); } [Test] public void Eutelsat5DvbSis() { FileStream streamSample = GetStreamSample("eutelsat5_12522v_dvb-sis.ts"); - ProcessSample(streamSample); + SkyscrapersTestingHarness result = ProcessSample(streamSample); streamSample.Close(); + Assert.True(result.ObjectStorage.TestForSisDsaci(1375, 20700, 9, 17)); } [Test] public void Kira7Patchday() { FileStream streamSample = GetStreamSample("kira7.ts"); - ProcessSample(streamSample); + SkyscrapersTestingHarness result = ProcessSample(streamSample); streamSample.Close(); + Assert.IsTrue(result.IpTrafficHandler.TestForUdpTraffic("192.168.1.48", "224.0.0.252", 62983, 5355)); + Assert.IsTrue(result.IpTrafficHandler.TestForLlcTraffic("ff:ff:ff:ff:ff:ff", 8, 0, 0)); } - private void ProcessSample(Stream sample) + private SkyscrapersTestingHarness ProcessSample(Stream sample) { TsContext ts = new TsContext(); InMemoryScraperStorageFactory inMemoryStorageFactory = new InMemoryScraperStorageFactory(); DataStorage dataStorage = inMemoryStorageFactory.CreateDataStorage(); - NullObjectStorage nullObjectStorage = new NullObjectStorage(); + ObjectStorage blackholeObjectStorage = new BlackholeObjectStorage(); - SkyscraperContext context = new SkyscraperContext(ts, dataStorage, nullObjectStorage); + BlackholeIpTrafficHandler ipTrafficHandler = new BlackholeIpTrafficHandler(); + + SkyscraperContext context = new SkyscraperContext(ts, dataStorage, blackholeObjectStorage); context.InitalizeFilterChain(); + context.OverrideIpTrafficHandler(ipTrafficHandler); context.IngestFromStream(sample); - } + SkyscrapersTestingHarness harness = new SkyscrapersTestingHarness(); + harness.DataStorage = dataStorage; + harness.ObjectStorage = blackholeObjectStorage; + harness.Events = GetCapturedLogEvents(); + harness.IpTrafficHandler = ipTrafficHandler; + return harness; + } } diff --git a/skyscraper8.Tests/Tests/ResourceTests/SkyscraperResourceTests.cs b/skyscraper8.Tests/Tests/ResourceTests/SkyscraperResourceTests.cs index 2091421..cde3fac 100644 --- a/skyscraper8.Tests/Tests/ResourceTests/SkyscraperResourceTests.cs +++ b/skyscraper8.Tests/Tests/ResourceTests/SkyscraperResourceTests.cs @@ -24,7 +24,7 @@ public class SkyscraperResourceTests : SkyscrapersTestingFramework { TsContext mpeg2 = new TsContext(); DataStorage ds = new InMemoryScraperStorageFactory().CreateDataStorage(); - ObjectStorage os = new NullObjectStorage(); + ObjectStorage os = new BlackholeObjectStorage(); SkyscraperContext skyscraper = new SkyscraperContext(mpeg2, ds, os); MemoryStream ms = new MemoryStream(buffer, false); diff --git a/skyscraper8.sln.DotSettings.user b/skyscraper8.sln.DotSettings.user index 87de0ec..410bc16 100644 --- a/skyscraper8.sln.DotSettings.user +++ b/skyscraper8.sln.DotSettings.user @@ -4,6 +4,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded diff --git a/skyscraper8/Dvb/DataBroadcasting/MultiprotocolEncapsulationDecoder.cs b/skyscraper8/Dvb/DataBroadcasting/MultiprotocolEncapsulationDecoder.cs index c551c4e..caf8aa8 100644 --- a/skyscraper8/Dvb/DataBroadcasting/MultiprotocolEncapsulationDecoder.cs +++ b/skyscraper8/Dvb/DataBroadcasting/MultiprotocolEncapsulationDecoder.cs @@ -134,7 +134,7 @@ namespace skyscraper5.Dvb.DataBroadcasting { if (!announcedLlcTraffic) { - //logger.InfoFormat("Detected LLC/SNAP traffic on PID {0:x4}", sourcePid); + logger.InfoFormat("Detected LLC/SNAP traffic on PID {0:x4}", sourcePid); announcedLlcTraffic = true; } diff --git a/skyscraper8/GS/POC/Pts2Bbf.cs b/skyscraper8/GS/POC/Pts2Bbf.cs index 8ebb6d8..cfb7e3f 100644 --- a/skyscraper8/GS/POC/Pts2Bbf.cs +++ b/skyscraper8/GS/POC/Pts2Bbf.cs @@ -46,7 +46,7 @@ public class Pts2Bbf TsContext mpeg2 = new TsContext(); mpeg2.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(null, dumper)); DataStorage dataStorage = new InMemoryScraperStorage(); - ObjectStorage objectStorage = new NullObjectStorage(); + ObjectStorage objectStorage = new BlackholeObjectStorage(); SkyscraperContext skyscraper = new SkyscraperContext(mpeg2, dataStorage, objectStorage); skyscraper.InitalizeFilterChain(); skyscraper.IngestFromStream(fileStream); diff --git a/skyscraper8/GS/POC/Pts2Bbf2.cs b/skyscraper8/GS/POC/Pts2Bbf2.cs index 3c0b984..5f1d125 100644 --- a/skyscraper8/GS/POC/Pts2Bbf2.cs +++ b/skyscraper8/GS/POC/Pts2Bbf2.cs @@ -28,7 +28,7 @@ public class Pts2Bbf2 : IBbframeDeencapsulator Stid135BbFrameReader bbFrameReader = new Stid135BbFrameReader(null, this); mpeg2.RegisterPacketProcessor(0x010e, bbFrameReader); - SkyscraperContext context = new SkyscraperContext(mpeg2, new InMemoryScraperStorage(), new NullObjectStorage()); + SkyscraperContext context = new SkyscraperContext(mpeg2, new InMemoryScraperStorage(), new BlackholeObjectStorage()); context.InitalizeFilterChain(); FileStream fileStream = _fi.OpenRead(); diff --git a/skyscraper8/Ietf/Rfc2460_IPv6/Ipv6Header.cs b/skyscraper8/Ietf/Rfc2460_IPv6/Ipv6Header.cs index b0bba55..6c89547 100644 --- a/skyscraper8/Ietf/Rfc2460_IPv6/Ipv6Header.cs +++ b/skyscraper8/Ietf/Rfc2460_IPv6/Ipv6Header.cs @@ -36,6 +36,8 @@ namespace skyscraper5.Ietf.Rfc2460 HopLimit = ms.ReadUInt8(); SourceAddress = new IPAddress(ms.ReadBytes(16)); DestinationAddress = new IPAddress(ms.ReadBytes(16)); + + HeaderEndOffset = (int)ms.Position; Valid = true; } @@ -54,5 +56,7 @@ namespace skyscraper5.Ietf.Rfc2460 public int TrafficClass { get; } public int FlowLabel { get; } + + public int HeaderEndOffset { get; } } } diff --git a/skyscraper8/Program.cs b/skyscraper8/Program.cs index ef97b7c..5e567cc 100644 --- a/skyscraper8/Program.cs +++ b/skyscraper8/Program.cs @@ -130,7 +130,7 @@ namespace skyscraper5 FileStream fstream = fi.OpenRead(); TsContext mpeg2 = new TsContext(); - SkyscraperContext skyscraper = new SkyscraperContext(mpeg2, new InMemoryScraperStorage(), new NullObjectStorage()); + SkyscraperContext skyscraper = new SkyscraperContext(mpeg2, new InMemoryScraperStorage(), new BlackholeObjectStorage()); skyscraper.InitalizeFilterChain(); MultiprotocolEncapsulationDecoder mpeDecoder = new MultiprotocolEncapsulationDecoder(skyscraper); diff --git a/skyscraper8/Skyscraper/Net/BlackholeIpTrafficHandler.cs b/skyscraper8/Skyscraper/Net/BlackholeIpTrafficHandler.cs new file mode 100644 index 0000000..b7a1416 --- /dev/null +++ b/skyscraper8/Skyscraper/Net/BlackholeIpTrafficHandler.cs @@ -0,0 +1,179 @@ +using System.Net; +using System.Net.NetworkInformation; +using skyscraper5.Ietf.Rfc2460; +using skyscraper5.Ietf.Rfc768; +using skyscraper5.Ietf.Rfc971; +using skyscraper5.Skyscraper.Plugins; +using skyscraper8.Skyscraper.Net.VirtualNetworks; +using skyscraper8.Skyscraper.Scraper.Storage; + +namespace skyscraper8.Skyscraper.Net; + +[SkyscraperPlugin] +[StorageId(3)] +[StorageName("Packet Discarder")] +public class BlackholeIpTrafficHandler : IpTrafficHandler +{ + public void Dispose() + { + // TODO release managed resources here + } + + public void HandleIpPacket(VirtualNetworkIdentifier pid, byte[] payload) + { + if (payload == null || payload.Length == 0) + return; + + int ipVersion = (payload[0] & 0xF0) >> 4; + bool isIpv4 = ipVersion == 4; + bool isUdp = false; + int udpOffset = -1; + byte proto; + IPAddress srcAddr; + IPAddress dstAddr; + if (isIpv4) + { + InternetHeader ipv4 = new InternetHeader(payload); + isUdp = ipv4.Protocol == 17; + udpOffset = ipv4.NextHeaderOffset; + srcAddr = ipv4.SourceAddress; + dstAddr = ipv4.DestinationAddress; + proto = ipv4.Protocol; + } + else + { + bool isIpv6 = ipVersion == 6; + if (isIpv6) + { + Ipv6Header ipv6 = new Ipv6Header(payload); + isUdp = ipv6.NextHeader == 17; + udpOffset = ipv6.HeaderEndOffset; + srcAddr = ipv6.SourceAddress; + dstAddr = ipv6.DestinationAddress; + proto = ipv6.NextHeader; + } + else + { + return; + } + } + + if (isUdp) + { + UserDatagram userDatagram = new UserDatagram(new Span(payload).Slice(udpOffset).ToArray()); + TrackUdpContent(srcAddr, dstAddr, userDatagram.SourcePort, userDatagram.DestinationPort, userDatagram.Payload); + } + + TrackIpContent(srcAddr, dstAddr, proto, payload.Length - udpOffset); + + } + + private void TrackIpContent(IPAddress srcAddr, IPAddress dstAddr, byte proto, int payloadLength) + { + if (_ipContents == null) + _ipContents = new Dictionary, TrafficTracking>(); + + Tuple coordinate = new Tuple(srcAddr, dstAddr, proto); + if (!_ipContents.ContainsKey(coordinate)) + { + TrafficTracking tracking = new TrafficTracking(); + tracking.Count(payloadLength); + _ipContents.Add(coordinate, tracking); + } + else + { + _ipContents[coordinate].Count(payloadLength); + } + } + + public void HandleLlcFrame(VirtualNetworkIdentifier pid, PhysicalAddress source, PhysicalAddress destination, + ushort etherType, byte[] contents) + { + Tuple coordinate = new Tuple(destination, etherType, contents[0], contents[1]); + + if (_llcContents == null) + _llcContents = new Dictionary, TrafficTracking>(); + + if (!_llcContents.ContainsKey(coordinate)) + { + TrafficTracking tracking = new TrafficTracking(); + tracking.Count(contents.Length - 2); + _llcContents.Add(coordinate, tracking); + } + else + { + _llcContents[coordinate].Count(contents.Length - 2); + } + } + + private void TrackUdpContent(IPAddress src, IPAddress dst, ushort srcPort, ushort dstPort, byte[] contents) + { + if (_udpContents == null) + { + _udpContents = new Dictionary, TrafficTracking>(); + } + + Tuple coordinate = new Tuple(src, dst, srcPort, dstPort); + if (!_udpContents.ContainsKey(coordinate)) + { + TrafficTracking tracking = new TrafficTracking(); + tracking.Count(contents.Length); + _udpContents.Add(coordinate, tracking); + } + else + { + _udpContents[coordinate].Count(contents.Length); + } + } + + + private Dictionary, TrafficTracking> _llcContents; + private Dictionary, TrafficTracking> _ipContents; + private Dictionary, TrafficTracking> _udpContents; + + public class TrafficTracking + { + public void Count(int length) + { + NumPackets++; + NumBytes += length; + } + + public int NumPackets { get; set; } + + public int NumBytes { get; set; } + } + + public bool? TestForUdpTraffic(string srcIp, string dstIp, int stcPort, int dstPort) + { + IPAddress ipL = IPAddress.Parse(srcIp); + IPAddress ipR = IPAddress.Parse(dstIp); + ushort portL = Convert.ToUInt16(stcPort); + ushort portR = Convert.ToUInt16(dstPort); + return TestForUdpTraffic(ipL, ipR, portL, portR); + } + + private bool? TestForUdpTraffic(IPAddress srcIp, IPAddress dstIp, ushort stcPort, ushort dstPort) + { + Tuple coordinate = new Tuple(srcIp, dstIp, stcPort, dstPort); + return _udpContents.ContainsKey(coordinate); + } + + public bool TestForLlcTraffic(string mac, int ethertype, int ssap, int dsap) + { + PhysicalAddress srcMac = PhysicalAddress.Parse(mac); + ushort etherType16 = Convert.ToUInt16(ethertype); + byte ssap8 = Convert.ToByte(ssap); + byte dsap8 = Convert.ToByte(dsap); + return TestForLlcTraffic(srcMac, etherType16, ssap8, dsap8); + } + + private bool TestForLlcTraffic(PhysicalAddress srcMac, ushort etherType16, byte ssap8, byte dsap8) + { + if (_llcContents == null) + return false; + + Tuple coordinate = new Tuple(srcMac, etherType16, ssap8, dsap8); + return _llcContents.ContainsKey(coordinate); + } +} \ No newline at end of file diff --git a/skyscraper8/Skyscraper/Net/IpTrafficHandler.cs b/skyscraper8/Skyscraper/Net/IpTrafficHandler.cs index 09d852a..d478286 100644 --- a/skyscraper8/Skyscraper/Net/IpTrafficHandler.cs +++ b/skyscraper8/Skyscraper/Net/IpTrafficHandler.cs @@ -8,7 +8,7 @@ using skyscraper8.Skyscraper.Net.VirtualNetworks; namespace skyscraper8.Skyscraper.Net { - internal interface IpTrafficHandler : IDisposable + public interface IpTrafficHandler : IDisposable { void HandleIpPacket(VirtualNetworkIdentifier pid, byte[] payload); void HandleLlcFrame(VirtualNetworkIdentifier pid, PhysicalAddress source, PhysicalAddress destination, ushort etherType, byte[] contents); diff --git a/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs b/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs index ad82392..3b1f117 100644 --- a/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs +++ b/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs @@ -3173,7 +3173,7 @@ namespace skyscraper5.Skyscraper.Scraper return; } - //ipTrafficHandler.HandleLlcFrame(pid, source, destination, etherType, contents); + ipTrafficHandler.HandleLlcFrame(pid, source, destination, etherType, contents); MemoryStream llcStream = new MemoryStream(contents, true); @@ -3671,5 +3671,14 @@ namespace skyscraper5.Skyscraper.Scraper ObjectStorage.StoreThreemediaSegment(tarHeader, entryStream); } } + + public void OverrideIpTrafficHandler(IpTrafficHandler sink) + { + if (ipTrafficHandler != null) + { + throw new ScraperException("Can not override IP Traffic handler when a handler is already set."); + } + ipTrafficHandler = sink; + } } } diff --git a/skyscraper8/Skyscraper/Scraper/Storage/NullObjectStorage.cs b/skyscraper8/Skyscraper/Scraper/Storage/BlackholeObjectStorage.cs similarity index 60% rename from skyscraper8/Skyscraper/Scraper/Storage/NullObjectStorage.cs rename to skyscraper8/Skyscraper/Scraper/Storage/BlackholeObjectStorage.cs index 5c82d7a..16f2006 100644 --- a/skyscraper8/Skyscraper/Scraper/Storage/NullObjectStorage.cs +++ b/skyscraper8/Skyscraper/Scraper/Storage/BlackholeObjectStorage.cs @@ -15,23 +15,55 @@ using skyscraper8.Skyscraper.Scraper.Storage.Tar; namespace skyscraper8.Skyscraper.Scraper.Storage { - public class NullObjectStorage : ObjectStorage + public class BlackholeObjectStorage : ObjectStorage { + public bool SsdpDeviceKnown(SsdpDevice ssdpDevice) + { + throw new NotImplementedException(); + } + + public void SsdpStoreMetadata(SsdpDevice ssdpDevice, byte[] ssdpMetadataByteArray) + { + throw new NotImplementedException(); + } + + public byte[] SsdpGetMetadata(SsdpDevice ssdpDevice) + { + throw new NotImplementedException(); + } + public bool ObjectCarouselFileArrival(VfsFile vfsFile, int transportStreamId, int networkId) { throw new NotImplementedException(); } + public bool TestForObjectCarouselFileArrival(string vfsFile, int transportStreamId, int pid, int networkId) + { + throw new NotImplementedException(); + } + + public byte[] GetObjectCarouselFileArrival(string vfsFile, int transportStreamId, int pid, int networkId) + { + throw new NotImplementedException(); + } + public void DataCarouselModuleArrival(int currentNetworkId, int currentTransportStreamId, int elementaryPid, ushort moduleModuleId, byte moduleModuleVersion, Stream result) { throw new NotImplementedException(); } + private HashSet> knownDsmCcModules; public bool IsDsmCcModuleWanted(int currentNetworkId, int currentTransportStreamId, int elementaryPid, ushort moduleId, byte moduleVersion) { - return false; + if (knownDsmCcModules == null) + return true; + else + { + Tuple module = Tuple.Create(currentNetworkId, currentTransportStreamId, elementaryPid, moduleId, moduleVersion); + return !knownDsmCcModules.Contains(module); + } } public bool TestForFramegrab(int currentNetworkId, int transportStreamId, ushort mappingProgramNumber, @@ -56,17 +88,19 @@ namespace skyscraper8.Skyscraper.Scraper.Storage throw new NotImplementedException(); } - public class NullToken + class BlackholeObjectStorageToken { - + } + private object[] _token; public object[] GetPluginConnector() { - return new object[1] + if (_token == null) { - new NullToken() - }; + _token = new object[] { new BlackholeObjectStorageToken() }; + } + return _token; } public void Ping() @@ -74,13 +108,19 @@ namespace skyscraper8.Skyscraper.Scraper.Storage throw new NotImplementedException(); } + private HashSet _nipFiles; public bool DvbNipTestForFile(string announcedFileContentLocation) { - return true; + if (_nipFiles == null) + return false; + return _nipFiles.Contains(announcedFileContentLocation); } public void DvbNipFileArrival(NipActualCarrierInformation carrier, FluteListener listener) { + if (_nipFiles == null) + _nipFiles = new HashSet(); + _nipFiles.Add(listener.FileAssociation.ContentLocation); } public void StoreIqGraph(Guid jobGuid, long frequency, char polarity, IqChartData plot) @@ -103,6 +143,11 @@ namespace skyscraper8.Skyscraper.Scraper.Storage throw new NotImplementedException(); } + public RfSpectrumData GetRfSpectrum(Guid selectedGuid) + { + throw new NotImplementedException(); + } + public bool OtvSsuTestFile(int? currentNetworkId, int? currentTransportStreamId, int sourcePid, ushort tableIdExtension, uint fileId, uint unknown1, uint length) { @@ -118,87 +163,65 @@ namespace skyscraper8.Skyscraper.Scraper.Storage public void OnNdsSsuComplete(int? currentNetworkId, int? currentTransportStreamId, int pid, ushort tableIdExtension, NdsSsuDataMap dataMap) { - dataMap.Dispose(); + throw new NotImplementedException(); } public bool NdsSsuTestFile(int? currentNetworkId, int? currentTransportStreamId, int pid, ushort tableIdExtension) - { - return true; - } - - public bool SsdpDeviceKnown(SsdpDevice ssdpDevice) - { - return false; - } - - public void SsdpStoreMetadata(SsdpDevice ssdpDevice, byte[] ssdpMetadataByteArray) - { - - } - - public byte[] SsdpGetMetadata(SsdpDevice ssdpDevice) { throw new NotImplementedException(); } - public bool TestForSisDsaci(int value1, int value2, ushort groupId, int versionNumber) - { - return true; - } - - public void StoreSisDsaci(int value1, int value2, ushort currentDsaGroupId, int versionNumber, Stream dsaci) - { - throw new NotImplementedException(); - } - - public bool TestForObjectCarouselFileArrival(string vfsFile, int transportStreamId, int pid, int networkId) + private HashSet> _sisDsaci; + public bool TestForSisDsaci(int value1, int value2, ushort groupId, int versionNumber) { - throw new NotImplementedException(); + if (_sisDsaci == null) + return false; + else + { + return _sisDsaci.Contains(Tuple.Create(value1, value2, groupId, versionNumber)); + } } - public byte[] GetObjectCarouselFileArrival(string vfsFile, int transportStreamId, int pid, int networkId) + public void StoreSisDsaci(int value1, int value2, ushort currentDsaGroupId, int versionNumber, Stream dsaci) { - throw new NotImplementedException(); + if (_sisDsaci == null) + _sisDsaci = new HashSet>(); + _sisDsaci.Add(Tuple.Create(value1, value2, currentDsaGroupId, versionNumber)); } public byte[] DvbNipGetFile(string path) { - return new byte[0] { }; + throw new NotImplementedException(); } - public RfSpectrumData GetRfSpectrum(Guid selectedGuid) + public bool TestForWneStory(uint sessionId, string filename) { throw new NotImplementedException(); } - public bool TestForWneStory(uint sessionId, string filename) - { - return true; - } + public void StoreWneStory(uint sessionId, string filename, Stream value) + { + throw new NotImplementedException(); + } - public void StoreWneStory(uint sessionId, string filename, Stream value) - { - throw new NotImplementedException(); - } + public bool TestForAtsc3Segment(IPEndPoint destination, string outFileName) + { + throw new NotImplementedException(); + } - public bool TestForAtsc3Segment(IPEndPoint destination, string outFileName) - { - throw new NotImplementedException(); - } + public void StoreAtsc3Segment(IPEndPoint destination, string outFileName, Stream stream) + { + throw new NotImplementedException(); + } - public void StoreAtsc3Segment(IPEndPoint destination, string outFileName, Stream stream) - { - throw new NotImplementedException(); - } + public bool TestForThreemediaSegment(TarHeader tarHeader) + { + throw new NotImplementedException(); + } - public bool TestForThreemediaSegment(TarHeader tarHeader) - { - throw new NotImplementedException(); - } - - public void StoreThreemediaSegment(TarHeader tarHeader, MemoryStream memoryStream) - { - throw new NotImplementedException(); - } + public void StoreThreemediaSegment(TarHeader tarHeader, MemoryStream memoryStream) + { + throw new NotImplementedException(); + } } }