{
struct lldpd_port *port = &hardware->h_lport;
- if (port->p_id_subtype == LLDP_PORTID_SUBTYPE_LOCAL)
- return;
-
/* We need to set the portid to what the client configured.
This can be done from the CLI.
*/
- switch (cfg->g_config.c_lldp_portid_type) {
- case LLDP_PORTID_SUBTYPE_IFNAME:
- log_debug("interfaces", "use ifname for %s",
- hardware->h_ifname);
- port->p_id_subtype = LLDP_PORTID_SUBTYPE_IFNAME;
- port->p_id_len = strlen(hardware->h_ifname);
- free(port->p_id);
- if ((port->p_id = calloc(1, port->p_id_len)) == NULL)
- fatal("interfaces", NULL);
- memcpy(port->p_id, hardware->h_ifname, port->p_id_len);
- break;
- case LLDP_PORTID_SUBTYPE_LLADDR:
- /* fall through so we use the mac address */
- default:
- log_debug("interfaces", "use MAC address for %s",
- hardware->h_ifname);
- port->p_id_subtype = LLDP_PORTID_SUBTYPE_LLADDR;
- free(port->p_id);
- if ((port->p_id = calloc(1, ETHER_ADDR_LEN)) == NULL)
- fatal("interfaces", NULL);
- memcpy(port->p_id, hardware->h_lladdr, ETHER_ADDR_LEN);
- port->p_id_len = ETHER_ADDR_LEN;
- }
+ int has_alias = (iface->alias != NULL && strlen(iface->alias) != 0);
+ int portid_type = cfg->g_config.c_lldp_portid_type;
+ if (portid_type == LLDP_PORTID_SUBTYPE_IFNAME ||
+ (portid_type == LLDP_PORTID_SUBTYPE_UNKNOWN && has_alias) ||
+ (portid_type == LLDP_PORTID_SUBTYPE_LOCAL && has_alias)) {
+ if (portid_type != LLDP_PORTID_SUBTYPE_LOCAL) {
+ log_debug("interfaces", "use ifname for %s",
+ hardware->h_ifname);
+ port->p_id_subtype = LLDP_PORTID_SUBTYPE_IFNAME;
+ port->p_id_len = strlen(hardware->h_ifname);
+ free(port->p_id);
+ if ((port->p_id = calloc(1, port->p_id_len)) == NULL)
+ fatal("interfaces", NULL);
+ memcpy(port->p_id, hardware->h_ifname, port->p_id_len);
+ }
- 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",
hardware->h_ifname);
free(port->p_descr);
- port->p_descr = strdup(iface->alias);
+ if (has_alias) {
+ port->p_descr = strdup(iface->alias);
+ }
} else {
+ if (portid_type != LLDP_PORTID_SUBTYPE_LOCAL) {
+ log_debug("interfaces", "use MAC address for %s",
+ hardware->h_ifname);
+ port->p_id_subtype = LLDP_PORTID_SUBTYPE_LLADDR;
+ free(port->p_id);
+ if ((port->p_id = calloc(1, ETHER_ADDR_LEN)) == NULL)
+ fatal("interfaces", NULL);
+ memcpy(port->p_id, hardware->h_lladdr, ETHER_ADDR_LEN);
+ port->p_id_len = ETHER_ADDR_LEN;
+ }
+
/* use the ifname in the port description until alias is set */
log_debug("interfaces", "using ifname in description for %s",
hardware->h_ifname);
Capability: Wlan, off
Capability: Station, on
Port:
- PortID: mac 50:54:0e:ec:6e:77
- PortDescr: iface2
+ PortID: ifname iface2
+ PortDescr: SecondInterface
LLDP-MED:
Device Type: Media Endpoint (Class II)
Capability: Capabilities
Capability: Wlan, off
Capability: Station, on
Port:
- PortID: mac 50:54:0e:ec:6e:77
- PortDescr: iface2
+ PortID: ifname iface2
+ PortDescr: SecondInterface
VLAN: 450 iface2.450
VLAN: 451 iface2.451
VLAN: 452 iface2.452
Capability: Wlan, off
Capability: Station, on
Port:
- PortID: mac 50:54:0e:ec:6e:77
- PortDescr: iface2
+ PortID: ifname iface2
+ PortDescr: SecondInterface
VLAN: 450 iface2.450
VLAN: 452 iface2.452
LLDP-MED:
Capability: Wlan, off
Capability: Station, off
Port:
- PortID: mac 50:54:0e:ec:6e:77
- PortDescr: iface2
+ PortID: ifname iface2
+ PortDescr: SecondInterface
MDI Power: supported: yes, enabled: yes, pair control: yes
Device type: PSE
Power pairs: spare
Capability: Wlan, off
Capability: Station, off
Port:
- PortID: mac 50:54:0e:ec:6e:77
- PortDescr: iface2
+ PortID: ifname iface2
+ PortDescr: SecondInterface
MDI Power: supported: yes, enabled: yes, pair control: yes
Device type: PSE
Power pairs: spare