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

GTPHeader.post_build() fixed

--HG--
branch : GTP support
parent 4f552fe2
No related branches found
No related tags found
No related merge requests found
...@@ -59,9 +59,9 @@ CauseValues = { 0 : "Request IMSI", ...@@ -59,9 +59,9 @@ CauseValues = { 0 : "Request IMSI",
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 prefernce", 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-exitent", 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",
...@@ -76,17 +76,17 @@ CauseValues = { 0 : "Request IMSI", ...@@ -76,17 +76,17 @@ CauseValues = { 0 : "Request IMSI",
204 : "System failure", 204 : "System failure",
205 : "Roaming restriction", 205 : "Roaming restriction",
206 : "P-TMSI Signature mismatch", 206 : "P-TMSI Signature mismatch",
207 : "GRPS 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 : "Realocation 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 : "Semantc 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",
...@@ -110,44 +110,22 @@ TeardownInd_value = { 254 : "False", ...@@ -110,44 +110,22 @@ TeardownInd_value = { 254 : "False",
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("type", None, GTPmessageType), ByteEnumField("gtp_type", None, GTPmessageType),
BitField("length", None, 16), ShortField("length", None),
XBitField("TEID", 0, 32),] IntField("TEID", 0) ]
def post_build(self, p, pay): def post_build(self, p, pay):
p +=pay p += pay
warning("Packet length: " + str(len(p)-8))
if self.length is None: if self.length is None:
l = len(p)-8 l = len(p)-8
p = p[:1] + struct.pack("!i",l)+ p[4:] p = p[:2] + struct.pack("!H", l)+ p[4:]
if self.type is None: return p
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
class GTPEchoRequest(Packet): class GTPEchoRequest(Packet):
# 3GPP TS 29.060 V9.1.0 (2009-12) # 3GPP TS 29.060 V9.1.0 (2009-12)
...@@ -339,13 +317,6 @@ class GTPCreatePDPContextRequest(Packet): ...@@ -339,13 +317,6 @@ class GTPCreatePDPContextRequest(Packet):
ByteField("next_ex", 0), ByteField("next_ex", 0),
PacketListField("IE_list", [], IE_Dispatcher) ] 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): class GTPErrorIndication(Packet):
# 3GPP TS 29.060 V9.1.0 (2009-12) # 3GPP TS 29.060 V9.1.0 (2009-12)
name = "GTP Error Indication" name = "GTP Error Indication"
...@@ -417,11 +388,11 @@ class GTPmorethan1500(Packet): ...@@ -417,11 +388,11 @@ class GTPmorethan1500(Packet):
# Bind GTP-C # Bind GTP-C
bind_layers(UDP, GTPHeader) bind_layers(UDP, GTPHeader)
bind_layers(GTPHeader, GTPEchoRequest, type = 1) bind_layers(GTPHeader, GTPEchoRequest, gtp_type = 1)
bind_layers(GTPHeader, GTPEchoResponse, type = 2) bind_layers(GTPHeader, GTPEchoResponse, gtp_type = 2)
bind_layers(GTPHeader, GTPCreatePDPContextRequest, type = 16) bind_layers(GTPHeader, GTPCreatePDPContextRequest, gtp_type = 16)
bind_layers(GTPHeader, GTPDeletePDPContextRequest, type = 20) bind_layers(GTPHeader, GTPDeletePDPContextRequest, gtp_type = 20)
bind_layers(GTPHeader, GTPDeletePDPContextResponse, type = 21) bind_layers(GTPHeader, GTPDeletePDPContextResponse, gtp_type = 21)
# Bind GTP-U # Bind GTP-U
bind_layers(UDP, GTP_U_Header) bind_layers(UDP, GTP_U_Header)
bind_layers(GTP_U_Header, IP) bind_layers(GTP_U_Header, IP)
......
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