[Guessnet-devel] [svn] r178 - in trunk: . src
Enrico Zini
enrico at costa.debian.org
Sat Sep 23 15:44:03 UTC 2006
Author: enrico
Date: Sat Sep 23 15:44:00 2006
New Revision: 178
Modified:
trunk/ (props changed)
trunk/src/GuessnetEnvironment.cc
Log:
r455 at viaza: enrico | 2006-09-23 16:43:38 +0100
Allow to have negated interfaces in the mapping stanza
Modified: trunk/src/GuessnetEnvironment.cc
==============================================================================
--- trunk/src/GuessnetEnvironment.cc (original)
+++ trunk/src/GuessnetEnvironment.cc Sat Sep 23 15:44:00 2006
@@ -194,10 +194,11 @@
{
protected:
set<string> ifupdownProfiles;
+ bool ifupdownProfilesMatchInverted;
public:
IfupdownEnvironment(wibble::commandline::GuessnetOptions& opt) :
- StandaloneEnvironment(opt)
+ StandaloneEnvironment(opt), ifupdownProfilesMatchInverted(false)
{
// We have a default config file name in ifupdown mode
if (configFile.empty())
@@ -259,8 +260,29 @@
else
{
Tokenizer t(line);
+ bool first = true;
for (string w = t.next(); !w.empty(); w = t.next())
- ifupdownProfiles.insert(w);
+ {
+ if (first)
+ {
+ ifupdownProfilesMatchInverted = w[0] == '!';
+ first = false;
+ }
+ if (w[0] == '!')
+ {
+ if (!ifupdownProfilesMatchInverted)
+ throw wibble::exception::Consistency(
+ "parsing list of interfaces to use",
+ "found negated interface "+w+" after a normal interface");
+ ifupdownProfiles.insert(w.substr(1));
+ } else {
+ if (ifupdownProfilesMatchInverted)
+ throw wibble::exception::Consistency(
+ "parsing list of interfaces to use",
+ "found normal interface "+w+" after negated interface");
+ ifupdownProfiles.insert(w);
+ }
+ }
}
line = string();
linenum++;
@@ -274,7 +296,11 @@
void IfupdownEnvironment::handleScan(const Scan* scan) throw ()
{
- if (ifupdownProfiles.size() == 0 || ifupdownProfiles.find(scan->name()) != ifupdownProfiles.end())
+ if (ifupdownProfiles.size() == 0)
+ _scans.push_back(scan);
+ else if (ifupdownProfilesMatchInverted && ifupdownProfiles.find(scan->name()) == ifupdownProfiles.end())
+ _scans.push_back(scan);
+ else if (!ifupdownProfilesMatchInverted && ifupdownProfiles.find(scan->name()) != ifupdownProfiles.end())
_scans.push_back(scan);
}
More information about the Guessnet-devel
mailing list