Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scapy
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
066b1d5d
Commit
066b1d5d
authored
7 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
Make FlagValue objects hashable
This will make them usable as set elements or dict or Counter keys.
parent
1944f788
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scapy/fields.py
+2
-0
2 additions, 0 deletions
scapy/fields.py
test/regression.uts
+2
-0
2 additions, 0 deletions
test/regression.uts
with
4 additions
and
0 deletions
scapy/fields.py
+
2
−
0
View file @
066b1d5d
...
@@ -1039,6 +1039,8 @@ class FlagValue(object):
...
@@ -1039,6 +1039,8 @@ class FlagValue(object):
self
.
multi
=
isinstance
(
names
,
list
)
self
.
multi
=
isinstance
(
names
,
list
)
self
.
names
=
names
self
.
names
=
names
self
.
value
=
self
.
_fixvalue
(
value
)
self
.
value
=
self
.
_fixvalue
(
value
)
def
__hash__
(
self
):
return
hash
(
self
.
value
)
def
__int__
(
self
):
def
__int__
(
self
):
return
self
.
value
return
self
.
value
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
...
...
This diff is collapsed.
Click to expand it.
test/regression.uts
+
2
−
0
View file @
066b1d5d
...
@@ -8185,6 +8185,8 @@ assert pkt.flags.DF
...
@@ -8185,6 +8185,8 @@ assert pkt.flags.DF
assert pkt.flags.evil
assert pkt.flags.evil
assert repr(pkt.flags) == '<Flag 6 (DF+evil)>'
assert repr(pkt.flags) == '<Flag 6 (DF+evil)>'
assert len({IP().flags, IP().flags}) == 1
= TCP flags
= TCP flags
~ TCP
~ TCP
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment