FD.io VPP  v18.04-17-g3a0d853
Vector Packet Processing
sub_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_SUB_INTERFACE_H__
17 #define __VOM_SUB_INTERFACE_H__
18 
19 #include "vom/interface.hpp"
20 
21 namespace VOM {
22 /**
23  * A Sub-interface. e.g. a VLAN sub-interface on an Ethernet interface
24  */
25 class sub_interface : public interface
26 {
27  /*
28  * Typedef for VLAN ID
29  */
30  typedef uint16_t vlan_id_t;
31 
32 public:
33  /**
34  * Construct a new object matching the desried state
35  */
36  sub_interface(const interface& parent, admin_state_t state, vlan_id_t vlan);
37 
38  sub_interface(const interface& parent,
39  admin_state_t state,
40  const route_domain& rd,
41  vlan_id_t vlan);
42 
43  /**
44  * Destructor
45  */
47  /**
48  * Copy Constructor
49  */
50  sub_interface(const sub_interface& o);
51 
52  /**
53  * comparison operator - for UT
54  */
55  bool operator==(const sub_interface& s) const;
56 
57  /**
58  * Return the matching 'singular instance' of the sub-interface
59  */
60  std::shared_ptr<sub_interface> singular() const;
61 
62  /**
63  * Find a subinterface from its key
64  */
65  static std::shared_ptr<sub_interface> find(const key_t& k);
66 
67 private:
68  /**
69  * Return the matching 'instance' of the sub-interface
70  * over-ride from the base class
71  */
72  std::shared_ptr<interface> singular_i() const;
73 
74  /**
75  * Virtual functions to construct an interface create commands.
76  */
77  virtual std::queue<cmd*>& mk_create_cmd(std::queue<cmd*>& cmds);
78 
79  /**
80  * Virtual functions to construct an interface delete commands.
81  */
82  virtual std::queue<cmd*>& mk_delete_cmd(std::queue<cmd*>& cmds);
83 
84  /**
85  * From the name of the parent and the vlan,
86  * construct the sub-interface's name
87  */
88  static std::string mk_name(const interface& parent, vlan_id_t vlan);
89 
90  /**
91  * Refernece conter lock on the parent
92  */
93  const std::shared_ptr<interface> m_parent;
94 
95  /**
96  * VLAN ID
97  */
98  vlan_id_t m_vlan;
99 };
100 };
101 
102 /*
103  * fd.io coding-style-patch-verification: ON
104  *
105  * Local Variables:
106  * eval: (c-set-style "mozilla")
107  * End:
108  */
109 
110 #endif
~sub_interface()
Destructor.
A Sub-interface.
sub_interface(const interface &parent, admin_state_t state, vlan_id_t vlan)
Construct a new object matching the desried state.
static std::shared_ptr< sub_interface > find(const key_t &k)
Find a subinterface from its key.
A route-domain is a VRF.
The admin state of the interface.
Definition: interface.hpp:127
A representation of an interface in VPP.
Definition: interface.hpp:41
vhost_vring_state_t state
Definition: vhost-user.h:82
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
bool operator==(const sub_interface &s) const
comparison operator - for UT
std::string key_t
The key for interface&#39;s key.
Definition: interface.hpp:56
std::shared_ptr< sub_interface > singular() const
Return the matching &#39;singular instance&#39; of the sub-interface.