FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
l3_binding_cmds.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Cisco and/or its affiliates.
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 #ifndef __VOM_L3_BINDING_CMDS_H__
17 #define __VOM_L3_BINDING_CMDS_H__
18 
19 #include "vom/dump_cmd.hpp"
20 #include "vom/l3_binding.hpp"
21 #include "vom/rpc_cmd.hpp"
22 
23 #include <vapi/interface.api.vapi.hpp>
24 #include <vapi/ip.api.vapi.hpp>
25 
26 namespace VOM {
27 namespace l3_binding_cmds {
28 
29 /**
30  * A functor class that binds the L3 config to the interface
31  */
32 class bind_cmd
33  : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_add_del_address>
34 {
35 public:
36  /**
37  * Constructor
38  */
40  const handle_t& itf,
41  const route::prefix_t& pfx);
42 
43  /**
44  * Issue the command to VPP/HW
45  */
47  /**
48  * convert to string format for debug purposes
49  */
50  std::string to_string() const;
51 
52  /**
53  * Comparison operator - only used for UT
54  */
55  bool operator==(const bind_cmd& i) const;
56 
57 private:
58  /**
59  * Reference to the interface to bind to
60  */
61  const handle_t& m_itf;
62 
63  /**
64  * The prefix to bind
65  */
66  const route::prefix_t& m_pfx;
67 };
68 
69 /**
70  * A cmd class that Unbinds L3 Config from an interface
71  */
73  : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_add_del_address>
74 {
75 public:
76  /**
77  * Constructor
78  */
80  const handle_t& itf,
81  const route::prefix_t& pfx);
82 
83  /**
84  * Issue the command to VPP/HW
85  */
87  /**
88  * convert to string format for debug purposes
89  */
90  std::string to_string() const;
91 
92  /**
93  * Comparison operator - only used for UT
94  */
95  bool operator==(const unbind_cmd& i) const;
96 
97 private:
98  /**
99  * Reference to the interface to unbind fomr
100  */
101  const handle_t& m_itf;
102 
103  /**
104  * The prefix to unbind
105  */
106  const route::prefix_t& m_pfx;
107 };
108 
109 /**
110  * A cmd class that Dumps all the IPv4 L3 configs
111  */
112 class dump_v4_cmd : public dump_cmd<vapi::Ip_address_dump>
113 {
114 public:
115  /**
116  * Constructor
117  */
118  dump_v4_cmd(const handle_t& itf);
119  dump_v4_cmd(const dump_v4_cmd& d);
120 
121  /**
122  * Issue the command to VPP/HW
123  */
125  /**
126  * convert to string format for debug purposes
127  */
128  std::string to_string() const;
129 
130  /**
131  * Comparison operator - only used for UT
132  */
133  bool operator==(const dump_v4_cmd& i) const;
134 
135 private:
136  /**
137  * HW reutrn code
138  */
139  HW::item<bool> item;
140 
141  /**
142  * The interface to get the addresses for
143  */
144  const handle_t& m_itf;
145 };
146 
147 }; // namespace l3_binding_cmds
148 }; // namespace VOM
149 
150 /*
151  * fd.io coding-style-patch-verification: OFF
152  *
153  * Local Variables:
154  * eval: (c-set-style "mozilla")
155  * End:
156  */
157 
158 #endif
VOM::route::prefix_t
A prefix defintion.
Definition: prefix.hpp:131
VOM::HW::item< bool >
VOM::l3_binding_cmds::bind_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: l3_binding_cmds.cpp:38
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::l3_binding_cmds::dump_v4_cmd::operator==
bool operator==(const dump_v4_cmd &i) const
Comparison operator - only used for UT.
Definition: l3_binding_cmds.cpp:124
VOM::l3_binding_cmds::unbind_cmd::unbind_cmd
unbind_cmd(HW::item< bool > &item, const handle_t &itf, const route::prefix_t &pfx)
Constructor.
Definition: l3_binding_cmds.cpp:66
VOM::rpc_cmd
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:40
con
Connection con
Definition: vapi_cpp_test.cpp:56
VOM::l3_binding_cmds::dump_v4_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: l3_binding_cmds.cpp:130
VOM::l3_binding_cmds::bind_cmd
A functor class that binds the L3 config to the interface.
Definition: l3_binding_cmds.hpp:32
VOM::l3_binding_cmds::dump_v4_cmd
A cmd class that Dumps all the IPv4 L3 configs.
Definition: l3_binding_cmds.hpp:112
VOM::l3_binding_cmds::unbind_cmd::operator==
bool operator==(const unbind_cmd &i) const
Comparison operator - only used for UT.
Definition: l3_binding_cmds.cpp:76
VOM::l3_binding_cmds::bind_cmd::operator==
bool operator==(const bind_cmd &i) const
Comparison operator - only used for UT.
Definition: l3_binding_cmds.cpp:32
VOM::connection
A representation of the connection to VPP.
Definition: connection.hpp:33
VOM::l3_binding_cmds::dump_v4_cmd::dump_v4_cmd
dump_v4_cmd(const handle_t &itf)
Constructor.
Definition: l3_binding_cmds.cpp:113
VOM::handle_t
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
dump_cmd.hpp
VOM::l3_binding_cmds::dump_v4_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: l3_binding_cmds.cpp:146
VOM::l3_binding_cmds::bind_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: l3_binding_cmds.cpp:57
VOM::l3_binding_cmds::unbind_cmd::issue
rc_t issue(connection &con)
Issue the command to VPP/HW.
Definition: l3_binding_cmds.cpp:82
VOM::rpc_cmd< HW::item< bool >, vapi::Sw_interface_add_del_address >::item
HW::item< bool > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:66
VOM::l3_binding_cmds::unbind_cmd::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: l3_binding_cmds.cpp:104
i
int i
Definition: flowhash_template.h:376
l3_binding.hpp
VOM::rc_t
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
VOM::l3_binding_cmds::bind_cmd::bind_cmd
bind_cmd(HW::item< bool > &item, const handle_t &itf, const route::prefix_t &pfx)
Constructor.
Definition: l3_binding_cmds.cpp:22
VOM::dump_cmd
A base class for VPP dump commands.
Definition: dump_cmd.hpp:43
VOM::l3_binding_cmds::unbind_cmd
A cmd class that Unbinds L3 Config from an interface.
Definition: l3_binding_cmds.hpp:72
rpc_cmd.hpp
string
const char *const string
Definition: cJSON.h:172