1# GTPv2 unit tests 2# 3# Type the following command to launch start the tests: 4# $ test/run_tests -P "load_contrib('gtp_v2')" -t scapy/contrib/gtp_v2.uts 5 6+ GTPv2 7 8= GTPHeader v2, basic instanciation 9gtp = IP()/UDP(dport=2123)/GTPHeader(gtp_type=1) 10gtp.dport == 2123 and gtp.gtp_type == 1 11 12= GTPV2EchoRequest, basic instantiation 13gtp = IP()/UDP(dport=2123) / GTPHeader(seq=12345) / GTPV2EchoRequest() 14gtp.dport == 2123 and gtp.seq == 12345 and gtp.gtp_type == 1 and gtp.T == 0 15 16= GTPV2CreateSessionRequest, basic instantiation 17gtp = IP() / UDP(dport=2123) / \ 18 GTPHeader(gtp_type="create_session_req", teid=2807, seq=12345) / \ 19 GTPV2CreateSessionRequest() 20gtp.dport == 2123 and gtp.teid == 2807 and gtp.seq == 12345 21 22= GTPV2EchoRequest, dissection 23h = "333333333333222222222222810080c808004588002937dd0000fd1115490a2a00010a2a0002084b084b00152d0e4001000900000100030001000daa000000003f1f382f" 24gtp = Ether(hex_bytes(h)) 25gtp.gtp_type == 1 26 27= GTPV2EchoResponse, dissection 28h = "3333333333332222222222228100e384080045fc002fd6d70000f21180d40a2a00010a2a0002084b084b001b00004002000f000001000300010001020002001000731cd7c5" 29gtp = Ether(hex_bytes(h)) 30gtp.gtp_type == 2 31 32= GTPV2ModifyBearerRequest, dissection 33h = "3333333333332222222222228100a384080045b8004300000000fc1185350a2a00010a2a00027a76084b002f6c344822002392e9e1143652540052000100065d00120049000100055700090080000010927f000002ac79a28e" 34gtp = Ether(hex_bytes(h)) 35gtp.gtp_type == 34 36 37= IE_IMSI, dissection 38h = "3333333333332222222222228100a384080045b800ed00000000fc1193430a2a00010a2a00027f61084b00d91c47482000cd00000000661759000100080002081132547600004b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a00196161616161616161616161616161616161616161616161616163000100014f000500017f0000034d0004000808000048000800000017000000a4105d002c0049000100235700090385000010927f00000250001600580700000000000000000000000000000000000000007200020040005311004c" 39gtp = Ether(hex_bytes(h)) 40ie = gtp.IE_list[0] 41ie.IMSI == b"2080112345670000" 42 43= IE_IMSI, basic instantiation 44ie = IE_IMSI(ietype='IMSI', length=8, IMSI='2080112345670000') 45ie.ietype == 1 and ie.IMSI == b'2080112345670000' 46 47= IE_Cause, dissection 48h = "3333333333332222222222228100838408004588004a00000000fd1193160a2a00010a2a0002084b824600366a744823002a45e679235ea151000200020010005d001800490001006c0200020010005700090081000010927f000002558d3b69" 49gtp = Ether(hex_bytes(h)) 50ie = gtp.IE_list[0] 51ie.Cause == 16 52 53= IE_Cause, basic instantiation 54ie = IE_Cause( 55 ietype='Cause', length=2, Cause='Request Accepted', PCE=1, BCE=0, CS=0) 56ie.ietype == 2 and ie.Cause == 16 and ie.PCE == 1 and ie.BCE == 0 and ie.CS == 0 57 58= IE_Cause, basic instantiation 2 59ie = IE_Cause( 60 ietype='Cause', length=2, Cause='Request Accepted', PCE=0, BCE=1, CS=0) 61ie.ietype == 2 and ie.Cause == 16 and ie.PCE == 0 and ie.BCE == 1 and ie.CS == 0 62 63= IE_Cause, basic instantiation 3 64ie = IE_Cause( 65 ietype='Cause', length=2, Cause='Request Accepted', PCE=0, BCE=0, CS=1) 66ie.ietype == 2 and ie.Cause == 16 and ie.PCE == 0 and ie.BCE == 0 and ie.CS == 1 67 68= IE_RecoveryRestart, dissection 69h = "3333333333332222222222228100838408004588002937dd0000fd1115490a2a00010a2a0002084b084b00152d0e400100095e4b1f00030001000daa000000003f1f382f" 70gtp = Ether(hex_bytes(h)) 71ie = gtp.IE_list[0] 72ie.ietype == 3 and ie.restart_counter == 13 73 74= IE_RecoveryRestart, basic instantiation 75ie = IE_RecoveryRestart( 76 ietype='Recovery Restart', length=1, restart_counter=17) 77ie.ietype == 3 and ie.restart_counter == 17 78 79= IE_APN, dissection 80h = "3333333333332222222222228100a384080045b800ed00000000fc1193430a2a00010a2a00027f61084b00d91c47482000cd140339f4d99f66000100080002081132547600004b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a00196161616161616161616161616161616161616161616161616163000100014f000500017f0000034d0004000808000048000800000017000000a4105d002c0049000100e55700090385000010927f00000250001600580700000000000000000000000000000000000000007200020014005311004c" 81gtp = Ether(hex_bytes(h)) 82ie = gtp.IE_list[7] 83ie.APN == b'aaaaaaaaaaaaaaaaaaaaaaaaa' 84 85= IE_APN, basic instantiation 86ie = IE_APN(ietype='APN', length=26, APN='aaaaaaaaaaaaaaaaaaaaaaaaa') 87ie.ietype == 71 and ie.APN == b'aaaaaaaaaaaaaaaaaaaaaaaaa' 88 89= IE_AMBR, dissection 90h = "3333333333332222222222228100a384080045b800ed00000000fc1193430a2a00010a2a00027f61084b00d91c47482000cd140339f4d99f66000100080002081132547600004b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a00196161616161616161616161616161616161616161616161616163000100014f000500017f0000034d0004000808000048000800000017000000a4105d002c0049000100e55700090385000010927f00000250001600580700000000000000000000000000000000000000007200020014005311004c" 91gtp = Ether(hex_bytes(h)) 92ie = gtp.IE_list[11] 93ie.AMBR_Uplink == 5888 and ie.AMBR_Downlink == 42000 94 95= IE_AMBR, basic instantiation 96ie = IE_AMBR( 97 ietype='AMBR', length=8, AMBR_Uplink=5888, AMBR_Downlink=42000) 98ie.ietype == 72 and ie.AMBR_Uplink == 5888 and ie.AMBR_Downlink == 42000 99 100= IE_EPSBearerID, dissection 101h = "3333333333332222222222228100838408004580006d00000000f31180d20a2a00010a2a0002084b85930059e49a4823004d55819f6500ede7000200020010004c000600111111111111490001003248000800000061a8000249f07f000100005d001300490001000b0200020010005e00040039004f454a0004007f00000436f73a63" 102gtp = Ether(hex_bytes(h)) 103ie = gtp.IE_list[2] 104ie.EBI == 50 105 106= IE_EPSBearerID, basic instantiation 107ie = IE_EPSBearerID(ietype='EPS Bearer ID', length=1, EBI=50) 108ie.ietype == 73 and ie.EBI == 50 109 110= IE_IPv4, dissection 111h = "3333333333332222222222228100838408004580006d00000000f31180d20a2a00010a2a0002084b85930059e49a4823004d84530d5a4cdee2000200020010004c00060011111111111149000100b248000800000061a8000249f07f000100005d00130049000100da0200020010005e00040039004f454a0004007f00000436f73a63" 112gtp = Ether(hex_bytes(h)) 113ie = gtp.IE_list[6] 114ie.address == '127.0.0.4' 115 116= IE_IPv4, basic instantiation 117ie = IE_IPv4(ietype='IPv4', length=4, address='127.0.0.4') 118ie.ietype == 74 and ie.address == '127.0.0.4' 119 120= IE_MEI, dissection 121h = "3333333333332222222222228100a384080045b800ed00000000fc1193430a2a00010a2a00027f61084b00d91c47482000cd140339f4d99f66000100080002081132547600004b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a00196161616161616161616161616161616161616161616161616163000100014f000500017f0000034d0004000808000048000800000017000000a4105d002c0049000100e55700090385000010927f00000250001600580700000000000000000000000000000000000000007200020014005311004c" 122gtp = Ether(hex_bytes(h)) 123ie = gtp.IE_list[1] 124ie.MEI == 123456 125 126= IE_MEI, basic instantiation 127ie = IE_MEI(ietype='MEI', length=1, MEI=123456) 128ie.ietype == 75 and ie.MEI == 123456 129 130= IE_MSISDN, dissection 131h = "3333333333332222222222228100838408004580006d00000000f31180d20a2a00010a2a0002084b85930059e49a4823004d55819f6500ede7000200020010004c000600111111111111490001003248000800000061a8000249f07f000100005d001300490001000b0200020010005e00040039004f454a0004007f00000436f73a63" 132gtp = Ether(hex_bytes(h)) 133ie = gtp.IE_list[1] 134ie.digits == b'111111111111' 135 136= IE_MSISDN, basic instantiation 137ie = IE_MSISDN(ietype='MSISDN', length=6, digits='111111111111') 138ie.ietype == 76 and ie.digits == b'111111111111' 139 140= IE_Indication, dissection 141h = "3333333333332222222222228100a384080045b800ed00000000fc1193430a2a00010a2a00027f61084b00d91c47482000cd140339f4d99f66000100080002081132547600004b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a00196161616161616161616161616161616161616161616161616163000100014f000500017f0000034d0004000808000048000800000017000000a4105d002c0049000100e55700090385000010927f00000250001600580700000000000000000000000000000000000000007200020014005311004c" 142gtp = Ether(hex_bytes(h)) 143ie = gtp.IE_list[10] 144ie.DAF == 0 and ie.DTF == 0 and ie.PS == 1 and ie.CCRSI == 0 and ie.CPRAI == 0 and ie.PPON == 0 and ie.CLII == 0 and ie.CPSR == 0 145 146= IE_Indication, basic instantiation 147ie = IE_Indication(ietype='Indication', length=8, PS=1, CPRAI=1) 148ie.ietype == 77 and ie.PS == 1 and ie.CPRAI == 1 149 150= IE_Indication, basic instantiation 2 151ie = IE_Indication(ietype='Indication', length=8, DTF=1, PPSI=1) 152ie.ietype == 77 and ie.DTF == 1 and ie.PPSI == 1 153 154= IE_PCO, dissection 155h = "333333333333222222222222810083840800458800a500000000fd1183bb0a2a00010a2a0002084b76a00091cf0b48210085bd574af24c68e300020002001000570009008b000010927f0000025700090187000010927f0000024f000500017f0000037f000100004e00220080000d040a2a0003000d040a2a00038021100300001081060a2a000483060a2a00045d00250049000100660200020010005700090081000010927f0000025700090285000010927f000002dd9f22c6" 156gtp = Ether(hex_bytes(h)) 157ie = gtp.IE_list[5] 158ie.Protocols[0].address == '10.42.0.3' 159 160= IE_PCO, basic instantiation 161ie = IE_PCO(ietype='Protocol Configuration Options', length=8, Extension=1, PPP=3, Protocols=[ 162 PCO_DNS_Server_IPv4(type='DNS Server IPv4 Address Request', length=4, address='10.42.0.3')]) 163ie.Extension == 1 and ie.PPP == 3 and ie.Protocols[0].address == '10.42.0.3' 164 165= IE_PAA, dissection 166h = "3333333333332222222222228100a384080045b800ed00000000fc1193430a2a00010a2a00027f61084b00d91c47482000cd140339f4d99f66000100080002081132547600004b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a00196161616161616161616161616161616161616161616161616163000100014f000500017f0000034d0004000808000048000800000017000000a4105d002c0049000100e55700090385000010927f00000250001600580700000000000000000000000000000000000000007200020014005311004c" 167gtp = Ether(hex_bytes(h)) 168ie = gtp.IE_list[9] 169ie.PDN_type == 1 and ie.ipv4 == '127.0.0.3' 170 171= IE_PAA, basic instantiation 172ie = IE_PAA(ietype='PAA', length=5, PDN_type='IPv4', ipv4='127.0.0.3') 173ie.ietype == 79 and ie.PDN_type == 1 and ie.ipv4 == '127.0.0.3' 174 175= IE_Bearer_QoS, dissection 176h = "3333333333332222222222228100a384080045b800ed00000000fc1193430a2a00010a2a00027f61084b00d91c47482000cd140339f4d99f66000100080002081132547600004b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a00196161616161616161616161616161616161616161616161616163000100014f000500017f0000034d0004000808000048000800000017000000a4105d002c0049000100e55700090385000010927f00000250001600580700000000000000000000000000000000000000007200020014005311004c" 177gtp = Ether(hex_bytes(h)) 178ie = gtp.IE_list[12].IE_list[2] 179ie.MaxBitRateForUplink == 0 and ie.MaxBitRateForDownlink == 0 and ie.QCI == 7 180 181= IE_Bearer_QoS, basic instantiation 182ie = IE_Bearer_QoS(ietype='Bearer QoS', length=22, PCI=4, PriorityLevel=5, PVI=6, QCI=7, 183 MaxBitRateForUplink=1, MaxBitRateForDownlink=2, GuaranteedBitRateForUplink=3, GuaranteedBitRateForDownlink=4) 184ie.ietype == 80 and ie.PCI == 4 and ie.PriorityLevel == 5 and ie.PVI == 6 and ie.QCI == 7 and ie.MaxBitRateForUplink == 1 and ie.MaxBitRateForDownlink == 2 and ie.GuaranteedBitRateForUplink == 3 and ie.GuaranteedBitRateForDownlink == 4 185 186= IE_RAT, dissection 187h = "3333333333332222222222228100a384080045b800ed00000000fc1193430a2a00010a2a00027f61084b00d91c47482000cd140339f4d99f66000100080002081132547600004b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a00196161616161616161616161616161616161616161616161616163000100014f000500017f0000034d0004000808000048000800000017000000a4105d002c0049000100e55700090385000010927f00000250001600580700000000000000000000000000000000000000007200020014005311004c" 188gtp = Ether(hex_bytes(h)) 189ie = gtp.IE_list[4] 190ie.RAT_type == 6 191 192= IE_RAT, basic instantiation 193ie = IE_RAT(ietype='RAT', length=1, RAT_type='EUTRAN') 194ie.ietype == 82 and ie.RAT_type == 6 195 196= IE_ServingNetwork, dissection 197h = "3333333333332222222222228100a384080045b800ed00000000fc1193430a2a00010a2a00027f61084b00d91c47482000cd140339f4d99f66000100080002081132547600004b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a00196161616161616161616161616161616161616161616161616163000100014f000500017f0000034d0004000808000048000800000017000000a4105d002c0049000100e55700090385000010927f00000250001600580700000000000000000000000000000000000000007200020014005311004c" 198gtp = Ether(hex_bytes(h)) 199ie = gtp.IE_list[3] 200ie.MCC == b'234' and ie.MNC == b'02' 201 202= IE_ServingNetwork, basic instantiation 203ie = IE_ServingNetwork( 204 ietype='Serving Network', length=3, MCC='234', MNC='02') 205ie.ietype == 83 and ie.MCC == b'234' and ie.MNC == b'02' 206 207= IE_ULI, dissection 208h = "3333333333332222222222228100a384080045b800ed00000000fc1193430a2a00010a2a00027f61084b00d91c47482000cd140339f4d99f66000100080002081132547600004b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a00196161616161616161616161616161616161616161616161616163000100014f000500017f0000034d0004000808000048000800000017000000a4105d002c0049000100e55700090385000010927f00000250001600580700000000000000000000000000000000000000007200020014005311004c" 209gtp = Ether(hex_bytes(h)) 210ie = gtp.IE_list[2] 211ie.TAI_Present == 1 and ie.ECGI_Present == 1 and ie.TAI.MCC == b'234' and ie.TAI.MNC == b'02' and ie.TAI.TAC == 12345 and ie.ECGI.MCC == b'234' and ie.ECGI.MNC == b'02' and ie.ECGI.ECI == 123456 212 213= IE_ULI, basic instantiation 214ie = IE_ULI(ietype='ULI', length=13, LAI_Present=0, ECGI_Present=1, TAI_Present=1, RAI_Present=0, SAI_Present=0, 215 CGI_Present=0, TAI=ULI_TAI(MCC='234', MNC='02', TAC=12345), ECGI=ULI_ECGI(MCC='234', MNC='02', ECI=123456)) 216ie.ietype == 86 and ie.LAI_Present == 0 and ie.ECGI_Present == 1 and ie.TAI_Present == 1 and ie.RAI_Present == 0 and ie.SAI_Present == 0 and ie.CGI_Present == 0 and ie.TAI.MCC == b'234' and ie.TAI.MNC == b'02' and ie.TAI.TAC == 12345 and ie.ECGI.MCC == b'234' and ie.ECGI.MNC == b'02' and ie.ECGI.ECI == 123456 217 218= IE_FTEID, dissection 219h = "3333333333332222222222228100a384080045b800ed00000000fc1193430a2a00010a2a00027f61084b00d91c47482000cd140339f4d99f66000100080002081132547600004b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a00196161616161616161616161616161616161616161616161616163000100014f000500017f0000034d0004000808000048000800000017000000a4105d002c0049000100e55700090385000010927f00000250001600580700000000000000000000000000000000000000007200020014005311004c" 220gtp = Ether(hex_bytes(h)) 221ie = gtp.IE_list[5] 222ie.GRE_Key == 4242 and ie.ipv4 == '127.0.0.2' 223 224= IE_FTEID, basic instantiation 225ie = IE_FTEID(ietype='F-TEID', length=9, ipv4_present=1, 226 InterfaceType=10, GRE_Key=0x1092, ipv4='127.0.0.2') 227ie.ietype == 87 and ie.ipv4_present == 1 and ie.InterfaceType == 10 and ie.GRE_Key == 0x1092 and ie.ipv4 == '127.0.0.2' 228 229= IE_BearerContext, dissection 230h = "3333333333332222222222228100a384080045b800ed00000000fc1193430a2a00010a2a00027f61084b00d91c47482000cd140339f4d99f66000100080002081132547600004b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a00196161616161616161616161616161616161616161616161616163000100014f000500017f0000034d0004000808000048000800000017000000a4105d002c0049000100e55700090385000010927f00000250001600580700000000000000000000000000000000000000007200020014005311004c" 231gtp = Ether(hex_bytes(h)) 232ie = gtp.IE_list[12] 233len(ie.IE_list) == 3 and ie.IE_list[0].ietype == 73 and ie.IE_list[0].EBI == 229 and ie.IE_list[ 234 1].ietype == 87 and ie.IE_list[1].ipv4 == '127.0.0.2' and ie.IE_list[2].ietype == 80 and ie.IE_list[2].QCI == 7 235 236= IE_BearerContext, basic instantiation 237ie = IE_BearerContext(ietype='Bearer Context', length=44, IE_list=[ 238 IE_EPSBearerID(ietype='EPS Bearer ID', length=1, EBI=229)]) 239ie.ietype == 93 and len(ie.IE_list) == 1 and ie.IE_list[ 240 0].ietype == 73 and ie.IE_list[0].EBI == 229 241 242= IE_ChargingID, dissection 243h = "3333333333332222222222228100838408004580006d00000000f31180d20a2a00010a2a0002084b85930059e49a4823004da0316b4d96ac2c000200020010004c00060011111111111149000100c348000800000061a8000249f07f000100005d001300490001003f0200020010005e00040039004f454a0004007f00000436f73a63" 244gtp = Ether(hex_bytes(h)) 245ie = gtp.IE_list[5].IE_list[2] 246ie.ChargingID == 956321605 247 248= IE_ChargingID, basic instantiation 249ie = IE_ChargingID(ietype='Charging ID', length=4, ChargingID=956321605) 250ie.ietype == 94 and ie.ChargingID == 956321605 251 252= IE_ChargingCharacteristics, dissection 253h = "3333333333332222222222228100a384080045b8011800000000fc1193150a2a00010a2a00027be5084b010444c4482000f82fd783953790a2000100080002081132547600004c0006001111111111114b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a001961616161616161616161616161616161616161616161616161800001000063000100014f000500017f0000034d000400000800007f00010000480008000000c3500002e6304e001a008080211001000010810600000000830600000000000d00000a005d001f00490001000750001600190700000000000000000000000000000000000000007200020014005f0002000a008e80b09f" 254gtp = Ether(hex_bytes(h)) 255ie = gtp.IE_list[18] 256ie.ChargingCharacteristric == 0xa00 257 258= IE_ChargingCharacteristics, basic instantiation 259ie = IE_ChargingCharacteristics( 260 ietype='Charging Characteristics', length=2, ChargingCharacteristric=0xa00) 261ie.ietype == 95 and ie.ChargingCharacteristric == 0xa00 262 263= IE_PDN_type, dissection 264h = "3333333333332222222222228100a384080045b800ed00000000fc1193430a2a00010a2a00027f61084b00d91c47482000cd140339f4d99f66000100080002081132547600004b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a00196161616161616161616161616161616161616161616161616163000100014f000500017f0000034d0004000808000048000800000017000000a4105d002c0049000100e55700090385000010927f00000250001600580700000000000000000000000000000000000000007200020014005311004c" 265gtp = Ether(hex_bytes(h)) 266ie = gtp.IE_list[8] 267ie.PDN_type == 1 268 269= IE_PDN_type, basic instantiation 270ie = IE_PDN_type(ietype='PDN Type', length=1, PDN_type='IPv4') 271ie.ietype == 99 and ie.PDN_type == 1 272 273= IE_UE_Timezone, dissection 274h = "3333333333332222222222228100a384080045b800ed00000000fc1193430a2a00010a2a00027f61084b00d91c47482000cd140339f4d99f66000100080002081132547600004b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a00196161616161616161616161616161616161616161616161616163000100014f000500017f0000034d0004000808000048000800000017000000a4105d002c0049000100e55700090385000010927f00000250001600580700000000000000000000000000000000000000007200020014005311004c" 275gtp = Ether(hex_bytes(h)) 276ie = gtp.IE_list[13] 277ie.Timezone == 20 and ie.DST == 0 278 279= IE_UE_Timezone, basic instantiation 280ie = IE_UE_Timezone(ietype='UE Time zone', length=2, Timezone=20, DST=0) 281ie.ietype == 114 and ie.Timezone == 20 and ie.DST == 0 282 283= IE_UE_Timezone, basic instantiation 284ie = IE_UE_Timezone(ietype='UE Time zone', length=2, Timezone=20, DST=1) 285ie.ietype == 114 and ie.Timezone == 20 and ie.DST == 1 286 287= IE_Port_Number, dissection 288h = "00010203040800808e8f8ab608004500004100010000401169140b00019705000001ec45084b002da8524820001d00000000006e400001000700420061896453f44a0004005f1e1d737e0002004532" 289gtp = Ether(hex_bytes(h)) 290ie = gtp.IE_list[2] 291ie.PortNumber == 17714 292 293= IE_Port_Number, basic instantiation 294ie = IE_Port_Number( 295 ietype='Port Number', length=2, PortNumber=17714) 296ie.ietype == 126 and ie.PortNumber == 17714 297 298= IE_APN_Restriction, dissection 299h = "3333333333332222222222228100838408004580006d00000000f31180d20a2a00010a2a0002084b85930059e49a4823004d55819f6500ede7000200020010004c000600111111111111490001003248000800000061a8000249f07f000100005d001300490001000b0200020010005e00040039004f454a0004007f00000436f73a63" 300gtp = Ether(hex_bytes(h)) 301ie = gtp.IE_list[4] 302ie.APN_Restriction == 0 303 304= IE_APN_Restriction, basic instantiation 305ie = IE_APN_Restriction( 306 ietype='APN Restriction', length=1, APN_Restriction=0) 307ie.ietype == 127 and ie.APN_Restriction == 0 308 309= IE_SelectionMode, dissection 310h = "3333333333332222222222228100a384080045b8011800000000fc1193150a2a00010a2a00027be5084b010444c4482000f8093ca4cc47fa69000100080002081132547600004c0006001111111111114b000800000000000001e24056000d001832f420303932f4200001e2405300030032f4205200010006570009008a000010927f0000025700090187000010927f00000247001a001961616161616161616161616161616161616161616161616161800001000063000100014f000500017f0000034d000400000800007f00010000480008000000c3500002e6304e001a008080211001000010810600000000830600000000000d00000a005d001f00490001004850001600190700000000000000000000000000000000000000007200020014005f0002000a008e80b09f" 311gtp = Ether(hex_bytes(h)) 312ie = gtp.IE_list[9] 313ie.SelectionMode == 0 314 315= IE_SelectionMode, basic instantiation 316ie = IE_SelectionMode( 317 ietype='Selection Mode', length=1, SelectionMode=4) 318ie.ietype == 128 and ie.SelectionMode == 4 319 320= IE_MMBR, dissection 321h = "3333333333332222222222228100838408004580014c97af0000f011830e0a2a00010a2a000282d5084b013876a74820012c29694a667f4a0b000100080002081132547600004c0006001111111111114b000800000000000001e24056000f000632f42030391a8532f42030391a855300030032f420520001000157001900c6000010927f0000020000000000000000000000000000fe8247001a001961616161616161616161616161616161616161616161616161800001000063000100014f000500017f0000034d000400000000007f000100004800080000001640000052084e00200080c02306010000060000802110010000108106000000008306000000000005005d003c00490001006057001902c4000010927f0000020000000000000000000000000000fe825000160029080000000000000000000000000000000000000000720002006e005f0002000a00a10008000000164000005208e4701ad2" 322gtp = Ether(hex_bytes(h)) 323ie = gtp.IE_list[18] 324ie.uplink_rate == 5696 and ie.downlink_rate == 21000 325 326= IE_MMBR, basic instantiation 327ie = IE_MMBR(ietype='Max MBR/APN-AMBR (MMBR)', 328 length=8, uplink_rate=5696, downlink_rate=21000) 329ie.ietype == 161 and ie.uplink_rate == 5696 and ie.downlink_rate == 21000 330 331= GTPHeader answers to not GTPHeader instance 332GTPHeader(gtp_type=2).answers(Ether()) == False 333 334= GTPHeader post_build 335gtp = GTPHeader(gtp_type="create_session_req") / ("X"*32) 336gtp.show2() 337 338= GTPHeader hashret 339req = GTPHeader(gtp_type="create_session_req") / ("X"*32) 340res = GTPHeader(gtp_type="create_session_res") / ("Y"*32) 341req.hashret() == res.hashret() 342 343= IE_NotImplementedTLV 344h = "333333333333222222222222810080c808004588002937dd0000fd1115490a2a00010a2a0002084b084b00152d0e4001000900000100ff0001000daa000000003f1f382f" 345gtp = Ether(hex_bytes(h)) 346isinstance(gtp.IE_list[0], IE_NotImplementedTLV) 347 348