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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef __VOM_IP_UNNUMBERED_H__
17 #define __VOM_IP_UNNUMBERED_H__
20 #include "vom/inspect.hpp"
21 #include "vom/interface.hpp"
22 #include "vom/object_base.hpp"
24 #include "vom/singular_db.hpp"
28 * A representation of IP unnumbered configuration on an interface
30 class ip_unnumbered : public object_base
34 * Construct a new object matching the desried state
36 * @param itf - The interface with no IP address
37 * @param l3_itf - The interface that has the IP address we wish to
40 ip_unnumbered(const interface& itf, const interface& l3_itf);
45 ip_unnumbered(const ip_unnumbered& o);
53 * Return the 'singular instance' of the L3-Config that matches this
56 std::shared_ptr<ip_unnumbered> singular() const;
59 * convert to string format for debug purposes
61 std::string to_string() const;
64 * Dump all ip_unnumbereds into the stream provided
66 static void dump(std::ostream& os);
69 * The key type for ip_unnumbereds
71 typedef interface::key_t key_t;
74 * Find an singular instance in the DB for the interface passed
76 static std::shared_ptr<ip_unnumbered> find(const interface& i);
80 * Class definition for listeners to OM events
82 class event_handler : public OM::listener, public inspect::command_handler
86 virtual ~event_handler() = default;
89 * Handle a populate event
91 void handle_populate(const client_db::key_t& key);
94 * Handle a replay event
99 * Show the object in the Singular DB
101 void show(std::ostream& os);
104 * Get the sortable Id of the listener
106 dependency_t order() const;
110 * event_handler to register with OM
112 static event_handler m_evh;
115 * Enquue commonds to the VPP command Q for the update
117 void update(const ip_unnumbered& obj);
120 * Find or add the singular instance in the DB
122 static std::shared_ptr<ip_unnumbered> find_or_add(const ip_unnumbered& temp);
125 * It's the VPPHW class that updates the objects in HW
130 * It's the singular_db class that calls replay
132 friend class singular_db<key_t, ip_unnumbered>;
135 * Sweep/reap the object if still stale
140 * replay the object to create it in hardware
145 * A reference counting pointer the interface that requires an address.
147 const std::shared_ptr<interface> m_itf;
149 * A reference counting pointer the interface that has an address.
151 const std::shared_ptr<interface> m_l3_itf;
154 * HW configuration for the binding. The bool representing the
157 HW::item<bool> m_config;
160 * A map of all L3 configs keyed against a combination of the interface
163 static singular_db<key_t, ip_unnumbered> m_db;
168 * fd.io coding-style-patch-verification: ON
171 * eval: (c-set-style "mozilla")