AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CXXFLAGS = $(KEA_CXXFLAGS)
+# Some versions of GCC warn about some versions of Boost regarding
+# missing initializer for members in its posix_time.
+# https://svn.boost.org/trac/boost/ticket/3477
+# But older GCC compilers don't have the flag.
+AM_CXXFLAGS += $(WARNING_NO_MISSING_FIELD_INITIALIZERS_CFLAG)
+
lib_LTLIBRARIES = libkea-eval.la
libkea_eval_la_SOURCES =
libkea_eval_la_SOURCES += token.cc token.h
libkea_eval_la_LIBADD = $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libkea_eval_la_LIBADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
libkea_eval_la_LDFLAGS = -no-undefined -version-info 3:0:0
-libkea_eval_la_LDFLAGS += $(CRYPTO_LDFLAGS)
+libkea_eval_la_LDFLAGS += $(LOG4CPLUS_LIBS) $(CRYPTO_LDFLAGS)
EXTRA_DIST = eval.dox
EXTRA_DIST += eval_messages.mes
-// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
-# Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
}
// This test checks if a token representing an option value is able to extract
-// the option from a packet and properly store the option's value.
-TEST_F(TokenTest, optionString) {
+// the option from an IPv4 packet and properly store the option's value.
+TEST_F(TokenTest, optionString4) {
TokenPtr found;
TokenPtr not_found;
EXPECT_EQ("hundred4", values_.top());
}
+// This test checks if a token representing an option value is able to extract
+// the option from an IPv6 packet and properly store the option's value.
+TEST_F(TokenTest, optionString6) {
+ TokenPtr found;
+ TokenPtr not_found;
+
+ // The packets we use have option 100 with a string in them.
+ ASSERT_NO_THROW(found.reset(new TokenOption(100)));
+ ASSERT_NO_THROW(not_found.reset(new TokenOption(101)));
+
+ // This should evaluate to the content of the option 100 (i.e. "hundred6")
+ ASSERT_NO_THROW(found->evaluate(*pkt6_, values_));
+
+ // This should evaluate to "" as there is no option 101.
+ ASSERT_NO_THROW(not_found->evaluate(*pkt6_, values_));
+
+ // There should be 2 values evaluated.
+ ASSERT_EQ(2, values_.size());
+
+ // This is a stack, so the pop order is inversed. We should get the empty
+ // string first.
+ EXPECT_EQ("", values_.top());
+ values_.pop();
+
+ // Then the content of the option 100.
+ EXPECT_EQ("hundred6", values_.top());
+}
+
// This test checks if a token representing an == operator is able to
// compare two values (with incorrectly built stack).
TEST_F(TokenTest, optionEqualInvalid) {
if (values.size() < 2) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
- "2 values, got " << values.size());
+ "2 values for == operator, got " << values.size());
}
string op1 = values.top();
///
/// We need to pass the packet being evaluated and possibly previously
/// evaluated values. Specific implementations may ignore the packet altogether
- /// and just put theirr own value on the stack (constant tokens), look at the
+ /// and just put their own value on the stack (constant tokens), look at the
/// packet and put some data extracted from it on the stack (option tokens),
/// or pop arguments from the stack and put back the result (operators).
///
/// Value is set during token construction.
///
/// @param str constant string to be represented.
- TokenString(std::string str)
+ TokenString(const std::string& str)
:value_(str){
}
/// to extract the option from the packet and put its value on the stack.
/// If the option is not there, an empty string ("") is put on the stack.
///
- /// @param pkt not used
+ /// @param pkt specified option will be extracted from this packet (if present)
/// @param values value of the option will be pushed here (or "")
void evaluate(const Pkt& pkt, ValueStack& values);