/// @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.
///
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);
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);
/// @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
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;
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;
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;