FD.io VPP  v18.10-32-g1161dda
Vector Packet Processing
tap_interface.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_TAP_INTERFACE_H__
17 #define __VOM_TAP_INTERFACE_H__
18 
19 #include "vom/interface.hpp"
20 
21 namespace VOM {
22 /**
23  * A tap-interface. e.g. a tap interface
24  */
25 class tap_interface : public interface
26 {
27 public:
28  tap_interface(const std::string& name,
29  type_t type,
32 
33  tap_interface(const std::string& name,
34  type_t type,
35  admin_state_t state,
36  route::prefix_t prefix,
37  const l2_address_t& l2_address);
38 
40  tap_interface(const tap_interface& o);
41 
42  /**
43  * Return the matching 'singular instance' of the TAP interface
44  */
45  std::shared_ptr<tap_interface> singular() const;
46 
47 private:
48  /**
49  * Class definition for listeners to OM events
50  */
52  {
53  public:
54  event_handler();
55  virtual ~event_handler() = default;
56 
57  /**
58  * Handle a populate event
59  */
60  void handle_populate(const client_db::key_t& key);
61 
62  /**
63  * Handle a replay event
64  */
65  void handle_replay();
66 
67  /**
68  * Show the object in the Singular DB
69  */
70  void show(std::ostream& os);
71 
72  /**
73  * Get the sortable Id of the listener
74  */
75  dependency_t order() const;
76  };
77  static event_handler m_evh;
78 
79  /**
80  * host Ip Prefix
81  */
82  route::prefix_t m_prefix;
83 
84  /**
85  * host mac address
86  */
87  l2_address_t m_l2_address;
88 
89  /**
90  * interface is a friend so it can construct with handles
91  */
92  friend class interface;
93 
94  /**
95  * Return the matching 'instance' of the sub-interface
96  * over-ride from the base class
97  */
98  std::shared_ptr<interface> singular_i() const;
99 
100  /**
101  * Virtual functions to construct an interface create commands.
102  */
103  virtual std::queue<cmd*>& mk_create_cmd(std::queue<cmd*>& cmds);
104 
105  /**
106  * Virtual functions to construct an interface delete commands.
107  */
108  virtual std::queue<cmd*>& mk_delete_cmd(std::queue<cmd*>& cmds);
109 
110  /*
111  * It's the OM class that call singular()
112  */
113  friend class OM;
114 };
115 }
116 
117 /*
118  * fd.io coding-style-patch-verification: ON
119  *
120  * Local Variables:
121  * eval: (c-set-style "mozilla")
122  * End:
123  */
124 
125 #endif
tap_interface(const std::string &name, type_t type, admin_state_t state, route::prefix_t prefix)
Construct a new object matching the desried state.
A tap-interface.
const std::string key_t
In the opflex world each entity is known by a URI which can be converted into a string.
Definition: client_db.hpp:51
Type def of a L2 address as read from VPP.
Definition: types.hpp:334
vhost_vring_state_t state
Definition: vhost_user.h:120
const l2_address_t & l2_address() const
Return the L2 Address.
Definition: interface.cpp:145
The admin state of the interface.
Definition: interface.hpp:142
A representation of an interface in VPP.
Definition: interface.hpp:41
Class definition for listeners to OM events.
Definition: om.hpp:284
inspect command handler Handler
Definition: inspect.hpp:54
void event_handler(void *tls_async)
Definition: tls_async.c:339
std::shared_ptr< tap_interface > singular() const
Return the matching &#39;singular instance&#39; of the TAP interface.
dependency_t
There needs to be a strict order in which object types are read from VPP (at boot time) and replayed ...
Definition: types.hpp:43
const std::string & name() const
Return the interface type.
Definition: interface.cpp:265
The interface to writing objects into VPP OM.
Definition: om.hpp:140
An interface type.
Definition: interface.hpp:67
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
typedef prefix
Definition: ip_types.api:40
const type_t & type() const
Return the interface type.
Definition: interface.cpp:127
A prefix defintion.
Definition: prefix.hpp:92
const key_t & key() const
Return the interface type.
Definition: interface.cpp:271