.Op Fl X Ar socket
.Op Fl m Ar management
.Op Fl I Ar interfaces
+.Op Fl C Ar interfaces
.Op Fl M Ar class
.Op Fl H Ar hide
.Sh DESCRIPTION
.Em eth1
and
.Em eth2 .
+.It Fl C Ar interfaces
+Specify which interfaces to use for computing chassis ID. Without this
+option, all interfaces are considered.
+.Nm
+will take the first MAC address from all the considered interfaces
+to compute the chassis ID. The logic of this option is the same as for
+.Fl I
+flag: you can exclude interfaces with an exclamation mark and use
+globbing to specify several interfaces. If all interfaces are
+blacklisted (with
+.Em !* ) ,
+the system name is used as a chassis ID instead.
.It Fl M Ar class
Enable emission of LLDP-MED frame. The class should be one of the
following value:
struct lldpd_ops eth_ops;
struct lldpd_ops bond_ops;
+static int
+iface_match(char *iface, char *list)
+{
+ char *interfaces = NULL;
+ char *pattern;
+ int found = 0;
+
+ if ((interfaces = strdup(list)) == NULL) {
+ LLOG_WARNX("unable to allocate memory");
+ return 0;
+ }
+
+ for (pattern = strtok(interfaces, ",");
+ pattern != NULL;
+ pattern = strtok(NULL, ",")) {
+ if ((pattern[0] == '!') &&
+ ((fnmatch(pattern + 1, iface, 0) == 0))) {
+ /* Blacklisted. No need to search further. */
+ found = 0;
+ break;
+ }
+ if (fnmatch(pattern, iface, 0) == 0)
+ found = 1;
+ }
+
+ free(interfaces);
+ return found;
+}
+
static int
old_iface_is_bridge(struct lldpd *cfg, const char *name)
{
lldpd_ifh_whitelist(struct lldpd *cfg, struct ifaddrs *ifap)
{
struct ifaddrs *ifa;
- char *interfaces = NULL;
- char *pattern;
- int whitelisted;
if (!cfg->g_interfaces)
return;
- if ((interfaces = strdup(cfg->g_interfaces)) == NULL) {
- LLOG_WARNX("unable to allocate memory");
- return;
- }
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
if (ifa->ifa_flags == 0) continue; /* Already handled by someone else */
- strcpy(interfaces, cfg->g_interfaces); /* Restore our list of interfaces */
- whitelisted = 0;
- for (whitelisted = 0, pattern = strtok(interfaces, ",");
- pattern != NULL;
- pattern = strtok(NULL, ",")) {
- if ((pattern[0] == '!') &&
- ((fnmatch(pattern + 1, ifa->ifa_name, 0) == 0))) {
- /* Blacklisted. Definitive */
- whitelisted = 0;
- break;
- }
- if (fnmatch(pattern, ifa->ifa_name, 0) == 0)
- whitelisted = 1;
- }
- if (!whitelisted) {
+ if (!iface_match(ifa->ifa_name, cfg->g_interfaces)) {
/* This interface was not found. We flag it. */
LLOG_DEBUG("blacklist %s", ifa->ifa_name);
ifa->ifa_flags = 0;
}
}
-
- free(interfaces);
}
static int
return; /* We already have one */
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
- if (ifa->ifa_flags) continue; /* This interface is not valid */
+ if (ifa->ifa_flags) continue;
+ if (cfg->g_cid_pattern &&
+ !iface_match(ifa->ifa_name, cfg->g_cid_pattern)) continue;
if ((hardware = lldpd_get_hardware(cfg,
ifa->ifa_name,
char *agentx = NULL; /* AgentX socket */
#endif
char *mgmtp = NULL;
+ char *cidp = NULL;
char *interfaces = NULL;
char *popt, opts[] =
- "H:hkrdxX:m:I:p:M:S:i@ ";
+ "H:hkrdxX:m:I:C:p:M:S:i@ ";
int i, found, advertise_version = 1;
#ifdef ENABLE_LLDPMED
int lldpmed = 0, noinventory = 0;
case 'I':
interfaces = optarg;
break;
+ case 'C':
+ cidp = optarg;
+ break;
case 'k':
advertise_version = 0;
break;
fatal(NULL);
cfg->g_mgmt_pattern = mgmtp;
+ cfg->g_cid_pattern = cidp;
cfg->g_interfaces = interfaces;
cfg->g_smart = smart;
cfg->g_receiveonly = receiveonly;