Add validation of IP address

With the current implementation, when configuring a wrong ip,
there no error thrown, instead that ip address is being configured.

POST -d '{"data":["10.10.10",162]}' https://${bmc}/xyz/openbmc_project/network/snmp/manager/action/Client
{
  "data": "/xyz/openbmc_project/network/snmp/manager/27",
  "message": "200 OK",
  "status": "ok"
}

This commit adds the validation of the ip address during
the configuration.

Tested-By:

Failure case:
POST -d '{"data":["10.10.10",162]}' https://${bmc}/xyz/openbmc_project/network/snmp/manager/action/Client
{
  "data": {
    "description": "xyz.openbmc_project.Common.Error.InvalidArgument"
  },
  "message": "Invalid argument was given.",
  "status": "error"
}

Few more cases that are tested:
"10.10.10.10.10"
"10.10.10.100000"
"10.10.10.bb"
"10.10.10.10.bb"
"10.10.bb.aa"

Success case:
POST -d '{"data":["10.10.10.101",162]}' https://${bmc}/xyz/openbmc_project/network/snmp/manager/action/Client
{
  "data": "/xyz/openbmc_project/network/snmp/manager/1",
  "message": "200 OK",
  "status": "ok"
}

Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com>
Change-Id: Ia08e6eeaa70e3ce45eb055cf927901b36bc4f845
1 file changed