diff --git a/Dockerfile b/Dockerfile index 6da5ee2..8619b03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,19 @@ +# Copyright 2020 The P4-Constraints Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + FROM ubuntu:16.04 ARG DEBIAN_FRONTEND=noninteractive diff --git a/e2e_tests/action_restrictions_invalid.p4 b/e2e_tests/action_restrictions_invalid.p4 index 3ae7e4c..b41d5d8 100644 --- a/e2e_tests/action_restrictions_invalid.p4 +++ b/e2e_tests/action_restrictions_invalid.p4 @@ -1,3 +1,19 @@ +// Copyright 2023 The P4-Constraints Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + #include type bit<16> custom_type_t; diff --git a/e2e_tests/action_restrictions_valid.p4 b/e2e_tests/action_restrictions_valid.p4 index 33b5c21..494673c 100644 --- a/e2e_tests/action_restrictions_valid.p4 +++ b/e2e_tests/action_restrictions_valid.p4 @@ -1,3 +1,19 @@ +// Copyright 2023 The P4-Constraints Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + #include struct headers {}; diff --git a/e2e_tests/common.p4 b/e2e_tests/common.p4 index 3aa8571..251a9f0 100644 --- a/e2e_tests/common.p4 +++ b/e2e_tests/common.p4 @@ -1,3 +1,19 @@ +// Copyright 2021 The P4-Constraints Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + #include #define IPv4_ETHER_TYPE 0x0800 diff --git a/e2e_tests/invalid_constraints.expected.output b/e2e_tests/invalid_constraints.expected.output index d04ef59..f95f6ea 100644 --- a/e2e_tests/invalid_constraints.expected.output +++ b/e2e_tests/invalid_constraints.expected.output @@ -8,12 +8,12 @@ Syntax error: @entry_restriction must be enclosed in '("' and '")' - In @entry_restriction of table 'invalid_constraints.empty_restriction'; at offset line 1, column 1: Parse error: unexpected token: . Expected true, false, , , , , , ::, !, -, or (. -- e2e_tests/invalid_constraints.p4:21:3: +- e2e_tests/invalid_constraints.p4:37:3: Parse error: unexpected token: . Expected true, false, , , , , , ::, !, -, or (. -- e2e_tests/invalid_constraints.p4:27:5-15: +- e2e_tests/invalid_constraints.p4:43:5-15: | -27 | foo.bar.baz == 2 +43 | foo.bar.baz == 2 | ^^^^^^^^^^^ Type error: unknown key foo.bar.baz @@ -22,9 +22,9 @@ Type error: unknown key foo.bar.baz | ^^^^^^^^^^^ Type error: unknown key foo.bar.baz -- e2e_tests/invalid_constraints.p4:38:21-22: +- e2e_tests/invalid_constraints.p4:54:21-22: | -38 | foo.bar.baz == 0b2 +54 | foo.bar.baz == 0b2 | ^^ Parse error: unexpected token: . Expected , ), ::, &&, ;, ||, ->, ==, !=, >, >=, <, or <=. @@ -33,56 +33,56 @@ Parse error: unexpected token: . Expected , ), ::, &&, ;, ||, | ^^ Parse error: unexpected token: . Expected , ), ::, &&, ;, ||, ->, ==, !=, >, >=, <, or <=. -- e2e_tests/invalid_constraints.p4:52:11-14: +- e2e_tests/invalid_constraints.p4:68:11-14: | /**************************************************************************/ -52 | error here +68 | error here | ^^^^ Parse error: unexpected token: . Expected , ), ::, &&, ;, ||, ->, ==, !=, >, >=, <, or <=. -- e2e_tests/invalid_constraints.p4:60:5-30: +- e2e_tests/invalid_constraints.p4:76:5-30: | -60 | ternary_key::prefix_length +76 | ternary_key::prefix_length | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Type error: expression of type ternary<32> has no field 'prefix_length' -- e2e_tests/invalid_constraints.p4:70:5-19: +- e2e_tests/invalid_constraints.p4:86:5-19: | -70 | 0x0F0F :: value +86 | 0x0F0F :: value | ^^^^^^^^^^^^^^^ Type error: expression of type int has no field 'value' -- e2e_tests/invalid_constraints.p4:77:42-46: +- e2e_tests/invalid_constraints.p4:93:42-46: | -77 | -0x0F0F == -0o01234567 -> !false && -false +93 | -0x0F0F == -0o01234567 -> !false && -false | ^^^^^ Type error: expected type int, got bool -- e2e_tests/invalid_constraints.p4:84:33: - | -84 | !false -> -8 == -0b1000 || !1 - | ^ +- e2e_tests/invalid_constraints.p4:100:33: + | +100 | !false -> -8 == -0b1000 || !1 + | ^ Type error: expected type bool, got int -- e2e_tests/invalid_constraints.p4:92:5-21: - | -92 | optional_key > 10; - | ^^^^^^^^^^^^^^^^^ +- e2e_tests/invalid_constraints.p4:108:5-21: + | +108 | optional_key > 10; + | ^^^^^^^^^^^^^^^^^ Type error: operand type optional<32> does not support ordered comparison -- e2e_tests/invalid_constraints.p4:102:5-13: +- e2e_tests/invalid_constraints.p4:118:5-13: | -102 | ::unknown > 10; +118 | ::unknown > 10; | ^^^^^^^^^ Type error: unknown attribute 'unknown' -- e2e_tests/invalid_constraints.p4:113:1-9: +- e2e_tests/invalid_constraints.p4:129:1-9: | headers.ethernet.ether_type == 0x86DD; -113 | ::unknown > 10; +129 | ::unknown > 10; | ^^^^^^^^^ Type error: unknown attribute 'unknown' -- e2e_tests/invalid_constraints.p4:157:5-13: +- e2e_tests/invalid_constraints.p4:173:5-13: | // An invalid constraint to ensure error messages are sensible. -157 | ::unknown > 10; +173 | ::unknown > 10; | ^^^^^^^^^ Type error: unknown attribute 'unknown' diff --git a/e2e_tests/invalid_constraints.p4 b/e2e_tests/invalid_constraints.p4 index f6d1085..f0395f1 100644 --- a/e2e_tests/invalid_constraints.p4 +++ b/e2e_tests/invalid_constraints.p4 @@ -1,3 +1,19 @@ +// Copyright 2021 The P4-Constraints Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + #include "common.p4" control invalid_constraints(inout headers_t headers, diff --git a/e2e_tests/valid_constraints.expected.output b/e2e_tests/valid_constraints.expected.output index f812464..57f1fdc 100644 --- a/e2e_tests/valid_constraints.expected.output +++ b/e2e_tests/valid_constraints.expected.output @@ -10,9 +10,9 @@ e2e_tests/table_entries/acl_table_1.pb.txt === Output === All entries must satisfy: -e2e_tests/valid_constraints.p4:22:5-65: +e2e_tests/valid_constraints.p4:38:5-65: | // Either wildcard or exact match (i.e., 'optional' match). -22 | hdr.ipv4.dst_addr::mask == 0 || hdr.ipv4.dst_addr::mask == -1; +38 | hdr.ipv4.dst_addr::mask == 0 || hdr.ipv4.dst_addr::mask == -1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ But your entry does not. @@ -84,9 +84,9 @@ e2e_tests/table_entries/optional_match_table_invalid_1.pb.txt === Output === All entries must satisfy: -e2e_tests/valid_constraints.p4:100:5-32: +e2e_tests/valid_constraints.p4:116:5-32: | // A real constraint: only wildcard match is okay. -100 | hdr.ipv4.dst_addr::mask == 0; +116 | hdr.ipv4.dst_addr::mask == 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ But your entry does not. @@ -107,9 +107,9 @@ e2e_tests/table_entries/optional_match_table_valid_max_priority.pb.txt === Output === All entries must satisfy: -e2e_tests/valid_constraints.p4:102:5-27: +e2e_tests/valid_constraints.p4:118:5-27: | // A constraint on metadata. -102 | ::priority < 0x7fffffff; +118 | ::priority < 0x7fffffff; | ^^^^^^^^^^^^^^^^^^^^^^^ But your entry does not. @@ -123,8 +123,8 @@ e2e_tests/table_entries/reject_all_entries_1.pb.txt === Output === All entries must satisfy: -e2e_tests/valid_constraints.p4:14:1-5: -14 | false +e2e_tests/valid_constraints.p4:30:1-5: +30 | false | ^^^^^ But your entry does not. diff --git a/e2e_tests/valid_constraints.p4 b/e2e_tests/valid_constraints.p4 index 014d7fd..5310729 100644 --- a/e2e_tests/valid_constraints.p4 +++ b/e2e_tests/valid_constraints.p4 @@ -1,3 +1,19 @@ +// Copyright 2021 The P4-Constraints Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + #include "common.p4" control valid_constraints(inout headers_t hdr, diff --git a/format.sh b/format.sh index 09b2698..999f5f0 100755 --- a/format.sh +++ b/format.sh @@ -1,4 +1,20 @@ #!/bin/bash +# Copyright 2020 The P4-Constraints Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + # # Formats source files according to Google's style guide. Requires clang-format. # diff --git a/gutils/proto.cc b/gutils/proto.cc index 0362124..0f4b788 100644 --- a/gutils/proto.cc +++ b/gutils/proto.cc @@ -1,3 +1,19 @@ +// Copyright 2022 The P4-Constraints Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + #include "gutils/proto.h" #include diff --git a/gutils/proto.h b/gutils/proto.h index bf5f9b0..6ba9eaf 100644 --- a/gutils/proto.h +++ b/gutils/proto.h @@ -1,3 +1,21 @@ +/* + * Copyright 2022 The P4-Constraints Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + #ifndef THIRD_PARTY_P4LANG_P4_CONSTRAINTS_GUTILS_PROTO_H_ #define THIRD_PARTY_P4LANG_P4_CONSTRAINTS_GUTILS_PROTO_H_ diff --git a/gutils/status.cc b/gutils/status.cc index 4708854..22273af 100644 --- a/gutils/status.cc +++ b/gutils/status.cc @@ -1,3 +1,19 @@ +// Copyright 2022 The P4-Constraints Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + #include "gutils/status.h" #include diff --git a/gutils/status.h b/gutils/status.h index 6a3b36e..0a5ee9c 100644 --- a/gutils/status.h +++ b/gutils/status.h @@ -1,3 +1,21 @@ +/* + * Copyright 2022 The P4-Constraints Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + #ifndef THIRD_PARTY_P4LANG_P4_CONSTRAINTS_GUTILS_STATUS_H_ #define THIRD_PARTY_P4LANG_P4_CONSTRAINTS_GUTILS_STATUS_H_ diff --git a/gutils/testing_test.cc b/gutils/testing_test.cc index ad244d9..5de91c5 100644 --- a/gutils/testing_test.cc +++ b/gutils/testing_test.cc @@ -1,3 +1,18 @@ +// Copyright 2023 The P4-Constraints Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 #include "gutils/testing.h" diff --git a/p4_constraints/backend/constraint_info_test.cc b/p4_constraints/backend/constraint_info_test.cc index 7ad8be4..445f7a8 100644 --- a/p4_constraints/backend/constraint_info_test.cc +++ b/p4_constraints/backend/constraint_info_test.cc @@ -1,3 +1,19 @@ +// Copyright 2023 The P4-Constraints Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + #include "p4_constraints/backend/constraint_info.h" #include diff --git a/p4_constraints/backend/errors.cc b/p4_constraints/backend/errors.cc index c021646..46e9915 100644 --- a/p4_constraints/backend/errors.cc +++ b/p4_constraints/backend/errors.cc @@ -1,3 +1,19 @@ +// Copyright 2023 The P4-Constraints Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + #include "p4_constraints/backend/errors.h" #include diff --git a/p4_constraints/backend/errors.h b/p4_constraints/backend/errors.h index 4fcaae3..7da416b 100644 --- a/p4_constraints/backend/errors.h +++ b/p4_constraints/backend/errors.h @@ -1,3 +1,21 @@ +/* + * Copyright 2023 The P4-Constraints Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + #ifndef THIRD_PARTY_P4LANG_P4_CONSTRAINTS_P4_CONSTRAINTS_BACKEND_ERRORS_H_ #define THIRD_PARTY_P4LANG_P4_CONSTRAINTS_P4_CONSTRAINTS_BACKEND_ERRORS_H_ diff --git a/p4_constraints/backend/symbolic_interpreter_test.cc b/p4_constraints/backend/symbolic_interpreter_test.cc index 80532bc..9714ebf 100644 --- a/p4_constraints/backend/symbolic_interpreter_test.cc +++ b/p4_constraints/backend/symbolic_interpreter_test.cc @@ -1,3 +1,19 @@ +// Copyright 2023 The P4-Constraints Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + #include "p4_constraints/backend/symbolic_interpreter.h" #include