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
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Member Shapes
code and reports ARP, RARP, DRARP or InARP through
:attr:`~pcapkit.protocols.protocol.Protocol.alias`

Nothing dispatches to :class:`~pcapkit.protocols.link.arp.InARP` ``('InARP',)``:
Nothing dispatches to :class:`~pcapkit.protocols.link.inarp.InARP` ``('InARP',)``:
under EtherType ``0x0806``, operation 8 parses as ARP with alias ``InARP``.
Only :class:`~pcapkit.protocols.application.rarp.RARP` ``('RARP', 'DRARP')`` is bound
to EtherType ``0x8035``
Expand Down Expand Up @@ -241,6 +241,5 @@ holds :class:`~pcapkit.protocols.link.linux_sll1.LinuxSLL1`. **The** ``schema/``
name, and sub-structure classes such as
:class:`~pcapkit.protocols.schema.internet.igmpv3.Query` share its module. Ruled on
:issue:`2529`, where the classes that do not match yet are pending:
:class:`arp.InARP <pcapkit.protocols.link.arp.InARP>`,
:class:`tls.SSLv3 <pcapkit.protocols.application.tls.SSLv3>` and
:class:`null.NoPayload <pcapkit.protocols.misc.null.NoPayload>`.
2 changes: 1 addition & 1 deletion docs/source/ext.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The protocol classes :mod:`pcapkit` ships:
+==================================================================+================+==============+======================================================================+
| | | :class:`pcapkit.protocols.link.arp.ARP` |
+ + ARP Family +-----------------------+-------------------------------------------------------------+
| | | :class:`pcapkit.protocols.link.arp.InARP` |
| | | :class:`pcapkit.protocols.link.inarp.InARP` |
+ Link Layer +----------------+-----------------------+-------------------------------------------------------------+
| (:class:`~pcapkit.protocols.link.link.Link` subclasses) | :class:`pcapkit.protocols.link.ethernet.Ethernet` |
+ +----------------+-----------------------+-------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/source/pcapkit/protocols/application/tls.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ carries ``0x0303`` and reads ``TLS 1.2``; and a TLS 1.2 ``ClientHello`` sent
at record version ``0x0301`` reads ``TLS 1.0``.

:class:`~pcapkit.protocols.application.tls.SSLv3` is for explicit
construction only, mirroring :class:`~pcapkit.protocols.link.arp.InARP`: it
construction only, mirroring :class:`~pcapkit.protocols.link.inarp.InARP`: it
narrows :meth:`~pcapkit.protocols.application.tls.SSLv3.id` to ``('SSLv3',)``
and inherits :meth:`~pcapkit.protocols.application.tls.TLS.read` unchanged,
so the alias still follows the wire. Dispatch never constructs one.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/pcapkit/protocols/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ from given information. The class hierarchy of :mod:`pcapkit.protocols`:
click C_Tag "link/c_tag.html#pcapkit.protocols.link.c_tag.C_Tag"
click S_Tag "link/s_tag.html#pcapkit.protocols.link.s_tag.S_Tag"
click ARP "link/arp.html#pcapkit.protocols.link.arp.ARP"
click InARP "link/arp.html#pcapkit.protocols.link.arp.InARP"
click InARP "link/inarp.html#pcapkit.protocols.link.inarp.InARP"

click Internet "internet/internet.html#pcapkit.protocols.internet.internet.Internet"
click AH "internet/ah.html#pcapkit.protocols.internet.ah.AH"
Expand Down
23 changes: 11 additions & 12 deletions docs/source/pcapkit/protocols/link/arp.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
ARP/InARP - (Inverse) Address Resolution Protocol
=================================================
ARP - Address Resolution Protocol
=================================

.. module:: pcapkit.protocols.link.arp

