-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[P4_Symbolic] Adding p4_symbolic/symbolic/parser.h [Evaluate parsers …
…symbolically.]
- Loading branch information
1 parent
aa4d303
commit f9e0b66
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// 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. | ||
|
||
#ifndef PINS_P4_SYMBOLIC_SYMBOLIC_PARSER_H_ | ||
#define PINS_P4_SYMBOLIC_SYMBOLIC_PARSER_H_ | ||
|
||
#include "p4_symbolic/ir/ir.pb.h" | ||
#include "p4_symbolic/symbolic/symbolic.h" | ||
#include "z3++.h" | ||
|
||
namespace p4_symbolic { | ||
namespace symbolic { | ||
namespace parser { | ||
|
||
// Returns a Z3 bit-vector representing the `parser_error` field value of the | ||
// given `error_name`. | ||
absl::StatusOr<z3::expr> GetErrorCodeExpression(const ir::P4Program &program, | ||
const std::string &error_name); | ||
|
||
// Evaluates all parsers in the P4 program and returns a map of symbolic headers | ||
// that captures the effect of parser execution given the `ingress_headers`. | ||
// | ||
// Returns error if a header field is not a free bit-vector variable upon | ||
// extracting its header, which could mean the header is extracted twice. We | ||
// require extracting to the same header happens at most once to avoid loops. | ||
// | ||
// If a parser error occurs, the `standard_metadata.parser_error` field will be | ||
// set to the corresponding error code and the function returns immediately. The | ||
// current implementation may only result in 2 types of parser error, NoError | ||
// and NoMatch. | ||
absl::StatusOr<SymbolicPerPacketState> EvaluateParsers( | ||
const ir::P4Program &program, | ||
const SymbolicPerPacketState &ingress_headers); | ||
|
||
} // namespace parser | ||
} // namespace symbolic | ||
} // namespace p4_symbolic | ||
|
||
#endif // PINS_P4_SYMBOLIC_SYMBOLIC_PARSER_H_ |