From: Vincent Bernat Date: Sat, 13 Aug 2011 10:47:39 +0000 (+0200) Subject: lldp: ensure that boolean values are really boolean X-Git-Tag: 0.5.5~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0a36d97b918c3f4070a29ade25f80c87b8774cd5;p=thirdparty%2Flldpd.git 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. --- 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;