:mod:`pcapkit.protocols.link.arp` contains
:class:`~pcapkit.protocols.link.arp.ARP` and
:class:`~pcapkit.protocols.link.arp.InARP`,
which implement extractors for (Inverse) Address Resolution
Protocol (ARP/InARP) [*]_, whose structure is described as
:class:`~pcapkit.protocols.link.arp.ARP` only,
which implements an extractor for Address Resolution
Protocol (ARP) [*]_, whose structure is described as
below:

.. table::
Expand All @@ -34,6 +33,12 @@ below:
24 192 ``arp.tpa`` Target Protocol Address
====== ==== ============= =======================

.. versionremoved:: 1.6.0

``pcapkit.protocols.link.arp.InARP``, with no alias. The class moved to
:mod:`pcapkit.protocols.link.inarp`, since a module holds one protocol
class, named after it (:issue:`2529`).

.. autoclass:: pcapkit.protocols.link.arp.ARP
:no-members:
:show-inheritance:
Expand All @@ -59,12 +64,6 @@ below:
.. automethod:: _make_addr_resolve
.. automethod:: _make_proto_resolve

.. autoclass:: pcapkit.protocols.link.arp.InARP
:no-members:
:show-inheritance:

.. automethod:: id

Header Schemas
--------------

Expand Down
30 changes: 30 additions & 0 deletions docs/source/pcapkit/protocols/link/inarp.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
InARP - Inverse Address Resolution Protocol
===========================================

.. module:: pcapkit.protocols.link.inarp

:mod:`pcapkit.protocols.link.inarp` contains
:class:`~pcapkit.protocols.link.inarp.InARP` only,
which implements an extractor for Inverse Address
Resolution Protocol (InARP) [*]_, whose frame is the one
:mod:`pcapkit.protocols.link.arp` describes.

Nothing dispatches to :class:`~pcapkit.protocols.link.inarp.InARP`:
under EtherType ``0x0806``, an InARP operation parses as
:class:`~pcapkit.protocols.link.arp.ARP` with alias ``InARP``.

.. versionadded:: 1.6.0

Moved here from :mod:`pcapkit.protocols.link.arp`, which keeps
:class:`~pcapkit.protocols.link.arp.ARP` alone, since a module holds one
protocol class, named after it (:issue:`2529`).

.. autoclass:: pcapkit.protocols.link.inarp.InARP
:no-members:
:show-inheritance:

.. automethod:: id

.. rubric:: Footnotes

.. [*] https://datatracker.ietf.org/doc/html/rfc2390
1 change: 1 addition & 0 deletions docs/source/pcapkit/protocols/link/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ link layer, with detailed implementation and methods.
link
ethernet
arp
inarp
frad
gre
l2tp
Expand Down
3 changes: 2 additions & 1 deletion docs/source/pcapkit/protocols/link/link.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Link Layer Base Protocol
.. module:: pcapkit.protocols.link.link

:mod:`pcapkit.protocols.link.link` contains :class:`~pcapkit.protocols.link.link.Link`,
which is a base class for link layer protocols, e.g. :class:`~pcapkit.protocols.link.arp.ARP`/InARP,
which is a base class for link layer protocols, e.g.
:class:`~pcapkit.protocols.link.arp.ARP`/:class:`~pcapkit.protocols.link.inarp.InARP`,
:class:`~pcapkit.protocols.link.ethernet.Ethernet`, :class:`~pcapkit.protocols.link.l2tp.L2TP`
and :class:`~pcapkit.protocols.link.vlan.VLAN`.

Expand Down
2 changes: 1 addition & 1 deletion pcapkit/protocols/application/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ class SSLv3(TLS, schema=Schema_TLS, data=Data_TLS):
"""This class implements Secure Sockets Layer version 3.

Dispatch never constructs it: an SSLv3 record parses as :class:`TLS` with
:attr:`~TLS.alias` ``'SSLv3'``. Like :class:`~pcapkit.protocols.link.arp.InARP`
:attr:`~TLS.alias` ``'SSLv3'``. Like :class:`~pcapkit.protocols.link.inarp.InARP`
to :class:`~pcapkit.protocols.link.arp.ARP`, it narrows :meth:`id` only.

"""
Expand Down
3 changes: 2 additions & 1 deletion pcapkit/protocols/link/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
from pcapkit.protocols.link.link import Link

# Link Layer Protocols
from pcapkit.protocols.link.arp import ARP, InARP
from pcapkit.protocols.link.arp import ARP
from pcapkit.protocols.link.inarp import InARP
from pcapkit.protocols.link.ethernet import Ethernet
from pcapkit.protocols.link.frad import FRAD
from pcapkit.protocols.link.gre import GRE
Expand Down
41 changes: 13 additions & 28 deletions pcapkit/protocols/link/arp.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# -*- coding: utf-8 -*-
"""ARP/InARP - (Inverse) Address Resolution Protocol
=======================================================
"""ARP - Address Resolution Protocol
=======================================

.. module:: pcapkit.protocols.link.arp

:mod:`pcapkit.protocols.link.arp` contains
:class:`~pcapkit.protocols.link.arp.ARP` and
:class:`~pcapkit.protocols.link.arp.InARP`,
which implement extractors for (Inverse) Address Resolution
Protocol (ARP/InARP) [*]_, whose structure is described as
:class:`~pcapkit.protocols.link.arp.ARP` only,
which implements an extractor for Address Resolution
Protocol (ARP) [*]_, whose structure is described as
below:

.. table::
Expand Down Expand Up @@ -37,6 +36,12 @@

.. [*] http://en.wikipedia.org/wiki/Address_Resolution_Protocol

.. versionremoved:: 1.6.0

``pcapkit.protocols.link.arp.InARP``, with no alias. The class moved to
:mod:`pcapkit.protocols.link.inarp`, since a module holds one protocol
class, named after it (:issue:`2529`).

"""
import ipaddress
import re
Expand Down Expand Up @@ -65,7 +70,7 @@
from pcapkit.protocols.protocol import ProtocolBase
from pcapkit.protocols.schema.schema import Schema

__all__ = ['ARP', 'InARP']
__all__ = ['ARP']

# Ethernet address pattern, of any number of octets (``hlen`` is not fixed at 6)
PAT_MAC_ADDR = re.compile(rb'(?i)(?:[0-9a-f]{2}(?:[:-][0-9a-f]{2})*)?')
Expand All @@ -78,7 +83,7 @@ class ARP(Link[Data_ARP, Schema_ARP],
- Address Resolution Protocol (:class:`~pcapkit.protocols.link.arp.ARP`) [:rfc:`826`]
- Reverse Address Resolution Protocol (:class:`~pcapkit.protocols.application.rarp.RARP`) [:rfc:`903`]
- Dynamic Reverse Address Resolution Protocol (:class:`~pcapkit.protocols.application.drarp.DRARP`) [:rfc:`1931`]
- Inverse Address Resolution Protocol (:class:`~pcapkit.protocols.link.arp.InARP`) [:rfc:`2390`]
- Inverse Address Resolution Protocol (:class:`~pcapkit.protocols.link.inarp.InARP`) [:rfc:`2390`]

.. versionchanged:: 1.5.0

Expand Down Expand Up @@ -516,23 +521,3 @@ def _make_proto_resolve(self, addr: 'IPv4Address | IPv6Address | str | bytes', p
if isinstance(addr, (bytes, bytearray)):
return bytes(addr)
raise ProtocolError(f'{self.__class__.__name__}: invalid protocol address: {addr!r}')


class InARP(ARP, schema=Schema_ARP, data=Data_ARP):
"""This class implements Inverse Address Resolution Protocol.

.. versionchanged:: 1.5.0

Parses with the ARP schema rather than falling back to the raw one
(:issue:`1204`).

"""

##########################################################################
# Methods.
##########################################################################

@classmethod
def id(cls) -> 'tuple[Literal["InARP"]]': # type: ignore[override]
"""Index ID of the protocol."""
return ('InARP',)
55 changes: 55 additions & 0 deletions pcapkit/protocols/link/inarp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
"""InARP - Inverse Address Resolution Protocol
=================================================

.. module:: pcapkit.protocols.link.inarp

:mod:`pcapkit.protocols.link.inarp` contains
:class:`~pcapkit.protocols.link.inarp.InARP` only,
which implements an extractor for Inverse Address
Resolution Protocol (InARP) [*]_, whose frame is the one
:mod:`pcapkit.protocols.link.arp` describes.

Nothing dispatches to :class:`~pcapkit.protocols.link.inarp.InARP`:
under EtherType ``0x0806``, an InARP operation parses as
:class:`~pcapkit.protocols.link.arp.ARP` with alias ``InARP``.

.. [*] https://datatracker.ietf.org/doc/html/rfc2390

.. versionadded:: 1.6.0

Moved here from :mod:`pcapkit.protocols.link.arp`, which keeps
:class:`~pcapkit.protocols.link.arp.ARP` alone, since a module holds one
protocol class, named after it (:issue:`2529`).

"""
from typing import TYPE_CHECKING

from pcapkit.protocols.data.link.arp import ARP as Data_ARP
from pcapkit.protocols.link.arp import ARP
from pcapkit.protocols.schema.link.arp import ARP as Schema_ARP

if TYPE_CHECKING:
from typing_extensions import Literal

__all__ = ['InARP']


class InARP(ARP, schema=Schema_ARP, data=Data_ARP):
"""This class implements Inverse Address Resolution Protocol.

.. versionchanged:: 1.5.0

Parses with the ARP schema rather than falling back to the raw one
(:issue:`1204`).

"""

##########################################################################
# Methods.
##########################################################################

@classmethod
def id(cls) -> 'tuple[Literal["InARP"]]': # type: ignore[override]
"""Index ID of the protocol."""
return ('InARP',)
2 changes: 1 addition & 1 deletion pcapkit/protocols/link/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:mod:`pcapkit.protocols.link.link` contains
:class:`~pcapkit.protocols.link.link.Link`,
which is a base class for link layer protocols, e.g.
:class:`~pcapkit.protocols.link.arp.ARP`/:class:`~pcapkit.protocols.link.arp.InARP`,
:class:`~pcapkit.protocols.link.arp.ARP`/:class:`~pcapkit.protocols.link.inarp.InARP`,
:class:`~pcapkit.protocols.link.ethernet.Ethernet`,
:class:`~pcapkit.protocols.link.frad.FRAD`,
:class:`~pcapkit.protocols.link.l2tp.L2TP`,
Expand Down
6 changes: 5 additions & 1 deletion tests/project/test_no_moved_name_re_exports_1744_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
('pcapkit.protocols.application.ngap', 'ProtocolIE'),
('pcapkit.protocols.internet.mh', 'NTPTimestamp'),
('pcapkit.protocols.internet.mh', 'PMIPv6Timestamp'),
('pcapkit.protocols.link.arp', 'InARP'),
# #2529: renamed after their modules.
('pcapkit.protocols.application.httpv1', 'HTTP'),
('pcapkit.protocols.application.httpv2', 'HTTP'),
Expand Down Expand Up @@ -94,10 +95,13 @@
('pcapkit.protocols.application.ftp', 'FTP_DATA',
'pcapkit/protocols/application/ftp.py',
'pcapkit/protocols/application/ftp.rst', '1.5.0'),
# #2529: shipped in 1.5.x, moved to its own module.
# #2529: shipped in 1.5.x, moved to their own modules.
('pcapkit.protocols.application.rarp', 'DRARP',
'pcapkit/protocols/application/rarp.py',
'pcapkit/protocols/application/rarp.rst', '1.6.0'),
('pcapkit.protocols.link.arp', 'InARP',
'pcapkit/protocols/link/arp.py',
'pcapkit/protocols/link/arp.rst', '1.6.0'),
# #2529: shipped in 1.5.x, renamed after their modules.
('pcapkit.protocols.application.httpv1', 'HTTP',
'pcapkit/protocols/application/httpv1.py',
Expand Down
3 changes: 2 additions & 1 deletion tests/protocols/application/test_layer_placement_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def test_ospf_and_rarp_report_the_application_layer(self) -> None:

def test_arp_and_inarp_stay_on_the_link_layer(self) -> None:
""":rfc:`1122#section-2.3.2` keeps ARP on the link layer; RARP is not."""
from pcapkit.protocols.link.arp import ARP, InARP
from pcapkit.protocols.link.arp import ARP
from pcapkit.protocols.link.inarp import InARP

self.assertEqual(ARP.__layer__, 'Link')
self.assertEqual(InARP.__layer__, 'Link')
Expand Down
4 changes: 2 additions & 2 deletions tests/protocols/application/test_ssl_tls_dtls_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ def test_dtls_0xfeff_client_hello_negotiating_1_3_dispatches_dtls_1_3(self) -> N

def test_sslv3_is_constructible_directly_and_narrows_id(self) -> None:
""":class:`SSLv3` -- explicit/manual construction only, mirroring
:class:`~pcapkit.protocols.link.arp.InARP`'s relationship to
:class:`~pcapkit.protocols.link.inarp.InARP`'s relationship to
:class:`~pcapkit.protocols.link.arp.ARP`: it narrows :meth:`id` only
and inherits :meth:`~pcapkit.protocols.application.tls.TLS.read`
unchanged, so parsing SSLv3-shaped data through it sets
Expand All @@ -809,7 +809,7 @@ def test_sslv3_is_constructible_directly_and_narrows_id(self) -> None:
self.assertEqual(SSLv3.id(), ('SSLv3',))

def test_sslv3_class_does_not_force_its_own_alias(self) -> None:
"""The same nuance :class:`~pcapkit.protocols.link.arp.InARP` has:
"""The same nuance :class:`~pcapkit.protocols.link.inarp.InARP` has:
constructing :class:`SSLv3` directly over data that is not actually
SSLv3-shaped still reports the *real* tier, since :meth:`read` is
inherited unmodified and dispatches off the wire, not off the class
Expand Down
6 changes: 3 additions & 3 deletions tests/protocols/link/test_arp_roundtrip_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

GitHub issues:

* #1204: :class:`~pcapkit.protocols.link.arp.InARP` and
* #1204: :class:`~pcapkit.protocols.link.inarp.InARP` and
:class:`~pcapkit.protocols.application.drarp.DRARP` did not pass
``schema=``/``data=``, so they fell back to the ``Raw`` schema and could not
parse any input.
Expand Down Expand Up @@ -34,7 +34,7 @@
#: ``(module, class)`` for every ARP-family class.
CLASSES = (
('pcapkit.protocols.link.arp', 'ARP'),
('pcapkit.protocols.link.arp', 'InARP'),
('pcapkit.protocols.link.inarp', 'InARP'),
('pcapkit.protocols.application.rarp', 'RARP'),
('pcapkit.protocols.application.drarp', 'DRARP'),
)
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_subclasses_use_arp_schema(self) -> None:

def test_subclasses_round_trip(self) -> None:
"""#1204: the issue's repro parses and rebuilds for InARP and DRARP."""
for module, name, oper in (('pcapkit.protocols.link.arp', 'InARP', '0008'),
for module, name, oper in (('pcapkit.protocols.link.inarp', 'InARP', '0008'),
('pcapkit.protocols.application.drarp', 'DRARP', '0005')):
with self.subTest(cls=name):
cls = self._cls(module, name)
Expand Down
Loading
Loading