mirror of
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git
synced 2024-11-15 22:15:13 +08:00
utils: make hexstring_a2n provide the number of hex digits parsed
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Acked-by: Phil Sutter <phil@nwl.cc>
This commit is contained in:
parent
90353c3341
commit
89ae502056
@ -114,8 +114,8 @@ int get_u8(__u8 *val, const char *arg, int base);
|
||||
int get_s8(__s8 *val, const char *arg, int base);
|
||||
int get_addr64(__u64 *ap, const char *cp);
|
||||
|
||||
char* hexstring_n2a(const __u8 *str, int len, char *buf, int blen);
|
||||
__u8* hexstring_a2n(const char *str, __u8 *buf, int blen);
|
||||
char *hexstring_n2a(const __u8 *str, int len, char *buf, int blen);
|
||||
__u8 *hexstring_a2n(const char *str, __u8 *buf, int blen, unsigned int *len);
|
||||
#define ADDR64_BUF_SIZE sizeof("xxxx:xxxx:xxxx:xxxx")
|
||||
int addr64_n2a(__u64 addr, char *buff, size_t len);
|
||||
|
||||
|
@ -866,9 +866,9 @@ char *hexstring_n2a(const __u8 *str, int len, char *buf, int blen)
|
||||
return buf;
|
||||
}
|
||||
|
||||
__u8* hexstring_a2n(const char *str, __u8 *buf, int blen)
|
||||
__u8 *hexstring_a2n(const char *str, __u8 *buf, int blen, unsigned int *len)
|
||||
{
|
||||
int cnt = 0;
|
||||
unsigned int cnt = 0;
|
||||
char *endptr;
|
||||
|
||||
if (strlen(str) % 2)
|
||||
@ -885,6 +885,10 @@ __u8* hexstring_a2n(const char *str, __u8 *buf, int blen)
|
||||
buf[cnt++] = tmp;
|
||||
str += 2;
|
||||
}
|
||||
|
||||
if (len)
|
||||
*len = cnt;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user