diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2011-10-06 18:49:41 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2011-10-06 18:49:41 +0100 |
commit | f43458f6e2f777228fc78cb38280f670fe603b9a (patch) | |
tree | 902203e4e6b0e9e2a4815a25f475161f495ececc /tools/libxl/libxl_internal.c | |
parent | ec0c9b58c2a50f33904800882400315c49f65b72 (diff) | |
download | xen-f43458f6e2f777228fc78cb38280f670fe603b9a.tar.gz xen-f43458f6e2f777228fc78cb38280f670fe603b9a.tar.bz2 xen-f43458f6e2f777228fc78cb38280f670fe603b9a.zip |
libxl: add and use parse_mac helper function
rather than open coding a bunch it a bunch of times.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/libxl_internal.c')
-rw-r--r-- | tools/libxl/libxl_internal.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index 56e6618653..eabb9f27db 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -277,6 +277,23 @@ int libxl__file_reference_unmap(libxl_file_reference *f) return ERROR_FAIL; } +_hidden int libxl__parse_mac(const char *s, libxl_mac mac) +{ + const char *tok; + char *endptr; + int i; + + for (i = 0, tok = s; *tok && (i < 6); ++i, tok += 3) { + mac[i] = strtol(tok, &endptr, 16); + if (endptr != (tok + 2) || (*endptr != '\0' && *endptr != ':') ) + return ERROR_INVAL; + } + if ( i != 6 ) + return ERROR_INVAL; + + return 0; +} + int libxl__fd_set_cloexec(int fd) { int flags = 0; |