Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:GA
open-lldp
hex2int-move-to-lldp_utils.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File hex2int-move-to-lldp_utils.patch of Package open-lldp
From: Aaron Conole <aconole@redhat.com> Date: Wed, 13 Jun 2018 10:47:04 -0400 Subject: hex2int: move to lldp_utils Git-commit: a3cdf431a9d8a97f4009c4bdc02857e959c4ba17 Patch-mainline: v1.1 This will be used by an upcoming commit adding a unit test framework. Signed-off-by: Aaron Conole <aconole@redhat.com> Acked-by: Lee Duncan <lduncan@suse.com> --- Makefile.am | 6 ++++-- dcbtool_cmds.c | 23 ----------------------- include/lldp_util.h | 1 + include/lldptool.h | 1 - lldp_util.c | 23 +++++++++++++++++++++++ lldptool.c | 22 ---------------------- 6 files changed, 28 insertions(+), 48 deletions(-) --- a/Makefile.am +++ b/Makefile.am @@ -77,9 +77,11 @@ liblldp_clif_includedir = ${srcdir}/incl liblldp_clif_la_SOURCES = clif.c dcbtool_SOURCES = dcbtool.c dcbtool_cmds.c parse_cli.l \ -weak_readline.c $(lldpad_include_HEADERS) $(noinst_HEADERS) + weak_readline.c lldp_rtnl.c lldp_util.c \ + $(lldpad_include_HEADERS) $(noinst_HEADERS) + dcbtool_LDADD = ${srcdir}/liblldp_clif.la -dcbtool_LDFLAGS = -ldl -llldp_clif +dcbtool_LDFLAGS = -ldl -llldp_clif $(LIBNL_LIBS) lldptool_SOURCES = lldptool.c lldptool_cmds.c lldp_rtnl.c \ lldp_mand_clif.c lldp_basman_clif.c lldp_med_clif.c \ --- a/dcbtool_cmds.c +++ b/dcbtool_cmds.c @@ -38,7 +38,6 @@ static char *print_status(cmd_status status); static char *get_pgdesc_args(int cmd); -static int hex2int(char *b); static void free_cmd_args(char *args); static char *get_dcb_args(void); static char *get_dcbx_args(void); @@ -93,28 +92,6 @@ static char *print_status(cmd_status sta return str; } -/* assumes input is pointer to two hex digits */ -/* returns -1 on error */ -static int hex2int(char *b) -{ - int i; - int n=0; - int m; - - for (i=0,m=1; i<2; i++,m--) { - if (isxdigit(*(b+i))) { - if (*(b+i) <= '9') - n |= (*(b+i) & 0x0f) << (4*m); - else - n |= ((*(b+i) & 0x0f) + 9) << (4*m); - } - else { - return -1; - } - } - return n; -} - static char *get_dcb_args(void) { char buf[8]; --- a/include/lldp_util.h +++ b/include/lldp_util.h @@ -119,6 +119,7 @@ int hexstr2bin(const char *hex, u8 *buf, size_t len); int bin2hexstr(const u8 *hex, size_t hexlen, char *buf, size_t buflen); +int hex2int(char *b); int is_valid_lldp_device(const char *ifname); int is_active(const char *ifname); --- a/include/lldptool.h +++ b/include/lldptool.h @@ -31,7 +31,6 @@ struct lldp_head lldp_cli_head; -int hex2int(char *b); int clif_command(struct clif *clif, char *cmd, int raw); void print_raw_message(char *msg, int print); int parse_print_message(char *msg, int print); --- a/lldp_util.c +++ b/lldp_util.c @@ -24,6 +24,7 @@ *******************************************************************************/ +#include <ctype.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -122,6 +123,28 @@ int hexstr2bin(const char *hex, u8 *buf, return 0; } +/* assumes input is pointer to two hex digits */ +/* returns -1 on error */ +int hex2int(char *b) +{ + int i; + int n=0; + int m; + + for (i=0,m=1; i<2; i++,m--) { + if (isxdigit(*(b+i))) { + if (*(b+i) <= '9') + n |= (*(b+i) & 0x0f) << (4*m); + else + n |= ((*(b+i) & 0x0f) + 9) << (4*m); + } + else { + return -1; + } + } + return n; +} + char *print_mac(char *mac, char *buf) { sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x", --- a/lldptool.c +++ b/lldptool.c @@ -222,28 +222,6 @@ static void usage(void) commands_usage, commands_options, commands_help); } -/* assumes input is pointer to two hex digits */ -/* returns -1 on error */ -int hex2int(char *b) -{ - int i; - int n=0; - int m; - - for (i=0,m=1; i<2; i++,m--) { - if (isxdigit(*(b+i))) { - if (*(b+i) <= '9') - n |= (*(b+i) & 0x0f) << (4*m); - else - n |= ((*(b+i) & 0x0f) + 9) << (4*m); - } - else { - return -1; - } - } - return n; -} - void print_raw_message(char *msg, int print) { if (!print || !(print & SHOW_RAW))
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor