Check prefix length in Set LAN Config Param 6 & 56

In phosphor-networkd, the allowed prefix length is 1 to 32 for IPv4 and
1 to 128 for IPv6. Calling DBus API with an invalid prefix length will
result in uncaught exceptions. This patch checks prefix length before
setting it and returns appropriate error code on invalid value.

Tested:
* Setting IPv4 SubnetMask to 0.0.0.0 (Param 6) returns 0xcc.
* Setting IPv6 static address with PrefixLength==129 (Param 56) returns
  0xc9.

Change-Id: I03af233905e415c96c896c85baf98846d0880e95
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
diff --git a/transporthandler.cpp b/transporthandler.cpp
index 056c3f5..0f9f8a3 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -992,8 +992,12 @@
                 return responseReqDataLenInvalid();
             }
             copyInto(netmask, bytes);
-            channelCall<reconfigureIfAddr4>(channel, std::nullopt,
-                                            netmaskToPrefix(netmask));
+            uint8_t prefix = netmaskToPrefix(netmask);
+            if (prefix < MIN_IPV4_PREFIX_LENGTH)
+            {
+                return responseInvalidFieldRequest();
+            }
+            channelCall<reconfigureIfAddr4>(channel, std::nullopt, prefix);
             return responseSuccess();
         }
         case LanParam::Gateway1:
@@ -1109,6 +1113,11 @@
             copyInto(ip, ipbytes);
             if (enabled)
             {
+                if (prefix < MIN_IPV6_PREFIX_LENGTH ||
+                    prefix > MAX_IPV6_PREFIX_LENGTH)
+                {
+                    return responseParmOutOfRange();
+                }
                 try
                 {
                     channelCall<reconfigureIfAddr6>(channel, set, ip, prefix);