Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INET6] add the PREF64 ND option #4105

Merged
merged 1 commit into from
Aug 29, 2023
Merged

Conversation

evverx
Copy link
Contributor

@evverx evverx commented Aug 28, 2023

https://datatracker.ietf.org/doc/html/rfc8781#name-option-format

      0                   1                   2                   3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     |     Type      |    Length     |     Scaled Lifetime     | PLC |
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     |                                                               |
     +                                                               +
     |              Highest 96 bits of the Prefix                    |
     +                                                               +
     |                                                               |
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Figure 1: NAT64 Prefix Option Format

   Fields:

   Type:  8-bit identifier of the PREF64 option type (38)

   Length:  8-bit unsigned integer.  The length of the option (including
      the Type and Length fields) is in units of 8 octets.  The sender
      MUST set the length to 2.  The receiver MUST ignore the PREF64
      option if the Length field value is not 2.

   Scaled Lifetime:  13-bit unsigned integer.  The maximum time in units
      of 8 seconds over which this NAT64 prefix MAY be used.

   PLC (Prefix Length Code):  3-bit unsigned integer.  This field
      encodes the NAT64 Prefix Length defined in [RFC6052].  The PLC
      field values 0, 1, 2, 3, 4, and 5 indicate the NAT64 prefix length
      of 96, 64, 56, 48, 40, and 32 bits, respectively.  The receiver
      MUST ignore the PREF64 option if the Prefix Length Code field is
      not set to one of those values.

   Highest 96 bits of the Prefix:  96-bit unsigned integer.  Contains
      bits 0 - 95 of the NAT64 prefix.

The patch was also cross-checked with Wireshark:

    ICMPv6 Option (PREF64 Option)
        Type: PREF64 Option (38)
        Length: 2 (16 bytes)
        0000 0111 0000 1... = Scaled Lifetime: 225
        .... .... .... .001 = PLC (Prefix Length Code): 64 bits prefix length (0x1)
        Prefix: 2003:da8:1::

(It's mostly prompted by systemd/systemd#28985)

@codecov
Copy link

codecov bot commented Aug 28, 2023

Codecov Report

Merging #4105 (bb38bdc) into master (0bc40c6) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #4105      +/-   ##
==========================================
- Coverage   81.96%   81.96%   -0.01%     
==========================================
  Files         328      328              
  Lines       75933    75944      +11     
==========================================
+ Hits        62239    62247       +8     
- Misses      13694    13697       +3     
Files Changed Coverage Δ
scapy/layers/inet6.py 88.60% <100.00%> (+0.12%) ⬆️

... and 8 files with indirect coverage changes

@evverx evverx force-pushed the pref64-ra-option branch 2 times, most recently from 9b9ec20 to 5e8becc Compare August 28, 2023 10:50
Copy link
Member

@guedou guedou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR!

scapy/layers/inet6.py Outdated Show resolved Hide resolved
https://datatracker.ietf.org/doc/html/rfc8781#name-option-format

      0                   1                   2                   3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     |     Type      |    Length     |     Scaled Lifetime     | PLC |
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     |                                                               |
     +                                                               +
     |              Highest 96 bits of the Prefix                    |
     +                                                               +
     |                                                               |
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Figure 1: NAT64 Prefix Option Format

   Fields:

   Type:  8-bit identifier of the PREF64 option type (38)

   Length:  8-bit unsigned integer.  The length of the option (including
      the Type and Length fields) is in units of 8 octets.  The sender
      MUST set the length to 2.  The receiver MUST ignore the PREF64
      option if the Length field value is not 2.

   Scaled Lifetime:  13-bit unsigned integer.  The maximum time in units
      of 8 seconds over which this NAT64 prefix MAY be used.

   PLC (Prefix Length Code):  3-bit unsigned integer.  This field
      encodes the NAT64 Prefix Length defined in [RFC6052].  The PLC
      field values 0, 1, 2, 3, 4, and 5 indicate the NAT64 prefix length
      of 96, 64, 56, 48, 40, and 32 bits, respectively.  The receiver
      MUST ignore the PREF64 option if the Prefix Length Code field is
      not set to one of those values.

   Highest 96 bits of the Prefix:  96-bit unsigned integer.  Contains
      bits 0 - 95 of the NAT64 prefix.

The patch was also cross-checked with Wireshark:
    ICMPv6 Option (PREF64 Option)
        Type: PREF64 Option (38)
        Length: 2 (16 bytes)
        0000 0111 0000 1... = Scaled Lifetime: 225
        .... .... .... .001 = PLC (Prefix Length Code): 64 bits prefix length (0x1)
        Prefix: 2003:da8:1::

(It's mostly prompted by systemd/systemd#28985)
@guedou guedou merged commit e454990 into secdev:master Aug 29, 2023
18 checks passed
@gpotter2 gpotter2 added this to the 2.6.0 milestone Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants