bmv2
Designing your own switch target with bmv2
deparser.h
Go to the documentation of this file.
1 /* Copyright 2013-present Barefoot Networks, Inc.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /*
17  * Antonin Bas (antonin@barefootnetworks.com)
18  *
19  */
20 
22 
23 #ifndef BM_BM_SIM_DEPARSER_H_
24 #define BM_BM_SIM_DEPARSER_H_
25 
26 #include <bm/bm_sim/actions.h>
27 #include <bm/bm_sim/packet.h>
28 #include <bm/bm_sim/phv.h>
29 
30 #include <string>
31 #include <memory>
32 #include <utility>
33 #include <vector>
34 
35 #include "named_p4object.h"
36 #include "phv_forward.h"
37 #include "stateful.h"
38 
39 namespace bm {
40 
41 class Packet;
42 
43 class Checksum;
44 
45 struct DeparserOp;
46 
50 class Deparser : public NamedP4Object {
51  public:
52  Deparser(const std::string &name, p4object_id_t id);
53 
54  void push_back_header(header_id_t header_id) {
55  headers.push_back(header_id);
56  }
57 
58  void add_checksum(const Checksum *checksum) {
59  checksums.push_back(checksum);
60  }
61 
62  ~Deparser();
63 
71  void deparse(Packet *pkt) const;
72 
73  void add_method_call(ActionFn *action_fn);
74 
75  private:
76  size_t get_headers_size(const PHV &phv) const;
77 
78  void update_checksums(Packet *pkt) const;
79 
80  private:
81  std::vector<header_id_t> headers{};
82  std::vector<const Checksum *> checksums{};
83  RegisterSync register_sync{};
84  std::vector<std::unique_ptr<DeparserOp> > deparser_ops;
85 };
86 
87 } // namespace bm
88 
89 #endif // BM_BM_SIM_DEPARSER_H_
bm::NamedP4Object
Definition: named_p4object.h:39
bm::Deparser::deparse
void deparse(Packet *pkt) const
named_p4object.h
bm::Packet
Definition: packet.h:98
actions.h
stateful.h
packet.h
bm::Deparser
Definition: deparser.h:50
bm::PHV
Definition: phv.h:68
phv.h