|
|
049c96 |
From da4ac3dc839ed968d4701534344a597df97b0cf0 Mon Sep 17 00:00:00 2001
|
|
|
049c96 |
From: Davide Caratti <dcaratti@redhat.com>
|
|
|
049c96 |
Date: Wed, 6 Jul 2016 18:41:33 +0200
|
|
|
049c96 |
Subject: [PATCH] utils: make hexstring_a2n provide the number of hex digits
|
|
|
049c96 |
parsed
|
|
|
049c96 |
|
|
|
049c96 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1300765
|
|
|
049c96 |
Upstream Status: iproute2.git commit 89ae502056f5
|
|
|
049c96 |
|
|
|
049c96 |
Conflicts: context conflicts around decalaration of hexstring_{n2a,a2n}
|
|
|
049c96 |
due to missing code cleanup (lack of upstream commit 892e21248cfd)
|
|
|
049c96 |
|
|
|
049c96 |
commit 89ae502056f58a0177b9970f1f79a9683ac7fdd0
|
|
|
049c96 |
Author: Sabrina Dubroca <sd@queasysnail.net>
|
|
|
049c96 |
Date: Fri Jun 3 16:45:45 2016 +0200
|
|
|
049c96 |
|
|
|
049c96 |
utils: make hexstring_a2n provide the number of hex digits parsed
|
|
|
049c96 |
|
|
|
049c96 |
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
|
|
|
049c96 |
Acked-by: Phil Sutter <phil@nwl.cc>
|
|
|
049c96 |
|
|
|
049c96 |
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
|
|
|
049c96 |
---
|
|
|
049c96 |
include/utils.h | 4 ++--
|
|
|
049c96 |
lib/utils.c | 8 ++++++--
|
|
|
049c96 |
2 files changed, 8 insertions(+), 4 deletions(-)
|
|
|
049c96 |
|
|
|
049c96 |
diff --git a/include/utils.h b/include/utils.h
|
|
|
049c96 |
index 0234277..86af63b 100644
|
|
|
049c96 |
--- a/include/utils.h
|
|
|
049c96 |
+++ b/include/utils.h
|
|
|
049c96 |
@@ -98,8 +98,8 @@ extern int get_s16(__s16 *val, const char *arg, int base);
|
|
|
049c96 |
extern int get_u8(__u8 *val, const char *arg, int base);
|
|
|
049c96 |
extern int get_s8(__s8 *val, const char *arg, int base);
|
|
|
049c96 |
|
|
|
049c96 |
-extern char* hexstring_n2a(const __u8 *str, int len, char *buf, int blen);
|
|
|
049c96 |
-extern __u8* hexstring_a2n(const char *str, __u8 *buf, int blen);
|
|
|
049c96 |
+char *hexstring_n2a(const __u8 *str, int len, char *buf, int blen);
|
|
|
049c96 |
+__u8 *hexstring_a2n(const char *str, __u8 *buf, int blen, unsigned int *len);
|
|
|
049c96 |
|
|
|
049c96 |
extern const char *format_host(int af, int len, const void *addr,
|
|
|
049c96 |
char *buf, int buflen);
|
|
|
049c96 |
diff --git a/lib/utils.c b/lib/utils.c
|
|
|
049c96 |
index 7f842ae..5337084 100644
|
|
|
049c96 |
--- a/lib/utils.c
|
|
|
049c96 |
+++ b/lib/utils.c
|
|
|
049c96 |
@@ -787,9 +787,9 @@ char *hexstring_n2a(const __u8 *str, int len, char *buf, int blen)
|
|
|
049c96 |
return buf;
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
-__u8* hexstring_a2n(const char *str, __u8 *buf, int blen)
|
|
|
049c96 |
+__u8 *hexstring_a2n(const char *str, __u8 *buf, int blen, unsigned int *len)
|
|
|
049c96 |
{
|
|
|
049c96 |
- int cnt = 0;
|
|
|
049c96 |
+ unsigned int cnt = 0;
|
|
|
049c96 |
char *endptr;
|
|
|
049c96 |
|
|
|
049c96 |
if (strlen(str) % 2)
|
|
|
049c96 |
@@ -806,6 +806,10 @@ __u8* hexstring_a2n(const char *str, __u8 *buf, int blen)
|
|
|
049c96 |
buf[cnt++] = tmp;
|
|
|
049c96 |
str += 2;
|
|
|
049c96 |
}
|
|
|
049c96 |
+
|
|
|
049c96 |
+ if (len)
|
|
|
049c96 |
+ *len = cnt;
|
|
|
049c96 |
+
|
|
|
049c96 |
return buf;
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
--
|
|
|
049c96 |
1.8.3.1
|
|
|
049c96 |
|