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
a20fd5bc
Commit
a20fd5bc
authored
15 years ago
by
Phil
Browse files
Options
Downloads
Patches
Plain Diff
Added automata breakpoint management
parent
b2bb8e4e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scapy/automaton.py
+24
-0
24 additions, 0 deletions
scapy/automaton.py
with
24 additions
and
0 deletions
scapy/automaton.py
+
24
−
0
View file @
a20fd5bc
...
...
@@ -205,6 +205,8 @@ class Automaton:
def
__init__
(
self
,
*
args
,
**
kargs
):
self
.
running
=
False
self
.
breakpointed
=
None
self
.
breakpoints
=
set
()
self
.
debug_level
=
0
self
.
init_args
=
args
self
.
init_kargs
=
kargs
...
...
@@ -224,6 +226,11 @@ class Automaton:
class
Stuck
(
ErrorState
):
pass
class
Breakpoint
(
Exception
):
def
__init__
(
self
,
msg
,
breakpoint
):
Exception
.
__init__
(
self
,
msg
)
self
.
breakpoint
=
breakpoint
def
parse_args
(
self
,
debug
=
0
,
store
=
1
,
**
kargs
):
self
.
debug_level
=
debug
self
.
socket_kargs
=
kargs
...
...
@@ -248,6 +255,18 @@ class Automaton:
self
.
debug
(
2
,
"
%s [%s] not taken
"
%
(
cond
.
atmt_type
,
cond
.
atmt_condname
))
def
add_breakpoints
(
self
,
*
bps
):
for
bp
in
bps
:
if
hasattr
(
bp
,
"
atmt_state
"
):
bp
=
bp
.
atmt_state
self
.
breakpoints
.
add
(
bp
)
def
remove_breakpoints
(
self
,
*
bps
):
for
bp
in
bps
:
if
hasattr
(
bp
,
"
atmt_state
"
):
bp
=
bp
.
atmt_state
if
bp
in
self
.
breakpoints
:
self
.
breakpoints
.
remove
(
pb
)
def
start
(
self
,
*
args
,
**
kargs
):
self
.
running
=
True
...
...
@@ -271,6 +290,11 @@ class Automaton:
self
.
debug
(
1
,
"
## state=[%s]
"
%
self
.
state
.
state
)
# Entering a new state. First, call new state function
if
self
.
state
.
state
in
self
.
breakpoints
and
self
.
state
.
state
!=
self
.
breakpointed
:
self
.
breakpointed
=
self
.
state
.
state
raise
self
.
Breakpoint
(
"
breakpoint triggered on state %s
"
%
self
.
state
.
state
,
breakpoint
=
self
.
state
.
state
)
self
.
breakpointed
=
None
state_output
=
self
.
state
.
run
()
if
self
.
state
.
error
:
self
.
running
=
False
...
...
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