From: Fabio M. Di Nitto Date: Tue, 13 Nov 2012 05:32:20 +0000 (+0100) Subject: kronosnetd: fix parsing of ip_list return from libtap X-Git-Tag: v0.8~818 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=120ec499d9e6b41e7741aa9df54750c7cdd98bfc;p=mirror_kronosnet.git kronosnetd: fix parsing of ip_list return from libtap Signed-off-by: Fabio M. Di Nitto --- diff --git a/TODO b/TODO index ad2b05d..510ea82 100644 --- a/TODO +++ b/TODO @@ -13,8 +13,6 @@ compress must happen before encrypt fix libtap init when creating a new interface live (flags issues in libtap) -fix config save (ip... with more than one interface, see orazio) - consider adding dhcp support for tap device need bind to interface for dynamic ip local interfaces vs src ip address or diff --git a/kronosnetd/vty_cli_cmds.c b/kronosnetd/vty_cli_cmds.c index c4d94d1..23d31fe 100644 --- a/kronosnetd/vty_cli_cmds.c +++ b/kronosnetd/vty_cli_cmds.c @@ -1743,7 +1743,7 @@ static int knet_cmd_print_conf(struct knet_vty *vty) struct knet_host *host = NULL; const char *nl = telnet_newline; char *ip_list = NULL; - int ip_list_entries = 0, offset = 0; + int ip_list_entries = 0; if (vty->filemode) nl = file_newline; @@ -1763,10 +1763,12 @@ static int knet_cmd_print_conf(struct knet_vty *vty) tap_get_ips(knet_iface->cfg_eth.tap, &ip_list, &ip_list_entries); if ((ip_list) && (ip_list_entries > 0)) { + char *ipaddr = NULL, *prefix = NULL, *next = ip_list; for (i = 1; i <= ip_list_entries; i++) { - knet_vty_write(vty, " ip %s %s%s", ip_list + offset, ip_list + offset + strlen(ip_list + offset) + 1, nl); - offset = offset + strlen(ip_list) + 1; - offset = offset + strlen(ip_list + offset) + 1; + ipaddr = next; + prefix = ipaddr + strlen(ipaddr) + 1; + next = prefix + strlen(prefix) + 1; + knet_vty_write(vty, " ip %s %s%s", ipaddr, prefix, nl); } free(ip_list); ip_list = NULL;