• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# GTP unit tests
2#
3# Type the following command to launch start the tests:
4# $ test/run_tests -P "load_contrib('gtp')" -t test/contrib/gtp.uts
5
6+ GTPv1
7
8= GTPHeader, basic instantiation
9
10a = GTPHeader()
11assert a.version == 1
12assert a.E == a.S == a.PN == 0
13
14= GTP_U_Header detection
15
16a = GTPHeader(raw(GTP_U_Header()/GTPErrorIndication()))
17assert isinstance(a, GTP_U_Header)
18
19= GTP_U_Header with PDU Session Container
20
21a = GTPHeader(raw(GTP_U_Header()/GTPPDUSessionContainer(QFI=3)))
22assert isinstance(a, GTP_U_Header)
23assert a[GTP_U_Header].E == 1 and a[GTP_U_Header].next_ex == 0x85
24assert a[GTPPDUSessionContainer].ExtHdrLen == 1
25assert a[GTPPDUSessionContainer].PPP == 0 and a[GTPPDUSessionContainer].RQI == 0
26assert a[GTPPDUSessionContainer].QFI == 3
27assert a[GTPPDUSessionContainer].NextExtHdr == 0
28
29= GTP_U_Header with PDU Session Container with QFI/PPI
30
31a = GTPHeader(raw(GTP_U_Header()/GTPPDUSessionContainer(type=0, QFI=3, PPP=1, PPI=6)))
32assert isinstance(a, GTP_U_Header)
33assert a[GTP_U_Header].E == 1 and a[GTP_U_Header].next_ex == 0x85
34assert a[GTPPDUSessionContainer].ExtHdrLen == 2
35assert a[GTPPDUSessionContainer].PPP == 1 and a[GTPPDUSessionContainer].RQI == 0
36assert a[GTPPDUSessionContainer].QFI == 3 and a[GTPPDUSessionContainer].PPI == 6
37assert a[GTPPDUSessionContainer].NextExtHdr == 0
38assert a[GTPPDUSessionContainer].type == 0
39
40= GTP_U_Header sub layers
41
42a = IPv6(raw(IPv6()/UDP()/GTP_U_Header()/IPv6()))
43b = IPv6(raw(IPv6()/UDP()/GTP_U_Header()/IP()))
44c = IP(raw(IP()/UDP()/GTP_U_Header()/IPv6()))
45d = IP(raw(IP()/UDP()/GTP_U_Header()/IP()))
46
47assert isinstance(a[GTP_U_Header].payload, IPv6)
48assert isinstance(b[GTP_U_Header].payload, IP)
49assert isinstance(c[GTP_U_Header].payload, IPv6)
50assert isinstance(d[GTP_U_Header].payload, IP)
51
52a = IP(raw(IP()/UDP()/GTP_U_Header()/PPP()))
53assert isinstance(a[GTP_U_Header].payload, PPP)
54
55= GTPPDUSessionContainer(), dissect
56h = 'fa163ed6de7bfa163ed82b9408004500008400000000fe114b560a0a2e010a0a2efe086808680070000034ff006000000001fa163e850200ff800000000045000054074d00004001fb490a0a31fe0a0a32010000325600930001c444ca5f00000000759e0a0000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637'
57gtp = Ether(hex_bytes(h))
58gtp[GTP_U_Header].ExtHdrLen == 2 and gtp[GTP_U_Header].padding == b'\x00\x00\x00' and gtp[GTP_U_Header][IP].src == '10.10.49.254' and gtp[GTP_U_Header][IP][ICMP].type == 0 and gtp[GTP_U_Header].type == 0 and gtp[GTP_U_Header].QMP == 0 and gtp[GTP_U_Header].PPP == 1 and gtp[GTP_U_Header].RQI == 1 and gtp[GTP_U_Header].QFI == 63 and gtp[GTP_U_Header].PPI == 4
59
60= GTPPDUSessionContainer with padding
61data = b'\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x08\x00E\x00\x00^\x00\x01\x00\x00@\x11|\x8c\x7f\x00\x00\x01\x7f\x00\x00\x01\x08h\x08h\x00J\xed^4\xff\x00:\x00\x00\x00\x00\x00\x00\x00\x85\x04\x08\xbf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00E\x00\x00&\x00\x01\x00\x00@\x11|\xc4\x7f\x00\x00\x01\x7f\x00\x00\x01\x005\x005\x00\x12\x01^ffffffffff000'
62gtp = Ether(data)
63assert IP in gtp
64
65= GTPEchoResponse matches GTPEchoRequest by seq
66req = GTPHeader(seq=12345)/GTPEchoRequest()
67res = GTPHeader(seq=12345)/GTPEchoResponse()
68assert req.hashret() == res.hashret()
69assert res.answers(req)
70
71= GTPCreatePDPContextRequest(), basic instantiation
72gtp = IP(src="127.0.0.1", dst="127.0.0.1")/UDP(dport=2123, sport=2123)/GTPHeader(teid=2807)/GTPCreatePDPContextRequest()
73gtp.dport == 2123 and gtp.teid == 2807 and len(gtp.IE_list) == 5
74
75= GTPCreatePDPContextRequest(), basic dissection
76random.seed(0x2807)
77rg = raw(gtp)
78rg
79assert rg in [
80    b"E\x00\x00K\x00\x01\x00\x00@\x11|\x9f\x7f\x00\x00\x01\x7f\x00\x00\x01\x08K\x08K\x007\x8e\x860\x10\x00'\x00\x00\n\xf7\x10\x12\x05\xf7(\x14\x0b\x85\x00\x04_\xe2,i\x85\x00\x04\xadm\x97\x83\x87\x00\x0f1DfOTLcIukpXKxV",
81    b'E\x00\x00K\x00\x01\x00\x00@\x11|\x9f\x7f\x00\x00\x01\x7f\x00\x00\x01\x08K\x08K\x007ty0\x10\x00\'\x00\x00\n\xf7\x10\xf0\x84"\x1c\x14\x00\x85\x00\x04\x02D\x81\xe8\x85\x00\x04\xbd\xeb\x92z\x87\x00\x0fv2LUNmjgwdrVOeg',
82    b"E\x00\x00K\x00\x01\x00\x00@\x11|\x9f\x7f\x00\x00\x01\x7f\x00\x00\x01\x08K\x08K\x007n\xb20\x10\x00'\x00\x00\n\xf7\x10\x91\x9f\xbc\xaa\x14\x07\x85\x00\x04<\x7f\x87\x14\x85\x00\x04\xbcU\x14\xcb\x87\x00\x0f9Co27Fbj65eKHyQ",
83]
84
85= GTPV1UpdatePDPContextRequest(), dissect
86h = "3333333333332222222222228100a38408004588006800000000fd1134820a2a00010a2a00024aa5084b005408bb32120044ed99aea9386f0000100000530514058500040a2a00018500040a2a000187000c0213921f739680fe74f2ffff94000130970001019800080112f41004d204d29900024000b6000101"
87gtp = Ether(hex_bytes(h))
88assert gtp.gtp_type == 18
89assert gtp.next_ex == 0
90
91= GTPV1UpdatePDPContextResponse(), dissect
92h = "3333333333332222222222228100838408004588005400000000fd1182850a2a00010a2a0002084b084b00406b46321300305843da17f07300000180100000032c7f4a0f58108500040a2a00018500040a2a000187000f0213921f7396d1fe7482ffff004a00f7a71e0a"
93gtp = Ether(hex_bytes(h))
94gtp.gtp_type == 19
95
96= IE_Cause(), dissect
97h = "3333333333332222222222228100838408004588005400000000fd1182850a2a00010a2a0002084b084b00406b4632130030f15422be19ed0000018010000046a97f4a0f58108500040a2a00018500040a2a000187000f0213921f7396d1fe7482ffff004a00f7a71e0a"
98gtp = Ether(hex_bytes(h))
99ie = gtp.IE_list[0]
100ie.ietype == 1 and ie.CauseValue == 128
101
102= IE_Cause(), basic instantiation
103ie = IE_Cause(CauseValue='IMSI not known')
104ie.ietype == 1 and ie.CauseValue == 194
105
106= IE_IMSI(), dissect
107h = "333333333333222222222222810083840800458800ba00000000fc1185060a2a00010a2a00024ace084b00a68204321000960eeec43e99ae00000202081132547600000332f42004d27b0ffc102c0787b611b2f9023914051a0400800002f1218300070661616161616184001480802110010100108106000000008306000000008500040a2a00018500040a2a00018600079111111111111187000d0213621f7396737374f2ffff0094000120970001029800080032f42004d204d299000240009a00081111111111110000d111193b"
108gtp = Ether(hex_bytes(h))
109ie = gtp.IE_list[0]
110ie.ietype == 2 and ie.imsi == b'2080112345670000'
111
112= IE_IMSI(), basic instantiation
113ie = IE_IMSI(imsi='208103397660354')
114ie.ietype == 2 and ie.imsi == b'208103397660354'
115
116= IE_Routing(), dissect
117h = "33333333333322222222222281008384080045880072647100003e11dcf60a2a00010a2a0002084b084b005e78d93212004ef51a4ac3a291ff000332f42004d27b10eb3981b414058500040a2a00018500040a2a000187000f0213921f7396d1fe7482ffff004a0094000110970001019800080132f42004d204d299000240fcb60001015bf2090f"
118gtp = Ether(hex_bytes(h))
119ie = gtp.IE_list[0]
120ie.ietype == 3 and ie.MCC == b'234' and ie.MNC == b'02' and ie.LAC == 1234 and ie.RAC == 123
121
122= IE_Routing(), basic instantiation
123ie = IE_Routing(MCC='234', MNC='02', LAC=1234, RAC=123)
124ie.ietype == 3 and ie.MCC == b'234' and ie.MNC == b'02' and ie.LAC == 1234 and ie.RAC == 123
125
126= IE_Recovery(), dissect
127h = "3333333333332222222222228100038408004500002ac6e60000fd11ccbc0a2a00010a2a0002084b084b001659db32020006c192a26c8cb400000e0e00000000f4b40b31"
128gtp = Ether(hex_bytes(h))
129ie = gtp.IE_list[0]
130ie.ietype == 14 and ie.restart_counter == 14
131
132= IE_Recovery(), basic instantiation
133ie = IE_Recovery(restart_counter=14)
134ie.ietype == 14 and ie.restart_counter == 14
135
136= IE_SelectionMode(), dissect
137h = "333333333333222222222222810083840800458800c500000000fc1184df0a2a00010a2a00024a55084b00b1f62a321000a11c025b77dccc00000202081132547600000332f42004d27b0ffc1055080923117c347b6a14051a0a00800002f1218300070661616161616184001d8080211001000010810600000000830600000000000d00000a000005008500040a2a00018500040a2a00018600079111111111111187000f0213921f7396d3fe74f2ffff00640094000120970001019800080132f42004d204d299000240009a00081111111111110000eea69220"
138gtp = Ether(hex_bytes(h))
139ie = gtp.IE_list[2]
140ie.ietype == 15 and ie.SelectionMode == 252
141
142= IE_SelectionMode(), basic instantiation
143ie = IE_SelectionMode(SelectionMode=252)
144ie.ietype == 15 and ie.SelectionMode == 252
145
146= IE_TEIDI(), dissect
147h = "3333333333332222222222228100838408004588005400000000fd1182850a2a00010a2a0002084b084b00406b46321300303f0ff4fb966f00000180109a0f08ef7f3af826978500040a2a00018500040a2a000187000f0213921f7396d1fe7482ffff004a00f7a71e0a"
148gtp = Ether(hex_bytes(h))
149ie = gtp.IE_list[1]
150ie.ietype == 16 and ie.TEIDI == 0x9a0f08ef
151
152= IE_TEIDI(), basic instantiation
153ie = IE_TEIDI(TEIDI=0x9a0f08ef)
154ie.ietype == 16 and ie.TEIDI == 0x9a0f08ef
155
156= IE_TEICP(), dissect
157h = "333333333333222222222222810083840800458800c500000000fc1184df0a2a00010a2a00024a55084b00b1f62a321000a1b75eb617464800000202081132547600000332f42004d27b0ffc10db5c765711ba5d87ba14051a0a00800002f1218300070661616161616184001d8080211001000010810600000000830600000000000d00000a000005008500040a2a00018500040a2a00018600079111111111111187000f0213921f7396d3fe74f2ffff00640094000120970001019800080132f42004d204d299000240009a00081111111111110000eea69220"
158gtp = Ether(hex_bytes(h))
159ie = gtp.IE_list[4]
160ie.ietype == 17 and ie.TEICI == 0xba5d87ba
161
162= IE_TEICP(), basic instantiation
163ie = IE_TEICP(TEICI=0xba5d87ba)
164ie.ietype == 17 and ie.TEICI == 0xba5d87ba
165
166= IE_Teardown(), dissect
167h = "3333333333332222222222228100838408004588002c00000000fd1184640a2a00010a2a00023d66084b00184c2232140008ba66ce5b6efe000013ff14050000c309006c"
168gtp = Ether(hex_bytes(h))
169ie = gtp.IE_list[0]
170ie.ietype == 19 and ie.indicator == 255
171
172= IE_Teardown(), basic instantiation
173ie = IE_Teardown(indicator='True')
174ie.ietype == 19 and ie.indicator == 255
175
176= IE_NSAPI(), dissect
177h = "3333333333332222222222228100838408004588002c00000000fd1184640a2a00010a2a00023d66084b00184c2232140008dafc273ee7ab000013ff14050000c309006c"
178gtp = Ether(hex_bytes(h))
179ie = gtp.IE_list[1]
180ie.ietype == 20 and ie.NSAPI == 5
181
182= IE_NSAPI(), basic instantiation
183ie = IE_NSAPI(NSAPI=5)
184ie.ietype == 20 and ie.NSAPI == 5
185
186= IE_ChargingCharacteristics(), dissect
187h = "333333333333222222222222810083840800458800bc00000000fc1184c90a2a00010a2a00024acf084b00a87bbb32100098a3e2565004a400000202081132547600000332f42004d27b0ffc10b87f17ad11c53c5e1b14051a0400800002f1218300070661616161616184001480802110010000108106000000008306000000008500040a2a00018500040a2a00018600079111111111111187000f0213921f7396d3fe74f2ffff004a0094000120970001019800080132f42004d204d299000240009a00081111111111110000951c5bbe"
188gtp = Ether(hex_bytes(h))
189ie = gtp.IE_list[6]
190ie.ietype == 26 and ie.normal_charging == 0 and ie.prepaid_charging == 1 and ie.flat_rate_charging == 0
191
192= IE_ChargingCharacteristics(), basic instantiation
193ie = IE_ChargingCharacteristics(
194    normal_charging=0, prepaid_charging=1, flat_rate_charging=0)
195ie.ietype == 26 and ie.normal_charging == 0 and ie.prepaid_charging == 1 and ie.flat_rate_charging == 0
196
197= IE_TraceReference(), basic instantiation
198ie = IE_TraceReference(Trace_reference=0x1212)
199ie.ietype == 27 and ie.Trace_reference == 0x1212
200
201= IE_TraceType(), basic instantiation
202ie = IE_TraceType(Trace_type=0x1212)
203ie.ietype == 28 and ie.Trace_type == 0x1212
204
205= IE_ChargingId(), dissect
206h = "3333333333332222222222228100838408004588005400000000fd1182850a2a00010a2a0002084b084b00406b4632130030e77ffb7e30410000018010ed654ff37fff1bc3f28500040a2a00018500040a2a000187000f0213921f7396d1fe7482ffff004a00f7a71e0a"
207gtp = Ether(hex_bytes(h))
208ie = gtp.IE_list[2]
209ie.ietype == 127 and ie.Charging_id == 0xff1bc3f2
210
211= IE_ChargingId(), basic instantiation
212ie = IE_ChargingId(Charging_id=0xff1bc3f2)
213ie.ietype == 127 and ie.Charging_id == 0xff1bc3f2
214
215= IE_EndUserAddress(), dissect
216h = "3333333333332222222222228100838408004588008500000000fd11840b0a2a00010a2a0002084b4a6c00717c8a32110061c1b9728f356a0000018008fe10af709e9011e3cb6a4b7fb60e1b28800006f1210a2a00038400218080210a0301000a03060ab0aa93802110030100108106ac14020a8306ac1402278500040a2a00018500040a2a000187000c0213621f7396486874f2ffff44ded108"
217gtp = Ether(hex_bytes(h))
218ie = gtp.IE_list[5]
219ie.ietype == 128 and ie.length == 6 and ie.PDPTypeOrganization == 1 and ie.PDPTypeNumber == 0x21 and ie.PDPAddress == '10.42.0.3'
220
221= IE_EndUserAddress(), IPv4/IPv6 dissect
222h = "00e0fc065f3800e1fc452bf30800450000cf00004000ff11a8afbd28ac11bd28ac0b084b084b00bb0000321100ab645b29420f990000018008fe0e12100270582511027258257f030b15a6800016f18d0a2a00032805021582842522000000000000000084004f80c0230e0200000e0957656c636f6d65210a802110030000108106bd28c6508306bd28c651000310280402148000ffff0000000000000080000310280402148000ffff000000000000008100050101850004bd28ac12850004bd28ac1287000f0223921f9196fefe74f8fefe004a00fb00040acf6976"
223gtp = Ether(hex_bytes(h))
224ie = gtp.IE_list[6]
225ie.ietype == 128 and ie.length == 22 and ie.PDPTypeOrganization == 1 and ie.PDPTypeNumber == 0x8d and ie.PDPAddress == '10.42.0.3' and ie.IPv6_PDPAddress == '2805:215:8284:2522::'
226
227= IE_EndUserAddress(), basic instantiation IPv4
228ie = IE_EndUserAddress(
229    length=6, PDPTypeOrganization=1, PDPTypeNumber=0x21, PDPAddress='10.42.0.3')
230ie.ietype == 128 and ie.length == 6 and ie.PDPTypeOrganization == 1 and ie.PDPTypeNumber == 0x21 and ie.PDPAddress == '10.42.0.3'
231
232= IE_EndUserAddress(), basic instantiation IPv6
233ie = IE_EndUserAddress(
234    length=18, PDPTypeOrganization=1, PDPTypeNumber=0x57, IPv6_PDPAddress='2804::')
235ie.ietype == 128 and ie.length == 18 and ie.PDPTypeOrganization == 1 and ie.PDPTypeNumber == 0x57 and ie.IPv6_PDPAddress == '2804::'
236
237= IE_EndUserAddress(), basic instantiation IPv4/IPv6
238ie = IE_EndUserAddress(
239    length=22, PDPTypeOrganization=1, PDPTypeNumber=0x8d, PDPAddress='10.42.0.3', IPv6_PDPAddress ='2804::')
240ie.ietype == 128 and ie.length == 22 and ie.PDPTypeOrganization == 1 and ie.PDPTypeNumber == 0x8d and ie.IPv6_PDPAddress == '2804::' and ie.PDPAddress == '10.42.0.3'
241
242
243= IE_AccessPointName(), dissect
244h = "333333333333222222222222810083840800458800bc00000000fc1184c90a2a00010a2a00024acf084b00a87bbb3210009867fe972185e800000202081132547600000332f42004d27b0ffc1093b20c3f11940eb2bf14051a0400800002f1218300070661616161616184001480802110010000108106000000008306000000008500040a2a00018500040a2a00018600079111111111111187000f0213921f7396d3fe74f2ffff004a0094000120970001019800080132f42004d204d299000240009a000811111111111100001b1212951c5bbe"
245gtp = Ether(hex_bytes(h))
246ie = gtp.IE_list[8]
247ie.ietype == 131 and ie.APN == b'aaaaaa'
248
249= IE_AccessPointName(), basic instantiation
250ie = IE_AccessPointName(APN='aaaaaa')
251ie.ietype == 131 and ie.APN == b'aaaaaa'
252
253= IE_ProtocolConfigurationOptions(), dissect
254h = "333333333333222222222222810083840800458800c300000000fc1184e50a2a00010a2a00024a4d084b00af41993210009fdef90e15440900000202081132547600000332f42004d27b0ffc10c29998b81145c6c9ee14051a0a00800002f1218300070661616161616184001d80c02306010100060000802110010100108106000000008306000000008500040a2a00018500040a2a00018600079111111111111187000d0213621f73967373741affff0094000120970001029800080032f42004d204d299000240009a0008111111111111000081182fb2"
255gtp = Ether(hex_bytes(h))
256ie = gtp.IE_list[9]
257ie.ietype == 132 and ie.Protocol_Configuration == b'\x80\xc0#\x06\x01\x01\x00\x06\x00\x00\x80!\x10\x01\x01\x00\x10\x81\x06\x00\x00\x00\x00\x83\x06\x00\x00\x00\x00'
258
259= IE_ProtocolConfigurationOptions(), basic instantiation
260ie = IE_ProtocolConfigurationOptions(
261    length=29, Protocol_Configuration=b'\x80\xc0#\x06\x01\x01\x00\x06\x00\x00\x80!\x10\x01\x01\x00\x10\x81\x06\x00\x00\x00\x00\x83\x06\x00\x00\x00\x00')
262ie.ietype == 132 and ie.Protocol_Configuration == b'\x80\xc0#\x06\x01\x01\x00\x06\x00\x00\x80!\x10\x01\x01\x00\x10\x81\x06\x00\x00\x00\x00\x83\x06\x00\x00\x00\x00'
263
264= IE_GSNAddress(), simple build/dissect IPv4
265r = raw(IE_GSNAddress(length=4, ipv4_address='10.42.0.1'))
266assert r == b'\x85\x00\x04\x0a\x2a\x00\x01'
267ie = IE_GSNAddress(r)
268ie.ietype == 133 and ie.ipv4_address == '10.42.0.1'
269
270= IE_GSNAddress(), simple build/dissect IPv6
271r = raw(IE_GSNAddress(length=16, ipv6_address='fd01:1::1'))
272assert r == b'\x85\x00\x10\xfd\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'
273ie = IE_GSNAddress(r)
274ie.ietype == 133 and ie.ipv6_address == 'fd01:1::1'
275
276= IE_GSNAddress(), dissect IPv4
277h = "3333333333332222222222228100838408004588005400000000fd1182850a2a00010a2a0002084b084b00406b463213003031146413c18000000180109181ba027fcf701a8c8500040a2a00018500040a2a000187000f0213921f7396d1fe7482ffff004a00f7a71e0a"
278gtp = Ether(hex_bytes(h))
279ie = gtp.IE_list[3]
280ie.ietype == 133 and ie.ipv4_address == '10.42.0.1'
281
282= IE_GSNAddress(), dissect IPv6
283h = "33333333333322222222222286dd60000000002c1140fd010001000000000000000000000001fd01000100000000000000000000000208680868002ce2e9321a001c000000000000000010000004d2850010fd010001000000000000000000000001"
284gtp = Ether(hex_bytes(h))
285ie = gtp.IE_list[1]
286ie.ietype == 133 and ie.ipv6_address == 'fd01:1::1'
287
288= IE_GSNAddress(), basic instantiation IPv4
289ie = IE_GSNAddress(length=4, ipv4_address='10.42.0.1')
290ie.ietype == 133 and ie.ipv4_address == '10.42.0.1'
291
292= IE_GSNAddress(), basic instantiation IPv6
293ie = IE_GSNAddress(length=16, ipv6_address='fd01:1::1')
294ie.ietype == 133 and ie.ipv6_address == 'fd01:1::1'
295
296= IE_MSInternationalNumber(), dissect
297h = "333333333333222222222222810083840800458800c300000000fc1184e50a2a00010a2a00024a4d084b00af41993210009f79504a3e048e00000202081132547600000332f42004d27b0ffc10a692773d1158da9e2214051a0a00800002f1218300070661616161616184001d80c02306010100060000802110010100108106000000008306000000008500040a2a00018500040a2a00018600079111111111111187000d0213621f73967373741affff0094000120970001029800080032f42004d204d299000240009a0008111111111111000081182fb2"
298gtp = Ether(hex_bytes(h))
299ie = gtp.IE_list[12]
300ie.ietype == 134 and ie.flags == 145 and ie.digits == b'111111111111'
301
302= IE_MSInternationalNumber(), basic instantiation
303ie = IE_MSInternationalNumber(flags=145, digits='111111111111')
304ie.ietype == 134 and ie.flags == 145 and ie.digits == b'111111111111'
305
306= IE_QoS(), dissect
307h = "3333333333332222222222228100838408004588005400000000fd1182850a2a00010a2a0002084b084b00406b4632130030afe9d3a3317e0000018010bd82f3997f9febcaf58500040a2a00018500040a2a000187000f0213921f7396d1fe7482ffff004a00f7a71e0a"
308gtp = Ether(hex_bytes(h))
309ie = gtp.IE_list[5]
310ie.ietype == 135 and ie.allocation_retention_prioiry == 2 and ie.delay_class == 2 and ie.traffic_class == 3
311
312= IE_QoS(), basic instantiation
313ie = IE_QoS(allocation_retention_prioiry=2, delay_class=2, traffic_class=3, length=50)
314ie.ietype == 135 and ie.allocation_retention_prioiry == 2 and ie.delay_class == 2 and ie.traffic_class == 3
315
316= IE_CommonFlags(), dissect
317h = "3333333333332222222222228100a38408004588006800000000fd1134820a2a00010a2a00024aa5084b005408bb32120044623f97e3ac610000104d82c69214058500040a2a00018500040a2a000187000c0213921f739680fe74f2ffff94000130970001019800080132f42004d204d29900024000b6000101"
318gtp = Ether(hex_bytes(h))
319ie = gtp.IE_list[5]
320ie.ietype == 148 and ie.nrsn == 1 and ie.no_qos_nego == 1 and ie.prohibit_payload_compression == 0
321
322= IE_CommonFlags(), basic instantiation
323ie = IE_CommonFlags(nrsn=1, no_qos_nego=1)
324ie.ietype == 148 and ie.nrsn == 1 and ie.no_qos_nego == 1 and ie.prohibit_payload_compression == 0
325
326= IE_APNRestriction(), basic instantiation
327ie = IE_APNRestriction(restriction_type_value=12)
328ie.ietype == 149 and ie.restriction_type_value == 12
329
330= IE_RATType(), dissect
331h = "3333333333332222222222228100a38408004588006800000000fd1134820a2a00010a2a00024aa5084b005408bb321200442f686a89d33c000010530ec20a14058500040a2a00018500040a2a000187000c0213921f739680fe74f2ffff94000130970001019800080132f42004d204d29900024000b6000101"
332gtp = Ether(hex_bytes(h))
333ie = gtp.IE_list[6]
334ie.ietype == 151 and ie.RAT_Type == 1
335
336= IE_RATType(), basic instantiation
337ie = IE_RATType(RAT_Type=1)
338ie.ietype == 151 and ie.RAT_Type == 1
339
340= IE_UserLocationInformation(), dissect
341h = "3333333333332222222222228100a38408004588006800000000fd1134820a2a00010a2a00024aa5084b005408bb32120044981eb5dcb29400001016e85d9f14058500040a2a00018500040a2a000187000c0213921f739680fe74f2ffff94000130970001019800080132f42004d204d29900024000b6000101"
342gtp = Ether(hex_bytes(h))
343ie = gtp.IE_list[7]
344ie.MCC == b'234' and ie.MNC == b'02' and ie.LAC == 1234 and ie.SAC == 1234
345
346= IE_UserLocationInformation(), basic instantiation
347ie = IE_UserLocationInformation(MCC='234', MNC='02', LAC=1234, SAC=1234)
348ie.ietype == 152 and ie.MCC == b'234' and ie.MNC == b'02' and ie.LAC == 1234 and ie.SAC == 1234
349
350= IE_MSTimeZone(), dissect
351h = "3333333333332222222222228100a38408004588006800000000fd1134820a2a00010a2a00024aa5084b005408bb32120044f24a4d5825290000102ca9c8c314058500040a2a00018500040a2a000187000c0213921f739680fe74f2ffff94000130970001019800080132f42004d204d29900024000b6000101"
352gtp = Ether(hex_bytes(h))
353ie = gtp.IE_list[8]
354ie.ietype == 153 and ie.timezone == 64 and ie.daylight_saving_time == 0
355
356= IE_MSTimeZone(), basic instantiation
357ie = IE_MSTimeZone(timezone=64)
358ie.ietype == 153 and ie.timezone == 64 and ie.daylight_saving_time == 0
359
360= IE_IMEI(), dissect
361h = "333333333333222222222222810083840800458800c300000000fc1184e50a2a00010a2a00024a4d084b00af41993210009f2f3ae0eb7b9c00000202081132547600000332f42004d27b0ffc10424a10c8117ca21aba14051a0a00800002f1218300070661616161616184001d80c02306010100060000802110010100108106000000008306000000008500040a2a00018500040a2a00018600079111111111111187000d0213621f73967373741affff0094000120970001029800080032f42004d204d299000240009a0008111111111111000081182fb2"
362gtp = Ether(hex_bytes(h))
363ie = gtp.IE_list[18] and ie.ietype == 154 and ie.IMEI == b'0132750094080322'
364
365= IE_IMEI(), basic instantiation
366ie = IE_IMEI(IMEI='0132750094080322')
367ie.ietype == 154 and ie.IMEI == b'0132750094080322'
368
369= IE_MSInfoChangeReportingAction(), basic instantiation
370ie = IE_MSInfoChangeReportingAction(Action=12)
371ie.ietype == 181 and ie.Action == 12
372
373= IE_DirectTunnelFlags(), dissect
374h = "3333333333332222222222228100a38408004588006800000000fd1134820a2a00010a2a00024aa5084b005408bb32120044d2a7dffabfb70000108caa6b0b14058500040a2a00018500040a2a000187000c0213921f739680fe74f2ffff94000130970001019800080132f42004d204d29900024000b6000101"
375gtp = Ether(hex_bytes(h))
376ie = gtp.IE_list[9]
377ie.ietype == 182 and ie.EI == 0 and ie.GCSI == 0 and ie.DTI == 1
378
379= IE_DirectTunnelFlags(), basic instantiation
380ie = IE_DirectTunnelFlags(DTI=1)
381ie.ietype == 182 and ie.EI == 0 and ie.GCSI == 0 and ie.DTI == 1
382
383= IE_BearerControlMode(), basic instantiation
384ie = IE_BearerControlMode(bearer_control_mode=1)
385ie.ietype == 184 and ie.bearer_control_mode == 1
386
387= IE_EvolvedAllocationRetentionPriority(), basic instantiation
388ie = IE_EvolvedAllocationRetentionPriority(PCI=1)
389ie.ietype == 191 and ie.PCI == 1
390
391= IE_CharginGatewayAddress(), basic instantiation
392ie = IE_CharginGatewayAddress()
393assert ie.ietype == 251 and ie.ipv4_address == '127.0.0.1'
394ie = IE_CharginGatewayAddress(length=16)
395assert ie.ietype == 251 and ie.ipv6_address == '::1'
396
397= IE_PrivateExtension(), basic instantiation
398ie = IE_PrivateExtension(extention_value='hello')
399ie.ietype == 255 and ie.extention_value == b'hello'
400