FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
ip_unnumbered.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_IP_UNNUMBERED_H__
17 #define __VOM_IP_UNNUMBERED_H__
18 
19 #include "vom/hw.hpp"
20 #include "vom/inspect.hpp"
21 #include "vom/interface.hpp"
22 #include "vom/object_base.hpp"
23 #include "vom/om.hpp"
24 #include "vom/singular_db.hpp"
25 
26 namespace VOM {
27 /**
28  * A representation of IP unnumbered configuration on an interface
29  */
30 class ip_unnumbered : public object_base
31 {
32 public:
33  /**
34  * Construct a new object matching the desried state
35  *
36  * @param itf - The interface with no IP address
37  * @param l3_itf - The interface that has the IP address we wish to
38  * share.
39  */
40  ip_unnumbered(const interface& itf, const interface& l3_itf);
41 
42  /**
43  * Copy Constructor
44  */
45  ip_unnumbered(const ip_unnumbered& o);
46 
47  /**
48  * Destructor
49  */
51 
52  /**
53  * Return the 'singular instance' of the L3-Config that matches this
54  * object
55  */
56  std::shared_ptr<ip_unnumbered> singular() const;
57 
58  /**
59  * convert to string format for debug purposes
60  */
61  std::string to_string() const;
62 
63  /**
64  * Dump all ip_unnumbereds into the stream provided
65  */
66  static void dump(std::ostream& os);
67 
68  /**
69  * The key type for ip_unnumbereds
70  */
72 
73  /**
74  * Find an singular instance in the DB for the interface passed
75  */
76  static std::shared_ptr<ip_unnumbered> find(const interface& i);
77 
78 private:
79  /**
80  * Class definition for listeners to OM events
81  */
83  {
84  public:
85  event_handler();
86  virtual ~event_handler() = default;
87 
88  /**
89  * Handle a populate event
90  */
91  void handle_populate(const client_db::key_t& key);
92 
93  /**
94  * Handle a replay event
95  */
96  void handle_replay();
97 
98  /**
99  * Show the object in the Singular DB
100  */
101  void show(std::ostream& os);
102 
103  /**
104  * Get the sortable Id of the listener
105  */
106  dependency_t order() const;
107  };
108 
109  /**
110  * event_handler to register with OM
111  */
112  static event_handler m_evh;
113 
114  /**
115  * Enquue commonds to the VPP command Q for the update
116  */
117  void update(const ip_unnumbered& obj);
118 
119  /**
120  * Find or add the singular instance in the DB
121  */
122  static std::shared_ptr<ip_unnumbered> find_or_add(const ip_unnumbered& temp);
123 
124  /*
125  * It's the VPPHW class that updates the objects in HW
126  */
127  friend class OM;
128 
129  /**
130  * It's the singular_db class that calls replay
131  */
132  friend class singular_db<key_t, ip_unnumbered>;
133 
134  /**
135  * Sweep/reap the object if still stale
136  */
137  void sweep(void);
138 
139  /**
140  * replay the object to create it in hardware
141  */
142  void replay(void);
143 
144  /**
145  * A reference counting pointer the interface that requires an address.
146  */
147  const std::shared_ptr<interface> m_itf;
148  /**
149  * A reference counting pointer the interface that has an address.
150  */
151  const std::shared_ptr<interface> m_l3_itf;
152 
153  /**
154  * HW configuration for the binding. The bool representing the
155  * do/don't bind.
156  */
157  HW::item<bool> m_config;
158 
159  /**
160  * A map of all L3 configs keyed against a combination of the interface
161  * and subnet's keys.
162  */
164 };
165 };
166 
167 /*
168  * fd.io coding-style-patch-verification: ON
169  *
170  * Local Variables:
171  * eval: (c-set-style "mozilla")
172  * End:
173  */
174 
175 #endif
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
int i
interface::key_t key_t
The key type for ip_unnumbereds.
std::shared_ptr< ip_unnumbered > singular() const
Return the &#39;singular instance&#39; of the L3-Config that matches this object.
~ip_unnumbered()
Destructor.
A representation of IP unnumbered configuration on an interface.
A Database to store the unique &#39;singular&#39; instances of a single object type.
Definition: singular_db.hpp:33
A representation of an interface in VPP.
Definition: interface.hpp:41
Class definition for listeners to OM events.
Definition: om.hpp:284
static void dump(std::ostream &os)
Dump all ip_unnumbereds into the stream provided.
inspect command handler Handler
Definition: inspect.hpp:54
void event_handler(void *tls_async)
Definition: tls_async.c:338
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
ip_unnumbered(const interface &itf, const interface &l3_itf)
Construct a new object matching the desried state.
The interface to writing objects into VPP OM.
Definition: om.hpp:140
A base class for all object_base in the VPP object_base-Model.
Definition: object_base.hpp:29
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
typedef key
Definition: ipsec.api:247
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
std::string to_string() const
convert to string format for debug purposes
std::string key_t
The key for interface&#39;s key.
Definition: interface.hpp:56
static std::shared_ptr< ip_unnumbered > find(const interface &i)
Find an singular instance in the DB for the interface passed.