[xen-tools-dev] [PATCH v2 13/13] Add validation for ip and mac
Stéphane Jourdois
sjourdois at gmail.com
Sun Jul 18 22:04:23 CEST 2010
I forgot those on first pass, sorry.
---
bin/xen-create-image | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/bin/xen-create-image b/bin/xen-create-image
index 833a06e..6d63e3a 100755
--- a/bin/xen-create-image
+++ b/bin/xen-create-image
@@ -1571,6 +1571,10 @@ sub checkOption
check => qr/^[a-z0-9_.-]*$/,
message => "must be a valid filename.\n",
},
+ mac => {
+ check => qr/^(?:[0-9a-f]{2}:){5}[0-9a-f]{2}$/i,
+ message => "must be a valid ethernet mac address.\n",
+ },
);
# Define what argument each option accepts.
@@ -1602,6 +1606,8 @@ sub checkOption
template => 'configFile',
output => 'existingDir',
extension => 'filename',
+ mac => 'mac',
+ ip => 'ipv4',
);
# If given option does not exists in optionsTypes,
@@ -1696,8 +1702,8 @@ sub parseCommandLineArguments
"bridge=s", \&checkOption,
"gateway=s", \&checkOption,
"hostname=s", \&checkOption,
- "ip=s@", \$CONFIG{ 'ip' },
- "mac=s", \$CONFIG{ 'mac' },
+ "ip=s@", \&checkOption,
+ "mac=s", \&checkOption,
"netmask=s", \&checkOption,
"broadcast=s", \&checkOption,
"nameserver=s", \&checkOption,
--
1.7.1.1
More information about the xen-tools-dev
mailing list