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
18bdf0c8
Commit
18bdf0c8
authored
8 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
wrpcap: accept packets from an SndRcvList() object
parent
9fce9b96
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
+11
-0
11 additions, 0 deletions
scapy/utils.py
with
11 additions
and
0 deletions
scapy/utils.py
+
11
−
0
View file @
18bdf0c8
...
...
@@ -913,6 +913,11 @@ sync: do not bufferize writes to the capture file
def
_write_packet
(
self
,
packet
,
sec
=
None
,
usec
=
None
,
caplen
=
None
,
wirelen
=
None
):
"""
writes a single packet to the pcap file
"""
if
isinstance
(
packet
,
tuple
):
for
pkt
in
packet
:
self
.
_write_packet
(
pkt
,
sec
=
sec
,
usec
=
usec
,
caplen
=
caplen
,
wirelen
=
wirelen
)
return
if
caplen
is
None
:
caplen
=
len
(
packet
)
if
wirelen
is
None
:
...
...
@@ -945,6 +950,8 @@ sync: do not bufferize writes to the capture file
class
PcapWriter
(
RawPcapWriter
):
"""
A stream PCAP writer with more control than wrpcap()
"""
def
_write_header
(
self
,
pkt
):
if
isinstance
(
pkt
,
tuple
)
and
pkt
:
pkt
=
pkt
[
0
]
if
self
.
linktype
==
None
:
try
:
self
.
linktype
=
conf
.
l2types
[
pkt
.
__class__
]
...
...
@@ -954,6 +961,10 @@ class PcapWriter(RawPcapWriter):
RawPcapWriter
.
_write_header
(
self
,
pkt
)
def
_write_packet
(
self
,
packet
):
if
isinstance
(
packet
,
tuple
):
for
pkt
in
packet
:
self
.
_write_packet
(
pkt
)
return
sec
=
int
(
packet
.
time
)
usec
=
int
(
round
((
packet
.
time
-
sec
)
*
1000000
))
s
=
str
(
packet
)
...
...
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