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
1bb54991
Commit
1bb54991
authored
8 years ago
by
Guillaume Valadon
Browse files
Options
Downloads
Patches
Plain Diff
Support Raw IPv6 as PCAP linktype
parent
6aaf9ef9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
scapy/data.py
+4
-1
4 additions, 1 deletion
scapy/data.py
scapy/layers/inet.py
+1
-0
1 addition, 0 deletions
scapy/layers/inet.py
scapy/layers/inet6.py
+18
-0
18 additions, 0 deletions
scapy/layers/inet6.py
test/regression.uts
+8
-0
8 additions, 0 deletions
test/regression.uts
with
31 additions
and
1 deletion
scapy/data.py
+
4
−
1
View file @
1bb54991
...
...
@@ -30,8 +30,11 @@ ARPHDR_PPP = 512
ARPHDR_LOOPBACK
=
772
ARPHDR_TUN
=
65534
# From
net/bpf
.h
# From
pcap/dlt
.h
DLT_NULL
=
0
DLT_RAW
=
101
DLT_IPV4
=
228
DLT_IPV6
=
229
# From net/ipv6.h on Linux (+ Additions)
IPV6_ADDR_UNICAST
=
0x01
...
...
This diff is collapsed.
Click to expand it.
scapy/layers/inet.py
+
1
−
0
View file @
1bb54991
...
...
@@ -804,6 +804,7 @@ bind_layers( IP, GRE, frag=0, proto=47)
conf
.
l2types
.
register
(
101
,
IP
)
conf
.
l2types
.
register_num2layer
(
12
,
IP
)
conf
.
l2types
.
register
(
DLT_IPV4
,
IP
)
conf
.
l3types
.
register
(
ETH_P_IP
,
IP
)
conf
.
l3types
.
register_num2layer
(
ETH_P_ALL
,
IP
)
...
...
This diff is collapsed.
Click to expand it.
scapy/layers/inet6.py
+
18
−
0
View file @
1bb54991
...
...
@@ -525,6 +525,21 @@ class IPv6(_IPv6GuessPayload, Packet, IPTools):
return
self
.
payload
.
answers
(
other
.
payload
)
class
_IPv46
(
IP
):
"""
This class implements a dispatcher that is used to detect the IP version
while parsing Raw IP pcap files.
"""
@classmethod
def
dispatch_hook
(
cls
,
_pkt
=
None
,
*
_
,
**
kargs
):
if
_pkt
:
if
struct
.
unpack
(
'
B
'
,
_pkt
[
0
])[
0
]
>>
4
==
6
:
return
IPv6
elif
kargs
.
get
(
"
version
"
)
==
6
:
return
IPv6
return
IP
def
inet6_register_l3
(
l2
,
l3
):
return
getmacbyip6
(
l3
.
dst
)
conf
.
neighbor
.
register_l3
(
Ether
,
IPv6
,
inet6_register_l3
)
...
...
@@ -3074,6 +3089,7 @@ _mip6_mhtype2cls = { 0: MIP6MH_BRR,
7
:
MIP6MH_BE
}
#############################################################################
#############################################################################
### Traceroute6 ###
...
...
@@ -3858,6 +3874,8 @@ def NDP_Attack_Fake_Router(ra, iface=None, mac_src_filter=None,
conf
.
l3types
.
register
(
ETH_P_IPV6
,
IPv6
)
conf
.
l2types
.
register
(
31
,
IPv6
)
conf
.
l2types
.
register
(
DLT_IPV6
,
IPv6
)
conf
.
l2types
.
register
(
DLT_RAW
,
_IPv46
)
bind_layers
(
Ether
,
IPv6
,
type
=
0x86dd
)
bind_layers
(
CookedLinux
,
IPv6
,
proto
=
0x86dd
)
...
...
This diff is collapsed.
Click to expand it.
test/regression.uts
+
8
−
0
View file @
1bb54991
...
...
@@ -4964,6 +4964,14 @@ pcapfile = cStringIO.StringIO(b'\xd4\xc3\xb2\xa1\x02\x00\x04\x00\x00\x00\x00\x00
values = [tuple(int(val) for val in line[:-1].split('\t')) for line in tcpdump(pcapfile, prog=conf.prog.tshark, getfd=True, args=['-T', 'fields', '-e', 'ip.ttl', '-e', 'ip.proto'])]
assert values == [(64, 6), (64, 17), (64, 1)]
= Check Raw IP pcap files
import tempfile
filename = tempfile.mktemp(suffix=".pcap")
wrpcap(filename, [IP()/UDP(), IPv6()/UDP()], linktype=DLT_RAW)
packets = rdpcap(filename)
assert(isinstance(packets[0], IP) and isinstance(packets[1], IPv6))
############
############
...
...
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