X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=VNFs%2FDPPD-PROX%2Fhelper-scripts%2Frapid%2Fhelper.lua;h=a5633409d94d57a77b4564db04f79b12722c2123;hb=refs%2Fchanges%2F00%2F73800%2F2;hp=d38bb80862989fcdfe55dae5bd2c91b085be3c81;hpb=b3c5a6a20926dc9fca32240b89f3dea09d07aa02;p=samplevnf.git diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/helper.lua b/VNFs/DPPD-PROX/helper-scripts/rapid/helper.lua index d38bb808..a5633409 100644 --- a/VNFs/DPPD-PROX/helper-scripts/rapid/helper.lua +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/helper.lua @@ -1,5 +1,5 @@ -- --- Copyright (c) 2010-2020 Intel Corporation +-- Copyright (c) 2020 Intel Corporation -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. @@ -21,6 +21,22 @@ function convertIPToHex(ip) return "IP ADDRESS ERROR" end + local chunks = {ip:match("^(%d+)%.(%d+)%.(%d+)%.(%d+)(/%d+)$")} + if #chunks == 5 then + for i,v in ipairs(chunks) do + if i < 5 then + if tonumber(v) > 255 then + print ("IPV4 ADDRESS ERROR: ", ip) + return "IPV4 ADDRESS ERROR" + end + address_chunks[#address_chunks + 1] = string.format ("%02x", v) + end + end + result = table.concat(address_chunks, " ") + print ("Hex IPV4: ", result) + return result + end + local chunks = {ip:match("^(%d+)%.(%d+)%.(%d+)%.(%d+)$")} if #chunks == 4 then for i,v in ipairs(chunks) do