return (u_char *)hardware->h_lport.p_descr;
#ifdef ENABLE_DOT3
case LLDP_SNMP_LOCAL_DOT3_AUTONEG_SUPPORT:
- long_ret = 2 - hardware->h_lport.p_autoneg_support;
+ long_ret = 2 - hardware->h_lport.p_macphy.autoneg_support;
return (u_char *)&long_ret;
case LLDP_SNMP_LOCAL_DOT3_AUTONEG_ENABLED:
- long_ret = 2 - hardware->h_lport.p_autoneg_enabled;
+ long_ret = 2 - hardware->h_lport.p_macphy.autoneg_enabled;
return (u_char *)&long_ret;
case LLDP_SNMP_LOCAL_DOT3_AUTONEG_ADVERTISED:
*var_len = 2;
- return (u_char *)&hardware->h_lport.p_autoneg_advertised;
+ return (u_char *)&hardware->h_lport.p_macphy.autoneg_advertised;
case LLDP_SNMP_LOCAL_DOT3_AUTONEG_MAU:
- long_ret = hardware->h_lport.p_mau_type;
+ long_ret = hardware->h_lport.p_macphy.mau_type;
return (u_char *)&long_ret;
case LLDP_SNMP_LOCAL_DOT3_AGG_STATUS:
bit = swap_bits((hardware->h_lport.p_aggregid > 0) ? 3 : 0);
return (u_char *)&bit;
#ifdef ENABLE_DOT3
case LLDP_SNMP_REMOTE_DOT3_AUTONEG_SUPPORT:
- long_ret = 2 - port->p_autoneg_support;
+ long_ret = 2 - port->p_macphy.autoneg_support;
return (u_char *)&long_ret;
case LLDP_SNMP_REMOTE_DOT3_AUTONEG_ENABLED:
- long_ret = 2 - port->p_autoneg_enabled;
+ long_ret = 2 - port->p_macphy.autoneg_enabled;
return (u_char *)&long_ret;
case LLDP_SNMP_REMOTE_DOT3_AUTONEG_ADVERTISED:
*var_len = 2;
- return (u_char *)&port->p_autoneg_advertised;
+ return (u_char *)&port->p_macphy.autoneg_advertised;
case LLDP_SNMP_REMOTE_DOT3_AUTONEG_MAU:
- long_ret = port->p_mau_type;
+ long_ret = port->p_macphy.mau_type;
return (u_char *)&long_ret;
case LLDP_SNMP_REMOTE_DOT3_AGG_STATUS:
bit = swap_bits((port->p_aggregid > 0) ? 3 : 0);
static void
display_autoneg(struct writer * w, struct lldpd_port *port, int bithd, int bitfd, char *desc)
{
- if (!((port->p_autoneg_advertised & bithd) ||
- (port->p_autoneg_advertised & bitfd)))
+ if (!((port->p_macphy.autoneg_advertised & bithd) ||
+ (port->p_macphy.autoneg_advertised & bitfd)))
return;
tag_start(w, "advertised", "Adv");
tag_attr(w, "type", "", desc);
- tag_attr(w, "hd", "HD", (port->p_autoneg_advertised & bithd)?"yes":"no");
- tag_attr(w, "fd", "FD", (port->p_autoneg_advertised)?"yes":"no");
+ tag_attr(w, "hd", "HD", (port->p_macphy.autoneg_advertised & bithd)?"yes":"no");
+ tag_attr(w, "fd", "FD", (port->p_macphy.autoneg_advertised)?"yes":"no");
tag_end (w);
}
#endif
tag_datatag(w, "aggregation", " Port is aggregated. PortAggregID",
u2str(port->p_aggregid));
- if (port->p_autoneg_support || port->p_autoneg_enabled ||
- port->p_mau_type) {
+ if (port->p_macphy.autoneg_support || port->p_macphy.autoneg_enabled ||
+ port->p_macphy.mau_type) {
tag_start(w, "auto-negotiation", "PMD autoneg");
- tag_attr (w, "supported", "supported", port->p_autoneg_support?"yes":"no");
- tag_attr (w, "enabled", "enabled", port->p_autoneg_enabled?"yes":"no");
+ tag_attr (w, "supported", "supported",
+ port->p_macphy.autoneg_support?"yes":"no");
+ tag_attr (w, "enabled", "enabled",
+ port->p_macphy.autoneg_enabled?"yes":"no");
- if (port->p_autoneg_enabled) {
+ if (port->p_macphy.autoneg_enabled) {
display_autoneg(w, port, LLDP_DOT3_LINK_AUTONEG_10BASE_T,
LLDP_DOT3_LINK_AUTONEG_10BASET_FD,
"10Base-T");
"1000Base-T");
}
tag_datatag(w, "current", "MAU oper type",
- map_lookup(operational_mau_type_values, port->p_mau_type));
+ map_lookup(operational_mau_type_values, port->p_macphy.mau_type));
tag_end(w);
}
#endif
{0,0}};
if (priv_ethtool(hardware->h_ifname, ðc) == 0) {
- port->p_autoneg_support = (ethc.supported & SUPPORTED_Autoneg) ? 1 : 0;
- port->p_autoneg_enabled = (ethc.autoneg == AUTONEG_DISABLE) ? 0 : 1;
+ port->p_macphy.autoneg_support = (ethc.supported & SUPPORTED_Autoneg) ? 1 : 0;
+ port->p_macphy.autoneg_enabled = (ethc.autoneg == AUTONEG_DISABLE) ? 0 : 1;
for (j=0; advertised_ethtool_to_rfc3636[j][0]; j++) {
if (ethc.advertising & advertised_ethtool_to_rfc3636[j][0])
- port->p_autoneg_advertised |=
+ port->p_macphy.autoneg_advertised |=
advertised_ethtool_to_rfc3636[j][1];
}
switch (ethc.speed) {
case SPEED_10:
- port->p_mau_type = (ethc.duplex == DUPLEX_FULL) ? \
+ port->p_macphy.mau_type = (ethc.duplex == DUPLEX_FULL) ? \
LLDP_DOT3_MAU_10BASETFD : LLDP_DOT3_MAU_10BASETHD;
- if (ethc.port == PORT_BNC) port->p_mau_type = LLDP_DOT3_MAU_10BASE2;
+ if (ethc.port == PORT_BNC) port->p_macphy.mau_type = LLDP_DOT3_MAU_10BASE2;
if (ethc.port == PORT_FIBRE)
- port->p_mau_type = (ethc.duplex == DUPLEX_FULL) ? \
+ port->p_macphy.mau_type = (ethc.duplex == DUPLEX_FULL) ? \
LLDP_DOT3_MAU_10BASEFLDF : LLDP_DOT3_MAU_10BASEFLHD;
break;
case SPEED_100:
- port->p_mau_type = (ethc.duplex == DUPLEX_FULL) ? \
+ port->p_macphy.mau_type = (ethc.duplex == DUPLEX_FULL) ? \
LLDP_DOT3_MAU_100BASETXFD : LLDP_DOT3_MAU_100BASETXHD;
if (ethc.port == PORT_BNC)
- port->p_mau_type = (ethc.duplex == DUPLEX_FULL) ? \
+ port->p_macphy.mau_type = (ethc.duplex == DUPLEX_FULL) ? \
LLDP_DOT3_MAU_100BASET2DF : LLDP_DOT3_MAU_100BASET2HD;
if (ethc.port == PORT_FIBRE)
- port->p_mau_type = (ethc.duplex == DUPLEX_FULL) ? \
+ port->p_macphy.mau_type = (ethc.duplex == DUPLEX_FULL) ? \
LLDP_DOT3_MAU_100BASEFXFD : LLDP_DOT3_MAU_100BASEFXHD;
break;
case SPEED_1000:
- port->p_mau_type = (ethc.duplex == DUPLEX_FULL) ? \
+ port->p_macphy.mau_type = (ethc.duplex == DUPLEX_FULL) ? \
LLDP_DOT3_MAU_1000BASETFD : LLDP_DOT3_MAU_1000BASETHD;
if (ethc.port == PORT_FIBRE)
- port->p_mau_type = (ethc.duplex == DUPLEX_FULL) ? \
+ port->p_macphy.mau_type = (ethc.duplex == DUPLEX_FULL) ? \
LLDP_DOT3_MAU_1000BASEXFD : LLDP_DOT3_MAU_1000BASEXHD;
break;
case SPEED_10000:
- port->p_mau_type = (ethc.port == PORT_FIBRE) ? \
+ port->p_macphy.mau_type = (ethc.port == PORT_FIBRE) ? \
LLDP_DOT3_MAU_10GIGBASEX : LLDP_DOT3_MAU_10GIGBASER;
break;
}
- if (ethc.port == PORT_AUI) port->p_mau_type = LLDP_DOT3_MAU_AUI;
+ if (ethc.port == PORT_AUI) port->p_macphy.mau_type = LLDP_DOT3_MAU_AUI;
}
#endif
}
POKE_START_LLDP_TLV(LLDP_TLV_ORG) &&
POKE_BYTES(dot3, sizeof(dot3)) &&
POKE_UINT8(LLDP_TLV_DOT3_MAC) &&
- POKE_UINT8(port->p_autoneg_support |
- (port->p_autoneg_enabled << 1)) &&
- POKE_UINT16(port->p_autoneg_advertised) &&
- POKE_UINT16(port->p_mau_type) &&
+ POKE_UINT8(port->p_macphy.autoneg_support |
+ (port->p_macphy.autoneg_enabled << 1)) &&
+ POKE_UINT16(port->p_macphy.autoneg_advertised) &&
+ POKE_UINT16(port->p_macphy.mau_type) &&
POKE_END_LLDP_TLV))
goto toobig;
switch (tlv_subtype) {
case LLDP_TLV_DOT3_MAC:
CHECK_TLV_SIZE(9, "MAC/PHY");
- port->p_autoneg_support = PEEK_UINT8;
- port->p_autoneg_enabled =
- port->p_autoneg_support && 0x2;
- port->p_autoneg_support =
- port->p_autoneg_support && 0x1;
- port->p_autoneg_advertised =
+ port->p_macphy.autoneg_support = PEEK_UINT8;
+ port->p_macphy.autoneg_enabled =
+ port->p_macphy.autoneg_support && 0x2;
+ port->p_macphy.autoneg_support =
+ port->p_macphy.autoneg_support && 0x1;
+ port->p_macphy.autoneg_advertised =
PEEK_UINT16;
- port->p_mau_type = PEEK_UINT16;
+ port->p_macphy.mau_type = PEEK_UINT16;
break;
case LLDP_TLV_DOT3_LA:
CHECK_TLV_SIZE(9, "Link aggregation");
};
#endif
+#ifdef ENABLE_DOT3
+#define STRUCT_LLDPD_DOT3_MACPHY "(bbww)"
+struct lldpd_dot3_macphy {
+ u_int8_t autoneg_support;
+ u_int8_t autoneg_enabled;
+ u_int16_t autoneg_advertised;
+ u_int16_t mau_type;
+};
+#endif
+
struct lldpd_chassis {
TAILQ_ENTRY(lldpd_chassis) c_entries;
u_int16_t c_refcount; /* Reference count by ports */
u_int8_t p_hidden_out:2; /* Considered as hidden for emission */
#ifdef ENABLE_DOT3
-#define STRUCT_LLDPD_PORT_DOT3 "lbbww"
+#define STRUCT_LLDPD_PORT_DOT3 "l" STRUCT_LLDPD_DOT3_MACPHY
/* Dot3 stuff */
u_int32_t p_aggregid;
- u_int8_t p_autoneg_support;
- u_int8_t p_autoneg_enabled;
- u_int16_t p_autoneg_advertised;
- u_int16_t p_mau_type;
+ struct lldpd_dot3_macphy p_macphy;
#else
#define STRUCT_LLDPD_PORT_DOT3 ""
#endif
hardware.h_lport.p_descr = "Fake port description";
hardware.h_lport.p_mfs = 1516;
hardware.h_lport.p_aggregid = 5;
- hardware.h_lport.p_autoneg_support = 1;
- hardware.h_lport.p_autoneg_enabled = 1;
- hardware.h_lport.p_autoneg_advertised = LLDP_DOT3_LINK_AUTONEG_10BASE_T |
+ hardware.h_lport.p_macphy.autoneg_support = 1;
+ hardware.h_lport.p_macphy.autoneg_enabled = 1;
+ hardware.h_lport.p_macphy.autoneg_advertised = LLDP_DOT3_LINK_AUTONEG_10BASE_T |
LLDP_DOT3_LINK_AUTONEG_10BASET_FD | LLDP_DOT3_LINK_AUTONEG_100BASE_TX |
LLDP_DOT3_LINK_AUTONEG_100BASE_TXFD;
- hardware.h_lport.p_mau_type = LLDP_DOT3_MAU_100BASETXFD;
+ hardware.h_lport.p_macphy.mau_type = LLDP_DOT3_MAU_100BASETXFD;
chassis.c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR;
chassis.c_id = macaddress;
chassis.c_id_len = ETH_ALEN;
ck_assert_int_eq(nchassis->c_mgmt_if, 3);
#ifdef ENABLE_DOT3
ck_assert_int_eq(nport->p_aggregid, 0);
- ck_assert_int_eq(nport->p_autoneg_enabled, 1);
- ck_assert_int_eq(nport->p_autoneg_support, 1);
- ck_assert_int_eq(nport->p_autoneg_advertised,
+ ck_assert_int_eq(nport->p_macphy.autoneg_enabled, 1);
+ ck_assert_int_eq(nport->p_macphy.autoneg_support, 1);
+ ck_assert_int_eq(nport->p_macphy.autoneg_advertised,
LLDP_DOT3_LINK_AUTONEG_1000BASE_TFD |
LLDP_DOT3_LINK_AUTONEG_1000BASE_T |
LLDP_DOT3_LINK_AUTONEG_100BASE_TXFD |
LLDP_DOT3_LINK_AUTONEG_100BASE_TX |
LLDP_DOT3_LINK_AUTONEG_10BASET_FD |
LLDP_DOT3_LINK_AUTONEG_10BASE_T);
- ck_assert_int_eq(nport->p_mau_type,
+ ck_assert_int_eq(nport->p_macphy.mau_type,
LLDP_DOT3_MAU_100BASETXFD);
ck_assert_int_eq(nport->p_mfs, 1500);
#endif
(u_int32_t)inet_addr("15.255.122.148"));
ck_assert_int_eq(nchassis->c_mgmt_if, 0);
#ifdef ENABLE_DOT3
- ck_assert_int_eq(nport->p_autoneg_enabled, 1);
- ck_assert_int_eq(nport->p_autoneg_support, 1);
- ck_assert_int_eq(nport->p_autoneg_advertised,
+ ck_assert_int_eq(nport->p_macphy.autoneg_enabled, 1);
+ ck_assert_int_eq(nport->p_macphy.autoneg_support, 1);
+ ck_assert_int_eq(nport->p_macphy.autoneg_advertised,
LLDP_DOT3_LINK_AUTONEG_100BASE_TXFD |
LLDP_DOT3_LINK_AUTONEG_100BASE_TX |
LLDP_DOT3_LINK_AUTONEG_10BASET_FD |
LLDP_DOT3_LINK_AUTONEG_10BASE_T);
- ck_assert_int_eq(nport->p_mau_type,
+ ck_assert_int_eq(nport->p_macphy.mau_type,
LLDP_DOT3_MAU_100BASETXFD);
#endif
ck_assert_int_eq(nchassis->c_med_cap_available,