]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldp: ensure that boolean values are really boolean
authorVincent Bernat <bernat@luffy.cx>
Sat, 13 Aug 2011 10:47:39 +0000 (12:47 +0200)
committerVincent Bernat <bernat@luffy.cx>
Sat, 13 Aug 2011 10:47:39 +0000 (12:47 +0200)
Some of p_macphy.autoneg_*, p_power.* should be 0 or 1, even if they
are mostly used in conditions.

src/lldp.c

index 9d7cc4d14bb196dc21b74463fc4d214fd876e040..80832f31e59f5bb33edcb98956a35ca7bc3d414e 100644 (file)
@@ -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;