[Xorp-hackers] [PATCH 1/4] xorp: Added support for uint64 type

igorm at etf.rs igorm at etf.rs
Tue Mar 13 03:49:12 PDT 2012


From: Igor Maravic <igorm at etf.rs>

In template.yy and template.ll files added support for uint64 and uin64range types. Their nodes are called
NODE_ULONG and NODE_ULONGRANGE respectively.

In range.hh added U64Range class. Does everything as U32Range, but with uint64_t instead of uint32_t variables.

In template_tree_node.cc and template_tree_node.hh added ULongTemplate and ULongRangeTemplate to handle new types.

Unfortunately Eclipse striped whitespaces from changed files, so they are meshed up with the changed code.

Signed-off-by: Igor Maravic <igorm at etf.rs>
---
 xorp/libxorp/range.hh             |  133 +++++++++++++++++++++++++++++++++++-
 xorp/rtrmgr/conf_tree.cc          |   27 +++++--
 xorp/rtrmgr/template.ll           |   10 +++
 xorp/rtrmgr/template.yy           |   12 ++++
 xorp/rtrmgr/template_tree.cc      |   22 ++++--
 xorp/rtrmgr/template_tree_node.cc |  124 +++++++++++++++++++++++++++++++++--
 xorp/rtrmgr/template_tree_node.hh |  129 +++++++++++++++++++++++-------------
 7 files changed, 385 insertions(+), 72 deletions(-)

diff --git a/xorp/libxorp/range.hh b/xorp/libxorp/range.hh
index 538610f..1acb0ef 100644
--- a/xorp/libxorp/range.hh
+++ b/xorp/libxorp/range.hh
@@ -9,13 +9,13 @@
 // Redistribution and/or modification of this program under the terms of
 // any other version of the GNU Lesser General Public License is not
 // permitted.
-// 
+//
 // This program is distributed in the hope that it will be useful, but
 // WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
 // see the GNU Lesser General Public License, Version 2.1, a copy of
 // which can be found in the XORP LICENSE.lgpl file.
-// 
+//
 // XORP, Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
 // http://xorp.net
 
@@ -76,7 +76,7 @@ public:
     /**
      * Default constructor
      */
-    U32Range() 			{ Range<uint32_t>::_low = 
+    U32Range() 			{ Range<uint32_t>::_low =
     				   Range<uint32_t>::_high = 0; }
 
     /**
@@ -110,6 +110,54 @@ public:
 };
 
 /**
+ * @short A linear range class (uint64_t low)..(uint64_t high)
+ *
+ * Inherits from templatized general Range<uint64_t> class.
+ * Provides specialized constructor from string and str() method.
+ */
+class U64Range: public Range<uint64_t> {
+public:
+	/**
+	 * Default constructor
+	 */
+	U64Range()				{ Range<uint64_t>::_low =
+						Range<uint64_t>::_high = 0; }
+
+	/**
+	 * Constructor	from a string.
+	 */
+	U64Range(const char *from_cstr) {
+	string from_string = string(from_cstr);
+	string::size_type delim = from_string.find("..", 0);
+	if (delim == string::npos) {
+	    _low = _high = strtoul(from_cstr, NULL, 10);
+	} else if (delim > 0 && (from_string.length() - delim > 2)) {
+	    _low = strtoul(from_string.substr(0, delim).c_str(), NULL, 10);
+	    _high = strtoul(from_string.substr(delim + 2, from_string.length()).c_str(), NULL, 10);
+	} else {
+	    xorp_throw(InvalidString, "Syntax error");
+	}
+    }
+
+    /**
+     * Convert the range to a human-readable format.
+     *
+     * @return C++ string.
+     */
+    string str() const {
+	ostringstream os;
+	os << _low;
+	if (_low < _high)
+	    os << ".." << _high;
+	return os.str();
+    }
+};
+
+/**
+ * Operators for uint32_t and U32Range
+ */
+
+/**
  * Equality Operator for @ref uint32_t against @ref U32Range operand.
  *
  * @param lhs the left-hand @ref uint32_t type operand.
@@ -182,6 +230,83 @@ inline bool operator>=(const uint32_t& lhs, const U32Range& rhs) {
     return (lhs >= rhs.low());
 }
 
+/**
+ * Operators for uint64_t and U64Range
+ */
+
+/**
+ * Equality Operator for @ref uint64_t against @ref U64Range operand.
+ *
+ * @param lhs the left-hand @ref uint64_t type operand.
+ * @param rhs the right-hand @ref U64Range operand.
+ * @return true if the value of the left-hand operand falls inside
+ * the range defined by the right-hand operand.
+ */
+inline bool operator==(const uint64_t& lhs, const U64Range& rhs) {
+    return (lhs >= rhs.low() && lhs <= rhs.high());
+}
+
+
+/**
+ * Non-equality Operator for @ref uint64_t against @ref U64Range operand.
+ *
+ * @param lhs the left-hand @ref uint64_t type operand.
+ * @param rhs the right-hand @ref U64Range operand.
+ * @return true if the value of the left-hand operand falls outside
+ * the range defined by the right-hand operand.
+ */
+inline bool operator!=(const uint64_t& lhs, const U64Range& rhs) {
+    return (lhs < rhs.low() || lhs > rhs.high());
+}
+
+/**
+ * Less-than comparison for @ref uint64_t against @ref U64Range operand.
+ *
+ * @param lhs the left-hand @ref uint64_t type operand.
+ * @param rhs the right-hand @ref U64Range operand.
+ * @return true if the value of the left-hand operand is bellow
+ * the range defined by the right-hand operand.
+ */
+inline bool operator<(const uint64_t& lhs, const U64Range& rhs) {
+    return (lhs < rhs.low());
+}
+
+/**
+ * Less-than or equal comparison for @ref uint64_t against @ref U64Range
+ *
+ * @param lhs the left-hand @ref uint64_t type operand.
+ * @param rhs the right-hand @ref U64Range operand.
+ * @return true if the value of the left-hand operand is bellow or within
+ * the range defined by the right-hand operand.
+ */
+inline bool operator<=(const uint64_t& lhs, const U64Range& rhs) {
+    return (lhs <= rhs.high());
+}
+
+/**
+ * Greater-than comparison for @ref uint64_t against @ref U64Range operand.
+ *
+ * @param lhs the left-hand @ref uint64_t type operand.
+ * @param rhs the right-hand @ref U64Range operand.
+ * @return true if the value of the left-hand operand is above
+ * the range defined by the right-hand operand.
+ */
+inline bool operator>(const uint64_t& lhs, const U64Range& rhs) {
+    return (lhs > rhs.high());
+}
+
+/**
+ * Greater-than or equal comparison for @ref uint64_t against @ref U64Range
+ *
+ * @param lhs the left-hand @ref uint64_t type operand.
+ * @param rhs the right-hand @ref U64Range operand.
+ * @return true if the value of the left-hand operand is above or within
+ * the range defined by the right-hand operand.
+ */
+inline bool operator>=(const uint64_t& lhs, const U64Range& rhs) {
+    return (lhs >= rhs.low());
+}
+
 
 /**
  * @short A linear IPvX class template (IPvX low)..(IPvX high)
@@ -207,7 +332,7 @@ public:
 	    Range<T>::_low = Range<T>::_high = T(from_cstr);
 	else if (delim > 0 && (from_string.length() - delim > 2)) {
 	    Range<T>::_low = T(from_string.substr(0, delim).c_str());
-	    Range<T>::_high = T(from_string.substr(delim + 2, 
+	    Range<T>::_high = T(from_string.substr(delim + 2,
 	    					   from_string.length())
 						    .c_str());
 	} else {
diff --git a/xorp/rtrmgr/conf_tree.cc b/xorp/rtrmgr/conf_tree.cc
index f52ace5..77cd3b9 100644
--- a/xorp/rtrmgr/conf_tree.cc
+++ b/xorp/rtrmgr/conf_tree.cc
@@ -7,13 +7,13 @@
 // 1991 as published by the Free Software Foundation. Redistribution
 // and/or modification of this program under the terms of any other
 // version of the GNU General Public License is not permitted.
-// 
+//
 // This program is distributed in the hope that it will be useful, but
 // WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
 // see the GNU General Public License, Version 2, a copy of which can be
 // found in the XORP LICENSE.gpl file.
-// 
+//
 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
 // http://xorp.net
 
@@ -112,7 +112,7 @@ ConfigTree::path_as_segments() const
     ConfigTreeNode* ctn = _current_node;
 
     while (ctn->parent() != NULL) {
-	path_segments.push_front(ConfPathSegment(ctn->segname(), 
+	path_segments.push_front(ConfPathSegment(ctn->segname(),
 						 ctn->type(), ctn->node_id()));
 	ctn = ctn->parent();
     }
@@ -271,7 +271,7 @@ ConfigTree::add_node(const string& segment, int type,
 
 
 void
-ConfigTree::terminal_value(const string& value, int type, ConfigOperator op) 
+ConfigTree::terminal_value(const string& value, int type, ConfigOperator op)
     throw (ParseError)
 {
     string error_msg;
@@ -289,12 +289,22 @@ ConfigTree::terminal_value(const string& value, int type, ConfigOperator op)
 	    svalue = "true";
 	}
     }
+    /**
+     * If ctn_type() == NODE_ULONG, then
+     * type will be NODE_UINT, because
+     * we read uint64 values just as uint values
+     */
+    if (ctn->type() == NODE_ULONG && type == NODE_UINT)
+		type = NODE_ULONG;
+
     if ((ctn->type() == NODE_TEXT) && (type == NODE_TEXT)) {
 	svalue = unquote(svalue);
     } else if ((ctn->type() == NODE_TEXT) && (type != NODE_TEXT)) {
 	// We'll accept anything as text
-    } else if ((ctn->type() == NODE_UINTRANGE) && (type == NODE_UINT)) {
+    } else if (((ctn->type() == NODE_UINTRANGE) && (type == NODE_UINT)) ||
+			((ctn->type() == NODE_ULONGRANGE) && (type == NODE_ULONG))) {
 	// Expand a single uint to a uintrange
+    // or a single uint64 to uint64range
 	svalue += ".." + value;
     } else if ((ctn->type() == NODE_IPV4RANGE) && (type == NODE_IPV4)) {
 	// Expand a single IPv4 to a ipv4range
@@ -315,6 +325,7 @@ ConfigTree::terminal_value(const string& value, int type, ConfigOperator op)
 	    // Not clear what to do here
 	    break;
 	case NODE_UINT:
+	case NODE_ULONG:
 	    for (size_t i = 0; i < svalue.size(); i++) {
 		if ((svalue[i] < '0') || (svalue[i] > '9')) {
 		    goto parse_error;
@@ -440,7 +451,7 @@ ConfigTree::find_config_node(const list<string>& path_segments) const
 
 
 string
-ConfigTree::show_subtree(bool show_top, const list<string>& path_segments, 
+ConfigTree::show_subtree(bool show_top, const list<string>& path_segments,
 			 bool numbered, bool suppress_default_values) const
 {
     const ConfigTreeNode *found = find_config_node(path_segments);
@@ -464,7 +475,7 @@ ConfigTree::show_tree(bool numbered) const
     return const_root_node().show_subtree(/* show_top */ false,
 					  /* depth */ 0,
 					  /* indent */ 0,
-					  /* do_indent */ true, 
+					  /* do_indent */ true,
 					  numbered,
 					  /* annotate */ true,
 					  /* suppress_default_values */ false);
@@ -476,7 +487,7 @@ ConfigTree::show_unannotated_tree(bool numbered) const
     return const_root_node().show_subtree(/* show_top */ false,
 					  /* depth */ 0,
 					  /* indent */ 0,
-					  /* do_indent */ true, 
+					  /* do_indent */ true,
 					  numbered,
 					  /* annotate */ false,
 					  /* suppress_default_values */ false);
diff --git a/xorp/rtrmgr/template.ll b/xorp/rtrmgr/template.ll
index abcb2aa..fbe3ad7 100644
--- a/xorp/rtrmgr/template.ll
+++ b/xorp/rtrmgr/template.ll
@@ -285,6 +285,16 @@ RE_URL_SUBDELIMS "!"|"$"|"&"|"'"|"("|")"|"*"|"+"|","|";"|"="
 	return UINT_TYPE;
 	}
 
+"u64range"	{
+	tpltlval = strdup(tplttext);
+	return ULONGRANGE_TYPE;
+	}
+
+"u64"	{
+	tpltlval = strdup(tplttext);
+	return ULONG_TYPE;
+	}
+
 "bool"	{
 	tpltlval = strdup(tplttext);
 	return BOOL_TYPE;
diff --git a/xorp/rtrmgr/template.yy b/xorp/rtrmgr/template.yy
index 9eadafe..b02b5bc 100644
--- a/xorp/rtrmgr/template.yy
+++ b/xorp/rtrmgr/template.yy
@@ -93,6 +93,8 @@ parse_template() throw (ParseError);
 %token INT_TYPE
 %token UINT_TYPE
 %token UINTRANGE_TYPE
+%token ULONG_TYPE
+%token ULONGRANGE_TYPE
 %token BOOL_TYPE
 %token TOGGLE_TYPE
 %token IPV4_TYPE
@@ -161,6 +163,8 @@ type:		TEXT_TYPE { tplt_type = NODE_TEXT; }
 		| INT_TYPE { tplt_type = NODE_INT; }
 		| UINT_TYPE { tplt_type = NODE_UINT; }
 		| UINTRANGE_TYPE { tplt_type = NODE_UINTRANGE; }
+		| ULONG_TYPE { tplt_type = NODE_ULONG; }
+		| ULONGRANGE_TYPE { tplt_type = NODE_ULONGRANGE; }
 		| BOOL_TYPE { tplt_type = NODE_BOOL; }
 		| TOGGLE_TYPE { tplt_type = NODE_TOGGLE; }
 		| IPV4_TYPE { tplt_type = NODE_IPV4; }
@@ -192,6 +196,14 @@ init_type:	TEXT_TYPE ASSIGN_DEFAULT STRING {
 			tplt_type = NODE_UINTRANGE;
 			tplt_initializer = $3;
 		}
+		| ULONG_TYPE ASSIGN_DEFAULT INTEGER_VALUE {
+			tplt_type = NODE_ULONG;
+			tplt_initializer = $3;
+		}
+		| ULONGRANGE_TYPE ASSIGN_DEFAULT UINTRANGE_VALUE {
+			tplt_type = NODE_ULONGRANGE;
+			tplt_initializer = $3;
+		}
 		| BOOL_TYPE ASSIGN_DEFAULT BOOL_VALUE {
 			tplt_type = NODE_BOOL;
 			tplt_initializer = $3;
diff --git a/xorp/rtrmgr/template_tree.cc b/xorp/rtrmgr/template_tree.cc
index e228bb5..6b51a3a 100644
--- a/xorp/rtrmgr/template_tree.cc
+++ b/xorp/rtrmgr/template_tree.cc
@@ -7,13 +7,13 @@
 // 1991 as published by the Free Software Foundation. Redistribution
 // and/or modification of this program under the terms of any other
 // version of the GNU General Public License is not permitted.
-// 
+//
 // This program is distributed in the hope that it will be useful, but
 // WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
 // see the GNU General Public License, Version 2, a copy of which can be
 // found in the XORP LICENSE.gpl file.
-// 
+//
 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
 // http://xorp.net
 
@@ -64,7 +64,7 @@ TemplateTree::~TemplateTree()
     delete _root_node;
 }
 
-bool 
+bool
 TemplateTree::load_template_tree(const string& config_template_dir,
 				 string& error_msg)
 {
@@ -123,9 +123,9 @@ TemplateTree::load_template_tree(const string& config_template_dir,
     return true;
 }
 
-bool 
+bool
 TemplateTree::parse_file(const string& filename,
-			 const string& config_template_dir, string& error_msg) 
+			 const string& config_template_dir, string& error_msg)
 {
     if (init_template_parser(filename.c_str(), this) < 0) {
 	complete_template_parser();
@@ -142,7 +142,7 @@ TemplateTree::parse_file(const string& filename,
     }
     if (_path_segments.size() != 0) {
 	complete_template_parser();
-	error_msg = c_format("File %s is not terminated properly", 
+	error_msg = c_format("File %s is not terminated properly",
 			     filename.c_str());
 	return false;
     }
@@ -228,6 +228,12 @@ TemplateTree::new_node(TemplateTreeNode* parent,
     case NODE_UINTRANGE:
 	ttn = new UIntRangeTemplate(*this, parent, path, varname, initializer);
 	break;
+    case NODE_ULONG:
+    ttn = new ULongTemplate(*this, parent, path, varname, initializer);
+    break;
+    case NODE_ULONGRANGE:
+    ttn = new ULongRangeTemplate(*this, parent, path, varname, initializer);
+    break;
     case NODE_INT:
 	ttn = new IntTemplate(*this, parent, path, varname, initializer);
 	break;
@@ -443,7 +449,7 @@ TemplateTree::find_node(const list<string>& path_segments) const
 }
 
 const TemplateTreeNode*
-TemplateTree::find_node_by_type(const list<ConfPathSegment>& path_segments) 
+TemplateTree::find_node_by_type(const list<ConfPathSegment>& path_segments)
     const
 {
     TemplateTreeNode* ttn = _root_node;
@@ -490,7 +496,7 @@ TemplateTree::find_node_by_type(const list<ConfPathSegment>& path_segments)
 	    // XXX: the type check failed.
 	    // If there is a matching template node type of type NODE_TEXT,
 	    // then we accept this node.
-	    // 
+	    //
 	    // The upside of this is that we can use a single template
 	    // node like "foo @: txt" that can be used with, say,
 	    // IPv4 or IPv6 addresses, a host name, or any other text string.
diff --git a/xorp/rtrmgr/template_tree_node.cc b/xorp/rtrmgr/template_tree_node.cc
index b4d7d50..7ae9698 100644
--- a/xorp/rtrmgr/template_tree_node.cc
+++ b/xorp/rtrmgr/template_tree_node.cc
@@ -7,13 +7,13 @@
 // 1991 as published by the Free Software Foundation. Redistribution
 // and/or modification of this program under the terms of any other
 // version of the GNU General Public License is not permitted.
-// 
+//
 // This program is distributed in the hope that it will be useful, but
 // WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
 // see the GNU General Public License, Version 2, a copy of which can be
 // found in the XORP LICENSE.gpl file.
-// 
+//
 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
 // http://xorp.net
 
@@ -946,7 +946,7 @@ TemplateTreeNode::find_child_varname_node(const list<string>& var_parts)
 
     // The name might refer to this node
     if (var_parts.size() == 1) {
-	if ((var_parts.front() == "@") 
+	if ((var_parts.front() == "@")
 	    || (var_parts.front() == _segname)
 	    || (var_parts.front() == "<>")
 	    || (var_parts.front() == "#")) {
@@ -1544,6 +1544,120 @@ UIntRangeTemplate::type_match(const string& s, string& error_msg) const
 
 
 /**************************************************************************
+ * ULongTemplate
+ **************************************************************************/
+
+ULongTemplate::ULongTemplate(TemplateTree& template_tree,
+			   TemplateTreeNode* parent,
+			   const string& path, const string& varname,
+			   const string& initializer) throw (ParseError)
+    : TemplateTreeNode(template_tree, parent, path, varname)
+{
+    string error_msg;
+
+    if (initializer.empty())
+	return;
+
+    string s = strip_quotes(initializer);
+    if (! type_match(s, error_msg)) {
+	error_msg = c_format("Bad ULong type value \"%s\": %s.",
+			     initializer.c_str(), error_msg.c_str());
+	xorp_throw(ParseError, error_msg);
+    }
+    _default = strtoll(s.c_str(), (char **)NULL, 10);
+    set_has_default();
+}
+
+bool
+ULongTemplate::type_match(const string& orig, string& error_msg) const
+{
+    string s = strip_quotes(orig);
+
+    for (size_t i = 0; i < s.length(); i++) {
+	if (s[i] < '0' || s[i] > '9') {
+	    if (s[i]=='-') {
+		error_msg = "value cannot be negative";
+	    } else if (s[i]=='.') {
+		error_msg = "value must be an integer";
+	    } else {
+		error_msg = "value must be numeric";
+	    }
+	    return false;
+	}
+    }
+    return true;
+}
+
+string
+ULongTemplate::default_str() const
+{
+    return c_format("%lu", _default);
+}
+
+
+/**************************************************************************
+ * ULongRangeTemplate
+ **************************************************************************/
+
+ULongRangeTemplate::ULongRangeTemplate(TemplateTree& template_tree,
+			   TemplateTreeNode* parent,
+			   const string& path, const string& varname,
+			   const string& initializer) throw (ParseError)
+    : TemplateTreeNode(template_tree, parent, path, varname),
+      _default(NULL)
+{
+    string error_msg;
+
+    if (initializer.empty())
+	return;
+
+    try {
+	_default = new U64Range(initializer.c_str());
+    } catch (InvalidString) {
+	error_msg = c_format("Bad U64Range type value \"%s\".",
+			     initializer.c_str());
+	xorp_throw(ParseError, error_msg);
+    }
+    set_has_default();
+}
+
+ULongRangeTemplate::~ULongRangeTemplate()
+{
+    if (_default != NULL)
+	delete _default;
+}
+
+string
+ULongRangeTemplate::default_str() const
+{
+    if (_default != NULL)
+	return _default->str();
+
+    return "";
+}
+
+bool
+ULongRangeTemplate::type_match(const string& s, string& error_msg) const
+{
+    string tmp = strip_quotes(s);
+
+    if (tmp.empty()) {
+	error_msg = "value must be a valid range of unsigned 64-bit integers";
+	return false;
+    }
+
+    try {
+	U64Range* u64range = new U64Range(tmp.c_str());
+	delete u64range;
+    } catch (InvalidString) {
+	error_msg = "value must be a valid range of unsigned 64-bit integers";
+	return false;
+    }
+    return true;
+}
+
+
+/**************************************************************************
  * IntTemplate
  **************************************************************************/
 
@@ -1586,7 +1700,7 @@ IntTemplate::type_match(const string& orig, string& error_msg) const
 		error_msg = "value must be an integer";
 	    } else {
 		error_msg = "value must be numeric";
-	    }	    
+	    }
 	    return false;
 	}
     return true;
@@ -1613,7 +1727,7 @@ BoolTemplate::BoolTemplate(TemplateTree& template_tree,
 
     if (initializer.empty())
 	return;
-    
+
     if (! type_match(initializer, error_msg)) {
 	error_msg = c_format("Bad Bool type value \"%s\": %s.",
 			     initializer.c_str(), error_msg.c_str());
diff --git a/xorp/rtrmgr/template_tree_node.hh b/xorp/rtrmgr/template_tree_node.hh
index 88e257e..f681fd5 100644
--- a/xorp/rtrmgr/template_tree_node.hh
+++ b/xorp/rtrmgr/template_tree_node.hh
@@ -7,13 +7,13 @@
 // 1991 as published by the Free Software Foundation. Redistribution
 // and/or modification of this program under the terms of any other
 // version of the GNU General Public License is not permitted.
-// 
+//
 // This program is distributed in the hope that it will be useful, but
 // WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
 // see the GNU General Public License, Version 2, a copy of which can be
 // found in the XORP LICENSE.gpl file.
-// 
+//
 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
 // http://xorp.net
 
@@ -42,22 +42,24 @@ enum TTNodeType {
     NODE_VOID		= 0,
     NODE_TEXT		= 1,
     NODE_UINT		= 2,
-    NODE_INT		= 3,
-    NODE_BOOL		= 4,
-    NODE_TOGGLE		= 4,
-    NODE_IPV4		= 5,
-    NODE_IPV4NET	= 6,
-    NODE_IPV6		= 7,
-    NODE_IPV6NET	= 8,
-    NODE_MACADDR	= 9,
-    NODE_URL_FILE	= 10,
-    NODE_URL_FTP	= 11,
-    NODE_URL_HTTP	= 12,
-    NODE_URL_TFTP	= 13,
-    NODE_ARITH		= 14,
-    NODE_UINTRANGE	= 15,
-    NODE_IPV4RANGE	= 16,
-    NODE_IPV6RANGE	= 17
+    NODE_ULONG		= 3,
+    NODE_INT		= 4,
+    NODE_BOOL		= 5,
+    NODE_TOGGLE		= 5,
+    NODE_IPV4		= 6,
+    NODE_IPV4NET	= 7,
+    NODE_IPV6		= 8,
+    NODE_IPV6NET	= 9,
+    NODE_MACADDR	= 10,
+    NODE_URL_FILE	= 11,
+    NODE_URL_FTP	= 12,
+    NODE_URL_HTTP	= 13,
+    NODE_URL_TFTP	= 14,
+    NODE_ARITH		= 15,
+    NODE_UINTRANGE	= 16,
+    NODE_ULONGRANGE	= 17,
+    NODE_IPV4RANGE	= 18,
+    NODE_IPV6RANGE	= 19
 };
 
 enum TTSortOrder {
@@ -73,7 +75,7 @@ class TemplateTree;
 
 class TemplateTreeNode {
 public:
-    TemplateTreeNode(TemplateTree& template_tree, TemplateTreeNode* parent, 
+    TemplateTreeNode(TemplateTree& template_tree, TemplateTreeNode* parent,
 		     const string& path, const string& varname);
     virtual ~TemplateTreeNode();
 
@@ -115,7 +117,7 @@ public:
 #if 0
     bool check_template_tree(string& error_msg) const;
 #endif
-    bool check_command_tree(const list<string>& commands, 
+    bool check_command_tree(const list<string>& commands,
 			    bool include_intermediate_nodes,
 			    bool include_read_only_nodes,
 			    bool include_permanent_nodes,
@@ -238,8 +240,8 @@ private:
 
 class UIntTemplate : public TemplateTreeNode {
 public:
-    UIntTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, 
-		 const string& path, const string& varname, 
+    UIntTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
+		 const string& path, const string& varname,
 		 const string& initializer) throw (ParseError);
 
     string typestr() const { return string("uint"); }
@@ -254,8 +256,8 @@ private:
 
 class UIntRangeTemplate : public TemplateTreeNode {
 public:
-    UIntRangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, 
-		 const string& path, const string& varname, 
+    UIntRangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
+		 const string& path, const string& varname,
 		 const string& initializer) throw (ParseError);
     ~UIntRangeTemplate();
 
@@ -269,10 +271,43 @@ private:
     U32Range* _default;
 };
 
+class ULongTemplate : public TemplateTreeNode {
+public:
+    ULongTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
+		 const string& path, const string& varname,
+		 const string& initializer) throw (ParseError);
+
+    string typestr() const { return string("uint64"); }
+    TTNodeType type() const { return NODE_ULONG; }
+    unsigned int default_value() const { return _default; }
+    string default_str() const;
+    bool type_match(const string& s, string& error_msg) const;
+
+private:
+    uint64_t _default;
+};
+
+class ULongRangeTemplate : public TemplateTreeNode {
+public:
+    ULongRangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
+		 const string& path, const string& varname,
+		 const string& initializer) throw (ParseError);
+    ~ULongRangeTemplate();
+
+    string typestr() const { return string("uint64range"); }
+    TTNodeType type() const { return NODE_ULONGRANGE; }
+    U64Range* default_value() const { return _default; }
+    string default_str() const;
+    bool type_match(const string& s, string& error_msg) const;
+
+private:
+    U64Range* _default;
+};
+
 class IntTemplate : public TemplateTreeNode {
 public:
-    IntTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, 
-		const string& path, const string& varname, 
+    IntTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
+		const string& path, const string& varname,
 		const string& initializer) throw (ParseError);
     string typestr() const { return string("int"); }
     TTNodeType type() const { return NODE_INT; }
@@ -286,8 +321,8 @@ private:
 
 class ArithTemplate : public TemplateTreeNode {
 public:
-    ArithTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, 
-		  const string& path, const string& varname, 
+    ArithTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
+		  const string& path, const string& varname,
 		  const string& initializer) throw (ParseError);
     string typestr() const { return string("uint"); }
     TTNodeType type() const { return NODE_ARITH; }
@@ -301,8 +336,8 @@ private:
 
 class TextTemplate : public TemplateTreeNode {
 public:
-    TextTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, 
-		 const string& path, const string& varname, 
+    TextTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
+		 const string& path, const string& varname,
 		 const string& initializer) throw (ParseError);
 
     string typestr() const { return string("text"); }
@@ -317,8 +352,8 @@ private:
 
 class BoolTemplate : public TemplateTreeNode {
 public:
-    BoolTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, 
-		 const string& path, const string& varname, 
+    BoolTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
+		 const string& path, const string& varname,
 		 const string& initializer) throw (ParseError);
 
     string typestr() const { return string("bool"); }
@@ -333,7 +368,7 @@ private:
 
 class IPv4Template : public TemplateTreeNode {
 public:
-    IPv4Template(TemplateTree& template_tree, TemplateTreeNode* parent, 
+    IPv4Template(TemplateTree& template_tree, TemplateTreeNode* parent,
 		 const string& path, const string& varname,
 		 const string& initializer) throw (ParseError);
     ~IPv4Template();
@@ -350,8 +385,8 @@ private:
 
 class IPv4NetTemplate : public TemplateTreeNode {
 public:
-    IPv4NetTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, 
-		    const string& path, const string& varname, 
+    IPv4NetTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
+		    const string& path, const string& varname,
 		    const string& initializer) throw (ParseError);
     ~IPv4NetTemplate();
 
@@ -367,8 +402,8 @@ private:
 
 class IPv4RangeTemplate : public TemplateTreeNode {
 public:
-    IPv4RangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, 
-		    const string& path, const string& varname, 
+    IPv4RangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
+		    const string& path, const string& varname,
 		    const string& initializer) throw (ParseError);
     ~IPv4RangeTemplate();
 
@@ -385,7 +420,7 @@ private:
 class IPv6Template : public TemplateTreeNode {
 public:
     IPv6Template(TemplateTree& template_tree, TemplateTreeNode* parent,
-		 const string& path, const string& varname, 
+		 const string& path, const string& varname,
 		 const string& initializer) throw (ParseError);
     ~IPv6Template();
 
@@ -401,8 +436,8 @@ private:
 
 class IPv6NetTemplate : public TemplateTreeNode {
 public:
-    IPv6NetTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, 
-		    const string& path, const string& varname, 
+    IPv6NetTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
+		    const string& path, const string& varname,
 		    const string& initializer) throw (ParseError);
     ~IPv6NetTemplate();
 
@@ -419,7 +454,7 @@ private:
 class IPv6RangeTemplate : public TemplateTreeNode {
 public:
     IPv6RangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
-		 const string& path, const string& varname, 
+		 const string& path, const string& varname,
 		 const string& initializer) throw (ParseError);
     ~IPv6RangeTemplate();
 
@@ -435,8 +470,8 @@ private:
 
 class MacaddrTemplate : public TemplateTreeNode {
 public:
-    MacaddrTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, 
-		    const string& path, const string& varname, 
+    MacaddrTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
+		    const string& path, const string& varname,
 		    const string& initializer) throw (ParseError);
     ~MacaddrTemplate();
 
@@ -452,7 +487,7 @@ private:
 
 class UrlFileTemplate : public TemplateTreeNode {
 public:
-    UrlFileTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, 
+    UrlFileTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
 		    const string& path, const string& varname,
 		    const string& initializer) throw (ParseError);
 
@@ -468,7 +503,7 @@ private:
 
 class UrlFtpTemplate : public TemplateTreeNode {
 public:
-    UrlFtpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, 
+    UrlFtpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
 		   const string& path, const string& varname,
 		   const string& initializer) throw (ParseError);
 
@@ -484,7 +519,7 @@ private:
 
 class UrlHttpTemplate : public TemplateTreeNode {
 public:
-    UrlHttpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, 
+    UrlHttpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
 		    const string& path, const string& varname,
 		    const string& initializer) throw (ParseError);
 
@@ -500,7 +535,7 @@ private:
 
 class UrlTftpTemplate : public TemplateTreeNode {
 public:
-    UrlTftpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, 
+    UrlTftpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent,
 		    const string& path, const string& varname,
 		    const string& initializer) throw (ParseError);
 
-- 
1.7.5.4



More information about the Xorp-hackers mailing list