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
3bc49afb
Commit
3bc49afb
authored
9 years ago
by
Marcel Patzlaff
Browse files
Options
Downloads
Patches
Plain Diff
CHANGE: removed dedicated CLNS layer and replaced it with a better usable solution
CHANGE: made IS-IS more PEP-8 compliant
parent
5a64a524
No related branches found
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scapy/contrib/isis.py
+258
-214
258 additions, 214 deletions
scapy/contrib/isis.py
scapy/layers/clns.py
+44
-46
44 additions, 46 deletions
scapy/layers/clns.py
with
302 additions
and
260 deletions
scapy/contrib/isis.py
+
258
−
214
View file @
3bc49afb
This diff is collapsed.
Click to expand it.
scapy/layers/clns.py
+
44
−
46
View file @
3bc49afb
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
CLNS Extension
CLNS Extension
~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~
:copyright: 2014 BENOCS GmbH, Berlin (Germany)
:copyright: 2014
, 2015
BENOCS GmbH, Berlin (Germany)
:author: Marcel Patzlaff, mpatzlaff@benocs.com
:author: Marcel Patzlaff, mpatzlaff@benocs.com
:license: GPLv2
:license: GPLv2
...
@@ -18,69 +18,67 @@
...
@@ -18,69 +18,67 @@
:description:
:description:
This module provides a layer and registration function for
This module provides a registration function and a generic PDU
OSI Connectionless-mode Network Services (such as IS-IS).
for OSI Connectionless-mode Network Services (such as IS-IS).
:TODO:
- rework this if a better way is found/implemented to bind
protocols such as IS-IS (or if IS-IS remains the sole CLN
protocol)
"""
"""
import
struct
import
struct
from
scapy.config
import
conf
from
scapy.config
import
conf
from
scapy.fields
import
ByteEnumField
,
PacketField
from
scapy.fields
import
ByteEnumField
,
PacketField
from
scapy.layers.l2
import
LLC
from
scapy.layers.l2
import
LLC
from
scapy.packet
import
Packet
,
bind_
layers
from
scapy.packet
import
Packet
,
bind_
top_down
,
bind_bottom_up
network_layer_protocol_ids
=
{
network_layer_protocol_ids
=
{
0x00
:
"
Null
"
,
0x00
:
"
Null
"
,
0x08
:
"
Q.933
"
,
0x08
:
"
Q.933
"
,
0x80
:
"
IEEE SNAP
"
,
0x80
:
"
IEEE SNAP
"
,
0x81
:
"
ISO 8438 CLNP
"
,
0x81
:
"
ISO 8438 CLNP
"
,
0x82
:
"
ISO 9542 ES-IS
"
,
0x82
:
"
ISO 9542 ES-IS
"
,
0x83
:
"
ISO 10589 IS-IS
"
,
0x83
:
"
ISO 10589 IS-IS
"
,
0x8E
:
"
IPv6
"
,
0x8E
:
"
IPv6
"
,
0xB0
:
"
FRF.9
"
,
0xB0
:
"
FRF.9
"
,
0xB1
:
"
FRF.12
"
,
0xB1
:
"
FRF.12
"
,
0xC0
:
"
TRILL
"
,
0xC0
:
"
TRILL
"
,
0xC1
:
"
IEEE 802.aq
"
,
0xC1
:
"
IEEE 802.aq
"
,
0xCC
:
"
IPv4
"
,
0xCC
:
"
IPv4
"
,
0xCF
:
"
PPP
"
0xCF
:
"
PPP
"
}
}
_cln_protocols
=
{}
_cln_protocols
=
{}
class
_GenericClnsPdu
(
Packet
):
class
_GenericClnsPdu
(
Packet
):
name
=
"
Generic CLNS PDU
"
name
=
"
Generic CLNS PDU
"
fields_desc
=
[
fields_desc
=
[
ByteEnumField
(
"
nlpid
"
,
0x00
,
network_layer_protocol_ids
),
ByteEnumField
(
"
nlpid
"
,
0x00
,
network_layer_protocol_ids
),
PacketField
(
"
rawdata
"
,
None
,
conf
.
raw_layer
)
PacketField
(
"
rawdata
"
,
None
,
conf
.
raw_layer
)
]
]
class
ConnectionlessNetworkService
(
Packet
):
def
_create_cln_pdu
(
s
,
**
kwargs
):
name
=
"
Connectionless-mode Network Service
"
pdu_cls
=
conf
.
raw_layer
def
guess_payload_class
(
self
,
p
):
if
len
(
s
)
>=
1
:
cls
=
conf
.
raw_layer
nlpid
=
struct
.
unpack
(
"
!B
"
,
s
[
0
])[
0
]
pdu_cls
=
_cln_protocols
.
get
(
nlpid
,
_GenericClnsPdu
)
if
len
(
p
)
>=
1
:
nlpid
=
struct
.
unpack
(
"
!B
"
,
p
[
0
])[
0
]
return
pdu_cls
(
s
,
**
kwargs
)
cls
=
_cln_protocols
.
get
(
nlpid
,
_GenericClnsPdu
)
return
cls
@conf.commands.register
@conf.commands.register
def
register_cln_protocol
(
nlpid
,
cln_protocol_class
):
def
register_cln_protocol
(
nlpid
,
cln_protocol_class
):
if
nlpid
is
None
or
cln_protocol_class
is
None
:
if
nlpid
is
None
or
cln_protocol_class
is
None
:
return
return
_cln_protocols
[
nlpid
]
=
cln_protocol_class
chk
=
_cln_protocols
.
get
(
nlpid
,
None
)
if
chk
is
not
None
and
chk
!=
cln_protocol_class
:
raise
ValueError
(
"
different protocol already registered!
"
)
_cln_protocols
[
nlpid
]
=
cln_protocol_class
bind_top_down
(
LLC
,
cln_protocol_class
,
dsap
=
0xfe
,
ssap
=
0xfe
,
ctrl
=
3
)
bind_layers
(
LLC
,
ConnectionlessNetworkService
,
dsap
=
0xfe
,
ssap
=
0xfe
,
ctrl
=
3
)
bind_top_down
(
LLC
,
_GenericClnsPdu
,
dsap
=
0xfe
,
ssap
=
0xfe
,
ctrl
=
3
)
\ No newline at end of file
bind_bottom_up
(
LLC
,
_create_cln_pdu
,
dsap
=
0xfe
,
ssap
=
0xfe
,
ctrl
=
3
)
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