{
lldpctl_atom_t *iface;
const char *id = cmdenv_get(env, "port-id");
+ const char *descr = cmdenv_get(env, "port-descr");
if (!id || !strlen(id)) {
log_warnx("lldpctl", "no id speficied");
log_warnx("lldpctl", "unable to set LLDP PortID."
" %s", lldpctl_last_strerror(conn));
}
+ if (descr && lldpctl_atom_set_str(port, lldpctl_k_port_descr, descr) == NULL) {
+ log_warnx("lldpctl", "unable to set LLDP Port Description."
+ " %s", lldpctl_last_strerror(conn));
+ }
lldpctl_atom_dec_ref(port);
}
NULL, cmd_portid_type,
b_map->string);
} else if (!strcmp(b_map->string, "local")) {
- commands_new(
- commands_new(
- commands_new(configure_lldp_portid_type,
- b_map->string, "Local",
- NULL, NULL, NULL),
- NULL, "PortID",
- NULL, cmd_store_env_value, "port-id"),
+ struct cmd_node *port_id = commands_new(
+ commands_new(configure_lldp_portid_type,
+ b_map->string, "Local",
+ NULL, NULL, NULL),
+ NULL, "PortID",
+ NULL, cmd_store_env_value, "port-id");
+ commands_new(port_id,
NEWLINE, NULL,
NULL, cmd_portid_type_local,
b_map->string);
+ commands_new(port_id,
+ NULL, "Port Description",
+ NULL, cmd_store_env_value_and_pop, "port-descr");
} else if (!strcmp(b_map->string, "macaddress")) {
commands_new(
commands_new(configure_lldp_portid_type,
port->p_id_len = strlen(set->local_id);
port->p_id_subtype = LLDP_PORTID_SUBTYPE_LOCAL;
}
+ if (set->local_descr) {
+ log_debug("rpc", "requested change to Port Description");
+ free(port->p_descr);
+ port->p_descr = strdup(set->local_descr);
+ }
#ifdef ENABLE_LLDPMED
if (set->med_policy && set->med_policy->type > 0) {
log_debug("rpc", "requested change to MED policy");
if (!ret) *type = NONE;
free(set->ifname);
free(set->local_id);
+ free(set->local_descr);
#ifdef ENABLE_LLDPMED
free(set->med_policy);
if (set->med_location) free(set->med_location->data);
struct lldpd_port *port = &hardware->h_lport;
if (port->p_id_subtype == LLDP_PORTID_SUBTYPE_LOCAL)
- goto description;
+ return;
/* We need to set the portid to what the client configured.
This can be done from the CLI.
port->p_id_len = ETHER_ADDR_LEN;
}
-description:
if (iface->alias != NULL && strlen(iface->alias) != 0) {
/* use the actual alias in the port description */
log_debug("interfaces", "using alias in description for %s",
case lldpctl_k_port_id:
set.local_id = p->port->p_id;
break;
+ case lldpctl_k_port_descr:
+ set.local_descr = p->port->p_descr;
+ break;
#ifdef ENABLE_DOT3
case lldpctl_k_port_dot3_power:
if (value->type != atom_dot3_power) {
port->p_id = strdup(value);
port->p_id_len = strlen(value);
break;
+ case lldpctl_k_port_descr:
+ free(port->p_descr);
+ port->p_descr = strdup(value);
+ break;
default:
SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST);
return NULL;
lldpctl_k_port_age, /**< `(I)` Age of information, seconds from epoch. */
lldpctl_k_port_id_subtype, /**< `(IS)` The subtype ID of this port. */
lldpctl_k_port_id, /**< `(BS,WO)` The ID of this port. */
- lldpctl_k_port_descr, /**< `(S)` The description of this port. */
+ lldpctl_k_port_descr, /**< `(S,W)` The description of this port. */
lldpctl_k_port_hidden, /**< `(I)` Is this port hidden (or should it be displayed?)? */
lldpctl_k_port_dot3_mfs = 1300, /**< `(I)` MFS */
#endif
/* will set these to NULL so we don't free wrong memory */
- free(port->p_descr);
- port->p_descr = NULL;
if (all) {
free(port->p_id);
port->p_id = NULL;
+ free(port->p_descr);
+ port->p_descr = NULL;
free(port->p_lastframe);
if (port->p_chassis) { /* chassis may not have been attributed, yet */
port->p_chassis->c_refcount--;
struct lldpd_port_set {
char *ifname;
char *local_id;
+ char *local_descr;
#ifdef ENABLE_LLDPMED
struct lldpd_med_policy *med_policy;
struct lldpd_med_loc *med_location;
MARSHAL_BEGIN(lldpd_port_set)
MARSHAL_STR(lldpd_port_set, ifname)
MARSHAL_STR(lldpd_port_set, local_id)
+MARSHAL_STR(lldpd_port_set, local_descr)
#ifdef ENABLE_LLDPMED
MARSHAL_POINTER(lldpd_port_set, lldpd_med_policy, med_policy)
MARSHAL_POINTER(lldpd_port_set, lldpd_med_loc, med_location)