summaryrefslogtreecommitdiff
path: root/lib/command.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-01-31 13:27:42 -0500
committerGitHub <noreply@github.com>2017-01-31 13:27:42 -0500
commite46538e628ccab900bc58885204fc26ad0c6d8a2 (patch)
treec67194c749021ebf1fcf116b97d9246095a27e60 /lib/command.c
parent0a44125727920f6e7e3ab2298edfc426dc819548 (diff)
parent3a8b1ac043bc7be3cd8e1c58b977febd8cb6958d (diff)
Merge pull request #139 from opensourcerouting/cli_merge_prep_final
CLI split merge-step preparations
Diffstat (limited to 'lib/command.c')
-rw-r--r--lib/command.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/command.c b/lib/command.c
index 9485beddd9..510699f91b 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -1541,6 +1541,14 @@ DEFUN (show_startup_config,
return CMD_SUCCESS;
}
+int
+cmd_hostname_set (const char *hostname)
+{
+ XFREE (MTYPE_HOST, host.name);
+ host.name = hostname ? XSTRDUP (MTYPE_HOST, hostname) : NULL;
+ return CMD_SUCCESS;
+}
+
/* Hostname configuration */
DEFUN (config_hostname,
hostname_cmd,
@@ -1556,11 +1564,7 @@ DEFUN (config_hostname,
return CMD_WARNING;
}
- if (host.name)
- XFREE (MTYPE_HOST, host.name);
-
- host.name = XSTRDUP (MTYPE_HOST, word->arg);
- return CMD_SUCCESS;
+ return cmd_hostname_set (word->arg);
}
DEFUN (config_no_hostname,
@@ -1570,10 +1574,7 @@ DEFUN (config_no_hostname,
"Reset system's network name\n"
"Host name of this router\n")
{
- if (host.name)
- XFREE (MTYPE_HOST, host.name);
- host.name = NULL;
- return CMD_SUCCESS;
+ return cmd_hostname_set (NULL);
}
/* VTY interface password set. */