test_LibItsIpv6OverGeoNetworking_TypesAndValues.ttcn3 21.9 KB
Newer Older
filatov's avatar
filatov committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520
module test_LibItsIpv6OverGeoNetworking_TypesAndValues /*language "TTCN-3:2009 Advanced Parameterization"*/ {
    import from LibCommon_BasicTypesAndValues all;
    import from LibItsCommon_TypesAndValues all;
    import from LibItsIpv6OverGeoNetworking_TestSystem all;
    import from LibItsGeoNetworking_TypesAndValues all;
    import from LibItsGeoNetworking_Templates all;
    import from LibItsGeoNetworking_Pixits {
        modulepar PX_GN_UPPER_LAYER
    };
    import from LibItsIpv6OverGeoNetworking_TypesAndValues all;
    import from LibItsIpv6OverGeoNetworking_Templates all;
    import from LibItsExternal_TypesAndValues all;
    import from test_CommonCodec all;

    group LibItsGeoNetworking_DummyTemplates {
        
        template (value) GN_Address m_dummyGnAddrNodeA := {
            typeOfAddress := e_manual,
            stationType := {
                vehicleStation := {
                    stationType := e_vehicleStation,
                    vsKind := e_bus   
                }
            },
            stationSubType := e_private,
            stationCountryCode := 49,
            mid := 'a4fdea5ea5ed'O
        }
        
        template (value) LongPosVector m_dummyLongPosVectorNodeA := {
            gnAddr := m_dummyGnAddrNodeA,
            timestamp := 875,
            latitude := 265,
            longitude := 789,
            speed := 80,
            heading := 548,
            altitude := 12,
            timeAccuracy := 5,
            posAccuracy := 1,
            speedAccuracy := 3,
            headingAccuracy := 1,
            altitudeAccuracy := 2
        }
        
        template (value) Area m_dummyArea1 := {
            geoAreaPosLatitude := 298376,
            geoAreaPosLongitude := 32745,
            distanceA := 1234,
            distanceB := 5678,
            angle := 9123
        }
        
        template (value) GeoBroadcastArea m_dummyGeoBroadcastArea1 := {
            geoBroadcastSubType := e_geoBroadcastRect,
            geoBroadcastArea := m_dummyArea1
        }
        
    } // End of group LibItsGeoNetworking_DummyTemplates
    
    group LibItsIpv6OverGeoNetworking_DummyTemplates {

        template (value) IPv6OverGeoNetworkingInd m_ipv6OverGeoNwInd(
            charstring p_interface,
            MacAddress p_srcMacAddr,
            MacAddress p_dstMacAddr,
            Ipv6Packet p_ipv6Packet
        ) := {
            interface := p_interface,
            macSourceAddress := p_srcMacAddr,
            macDestinationAddress := p_dstMacAddr,
            ipv6Packet := p_ipv6Packet
        }

        template (value) AcGn6InterfaceInfoList m_trueAcInterfaceInfoList := { 
            { 
                interfaceName := "lo", 
                ipv6AddressList := { 
                    '00000000000000000000000000000001'O 
                } 
            }, 
            { 
                interfaceName := "eth1", 
                ipv6AddressList := { 
                    'FE8000000000000002D012FFFEF1ED0E'O 
                } 
            }, 
            { 
                interfaceName := "wlan0", 
                ipv6AddressList := { 
                    '200106603013F0050000000000000001'O, 
                    'FE80000000000000021BB1FFFEB18AA3'O 
                } 
            }, 
            { 
                interfaceName := "tun0", 
                ipv6AddressList := { 
                    '200106603013F0071400001BB1B18AA3'O, 
                    'FE800000000000001400001BB1B18AA3'O 
                } 
            }
        } // End of temlate m_trueAcInterfaceInfoList

        template (value) AcGn6InterfaceInfoList m_dummyAcInterfaceInfoList := {
            {
                interfaceName := "Interface #0",
                ipv6AddressList := {
                    '1001061804000000000000005199cc70'O,
                    '1001061804000000000000005199cc71'O,
                    '1001061804000000000000005199cc72'O
                }
            },
            {
                interfaceName := "Interface #1",
                ipv6AddressList := {
                    '2001061804000000000000005199cc70'O,
                    '2001061804000000000000005199cc71'O,
                    '2001061804000000000000005199cc72'O
                }
            },
            {
                interfaceName := "Interface #2",
                ipv6AddressList := {
                    '3001061804000000000000005199cc70'O,
                    '3001061804000000000000005199cc71'O,
                    '3001061804000000000000005199cc72'O
                }
            }
        }
        
        template AcGn6Response m_dummyAcInterfaceInfos (template (present) AcGn6InterfaceInfoList p_interfaceInfoList) := {
            interfaceInfoList := p_interfaceInfoList
        }
        
        template (value) AcGn6Primitive m_dummyAcGetInterfaceInfos := {
            getInterfaceInfos := 3
        }
        
    } // End of group LibItsIpv6OverGeoNetworking_DummyTemplates
    
