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
ed982c0e
Commit
ed982c0e
authored
9 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
rdpcap() calls _rdpcap() or _rdpcapng() to handle both format
parent
68ae3366
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/utils.py
+25
-3
25 additions, 3 deletions
scapy/utils.py
with
25 additions
and
3 deletions
scapy/utils.py
+
25
−
3
View file @
ed982c0e
...
...
@@ -527,14 +527,36 @@ endianness: "<" or ">", force endianness"""
@conf.commands.register
def
rdpcap
(
filename
,
count
=-
1
):
"""
Read a pcap or pcapng file and return a packet list
count: read only <count> packets
"""
try
:
return
_rdpcap
(
filename
,
count
=
count
)
except
Scapy_Exception
:
pass
try
:
return
_rdpcapng
(
filename
,
count
=
count
)
except
Scapy_Exception
:
raise
Scapy_Exception
(
"
Not a valid pcap or pcapng file
"
)
def
_rdpcap
(
filename
,
count
=-
1
):
"""
Read a pcap file and return a packet list
count: read only <count> packets
"""
count: read only <count> packets
"""
with
PcapReader
(
filename
)
as
fdesc
:
return
fdesc
.
read_all
(
count
=
count
)
def
rdpcapng
(
filename
,
count
=-
1
):
def
_
rdpcapng
(
filename
,
count
=-
1
):
"""
Read a pcapng file and return a packet list
count: read only <count> packets
"""
count: read only <count> packets
"""
with
PcapNgReader
(
filename
)
as
fdesc
:
return
fdesc
.
read_all
(
count
=
count
)
...
...
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