blob: 1c65782e980e2d897a8bd93b78a7c2f1d7a73252 [file] [log] [blame]
Neale Ranns812ed392017-10-16 04:20:13 -07001/*
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
21namespace VOM {
22/**
23 * A Sub-interface. e.g. a VLAN sub-interface on an Ethernet interface
24 */
25class sub_interface : public interface
26{
27 /*
28 * Typedef for VLAN ID
29 */
30 typedef uint16_t vlan_id_t;
31
32public:
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 * Destructor
39 */
40 ~sub_interface();
41 /**
42 * Copy Constructor
43 */
44 sub_interface(const sub_interface& o);
45
46 /**
Neale Rannsfd920602017-11-23 12:15:00 -080047 * comparison operator - for UT
48 */
49 bool operator==(const sub_interface& s) const;
50
51 /**
Neale Ranns812ed392017-10-16 04:20:13 -070052 * Return the matching 'singular instance' of the sub-interface
53 */
54 std::shared_ptr<sub_interface> singular() const;
55
Neale Rannsfd920602017-11-23 12:15:00 -080056 /**
57 * Find a subinterface from its key
58 */
59 static std::shared_ptr<sub_interface> find(const key_t& k);
60
Neale Ranns812ed392017-10-16 04:20:13 -070061private:
62 /**
63 * Construct with handle
64 */
65 sub_interface(const handle_t& handle,
66 const interface& parent,
67 admin_state_t state,
68 vlan_id_t vlan);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070069 friend class interface_factory;
70
Neale Ranns812ed392017-10-16 04:20:13 -070071 /**
72 * The interface class can construct interfaces with handles
73 */
74 friend class interface;
75
76 /**
77 * Return the matching 'instance' of the sub-interface
78 * over-ride from the base class
79 */
80 std::shared_ptr<interface> singular_i() const;
81
82 /**
83 * Virtual functions to construct an interface create commands.
84 */
85 virtual std::queue<cmd*>& mk_create_cmd(std::queue<cmd*>& cmds);
86
87 /**
88 * Virtual functions to construct an interface delete commands.
89 */
90 virtual std::queue<cmd*>& mk_delete_cmd(std::queue<cmd*>& cmds);
91
92 /**
93 * From the name of the parent and the vlan,
94 * construct the sub-interface's name
95 */
96 static std::string mk_name(const interface& parent, vlan_id_t vlan);
97
98 /**
99 * Refernece conter lock on the parent
100 */
101 const std::shared_ptr<interface> m_parent;
102
103 /**
104 * VLAN ID
105 */
106 vlan_id_t m_vlan;
107};
108};
109
110/*
111 * fd.io coding-style-patch-verification: ON
112 *
113 * Local Variables:
114 * eval: (c-set-style "mozilla")
115 * End:
116 */
117
118#endif