From 3c47eb51fb0eddb876f5b10bd33a4f2bedc3ee87 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Mon, 28 Nov 2011 11:33:39 +0200 Subject: [PATCH] Minor fix --- include/acl.h | 5 +++++ src/acl.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/switch.cpp | 5 ++++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/include/acl.h b/include/acl.h index 468671f..f275446 100644 --- a/include/acl.h +++ b/include/acl.h @@ -2,6 +2,7 @@ #define __GTS_ACL_H__ #include +#include 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 diff --git a/src/acl.cpp b/src/acl.cpp index 08f0405..a882182 100644 --- a/src/acl.cpp +++ b/src/acl.cpp @@ -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 { diff --git a/src/switch.cpp b/src/switch.cpp index db8a1be..01024a1 100644 --- a/src/switch.cpp +++ b/src/switch.cpp @@ -231,14 +231,17 @@ bool Switch::dropACLsByTable(const CTarget & target, unsigned profileId, const S bool Switch::createACLs(const CTarget & target) { std::vector::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; } -- 2.43.2