Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/pcapkit/protocols/internet/igmpv2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extractor for Internet Group Management Protocol version 2 (IGMPv2)
:no-members:
:show-inheritance:

.. autoproperty:: name
.. autoproperty:: version
.. autoproperty:: alias

Expand Down
1 change: 1 addition & 0 deletions docs/source/pcapkit/protocols/internet/igmpv3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Octets Bits Name Description
:no-members:
:show-inheritance:

.. autoproperty:: name
.. autoproperty:: version
.. autoproperty:: length

Expand Down
5 changes: 5 additions & 0 deletions pcapkit/protocols/internet/igmpv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class IGMPv2(IGMPBase[Data_IGMP, Schema_IGMP],
# Properties.
##########################################################################

@property
def name(self) -> 'Literal["Internet Group Management Protocol version 2"]': # type: ignore[override]
"""Name of corresponding protocol."""
return 'Internet Group Management Protocol version 2'

@property
def version(self) -> 'Literal[2]':
"""IGMP version this class reads: ``2``."""
Expand Down
5 changes: 5 additions & 0 deletions pcapkit/protocols/internet/igmpv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ class IGMPv3(IGMPBase[Data_IGMPv3, Schema_IGMPv3],
# Properties.
##########################################################################

@property
def name(self) -> 'Literal["Internet Group Management Protocol version 3"]': # type: ignore[override]
"""Name of corresponding protocol."""
return 'Internet Group Management Protocol version 3'

@property
def version(self) -> 'Literal[3]':
"""IGMP version this class reads: ``3``."""
Expand Down
15 changes: 14 additions & 1 deletion tests/protocols/internet/test_igmp_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,19 @@ def test_id_and_version(self) -> None:
self.assertEqual(object.__new__(IGMPv2).version, 2)
self.assertEqual(object.__new__(IGMPv3).version, 3)

def test_name_carries_the_version_its_rfc_names(self) -> None:
""":rfc:`2236` and :rfc:`3376` name IGMPv2 and IGMPv3 with their versions,
so their ``name`` carries it; :rfc:`1112` names IGMPv1 without one (#2558)."""
expected = {
'IGMPv1': 'Internet Group Management Protocol',
'IGMPv2': 'Internet Group Management Protocol version 2',
'IGMPv3': 'Internet Group Management Protocol version 3',
}
for name, (packet, version) in {**IGMP_PACKETS, **IGMPV3_PACKETS}.items():
with self.subTest(packet=name):
parsed = igmp_class(version)(io.BytesIO(packet), len(packet))
self.assertEqual(parsed.name, expected[version])

def test_base_id_covers_all_three_versions(self) -> None:
"""The base lists each version's canonical name, and only those: IGMPv1's
is the family name itself, so no ``id()`` carries ``'IGMPv1'``."""
Expand Down Expand Up @@ -630,7 +643,7 @@ def test_igmp_index_length_and_name(self) -> None:
self.assertEqual(IGMP.__index__(), TransType.IGMP)
self.assertEqual(proto.__length_hint__(), 8)
self.assertEqual(proto.length, 8)
self.assertEqual(proto.name, 'Internet Group Management Protocol')
self.assertEqual(proto.name, 'Internet Group Management Protocol version 2')
self.assertEqual(proto.alias, 'IGMPv2')

def test_igmpv3_length_varies_with_the_message(self) -> None:
Expand Down
Loading