    group ipv6_DummyTemplates { // See http://www.zytrax.com/tech/protocols/ipv6-formats.html
        
        template (value) MacAddress m_srcMacAddress_01 := '0000860580da'O;
        template (value) MacAddress m_dstMacAddress_01 := '0060970769ea'O;
        template (value) Ipv6Address m_src_01 := 'fe80000000000000020086fffe0580da'O; 
        template (value) Ipv6Address m_dst_01 := 'fe80000000000000026097fffe0769ea'O; 
        
        template (value) MacAddress m_srcMacAddress_02 := '0000860580da'O;
        template (value) MacAddress m_dstMacAddress_02 := '0060970769ea'O;
        template (value) Ipv6Address m_src_02 := 'fe80000000000000020086fffe0580da'O; 
        template (value) Ipv6Address m_dst_02 := 'fe80000000000000026097fffe0769ea'O; 
        
        template (value) MacAddress m_srcMacAddress_03 := '0000860580da'O;
        template (value) MacAddress m_dstMacAddress_03 := '0060970769ea'O;
        template (value) Ipv6Address m_src_03 := 'fe80000000000000020086fffe0580da'O; 
        template (value) Ipv6Address m_dst_03 := 'fe80000000000000026097fffe0769ea'O; 
        template RtAdvOptions m_rtAdvOpt_srcLinkLayerAddr_03 := {
            srcLinkLayerAddr := {
                icmpType := c_srcLinkLayerAddress,
                optionLength := 8,
                linkLayerAddr := '00000000860580da'O
            },
            prefixInfoList := omit,
            otherOption := omit
        }
        
        template (value) MacAddress m_srcMacAddress_04 := '0060970769ea'O;
        template (value) MacAddress m_dstMacAddress_04 := '333300000001'O;
        template (value) Ipv6Address m_src_04 := 'fe80000000000000026097fffe0769ea'O; 
        template (value) Ipv6Address m_dst_04 := 'ff020000000000000000000000000001'O; 
        template SrcLinkLayerAddress m_srcLinkLayerAddr_04 := {
            icmpType := c_srcLinkLayerAddress,
            optionLength := 8,
            linkLayerAddr := '00000060970769ea'O
        }
        template RtAdvOptions m_rtAdvOpt_prefixOpt_04 (
            in template (value) UInt8 p_prefixLength,
            in template (value) UInt1 p_lFlag,
            in template (value) UInt1 p_aFlag,
            in template (value) UInt32 p_validLifetime,
            in template (value) UInt32 p_preferredLifetime,
            in template (value) Ipv6Address p_prefix,
            in template (value) SrcLinkLayerAddress p_srcLinkLayerAddr 
        ):={
            srcLinkLayerAddr := p_srcLinkLayerAddr,
            prefixInfoList := {
                m_prefixInfo(
                    p_prefixLength,
                    p_lFlag,
                    p_aFlag,
                    p_validLifetime,
                    p_preferredLifetime,
                    p_prefix
                )
            },
            otherOption := omit
        }
    } // End of group ipv6_DummyTemplates
    
