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
c2ff2ce9
Commit
c2ff2ce9
authored
9 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
Pad packet when needed (fixes #90)
parent
9434f75b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scapy/arch/linux.py
+16
-3
16 additions, 3 deletions
scapy/arch/linux.py
scapy/config.py
+1
-0
1 addition, 0 deletions
scapy/config.py
with
17 additions
and
3 deletions
scapy/arch/linux.py
+
16
−
3
View file @
c2ff2ce9
...
...
@@ -13,6 +13,7 @@ from select import select
from
fcntl
import
ioctl
import
scapy.utils
import
scapy.utils6
from
scapy.packet
import
Packet
,
Padding
from
scapy.config
import
conf
from
scapy.data
import
*
from
scapy.supersocket
import
SuperSocket
...
...
@@ -398,14 +399,15 @@ class L3PacketSocket(SuperSocket):
sx
=
str
(
ll
(
x
))
x
.
sent_time
=
time
.
time
()
self
.
outs
.
sendto
(
sx
,
sdto
)
except
socket
.
error
,
msg
:
except
socket
.
error
,
msg
:
x
.
sent_time
=
time
.
time
()
# bad approximation
if
conf
.
auto_fragment
and
msg
[
0
]
==
90
:
if
msg
[
0
]
==
22
and
len
(
sx
)
<
conf
.
min_pkt_size
:
self
.
outs
.
send
(
sx
+
"
\x00
"
*
(
conf
.
min_pkt_size
-
len
(
sx
)))
elif
conf
.
auto_fragment
and
msg
[
0
]
==
90
:
for
p
in
x
.
fragment
():
self
.
outs
.
sendto
(
str
(
ll
(
p
)),
sdto
)
else
:
raise
...
...
@@ -460,6 +462,17 @@ class L2Socket(SuperSocket):
q
=
conf
.
raw_layer
(
pkt
)
q
.
time
=
get_last_packet_timestamp
(
self
.
ins
)
return
q
def
send
(
self
,
x
):
try
:
return
SuperSocket
.
send
(
self
,
x
)
except
socket
.
error
,
msg
:
if
msg
[
0
]
==
22
and
len
(
x
)
<
conf
.
min_pkt_size
:
padding
=
"
\x00
"
*
(
conf
.
min_pkt_size
-
len
(
x
))
if
isinstance
(
x
,
Packet
):
return
SuperSocket
.
send
(
self
,
x
/
Padding
(
load
=
padding
))
else
:
return
SuperSocket
.
send
(
self
,
str
(
x
)
+
padding
)
raise
class
L2ListenSocket
(
SuperSocket
):
...
...
This diff is collapsed.
Click to expand it.
scapy/config.py
+
1
−
0
View file @
c2ff2ce9
...
...
@@ -345,6 +345,7 @@ extensions_paths: path or list of paths where extensions are to be looked for
L3socket
=
None
L2socket
=
None
L2listen
=
None
min_pkt_size
=
60
histfile
=
os
.
path
.
join
(
os
.
path
.
expanduser
(
"
~
"
),
"
.scapy_history
"
)
padding
=
1
except_filter
=
""
...
...
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