Browse Source

[trac998] Change "addrmask" nasm to ipprefix

Stephen Morris 14 years ago
parent
commit
59908b70a9
2 changed files with 11 additions and 9 deletions
  1. 8 6
      src/lib/acl/ip_check.cc
  2. 3 3
      src/lib/acl/ip_check.h

+ 8 - 6
src/lib/acl/ip_check.cc

@@ -24,7 +24,7 @@ namespace acl {
 namespace internal {
 
 pair<string, int>
-splitIPAddress(const string& prefix) {
+splitIPAddress(const string& ipprefix) {
 
     // Set the default value for the prefix length.  As the type of the address
     // is not known at the point this function is called, the maximum
@@ -32,18 +32,20 @@ splitIPAddress(const string& prefix) {
     // a "match any address" match.
     int prefix_size = -1;
 
+    // Only deal with the string after we've removed leading and trailing
+    // spaces.
+    string mod_prefix = isc::util::str::trim(ipprefix);
+
     // Split string into its components - an address and a prefix length.
     // We initialize by assuming that there is no slash in the string given.
-    string address = prefix;
+    string address = mod_prefix;
     string prefixlen = "";
 
-    // Parse the string given after stripping leading and trailing spaces.
-    string mod_prefix = isc::util::str::trim(prefix);
     size_t slashpos = mod_prefix.find('/');
     if ((mod_prefix.size() == 0) || (slashpos == 0) ||
         (slashpos == (mod_prefix.size() - 1))) {
         // Nothing in prefix, or it starts with or ends with a slash.
-        isc_throw(isc::InvalidParameter, "address prefix of " << prefix <<
+        isc_throw(isc::InvalidParameter, "address prefix of " << ipprefix <<
                                          " is not valid");
 
     } else if (slashpos != string::npos) {
@@ -61,7 +63,7 @@ splitIPAddress(const string& prefix) {
             prefix_size = boost::lexical_cast<int>(prefixlen);
             if (prefix_size < 0) {
                 isc_throw(isc::InvalidParameter, "address prefix of " <<
-                          prefix << " is not valid");
+                          ipprefix << " is not valid");
             }
         } catch (boost::bad_lexical_cast&) {
             isc_throw(isc::InvalidParameter, "prefix length of " << prefixlen <<

+ 3 - 3
src/lib/acl/ip_check.h

@@ -16,6 +16,7 @@
 #define __IP_CHECK_H
 
 #include <cassert>
+#include <algorithm>
 #include <functional>
 #include <iterator>
 #include <utility>
@@ -30,7 +31,6 @@
 #include <netinet/in.h>
 
 #include <acl/check.h>
-#include <util/strutil.h>
 #include <exceptions/exceptions.h>
 
 namespace isc {
@@ -107,7 +107,7 @@ T createMask(size_t prefixlen) {
 /// N.B. This function does NOT check that the address component is a valid IP
 /// address; this is done elsewhere in the address parsing process.
 ///
-/// \param addrmask Address or address prefix.  The string should be passed
+/// \param ipprefix Address or address prefix.  The string should be passed
 ///                 without leading or trailing spaces.
 ///
 /// \return Pair of (string, int) holding the address string and the prefix
@@ -116,7 +116,7 @@ T createMask(size_t prefixlen) {
 /// \exception InvalidParameter Address prefix not of the expected syntax
 
 std::pair<std::string, int>
-splitIPAddress(const std::string& prefix);
+splitIPAddress(const std::string& ipprefix);
 
 } // namespace internal