6b6a1d7dab08416c5ae0f4357be3d26f19f6dc72
[vpp.git] / test / ext / vom_test.cpp
1 /*
2  * Test suite for class VppOM
3  *
4  * Copyright (c) 2017 Cisco Systems, Inc. and others.  All rights reserved.
5  *
6  * This program and the accompanying materials are made available under the
7  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
8  * and is available at http://www.eclipse.org/legal/epl-v10.html
9  */
10 #define BOOST_TEST_MODULE "VPP OBJECT MODEL"
11 #define BOOST_TEST_DYN_LINK
12
13 #include <boost/test/unit_test.hpp>
14 #include <boost/assign/list_inserter.hpp>
15
16
17 #include <iostream>
18 #include <deque>
19
20 #include "vom/om.hpp"
21 #include "vom/interface.hpp"
22 #include "vom/interface_cmds.hpp"
23 #include "vom/bond_interface_cmds.hpp"
24 #include "vom/bond_group_binding.hpp"
25 #include "vom/bond_group_binding_cmds.hpp"
26 #include "vom/l2_binding.hpp"
27 #include "vom/l2_binding_cmds.hpp"
28 #include "vom/l2_vtr_cmds.hpp"
29 #include "vom/l2_xconnect.hpp"
30 #include "vom/l2_xconnect_cmds.hpp"
31 #include "vom/l3_binding.hpp"
32 #include "vom/l3_binding_cmds.hpp"
33 #include "vom/bridge_domain.hpp"
34 #include "vom/bridge_domain_entry.hpp"
35 #include "vom/bridge_domain_arp_entry.hpp"
36 #include "vom/bridge_domain_cmds.hpp"
37 #include "vom/bridge_domain_entry_cmds.hpp"
38 #include "vom/bridge_domain_arp_entry_cmds.hpp"
39 #include "vom/prefix.hpp"
40 #include "vom/route.hpp"
41 #include "vom/route_cmds.hpp"
42 #include "vom/mroute_cmds.hpp"
43 #include "vom/route_domain.hpp"
44 #include "vom/route_domain_cmds.hpp"
45 #include "vom/vxlan_tunnel.hpp"
46 #include "vom/vxlan_tunnel_cmds.hpp"
47 #include "vom/sub_interface.hpp"
48 #include "vom/sub_interface_cmds.hpp"
49 #include "vom/acl_ethertype.hpp"
50 #include "vom/acl_ethertype_cmds.hpp"
51 #include "vom/acl_l2_list.hpp"
52 #include "vom/acl_l3_list.hpp"
53 #include "vom/acl_binding.hpp"
54 #include "vom/acl_list_cmds.hpp"
55 #include "vom/acl_binding_cmds.hpp"
56 #include "vom/acl_l3_rule.hpp"
57 #include "vom/acl_l2_rule.hpp"
58 #include "vom/arp_proxy_config.hpp"
59 #include "vom/arp_proxy_binding.hpp"
60 #include "vom/arp_proxy_config_cmds.hpp"
61 #include "vom/arp_proxy_binding_cmds.hpp"
62 #include "vom/igmp_binding.hpp"
63 #include "vom/igmp_binding_cmds.hpp"
64 #include "vom/igmp_listen.hpp"
65 #include "vom/igmp_listen_cmds.hpp"
66 #include "vom/ip_punt_redirect.hpp"
67 #include "vom/ip_punt_redirect_cmds.hpp"
68 #include "vom/ip_unnumbered.hpp"
69 #include "vom/ip_unnumbered_cmds.hpp"
70 #include "vom/interface_ip6_nd.hpp"
71 #include "vom/interface_span.hpp"
72 #include "vom/interface_span_cmds.hpp"
73 #include "vom/neighbour.hpp"
74 #include "vom/neighbour_cmds.hpp"
75 #include "vom/nat_static.hpp"
76 #include "vom/nat_static_cmds.hpp"
77 #include "vom/nat_binding.hpp"
78 #include "vom/nat_binding_cmds.hpp"
79 #include "vom/pipe.hpp"
80 #include "vom/pipe_cmds.hpp"
81 #include "vom/qos_mark.hpp"
82 #include "vom/qos_mark_cmds.hpp"
83 #include "vom/qos_map.hpp"
84 #include "vom/qos_map_cmds.hpp"
85 #include "vom/qos_record.hpp"
86 #include "vom/qos_record_cmds.hpp"
87
88 using namespace boost;
89 using namespace VOM;
90
91 /**
92  * An expectation exception
93  */
94 class ExpException
95 {
96 public:
97     ExpException(unsigned int number)
98     {
99         // a neat place to add a break point
100         // std::cout << "  ExpException here: " << number << std::endl;
101     }
102 };
103
104 class MockListener : public interface::event_listener,
105                      public interface::stat_listener
106 {
107     void handle_interface_stat(const interface& itf)
108     {
109     }
110     void handle_interface_event(std::vector<VOM::interface::event> events)
111     {
112     }
113 };
114
115 class MockCmdQ : public HW::cmd_q
116 {
117 public:
118     MockCmdQ():
119         m_strict_order(true)
120     {
121     }
122     virtual ~MockCmdQ()
123     {
124     }
125     void expect(cmd *f)
126     {
127         m_exp_queue.push_back(f);
128     }
129     void enqueue(cmd *f)
130     {
131         m_act_queue.push_back(f);
132     }
133     void enqueue(std::queue<cmd*> &cmds)
134     {
135         while (cmds.size())
136         {
137             m_act_queue.push_back(cmds.front());
138             cmds.pop();
139         }
140     }
141     void enqueue(std::shared_ptr<cmd> f)
142     {
143         m_act_queue.push_back(f.get());
144     }
145
146     void dequeue(cmd *f)
147     {
148     }
149
150     void dequeue(std::shared_ptr<cmd> cmd)
151     {
152     }
153
154     void strict_order(bool on)
155     {
156         m_strict_order = on;
157     }
158
159     bool is_empty()
160     {
161         return ((0 == m_exp_queue.size()) &&
162                 (0 == m_act_queue.size()));
163     }
164
165     rc_t write()
166     {
167         cmd *f_exp, *f_act;
168         rc_t rc = rc_t::OK;
169
170         while (m_act_queue.size())
171         {
172             bool matched = false;
173             auto it_exp = m_exp_queue.begin();
174             auto it_act = m_act_queue.begin();
175
176             f_act = *it_act;
177
178             std::cout << " Act: " << f_act->to_string() << std::endl;
179             while (it_exp != m_exp_queue.end())
180             {
181                 f_exp = *it_exp;
182                 try
183                 {
184                     std::cout << "  Exp: " << f_exp->to_string() << std::endl;
185
186                     if (typeid(*f_exp) != typeid(*f_act))
187                     {
188                         throw ExpException(1);
189                     }
190
191                     if (typeid(*f_exp) == typeid(interface_cmds::af_packet_create_cmd))
192                     {
193                         rc = handle_derived<interface_cmds::af_packet_create_cmd>(f_exp, f_act);
194                     }
195                     else if (typeid(*f_exp) == typeid(interface_cmds::loopback_create_cmd))
196                     {
197                         rc = handle_derived<interface_cmds::loopback_create_cmd>(f_exp, f_act);
198                     }
199                     else if (typeid(*f_exp) == typeid(interface_cmds::bvi_create_cmd))
200                     {
201                         rc = handle_derived<interface_cmds::bvi_create_cmd>(f_exp, f_act);
202                     }
203                     else if (typeid(*f_exp) == typeid(interface_cmds::vhost_create_cmd))
204                     {
205                         rc = handle_derived<interface_cmds::vhost_create_cmd>(f_exp, f_act);
206                     }
207                     else if (typeid(*f_exp) == typeid(bond_interface_cmds::create_cmd))
208                     {
209                        rc = handle_derived<bond_interface_cmds::create_cmd>(f_exp, f_act);
210                     }
211                     else if (typeid(*f_exp) == typeid(interface_cmds::loopback_delete_cmd))
212                     {
213                         rc = handle_derived<interface_cmds::loopback_delete_cmd>(f_exp, f_act);
214                     }
215                     else if (typeid(*f_exp) == typeid(interface_cmds::bvi_delete_cmd))
216                     {
217                         rc = handle_derived<interface_cmds::bvi_delete_cmd>(f_exp, f_act);
218                     }
219                     else if (typeid(*f_exp) == typeid(interface_cmds::af_packet_delete_cmd))
220                     {
221                         rc = handle_derived<interface_cmds::af_packet_delete_cmd>(f_exp, f_act);
222                     }
223                     else if (typeid(*f_exp) == typeid(interface_cmds::vhost_delete_cmd))
224                     {
225                        rc = handle_derived<interface_cmds::vhost_delete_cmd>(f_exp, f_act);
226                     }
227                     else if (typeid(*f_exp) == typeid(bond_interface_cmds::delete_cmd))
228                     {
229                        rc = handle_derived<bond_interface_cmds::delete_cmd>(f_exp, f_act);
230                     }
231                     else if (typeid(*f_exp) == typeid(interface_cmds::state_change_cmd))
232                     {
233                         rc = handle_derived<interface_cmds::state_change_cmd>(f_exp, f_act);
234                     }
235                     else if (typeid(*f_exp) == typeid(interface_cmds::set_table_cmd))
236                     {
237                         rc = handle_derived<interface_cmds::set_table_cmd>(f_exp, f_act);
238                     }
239                     else if (typeid(*f_exp) == typeid(interface_cmds::set_mac_cmd))
240                     {
241                         rc = handle_derived<interface_cmds::set_mac_cmd>(f_exp, f_act);
242                     }
243                     else if (typeid(*f_exp) == typeid(interface_cmds::set_tag))
244                     {
245                         rc = handle_derived<interface_cmds::set_tag>(f_exp, f_act);
246                     }
247                     else if (typeid(*f_exp) == typeid(bond_group_binding_cmds::bind_cmd))
248                     {
249                        rc = handle_derived<bond_group_binding_cmds::bind_cmd>(f_exp, f_act);
250                     }
251                     else if (typeid(*f_exp) == typeid(bond_group_binding_cmds::unbind_cmd))
252                     {
253                        rc = handle_derived<bond_group_binding_cmds::unbind_cmd>(f_exp, f_act);
254                     }
255                     else if (typeid(*f_exp) == typeid(route_domain_cmds::create_cmd))
256                     {
257                         rc = handle_derived<route_domain_cmds::create_cmd>(f_exp, f_act);
258                     }
259                     else if (typeid(*f_exp) == typeid(route_domain_cmds::delete_cmd))
260                     {
261                         rc = handle_derived<route_domain_cmds::delete_cmd>(f_exp, f_act);
262                     }
263                     else if (typeid(*f_exp) == typeid(route::ip_route_cmds::update_cmd))
264                     {
265                         rc = handle_derived<route::ip_route_cmds::update_cmd>(f_exp, f_act);
266                     }
267                     else if (typeid(*f_exp) == typeid(route::ip_route_cmds::delete_cmd))
268                     {
269                         rc = handle_derived<route::ip_route_cmds::delete_cmd>(f_exp, f_act);
270                     }
271                     else if (typeid(*f_exp) == typeid(route::ip_mroute_cmds::update_cmd))
272                     {
273                         rc = handle_derived<route::ip_mroute_cmds::update_cmd>(f_exp, f_act);
274                     }
275                     else if (typeid(*f_exp) == typeid(route::ip_mroute_cmds::delete_cmd))
276                     {
277                         rc = handle_derived<route::ip_mroute_cmds::delete_cmd>(f_exp, f_act);
278                     }
279                     else if (typeid(*f_exp) == typeid(neighbour_cmds::create_cmd))
280                     {
281                         rc = handle_derived<neighbour_cmds::create_cmd>(f_exp, f_act);
282                     }
283                     else if (typeid(*f_exp) == typeid(neighbour_cmds::delete_cmd))
284                     {
285                         rc = handle_derived<neighbour_cmds::delete_cmd>(f_exp, f_act);
286                     }
287                     else if (typeid(*f_exp) == typeid(l3_binding_cmds::bind_cmd))
288                     {
289                         rc = handle_derived<l3_binding_cmds::bind_cmd>(f_exp, f_act);
290                     }
291                     else if (typeid(*f_exp) == typeid(l3_binding_cmds::unbind_cmd))
292                     {
293                         rc = handle_derived<l3_binding_cmds::unbind_cmd>(f_exp, f_act);
294                     }
295                     else if (typeid(*f_exp) == typeid(bridge_domain_cmds::create_cmd))
296                     {
297                         rc = handle_derived<bridge_domain_cmds::create_cmd>(f_exp, f_act);
298                     }
299                     else if (typeid(*f_exp) == typeid(bridge_domain_cmds::delete_cmd))
300                     {
301                         rc = handle_derived<bridge_domain_cmds::delete_cmd>(f_exp, f_act);
302                     }
303                     else if (typeid(*f_exp) == typeid(bridge_domain_entry_cmds::create_cmd))
304                     {
305                         rc = handle_derived<bridge_domain_entry_cmds::create_cmd>(f_exp, f_act);
306                     }
307                     else if (typeid(*f_exp) == typeid(bridge_domain_entry_cmds::delete_cmd))
308                     {
309                         rc = handle_derived<bridge_domain_entry_cmds::delete_cmd>(f_exp, f_act);
310                     }
311                     else if (typeid(*f_exp) == typeid(bridge_domain_arp_entry_cmds::create_cmd))
312                     {
313                         rc = handle_derived<bridge_domain_arp_entry_cmds::create_cmd>(f_exp, f_act);
314                     }
315                     else if (typeid(*f_exp) == typeid(bridge_domain_arp_entry_cmds::delete_cmd))
316                     {
317                         rc = handle_derived<bridge_domain_arp_entry_cmds::delete_cmd>(f_exp, f_act);
318                     }
319                     else if (typeid(*f_exp) == typeid(l2_binding_cmds::bind_cmd))
320                     {
321                         rc = handle_derived<l2_binding_cmds::bind_cmd>(f_exp, f_act);
322                     }
323                     else if (typeid(*f_exp) == typeid(l2_binding_cmds::unbind_cmd))
324                     {
325                         rc = handle_derived<l2_binding_cmds::unbind_cmd>(f_exp, f_act);
326                     }
327                     else if (typeid(*f_exp) == typeid(l2_vtr_cmds::set_cmd))
328                     {
329                         rc = handle_derived<l2_vtr_cmds::set_cmd>(f_exp, f_act);
330                     }
331                     else if (typeid(*f_exp) == typeid(l2_xconnect_cmds::bind_cmd))
332                     {
333                         rc = handle_derived<l2_xconnect_cmds::bind_cmd>(f_exp, f_act);
334                     }
335                     else if (typeid(*f_exp) == typeid(l2_xconnect_cmds::unbind_cmd))
336                     {
337                         rc = handle_derived<l2_xconnect_cmds::unbind_cmd>(f_exp, f_act);
338                     }
339                     else if (typeid(*f_exp) == typeid(vxlan_tunnel_cmds::create_cmd))
340                     {
341                         rc = handle_derived<vxlan_tunnel_cmds::create_cmd>(f_exp, f_act);
342                     }
343                     else if (typeid(*f_exp) == typeid(vxlan_tunnel_cmds::delete_cmd))
344                     {
345                         rc = handle_derived<vxlan_tunnel_cmds::delete_cmd>(f_exp, f_act);
346                     }
347                     else if (typeid(*f_exp) == typeid(sub_interface_cmds::create_cmd))
348                     {
349                         rc = handle_derived<sub_interface_cmds::create_cmd>(f_exp, f_act);
350                     }
351                     else if (typeid(*f_exp) == typeid(sub_interface_cmds::delete_cmd))
352                     {
353                         rc = handle_derived<sub_interface_cmds::delete_cmd>(f_exp, f_act);
354                     }
355                     else if (typeid(*f_exp) == typeid(ACL::acl_ethertype_cmds::bind_cmd))
356                     {
357                         rc = handle_derived<ACL::acl_ethertype_cmds::bind_cmd>(f_exp, f_act);
358                     }
359                     else if (typeid(*f_exp) == typeid(ACL::acl_ethertype_cmds::unbind_cmd))
360                     {
361                         rc = handle_derived<ACL::acl_ethertype_cmds::unbind_cmd>(f_exp, f_act);
362                     }
363                     else if (typeid(*f_exp) == typeid(ACL::list_cmds::l3_update_cmd))
364                     {
365                         rc = handle_derived<ACL::list_cmds::l3_update_cmd>(f_exp, f_act);
366                     }
367                     else if (typeid(*f_exp) == typeid(ACL::list_cmds::l3_delete_cmd))
368                     {
369                         rc = handle_derived<ACL::list_cmds::l3_delete_cmd>(f_exp, f_act);
370                     }
371                     else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l3_bind_cmd))
372                     {
373                         rc = handle_derived<ACL::binding_cmds::l3_bind_cmd>(f_exp, f_act);
374                     }
375                     else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l3_unbind_cmd))
376                     {
377                         rc = handle_derived<ACL::binding_cmds::l3_unbind_cmd>(f_exp, f_act);
378                     }
379                     else if (typeid(*f_exp) == typeid(ACL::list_cmds::l2_update_cmd))
380                     {
381                         rc = handle_derived<ACL::list_cmds::l2_update_cmd>(f_exp, f_act);
382                     }
383                     else if (typeid(*f_exp) == typeid(ACL::list_cmds::l2_delete_cmd))
384                     {
385                         rc = handle_derived<ACL::list_cmds::l2_delete_cmd>(f_exp, f_act);
386                     }
387                     else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l2_bind_cmd))
388                     {
389                         rc = handle_derived<ACL::binding_cmds::l2_bind_cmd>(f_exp, f_act);
390                     }
391                     else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l2_unbind_cmd))
392                     {
393                         rc = handle_derived<ACL::binding_cmds::l2_unbind_cmd>(f_exp, f_act);
394                     }
395                     else if (typeid(*f_exp) == typeid(arp_proxy_binding_cmds::bind_cmd))
396                     {
397                         rc = handle_derived<arp_proxy_binding_cmds::bind_cmd>(f_exp, f_act);
398                     }
399                     else if (typeid(*f_exp) == typeid(arp_proxy_binding_cmds::unbind_cmd))
400                     {
401                         rc = handle_derived<arp_proxy_binding_cmds::unbind_cmd>(f_exp, f_act);
402                     }
403                     else if (typeid(*f_exp) == typeid(arp_proxy_config_cmds::config_cmd))
404                     {
405                         rc = handle_derived<arp_proxy_config_cmds::config_cmd>(f_exp, f_act);
406                     }
407                     else if (typeid(*f_exp) == typeid(arp_proxy_config_cmds::unconfig_cmd))
408                     {
409                         rc = handle_derived<arp_proxy_config_cmds::unconfig_cmd>(f_exp, f_act);
410                     }
411                     else if (typeid(*f_exp) == typeid(igmp_binding_cmds::bind_cmd))
412                     {
413                         rc = handle_derived<igmp_binding_cmds::bind_cmd>(f_exp, f_act);
414                     }
415                     else if (typeid(*f_exp) == typeid(igmp_binding_cmds::unbind_cmd))
416                     {
417                         rc = handle_derived<igmp_binding_cmds::unbind_cmd>(f_exp, f_act);
418                     }
419                     else if (typeid(*f_exp) == typeid(igmp_listen_cmds::listen_cmd))
420                     {
421                         rc = handle_derived<igmp_listen_cmds::listen_cmd>(f_exp, f_act);
422                     }
423                     else if (typeid(*f_exp) == typeid(igmp_listen_cmds::unlisten_cmd))
424                     {
425                         rc = handle_derived<igmp_listen_cmds::unlisten_cmd>(f_exp, f_act);
426                     }
427                     else if (typeid(*f_exp) == typeid(ip_punt_redirect_cmds::config_cmd))
428                     {
429                         rc = handle_derived<ip_punt_redirect_cmds::config_cmd>(f_exp, f_act);
430                     }
431                     else if (typeid(*f_exp) == typeid(ip_punt_redirect_cmds::unconfig_cmd))
432                     {
433                         rc = handle_derived<ip_punt_redirect_cmds::unconfig_cmd>(f_exp, f_act);
434                     }
435                     else if (typeid(*f_exp) == typeid(ip_unnumbered_cmds::config_cmd))
436                     {
437                         rc = handle_derived<ip_unnumbered_cmds::config_cmd>(f_exp, f_act);
438                     }
439                     else if (typeid(*f_exp) == typeid(ip_unnumbered_cmds::unconfig_cmd))
440                     {
441                         rc = handle_derived<ip_unnumbered_cmds::unconfig_cmd>(f_exp, f_act);
442                     }
443                     else if (typeid(*f_exp) == typeid(ip6nd_ra_config::config_cmd))
444                     {
445                         rc = handle_derived<ip6nd_ra_config::config_cmd>(f_exp, f_act);
446                     }
447                     else if (typeid(*f_exp) == typeid(ip6nd_ra_config::unconfig_cmd))
448                     {
449                         rc = handle_derived<ip6nd_ra_config::unconfig_cmd>(f_exp, f_act);
450                     }
451                     else if (typeid(*f_exp) == typeid(ip6nd_ra_prefix::config_cmd))
452                     {
453                         rc = handle_derived<ip6nd_ra_prefix::config_cmd>(f_exp, f_act);
454                     }
455                     else if (typeid(*f_exp) == typeid(ip6nd_ra_prefix::unconfig_cmd))
456                     {
457                         rc = handle_derived<ip6nd_ra_prefix::unconfig_cmd>(f_exp, f_act);
458                     }
459                     else if (typeid(*f_exp) == typeid(interface_span_cmds::config_cmd))
460                     {
461                         rc = handle_derived<interface_span_cmds::config_cmd>(f_exp, f_act);
462                     }
463                     else if (typeid(*f_exp) == typeid(interface_span_cmds::unconfig_cmd))
464                     {
465                         rc = handle_derived<interface_span_cmds::unconfig_cmd>(f_exp, f_act);
466                     }
467                     else if (typeid(*f_exp) == typeid(nat_static_cmds::create_44_cmd))
468                     {
469                         rc = handle_derived<nat_static_cmds::create_44_cmd>(f_exp, f_act);
470                     }
471                     else if (typeid(*f_exp) == typeid(nat_static_cmds::delete_44_cmd))
472                     {
473                         rc = handle_derived<nat_static_cmds::delete_44_cmd>(f_exp, f_act);
474                     }
475                     else if (typeid(*f_exp) == typeid(nat_binding_cmds::bind_44_input_cmd))
476                     {
477                         rc = handle_derived<nat_binding_cmds::bind_44_input_cmd>(f_exp, f_act);
478                     }
479                     else if (typeid(*f_exp) == typeid(nat_binding_cmds::unbind_44_input_cmd))
480                     {
481                         rc = handle_derived<nat_binding_cmds::unbind_44_input_cmd>(f_exp, f_act);
482                     }
483                     else if (typeid(*f_exp) == typeid(interface_cmds::events_cmd))
484                     {
485                         rc = handle_derived<interface_cmds::events_cmd>(f_exp, f_act);
486                     }
487                     else if (typeid(*f_exp) == typeid(pipe_cmds::create_cmd))
488                     {
489                         rc = handle_derived<pipe_cmds::create_cmd>(f_exp, f_act);
490                     }
491                     else if (typeid(*f_exp) == typeid(pipe_cmds::delete_cmd))
492                     {
493                         rc = handle_derived<pipe_cmds::delete_cmd>(f_exp, f_act);
494                     }
495                     else if (typeid(*f_exp) == typeid(QoS::mark_cmds::create_cmd))
496                     {
497                         rc = handle_derived<QoS::mark_cmds::create_cmd>(f_exp, f_act);
498                     }
499                     else if (typeid(*f_exp) == typeid(QoS::mark_cmds::delete_cmd))
500                     {
501                         rc = handle_derived<QoS::mark_cmds::delete_cmd>(f_exp, f_act);
502                     }
503                     else if (typeid(*f_exp) == typeid(QoS::record_cmds::create_cmd))
504                     {
505                         rc = handle_derived<QoS::record_cmds::create_cmd>(f_exp, f_act);
506                     }
507                     else if (typeid(*f_exp) == typeid(QoS::record_cmds::delete_cmd))
508                     {
509                         rc = handle_derived<QoS::record_cmds::delete_cmd>(f_exp, f_act);
510                     }
511                     else if (typeid(*f_exp) == typeid(QoS::map_cmds::create_cmd))
512                     {
513                         rc = handle_derived<QoS::map_cmds::create_cmd>(f_exp, f_act);
514                     }
515                     else if (typeid(*f_exp) == typeid(QoS::map_cmds::delete_cmd))
516                     {
517                         rc = handle_derived<QoS::map_cmds::delete_cmd>(f_exp, f_act);
518                     }
519                     else
520                     {
521                         throw ExpException(2);
522                     }
523
524                     // if we get here then we found the match.
525                     m_exp_queue.erase(it_exp);
526                     m_act_queue.erase(it_act);
527                     delete f_exp;
528                     delete f_act;
529
530                     // return any injected failures to the agent
531                     if (rc_t::OK != rc && rc_t::NOOP != rc)
532                     {
533                         return (rc);
534                     }
535
536                     matched = true;
537                     break;
538                 }
539                 catch (ExpException &e)
540                 {
541                     // The expected and actual do not match
542                     if (m_strict_order)
543                     {
544                         // in strict ordering mode this is fatal, so rethrow
545                         throw e;
546                     }
547                     else
548                     {
549                         // move the iterator onto the next in the expected list and
550                         // check for a match
551                         ++it_exp;
552                     }
553                 }
554             }
555
556             if (!matched)
557                 throw ExpException(3);
558         }
559
560         return (rc);
561     }
562 private:
563
564     template <typename T>
565     rc_t handle_derived(const cmd *f_exp, cmd *f_act)
566     {
567         const T *i_exp;
568         T *i_act;
569
570         i_exp = dynamic_cast<const T*>(f_exp);
571         i_act = dynamic_cast<T*>(f_act);
572         if (!(*i_exp == *i_act))
573         {
574             throw ExpException(4);
575         }
576         // pass the data and return code to the agent
577         i_act->item() = i_exp->item();
578
579         return (i_act->item().rc());
580     }
581
582     // The Q to push the expectations on
583     std::deque<cmd*> m_exp_queue;
584
585     // the queue to push the actual events on
586     std::deque<cmd*> m_act_queue;
587
588     // control whether the expected queue is strictly ordered.
589     bool m_strict_order;
590 };
591
592 class VppInit {
593 public:
594     std::string name;
595     MockCmdQ *f;
596
597     VppInit()
598         : name("vpp-ut"),
599           f(new MockCmdQ())
600     {
601         HW::init(f);
602         OM::init();
603         logger().set(log_level_t::DEBUG);
604     }
605
606     ~VppInit() {
607         delete f;
608     }
609 };
610
611 BOOST_AUTO_TEST_SUITE(vom)
612
613 #define TRY_CHECK_RC(stmt)                    \
614 {                                             \
615     try {                                     \
616         BOOST_CHECK(rc_t::OK == stmt);        \
617     }                                         \
618     catch (ExpException &e)                   \
619     {                                         \
620         BOOST_CHECK(false);                   \
621     }                                         \
622     BOOST_CHECK(vi.f->is_empty());            \
623 }
624
625 #define TRY_CHECK(stmt)                       \
626 {                                             \
627     try {                                     \
628         stmt;                                 \
629     }                                         \
630     catch (ExpException &e)                   \
631     {                                         \
632         BOOST_CHECK(false);                   \
633     }                                         \
634     BOOST_CHECK(vi.f->is_empty());            \
635 }
636
637 #define ADD_EXPECT(stmt)                      \
638     vi.f->expect(new stmt)
639
640 #define STRICT_ORDER_OFF()                        \
641     vi.f->strict_order(false)
642
643 BOOST_AUTO_TEST_CASE(test_interface) {
644     VppInit vi;
645     const std::string go = "GeorgeOrwell";
646     const std::string js = "JohnSteinbeck";
647     rc_t rc = rc_t::OK;
648
649     /*
650      * George creates and deletes the interface
651      */
652     std::string itf1_name = "afpacket1";
653     interface itf1(itf1_name,
654                    interface::type_t::AFPACKET,
655                    interface::admin_state_t::UP);
656
657     /*
658      * set the expectation for a afpacket interface create.
659      *  2 is the interface handle VPP [mock] assigns
660      */
661     HW::item<handle_t> hw_ifh(2, rc_t::OK);
662     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
663
664     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
665     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
666
667     TRY_CHECK_RC(OM::write(go, itf1));
668
669     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
670     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
671     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
672
673     TRY_CHECK(OM::remove(go));
674
675     /*
676      * George creates the interface, then John brings it down.
677      * George's remove is a no-op, sice John also owns the interface
678      */
679     interface itf1b(itf1_name,
680                     interface::type_t::AFPACKET,
681                     interface::admin_state_t::DOWN);
682
683     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
684     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
685     TRY_CHECK_RC(OM::write(go, itf1));
686
687     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
688     TRY_CHECK_RC(OM::write(js, itf1b));
689
690     TRY_CHECK(OM::remove(go));
691
692     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
693     TRY_CHECK(OM::remove(js));
694
695     /*
696      * George adds an interface, then we flush all of Geroge's state
697      */
698     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
699     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
700     TRY_CHECK_RC(OM::write(go, itf1));
701
702     TRY_CHECK(OM::mark(go));
703
704     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
705     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
706     TRY_CHECK(OM::sweep(go));
707
708     /*
709      * George adds an interface. mark stale. update the same interface. sweep
710      * and expect no delete
711      */
712     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
713     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
714     TRY_CHECK_RC(OM::write(go, itf1b));
715
716     TRY_CHECK(OM::mark(go));
717
718     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
719     TRY_CHECK_RC(OM::write(go, itf1));
720
721     TRY_CHECK(OM::sweep(go));
722
723     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
724     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
725     TRY_CHECK(OM::remove(go));
726
727     /*
728      * George adds an insterface, then we mark that state. Add a second interface
729      * an flush the first that is now stale.
730      */
731     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
732     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
733     TRY_CHECK_RC(OM::write(go, itf1));
734
735     TRY_CHECK(OM::mark(go));
736
737     std::string itf2_name = "afpacket2";
738     std::string itf2_tag = "uuid-of-afpacket2-interface";
739     interface itf2(itf2_name,
740                    interface::type_t::AFPACKET,
741                    interface::admin_state_t::UP,
742                    itf2_tag);
743     HW::item<handle_t> hw_ifh2(3, rc_t::OK);
744
745     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
746     ADD_EXPECT(interface_cmds::set_tag(hw_ifh2, itf2_tag));
747     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
748     TRY_CHECK_RC(OM::write(go, itf2));
749
750     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
751     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
752     TRY_CHECK(OM::sweep(go));
753
754     TRY_CHECK(OM::mark(go));
755
756     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
757     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
758     TRY_CHECK(OM::sweep(go));
759
760
761     std::string itf3_name = "/PATH/TO/vhost_user1.sock";
762     std::string itf3_tag = "uuid-of-vhost_user1-interface";
763     interface itf3(itf3_name,
764                    interface::type_t::VHOST,
765                    interface::admin_state_t::UP,
766                    itf3_tag);
767     HW::item<handle_t> hw_ifh3(4, rc_t::OK);
768
769     ADD_EXPECT(interface_cmds::vhost_create_cmd(hw_ifh3, itf3_name, itf3_tag));
770     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));
771     TRY_CHECK_RC(OM::write(go, itf3));
772
773     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
774     ADD_EXPECT(interface_cmds::vhost_delete_cmd(hw_ifh3, itf3_name));
775     TRY_CHECK(OM::remove(go));
776 }
777
778 BOOST_AUTO_TEST_CASE(test_bvi) {
779     VppInit vi;
780     const std::string ernest = "ErnestHemmingway";
781     const std::string graham = "GrahamGreene";
782     rc_t rc = rc_t::OK;
783     l3_binding *l3;
784
785     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP,
786                                                 rc_t::OK);
787     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
788                                                   rc_t::OK);
789
790     /*
791      * Enrest creates a BVI with address 10.10.10.10/24
792      */
793     route::prefix_t pfx_10("10.10.10.10", 24);
794
795     const std::string bvi_name = "bvi1";
796     interface itf(bvi_name,
797                   interface::type_t::BVI,
798                   interface::admin_state_t::UP);
799     HW::item<handle_t> hw_ifh(4, rc_t::OK);
800     HW::item<route::prefix_t> hw_pfx_10(pfx_10, rc_t::OK);
801
802     ADD_EXPECT(interface_cmds::bvi_create_cmd(hw_ifh, bvi_name));
803     ADD_EXPECT(interface_cmds::set_tag(hw_ifh, bvi_name));
804     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
805     TRY_CHECK_RC(OM::write(ernest, itf));
806
807     l3 = new l3_binding(itf, pfx_10);
808     HW::item<bool> hw_l3_bind(true, rc_t::OK);
809     HW::item<bool> hw_l3_unbind(false, rc_t::OK);
810     ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10));
811     TRY_CHECK_RC(OM::write(ernest, *l3));
812
813     // change the MAC address on the BVI
814     interface itf_new_mac(bvi_name,
815                           interface::type_t::BVI,
816                           interface::admin_state_t::UP);
817     l2_address_t l2_addr({0,1,2,3,4,5});
818     HW::item<l2_address_t> hw_mac(l2_addr, rc_t::OK);
819     itf_new_mac.set(l2_addr);
820     ADD_EXPECT(interface_cmds::set_mac_cmd(hw_mac, hw_ifh));
821     TRY_CHECK_RC(OM::write(ernest, itf_new_mac));
822
823     // create/write the interface to the OM again but with an unset MAC
824     // this should not generate a MAC address update
825     TRY_CHECK_RC(OM::write(ernest, itf));
826
827     // change the MAC address on the BVI - again
828     interface itf_new_mac2(bvi_name,
829                            interface::type_t::BVI,
830                            interface::admin_state_t::UP);
831     l2_address_t l2_addr2({0,1,2,3,4,6});
832     HW::item<l2_address_t> hw_mac2(l2_addr2, rc_t::OK);
833     itf_new_mac2.set(l2_addr2);
834     ADD_EXPECT(interface_cmds::set_mac_cmd(hw_mac2, hw_ifh));
835     TRY_CHECK_RC(OM::write(ernest, itf_new_mac2));
836
837     delete l3;
838     ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10));
839     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
840     ADD_EXPECT(interface_cmds::bvi_delete_cmd(hw_ifh));
841     TRY_CHECK(OM::remove(ernest));
842
843     /*
844      * Graham creates a BVI with address 10.10.10.10/24 in Routing Domain
845      */
846     route_domain rd(1);
847     HW::item<bool> hw_rd4_create(true, rc_t::OK);
848     HW::item<bool> hw_rd4_delete(false, rc_t::OK);
849     HW::item<bool> hw_rd6_create(true, rc_t::OK);
850     HW::item<bool> hw_rd6_delete(false, rc_t::OK);
851     HW::item<route::table_id_t> hw_rd4_bind(1, rc_t::OK);
852     HW::item<route::table_id_t> hw_rd4_unbind(route::DEFAULT_TABLE, rc_t::OK);
853     HW::item<route::table_id_t> hw_rd6_bind(1, rc_t::OK);
854     HW::item<route::table_id_t> hw_rd6_unbind(route::DEFAULT_TABLE, rc_t::OK);
855     ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd4_create, l3_proto_t::IPV4, 1));
856     ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd6_create, l3_proto_t::IPV6, 1));
857     TRY_CHECK_RC(OM::write(graham, rd));
858
859     const std::string bvi2_name = "bvi2";
860     interface *itf2 = new interface(bvi2_name,
861                                     interface::type_t::BVI,
862                                     interface::admin_state_t::UP,
863                                     rd);
864     HW::item<handle_t> hw_ifh2(5, rc_t::OK);
865
866     ADD_EXPECT(interface_cmds::bvi_create_cmd(hw_ifh2, bvi2_name));
867     ADD_EXPECT(interface_cmds::set_tag(hw_ifh2, bvi2_name));
868     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
869     ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_bind, l3_proto_t::IPV4, hw_ifh2));
870     ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_bind, l3_proto_t::IPV6, hw_ifh2));
871
872     TRY_CHECK_RC(OM::write(graham, *itf2));
873
874     l3 = new l3_binding(*itf2, pfx_10);
875     ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh2.data(), pfx_10));
876     TRY_CHECK_RC(OM::write(graham, *l3));
877
878     delete l3;
879     delete itf2;
880
881     ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh2.data(), pfx_10));
882     ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV4, hw_ifh2));
883     ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_unbind, l3_proto_t::IPV6, hw_ifh2));
884     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
885     ADD_EXPECT(interface_cmds::bvi_delete_cmd(hw_ifh2));
886     ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd4_delete, l3_proto_t::IPV4, 1));
887     ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd6_delete, l3_proto_t::IPV6, 1));
888     TRY_CHECK(OM::remove(graham));
889 }
890
891 BOOST_AUTO_TEST_CASE(test_bond) {
892     VppInit vi;
893     const std::string cb = "CarolBerg";
894     rc_t rc = rc_t::OK;
895
896     /*
897      * creates the interfaces
898      */
899     std::string itf1_name = "afpacket1";
900     interface itf1(itf1_name,
901                    interface::type_t::AFPACKET,
902                    interface::admin_state_t::UP);
903
904     HW::item<handle_t> hw_ifh(2, rc_t::OK);
905     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
906
907     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
908     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
909
910     TRY_CHECK_RC(OM::write(cb, itf1));
911
912     std::string itf2_name = "afpacket2";
913     interface itf2(itf2_name,
914                    interface::type_t::AFPACKET,
915                    interface::admin_state_t::UP);
916
917
918     HW::item<handle_t> hw_ifh2(4, rc_t::OK);
919     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
920     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
921
922     TRY_CHECK_RC(OM::write(cb, itf2));
923
924     std::string bond_name = "bond";
925     bond_interface bond_itf(bond_name, interface::admin_state_t::UP,
926                                  bond_interface::mode_t::LACP);
927
928     HW::item<handle_t> hw_ifh3(6, rc_t::OK);
929     ADD_EXPECT(bond_interface_cmds::create_cmd(hw_ifh3, bond_name,
930       bond_interface::mode_t::LACP, bond_interface::lb_t::L2, l2_address_t::ZERO));
931     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));
932
933     TRY_CHECK_RC(OM::write(cb, bond_itf));
934
935     bond_member *bm1 = new bond_member(itf1, bond_member::mode_t::ACTIVE,
936                                          bond_member::rate_t::SLOW);
937     bond_member *bm2 = new bond_member(itf2, bond_member::mode_t::ACTIVE,
938                                          bond_member::rate_t::SLOW);
939     bond_group_binding *bgb = new bond_group_binding(bond_itf, {*bm1, *bm2});
940
941     HW::item<bool> bond_hw_bind(true, rc_t::OK);
942     ADD_EXPECT(bond_group_binding_cmds::bind_cmd(bond_hw_bind, hw_ifh3.data(), *bm1));
943     ADD_EXPECT(bond_group_binding_cmds::bind_cmd(bond_hw_bind, hw_ifh3.data(), *bm2));
944
945     TRY_CHECK_RC(OM::write(cb, *bgb));
946
947     delete bgb;
948     delete bm2;
949     delete bm1;
950
951     STRICT_ORDER_OFF();
952     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
953     ADD_EXPECT(bond_group_binding_cmds::unbind_cmd(bond_hw_bind, hw_ifh.data()));
954     ADD_EXPECT(bond_group_binding_cmds::unbind_cmd(bond_hw_bind, hw_ifh2.data()));
955     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
956     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
957     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
958     ADD_EXPECT(bond_interface_cmds::delete_cmd(hw_ifh3));
959     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
960     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
961
962     TRY_CHECK(OM::remove(cb));
963 }
964
965 BOOST_AUTO_TEST_CASE(test_bridge) {
966     VppInit vi;
967     const std::string franz = "FranzKafka";
968     const std::string dante = "Dante";
969     const std::string jkr = "jkrowling";
970     rc_t rc = rc_t::OK;
971
972     /*
973      * Franz creates an interface, Bridge-domain, then binds the two
974      */
975
976     // interface create
977     std::string itf1_name = "afpacket1";
978     interface itf1(itf1_name,
979                    interface::type_t::AFPACKET,
980                    interface::admin_state_t::UP);
981
982     HW::item<handle_t> hw_ifh(3, rc_t::OK);
983     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP,
984                                                 rc_t::OK);
985     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
986     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
987
988     TRY_CHECK_RC(OM::write(franz, itf1));
989
990     // bridge-domain create
991     bridge_domain bd1(33);
992
993     HW::item<uint32_t> hw_bd(33, rc_t::OK);
994     ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd,
995                                               bridge_domain::learning_mode_t::ON,
996                                               bridge_domain::arp_term_mode_t::ON,
997                                               bridge_domain::arp_ufwd_mode_t::ON,
998                                               bridge_domain::flood_mode_t::ON,
999                                               bridge_domain::uu_flood_mode_t::ON,
1000                                               bridge_domain::mac_age_mode_t::OFF));
1001
1002     TRY_CHECK_RC(OM::write(franz, bd1));
1003
1004     // L2-interface create and bind
1005     // this needs to be delete'd before the flush below, since it too maintains
1006     // references to the BD and Interface
1007     l2_binding *l2itf = new l2_binding(itf1, bd1);
1008     HW::item<bool> hw_l2_bind(true, rc_t::OK);
1009
1010     ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind,
1011                                          hw_ifh.data(),
1012                                          hw_bd.data(),
1013                                          l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
1014     TRY_CHECK_RC(OM::write(franz, *l2itf));
1015
1016     /*
1017      * Dante adds an interface to the same BD
1018      */
1019     std::string itf2_name = "afpacket2";
1020     interface itf2(itf2_name,
1021                    interface::type_t::AFPACKET,
1022                    interface::admin_state_t::UP);
1023
1024     HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1025     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1026     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
1027     TRY_CHECK_RC(OM::write(dante, itf2));
1028
1029     // BD add is a no-op since it exists
1030     TRY_CHECK_RC(OM::write(dante, bd1));
1031
1032     l2_binding *l2itf2 = new l2_binding(itf2, bd1);
1033     HW::item<l2_vtr::option_t> hw_set_vtr(l2_vtr::option_t::POP_1, rc_t::OK);
1034     l2itf2->set(l2_vtr::option_t::POP_1, 68);
1035
1036     ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind,
1037                                          hw_ifh2.data(),
1038                                          hw_bd.data(),
1039                                          l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
1040     ADD_EXPECT(l2_vtr_cmds::set_cmd(hw_set_vtr, hw_ifh2.data(), 68));
1041     TRY_CHECK_RC(OM::write(dante, *l2itf2));
1042
1043     // Add some static entries to the bridge-domain
1044     HW::item<bool> hw_be1(true, rc_t::OK);
1045     mac_address_t mac1({0,1,2,3,4,5});
1046     bridge_domain_entry *be1 = new bridge_domain_entry(bd1, mac1, itf2);
1047     ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be1, mac1, bd1.id(), hw_ifh2.data(),
1048                                                     false));
1049     TRY_CHECK_RC(OM::write(dante, *be1));
1050
1051     // Add some entries to the bridge-domain ARP termination table
1052     HW::item<bool> hw_bea1(true, rc_t::OK);
1053     boost::asio::ip::address ip1 = boost::asio::ip::address::from_string("10.10.10.10");
1054
1055     bridge_domain_arp_entry *bea1 = new bridge_domain_arp_entry(bd1, ip1, mac1);
1056     ADD_EXPECT(bridge_domain_arp_entry_cmds::create_cmd(hw_be1, bd1.id(), mac1, ip1));
1057     TRY_CHECK_RC(OM::write(dante, *bea1));
1058
1059     // flush Franz's state
1060     delete l2itf;
1061     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
1062                                                   rc_t::OK);
1063     ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind,
1064                                            hw_ifh.data(),
1065                                            hw_bd.data(),
1066                                            l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
1067     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1068     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1069     TRY_CHECK(OM::remove(franz));
1070
1071     // flush Dante's state - the order the interface and BD are deleted
1072     // is an uncontrollable artifact of the C++ object destruction.
1073     delete l2itf2;
1074     delete be1;
1075     delete bea1;
1076     STRICT_ORDER_OFF();
1077     ADD_EXPECT(bridge_domain_arp_entry_cmds::delete_cmd(hw_be1, bd1.id(), mac1, ip1));
1078     ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be1, mac1, bd1.id(), false));
1079     ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind,
1080                                            hw_ifh2.data(),
1081                                            hw_bd.data(),
1082                                            l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
1083
1084     ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
1085     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
1086     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1087     TRY_CHECK(OM::remove(dante));
1088
1089     // test the BVI entry in l2fib
1090     bridge_domain bd2(99);
1091
1092     HW::item<uint32_t> hw_bd2(99, rc_t::OK);
1093     ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd2,
1094                                               bridge_domain::learning_mode_t::ON,
1095                                               bridge_domain::arp_term_mode_t::ON,
1096                                               bridge_domain::arp_ufwd_mode_t::ON,
1097                                               bridge_domain::flood_mode_t::ON,
1098                                               bridge_domain::uu_flood_mode_t::ON,
1099                                               bridge_domain::mac_age_mode_t::OFF));
1100
1101     TRY_CHECK_RC(OM::write(jkr, bd2));
1102
1103     std::string itf3_name = "bvi";
1104     interface itf3(itf3_name,
1105                    interface::type_t::BVI,
1106                    interface::admin_state_t::UP);
1107
1108     HW::item<handle_t> hw_ifh3(5, rc_t::OK);
1109     ADD_EXPECT(interface_cmds::bvi_create_cmd(hw_ifh3, itf3_name));
1110     ADD_EXPECT(interface_cmds::set_tag(hw_ifh3, itf3_name));
1111     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));
1112     TRY_CHECK_RC(OM::write(jkr, itf3));
1113
1114     l2_binding *l2itf3 = new l2_binding(itf3, bd2);
1115     ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind,
1116                                          hw_ifh3.data(),
1117                                          hw_bd2.data(),
1118                                          l2_binding::l2_port_type_t::L2_PORT_TYPE_BVI));
1119     TRY_CHECK_RC(OM::write(jkr, *l2itf3));
1120
1121     HW::item<bool> hw_be2(true, rc_t::OK);
1122     mac_address_t mac2({0,1,2,3,4,5});
1123     bridge_domain_entry *be2 = new bridge_domain_entry(bd2, mac2, itf3);
1124     ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be2, mac2, bd2.id(), hw_ifh3.data(), true));
1125     TRY_CHECK_RC(OM::write(jkr, *be2));
1126
1127     delete l2itf3;
1128     delete be2;
1129     STRICT_ORDER_OFF();
1130     ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind,
1131                                            hw_ifh3.data(),
1132                                            hw_bd2.data(),
1133                                            l2_binding::l2_port_type_t::L2_PORT_TYPE_BVI));
1134     ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be2, mac2, bd2.id(), true));
1135     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
1136     ADD_EXPECT(interface_cmds::bvi_delete_cmd(hw_ifh3));
1137     ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd2));
1138     TRY_CHECK(OM::remove(jkr));
1139 }
1140
1141 BOOST_AUTO_TEST_CASE(test_l2_xconnect) {
1142     VppInit vi;
1143     const std::string nicholas = "NicholasAbercrombie";
1144     rc_t rc = rc_t::OK;
1145
1146     /*
1147      * Interface 1
1148      */
1149     std::string itf1_name = "host1";
1150     interface itf1(itf1_name,
1151                    interface::type_t::AFPACKET,
1152                    interface::admin_state_t::UP);
1153     HW::item<handle_t> hw_ifh(2, rc_t::OK);
1154     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1155     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1156     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1157     TRY_CHECK_RC(OM::write(nicholas, itf1));
1158
1159     /*
1160      * Interface 2
1161      */
1162     std::string itf2_name = "host2";
1163     interface itf2(itf2_name,
1164                    interface::type_t::AFPACKET,
1165                    interface::admin_state_t::UP);
1166
1167     HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1168     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1169     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
1170     TRY_CHECK_RC(OM::write(nicholas, itf2));
1171
1172     l2_xconnect *l2_xconn = new l2_xconnect(itf1, itf2);
1173     HW::item<bool> xconnect_east(true, rc_t::OK);
1174     HW::item<bool> xconnect_west(true, rc_t::OK);
1175     HW::item<bool> xconnect_east_unbind(false, rc_t::OK);
1176     HW::item<bool> xconnect_west_unbind(false, rc_t::OK);
1177     ADD_EXPECT(l2_xconnect_cmds::bind_cmd(xconnect_east, hw_ifh.data(), hw_ifh2.data()));
1178     ADD_EXPECT(l2_xconnect_cmds::bind_cmd(xconnect_west, hw_ifh2.data(), hw_ifh.data()));
1179     TRY_CHECK_RC(OM::write(nicholas, *l2_xconn));
1180
1181     delete l2_xconn;
1182
1183     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1184     STRICT_ORDER_OFF();
1185     ADD_EXPECT(l2_xconnect_cmds::unbind_cmd(xconnect_east_unbind, hw_ifh.data(), hw_ifh2.data()));
1186     ADD_EXPECT(l2_xconnect_cmds::unbind_cmd(xconnect_west_unbind, hw_ifh2.data(), hw_ifh.data()));
1187     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
1188     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1189     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1190     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1191
1192     TRY_CHECK(OM::remove(nicholas));
1193 }
1194
1195 BOOST_AUTO_TEST_CASE(test_vxlan) {
1196     VppInit vi;
1197     const std::string franz = "FranzKafka";
1198     rc_t rc = rc_t::OK;
1199
1200     /*
1201      * Franz creates an interface, Bridge-domain, then binds the two
1202      */
1203
1204     // VXLAN create
1205     vxlan_tunnel::endpoint_t ep(boost::asio::ip::address::from_string("10.10.10.10"),
1206                                 boost::asio::ip::address::from_string("10.10.10.11"),
1207                                 322);
1208
1209     vxlan_tunnel vxt(ep.src, ep.dst, ep.vni);
1210
1211     HW::item<handle_t> hw_vxt(3, rc_t::OK);
1212     ADD_EXPECT(vxlan_tunnel_cmds::create_cmd(hw_vxt, "don't-care", ep,
1213                                              handle_t::INVALID));
1214
1215     TRY_CHECK_RC(OM::write(franz, vxt));
1216
1217     // bridge-domain create
1218     bridge_domain bd1(33, bridge_domain::learning_mode_t::OFF,
1219                       bridge_domain::arp_term_mode_t::OFF,
1220                       bridge_domain::arp_ufwd_mode_t::OFF,
1221                       bridge_domain::flood_mode_t::OFF,
1222                       bridge_domain::uu_flood_mode_t::OFF,
1223                       bridge_domain::mac_age_mode_t::ON);
1224
1225     HW::item<uint32_t> hw_bd(33, rc_t::OK);
1226     ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd,
1227                                               bridge_domain::learning_mode_t::OFF,
1228                                               bridge_domain::arp_term_mode_t::OFF,
1229                                               bridge_domain::arp_ufwd_mode_t::OFF,
1230                                               bridge_domain::flood_mode_t::OFF,
1231                                               bridge_domain::uu_flood_mode_t::OFF,
1232                                               bridge_domain::mac_age_mode_t::ON));
1233
1234     TRY_CHECK_RC(OM::write(franz, bd1));
1235
1236     // L2-interface create and bind
1237     // this needs to be delete'd before the flush below, since it too maintains
1238     // references to the BD and Interface
1239     l2_binding *l2itf = new l2_binding(vxt, bd1);
1240     HW::item<bool> hw_l2_bind(true, rc_t::OK);
1241
1242     ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind,
1243                                          hw_vxt.data(),
1244                                          hw_bd.data(),
1245                                          l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
1246     TRY_CHECK_RC(OM::write(franz, *l2itf));
1247
1248     // flush Franz's state
1249     delete l2itf;
1250     HW::item<handle_t> hw_vxtdel(3, rc_t::NOOP);
1251     STRICT_ORDER_OFF();
1252     ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind,
1253                                            hw_vxt.data(),
1254                                            hw_bd.data(),
1255                                            l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
1256     ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
1257     ADD_EXPECT(vxlan_tunnel_cmds::delete_cmd(hw_vxtdel, ep));
1258     TRY_CHECK(OM::remove(franz));
1259 }
1260
1261 BOOST_AUTO_TEST_CASE(test_vlan) {
1262     VppInit vi;
1263     const std::string noam = "NoamChomsky";
1264     rc_t rc = rc_t::OK;
1265
1266     std::string itf1_name = "host1";
1267     interface itf1(itf1_name,
1268                    interface::type_t::AFPACKET,
1269                    interface::admin_state_t::UP);
1270
1271     HW::item<handle_t> hw_ifh(2, rc_t::OK);
1272     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1273
1274     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1275     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1276
1277     TRY_CHECK_RC(OM::write(noam, itf1));
1278
1279     sub_interface *vl33 = new sub_interface(itf1,
1280                                             interface::admin_state_t::UP,
1281                                             33);
1282
1283     HW::item<handle_t> hw_vl33(3, rc_t::OK);
1284     ADD_EXPECT(sub_interface_cmds::create_cmd(hw_vl33, itf1_name+".33", hw_ifh.data(), 33));
1285     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_vl33));
1286
1287     TRY_CHECK_RC(OM::write(noam, *vl33));
1288
1289     delete vl33;
1290     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1291     HW::item<handle_t> hw_vl33_down(3, rc_t::NOOP);
1292     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_vl33));
1293     ADD_EXPECT(sub_interface_cmds::delete_cmd(hw_vl33_down));
1294     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1295     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1296
1297     TRY_CHECK(OM::remove(noam));
1298 }
1299
1300 BOOST_AUTO_TEST_CASE(test_acl) {
1301     VppInit vi;
1302     const std::string fyodor = "FyodorDostoyevsky";
1303     const std::string leo = "LeoTolstoy";
1304     rc_t rc = rc_t::OK;
1305
1306     /*
1307      * Fyodor adds an ACL in the input direction
1308      */
1309     std::string itf1_name = "host1";
1310     interface itf1(itf1_name,
1311                    interface::type_t::AFPACKET,
1312                    interface::admin_state_t::UP);
1313     HW::item<handle_t> hw_ifh(2, rc_t::OK);
1314     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1315     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1316     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1317     TRY_CHECK_RC(OM::write(fyodor, itf1));
1318
1319     ACL::ethertype_rule_t e1(ethertype_t::ARP, direction_t::INPUT);
1320     ACL::ethertype_rule_t e2(ethertype_t::ARP, direction_t::OUTPUT);
1321     ACL::ethertype_rule_t e3(ethertype_t::IPV4, direction_t::INPUT);
1322     ACL::acl_ethertype::ethertype_rules_t l_e = {e1, e2, e3};
1323     ACL::acl_ethertype *a_e = new ACL::acl_ethertype(itf1, l_e);
1324     HW::item<bool> ae_binding(true, rc_t::OK);
1325     ADD_EXPECT(ACL::acl_ethertype_cmds::bind_cmd(ae_binding, hw_ifh.data(), l_e));
1326     TRY_CHECK_RC(OM::write(fyodor, *a_e));
1327
1328     route::prefix_t src("10.10.10.10", 32);
1329     ACL::l3_rule r1(10, ACL::action_t::PERMIT, src, route::prefix_t::ZERO);
1330     ACL::l3_rule r2(20, ACL::action_t::DENY, route::prefix_t::ZERO, route::prefix_t::ZERO);
1331
1332     std::string acl_name = "acl1";
1333     ACL::l3_list acl1(acl_name);
1334     acl1.insert(r2);
1335     acl1.insert(r1);
1336     ACL::l3_list::rules_t rules = {r1, r2};
1337
1338     HW::item<handle_t> hw_acl(2, rc_t::OK);
1339     ADD_EXPECT(ACL::list_cmds::l3_update_cmd(hw_acl, acl_name, rules));
1340     TRY_CHECK_RC(OM::write(fyodor, acl1));
1341
1342     ACL::l3_rule r3(30, ACL::action_t::PERMIT, route::prefix_t::ZERO, route::prefix_t::ZERO);
1343     ACL::l3_list acl2(acl_name);
1344     acl2.insert(r3);
1345     ACL::l3_list::rules_t rules2 = {r3};
1346     ADD_EXPECT(ACL::list_cmds::l3_update_cmd(hw_acl, acl_name, rules2));
1347     TRY_CHECK_RC(OM::write(fyodor, acl2));
1348
1349     ACL::l3_binding *l3b = new ACL::l3_binding(direction_t::INPUT, itf1, acl1);
1350     HW::item<bool> hw_binding(true, rc_t::OK);
1351     ADD_EXPECT(ACL::binding_cmds::l3_bind_cmd(hw_binding, direction_t::INPUT,
1352                                          hw_ifh.data(), hw_acl.data()));
1353     TRY_CHECK_RC(OM::write(fyodor, *l3b));
1354
1355     /**
1356      * Leo adds an L2 ACL in the output direction
1357      */
1358     TRY_CHECK_RC(OM::write(leo, itf1));
1359
1360     std::string l2_acl_name = "l2_acl1";
1361     mac_address_t mac({0x0, 0x0, 0x1, 0x2, 0x3, 0x4});
1362     mac_address_t mac_mask({0xff, 0xff, 0xff, 0x0, 0x0, 0x0});
1363     ACL::l2_rule l2_r1(10, ACL::action_t::PERMIT, src, mac, mac_mask);
1364     ACL::l2_rule l2_r2(20, ACL::action_t::DENY, src, {}, {});
1365
1366     ACL::l2_list l2_acl(l2_acl_name);
1367     l2_acl.insert(l2_r2);
1368     l2_acl.insert(l2_r1);
1369
1370     ACL::l2_list::rules_t l2_rules = {l2_r1, l2_r2};
1371
1372     HW::item<handle_t> l2_hw_acl(3, rc_t::OK);
1373     ADD_EXPECT(ACL::list_cmds::l2_update_cmd(l2_hw_acl, l2_acl_name, l2_rules));
1374     TRY_CHECK_RC(OM::write(leo, l2_acl));
1375
1376     ACL::l2_binding *l2b = new ACL::l2_binding(direction_t::OUTPUT, itf1, l2_acl);
1377     HW::item<bool> l2_hw_binding(true, rc_t::OK);
1378     ADD_EXPECT(ACL::binding_cmds::l2_bind_cmd(l2_hw_binding, direction_t::OUTPUT,
1379                                        hw_ifh.data(), l2_hw_acl.data()));
1380     TRY_CHECK_RC(OM::write(leo, *l2b));
1381
1382     delete l2b;
1383     ADD_EXPECT(ACL::binding_cmds::l2_unbind_cmd(l2_hw_binding, direction_t::OUTPUT,
1384                                                 hw_ifh.data(), l2_hw_acl.data()));
1385     ADD_EXPECT(ACL::list_cmds::l2_delete_cmd(l2_hw_acl));
1386     TRY_CHECK(OM::remove(leo));
1387
1388     delete l3b;
1389     delete a_e;
1390     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
1391                                                   rc_t::OK);
1392     STRICT_ORDER_OFF();
1393     ADD_EXPECT(ACL::binding_cmds::l3_unbind_cmd(hw_binding, direction_t::INPUT,
1394                                          hw_ifh.data(), hw_acl.data()));
1395     ADD_EXPECT(ACL::list_cmds::l3_delete_cmd(hw_acl));
1396     ADD_EXPECT(ACL::acl_ethertype_cmds::unbind_cmd(ae_binding, hw_ifh.data()));
1397     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1398     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1399
1400     TRY_CHECK(OM::remove(fyodor));
1401 }
1402
1403 BOOST_AUTO_TEST_CASE(test_igmp) {
1404     VppInit vi;
1405     const std::string Isaiah = "IsaiahBerlin";
1406     rc_t rc = rc_t::OK;
1407
1408     boost::asio::ip::address_v4 gaddr = boost::asio::ip::address_v4::from_string("232.0.0.1");
1409     boost::asio::ip::address_v4 saddr1 = boost::asio::ip::address_v4::from_string("192.168.0.20");
1410     boost::asio::ip::address_v4 saddr2 = boost::asio::ip::address_v4::from_string("192.168.0.30");
1411
1412     std::string itf3_name = "host3";
1413     interface itf3(itf3_name,
1414                    interface::type_t::AFPACKET,
1415                    interface::admin_state_t::UP);
1416     HW::item<handle_t> hw_ifh(2, rc_t::OK);
1417     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1418     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf3_name));
1419     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1420     TRY_CHECK_RC(OM::write(Isaiah, itf3));
1421
1422     igmp_binding *ib = new igmp_binding(itf3);
1423     HW::item<bool> hw_binding(true, rc_t::OK);
1424     ADD_EXPECT(igmp_binding_cmds::bind_cmd(hw_binding, hw_ifh.data()));
1425     TRY_CHECK_RC(OM::write(Isaiah, *ib));
1426
1427     igmp_listen::src_addrs_t saddrs = {saddr1, saddr2};
1428
1429     igmp_listen *il = new igmp_listen(*ib, gaddr, saddrs);
1430     HW::item<bool> hw_as_listen(true, rc_t::OK);
1431     ADD_EXPECT(igmp_listen_cmds::listen_cmd(hw_as_listen, hw_ifh.data(), gaddr, saddrs));
1432     TRY_CHECK_RC(OM::write(Isaiah, *il));
1433
1434     delete il;
1435     delete ib;
1436
1437     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
1438                                                   rc_t::OK);
1439     STRICT_ORDER_OFF();
1440     ADD_EXPECT(igmp_listen_cmds::unlisten_cmd(hw_as_listen, hw_ifh.data(), gaddr));
1441     ADD_EXPECT(igmp_binding_cmds::unbind_cmd(hw_binding, hw_ifh.data()));
1442     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1443     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf3_name));
1444
1445     TRY_CHECK(OM::remove(Isaiah));
1446 }
1447
1448 BOOST_AUTO_TEST_CASE(test_arp_proxy) {
1449     VppInit vi;
1450     const std::string kurt = "KurtVonnegut";
1451     rc_t rc = rc_t::OK;
1452
1453     asio::ip::address_v4 low  = asio::ip::address_v4::from_string("10.0.0.0");
1454     asio::ip::address_v4 high = asio::ip::address_v4::from_string("10.0.0.255");
1455
1456     arp_proxy_config ap(low, high);
1457     HW::item<bool> hw_ap_cfg(true, rc_t::OK);
1458     ADD_EXPECT(arp_proxy_config_cmds::config_cmd(hw_ap_cfg, low, high));
1459     TRY_CHECK_RC(OM::write(kurt, ap));
1460
1461     std::string itf3_name = "host3";
1462     interface itf3(itf3_name,
1463                    interface::type_t::AFPACKET,
1464                    interface::admin_state_t::UP);
1465     HW::item<handle_t> hw_ifh(2, rc_t::OK);
1466     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1467     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf3_name));
1468     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1469     TRY_CHECK_RC(OM::write(kurt, itf3));
1470
1471     arp_proxy_binding *apb = new arp_proxy_binding(itf3);
1472     HW::item<bool> hw_binding(true, rc_t::OK);
1473     ADD_EXPECT(arp_proxy_binding_cmds::bind_cmd(hw_binding, hw_ifh.data()));
1474     TRY_CHECK_RC(OM::write(kurt, *apb));
1475
1476     delete apb;
1477
1478     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
1479                                                   rc_t::OK);
1480     STRICT_ORDER_OFF();
1481     ADD_EXPECT(arp_proxy_binding_cmds::unbind_cmd(hw_binding, hw_ifh.data()));
1482     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1483     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf3_name));
1484     ADD_EXPECT(arp_proxy_config_cmds::unconfig_cmd(hw_ap_cfg, low, high));
1485
1486     TRY_CHECK(OM::remove(kurt));
1487 }
1488
1489 BOOST_AUTO_TEST_CASE(test_ip_punt_redirect) {
1490     VppInit vi;
1491     const std::string eliot = "EliotReed";
1492     rc_t rc = rc_t::OK;
1493
1494     /*
1495      * Interface 1 is the tx interface
1496      */
1497     std::string itf1_name = "tx-itf";
1498     interface itf1(itf1_name,
1499                    interface::type_t::AFPACKET,
1500                    interface::admin_state_t::UP);
1501     HW::item<handle_t> hw_ifh(2, rc_t::OK);
1502     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1503     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1504     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1505     TRY_CHECK_RC(OM::write(eliot, itf1));
1506
1507     boost::asio::ip::address addr = boost::asio::ip::address::from_string("192.168.0.20");
1508
1509     /*
1510      * Interface 2 is the rx interface
1511      */
1512     std::string itf2_name = "rx-itf";
1513     interface itf2(itf2_name,
1514                    interface::type_t::AFPACKET,
1515                    interface::admin_state_t::UP);
1516
1517     HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1518     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1519     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
1520     TRY_CHECK_RC(OM::write(eliot, itf2));
1521
1522     ip_punt_redirect *ip_punt = new ip_punt_redirect(itf2, itf1, addr);
1523     HW::item<bool> hw_ip_cfg(true, rc_t::OK);
1524     HW::item<bool> hw_ip_uncfg(false, rc_t::OK);
1525     ADD_EXPECT(ip_punt_redirect_cmds::config_cmd(hw_ip_cfg, hw_ifh2.data(), hw_ifh.data(), addr));
1526     TRY_CHECK_RC(OM::write(eliot, *ip_punt));
1527
1528     delete ip_punt;
1529
1530     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1531     STRICT_ORDER_OFF();
1532     ADD_EXPECT(ip_punt_redirect_cmds::unconfig_cmd(hw_ip_uncfg, hw_ifh2.data(), hw_ifh.data(), addr));
1533     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1534     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1535     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
1536     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1537
1538     TRY_CHECK(OM::remove(eliot));
1539 }
1540
1541 BOOST_AUTO_TEST_CASE(test_ip_unnumbered) {
1542     VppInit vi;
1543     const std::string eric = "EricAmbler";
1544     rc_t rc = rc_t::OK;
1545
1546     /*
1547      * Interface 1 has the L3 address
1548      */
1549     std::string itf1_name = "host1";
1550     interface itf1(itf1_name,
1551                    interface::type_t::AFPACKET,
1552                    interface::admin_state_t::UP);
1553     HW::item<handle_t> hw_ifh(2, rc_t::OK);
1554     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1555     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1556     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1557     TRY_CHECK_RC(OM::write(eric, itf1));
1558
1559     route::prefix_t pfx_10("10.10.10.10", 24);
1560     l3_binding *l3 = new l3_binding(itf1, pfx_10);
1561     HW::item<bool> hw_l3_bind(true, rc_t::OK);
1562     HW::item<bool> hw_l3_unbind(false, rc_t::OK);
1563     ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10));
1564     TRY_CHECK_RC(OM::write(eric, *l3));
1565
1566     /*
1567      * Interface 2 is unnumbered
1568      */
1569     std::string itf2_name = "host2";
1570     interface itf2(itf2_name,
1571                    interface::type_t::AFPACKET,
1572                    interface::admin_state_t::UP);
1573
1574     HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1575     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1576     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
1577     TRY_CHECK_RC(OM::write(eric, itf2));
1578
1579     ip_unnumbered *ipun = new ip_unnumbered(itf2, itf1);
1580     HW::item<bool> hw_ip_cfg(true, rc_t::OK);
1581     HW::item<bool> hw_ip_uncfg(false, rc_t::OK);
1582     ADD_EXPECT(ip_unnumbered_cmds::config_cmd(hw_ip_cfg, hw_ifh2.data(), hw_ifh.data()));
1583     TRY_CHECK_RC(OM::write(eric, *ipun));
1584
1585     delete l3;
1586     delete ipun;
1587
1588     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1589     STRICT_ORDER_OFF();
1590     ADD_EXPECT(ip_unnumbered_cmds::unconfig_cmd(hw_ip_uncfg, hw_ifh2.data(), hw_ifh.data()));
1591     ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10));
1592     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
1593     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1594     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1595     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1596
1597     TRY_CHECK(OM::remove(eric));
1598 }
1599
1600 BOOST_AUTO_TEST_CASE(test_ip6nd) {
1601     VppInit vi;
1602     const std::string paulo = "PauloCoelho";
1603     rc_t rc = rc_t::OK;
1604
1605     /*
1606      * ra config
1607      */
1608     std::string itf_name = "host_ip6nd";
1609     interface itf(itf_name,
1610                    interface::type_t::AFPACKET,
1611                    interface::admin_state_t::UP);
1612     HW::item<handle_t> hw_ifh(3, rc_t::OK);
1613     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1614     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf_name));
1615     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1616     TRY_CHECK_RC(OM::write(paulo, itf));
1617
1618     route::prefix_t pfx_10("fd8f:69d8:c12c:ca62::3", 128);
1619     l3_binding *l3 = new l3_binding(itf, pfx_10);
1620     HW::item<bool> hw_l3_bind(true, rc_t::OK);
1621     HW::item<bool> hw_l3_unbind(false, rc_t::OK);
1622     ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10));
1623     TRY_CHECK_RC(OM::write(paulo, *l3));
1624
1625     ra_config ra(0, 1, 0, 4);
1626     ip6nd_ra_config *ip6ra = new ip6nd_ra_config(itf, ra);
1627     HW::item<bool> hw_ip6nd_ra_config_config(true, rc_t::OK);
1628     HW::item<bool> hw_ip6nd_ra_config_unconfig(false, rc_t::OK);
1629     ADD_EXPECT(ip6nd_ra_config::config_cmd(hw_ip6nd_ra_config_config, hw_ifh.data(), ra));
1630     TRY_CHECK_RC(OM::write(paulo, *ip6ra));
1631
1632     /*
1633      * ra prefix
1634      */
1635     ra_prefix ra_pfx(pfx_10, 0, 0, 2592000, 604800);
1636     ip6nd_ra_prefix *ip6pfx = new ip6nd_ra_prefix(itf, ra_pfx);
1637     HW::item<bool> hw_ip6nd_ra_prefix_config(true, rc_t::OK);
1638     HW::item<bool> hw_ip6nd_ra_prefix_unconfig(false, rc_t::OK);
1639     ADD_EXPECT(ip6nd_ra_prefix::config_cmd(hw_ip6nd_ra_prefix_config, hw_ifh.data(), ra_pfx));
1640     TRY_CHECK_RC(OM::write(paulo, *ip6pfx));
1641
1642     delete ip6pfx;
1643
1644     ADD_EXPECT(ip6nd_ra_prefix::unconfig_cmd(hw_ip6nd_ra_prefix_unconfig, hw_ifh.data(), ra_pfx));
1645
1646     delete ip6ra;
1647     delete l3;
1648
1649     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1650
1651     STRICT_ORDER_OFF();
1652     ADD_EXPECT(ip6nd_ra_config::unconfig_cmd(hw_ip6nd_ra_config_unconfig, hw_ifh.data(), ra));
1653     ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10));
1654     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1655     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf_name));
1656
1657     TRY_CHECK(OM::remove(paulo));
1658 }
1659
1660 BOOST_AUTO_TEST_CASE(test_interface_span) {
1661     VppInit vi;
1662     const std::string elif = "ElifShafak";
1663     rc_t rc = rc_t::OK;
1664
1665     /*
1666      * Interface 1 to be mirrored
1667      */
1668     std::string itf1_name = "port-from";
1669     interface itf1(itf1_name,
1670                    interface::type_t::AFPACKET,
1671                    interface::admin_state_t::UP);
1672     HW::item<handle_t> hw_ifh(2, rc_t::OK);
1673     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1674     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1675     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1676     TRY_CHECK_RC(OM::write(elif, itf1));
1677
1678     /*
1679      * Interface 2 where traffic is mirrored
1680      */
1681     std::string itf2_name = "port-to";
1682     interface itf2(itf2_name,
1683                    interface::type_t::AFPACKET,
1684                    interface::admin_state_t::UP);
1685
1686     HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1687     HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK);
1688
1689     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1690     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2));
1691     TRY_CHECK_RC(OM::write(elif, itf2));
1692
1693     interface_span *itf_span = new interface_span(itf1, itf2, interface_span::state_t::TX_RX_ENABLED);
1694     HW::item<bool> hw_is_cfg(true, rc_t::OK);
1695     HW::item<bool> hw_is_uncfg(true, rc_t::OK);
1696     ADD_EXPECT(interface_span_cmds::config_cmd(hw_is_cfg, hw_ifh.data(), hw_ifh2.data(), interface_span::state_t::TX_RX_ENABLED));
1697     TRY_CHECK_RC(OM::write(elif, *itf_span));
1698
1699     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1700     HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK);
1701
1702     delete itf_span;
1703     STRICT_ORDER_OFF();
1704     ADD_EXPECT(interface_span_cmds::unconfig_cmd(hw_is_uncfg, hw_ifh.data(), hw_ifh2.data()));
1705     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1706     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1707     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2));
1708     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1709
1710     TRY_CHECK(OM::remove(elif));
1711 }
1712
1713 BOOST_AUTO_TEST_CASE(test_routing) {
1714     VppInit vi;
1715     const std::string ian = "IanFleming";
1716     rc_t rc = rc_t::OK;
1717
1718     /*
1719      * non-default route domain
1720      */
1721     route_domain rd4(1);
1722     HW::item<bool> hw_rd4_create(true, rc_t::OK);
1723     HW::item<bool> hw_rd4_delete(false, rc_t::OK);
1724     HW::item<bool> hw_rd6_create(true, rc_t::OK);
1725     HW::item<bool> hw_rd6_delete(false, rc_t::OK);
1726     HW::item<route::table_id_t> hw_rd4_bind(1, rc_t::OK);
1727     HW::item<route::table_id_t> hw_rd4_unbind(route::DEFAULT_TABLE, rc_t::OK);
1728     HW::item<route::table_id_t> hw_rd6_bind(1, rc_t::OK);
1729     HW::item<route::table_id_t> hw_rd7_unbind(route::DEFAULT_TABLE, rc_t::OK);
1730     ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd4_create, l3_proto_t::IPV4, 1));
1731     ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd6_create, l3_proto_t::IPV6, 1));
1732     TRY_CHECK_RC(OM::write(ian, rd4));
1733
1734     /*
1735      * a couple of interfaces
1736      */
1737     std::string itf1_name = "af1";
1738     interface itf1(itf1_name,
1739                    interface::type_t::AFPACKET,
1740                    interface::admin_state_t::UP);
1741     HW::item<handle_t> hw_ifh(2, rc_t::OK);
1742     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1743     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1744     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1745     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1746     TRY_CHECK_RC(OM::write(ian, itf1));
1747
1748     std::string itf2_name = "af2";
1749     interface *itf2 = new interface(itf2_name,
1750                                     interface::type_t::AFPACKET,
1751                                     interface::admin_state_t::UP,
1752                                     rd4);
1753
1754     HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1755     HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK);
1756     HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK);
1757     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1758     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2));
1759     ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_bind, l3_proto_t::IPV4, hw_ifh2));
1760     ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_bind, l3_proto_t::IPV6, hw_ifh2));
1761     TRY_CHECK_RC(OM::write(ian, *itf2));
1762
1763     /*
1764      * prefix on each interface
1765      */
1766     route::prefix_t pfx_10("10.10.10.10", 24);
1767     l3_binding *l3_10 = new l3_binding(itf1, pfx_10);
1768     HW::item<bool> hw_l3_10_bind(true, rc_t::OK);
1769     HW::item<bool> hw_l3_10_unbind(false, rc_t::OK);
1770     ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_10_bind, hw_ifh.data(), pfx_10));
1771     TRY_CHECK_RC(OM::write(ian, *l3_10));
1772     route::prefix_t pfx_11("11.11.11.11", 24);
1773     l3_binding *l3_11 = new l3_binding(*itf2, pfx_11);
1774     HW::item<bool> hw_l3_11_bind(true, rc_t::OK);
1775     HW::item<bool> hw_l3_11_unbind(false, rc_t::OK);
1776     ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_11_bind, hw_ifh2.data(), pfx_11));
1777     TRY_CHECK_RC(OM::write(ian, *l3_11));
1778
1779     /*
1780      * A route via interface 1 in the default table
1781      */
1782     route::prefix_t pfx_5("5.5.5.5", 32);
1783     boost::asio::ip::address nh_9 = boost::asio::ip::address::from_string("10.10.10.9");
1784     route::path *path_9 = new route::path(nh_9, itf1);
1785     boost::asio::ip::address nh_10 = boost::asio::ip::address::from_string("10.10.10.11");
1786     route::path *path_10 = new route::path(nh_10, itf1);
1787     route::ip_route *route_5 = new route::ip_route(pfx_5);
1788     route_5->add(*path_10);
1789     route_5->add(*path_9);
1790     route::path_list_t pl_9_10 = {*path_9, *path_10};
1791     HW::item<handle_t> hw_route_5(0, rc_t::OK);
1792     ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5, 0, pfx_5, pl_9_10));
1793     TRY_CHECK_RC(OM::write(ian, *route_5));
1794
1795     route_5->remove(*path_9);
1796     route::path_list_t pl_10 = {*path_10};
1797     ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5, 0, pfx_5, pl_10));
1798     TRY_CHECK_RC(OM::write(ian, *route_5));
1799
1800     delete path_9;
1801
1802     /*
1803      * A route via interface 2 in the non-default table
1804      */
1805     boost::asio::ip::address nh_11 = boost::asio::ip::address::from_string("11.11.11.10");
1806     route::path *path_11 = new route::path(nh_11, *itf2);
1807     boost::asio::ip::address nh_12 = boost::asio::ip::address::from_string("11.11.11.12");
1808     route::path *path_12 = new route::path(nh_12, *itf2);
1809     route::ip_route *route_5_2 = new route::ip_route(rd4, pfx_5);
1810     route::path_list_t pl_11 = {*path_11};
1811     route_5_2->add(*path_11);
1812     HW::item<handle_t> hw_route_5_2(1, rc_t::OK);
1813     ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5_2, 1, pfx_5, pl_11));
1814     TRY_CHECK_RC(OM::write(ian, *route_5_2));
1815
1816     route::path_list_t pl_11_12 = {*path_11, *path_12};
1817     route_5_2->add(*path_12);
1818     ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5_2, 1, pfx_5, pl_11_12));
1819     TRY_CHECK_RC(OM::write(ian, *route_5_2));
1820
1821     /*
1822      * An ARP entry for the neighbour on itf1
1823      */
1824     HW::item<handle_t> hw_neighbour(0, rc_t::OK);
1825     mac_address_t mac_n({0,1,2,4,5,6});
1826     neighbour *ne = new neighbour(itf1, nh_10, mac_n);
1827     ADD_EXPECT(neighbour_cmds::create_cmd(hw_neighbour, hw_ifh.data(),
1828                                           mac_n, nh_10,
1829                                           neighbour::flags_t::STATIC));
1830     TRY_CHECK_RC(OM::write(ian, *ne));
1831
1832     /*
1833      * A DVR route
1834      */
1835     route::prefix_t pfx_6("6.6.6.6", 32);
1836     route::path *path_13 = new route::path(*itf2, nh_proto_t::ETHERNET);
1837     route::ip_route *route_dvr = new route::ip_route(pfx_6);
1838     route_dvr->add(*path_13);
1839     route::path_list_t pl_13 = {*path_13};
1840     HW::item<handle_t> hw_route_dvr(2, rc_t::OK);
1841     ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_dvr, 0, pfx_6, pl_13));
1842     TRY_CHECK_RC(OM::write(ian, *route_dvr));
1843
1844     /*
1845      * a multicast route
1846      */
1847     route::mprefix_t mpfx_4(boost::asio::ip::address::from_string("232.1.1.1"), 32);
1848     route::ip_mroute *mroute_4 = new route::ip_mroute(mpfx_4);
1849
1850     route::path *mp1 = new route::path(itf1, nh_proto_t::IPV4);
1851     route::path *mp2 = new route::path(*itf2, nh_proto_t::IPV4);
1852     mroute_4->add(*mp1, route::itf_flags_t::FORWARD);
1853     mroute_4->add(*mp1, route::itf_flags_t::ACCEPT);
1854     mroute_4->add(*mp2, route::itf_flags_t::FORWARD);
1855     HW::item<bool> hw_mroute_4(true, rc_t::OK);
1856     ADD_EXPECT(route::ip_mroute_cmds::update_cmd(hw_mroute_4, 0, mpfx_4,
1857                                                  *mp1, route::itf_flags_t::FORWARD));
1858     ADD_EXPECT(route::ip_mroute_cmds::update_cmd(hw_mroute_4, 0, mpfx_4,
1859                                                  *mp2, route::itf_flags_t::FORWARD));
1860     ADD_EXPECT(route::ip_mroute_cmds::update_cmd(hw_mroute_4, 0, mpfx_4,
1861                                                  *mp1, route::itf_flags_t::ACCEPT));
1862     TRY_CHECK_RC(OM::write(ian, *mroute_4));
1863
1864     STRICT_ORDER_OFF();
1865     // delete the stack objects that hold references to others
1866     // so the OM::remove is the call that removes the last reference
1867     delete l3_11;
1868     delete l3_10;
1869     delete itf2;
1870     delete route_5;
1871     delete route_5_2;
1872     delete route_dvr;
1873     delete ne;
1874     delete mroute_4;
1875
1876     ADD_EXPECT(route::ip_mroute_cmds::delete_cmd(hw_mroute_4, 0, mpfx_4,
1877                                                  *mp1, route::itf_flags_t::FORWARD));
1878     ADD_EXPECT(route::ip_mroute_cmds::delete_cmd(hw_mroute_4, 0, mpfx_4,
1879                                                  *mp2, route::itf_flags_t::FORWARD));
1880     ADD_EXPECT(route::ip_mroute_cmds::delete_cmd(hw_mroute_4, 0, mpfx_4,
1881                                                  *mp1, route::itf_flags_t::ACCEPT));
1882
1883     delete mp1;
1884     delete mp2;
1885
1886     ADD_EXPECT(neighbour_cmds::delete_cmd(hw_neighbour, hw_ifh.data(),
1887                                           mac_n, nh_10,
1888                                           neighbour::flags_t::STATIC));
1889     ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_dvr, 0, pfx_6));
1890     ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5_2, 1, pfx_5));
1891     ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5, 0, pfx_5));
1892
1893     delete path_10;
1894     delete path_11;
1895     delete path_12;
1896     delete path_13;
1897     pl_9_10.clear();
1898     pl_10.clear();
1899     pl_13.clear();
1900     pl_11_12.clear();
1901     pl_11.clear();
1902
1903     ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_10_unbind, hw_ifh.data(), pfx_10));
1904     ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_11_unbind, hw_ifh2.data(), pfx_11));
1905     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1906     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1907     ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV4, hw_ifh2));
1908     ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV6, hw_ifh2));
1909     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2));
1910     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1911     ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd4_delete, l3_proto_t::IPV4, 1));
1912     ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd6_delete, l3_proto_t::IPV6, 1));
1913
1914     TRY_CHECK(OM::remove(ian));
1915 }
1916
1917 BOOST_AUTO_TEST_CASE(test_nat) {
1918     VppInit vi;
1919     const std::string gs = "GeorgeSimenon";
1920     rc_t rc = rc_t::OK;
1921
1922     /*
1923      * Inside Interface
1924      */
1925     std::string itf_in_name = "inside";
1926     interface itf_in(itf_in_name,
1927                      interface::type_t::AFPACKET,
1928                      interface::admin_state_t::UP);
1929     HW::item<handle_t> hw_ifh(2, rc_t::OK);
1930     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1931     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1932     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf_in_name));
1933     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1934     TRY_CHECK_RC(OM::write(gs, itf_in));
1935
1936     /*
1937      * outside
1938      */
1939     std::string itf_out_name = "port-to";
1940     interface itf_out(itf_out_name,
1941                    interface::type_t::AFPACKET,
1942                    interface::admin_state_t::UP);
1943
1944     HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1945     HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK);
1946     HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK);
1947
1948     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf_out_name));
1949     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2));
1950     TRY_CHECK_RC(OM::write(gs, itf_out));
1951
1952     /*
1953      * A NAT static mapping
1954      */
1955     boost::asio::ip::address in_addr = boost::asio::ip::address::from_string("10.0.0.1");
1956     boost::asio::ip::address_v4 out_addr = boost::asio::ip::address_v4::from_string("1.1.1.1");
1957
1958     nat_static ns(in_addr, out_addr);
1959     HW::item<bool> hw_ns(true, rc_t::OK);
1960
1961     ADD_EXPECT(nat_static_cmds::create_44_cmd(hw_ns, 0, in_addr.to_v4(), out_addr));
1962     TRY_CHECK_RC(OM::write(gs, ns));
1963
1964     /*
1965      * bind nat inside and out
1966      */
1967     nat_binding *nb_in = new nat_binding(itf_in,
1968                                          direction_t::INPUT,
1969                                          l3_proto_t::IPV4,
1970                                          nat_binding::zone_t::INSIDE);
1971     HW::item<bool> hw_nb_in(true, rc_t::OK);
1972
1973     ADD_EXPECT(nat_binding_cmds::bind_44_input_cmd(hw_nb_in,
1974                                                    hw_ifh.data().value(),
1975                                                    nat_binding::zone_t::INSIDE));
1976     TRY_CHECK_RC(OM::write(gs, *nb_in));
1977
1978     nat_binding *nb_out = new nat_binding(itf_out,
1979                                           direction_t::INPUT,
1980                                           l3_proto_t::IPV4,
1981                                           nat_binding::zone_t::OUTSIDE);
1982     HW::item<bool> hw_nb_out(true, rc_t::OK);
1983
1984     ADD_EXPECT(nat_binding_cmds::bind_44_input_cmd(hw_nb_out,
1985                                                    hw_ifh2.data().value(),
1986                                                    nat_binding::zone_t::OUTSIDE));
1987     TRY_CHECK_RC(OM::write(gs, *nb_out));
1988
1989
1990     STRICT_ORDER_OFF();
1991     delete nb_in;
1992     delete nb_out;
1993     ADD_EXPECT(nat_binding_cmds::unbind_44_input_cmd(hw_nb_in,
1994                                                      hw_ifh.data().value(),
1995                                                      nat_binding::zone_t::INSIDE));
1996     ADD_EXPECT(nat_binding_cmds::unbind_44_input_cmd(hw_nb_out,
1997                                                      hw_ifh2.data().value(),
1998                                                      nat_binding::zone_t::OUTSIDE));
1999     ADD_EXPECT(nat_static_cmds::delete_44_cmd(hw_ns, 0, in_addr.to_v4(), out_addr));
2000     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
2001     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf_in_name));
2002     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2));
2003     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf_out_name));
2004
2005     TRY_CHECK(OM::remove(gs));
2006 }
2007
2008 BOOST_AUTO_TEST_CASE(test_interface_events) {
2009     VppInit vi;
2010     MockListener ml;
2011
2012     HW::item<bool> hw_want(true, rc_t::OK);
2013
2014     ADD_EXPECT(interface_cmds::events_cmd(ml));
2015     cmd* itf = new interface_cmds::events_cmd(ml);
2016
2017     HW::enqueue(itf);
2018     HW::write();
2019 }
2020
2021 BOOST_AUTO_TEST_CASE(test_interface_route_domain_change) {
2022     VppInit vi;
2023     const std::string rene = "ReneGoscinny";
2024     rc_t rc = rc_t::OK;
2025
2026     /*
2027      * Create an interface with two IP addresses
2028      */
2029     std::string itf1_name = "host1";
2030     interface itf1(itf1_name,
2031                    interface::type_t::AFPACKET,
2032                    interface::admin_state_t::UP);
2033     HW::item<handle_t> hw_ifh1(2, rc_t::OK);
2034     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
2035     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
2036     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh1, itf1_name));
2037     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh1));
2038     TRY_CHECK_RC(OM::write(rene, itf1));
2039
2040     route::prefix_t pfx_10("10.10.10.10", 24);
2041     l3_binding *l3_1 = new l3_binding(itf1, pfx_10);
2042     HW::item<bool> hw_l3_bind1(true, rc_t::OK);
2043     HW::item<bool> hw_l3_unbind1(false, rc_t::OK);
2044     ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10));
2045     TRY_CHECK_RC(OM::write(rene, *l3_1));
2046
2047     route::prefix_t pfx_11("10.10.11.11", 24);
2048     l3_binding *l3_2 = new l3_binding(itf1, pfx_11);
2049     HW::item<bool> hw_l3_bind2(true, rc_t::OK);
2050     HW::item<bool> hw_l3_unbind2(false, rc_t::OK);
2051     ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11));
2052     TRY_CHECK_RC(OM::write(rene, *l3_2));
2053
2054     route_domain rd(1);
2055     HW::item<bool> hw_rd_create(true, rc_t::OK);
2056     HW::item<bool> hw_rd_delete(false, rc_t::OK);
2057     HW::item<route::table_id_t> hw_rd_bind(1, rc_t::OK);
2058     HW::item<route::table_id_t> hw_rd_unbind(route::DEFAULT_TABLE, rc_t::OK);
2059     ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd_create, l3_proto_t::IPV4, 1));
2060     ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd_create, l3_proto_t::IPV6, 1));
2061     TRY_CHECK_RC(OM::write(rene, rd));
2062
2063     /*
2064      * update the interface to change to a new route-domain
2065      * expect that the l3-bindings are removed and readded.
2066      */
2067     interface *itf2 = new interface(itf1_name,
2068                                     interface::type_t::AFPACKET,
2069                                     interface::admin_state_t::UP,
2070                                     rd);
2071     ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10));
2072     ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11));
2073     ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_bind, l3_proto_t::IPV4, hw_ifh1));
2074     ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_bind, l3_proto_t::IPV6, hw_ifh1));
2075     ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10));
2076     ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11));
2077     TRY_CHECK_RC(OM::write(rene, *itf2));
2078
2079     /*
2080      * mve the interface back to the default route-domain
2081      */
2082     interface itf3(itf1_name,
2083                    interface::type_t::AFPACKET,
2084                    interface::admin_state_t::UP);
2085     ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10));
2086     ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11));
2087     ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_unbind, l3_proto_t::IPV4, hw_ifh1));
2088     ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_unbind, l3_proto_t::IPV6, hw_ifh1));
2089     ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10));
2090     ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11));
2091     TRY_CHECK_RC(OM::write(rene, itf3));
2092
2093     delete l3_1;
2094     delete l3_2;
2095     delete itf2;
2096
2097     STRICT_ORDER_OFF();
2098     ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10));
2099     ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11));
2100     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh1));
2101     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh1, itf1_name));
2102     ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd_delete, l3_proto_t::IPV4, 1));
2103     ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd_delete, l3_proto_t::IPV6, 1));
2104
2105     TRY_CHECK(OM::remove(rene));
2106 }
2107
2108 BOOST_AUTO_TEST_CASE(test_prefixes) {
2109     route::prefix_t p6_s_16(boost::asio::ip::address::from_string("2001::"), 16);
2110
2111     BOOST_CHECK(p6_s_16.mask() == boost::asio::ip::address::from_string("ffff::"));
2112
2113     route::prefix_t p6_s_17(boost::asio::ip::address::from_string("2001:ff00::"), 17);
2114
2115     BOOST_CHECK(p6_s_17.mask() == boost::asio::ip::address::from_string("ffff:8000::"));
2116     BOOST_CHECK(p6_s_17.low().address() == boost::asio::ip::address::from_string("2001:8000::"));
2117
2118     route::prefix_t p6_s_15(boost::asio::ip::address::from_string("2001:ff00::"), 15);
2119     BOOST_CHECK(p6_s_15.mask() == boost::asio::ip::address::from_string("fffe::"));
2120     BOOST_CHECK(p6_s_15.low().address() == boost::asio::ip::address::from_string("2000::"));
2121
2122     route::prefix_t p4_s_16(boost::asio::ip::address::from_string("192.168.0.0"), 16);
2123
2124     BOOST_CHECK(p4_s_16.mask() == boost::asio::ip::address::from_string("255.255.0.0"));
2125
2126     route::prefix_t p4_s_17(boost::asio::ip::address::from_string("192.168.127.0"), 17);
2127
2128     BOOST_CHECK(p4_s_17.mask() == boost::asio::ip::address::from_string("255.255.128.0"));
2129     BOOST_CHECK(p4_s_17.low().address() == boost::asio::ip::address::from_string("192.168.0.0"));
2130     BOOST_CHECK(p4_s_17.high().address() == boost::asio::ip::address::from_string("192.168.127.255"));
2131
2132     route::prefix_t p4_s_15(boost::asio::ip::address::from_string("192.168.255.255"), 15);
2133
2134     BOOST_CHECK(p4_s_15.mask() == boost::asio::ip::address::from_string("255.254.0.0"));
2135     BOOST_CHECK(p4_s_15.low().address() == boost::asio::ip::address::from_string("192.168.0.0"));
2136     BOOST_CHECK(p4_s_15.high().address() == boost::asio::ip::address::from_string("192.169.255.255"));
2137
2138     route::prefix_t p4_s_32(boost::asio::ip::address::from_string("192.168.1.1"), 32);
2139
2140     BOOST_CHECK(p4_s_32.mask() == boost::asio::ip::address::from_string("255.255.255.255"));
2141     BOOST_CHECK(p4_s_32.low().address() == boost::asio::ip::address::from_string("192.168.1.1"));
2142     BOOST_CHECK(p4_s_32.high().address() == boost::asio::ip::address::from_string("192.168.1.1"));
2143
2144 }
2145
2146 BOOST_AUTO_TEST_CASE(test_pipes) {
2147     VppInit vi;
2148     const std::string gk = "GKChesterton";
2149
2150     const std::string pipe_name_1 = "pipe1";
2151     VOM::pipe pipe1(1, interface::admin_state_t::UP);
2152     HW::item<handle_t> hw_hdl(4, rc_t::OK);
2153     HW::item<pipe::handle_pair_t> hw_hdl_pair(std::make_pair(5,6), rc_t::OK);
2154
2155     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP,
2156                                                 rc_t::OK);
2157     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
2158                                                   rc_t::OK);
2159     ADD_EXPECT(pipe_cmds::create_cmd(hw_hdl, pipe_name_1, 1, hw_hdl_pair));
2160     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_hdl));
2161     TRY_CHECK_RC(OM::write(gk, pipe1));
2162
2163     pipe1.set_ends(hw_hdl_pair.data());
2164
2165     // put each end of the pipe in a BD
2166     bridge_domain bd1(33, bridge_domain::learning_mode_t::OFF,
2167                       bridge_domain::arp_term_mode_t::OFF,
2168                       bridge_domain::arp_ufwd_mode_t::ON,
2169                       bridge_domain::flood_mode_t::OFF,
2170                       bridge_domain::uu_flood_mode_t::ON,
2171                       bridge_domain::mac_age_mode_t::ON);
2172
2173     HW::item<uint32_t> hw_bd(33, rc_t::OK);
2174     ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd,
2175                                               bridge_domain::learning_mode_t::OFF,
2176                                               bridge_domain::arp_term_mode_t::OFF,
2177                                               bridge_domain::arp_ufwd_mode_t::ON,
2178                                               bridge_domain::flood_mode_t::OFF,
2179                                               bridge_domain::uu_flood_mode_t::ON,
2180                                               bridge_domain::mac_age_mode_t::ON));
2181
2182     TRY_CHECK_RC(OM::write(gk, bd1));
2183
2184     l2_binding *l2_1 = new l2_binding(*pipe1.east(), bd1);
2185     HW::item<bool> hw_l2_1_bind(true, rc_t::OK);
2186
2187     ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_1_bind,
2188                                          pipe1.east()->handle(),
2189                                          hw_bd.data(),
2190                                          l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
2191     TRY_CHECK_RC(OM::write(gk, *l2_1));
2192
2193     l2_binding *l2_2 = new l2_binding(*pipe1.west(), bd1);
2194     HW::item<bool> hw_l2_2_bind(true, rc_t::OK);
2195
2196     ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_2_bind,
2197                                          pipe1.west()->handle(),
2198                                          hw_bd.data(),
2199                                          l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
2200     TRY_CHECK_RC(OM::write(gk, *l2_2));
2201
2202     STRICT_ORDER_OFF();
2203
2204     delete l2_1;
2205     delete l2_2;
2206     ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_1_bind,
2207                                            pipe1.east()->handle(),
2208                                            hw_bd.data(),
2209                                            l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
2210     ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_1_bind,
2211                                            pipe1.west()->handle(),
2212                                            hw_bd.data(),
2213                                            l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
2214     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_hdl));
2215     ADD_EXPECT(pipe_cmds::delete_cmd(hw_hdl, hw_hdl_pair));
2216     ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
2217     TRY_CHECK(OM::remove(gk));
2218 }
2219
2220 BOOST_AUTO_TEST_CASE(test_qos) {
2221     VppInit vi;
2222     const std::string albert = "AlbertCamus";
2223     rc_t rc = rc_t::OK;
2224
2225     /*
2226      * Create an interface on which to enable QoS
2227      */
2228     std::string itf_name = "host1";
2229     interface itf(itf_name,
2230                   interface::type_t::AFPACKET,
2231                   interface::admin_state_t::UP);
2232     HW::item<handle_t> hw_ifh(2, rc_t::OK);
2233     HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
2234     HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
2235     ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf_name));
2236     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
2237     TRY_CHECK_RC(OM::write(albert, itf));
2238
2239     QoS::map::outputs_t out;
2240     out[0][5] = 5;
2241     out[3][6] = 6;
2242
2243     QoS::map qem(1, out);
2244
2245     HW::item<bool> hw_qem(true, rc_t::OK);
2246     ADD_EXPECT(QoS::map_cmds::create_cmd(hw_qem, 1, out));
2247     TRY_CHECK_RC(OM::write(albert, qem));
2248
2249     QoS::record *qr = new QoS::record(itf, QoS::source_t::IP);
2250     HW::item<bool> hw_qr(true, rc_t::OK);
2251     ADD_EXPECT(QoS::record_cmds::create_cmd(hw_qr, hw_ifh.data(), QoS::source_t::IP));
2252     TRY_CHECK_RC(OM::write(albert, *qr));
2253
2254     QoS::mark *qm = new QoS::mark(itf, qem, QoS::source_t::IP);
2255     HW::item<bool> hw_qm(true, rc_t::OK);
2256     ADD_EXPECT(QoS::mark_cmds::create_cmd(hw_qm, hw_ifh.data(), 1, QoS::source_t::IP));
2257     TRY_CHECK_RC(OM::write(albert, *qm));
2258
2259     delete qr;
2260     delete qm;
2261     ADD_EXPECT(QoS::mark_cmds::delete_cmd(hw_qm, hw_ifh.data(), QoS::source_t::IP));
2262     ADD_EXPECT(QoS::map_cmds::delete_cmd(hw_qem, 1));
2263     ADD_EXPECT(QoS::record_cmds::delete_cmd(hw_qr, hw_ifh.data(), QoS::source_t::IP));
2264     ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
2265     ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf_name));
2266     TRY_CHECK(OM::remove(albert));
2267 }
2268
2269 BOOST_AUTO_TEST_SUITE_END()