This patch adds explicit integer conversions to the IGMP timer fields. This
is necessary because Python 3's pack(...) does not automatically coerce
floating-point values to integers (Python 3 actually throws a struct.error
on struct.pack('B', 1.0)).

This fixes IgmpQuerier._send_query and IgmpSnooper._do_query under Python
3, and possibly other functions that pass/assign floats to the `maxresp'
attribute.

Greetings,
-Fadi

2015-08-27 14:21 GMT+02:00 Fadi Moukayed <[email protected]>:

> Signed-off-by: Fadi Moukayed <[email protected]>
> ---
>  ryu/lib/packet/igmp.py | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/ryu/lib/packet/igmp.py b/ryu/lib/packet/igmp.py
> index f1d65b0..460f258 100644
> --- a/ryu/lib/packet/igmp.py
> +++ b/ryu/lib/packet/igmp.py
> @@ -209,7 +209,7 @@ class igmp(packet_base.PacketBase):
>
>      def serialize(self, payload, prev):
>          hdr = bytearray(struct.pack(self._PACK_STR, self.msgtype,
> -                        self.maxresp, self.csum,
> +                        int(self.maxresp), self.csum,
>                          addrconv.ipv4.text_to_bin(self.address)))
>
>          if self.csum == 0:
> @@ -299,9 +299,9 @@ class igmpv3_query(igmp):
>      def serialize(self, payload, prev):
>          s_qrv = self.s_flg << 3 | self.qrv
>          buf = bytearray(struct.pack(self._PACK_STR, self.msgtype,
> -                        self.maxresp, self.csum,
> +                        int(self.maxresp), self.csum,
>                          addrconv.ipv4.text_to_bin(self.address),
> -                        s_qrv, self.qqic, self.num))
> +                        s_qrv, int(self.qqic), self.num))
>          for src in self.srcs:
>              buf.extend(struct.pack('4s', addrconv.ipv4.text_to_bin(src)))
>          if 0 == self.num:
> --
> 1.9.1
>
>
------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to