private Acl ExampleAcl() { var p1 = new Prefix { Length = 24, Address = Ip.Parse("72.1.2.0").Value }; var p2 = new Prefix { Length = 24, Address = Ip.Parse("1.2.3.0").Value }; var p3 = new Prefix { Length = 32, Address = Ip.Parse("8.8.8.8").Value }; var p4 = new Prefix { Length = 32, Address = Ip.Parse("9.9.9.9").Value }; var aclLine1 = new AclLine { DstIp = p1, SrcIp = p2, Permitted = true }; var aclLine2 = new AclLine { DstIp = p3, SrcIp = p4, Permitted = false }; var lines = new AclLine[2] { aclLine1, aclLine2 }; return(new Acl { Lines = lines }); }
private Acl ExampleAcl2() { var random = new Random(7); var lines = new List <AclLine>(); for (int i = 0; i < 10; i++) { var dlow = (uint)random.Next(); var dhigh = (uint)random.Next((int)dlow, int.MaxValue); var slow = (uint)random.Next(); var shigh = (uint)random.Next((int)slow, int.MaxValue); var perm = random.Next() % 2 == 0; var line = new AclLine { DstIp = Prefix.Random(24, 32), SrcIp = Prefix.Random(24, 32), Permitted = perm, }; lines.Add(line); } return(new Acl { Lines = lines.ToArray() }); }
public void TestSymbolicExecutionAcl() { var random = new Random(1); var lines = new List <AclLine>(); bool parity = false; for (int i = 0; i < 19; i++) { parity = !parity; var dlow = (uint)random.Next(); var dhigh = (uint)random.Next((int)dlow, int.MaxValue); var slow = (uint)random.Next(); var shigh = (uint)random.Next((int)slow, int.MaxValue); var line = new AclLine { DstIp = Prefix.Random(24, 32), SrcIp = Prefix.Random(24, 32), Permitted = parity, }; Console.WriteLine($"{line.DstIp}, {line.SrcIp}, {line.Permitted}"); lines.Add(line); } var acl = new Acl { Lines = lines.ToArray() }; var function = Function <IpHeader, bool>(p => acl.Process(p, 0)); Assert.AreEqual(20, function.GenerateInputs().Count()); }
public void TestSymbolicExecutionPacketAcl() { var p1 = new Prefix { Length = 24, Address = Ip.Parse("72.1.2.0").Value }; var p2 = new Prefix { Length = 24, Address = Ip.Parse("1.2.3.0").Value }; var p3 = new Prefix { Length = 32, Address = Ip.Parse("8.8.8.8").Value }; var p4 = new Prefix { Length = 32, Address = Ip.Parse("9.9.9.9").Value }; var aclLine1 = new AclLine { DstIp = p1, SrcIp = p2, Permitted = true }; var aclLine2 = new AclLine { DstIp = p3, SrcIp = p4, Permitted = true }; var lines = new AclLine[2] { aclLine1, aclLine2 }; var acl = new Acl { Lines = lines }; var f = Function <IpHeader, bool>(h => acl.Process(h, 0)); Assert.AreEqual(3, f.GenerateInputs().Count()); }
public void CreateAcl() { var rnd = new Random(42); var lines = new List <AclLine>(); for (int i = 0; i < this.NumLines; i++) { var d = (uint)rnd.Next(); var s = (uint)rnd.Next(); var line = new AclLine { Permitted = (rnd.Next() & 1) == 0, DstIpLow = (d & 0xFFFFFF00), SrcIpLow = (s & 0xFFFFFF00), DstIpHigh = (d | 0x000000FF), SrcIpHigh = (s | 0x000000FF), }; lines.Add(line); } this.acl = new Acl { Name = "BenchAcl", Lines = lines.ToArray() }; }
public void CreateAcl() { var rnd = new Random(42); var lines = new List <AclLine>(); for (int i = 0; i < this.NumLines; i++) { var line = new AclLine { Permitted = (rnd.Next() & 1) == 0, DstIp = Prefix.Random(24, 32), SrcIp = Prefix.Random(24, 32), }; lines.Add(line); } // add default deny var defaultPrefix = new Prefix { Length = 0, Address = 0U }; lines.Add(new AclLine { DstIp = defaultPrefix, SrcIp = defaultPrefix }); this.acl = new Acl { Lines = lines.ToArray() }; }
private Acl ExampleAcl() { var aclLine1 = new AclLine { DstIpLow = 10, DstIpHigh = 20, SrcIpLow = 7, SrcIpHigh = 39, Permitted = true }; var aclLine2 = new AclLine { DstIpLow = 0, DstIpHigh = 100, SrcIpLow = 0, SrcIpHigh = 100, Permitted = false }; var lines = new AclLine[2] { aclLine1, aclLine2 }; return(new Acl { Lines = lines }); }