Added tor.p4 to p4src
Change-Id: I8c3a02dee76cbe45e0f9a4f7ca1f93a6f1d8a016
diff --git a/tools/test/p4src/tor/class_id.p4 b/tools/test/p4src/tor/class_id.p4
new file mode 100644
index 0000000..326dce7
--- /dev/null
+++ b/tools/test/p4src/tor/class_id.p4
@@ -0,0 +1,54 @@
+// Copyright (c) 2017, Google Inc.
+//
+// P4_16 specification for a Class ID assignment table.
+// Note: This code has not been tested and is expected to contain bugs.
+
+#ifndef P4_SPEC_CLASS_ID_P4_
+#define P4_SPEC_CLASS_ID_P4_
+
+#include "headers.p4"
+#include "parser.p4"
+
+//------------------------------------------------------------------------------
+// Packet Classification
+//------------------------------------------------------------------------------
+
+control class_id(inout parsed_packet_t hdr,
+ inout local_metadata_t local_metadata,
+ inout standard_metadata_t standard_metadata) {
+
+ @proto_package("class_id")
+ action set_class_id(@proto_tag(1) bit<8> class_id_value) {
+ local_metadata.class_id = class_id_value;
+ }
+
+ @proto_package("class_id")
+ table class_id_assignment_table {
+ key = {
+ hdr.ethernet.ether_type: exact @proto_tag(1);
+
+ hdr.ipv4_base.ttl: ternary @proto_tag(2);
+ hdr.ipv6_base.hop_limit: ternary @proto_tag(3);
+ hdr.ipv4_base.dst_addr: ternary @proto_tag(4);
+ hdr.ipv6_base.dst_addr: ternary @proto_tag(5);
+ hdr.ipv4_base.protocol: ternary @proto_tag(6);
+ hdr.ipv6_base.next_header: ternary @proto_tag(7);
+
+ local_metadata.l4_src_port: ternary @proto_tag(8);
+ local_metadata.l4_dst_port: ternary @proto_tag(9);
+
+ hdr.vlan_tag[0].vid: ternary @proto_tag(10);
+ hdr.vlan_tag[0].pcp: ternary @proto_tag(11);
+ }
+ actions = {
+ @proto_tag(1) set_class_id;
+ }
+ const default_action = set_class_id(0);
+ }
+ apply {
+ class_id_assignment_table.apply();
+ }
+
+} // end class_id
+
+#endif // P4_SPEC_CLASS_ID_P4_