{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE TemplateHaskell #-} module Traffic where ( ) data Endpoints = EUplink | EClient1 | EClient2 connections = compileConnections [ Mes.GE 1 0 1 <-> PC.Uplink , Mes.GE 1 0 21 <-> Ltp.FrontPort 1 , Mes.GE 1 0 22 <-> Ltp.FrontPort 3 , Mes.GE 1 0 23 <-> Ltp.FrontPort 5 , Mes.GE 1 0 7 <-> Ont.Port 3 1 1 , Mes.GE 1 0 8 <-> Ont.Port 3 6 1 ] endpoints = compileEndpoints [ EUplink <-> Ltp.FrontPort 1 , EClient1 <-> Ont.Port 3 1 1 , EClient2 <-> Ont.Port 3 6 1 ] testBroadcast = testCase "Broadcast" $ do let ltpConfig = DeviceConfig.Ltp.makeDefault { profilesCrossConnect = [ cc ] , profilesPorts = [ ports ] , interfaceOnt = [ ontConfig 3 1 { services = [ Ltp.Config.makeService "test1" ], profilePorts = "ports1" } , ontConfig 3 6 { services = [ Ltp.Config.makeService "test1" ], profilePorts = "ports1" } ] } let baseMesConfig = Mes.Config.makeDefault { interfaces = [ Mes.makeInterfaceConfig (Mes.GE 1 0 12) { switchPortMode = Access , allowedVlan = [ VlanId 3465 ] } ] } let (standMesConfig, standLtpConfig) = generateConfig connections ltpConfig endpoints let mesConfig = baseMesConfig <> standMesConfig mesConfigurator <- makeMesConfigurator { line = "/dev/ttyUSB1" } ltpConfigurator <- makeLtpConfigurator { line = "/dev/ttyUSB0" } uploadConfig mesConfigurator mesConfig uploadConfig ltpConfigurator standLtpConfig sendPacket (broadcastPing `addTag` VlanId 200) EUplink awaitPacket (broadcastPing `addTag` VlanId 1000) EClient1 awaitPacket (broadcastPing `addTag` VlanId 1000) EClient2 where cc = Ltp.Config.makeCrossConnect "test1" { replaceSide = ReplaceSideOnt , trafficModel = OneToOne , bridgeGroup = 10 , outerVid = 200 , userVid = Just 1000 } ports = Ltp.Config.makePorfilePorts "test1" { name = "ports1" , bridgeGroup = 10 }