Skip to content

Turn the remaining display strings into typed values #96

Description

@EONRaider

Target: 2.1.0 (Tier 3 — make typing the product)

The 1.3.0 option work landed the hard part — TCP.parsed_options
returns tuple[TCPOption, ...] and TCPOption.value decodes MSS,
window scale, SACK and timestamps into real types. Four places still
stop at a display string or raw bytes:

1. DNS RDATA is a rendered string.DNSResourceRecord.rdata_text
handles A, AAAA, NS/CNAME/PTR, MX, TXT and SOA, then falls back to
rdata.hex() — but it returns str for all of them. An A record
should give an ipaddress.IPv4Address, TXT a list[str], SOA a
structured record. Related: only the first question is exposed
(question_name/question_type/question_class); there is no
questions tuple.

2. DHCP has no option type.DHCP.option_map returns
dict[int, bytes] — the only accessor in the library that returns a
bare dict rather than typed objects. There is no DHCPOption class.
Only option 53 is interpreted, via message_type.

3. IPv4 options are named but not decoded.IPv4Option has
kind_name and no value. Record Route (7), Timestamp (68) and
Router Alert (148) are named, and their contents left raw — unlike
TCPOption, which does decode its values.

4. IPv6Routing.data is entirely unparsed. No segment-list
extraction for RH0, RPL or Mobile IPv6. IPv6Option likewise decodes
no values (Router Alert, Jumbo Payload stay raw).

Note on scope

This is four independent pieces of work sharing one theme. Split into
separate PRs — probably one per numbered item — rather than one large
change. DNS (1) is the highest value; IPv6 Routing (4) the lowest.

Whatever is added must not break bytes(decode(x)) == x: the raw bytes
stay authoritative, and typed values are derived lazily from them, as
parsed_options already does.

Acceptance criteria

  • DNS exposes structured RDATA and a full questions tuple.
  • A DHCPOption type replaces the bare dict, or the dict is
    documented as deliberate.
  • IPv4Option.value decodes the three named kinds.
  • Round-trip guarantees unchanged throughout.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions