public packet_out ProcessPacket(byte[] packet, Parser <H, M> p, VerifyChecksum <H, M> vr, Ingress <H, M> ig, Egress <H, M> eg, ComputeChecksum <H, M> ck, Deparser <H> dep) { H hdr = default(H); M meta = default(M); standard_metadata_t smeta = new standard_metadata_t(); try { p.apply(new packet_in(packet), out hdr, meta, ref meta, smeta, ref smeta); } catch (P4Exception ex) { Console.Error.WriteLine("P4 exception. V1Model not sure how to give to remainder of pipeline."); Console.Error.WriteLine(ex.Error); } vr.apply(hdr, meta, ref meta); ig.apply(hdr, ref hdr, meta, ref meta, smeta, ref smeta); eg.apply(hdr, ref hdr, meta, ref meta, smeta, ref smeta); ck.apply(hdr, ref hdr, meta, ref meta); packet_out po = new packet_out(smeta); dep.apply(po, hdr); // TODO do something with the result return(po); }
public void Use(Parser <H, M> p, VerifyChecksum <H, M> vr, Ingress <H, M> ig, Egress <H, M> eg, ComputeChecksum <H, M> ck, Deparser <H> dep) { this.p = p; this.vr = vr; this.ig = ig; this.eg = eg; this.ck = ck; this.dep = dep; }
public void VerifyFileChecksum_Pass(string algoritm, string hash) { var task = new VerifyChecksum { File = Path.Combine(AppContext.BaseDirectory, "TestResources", "lorem.bin"), BuildEngine = new MockEngine(), Algorithm = algoritm, Hash = hash, }; Assert.True(task.Execute(), "Task should pass"); }
public void VerifyFileChecksum_Fails(string algoritm, string hash) { var task = new VerifyChecksum { File = Path.Combine(AppContext.BaseDirectory, "TestResources", "lorem.bin"), BuildEngine = new MockEngine { ContinueOnError = true }, Algorithm = algoritm, Hash = hash, }; Assert.False(task.Execute(), "Task should fail"); }