Browse Source

[4226] Remaining two exception conditions removed.

Tomek Mrugalski 9 years ago
parent
commit
254d8f16cf
2 changed files with 17 additions and 11 deletions
  1. 10 8
      src/lib/dhcp/dhcp4.h
  2. 7 3
      src/lib/dhcp/pkt4.cc

+ 10 - 8
src/lib/dhcp/dhcp4.h

@@ -50,15 +50,17 @@ enum BOOTPTypes {
 /* Possible values for flags field... */
 static const uint16_t BOOTP_BROADCAST = 32768L;
 
-/* Possible values for hardware type (htype) field... */
+/// @brief Possible values for hardware type (htype) field.
 enum HType {
-    HTYPE_ETHER = 1,   /* Ethernet 10Mbps */
-    HTYPE_DOCSIS = 1,  /* The traffic captures we have from cable modems as well
-                          as this list by IANA: http://www.iana.org/assignments/
-                          arp-parameters/arp-parameters.xhtml suggest that
-                          Ethernet (1) should be used in DOCSIS environment. */
-    HTYPE_IEEE802 = 6, /* IEEE 802.2 Token Ring */
-    HTYPE_FDDI = 8     /* FDDI */
+    HTYPE_UNDEFINED = 0, ///< not specified or undefined
+    HTYPE_ETHER = 1,     ///< Ethernet 10Mbps
+    HTYPE_DOCSIS = 1,    ///< The traffic captures we have from cable modems as
+                         ///  well as this list by IANA:
+                         ///  http://www.iana.org/assignments/
+                         ///  arp-parameters/arp-parameters.xhtml suggest that
+                         ///  Ethernet (1) should be used in DOCSIS environment.
+    HTYPE_IEEE802 = 6,   ///< IEEE 802.2 Token Ring
+    HTYPE_FDDI = 8       ///< FDDI
     /// TODO Add infiniband here
 };
 

+ 7 - 3
src/lib/dhcp/pkt4.cc

@@ -415,7 +415,11 @@ Pkt4::toText() const {
         output << "," << std::endl << "options:";
         for (isc::dhcp::OptionCollection::const_iterator opt = options_.begin();
              opt != options_.end(); ++opt) {
-            output << std::endl << opt->second->toText(2);
+            try {
+                output << std::endl << opt->second->toText(2);
+            } catch (...) {
+                output << "(unknown)" << std::endl;
+            }
         }
 
     } else {
@@ -535,7 +539,7 @@ Pkt4::DHCPTypeToBootpType(uint8_t dhcpType) {
 uint8_t
 Pkt4::getHtype() const {
     if (!hwaddr_) {
-        isc_throw(InvalidOperation, "Can't get HType. HWAddr not defined");
+        return (HTYPE_UNDEFINED);
     }
     return (hwaddr_->htype_);
 }
@@ -543,7 +547,7 @@ Pkt4::getHtype() const {
 uint8_t
 Pkt4::getHlen() const {
     if (!hwaddr_) {
-        isc_throw(InvalidOperation, "Can't get HType. HWAddr not defined");
+        return (0);
     }
     uint8_t len = hwaddr_->hwaddr_.size();
     return (len <= MAX_CHADDR_LEN ? len : MAX_CHADDR_LEN);