]> git.stg.codes - ssmd.git/blobdiff - src/switch.cpp
Add max_acl_per_pdu param
[ssmd.git] / src / switch.cpp
index b70540294d9c1fa6ad4246366c17d9b99bb6e284..bf18aa3e227dd1e2006b1d9474bea0e83d47cb58 100644 (file)
@@ -174,24 +174,27 @@ bool Switch::dropACLsByTable(const CTarget & target, unsigned profileId, const S
     dropACLOidPrefix += ".";
     dropACLOidPrefix += boost::lexical_cast<std::string>(profileId);
     SNMPList aclsList(table.getList());
-    Pdu pdu;
-    SNMPList::const_iterator it;
-    for (it = aclsList.begin(); it != aclsList.end(); ++it) {
-        int id;
-        if (int c = it->get_value(id) != SNMP_CLASS_SUCCESS) {
-            logger << "Switch::dropACLsByTable() - failed to get ACL id for the switch '" << _ip << "'. Error message: '" << Snmp::error_msg(c) << "'" << std::endl;
+    SNMPList::const_iterator it(aclsList.begin());
+    size_t chunks = aclsList.size() / _settings.maxACLPerPDU() + 1;
+    for (size_t i = 0; i < chunks && it != aclsList.end(); ++i) {
+        Pdu pdu;
+        for (size_t j = 0; j < _settings.maxACLPerPDU() && it != aclsList.end(); ++j, ++it) {
+            int id;
+            if (int c = it->get_value(id) != SNMP_CLASS_SUCCESS) {
+                logger << "Switch::dropACLsByTable() - failed to get ACL id for the switch '" << _ip << "'. Error message: '" << Snmp::error_msg(c) << "'" << std::endl;
+                return false;
+            }
+            std::string dropACLOid(dropACLOidPrefix);
+            dropACLOid += ".";
+            dropACLOid += boost::lexical_cast<std::string>(id);
+            Vb vb(Oid(dropACLOid.c_str()));
+            vb.set_value(int(6));
+            pdu += vb;
+        }
+        if (int c = _snmp.set(pdu, target) != SNMP_CLASS_SUCCESS) {
+            logger << "Switch::dropACLsByTable() - failed to invoke Snmp::set for the switch '" << _ip << "'. Error message: '" << Snmp::error_msg(c) << "'" << std::endl;
             return false;
         }
-        std::string dropACLOid(dropACLOidPrefix);
-        dropACLOid += ".";
-        dropACLOid += boost::lexical_cast<std::string>(id);
-        Vb vb(Oid(dropACLOid.c_str()));
-        vb.set_value(int(6));
-        pdu += vb;
-    }
-    if (int c = _snmp.set(pdu, target) != SNMP_CLASS_SUCCESS) {
-        logger << "Switch::dropACLsByTable() - failed to invoke Snmp::set for the switch '" << _ip << "'. Error message: '" << Snmp::error_msg(c) << "'" << std::endl;
-        return false;
     }
     return true;
 }