N(lldpctl_atom_get_str(configuration, lldpctl_k_config_iface_pattern)));
tag_datatag(w, "cid-pattern", "Interface pattern for chassis ID",
N(lldpctl_atom_get_str(configuration, lldpctl_k_config_cid_pattern)));
+ tag_datatag(w, "cid-string", "User defined string for chassis ID",
+ N(lldpctl_atom_get_str(configuration, lldpctl_k_config_cid_string)));
tag_datatag(w, "description", "Override description with",
N(lldpctl_atom_get_str(configuration, lldpctl_k_config_description)));
tag_datatag(w, "platform", "Override platform with",
interface for example)
*/
if (LOCAL_CHASSIS(cfg)->c_id == NULL) {
- log_debug("localchassis", "no chassis ID is currently set, use chassis name");
- if (!(LOCAL_CHASSIS(cfg)->c_id = strdup(LOCAL_CHASSIS(cfg)->c_name)))
+ if (cfg->g_config.c_cid_string != NULL) {
+ log_debug("localchassis", "no chassis ID is currently set, use chassis id string");
+ if (!(LOCAL_CHASSIS(cfg)->c_id = strdup(cfg->g_config.c_cid_string)))
fatal("localchassis", NULL);
- LOCAL_CHASSIS(cfg)->c_id_len = strlen(LOCAL_CHASSIS(cfg)->c_name);
- LOCAL_CHASSIS(cfg)->c_id_subtype = LLDP_CHASSISID_SUBTYPE_LOCAL;
+ LOCAL_CHASSIS(cfg)->c_id_len = strlen(cfg->g_config.c_cid_string);
+ LOCAL_CHASSIS(cfg)->c_id_subtype = LLDP_CHASSISID_SUBTYPE_LOCAL;
+ } else {
+ log_debug("localchassis", "no chassis ID is currently set, use chassis name");
+ if (!(LOCAL_CHASSIS(cfg)->c_id = strdup(LOCAL_CHASSIS(cfg)->c_name)))
+ fatal("localchassis", NULL);
+ LOCAL_CHASSIS(cfg)->c_id_len = strlen(LOCAL_CHASSIS(cfg)->c_name);
+ LOCAL_CHASSIS(cfg)->c_id_subtype = LLDP_CHASSISID_SUBTYPE_LOCAL;
+ }
}
}
#endif
const char *ctlname = NULL;
char *mgmtp = NULL;
- char *cidp = NULL;
+ char *cidp = NULL, *cids = NULL;
char *interfaces = NULL;
/* We do not want more options here. Please add them in lldpcli instead
* unless there is a very good reason. Most command-line options will
* get deprecated at some point. */
char *popt, opts[] =
- "H:vhkrdD:p:xX:m:u:4:6:I:C:p:M:P:S:iL:O:@ ";
+ "H:vhkrdD:p:xX:m:u:4:6:I:C:c:p:M:P:S:iL:O:@ ";
int i, found, advertise_version = 1;
#ifdef ENABLE_LLDPMED
int lldpmed = 0, noinventory = 0;
}
cidp = strdup(optarg);
break;
+ case 'c':
+ if (cids) {
+ fprintf(stderr, "-c can only be used once\n");
+ usage();
+ }
+ cids = strdup(optarg);
+ break;
case 'L':
if (strlen(optarg)) lldpcli = optarg;
else lldpcli = NULL;
cfg->g_ctl = ctl;
cfg->g_config.c_mgmt_pattern = mgmtp;
cfg->g_config.c_cid_pattern = cidp;
+ cfg->g_config.c_cid_string = cids;
cfg->g_config.c_iface_pattern = interfaces;
cfg->g_config.c_smart = smart;
if (lldpcli)
res = c->config->c_iface_pattern; break;
case lldpctl_k_config_cid_pattern:
res = c->config->c_cid_pattern; break;
+ case lldpctl_k_config_cid_string:
+ res = c->config->c_cid_string; break;
case lldpctl_k_config_description:
res = c->config->c_description; break;
case lldpctl_k_config_platform:
lldpctl_k_config_mgmt_pattern, /**< `(S,WON)` Pattern to choose the management address */
lldpctl_k_config_iface_pattern, /**< `(S,WON)` Pattern of enabled interfaces */
lldpctl_k_config_cid_pattern, /**< `(S)` Interface pattern to choose the chassis ID */
+ lldpctl_k_config_cid_string, /**< `(S)` User defined string for the chassis ID */
lldpctl_k_config_description, /**< `(S,WON)` Chassis description overridden */
lldpctl_k_config_platform, /**< `(S,WON)` Platform description overridden (CDP) */
lldpctl_k_config_hostname, /**< `(S,WON)` System name overridden */
log_debug("alloc", "general configuration cleanup");
free(config->c_mgmt_pattern);
free(config->c_cid_pattern);
+ free(config->c_cid_string);
free(config->c_iface_pattern);
free(config->c_hostname);
free(config->c_platform);
char *c_mgmt_pattern; /* Pattern to match a management address */
char *c_cid_pattern; /* Pattern to match interfaces to use for chassis ID */
+ char *c_cid_string; /* User defined string for chassis ID */
char *c_iface_pattern; /* Pattern to match interfaces to use */
char *c_platform; /* Override platform description (for CDP) */
MARSHAL_BEGIN(lldpd_config)
MARSHAL_STR(lldpd_config, c_mgmt_pattern)
MARSHAL_STR(lldpd_config, c_cid_pattern)
+MARSHAL_STR(lldpd_config, c_cid_string)
MARSHAL_STR(lldpd_config, c_iface_pattern)
MARSHAL_STR(lldpd_config, c_hostname)
MARSHAL_STR(lldpd_config, c_platform)