[pve-devel] [PATCH common 1/2] JSONSchema: add get_netmask_bits and missing netmask

Dominik Csapak d.csapak at proxmox.com
Tue Apr 16 11:05:35 CEST 2019


so one can use the mapping from outside the module

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/PVE/JSONSchema.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 51ef3ab..d458ec1 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -266,6 +266,7 @@ sub pve_verify_ip {
 }
 
 my $ipv4_mask_hash = {
+    '0.0.0.0' => 0,
     '128.0.0.0' => 1,
     '192.0.0.0' => 2,
     '224.0.0.0' => 3,
@@ -300,6 +301,11 @@ my $ipv4_mask_hash = {
     '255.255.255.255' => 32,
 };
 
+sub get_netmask_bits {
+    my ($mask) = @_;
+    return $ipv4_mask_hash->{$mask};
+}
+
 register_format('ipv4mask', \&pve_verify_ipv4mask);
 sub pve_verify_ipv4mask {
     my ($mask, $noerr) = @_;
-- 
2.11.0





More information about the pve-devel mailing list