]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3807] Pkt6::getType now returns all message types, including client side.
authorMarcin Siodelski <marcin@isc.org>
Mon, 18 May 2015 14:34:20 +0000 (16:34 +0200)
committerMarcin Siodelski <marcin@isc.org>
Mon, 18 May 2015 14:34:20 +0000 (16:34 +0200)
src/lib/dhcp/pkt4.h
src/lib/dhcp/pkt6.cc
src/lib/dhcp/pkt6.h
src/lib/dhcp/tests/pkt6_unittest.cc

index 8dfa312d76017db9e8bef94e770be51cda6da9d5..9d2b54334ad388fe36a792b94f7ea29b061570bb 100644 (file)
@@ -244,7 +244,7 @@ public:
     /// @param type message type to be set
     void setType(uint8_t type);
 
-    /// @brief Returns name of the DHCP message.
+    /// @brief Returns name of the DHCP message for a given type number.
     ///
     /// @param type DHCPv4 message type which name should be returned.
     ///
index a62726fcce532bb904bc64ab488b0077133ae5ba..8a8b93adeea11cb6017226458d33b8224a36ff9c 100644 (file)
@@ -562,17 +562,27 @@ Pkt6::getOptions(uint16_t opt_type) {
 
 const char*
 Pkt6::getName(const uint8_t type) {
+    static const char* ADVERTISE = "ADVERTISE";
     static const char* CONFIRM = "CONFIRM";
     static const char* DECLINE = "DECLINE";
     static const char* INFORMATION_REQUEST = "INFORMATION_REQUEST";
+    static const char* LEASEQUERY = "LEASEQUERY";
+    static const char* LEASEQUERY_REPLY = "LEASEQUERY_REPLY";
     static const char* REBIND = "REBIND";
+    static const char* RECONFIGURE = "RECONFIGURE";
+    static const char* RELAY_FORW = "RELAY_FORWARD";
+    static const char* RELAY_REPL = "RELAY_REPLY";
     static const char* RELEASE = "RELEASE";
     static const char* RENEW = "RENEW";
+    static const char* REPLY = "REPLY";
     static const char* REQUEST = "REQUEST";
     static const char* SOLICIT = "SOLICIT";
     static const char* UNKNOWN = "UNKNOWN";
 
     switch (type) {
+    case DHCPV6_ADVERTISE:
+        return (ADVERTISE);
+
     case DHCPV6_CONFIRM:
         return (CONFIRM);
 
@@ -582,15 +592,33 @@ Pkt6::getName(const uint8_t type) {
     case DHCPV6_INFORMATION_REQUEST:
         return (INFORMATION_REQUEST);
 
+    case DHCPV6_LEASEQUERY:
+        return (LEASEQUERY);
+
+    case DHCPV6_LEASEQUERY_REPLY:
+        return (LEASEQUERY_REPLY);
+
     case DHCPV6_REBIND:
         return (REBIND);
 
+    case DHCPV6_RECONFIGURE:
+        return (RECONFIGURE);
+
+    case DHCPV6_RELAY_FORW:
+        return (RELAY_FORW);
+
+    case DHCPV6_RELAY_REPL:
+        return (RELAY_REPL);
+
     case DHCPV6_RELEASE:
         return (RELEASE);
 
     case DHCPV6_RENEW:
         return (RENEW);
 
+    case DHCPV6_REPLY:
+        return (REPLY);
+
     case DHCPV6_REQUEST:
         return (REQUEST);
 
index 92a63a9e539c0fc0a0057c463a4462df7157b65b..febb92d35f54ea640141feaaee872ba0c93bda3e 100644 (file)
@@ -266,32 +266,27 @@ public:
     /// @param relay structure with necessary relay information
     void addRelayInfo(const RelayInfo& relay);
 
-    /// @brief Returns name of the DHCPv6 message.
-    ///
-    /// Returns the name of valid packet received by the server (e.g. SOLICIT).
-    /// If the packet is unknown - or if it is a valid DHCP packet but not one
-    /// expected to be received by the server (such as an ADVERTISE), the string
-    /// "UNKNOWN" is returned.  This method is used in debug messages.
+    /// @brief Returns name of the DHCPv6 message for a given type number.
     ///
     /// As the operation of the method does not depend on any server state, it
     /// is declared static. There is also non-static getName() method that
     /// works on Pkt6 objects.
     ///
-    /// @param type DHCPv6 packet type
+    /// @param type DHCPv6 message type which name should be returned.
     ///
-    /// @return Pointer to "const" string containing the packet name.
-    ///         Note that this string is statically allocated and MUST NOT
-    ///         be freed by the caller.
+    /// @return Pointer to "const" string containing the message name. If
+    /// the message type is unknnown the "UNKNOWN" is returned. The caller
+    /// must not release the returned pointer.
     static const char* getName(const uint8_t type);
 
-    /// @brief returns textual representation of packet type.
+    /// @brief Returns name of the DHCPv6 message.
     ///
     /// This method requires an object. There is also static version, which
     /// requires one parameter (type).
     ///
-    /// @return Pointer to "const" string containing packet name.
-    ///         Note that this string is statically allocated and MUST NOT
-    ///         be freed by the caller.
+    /// @return Pointer to "const" string containing the message name. If
+    /// the message type is unknnown the "UNKNOWN" is returned. The caller
+    /// must not release the returned pointer.
     const char* getName() const;
 
     /// @brief copies relay information from client's packet to server's response
index 6b8087bd2b9045b1d698a6fffe601dbde4b9bfc4..d015359765ed1a3ea8f0ad38de21f1b18f530e01 100755 (executable)
@@ -509,6 +509,10 @@ TEST_F(Pkt6Test, getName) {
         uint8_t type = itype;
 
         switch (type) {
+        case DHCPV6_ADVERTISE:
+            EXPECT_STREQ("ADVERTISE", Pkt6::getName(type));
+            break;
+
         case DHCPV6_CONFIRM:
             EXPECT_STREQ("CONFIRM", Pkt6::getName(type));
             break;
@@ -522,10 +526,30 @@ TEST_F(Pkt6Test, getName) {
                          Pkt6::getName(type));
             break;
 
+        case DHCPV6_LEASEQUERY:
+            EXPECT_STREQ("LEASEQUERY", Pkt6::getName(type));
+            break;
+
+        case DHCPV6_LEASEQUERY_REPLY:
+            EXPECT_STREQ("LEASEQUERY_REPLY", Pkt6::getName(type));
+            break;
+
         case DHCPV6_REBIND:
             EXPECT_STREQ("REBIND", Pkt6::getName(type));
             break;
 
+        case DHCPV6_RECONFIGURE:
+            EXPECT_STREQ("RECONFIGURE", Pkt6::getName(type));
+            break;
+
+        case DHCPV6_RELAY_FORW:
+            EXPECT_STREQ("RELAY_FORWARD", Pkt6::getName(type));
+            break;
+
+        case DHCPV6_RELAY_REPL:
+            EXPECT_STREQ("RELAY_REPLY", Pkt6::getName(type));
+            break;
+
         case DHCPV6_RELEASE:
             EXPECT_STREQ("RELEASE", Pkt6::getName(type));
             break;
@@ -534,6 +558,10 @@ TEST_F(Pkt6Test, getName) {
             EXPECT_STREQ("RENEW", Pkt6::getName(type));
             break;
 
+        case DHCPV6_REPLY:
+            EXPECT_STREQ("REPLY", Pkt6::getName(type));
+            break;
+
         case DHCPV6_REQUEST:
             EXPECT_STREQ("REQUEST", Pkt6::getName(type));
             break;