mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 10:37:29 +00:00
isisd: API: circuit password
This cleans up circuit password configuration a little bit. (Restructured several times by both Christian Franke and David Lamparter.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
a38a72db2c
commit
50c7d14a2a
@ -1334,72 +1334,41 @@ isis_circuit_metric_set (struct isis_circuit *circuit, int level, int metric)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN (isis_passwd_md5,
|
int
|
||||||
isis_passwd_md5_cmd,
|
isis_circuit_passwd_unset (struct isis_circuit *circuit)
|
||||||
"isis password md5 WORD",
|
|
||||||
"IS-IS commands\n"
|
|
||||||
"Configure the authentication password for a circuit\n"
|
|
||||||
"Authentication type\n"
|
|
||||||
"Circuit password\n")
|
|
||||||
{
|
{
|
||||||
int len;
|
memset(&circuit->passwd, 0, sizeof(circuit->passwd));
|
||||||
struct isis_circuit *circuit = isis_circuit_lookup (vty);
|
return 0;
|
||||||
if (!circuit)
|
|
||||||
return CMD_ERR_NO_MATCH;
|
|
||||||
|
|
||||||
len = strlen (argv[0]);
|
|
||||||
if (len > 254)
|
|
||||||
{
|
|
||||||
vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
|
|
||||||
return CMD_ERR_AMBIGUOUS;
|
|
||||||
}
|
|
||||||
circuit->passwd.len = len;
|
|
||||||
circuit->passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
|
|
||||||
strncpy ((char *)circuit->passwd.passwd, argv[0], 255);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN (isis_passwd_clear,
|
static int
|
||||||
isis_passwd_clear_cmd,
|
isis_circuit_passwd_set (struct isis_circuit *circuit, u_char passwd_type, const char *passwd)
|
||||||
"isis password clear WORD",
|
|
||||||
"IS-IS commands\n"
|
|
||||||
"Configure the authentication password for a circuit\n"
|
|
||||||
"Authentication type\n"
|
|
||||||
"Circuit password\n")
|
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
struct isis_circuit *circuit = isis_circuit_lookup (vty);
|
|
||||||
if (!circuit)
|
|
||||||
return CMD_ERR_NO_MATCH;
|
|
||||||
|
|
||||||
len = strlen (argv[0]);
|
if (!passwd)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
len = strlen(passwd);
|
||||||
if (len > 254)
|
if (len > 254)
|
||||||
{
|
return -1;
|
||||||
vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
|
|
||||||
return CMD_ERR_AMBIGUOUS;
|
|
||||||
}
|
|
||||||
circuit->passwd.len = len;
|
|
||||||
circuit->passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
|
|
||||||
strncpy ((char *)circuit->passwd.passwd, argv[0], 255);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
circuit->passwd.len = len;
|
||||||
|
strncpy((char *)circuit->passwd.passwd, passwd, 255);
|
||||||
|
circuit->passwd.type = passwd_type;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN (no_isis_passwd,
|
int
|
||||||
no_isis_passwd_cmd,
|
isis_circuit_passwd_cleartext_set (struct isis_circuit *circuit, const char *passwd)
|
||||||
"no isis password",
|
|
||||||
NO_STR
|
|
||||||
"IS-IS commands\n"
|
|
||||||
"Configure the authentication password for a circuit\n")
|
|
||||||
{
|
{
|
||||||
struct isis_circuit *circuit = isis_circuit_lookup (vty);
|
return isis_circuit_passwd_set (circuit, ISIS_PASSWD_TYPE_CLEARTXT, passwd);
|
||||||
if (!circuit)
|
}
|
||||||
return CMD_ERR_NO_MATCH;
|
|
||||||
|
|
||||||
memset (&circuit->passwd, 0, sizeof (struct isis_passwd));
|
int
|
||||||
|
isis_circuit_passwd_hmac_md5_set (struct isis_circuit *circuit, const char *passwd)
|
||||||
return CMD_SUCCESS;
|
{
|
||||||
|
return isis_circuit_passwd_set (circuit, ISIS_PASSWD_TYPE_HMAC_MD5, passwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN (isis_hello_interval,
|
DEFUN (isis_hello_interval,
|
||||||
@ -2145,10 +2114,6 @@ isis_circuit_init ()
|
|||||||
install_element (INTERFACE_NODE, &interface_desc_cmd);
|
install_element (INTERFACE_NODE, &interface_desc_cmd);
|
||||||
install_element (INTERFACE_NODE, &no_interface_desc_cmd);
|
install_element (INTERFACE_NODE, &no_interface_desc_cmd);
|
||||||
|
|
||||||
install_element (INTERFACE_NODE, &isis_passwd_clear_cmd);
|
|
||||||
install_element (INTERFACE_NODE, &isis_passwd_md5_cmd);
|
|
||||||
install_element (INTERFACE_NODE, &no_isis_passwd_cmd);
|
|
||||||
|
|
||||||
install_element (INTERFACE_NODE, &isis_hello_interval_cmd);
|
install_element (INTERFACE_NODE, &isis_hello_interval_cmd);
|
||||||
install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd);
|
install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd);
|
||||||
install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd);
|
install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd);
|
||||||
|
@ -179,4 +179,8 @@ int isis_circuit_circ_type_set (struct isis_circuit *circuit, int circ_type);
|
|||||||
|
|
||||||
int isis_circuit_metric_set (struct isis_circuit *circuit, int level, int metric);
|
int isis_circuit_metric_set (struct isis_circuit *circuit, int level, int metric);
|
||||||
|
|
||||||
|
int isis_circuit_passwd_unset (struct isis_circuit *circuit);
|
||||||
|
int isis_circuit_passwd_cleartext_set (struct isis_circuit *circuit, const char *passwd);
|
||||||
|
int isis_circuit_passwd_hmac_md5_set (struct isis_circuit *circuit, const char *passwd);
|
||||||
|
|
||||||
#endif /* _ZEBRA_ISIS_CIRCUIT_H */
|
#endif /* _ZEBRA_ISIS_CIRCUIT_H */
|
||||||
|
@ -293,6 +293,59 @@ DEFUN (no_isis_network,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFUN (isis_passwd,
|
||||||
|
isis_passwd_cmd,
|
||||||
|
"isis password (md5|clear) WORD",
|
||||||
|
"IS-IS commands\n"
|
||||||
|
"Configure the authentication password for a circuit\n"
|
||||||
|
"HMAC-MD5 authentication\n"
|
||||||
|
"Cleartext password\n"
|
||||||
|
"Circuit password\n")
|
||||||
|
{
|
||||||
|
struct isis_circuit *circuit = isis_circuit_lookup (vty);
|
||||||
|
int rv;
|
||||||
|
if (!circuit)
|
||||||
|
return CMD_ERR_NO_MATCH;
|
||||||
|
|
||||||
|
if (argv[0][0] == 'm')
|
||||||
|
rv = isis_circuit_passwd_hmac_md5_set(circuit, argv[1]);
|
||||||
|
else
|
||||||
|
rv = isis_circuit_passwd_cleartext_set(circuit, argv[1]);
|
||||||
|
if (rv)
|
||||||
|
{
|
||||||
|
vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
|
||||||
|
return CMD_ERR_AMBIGUOUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFUN (no_isis_passwd,
|
||||||
|
no_isis_passwd_cmd,
|
||||||
|
"no isis password",
|
||||||
|
NO_STR
|
||||||
|
"IS-IS commands\n"
|
||||||
|
"Configure the authentication password for a circuit\n")
|
||||||
|
{
|
||||||
|
struct isis_circuit *circuit = isis_circuit_lookup (vty);
|
||||||
|
if (!circuit)
|
||||||
|
return CMD_ERR_NO_MATCH;
|
||||||
|
|
||||||
|
isis_circuit_passwd_unset(circuit);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
ALIAS (no_isis_passwd,
|
||||||
|
no_isis_passwd_arg_cmd,
|
||||||
|
"no isis password (md5|clear) WORD",
|
||||||
|
NO_STR
|
||||||
|
"IS-IS commands\n"
|
||||||
|
"Configure the authentication password for a circuit\n"
|
||||||
|
"HMAC-MD5 authentication\n"
|
||||||
|
"Cleartext password\n"
|
||||||
|
"Circuit password\n")
|
||||||
|
|
||||||
DEFUN (isis_priority,
|
DEFUN (isis_priority,
|
||||||
isis_priority_cmd,
|
isis_priority_cmd,
|
||||||
"isis priority <0-127>",
|
"isis priority <0-127>",
|
||||||
@ -822,6 +875,10 @@ isis_vty_init (void)
|
|||||||
install_element (INTERFACE_NODE, &isis_network_cmd);
|
install_element (INTERFACE_NODE, &isis_network_cmd);
|
||||||
install_element (INTERFACE_NODE, &no_isis_network_cmd);
|
install_element (INTERFACE_NODE, &no_isis_network_cmd);
|
||||||
|
|
||||||
|
install_element (INTERFACE_NODE, &isis_passwd_cmd);
|
||||||
|
install_element (INTERFACE_NODE, &no_isis_passwd_cmd);
|
||||||
|
install_element (INTERFACE_NODE, &no_isis_passwd_arg_cmd);
|
||||||
|
|
||||||
install_element (INTERFACE_NODE, &isis_priority_cmd);
|
install_element (INTERFACE_NODE, &isis_priority_cmd);
|
||||||
install_element (INTERFACE_NODE, &no_isis_priority_cmd);
|
install_element (INTERFACE_NODE, &no_isis_priority_cmd);
|
||||||
install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd);
|
install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd);
|
||||||
|
Loading…
Reference in New Issue
Block a user