return 1;
}
+static int
+cmd_management(struct lldpctl_conn_t *conn, struct writer *w,
+ struct cmd_env *env, void *arg)
+{
+ log_debug("lldpctl", "set management pattern");
+
+ lldpctl_atom_t *config = lldpctl_get_configuration(conn);
+ if (config == NULL) {
+ log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
+ lldpctl_last_strerror(conn));
+ return 0;
+ }
+ const char *value = cmdenv_get(env, "management-pattern");
+
+ if (lldpctl_atom_set_str(config,
+ lldpctl_k_config_mgmt_pattern, value) == NULL) {
+ log_warnx("lldpctl", "unable to set management pattern. %s",
+ lldpctl_last_strerror(conn));
+ lldpctl_atom_dec_ref(config);
+ return 0;
+ }
+ log_info("lldpctl", "management pattaren set to new value %s", value);
+ lldpctl_atom_dec_ref(config);
+ return 1;
+}
+
static int
cmd_hostname(struct lldpctl_conn_t *conn, struct writer *w,
struct cmd_env *env, void *arg)
const char *value = cmdenv_get(env, "hostname");
if (lldpctl_atom_set_str(config,
- lldpctl_k_config_hostname, cmdenv_get(env, "hostname")) == NULL) {
+ lldpctl_k_config_hostname, value) == NULL) {
log_warnx("lldpctl", "unable to set system name. %s",
lldpctl_last_strerror(conn));
lldpctl_atom_dec_ref(config);
NEWLINE, "Override system name",
NULL, cmd_hostname, NULL);
+ commands_new(
+ commands_new(
+ commands_new(
+ commands_new(
+ commands_new(configure_system,
+ "ip", "IP related options",
+ NULL, NULL, NULL),
+ "management", "IP management related options",
+ NULL, NULL, NULL),
+ "pattern", "Set IP management pattern",
+ NULL, NULL, NULL),
+ NULL, "IP management pattern (comma-separated list of wildcards)",
+ NULL, cmd_store_env_value, "management-pattern"),
+ NEWLINE, "Set IP management pattern",
+ NULL, cmd_management, NULL);
+
commands_new(
commands_new(
commands_new(configure_interface,
"pattern", "Set active interface pattern",
NULL, NULL, NULL),
- NULL, "Interface pattern (comma separated list of wildcards)",
+ NULL, "Interface pattern (comma-separated list of wildcards)",
NULL, cmd_store_env_value, "iface-pattern"),
NEWLINE, "Set active interface pattern",
NULL, cmd_iface_pattern, NULL);
is found or with the number of neighbors found.
.Ed
+.Cd configure
+.Cd system ip management pattern Ar pattern
+.Bd -ragged -offset XXXXXX
+Specify the management addresses of this system. As for interfaces
+(described above), this option can use wildcards and inversions.
+Without this option, the first IPv4 and the first IPv6 are used. If
+only negative patterns are provided, only one IPv4 and one IPv6
+addresses are chosen. Otherwise, many of them can be selected. If you
+want to blacklist IPv6 addresses, you can use
+.Em !*:* .
+.Ed
+
.Cd configure
.Cd lldp tx-interval Ar interval
.Bd -ragged -offset XXXXXX
struct _lldpctl_atom_config_t *c =
(struct _lldpctl_atom_config_t *)atom;
struct lldpd_config config = {};
- char *iface_pattern = NULL;
+ char *iface_pattern = NULL, *mgmt_pattern = NULL;
char *description = NULL;
int rc, len;
free(c->config->c_iface_pattern);
c->config->c_iface_pattern = strdup(iface_pattern);
break;
+ case lldpctl_k_config_mgmt_pattern:
+ mgmt_pattern = _lldpctl_alloc_in_atom(atom, strlen(value) + 1);
+ if (!mgmt_pattern)
+ return NULL;
+ memcpy(mgmt_pattern, value, len);
+ config.c_mgmt_pattern = mgmt_pattern;
+ free(c->config->c_mgmt_pattern);
+ c->config->c_mgmt_pattern = strdup(mgmt_pattern);
+ break;
case lldpctl_k_config_description:
description = _lldpctl_alloc_in_atom(atom, strlen(value) + 1);
if (!description)