Skip to content
Snippets Groups Projects
Commit e0089e06 authored by Guillaume Valadon's avatar Guillaume Valadon
Browse files

Code cleaning

--HG--
branch : GTP support
parent 71926ae2
No related branches found
No related tags found
No related merge requests found
...@@ -15,28 +15,28 @@ from scapy.all import * ...@@ -15,28 +15,28 @@ from scapy.all import *
# GTP Data types # GTP Data types
GTPmessageType = { 1 : "echo_request", GTPmessageType = { 1: "echo_request",
2 : "echo_response", 2: "echo_response",
16 : "create_pdp_context_req", 16: "create_pdp_context_req",
20 : "delete_pdp_context_req", 20: "delete_pdp_context_req",
21 : "delete_pdp_context_res", 21: "delete_pdp_context_res",
26 : "error_indication", 26: "error_indication",
255: "gtp_u_header" } 255: "gtp_u_header" }
IEType = { 1 : "Cause", IEType = { 1: "Cause",
2 : "IMSI", 2: "IMSI",
3 : "RAI", 3: "RAI",
4 : "TLLI", 4: "TLLI",
5 : "P_TMSI", 5: "P_TMSI",
14 : "Recovery", 14: "Recovery",
15 : "SelectionMode", 15: "SelectionMode",
16 : "TEIDI", 16: "TEIDI",
17 : "TEICP", 17: "TEICP",
19 : "TeardownInd", 19: "TeardownInd",
20 : "NSAPI", 20: "NSAPI",
26 : "ChargingChrt", 26: "ChargingChrt",
27 : "TraceReference", 27: "TraceReference",
28 : "TraceType", 28: "TraceType",
128: "EndUserAddress", 128: "EndUserAddress",
131: "AccessPointName", 131: "AccessPointName",
132: "ProtocolConfigurationOptions", 132: "ProtocolConfigurationOptions",
...@@ -49,73 +49,73 @@ IEType = { 1 : "Cause", ...@@ -49,73 +49,73 @@ IEType = { 1 : "Cause",
153: "MSTimeZone", 153: "MSTimeZone",
154: "IMEI" } 154: "IMEI" }
CauseValues = { 0 : "Request IMSI", CauseValues = { 0: "Request IMSI",
1 : "Request IMEI", 1: "Request IMEI",
2 : "Request IMSI and IMEI", 2: "Request IMSI and IMEI",
3 : "No identity needed", 3: "No identity needed",
4 : "MS Refuses", 4: "MS Refuses",
5 : "MS is not GPRS Responding", 5: "MS is not GPRS Responding",
128 : "Request accepted", 128: "Request accepted",
129 : "New PDP type due to network preference", 129: "New PDP type due to network preference",
130 : "New PDP type due to single address bearer only", 130: "New PDP type due to single address bearer only",
192 : "Non-existent", 192: "Non-existent",
193 : "Invalid message format", 193: "Invalid message format",
194 : "IMSI not known", 194: "IMSI not known",
195 : "MS is GPRS Detached", 195: "MS is GPRS Detached",
196 : "MS is not GPRS Responding", 196: "MS is not GPRS Responding",
197 : "MS Refuses", 197: "MS Refuses",
198 : "Version not supported", 198: "Version not supported",
199 : "No resources available", 199: "No resources available",
200 : "Service not supported", 200: "Service not supported",
201 : "Mandatory IE incorrect", 201: "Mandatory IE incorrect",
202 : "Mandatory IE missing", 202: "Mandatory IE missing",
203 : "Optional IE incorrect", 203: "Optional IE incorrect",
204 : "System failure", 204: "System failure",
205 : "Roaming restriction", 205: "Roaming restriction",
206 : "P-TMSI Signature mismatch", 206: "P-TMSI Signature mismatch",
207 : "GPRS connection suspended", 207: "GPRS connection suspended",
208 : "Authentication failure", 208: "Authentication failure",
209 : "User authentication failed", 209: "User authentication failed",
210 : "Context not found", 210: "Context not found",
211 : "All dynamic PDP addresses are occupied", 211: "All dynamic PDP addresses are occupied",
212 : "No memory is available", 212: "No memory is available",
213 : "Reallocation failure", 213: "Reallocation failure",
214 : "Unknown mandatory extension header", 214: "Unknown mandatory extension header",
215 : "Semantic error in the TFT operation", 215: "Semantic error in the TFT operation",
216 : "Syntactic error in TFT operation", 216: "Syntactic error in TFT operation",
217 : "Semantic errors in packet filter(s)", 217: "Semantic errors in packet filter(s)",
218 : "Syntactic errors in packet filter(s)", 218: "Syntactic errors in packet filter(s)",
219 : "Missing or unknown APN", 219: "Missing or unknown APN",
220 : "Unknown PDP address or PDP type", 220: "Unknown PDP address or PDP type",
221 : "PDP context without TFT already activated", 221: "PDP context without TFT already activated",
222 : "APN access denied : no subscription", 222: "APN access denied : no subscription",
223 : "APN Restriction type incompatibility with currently active PDP Contexts", 223: "APN Restriction type incompatibility with currently active PDP Contexts",
224 : "MS MBMS Capabilities Insufficient", 224: "MS MBMS Capabilities Insufficient",
225 : "Invalid Correlation : ID", 225: "Invalid Correlation : ID",
226 : "MBMS Bearer Context Superseded", 226: "MBMS Bearer Context Superseded",
227 : "Bearer Control Mode violation", 227: "Bearer Control Mode violation",
228 : "Collision with network initiated request" } 228: "Collision with network initiated request" }
Selection_Mode = { 11111100: "MSorAPN", Selection_Mode = { 11111100: "MS or APN",
11111101: "MS", 11111101: "MS",
11111110: "NET", 11111110: "NET",
11111111: "FutureUse" } 11111111: "FutureUse" }
TeardownInd_value = { 254 : "False", TeardownInd_value = { 254: "False",
255 : "True" } 255: "True" }
class GTPHeader(Packet): class GTPHeader(Packet):
# 3GPP TS 29.060 V9.1.0 (2009-12) # 3GPP TS 29.060 V9.1.0 (2009-12)
name = "GTP Header" name = "GTP Header"
fields_desc=[ BitField("version", 1, 3), fields_desc=[ BitField("version", 1, 3),
BitField("PT", 1, 1), BitField("PT", 1, 1),
BitField("Reserved", 0, 1), BitField("reserved", 0, 1),
BitField("E", 0, 1), BitField("E", 0, 1),
BitField("S", 1, 1), BitField("S", 1, 1),
BitField("PN", 0, 1), BitField("PN", 0, 1),
ByteEnumField("gtp_type", None, GTPmessageType), ByteEnumField("gtp_type", None, GTPmessageType),
ShortField("length", None), ShortField("length", None),
IntField("TEID", 0) ] IntField("teid", RandInt()) ]
def post_build(self, p, pay): def post_build(self, p, pay):
p += pay p += pay
...@@ -390,7 +390,7 @@ class GTPmorethan1500(Packet): ...@@ -390,7 +390,7 @@ class GTPmorethan1500(Packet):
# Bind GTP-C # Bind GTP-C
bind_layers(UDP, GTPHeader) bind_layers(UDP, GTPHeader, dport = 2123)
bind_layers(GTPHeader, GTPEchoRequest, gtp_type = 1) bind_layers(GTPHeader, GTPEchoRequest, gtp_type = 1)
bind_layers(GTPHeader, GTPEchoResponse, gtp_type = 2) bind_layers(GTPHeader, GTPEchoResponse, gtp_type = 2)
bind_layers(GTPHeader, GTPCreatePDPContextRequest, gtp_type = 16) bind_layers(GTPHeader, GTPCreatePDPContextRequest, gtp_type = 16)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment