/* key-chain for authentication.
- Copyright (C) 2000 Kunihiro Ishiguro
-
-This file is part of GNU Zebra.
-
-GNU Zebra is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published
-by the Free Software Foundation; either version 2, or (at your
-option) any later version.
-
-GNU Zebra is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Zebra; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+ * Copyright (C) 2000 Kunihiro Ishiguro
+ *
+ * This file is part of GNU Zebra.
+ *
+ * GNU Zebra is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * GNU Zebra is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
#include <zebra.h>
if (keychain->name)
XFREE(MTYPE_KEYCHAIN, keychain->name);
- list_delete(keychain->key);
+ list_delete(&keychain->key);
listnode_delete(keychain_list, keychain);
keychain_free(keychain);
}
-static struct key *key_lookup(const struct keychain *keychain, u_int32_t index)
+static struct key *key_lookup(const struct keychain *keychain, uint32_t index)
{
struct listnode *node;
struct key *key;
}
struct key *key_lookup_for_accept(const struct keychain *keychain,
- u_int32_t index)
+ uint32_t index)
{
struct listnode *node;
struct key *key;
if (key->accept.start == 0
|| (key->accept.start <= now
&& (key->accept.end >= now || key->accept.end == -1)))
- if (strncmp(key->string, auth_str, 16) == 0)
+ if (key->string && (strncmp(key->string, auth_str, 16) == 0))
return key;
}
return NULL;
return NULL;
}
-static struct key *key_get(const struct keychain *keychain, u_int32_t index)
+static struct key *key_get(const struct keychain *keychain, uint32_t index)
{
struct key *key;
keychain = keychain_lookup(argv[idx_word]->arg);
if (!keychain) {
- vty_out(vty, "Can't find keychain %s%s", argv[idx_word]->arg,
- VTY_NEWLINE);
- return CMD_WARNING;
+ vty_out(vty, "Can't find keychain %s\n", argv[idx_word]->arg);
+ return CMD_WARNING_CONFIG_FAILED;
}
keychain_delete(keychain);
int idx_number = 1;
VTY_DECLVAR_CONTEXT(keychain, keychain);
struct key *key;
- u_int32_t index;
+ uint32_t index;
- VTY_GET_INTEGER("key identifier", index, argv[idx_number]->arg);
+ index = strtoul(argv[idx_number]->arg, NULL, 10);
key = key_get(keychain, index);
VTY_PUSH_CONTEXT_SUB(KEYCHAIN_KEY_NODE, key);
int idx_number = 2;
VTY_DECLVAR_CONTEXT(keychain, keychain);
struct key *key;
- u_int32_t index;
+ uint32_t index;
- VTY_GET_INTEGER("key identifier", index, argv[idx_number]->arg);
+ index = strtoul(argv[idx_number]->arg, NULL, 10);
key = key_lookup(keychain, index);
if (!key) {
- vty_out(vty, "Can't find key %d%s", index, VTY_NEWLINE);
- return CMD_WARNING;
+ vty_out(vty, "Can't find key %d\n", index);
+ return CMD_WARNING_CONFIG_FAILED;
}
key_delete(keychain, key);
time_start = key_str2time(stime_str, sday_str, smonth_str, syear_str);
if (time_start < 0) {
- vty_out(vty, "Malformed time value%s", VTY_NEWLINE);
- return CMD_WARNING;
+ vty_out(vty, "Malformed time value\n");
+ return CMD_WARNING_CONFIG_FAILED;
}
time_end = key_str2time(etime_str, eday_str, emonth_str, eyear_str);
if (time_end < 0) {
- vty_out(vty, "Malformed time value%s", VTY_NEWLINE);
- return CMD_WARNING;
+ vty_out(vty, "Malformed time value\n");
+ return CMD_WARNING_CONFIG_FAILED;
}
if (time_end <= time_start) {
- vty_out(vty, "Expire time is not later than start time%s",
- VTY_NEWLINE);
- return CMD_WARNING;
+ vty_out(vty, "Expire time is not later than start time\n");
+ return CMD_WARNING_CONFIG_FAILED;
}
krange->start = time_start;
const char *duration_str)
{
time_t time_start;
- u_int32_t duration;
+ uint32_t duration;
time_start = key_str2time(stime_str, sday_str, smonth_str, syear_str);
if (time_start < 0) {
- vty_out(vty, "Malformed time value%s", VTY_NEWLINE);
- return CMD_WARNING;
+ vty_out(vty, "Malformed time value\n");
+ return CMD_WARNING_CONFIG_FAILED;
}
krange->start = time_start;
- VTY_GET_INTEGER("duration", duration, duration_str);
+ duration = strtoul(duration_str, NULL, 10);
krange->duration = 1;
krange->end = time_start + duration;
time_start = key_str2time(stime_str, sday_str, smonth_str, syear_str);
if (time_start < 0) {
- vty_out(vty, "Malformed time value%s", VTY_NEWLINE);
- return CMD_WARNING;
+ vty_out(vty, "Malformed time value\n");
+ return CMD_WARNING_CONFIG_FAILED;
}
krange->start = time_start;
"Day of th month to start\n"
"Month of the year to start\n"
"Year to start\n"
- "Never expires")
+ "Never expires\n")
{
int idx_hhmmss = 1;
int idx_number = 2;
"Month of the year to start\n"
"Day of th month to start\n"
"Year to start\n"
- "Never expires")
+ "Never expires\n")
{
int idx_hhmmss = 1;
int idx_month = 2;
argv[idx_number_3]->arg);
}
+DEFUN (no_accept_lifetime,
+ no_accept_lifetime_cmd,
+ "no accept-lifetime",
+ NO_STR
+ "Unset accept-lifetime\n")
+{
+ VTY_DECLVAR_CONTEXT_SUB(key, key);
+
+ if (key->accept.start)
+ key->accept.start = 0;
+ if (key->accept.end)
+ key->accept.end = 0;
+ if (key->accept.duration)
+ key->accept.duration = 0;
+
+ return CMD_SUCCESS;
+}
+
DEFUN (send_lifetime_day_month_day_month,
send_lifetime_day_month_day_month_cmd,
"send-lifetime HH:MM:SS (1-31) MONTH (1993-2035) HH:MM:SS (1-31) MONTH (1993-2035)",
"Day of th month to start\n"
"Month of the year to start\n"
"Year to start\n"
- "Never expires")
+ "Never expires\n")
{
int idx_hhmmss = 1;
int idx_number = 2;
"Month of the year to start\n"
"Day of th month to start\n"
"Year to start\n"
- "Never expires")
+ "Never expires\n")
{
int idx_hhmmss = 1;
int idx_month = 2;
argv[idx_number_3]->arg);
}
+DEFUN (no_send_lifetime,
+ no_send_lifetime_cmd,
+ "no send-lifetime",
+ NO_STR
+ "Unset send-lifetime\n")
+{
+ VTY_DECLVAR_CONTEXT_SUB(key, key);
+
+ if (key->send.start)
+ key->send.start = 0;
+ if (key->send.end)
+ key->send.end = 0;
+ if (key->send.duration)
+ key->send.duration = 0;
+
+ return CMD_SUCCESS;
+}
+
static struct cmd_node keychain_node = {KEYCHAIN_NODE, "%s(config-keychain)# ",
1};
char buf[BUFSIZ];
for (ALL_LIST_ELEMENTS_RO(keychain_list, node, keychain)) {
- vty_out(vty, "key chain %s%s", keychain->name, VTY_NEWLINE);
+ vty_out(vty, "key chain %s\n", keychain->name);
for (ALL_LIST_ELEMENTS_RO(keychain->key, knode, key)) {
- vty_out(vty, " key %d%s", key->index, VTY_NEWLINE);
+ vty_out(vty, " key %d\n", key->index);
if (key->string)
- vty_out(vty, " key-string %s%s", key->string,
- VTY_NEWLINE);
+ vty_out(vty, " key-string %s\n", key->string);
if (key->accept.start) {
keychain_strftime(buf, BUFSIZ,
&key->accept.end);
vty_out(vty, " %s", buf);
}
- vty_out(vty, "%s", VTY_NEWLINE);
+ vty_out(vty, "\n");
}
if (key->send.start) {
&key->send.end);
vty_out(vty, " %s", buf);
}
- vty_out(vty, "%s", VTY_NEWLINE);
+ vty_out(vty, "\n");
}
}
- vty_out(vty, "!%s", VTY_NEWLINE);
+ vty_out(vty, "!\n");
}
return 0;
&accept_lifetime_duration_day_month_cmd);
install_element(KEYCHAIN_KEY_NODE,
&accept_lifetime_duration_month_day_cmd);
+ install_element(KEYCHAIN_KEY_NODE, &no_accept_lifetime_cmd);
install_element(KEYCHAIN_KEY_NODE,
&send_lifetime_day_month_day_month_cmd);
&send_lifetime_duration_day_month_cmd);
install_element(KEYCHAIN_KEY_NODE,
&send_lifetime_duration_month_day_cmd);
+ install_element(KEYCHAIN_KEY_NODE, &no_send_lifetime_cmd);
}