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
a5d8291b
Commit
a5d8291b
authored
10 years ago
by
Guillaume Valadon
Browse files
Options
Downloads
Patches
Plain Diff
GTP_U_Header.post_build() fixed
--HG-- branch : GTP support
parent
a55f084a
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/contrib/gtp.py
+3
-14
3 additions, 14 deletions
scapy/contrib/gtp.py
with
3 additions
and
14 deletions
scapy/contrib/gtp.py
+
3
−
14
View file @
a5d8291b
...
...
@@ -353,7 +353,7 @@ class GTP_U_Header(Packet):
BitField
(
"
E
"
,
0
,
1
),
BitField
(
"
S
"
,
0
,
1
),
BitField
(
"
PN
"
,
0
,
1
),
ByteEnumField
(
"
type
"
,
None
,
GTPmessageType
),
ByteEnumField
(
"
gtp_
type
"
,
None
,
GTPmessageType
),
BitField
(
"
length
"
,
None
,
16
),
XBitField
(
"
TEID
"
,
0
,
32
),
ConditionalField
(
XBitField
(
"
seq
"
,
0
,
16
),
lambda
pkt
:
pkt
.
E
==
1
or
pkt
.
S
==
1
or
pkt
.
PN
==
1
),
...
...
@@ -363,25 +363,14 @@ class GTP_U_Header(Packet):
def
post_build
(
self
,
p
,
pay
):
p
+=
pay
warning
(
"
Packet length:
"
+
str
(
len
(
p
)
-
8
))
if
self
.
length
is
None
:
l
=
len
(
p
)
-
8
p
=
p
[:
1
]
+
struct
.
pack
(
"
!i
"
,
l
)
+
p
[
4
:]
if
self
.
type
is
None
:
if
isinstance
(
self
.
payload
,
IP
):
t
=
255
else
:
warning
(
"
GTP-U Header: Not PDU detected.
"
)
t
=
255
p
=
p
[:
1
]
+
struct
.
pack
(
"
!B
"
,
t
)
+
p
[
3
:]
p
=
p
[:
2
]
+
struct
.
pack
(
"
!H
"
,
l
)
+
p
[
4
:]
return
p
class
GTPmorethan1500
(
Packet
):
# 3GPP TS 29.060 V9.1.0 (2009-12)
name
=
"
GTP More than 1500
"
# GTP-U protocol is used to transmit T-PDUs between GSN pairs (or between an SGSN and an RNC in UMTS),
# encapsulated in G-PDUs. A G-PDU is a packet including a GTP-U header and a T-PDU. The Path Protocol
# defines the path and the GTP-U header defines the tunnel. Several tunnels may be multiplexed on a single path.
fields_desc
=
[
ByteEnumField
(
"
IE_Cause
"
,
"
Cause
"
,
IEType
),
BitField
(
"
IE
"
,
1
,
12000
),]
...
...
@@ -395,7 +384,7 @@ bind_layers(GTPHeader, GTPDeletePDPContextRequest, gtp_type = 20)
bind_layers
(
GTPHeader
,
GTPDeletePDPContextResponse
,
gtp_type
=
21
)
# Bind GTP-U
bind_layers
(
UDP
,
GTP_U_Header
)
bind_layers
(
GTP_U_Header
,
IP
)
bind_layers
(
GTP_U_Header
,
IP
,
gtp_type
=
255
)
if
__name__
==
"
__main__
"
:
interact
(
mydict
=
globals
(),
mybanner
=
"
Test GTPv1 add-on v0.1
"
)
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