MCPcopy Create free account
hub / github.com/secdev/scapy / encode_maxrespcode

Method encode_maxrespcode

scapy/contrib/igmpv3.py:63–83  ·  view source on GitHub ↗

Encode and replace the mrcode value to its IGMPv3 encoded time value if needed, # noqa: E501 as specified in rfc3376#section-4.1.1. If value < 128, return the value specified. If >= 128, encode as a floating # noqa: E501 point value. Value can be 0 - 31744.

(self)

Source from the content-addressed store, hash-verified

61 XShortField("chksum", None)]
62
63 def encode_maxrespcode(self):
64 """Encode and replace the mrcode value to its IGMPv3 encoded time value if needed, # noqa: E501
65 as specified in rfc3376#section-4.1.1.
66
67 If value < 128, return the value specified. If >= 128, encode as a floating # noqa: E501
68 point value. Value can be 0 - 31744.
69 """
70 value = self.mrcode
71 if value < 128:
72 code = value
73 elif value > 31743:
74 code = 255
75 else:
76 exp = 0
77 value >>= 3
78 while value > 31:
79 exp += 1
80 value >>= 1
81 exp <<= 4
82 code = 0x80 | exp | (value & 0x0F)
83 self.mrcode = code
84
85 def mysummary(self):
86 """Display a summary of the IGMPv3 object."""

Callers 1

igmpizeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected