GBP: Sclass to src-epg conversions
[vpp.git] / extras / vom / vom / gbp_endpoint_group.cpp
index e63b09f..44bdcdb 100644 (file)
@@ -30,6 +30,7 @@ gbp_endpoint_group::gbp_endpoint_group(epg_id_t epg_id,
                                        const gbp_bridge_domain& bd)
   : m_hw(false)
   , m_epg_id(epg_id)
+  , m_sclass(0xffff)
   , m_itf(itf.singular())
   , m_rd(rd.singular())
   , m_bd(bd.singular())
@@ -41,6 +42,34 @@ gbp_endpoint_group::gbp_endpoint_group(epg_id_t epg_id,
                                        const gbp_bridge_domain& bd)
   : m_hw(false)
   , m_epg_id(epg_id)
+  , m_sclass(0xffff)
+  , m_itf()
+  , m_rd(rd.singular())
+  , m_bd(bd.singular())
+{
+}
+
+gbp_endpoint_group::gbp_endpoint_group(epg_id_t epg_id,
+                                       uint16_t sclass,
+                                       const interface& itf,
+                                       const gbp_route_domain& rd,
+                                       const gbp_bridge_domain& bd)
+  : m_hw(false)
+  , m_epg_id(epg_id)
+  , m_sclass(sclass)
+  , m_itf(itf.singular())
+  , m_rd(rd.singular())
+  , m_bd(bd.singular())
+{
+}
+
+gbp_endpoint_group::gbp_endpoint_group(epg_id_t epg_id,
+                                       uint16_t sclass,
+                                       const gbp_route_domain& rd,
+                                       const gbp_bridge_domain& bd)
+  : m_hw(false)
+  , m_epg_id(epg_id)
+  , m_sclass(sclass)
   , m_itf()
   , m_rd(rd.singular())
   , m_bd(bd.singular())
@@ -50,6 +79,7 @@ gbp_endpoint_group::gbp_endpoint_group(epg_id_t epg_id,
 gbp_endpoint_group::gbp_endpoint_group(const gbp_endpoint_group& epg)
   : m_hw(epg.m_hw)
   , m_epg_id(epg.m_epg_id)
+  , m_sclass(epg.m_sclass)
   , m_itf(epg.m_itf)
   , m_rd(epg.m_rd)
   , m_bd(epg.m_bd)
@@ -77,8 +107,8 @@ gbp_endpoint_group::id() const
 bool
 gbp_endpoint_group::operator==(const gbp_endpoint_group& gg) const
 {
-  return (key() == gg.key() && (m_itf == gg.m_itf) && (m_rd == gg.m_rd) &&
-          (m_bd == gg.m_bd));
+  return (key() == gg.key() && (m_sclass == gg.m_sclass) &&
+          (m_itf == gg.m_itf) && (m_rd == gg.m_rd) && (m_bd == gg.m_bd));
 }
 
 void
@@ -95,7 +125,7 @@ gbp_endpoint_group::replay()
 {
   if (m_hw) {
     HW::enqueue(new gbp_endpoint_group_cmds::create_cmd(
-      m_hw, m_epg_id, m_bd->id(), m_rd->id(),
+      m_hw, m_epg_id, m_sclass, m_bd->id(), m_rd->id(),
       (m_itf ? m_itf->handle() : handle_t::INVALID)));
   }
 }
@@ -105,8 +135,9 @@ gbp_endpoint_group::to_string() const
 {
   std::ostringstream s;
   s << "gbp-endpoint-group:["
-    << "epg:" << m_epg_id << ", " << (m_itf ? m_itf->to_string() : "NULL")
-    << ", " << m_bd->to_string() << ", " << m_rd->to_string() << "]";
+    << "epg:" << m_epg_id << ", sclass:" << m_sclass << ", "
+    << (m_itf ? m_itf->to_string() : "NULL") << ", " << m_bd->to_string()
+    << ", " << m_rd->to_string() << "]";
 
   return (s.str());
 }
@@ -116,7 +147,7 @@ gbp_endpoint_group::update(const gbp_endpoint_group& r)
 {
   if (rc_t::OK != m_hw.rc()) {
     HW::enqueue(new gbp_endpoint_group_cmds::create_cmd(
-      m_hw, m_epg_id, m_bd->id(), m_rd->id(),
+      m_hw, m_epg_id, m_sclass, m_bd->id(), m_rd->id(),
       (m_itf ? m_itf->handle() : handle_t::INVALID)));
   }
 }
@@ -194,12 +225,13 @@ gbp_endpoint_group::event_handler::handle_populate(const client_db::key_t& key)
                                 << payload.epg.bd_id << "]";
 
     if (itf && bd && rd) {
-      gbp_endpoint_group gbpe(payload.epg.epg_id, *itf, *rd, *bd);
+      gbp_endpoint_group gbpe(payload.epg.epg_id, payload.epg.sclass, *itf, *rd,
+                              *bd);
       OM::commit(key, gbpe);
 
       VOM_LOG(log_level_t::DEBUG) << "read: " << gbpe.to_string();
     } else if (bd && rd) {
-      gbp_endpoint_group gbpe(payload.epg.epg_id, *rd, *bd);
+      gbp_endpoint_group gbpe(payload.epg.epg_id, payload.epg.sclass, *rd, *bd);
       OM::commit(key, gbpe);
 
       VOM_LOG(log_level_t::DEBUG) << "read: " << gbpe.to_string();