warjiang / dpkt

Automatically exported from code.google.com/p/dpkt
Other
0 stars 0 forks source link

STP Timers need to be shifted by 1 byte in stp.py #109

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The following fields need to be right shifted by 8 bits in stp.py.
age, max_age, hello, fd

Both tcpdump and Wireshark displayed the correct values.  Whereas dpkt was 
wrong.

I tested this with the 802.1D Wireshark sample capture.
http://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=stp.pca
p

I also attached a PVST+ capture I made where the same problem manifests.

Here is the diff.  There is probably a nicer way to handle this.  I just 
modeled this code on how I saw a similar situation handled in tcp.py.

17,20c17,20
<         ('age', 'H', 0),
<         ('max_age', 'H', 0),
<         ('hello', 'H', 0),
<         ('fd', 'H', 0)

---
>         ('age_x2', 'H', 0),
>         ('max_age_x2', 'H', 0),
>         ('hello_x2', 'H', 0),
>         ('fd_x2', 'H', 0)
21a22,39
> 
>     def _get_age(self): return self.age_x2 >> 8
>     def _set_age(self, age): self.age_x2 = age << 8
>     age = property(_get_age, _set_age)
> 
>     def _get_max_age(self): return self.max_age_x2 >> 8
>     def _set_max_age(self, max_age): self.max_age_x2 = max_age << 8
>     max_age = property(_get_max_age, _set_max_age)
> 
>     def _get_hello(self): return self.hello_x2 >> 8
>     def _set_hello(self, hello): self.hello_x2 = hello << 8
>     hello = property(_get_hello, _set_hello)
> 
>     def _get_fd(self): return self.fd_x2 >> 8
>     def _set_fd(self, fd): self.fd_x2 = fd << 8
>     fd = property(_get_fd, _set_fd)
> 
>     

Original issue reported on code.google.com by sm...@depht.com on 4 Jun 2013 at 2:40

Attachments: