-
-
Notifications
You must be signed in to change notification settings - Fork 36
protocols: reject an int MN-ID identifier for every subtype but IPv6_Address #468
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9b26fa3
protocols: reject an int MN-ID identifier for every subtype but IPv6_…
JarryShaw 1ea8b56
protocols: don't let MN-ID's own rejection message raise a bare Value…
JarryShaw 6195730
Merge remote-tracking branch 'origin/main' into fix-467-mn-id-int-ide…
JarryShaw a8c214a
protocols: convert an int MN-ID identifier instead of rejecting it (#…
JarryShaw 6a9e4e4
protocols: guard the IPv6_Address identifier's upper bound too (#467)
JarryShaw 5cf1740
protocols: list the third raising condition in _make_opt_mn_id (#467)
JarryShaw 6e8598b
Merge remote-tracking branch 'origin/main' into fix-467-mn-id-int-ide…
JarryShaw 4bebfd4
protocols: say why the MN-ID schema stub excludes int, since the make…
JarryShaw 2e78466
Merge branch 'main' into fix-467-mn-id-int-identifier
JarryShaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -724,7 +724,25 @@ class MNIDOption(Option, code=Enum_Option.MN_ID_OPTION_TYPE): | |
| identifier: 'bytes | str | IPv6Address' = SwitchField(selector=mn_id_selector) | ||
|
|
||
| if TYPE_CHECKING: | ||
| def __init__(self, type: 'Enum_Option', length: 'int', subtype: 'Enum_MNIDSubtype', identifier: 'bytes | str | IPv6Address | int') -> 'None': ... | ||
| # NOTE: No ``int`` here, and deliberately so even though | ||
| # :meth:`MH._make_opt_mn_id <pcapkit.protocols.internet.mh.MH._make_opt_mn_id>` | ||
| # *does* accept one. The two annotations describe different boundaries: | ||
| # the maker's is what a **caller** may pass, while this one is what the | ||
| # schema can **hold**, and the maker converts between them before ever | ||
| # constructing this class -- an ``int`` becomes :obj:`bytes` via | ||
| # :meth:`int.to_bytes` for the octet subtypes and an | ||
| # :class:`~ipaddress.IPv6Address` for ``IPv6_Address``. Measured through | ||
| # the maker: ``identifier=0x1234`` arrives here as ``b'\\x124'`` for | ||
| # ``IMSI``/``DUID`` and as ``IPv6Address('::1234')`` for | ||
| # ``IPv6_Address``, never as an ``int``. Widening this stub to admit one | ||
| # would therefore document a value the schema can never hold, and would | ||
| # positively mislead: ``mn_id_selector`` resolves every subtype but | ||
| # ``IPv6_Address`` to a | ||
| # :class:`~pcapkit.corekit.fields.strings.StringField` or | ||
| # :class:`~pcapkit.corekit.fields.strings.BytesField`, and handing either | ||
| # a raw ``int`` is precisely the #467 defect -- ``struct.pack()`` cannot | ||
| # consume it (c.f. #467, #468). | ||
| def __init__(self, type: 'Enum_Option', length: 'int', subtype: 'Enum_MNIDSubtype', identifier: 'bytes | str | IPv6Address') -> 'None': ... | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we still drop the int here? |
||
|
|
||
|
|
||
| @schema_final | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.