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
847ed832
Commit
847ed832
authored
15 years ago
by
Phil
Browse files
Options
Downloads
Patches
Plain Diff
Added opened_socked parameter to sniff()
parent
2c5e40f9
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/sendrecv.py
+13
-8
13 additions, 8 deletions
scapy/sendrecv.py
with
13 additions
and
8 deletions
scapy/sendrecv.py
+
13
−
8
View file @
847ed832
...
...
@@ -522,7 +522,7 @@ iface: listen answers only on the given interface"""
@conf.commands.register
def
sniff
(
count
=
0
,
store
=
1
,
offline
=
None
,
prn
=
None
,
lfilter
=
None
,
L2socket
=
None
,
timeout
=
None
,
*
arg
,
**
karg
):
def
sniff
(
count
=
0
,
store
=
1
,
offline
=
None
,
prn
=
None
,
lfilter
=
None
,
L2socket
=
None
,
timeout
=
None
,
opened_socket
=
None
,
*
arg
,
**
karg
):
"""
Sniff packets
sniff([count=0,] [prn=None,] [store=1,] [offline=None,] [lfilter=None,] + L2ListenSocket args) -> list of packets
...
...
@@ -537,15 +537,19 @@ lfilter: python function applied to each packet to determine
offline: pcap file to read packets from, instead of sniffing them
timeout: stop sniffing after a given time (default: None)
L2socket: use the provided L2socket
opened_socket: provide an object ready to use .recv() on
"""
c
=
0
if
offline
is
None
:
if
L2socket
is
None
:
L2socket
=
conf
.
L2listen
s
=
L2socket
(
type
=
ETH_P_ALL
,
*
arg
,
**
karg
)
if
opened_socket
is
not
None
:
s
=
opened_socket
else
:
s
=
PcapReader
(
offline
)
if
offline
is
None
:
if
L2socket
is
None
:
L2socket
=
conf
.
L2listen
s
=
L2socket
(
type
=
ETH_P_ALL
,
*
arg
,
**
karg
)
else
:
s
=
PcapReader
(
offline
)
lst
=
[]
if
timeout
is
not
None
:
...
...
@@ -575,7 +579,8 @@ L2socket: use the provided L2socket
break
except
KeyboardInterrupt
:
break
s
.
close
()
if
opened_socket
is
None
:
s
.
close
()
return
plist
.
PacketList
(
lst
,
"
Sniffed
"
)
@conf.commands.register
...
...
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