    group testAcPrimitives {
        
        /**
         * 
         * @desc validate AcGn6Primitive primitive
         * @verdict Pass on success, Fail otherwise
         */
        testcase tc_ipv6GetInterfaceInfo() runs on TCType system TCType {
            test_PDU<AcGn6Primitive>(
                m_dummyAcGetInterfaceInfos, 
                true,
                oct2bit('02000400000003'O) // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
            );
        }

        /**
         * @desc validate AcGn6Response
         * @verdict Pass on success, Fail otherwise
         */
        testcase tc_ipv6InterfaceInfoList() runs on TCType system TCType {
            test_PDU<AcGn6Response>(
                m_dummyAcInterfaceInfos(m_dummyAcInterfaceInfoList), 
                true,
                oct2bit('0400be6700bb030c496e74657266616365202330031001061804000000000000005199cc701001061804000000000000005199cc711001061804000000000000005199cc720c496e74657266616365202331032001061804000000000000005199cc702001061804000000000000005199cc712001061804000000000000005199cc720c496e74657266616365202332033001061804000000000000005199cc703001061804000000000000005199cc713001061804000000000000005199cc72'O) // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
            )
        }
        
        testcase tc_ipv6InterfaceInfoList2() runs on TCType system TCType {
            test_decodePDU<AcGn6Response>(
                m_dummyAcInterfaceInfos(m_trueAcInterfaceInfoList), 
                '04007804026c6f0100000000000000000000000000000001046574683101fe8000000000000002d012fffef1ed0e05776c616e3002200106603013f0050000000000000001fe80000000000000021bb1fffeb18aa30474756e3002200106603013f0071400001bb1b18aa3fe800000000000001400001bb1b18aa3'O
            )
        }
        
    } // End of group testAcPrimitives
    
    group ipv6 {
        
        testcase tc_geoNetReq_icmpv6_noAdvOptions() runs on TCType system TCType {
            if (PX_GN_UPPER_LAYER != e_ipv6) {
                log("PX_GN_UPPER_LAYER shall be set to e_ipv6");
                setverdict(inconc);
                stop;
            }
            test_PDU<IPv6OverGeoNetworkingReq>(
                m_ipv6OverGeoNwReq(
                    "Interface #0",
                    m_srcMacAddress_01,
                    m_dstMacAddress_01,
                    m_ipv6Packet(
                        m_src_01, 
                        m_dst_01, 
                        c_noNextHdr, 
                        omit
                    )
                ), 
                true,
                oct2bit('4f00410c496e746572666163652023300000860580da0060970769ea6000000000003bfffe80000000000000020086fffe0580dafe80000000000000026097fffe0769ea'O) // Check for 'LibItsIPv6GeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
            )
        }
        
        testcase tc_geoNetReq_icmpv6_withAdvOptions_prefixOpt() runs on TCType system TCType {
            var Ipv6Packet v_ipv6Packet := null;
            var octetstring v_buffer := '4f00710c496e746572666163652023310000860580da0060970769ea6000000000303afffe80000000000000020086fffe0580dafe80000000000000026097fffe0769ea8600273dff00ffffffffffff00000000030400c00000001e0000001e000000002001061804000000000000005199cc70'O; // Check for 'LibItsIPv6GeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
            
            if (PX_GN_UPPER_LAYER != e_ipv6) {
                log("PX_GN_UPPER_LAYER shall be set to e_ipv6");
                setverdict(inconc);
                stop;
            }
            
            test_PDU<IPv6OverGeoNetworkingReq>(
                m_ipv6OverGeoNwReq(
                    "Interface #1",
                    m_srcMacAddress_02,
                    m_dstMacAddress_02,
                    m_ipv6Packet(
                        m_src_02, 
                        m_dst_02, 
                        c_icmpHdr,
                        m_rtAdvWithOptions(
                            m_rtAdvOpt_prefixOpt(
                                0,
                                c_lFlag1,
                                c_aFlag1,
                                c_validLifetime30s,
                                c_preferredLifetime30s,
                                '2001061804000000000000005199cc70'O
                            )
                        )
                    )
                ), 
                false,
                oct2bit(v_buffer) 
            );
            v_ipv6Packet := m_ipv6Packet(
                m_src_02, 
                m_dst_02, 
                c_icmpHdr,
                m_rtAdvWithOptions(
                    m_rtAdvOpt_prefixOpt(
                        0,
                        c_lFlag1,
                        c_aFlag1,
                        c_validLifetime30s,
                        c_preferredLifetime30s,
                        '2001061804000000000000005199cc70'O
                    )
                )
            );
            v_ipv6Packet.ipv6Hdr.payloadLength := 48;
            v_ipv6Packet.ipv6Payload.routerAdvMsg.checksum := '273d'O;
            test_decodePDU<IPv6OverGeoNetworkingReq>(
                m_ipv6OverGeoNwReq(
                    "Interface #1",
                    m_srcMacAddress_02,
                    m_dstMacAddress_02,
                    v_ipv6Packet
                ), 
                v_buffer
            );
        }
        
        testcase tc_geoNetReq_icmpv6_withAdvOptions_linkLayerAddr() runs on TCType system TCType {
            var Ipv6Packet v_ipv6Packet := null;
            var octetstring v_buffer := '4f005b0c496e746572666163652023310000860580da0060970769ea60000000001a3afffe80000000000000020086fffe0580dafe80000000000000026097fffe0769ea86006b8eff00ffffffffffff00000000010800000000860580da'O; // Check for 'LibItsIPv6GeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
            
            if (PX_GN_UPPER_LAYER != e_ipv6) {
                log("PX_GN_UPPER_LAYER shall be set to e_ipv6");
                setverdict(inconc);
                stop;
            }
            test_PDU<IPv6OverGeoNetworkingReq>(
                m_ipv6OverGeoNwReq(
                    "Interface #1",
                    m_srcMacAddress_03,
                    m_dstMacAddress_03,
                    m_ipv6Packet(
                        m_src_03, 
                        m_dst_03, 
                        c_icmpHdr,
                        m_rtAdvWithOptions(
                            m_rtAdvOpt_srcLinkLayerAddr_03
                        )
                    )
                ), 
                false,
                oct2bit(v_buffer) // Check for 'LibItsIPv6GeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
            );
            v_ipv6Packet := m_ipv6Packet(
                m_src_03, 
                m_dst_03, 
                c_icmpHdr,
                m_rtAdvWithOptions(
                    m_rtAdvOpt_srcLinkLayerAddr_03
                )
            );
            v_ipv6Packet.ipv6Hdr.payloadLength := 26;
            v_ipv6Packet.ipv6Payload.routerAdvMsg.checksum := '6B8E'O;
            test_decodePDU<IPv6OverGeoNetworkingReq>(
                m_ipv6OverGeoNwReq(
                    "Interface #1",
                    m_srcMacAddress_03,
                    m_dstMacAddress_03,
                    v_ipv6Packet
                ), 
                v_buffer
            );
        }
        
        testcase tc_geoNetReq_icmpv6_withAdvOptions_prefixOpt_linkLayerAddr() runs on TCType system TCType {
            var Ipv6Packet v_ipv6Packet := null;
            var octetstring v_buffer := '4f007b0c496e746572666163652023310060970769ea33330000000160000000003a3afffe80000000000000026097fffe0769eaff02000000000000000000000000000186001221ff00ffffffffffff00000000010800000060970769ea030440c00036ee800036ee80000000003ffe0507000000010000000000000000'O; // Check for 'LibItsIPv6GeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
            
            if (PX_GN_UPPER_LAYER != e_ipv6) {
                log("PX_GN_UPPER_LAYER shall be set to e_ipv6");
                setverdict(inconc);
                stop;
            }
            test_PDU<IPv6OverGeoNetworkingReq>(
                m_ipv6OverGeoNwReq(
                    "Interface #1",
                    m_srcMacAddress_04,
                    m_dstMacAddress_04,
                    m_ipv6Packet(
                        m_src_04, 
                        m_dst_04, 
                        c_icmpHdr,
                        m_rtAdvWithOptions(
                            m_rtAdvOpt_prefixOpt_04(
                                64,
                                c_lFlag1,
                                c_aFlag1,
                                3600000,
                                3600000,
                                '3ffe0507000000010000000000000000'O,
                                m_srcLinkLayerAddr_04
                            )
                        )
                    )
                ), 
                false,
                oct2bit(v_buffer) // Check for 'LibItsIPv6GeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
            );
            v_ipv6Packet := m_ipv6Packet(
                m_src_04, 
                m_dst_04, 
                c_icmpHdr,
                m_rtAdvWithOptions(
                    m_rtAdvOpt_prefixOpt_04(
                        64,
                        c_lFlag1,
                        c_aFlag1,
                        3600000,
                        3600000,
                        '3ffe0507000000010000000000000000'O,
                        m_srcLinkLayerAddr_04
                    )
                )
            );
            v_ipv6Packet.ipv6Hdr.payloadLength := 58;
            v_ipv6Packet.ipv6Payload.routerAdvMsg.checksum := '1221'O;
            test_decodePDU<IPv6OverGeoNetworkingReq>(
                m_ipv6OverGeoNwReq(
                    "Interface #1",
                    m_srcMacAddress_04,
                    m_dstMacAddress_04,
                    v_ipv6Packet
                ), 
                v_buffer
            );
        }
    } // End of group ipv6
    
    group testIpv6OverGeoNetPrimitiveMessages {
        
        /**
         * @desc validate IPv6OverGeoNetworkingReq
         * @verdict Pass on success, Fail otherwise
         */
        testcase tc_ipv6OverGeoNetReq() runs on TCType system TCType {
            var Ipv6Packet v_ipv6Packet := null;
            var octetstring v_buffer := '4f00690c496e7465726661636520233000508d4938ea00b0d0c7c19d60000000002806ff2001061804000000000000005199cc70200106180001800000000000000000058c9b00506ae7073600000000a0021630299c00000204058c0402080a00dd1a390000000001030302'O; // Check for 'LibItsIPv6GeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
            
            if (PX_GN_UPPER_LAYER != e_ipv6) {
                log("PX_GN_UPPER_LAYER shall be set to e_ipv6");
                setverdict(inconc);
                stop;
            }
            test_PDU<IPv6OverGeoNetworkingReq>(
                m_ipv6OverGeoNwReq(
                    "Interface #0",
                    '00508d4938ea'O,
                    '00b0d0c7c19d'O,
                    m_ipv6Packet(
                        '2001061804000000000000005199cc70'O, 
                        '20010618000180000000000000000005'O, 
                        6,
                        { octetstringMsg := '8c9b00506ae7073600000000a0021630299c00000204058c0402080a00dd1a390000000001030302'O } ) ), 
                false, 
                oct2bit(v_buffer));
            v_ipv6Packet := m_ipv6Packet(
               '2001061804000000000000005199cc70'O, 
               '20010618000180000000000000000005'O, 
               6,
               { octetstringMsg := '8c9b00506ae7073600000000a0021630299c00000204058c0402080a00dd1a390000000001030302'O } 
            ); 
            v_ipv6Packet.ipv6Hdr.payloadLength := 40; // payload length = 40
            test_decodePDU<IPv6OverGeoNetworkingReq>(
                m_ipv6OverGeoNwReq(
                    "Interface #0",
                    '00508d4938ea'O,
                    '00b0d0c7c19d'O,
                    v_ipv6Packet
                ), 
                v_buffer
            );
        }
        
        testcase tc_ipv6OverGeoNetInd() runs on TCType system TCType {
            var Ipv6Packet v_ipv6Packet := null;
            var octetstring v_buffer := '4e00690c496e7465726661636520233000b0d0c7c19d00508d4938ea60000000002806ff2001061804000000000000005199cc70200106180001800000000000000000058c9b00506ae7073600000000a0021630299c00000204058c0402080a00dd1a390000000001030302'O; // Check for 'LibItsIPv6GeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
            
            if (PX_GN_UPPER_LAYER != e_ipv6) {
                log("PX_GN_UPPER_LAYER shall be set to e_ipv6");
                setverdict(inconc);
                stop;
            }
            test_PDU<IPv6OverGeoNetworkingInd>(
                m_ipv6OverGeoNwInd(
                    "Interface #0",
                    '00b0d0c7c19d'O,
                    '00508d4938ea'O, // On purpose: IUT must use this value
                    m_ipv6Packet( // payload length = 40
                        '2001061804000000000000005199cc70'O, 
                        '20010618000180000000000000000005'O, 
                        6,
                        { octetstringMsg := '8c9b00506ae7073600000000a0021630299c00000204058c0402080a00dd1a390000000001030302'O } ) ), 
                false, 
                oct2bit(v_buffer)
            );
            v_ipv6Packet := m_ipv6Packet(
                '2001061804000000000000005199cc70'O, 
                '20010618000180000000000000000005'O, 
                6,
                { octetstringMsg := '8c9b00506ae7073600000000a0021630299c00000204058c0402080a00dd1a390000000001030302'O } 
            ); 
            v_ipv6Packet.ipv6Hdr.payloadLength := 40; // payload length = 40
            test_decodePDU<IPv6OverGeoNetworkingInd>(
                m_ipv6OverGeoNwReq(
                    "Interface #0",
                    '00b0d0c7c19d'O,
                    '00508d4938ea'O, // On purpose: IUT must use this value
                    v_ipv6Packet
                ), 
                v_buffer
            );
        }
        
    }

} // End of module test_LibItsIpv6OverGeoNetworking_TypesAndValues