Parcourir la source

[trac4269] Add documentation and test for handling pkt4 as input

Shawn Routhier il y a 9 ans
Parent
commit
2a01de22f2
2 fichiers modifiés avec 27 ajouts et 0 suppressions
  1. 22 0
      doc/guide/classify.xml
  2. 5 0
      src/lib/eval/tests/token_unittest.cc

+ 22 - 0
doc/guide/classify.xml

@@ -169,6 +169,20 @@
 sub-option</entry><entry>relay4[code].hex</entry><entry>The value of
 sub-option</entry><entry>relay4[code].hex</entry><entry>The value of
 sub-option with code "code" from the DHCPv4 Relay Agent Information option
 sub-option with code "code" from the DHCPv4 Relay Agent Information option
 (option 82)</entry></row>
 (option 82)</entry></row>
+<row>
+  <entry>Message Type in DHCPv6 packet</entry>
+  <entry>pkt6.msgtype</entry>
+<!--  <entry>'1'</entry>
+-->
+  <entry>The value of the message type field in the DHCPv6 packet.</entry>
+</row>
+<row>
+  <entry>Transaction ID in DHCPv6 packet</entry>
+  <entry>pkt6.transid</entry>
+<!--  <entry>'12345'</entry>
+-->
+  <entry>The value of the transaction id in the DHCPv6 packet.</entry>
+</row>
           </tbody>
           </tbody>
           </tgroup>
           </tgroup>
         </table>
         </table>
@@ -210,6 +224,14 @@ sub-option with code "code" from the DHCPv4 Relay Agent Information option
       </para>
       </para>
 
 
       <para>
       <para>
+       "pkt6" refers to information from the client request.  To access any
+       information from an intermediate relay use "relay6".  "pkt6.msgtype"
+       outputs the string representation of the integer value for the message
+       type, for example SOLICIT will be '1'.  "pkt6.transid" outputs the string
+       representation of the value of the transaction ID.
+      </para>
+
+      <para>
         <table frame="all" id="classification-expressions-list">
         <table frame="all" id="classification-expressions-list">
           <title>List of Classification Expressions</title>
           <title>List of Classification Expressions</title>
           <tgroup cols='3'>
           <tgroup cols='3'>

+ 5 - 0
src/lib/eval/tests/token_unittest.cc

@@ -985,4 +985,9 @@ TEST_F(TokenTest, pkt6Fields) {
     EXPECT_NO_THROW(t_->evaluate(*pkt6_, values_));
     EXPECT_NO_THROW(t_->evaluate(*pkt6_, values_));
     ASSERT_EQ(1, values_.size());
     ASSERT_EQ(1, values_.size());
     EXPECT_EQ("12345", values_.top());
     EXPECT_EQ("12345", values_.top());
+
+    // Check that working with a v4 packet generates an error
+    clearStack();
+    ASSERT_NO_THROW(t_.reset(new TokenPkt6(TokenPkt6::TRANSID)));
+    EXPECT_THROW(t_->evaluate(*pkt4_, values_), EvalTypeError);
 }
 }