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
a55f084a
Commit
a55f084a
authored
10 years ago
by
Guillaume Valadon
Browse files
Options
Downloads
Patches
Plain Diff
GTPHeader.post_build() fixed
--HG-- branch : GTP support
parent
4f552fe2
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
+22
-51
22 additions, 51 deletions
scapy/contrib/gtp.py
with
22 additions
and
51 deletions
scapy/contrib/gtp.py
+
22
−
51
View file @
a55f084a
...
...
@@ -59,9 +59,9 @@ CauseValues = { 0 : "Request IMSI",
4
:
"
MS Refuses
"
,
5
:
"
MS is not GPRS Responding
"
,
128
:
"
Request accepted
"
,
129
:
"
New PDP type due to network prefernce
"
,
129
:
"
New PDP type due to network prefer
e
nce
"
,
130
:
"
New PDP type due to single address bearer only
"
,
192
:
"
Non-exitent
"
,
192
:
"
Non-exi
s
tent
"
,
193
:
"
Invalid message format
"
,
194
:
"
IMSI not known
"
,
195
:
"
MS is GPRS Detached
"
,
...
...
@@ -76,17 +76,17 @@ CauseValues = { 0 : "Request IMSI",
204
:
"
System failure
"
,
205
:
"
Roaming restriction
"
,
206
:
"
P-TMSI Signature mismatch
"
,
207
:
"
G
R
PS connection suspended
"
,
207
:
"
GP
R
S connection suspended
"
,
208
:
"
Authentication failure
"
,
209
:
"
User authentication failed
"
,
210
:
"
Context not found
"
,
211
:
"
All dynamic PDP addresses are occupied
"
,
212
:
"
No memory is available
"
,
213
:
"
Realocation failure
"
,
213
:
"
Real
l
ocation failure
"
,
214
:
"
Unknown mandatory extension header
"
,
215
:
"
Semantic error in the TFT operation
"
,
216
:
"
Syntactic error in TFT operation
"
,
217
:
"
Semantc errors in packet filter(s)
"
,
217
:
"
Semant
i
c errors in packet filter(s)
"
,
218
:
"
Syntactic errors in packet filter(s)
"
,
219
:
"
Missing or unknown APN
"
,
220
:
"
Unknown PDP address or PDP type
"
,
...
...
@@ -110,44 +110,22 @@ TeardownInd_value = { 254 : "False",
class
GTPHeader
(
Packet
):
# 3GPP TS 29.060 V9.1.0 (2009-12)
name
=
"
GTP Header
"
fields_desc
=
[
BitField
(
"
version
"
,
1
,
3
),
BitField
(
"
PT
"
,
1
,
1
),
BitField
(
"
Reserved
"
,
0
,
1
),
BitField
(
"
E
"
,
0
,
1
),
BitField
(
"
S
"
,
1
,
1
),
BitField
(
"
PN
"
,
0
,
1
),
ByteEnumField
(
"
type
"
,
None
,
GTPmessageType
),
Bi
tField
(
"
length
"
,
None
,
16
),
XBi
tField
(
"
TEID
"
,
0
,
32
),
]
fields_desc
=
[
BitField
(
"
version
"
,
1
,
3
),
BitField
(
"
PT
"
,
1
,
1
),
BitField
(
"
Reserved
"
,
0
,
1
),
BitField
(
"
E
"
,
0
,
1
),
BitField
(
"
S
"
,
1
,
1
),
BitField
(
"
PN
"
,
0
,
1
),
ByteEnumField
(
"
gtp_
type
"
,
None
,
GTPmessageType
),
Shor
tField
(
"
length
"
,
None
),
In
tField
(
"
TEID
"
,
0
)
]
def
post_build
(
self
,
p
,
pay
):
p
+=
pay
warning
(
"
Packet length:
"
+
str
(
len
(
p
)
-
8
))
p
+=
pay
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
,
GTPEchoRequest
):
t
=
1
elif
isinstance
(
self
.
payload
,
GTPEchoResponse
):
t
=
2
elif
isinstance
(
self
.
payload
,
GTPCreatePDPContextRequest
):
t
=
16
elif
isinstance
(
self
.
payload
,
GTPDeletePDPContextRequest
):
t
=
20
elif
isinstance
(
self
.
payload
,
GTPDeletePDPContextResponse
):
t
=
21
elif
isinstance
(
self
.
payload
,
GTPErrorIndication
):
t
=
26
else
:
warning
(
"
GTPHeader: cannot GPT type! Set type 1 (Echo Request).
"
)
t
=
1
p
=
p
[:
1
]
+
struct
.
pack
(
"
!B
"
,
t
)
+
p
[
3
:]
#if self.payload.seq is not None:
# warning("TODO: Set S bit '1' because seq number is present.")
#else:
# warning("TODO: Set S bit '0' because seq number is not present.")
return
p
p
=
p
[:
2
]
+
struct
.
pack
(
"
!H
"
,
l
)
+
p
[
4
:]
return
p
class
GTPEchoRequest
(
Packet
):
# 3GPP TS 29.060 V9.1.0 (2009-12)
...
...
@@ -339,13 +317,6 @@ class GTPCreatePDPContextRequest(Packet):
ByteField
(
"
next_ex
"
,
0
),
PacketListField
(
"
IE_list
"
,
[],
IE_Dispatcher
)
]
class
OLD_GTPCreatePDPContextRequest
(
Packet
):
# 3GPP TS 29.060 V9.1.0 (2009-12)
name
=
"
GTP Create PDP Context Request
"
fields_desc
=
[
XBitField
(
"
seq
"
,
0
,
16
),
PacketListField
(
"
IE_list
"
,
[],
IE_Dispatcher
)
]
class
GTPErrorIndication
(
Packet
):
# 3GPP TS 29.060 V9.1.0 (2009-12)
name
=
"
GTP Error Indication
"
...
...
@@ -417,11 +388,11 @@ class GTPmorethan1500(Packet):
# Bind GTP-C
bind_layers
(
UDP
,
GTPHeader
)
bind_layers
(
GTPHeader
,
GTPEchoRequest
,
type
=
1
)
bind_layers
(
GTPHeader
,
GTPEchoResponse
,
type
=
2
)
bind_layers
(
GTPHeader
,
GTPCreatePDPContextRequest
,
type
=
16
)
bind_layers
(
GTPHeader
,
GTPDeletePDPContextRequest
,
type
=
20
)
bind_layers
(
GTPHeader
,
GTPDeletePDPContextResponse
,
type
=
21
)
bind_layers
(
GTPHeader
,
GTPEchoRequest
,
gtp_
type
=
1
)
bind_layers
(
GTPHeader
,
GTPEchoResponse
,
gtp_
type
=
2
)
bind_layers
(
GTPHeader
,
GTPCreatePDPContextRequest
,
gtp_
type
=
16
)
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
)
...
...
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