From 0a36d97b918c3f4070a29ade25f80c87b8774cd5 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sat, 13 Aug 2011 12:47:39 +0200 Subject: [PATCH] lldp: ensure that boolean values are really boolean Some of p_macphy.autoneg_*, p_power.* should be 0 or 1, even if they are mostly used in conditions. --- src/lldp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lldp.c b/src/lldp.c index 9d7cc4d1..80832f31 100644 --- a/src/lldp.c +++ b/src/lldp.c @@ -598,7 +598,7 @@ lldp_decode(struct lldpd *cfg, char *frame, int s, CHECK_TLV_SIZE(9, "MAC/PHY"); port->p_macphy.autoneg_support = PEEK_UINT8; port->p_macphy.autoneg_enabled = - port->p_macphy.autoneg_support & 0x2; + (port->p_macphy.autoneg_support & 0x2) >> 1; port->p_macphy.autoneg_support = port->p_macphy.autoneg_support & 0x1; port->p_macphy.autoneg_advertised = @@ -618,11 +618,11 @@ lldp_decode(struct lldpd *cfg, char *frame, int s, CHECK_TLV_SIZE(7, "Power"); port->p_power.devicetype = PEEK_UINT8; port->p_power.supported = - port->p_power.devicetype & 0x2; + (port->p_power.devicetype & 0x2) >> 1; port->p_power.enabled = - port->p_power.devicetype & 0x4; + (port->p_power.devicetype & 0x4) >> 2; port->p_power.paircontrol = - port->p_power.devicetype & 0x8; + (port->p_power.devicetype & 0x8) >> 4; port->p_power.devicetype = (port->p_power.devicetype & 0x1)? LLDP_DOT3_POWER_PSE:LLDP_DOT3_POWER_PD; -- 2.39.5