]> git.stg.codes - ssmd.git/commitdiff
Minor fix
authorMaxim Mamontov <faust.madf@gmail.com>
Mon, 28 Nov 2011 09:33:39 +0000 (11:33 +0200)
committerMaxim Mamontov <faust.madf@gmail.com>
Mon, 28 Nov 2011 09:33:39 +0000 (11:33 +0200)
include/acl.h
src/acl.cpp
src/switch.cpp

index 468671f00c0af9762e61fb95060046aa3267af74..f2754466c8e112d4c6517dee44fb8506ef8037ea 100644 (file)
@@ -2,6 +2,7 @@
 #define __GTS_ACL_H__
 
 #include <string>
+#include <ostream>
 
 class Pdu;
 
@@ -43,8 +44,12 @@ class ACL {
         bool _isUpload;
 
         std::string getSuffix() const;
+
+        friend std::ostream & operator<<(std::ostream & stream, const ACL & acl);
 };
 
+std::ostream & operator<<(std::ostream & stream, const GTS::ACL & acl);
+
 }
 
 #endif
index 08f0405cef24de540f2f0111682ba36e3418bee6..a882182de03917982627ce9f88fc19394a4b9a17 100644 (file)
@@ -106,6 +106,42 @@ void ACL::appendPdu(Pdu & pdu) const
     pdu += vb;*/
 }
 
+std::ostream & GTS::operator<<(std::ostream & stream, const ACL & acl)
+{
+    std::string oidValue;
+    // MAC
+    if (acl._isUpload) {
+        oidValue = swACLEtherRuleSrcMacAddress;
+        oidValue += acl.getSuffix();
+    } else {
+        oidValue = swACLEtherRuleDstMacAddress;
+        oidValue += acl.getSuffix();
+    }
+    stream << oidValue << ":" << acl._mac << " ";
+
+    // Permit rule
+    oidValue = swACLEtherRulePermit;
+    oidValue += acl.getSuffix();
+    stream << oidValue << ":" << 2 << " ";
+
+    // Port
+    oidValue = swACLEtherRulePort;
+    oidValue += acl.getSuffix();
+    stream << oidValue << ":" << acl._port << " ";
+
+    // Shape
+    oidValue = swACLEtherRuleRxRate;
+    oidValue += acl.getSuffix();
+    stream << oidValue << ":" << acl._shape << " ";
+
+    // Create ACL
+    oidValue = swACLEtherRuleRowStatus;
+    oidValue += acl.getSuffix();
+    stream << oidValue << ":" << 4;
+
+    return stream;
+}
+
 inline
 std::string ACL::getSuffix() const
 {
index db8a1be6227dae9953e680bc2771f944610fc5b6..01024a13d4d8e5b60bf8fb55dba646a4846cbe69 100644 (file)
@@ -231,14 +231,17 @@ bool Switch::dropACLsByTable(const CTarget & target, unsigned profileId, const S
 bool Switch::createACLs(const CTarget & target)
 {
     std::vector<ACL>::const_iterator it;
+    size_t pos = 0;
     for (it = _acls.begin(); it != _acls.end(); ++it) {
         Pdu pdu;
         it->appendPdu(pdu);
         if (int c = _snmp.set(pdu, target) != SNMP_CLASS_SUCCESS) {
-            logger << "Switch::createACLs() - failed to invoke Snmp::set for the switch '" << _ip << "'. Error message: '" << Snmp::error_msg(c) << "'" << std::endl;
+            logger << "Switch::createACLs() - failed to invoke Snmp::set for the switch '" << _ip << "'. Error message: '" << Snmp::error_msg(c) << "'. Error occured at creation of " << (pos + 1) << " from " << _acls.size() << " ACL's" << std::endl;
+            logger << "Switch::createACLs() - ACL dump: " << *it << std::endl;
             return false;
         }
         _aclsCreated = true;
+        ++pos;
     }
     return true;
 }