LibItsFntp_Functions.ttcn3 47.8 KB
Newer Older
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 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
/**
 *  @author     ETSI / STF422_EETS
 *  @version    $URL:$
 *              $Id:$
 *  @desc       FAST networking & transport layer protocol (ISO 29281-2) functions
 */
module LibItsFntp_Functions {
    
    // Libcommon
    import from LibCommon_Sync all;
    import from LibCommon_VerdictControl {
      type FncRetCode
    };
    import from LibCommon_Time {
      function f_sleepIgnoreDef
    };
    import from LibCommon_BasicTypesAndValues { 
        type UInt16 
    };
    
    // LibIts
//    import from CITSapplMgmtApplReg language "ASN.1:1997" { // TODO To be removed
//        type ITSaid
//    };
    import from CALMmanagement language "ASN.1:1997" { 
        type StationID, ITS_scuId; 
    }; 
    import from CALMiitsscu language "ASN.1:1997" { 
        type 
            IIC_Request, IIC_Response 
    }; 
    import from CALMllsap language "ASN.1:1997" { 
        type 
            EUI64, IN_SAPaddress, LLserviceAddr, Link_ID, AccessParameters 
    }; 
    import from CALMfntp language "ASN.1:1997" all; 
    import from LibItsMgt_TypesAndValues { 
        type MacAddressType 
    }; 
    import from LibItsMgt_Functions { 
        altstep 
            a_mgtMNSapPortDefault, a_mgtSapAwaitFWTupdate 
    };
    import from CALMfsap language "ASN.1:1997" {
        type 
            CTX, SAM 
    };
    import from LibItsFsap_Templates {
        template 
            m_sam, m_ctx
    };
    import from LibItsFntp_TypesAndValues {
        const c_portDyn, c_portNon;
        type AcFntpPrimitive
    };
    import from LibItsFntp_Templates all;
    import from LibItsFntp_Pixits all;
    import from LibItsFntp_Pics {
        modulepar PICS_ITS_S_INW;
    };
    import from LibItsCommon_TypesAndValues {
        type UtCommandConfirm
    };
    import from LibItsCommon_Functions {
        function
            f_utInitializeIut, f_utCommandRequest
    };
    import from LibIts_Interface all; 
    
    group fntpConfigurationFunctions {
        
        /**
         * @desc This configuration features:
         * <li>Host and Router are combined (see ISO/WD 29281-2 - Figure 1 - Implementation architecture I)</li>
         * <li>MGT1 IISC Port (IISC/LAN) is not used</li>
         */
        function f_cf01Up() runs on ItsNt {
            
            // Sanity check
            if (PICS_ITS_S_INW) {
                log("*** f_cf01Up: ERROR: PICS_ITS_S_INW shall not be required for executing the TC ***");
                stop;
            }
            
            // Map
            map(self:acPort, system:acPort);
            map(self:utPort, system:utPort);
            map(self:mgtMNSapPort, system:mgtMNSapPort);
            map(self:fntpPort, system:fntpPort);
            
            // Connect
            f_connect4SelfOrClientSync();
            
            // Set processing on shutdown
            activate(a_cf01Down());
            
            // Initialize the component
            f_initialiseComponent("cf01Up");

            // Initialze the IUT
            f_initialState();
            
        } // End of function f_cf01Up
        
        /**
         * @desc This configuration features:
         * <li>Host and Router are separated (see ISO/WD 29281-2 - Figure 3 - Implementation architecture II & III)</li>
         * <li>MGT1 IISC Port (IISC/LAN) is not used</li>
         */
        function f_cf02Up() runs on ItsNt {
            
            // Sanity check
            if (not(PICS_ITS_S_INW)) {
                log("*** f_cf02Up: ERROR: PICS_ITS_S_INW required for executing the TC ***");
                stop;
            }
            
            vc_commandRef := 0;
            vc_pduCounter := 0;
            
            // Map
            map(self:acPort, system:acPort);
            map(self:utPort, system:utPort);
            map(self:mgtMNSapPort, system:mgtMNSapPort);
            map(self:fntpPort, system:fntpPort);
            
            // Connect
            f_connect4SelfOrClientSync();
            
            // Set processing on shutdown
            activate(a_cf02Down());
            
            // Initialize the component
            f_initialiseComponent("cf02Up");

            // Initialze the IUT
            f_initialState();
            
        } // End of function f_cf02Up
        
        /**
         * @desc Deletes configuration cf01
         */
        function f_cf01Down() runs on ItsNt {
            
            deactivate;
            
            // Unmap
            unmap(self:acPort, system:acPort);
            unmap(self:utPort, system:utPort);
            unmap(self:mgtMNSapPort, system:mgtMNSapPort);
            unmap(self:fntpPort, system:fntpPort);
            
            // Disconnect
            f_disconnect4SelfOrClientSync();
            
        } // end f_cf01Down
        
        function f_cf02Down() runs on ItsNt {
            
            deactivate;
            
            // Unmap
            unmap(self:acPort, system:acPort);
            unmap(self:utPort, system:utPort);
            unmap(self:fntpPort, system:fntpPort);
            
            // Disconnect
            f_disconnect4SelfOrClientSync();
            
        } // end f_cf02Down
        
        /**
         * @desc    Behavior function for initializing component's variables and tables
         * @param   p_componentName Name of the component
         */
        function f_initialiseComponent(in charstring p_componentName) runs on ItsNt {
            
            // Initialize variables
            vc_componentName := p_componentName;
            vc_portNumber := { portLong := c_portNon };
            vc_scuId := 255;
            
            // Set defaults
            activate(a_fntpDefault()); // Default for Fntp module
            activate(a_mgtMNSapPortDefault()); // Default for MGT module / MF-SAP port
            
        } // end f_initialiseComponent
        
    } // End of group fntpConfigurationFunctions
    
    group preambles {
        
        /**
         * @desc Brings the IUT into an initial state.
         */
        function f_initialState() runs on ItsNt {
            
            f_utInitializeIut(m_fntpInitialize);
            f_sleepIgnoreDef(2.0); // Wait until the IUT is in a stable situation (beaconing...)
        } // End of function f_initialState
        
        /**
         * @desc Implement the following Initial conditions:
         * <li>the IUT having set up properly the FNTP forwarding table, and the local port number of the ITS-S application</li>
         * <li>the IUT having an entry in the FNTP forwarding table for unicast communication with remote Link Port and Service Port</li>
         * <li>the IUT having an entry in the FNTP forwarding table for Service Port = port1, but not for Service Port = port2</li>
         * <li>the IUT having an entry in the FNTP forwarding table for a Service Port, but no entry for the peer station</li>
         * @param p_macAddressType Indicates the type of MAC address content
         * @param p_port Indicates the port number
         * @verdict Unchanged on success, set to fail on error (e_timeout)
         * @see ISO/WD 29281-2 Clause 8.2
         */
        function f_initializeFntpForwardingTable(in MacAddressType p_macAddressType, in UInt16 p_port) runs on ItsNt {
            // Request allocation of a port number associated with the ITS-SP
            f_utCommandRequest(
                m_generateNfFntpPortCreationRequest(
                    f_getIutServiceRef(), 
                    p_port),
                mw_fntpPortConfirm(
                    f_getIutServiceRef(), 
                    ?),
                false, // Reply is expected to retrieve the port number
                vc_utCommandConf);
            // Store the allocated port number
            vc_portNumber := vc_utCommandConf.utFntpCommandConfirm.nfSapPrimitives.primitivesUp.fntpPortConfirm.servicePort;
            if (ischosen(vc_portNumber.portShort)) {
                log("*** f_initializeFntpForwardingTable: INFO: portNumber value is: " & int2str(vc_portNumber.portShort) & " ***");
            } else {
                log("*** f_initializeFntpForwardingTable: INFO: portNumber value is: " & int2str(vc_portNumber.portLong) & " ***");
            }
            // And wait for a MN-SAP.MN-COMMAND/FWTupdate message sent by IST management entity to update the forwarding table
            f_mnSapAwaitFWTupdate();
            
        } // End of function f_initializeFntpForwardingTable
        
//        /**
//         * @desc Implement the following Initial conditions:
//         * <li>the IUT having an entry in the FNTP forwarding table for a Service Port, but no entry for the peer station</li>
//         * @param p_macAddressType Indicates the type of MAC address content
//         * @param p_port Indicates the port number
//         * @verdict Set to fail on error (timeout)
//         * 
//         * See ISO/WD 29281-2 Clause 8.2
//         */
//        // FIXME What does 'but no entry for the peer station' mean?
//        function f_initializeFntpForwardingTableWithNoPeerStation(in MacAddressType p_macAddressType, in UInt16 p_port) runs on ItsNt {
//            var boolean v_retCode := false;
//            
//            // FIXME To be rewritten
////            // Create sockect sending for FTN-SOCKET.request with a dynamic port allocation & waiting for FTN-SOCKET.confirm
////            f_utCommandRequest(
////                m_generateNfFntpSocketCreationRequest(f_getIutServiceRef(), p_port),
////                mw_fntpSocketConfirm(f_getIutServiceRef(), ?),
////                false, // Reply is expected to retrieve the port number
////                vc_utCommandConf);
////                
////            // Store the allocated port number
////            vc_portNumber := vc_utCommandConf.utFntpCommandConfirm.nfSapPrimitives.fntpSocketConfirm.servicePort;
////            log("*** f_initializeFntpForwardingTableWithNoPeerStation: INFO: portNumber value is: " & int2str(vc_portNumber) & " ***");
////            
////            // And wait for a MN-SAP.MN-COMMAND/FWTupdate message sent by IST management entity to update the forwarding table
////            f_mnSapAwaitFWTupdate();
//            
//        } // End of function f_initializeFntpForwardingTableWithNoPeerStation
//        
        /**
         * @desc Call this method to remove entry created by f_initializeFntpForwardingTable() in FNTP Forwarding Table
         * @verdict Unchanged
         */
        function f_unInitializeFntpForwardingTable() runs on ItsNt {
            // Send for FTN-SOCKET.request & Wait for FTN-SOCKET.confirm
            f_utCommandRequest(
                m_generateNfFntpPortDeletionRequest(f_getIutServiceRef(), vc_portNumber),
                mw_fntpPortConfirm(f_getIutServiceRef(), ?),
                false,
                vc_utCommandConf);
        } // End of function f_unInitializeFntpForwardingTable
        
//        /**
//         * @desc    TODO
//         * @verdict Unchanged on success, set to fail on error (e_timeout)
//         */
//        function f_registerToGroupcasting() runs on ItsNt {
//            if (not(f_mgtItsApplRegToGroupcasting(m_gCregClient(f_getIutHostScuIdValue(), f_getIutServiceIdValue())))) {
//                log("*** f_registerToGroupcasting: ERROR: Timeout while waiting for GCregClient MF-REQUEST.confirm serviec primitive ***");
//                f_selfOrClientSyncAndVerdict("error", e_timeout);
//            }
//        } // End of function f_registerToGroupcasting
//        
//        function f_deregisterToGroupcasting() runs on ItsNt {
//            if (not(f_mgtItsApplDeregToGroupcasting(m_gCderegClient(f_getIutHostScuIdValue())))) {
//                log("*** f_deregisterToGroupcasting: ERROR: Timeout while waiting for GCderegClient MF-REQUEST.confirm serviec primitive ***");
//                f_selfOrClientSyncAndVerdict("error", e_timeout);
//            }
//        } // End of function f_deregisterToGroupcasting
//        
    } // End of group preambles
    
    group postambles {
        
        /**
         * @desc The default postamble.
         */
        function f_poDefault() runs on ItsNt {
            //empty
        }
        
    } // End of group postambles
    
    /**
     * @desc    MN-SAP primitives
     * @see     ISO/CD 24102-3 - Clause 7. MN-SAP
     */
    group testerFunctions {
        
    } // End of group testerFunctions
    
    group mnSapFunctions {
        
        /**
         * @desc    Wait for MN-SAP.MN-COMMAND/FWTupdate message sent by IST management entity to update the forwarding table
         * @verdict Unchanged
         */
        function f_mnSapAwaitFWTupdate() runs on ItsNt {
            
            tc_ac.start;
            alt {
                [] a_mgtSapAwaitFWTupdate() {
                    tc_ac.stop;
                    log("*** f_mnSapAwaitFWTupdate: INFO: Expected message not received ***");
                }
                [] tc_ac.timeout {
                    log("*** f_mnSapAwaitFWTupdate: ERROR: MN-SAP FWTupdate service primitive not received ***");
                }
            } // End of 'alt' statement
        } // End of function f_mnSapAwaitFWTupdate()
        
        /**
         * @desc    Generate a correctly formatted GCctxTxCmd message via IN-SAP interface
         * @param   p_commandRef  Unique cyclic reference number of command. Same value as in related MN-REQUEST.request
         * @param   p_linkID      Link ID of the peer station
         * @param   p_clientID    TODO
         * @verdict Unchanged
         */
        // FIXME To be removed - Moved on NF-SAP
//        function f_mnSapGenerateGCctxTxCmd(in CommandRef p_commandRef, in Link_ID p_linkID, in ITSaid p_clientID) runs on ItsNt {
//            f_mgtGenerateGCctxTxCmd(
//                p_commandRef, 
//                m_gCctxTxCmd(
//                    f_getIutINSapAddress(), 
//                    p_linkID, 
//                    p_clientID
//                )
//            );
//        }
        
        /**
         * @desc    Generate a correctly formatted SAM/CTXrxNot message from peer station via IN-SAP interface
         * @param   p_commandRef  Unique cyclic reference number of command. Same value as in related MN-REQUEST.request
         * @param   p_linkID      Link ID of the peer station
         * @param   p_clientID    
         * @verdict Unchanged
         */
        // FIXME To be removed - Moved on NF-SAP
//        function f_mnSapGenerateCTXrxNot(in CommandRef p_commandRef, in Link_ID p_linkID, in ITSaid p_clientID) runs on ItsNt {
//            f_mgtGenerateCTXrxNot(
//                p_commandRef, 
//                m_cTXrxNot(
//                    f_getIutINSapAddress(), 
//                    p_linkID, 
//                    p_clientID
//                )
//            );
//        }
        
    } // End of group testerFunctions
    
    group adapterControl {
        
        /**
         * @desc    Triggers event in the test system adaptation via IN-SAP interface.
         * @param   p_event The event to trigger
         */
        function f_acTriggerEvent(template (value) AcFntpPrimitive p_event) runs on ItsAdapterComponent {
            acPort.send(p_event);
        }
        
        /**
         * @desc    Triggers test adapter to send FNTP NDPU
         * @param   p_sourcePort TODO
         * @param   p_destinationPort TODO
         * @param   p_sourcePort IN-SAP source port
         * @param   p_destinationPort IN-SAP destination port
         * @param   p_hops N-hops value
         */
        function f_acGenerateFntpNPDU(
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) LLserviceAddr p_insap_source_address, // TODO Rename in p_insap_source_address
            in template (value) LLserviceAddr p_insap_dest_address,  // TODO Rename in p_insap_dest_address
            in FNTPhopCount p_hops 
        ) runs on ItsNt { 
            f_acTriggerEvent( 
                m_generateFntpNPDU( 
                    p_insap_source_address, 
                    p_insap_dest_address, 
                    bit2oct( 
                        encvalue( 
                            m_basicNPDU( 
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops 
                            ) 
                        ) 
                    ) 
                ) 
            ); 
        } // End of function f_acGenerateFntpNPDU
        
        /**
         * @desc    Triggers lower tester to send FNTP station-internal NDPU with several hops and an invalid control field
         * @param   p_sourcePort        Source port 
         * @param   p_destinationPort   Destination port 
         * @param   p_insap_source_address     IN-SAP source port 
         * @param   p_insap_dest_address       IN-SAP destination port 
         * @param   p_hops              N-hops value 
         */
        function f_acGenerateFntpNPDU_InvalidCtrlField( 
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) LLserviceAddr p_insap_source_address, // TODO Rename in p_insap_source_address
            in template (value) LLserviceAddr p_insap_dest_address,  // TODO Rename in p_insap_dest_address
            in template (value) FNTPhopCount p_hops 
        ) runs on ItsNt { 
            f_acTriggerEvent(
                m_generateFntpNPDU( 
                    p_insap_source_address, 
                    p_insap_dest_address, 
                    bit2oct( 
                        encvalue( 
                            md_extendedNPDU_InvalidCtrlField( 
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops 
                            ) 
                        ) 
                    ) 
                ) 
            ); 
        } // End of function f_acGenerateFntpNPDU_InvalidCtrlField
        
        /**
         * @desc    Triggers lower tester to send FNTP station-internal NDPU with bit5 set 
         * @param   p_sourcePort        Source port 
         * @param   p_destinationPort   Destination port 
         * @param   p_insap_source_address     IN-SAP source port 
         * @param   p_insap_dest_address       IN-SAP destination port 
         */
        function f_acGenerateFntpNPDU_InvalidBitSet( 
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) LLserviceAddr p_insap_source_address, // TODO Rename in p_insap_source_address
            in template (value) LLserviceAddr p_insap_dest_address  // TODO Rename in p_insap_dest_address
        ) runs on ItsNt { 
            f_acTriggerEvent(
                m_generateFntpNPDU( 
                    p_insap_source_address, 
                    p_insap_dest_address, 
                    bit2oct( 
                        encvalue( 
                            md_extendedNPDU_InvalidBitSet( 
                                p_sourcePort, 
                                p_destinationPort, 
                                omit
                            ) 
                        ) 
                    ) 
                ) 
            ); 
        } // End of function f_acGenerateFntpNPDU_With_Bit5
        
        /**
         * @desc    Triggers test adapter to send FNTP NDPU
         * @param   p_sourcePort        Source port 
         * @param   p_destinationPort   Destination port 
         * @param   p_insap_source_address     IN-SAP source port 
         * @param   p_insap_dest_address       IN-SAP destination port 
         * @param   p_hops              N-hops value 
         * @param   p_rxCIP             Receive (RX) parameter settings
         * @param   p_txCIP             Transmit (TX) parameters of a VCI
         * @param   p_accessParams        Access parameters 
         */
        function f_acGenerateFntpNPDU_CIP(
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) LLserviceAddr p_insap_source_address, // TODO Rename in p_insap_source_address
            in template (value) LLserviceAddr p_insap_dest_address,  // TODO Rename in p_insap_dest_address
            in template (value) FNTPhopCount p_hops, 
            in template (value) RXcip p_rxCIP, // TODO Perhaps this parameter is not required, p_accessParams would be enough
            in template (value) TXcip p_txCIP, // TODO Perhaps this parameter is not required, p_accessParams would be enough
            in template (value) AccessParameters p_accessParams 
        ) runs on ItsNt { 
            f_acTriggerEvent( 
                m_generateFntpNPDU_CIP( 
                    p_insap_source_address, 
                    p_insap_dest_address, 
                    bit2oct( 
                        encvalue( 
                            md_extendedNPDU_CIP( 
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops, 
                                p_rxCIP, // TODO Perhaps this parameter is not required, p_accessParams would be enough
                                p_txCIP // TODO Perhaps this parameter is not required, p_accessParams would be enough
                            ) 
                        ) 
                    ), 
                    p_accessParams 
                ) 
            ); 
        } // End of function f_acGenerateFntpNPDU_CIP
        
        /**
         * @desc    Triggers test adapter to send FNTP forwarding NDPU
         * @param   p_sourcePort        Source port (c_portRtr or c_portHst)
         * @param   p_destinationPort   Destination port (c_portRtr or c_portHst)
         * @param   p_fromPort          Forwarding source port
         * @param   p_toPort            Forwarding destination port
         * @param   p_sourcePort        IN-SAP source port
         * @param   p_destinationPort   IN-SAP destination port
         * @param   p_counter           Expected value of FNTP packet counter counter field
         * @param   p_hops              N-hops value
         */
        function f_acGenerateFntpForwardingNPDU(
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) PortNumber p_fromPort, 
            in template (value) PortNumber p_toPort,
            in template (value) LLserviceAddr p_insap_source_address, // TODO Rename in p_insap_source_address
            in template (value) LLserviceAddr p_insap_dest_address,  // TODO Rename in p_insap_dest_address
            in template (value) FNTPpacketCounter p_counter, 
            in template (value) FNTPhopCount p_hops 
        ) runs on ItsNt { 
            f_acTriggerEvent( 
                m_generateFntpNPDU( 
                    p_insap_source_address, 
                    p_insap_dest_address, 
                    bit2oct( 
                        encvalue( 
                            md_forwardingNPDU( 
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops,
                                p_fromPort,
                                p_toPort,
                                p_counter 
                            ) // End of field 'md_forwardingNPDU'
                        ) // End of function encvalue
                    ) // End of function bit2oct
                ) // End of field 'm_generateFntpNPDU'
            ); 
        } // End of function f_acGenerateFntpForwardingNPDU
        
        /**
         * @desc    Triggers test adapter to send FNTP forwarding NDPU with an unknown ITS-SCU-ID
         * @param   p_sourcePort        Source port (c_portRtr or c_portHst)
         * @param   p_destinationPort   Destination port (c_portRtr or c_portHst)
         * @param   p_fromPort          Forwarding source port
         * @param   p_toPort            Forwarding destination port
         * @param   p_sourcePort        IN-SAP source port
         * @param   p_destinationPort   IN-SAP destination port
         * @param   p_counter           Expected value of FNTP packet counter counter field
         * @param   p_hops              N-hops value
         */
        function f_acGenerateFntpForwardingNPDU_UnknownITS_SCU_ID(
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) PortNumber p_fromPort, 
            in template (value) PortNumber p_toPort,
            in template (value) LLserviceAddr p_insap_source_address, // TODO Rename in p_insap_source_address
            in template (value) LLserviceAddr p_insap_dest_address,  // TODO Rename in p_insap_dest_address
            in template (value) FNTPpacketCounter p_counter, 
            in template (value) FNTPhopCount p_hops 
        ) runs on ItsNt { 
            f_acTriggerEvent( 
                m_generateFntpNPDU( 
                    p_insap_source_address, 
                    p_insap_dest_address, 
                    bit2oct( 
                        encvalue( 
                            md_forwardingNPDU_UnknownITS_SCU_ID( 
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops,
                                p_fromPort,
                                p_toPort,
                                p_counter 
                            ) // End of field 'md_forwardingNPDU_UnknownITS_SCU_ID'
                        ) // End of function encvalue
                    ) // End of function bit2oct
                ) // End of field 'm_generateFntpNPDU'
            ); 
        } // End of function f_acGenerateFntpForwardingNPDU_UnknownITS_SCU_ID
        
        /**
         * @desc    Triggers test adapter to send FNTP forwarding NDPU with CIP
         * @param   p_sourcePort        Source port (c_portRtr or c_portHst)
         * @param   p_destinationPort   Destination port (c_portRtr or c_portHst)
         * @param   p_fromPort          Forwarding source port
         * @param   p_toPort            Forwarding destination port
         * @param   p_sourcePort        IN-SAP source port
         * @param   p_destinationPort   IN-SAP destination port
         * @param   p_counter           Expected value of FNTP packet counter counter field
         * @param   p_hops              N-hops value
         * @param   p_rxCIP             Receive (RX) parameter settings
         * @param   p_txCIP             Transmit (TX) parameters of a VCI
         */
        function f_acGenerateFntpForwardingNPDU_CIP(
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) PortNumber p_fromPort, 
            in template (value) PortNumber p_toPort,
            in template (value) LLserviceAddr p_insap_source_address, // TODO Rename in p_insap_source_address
            in template (value) LLserviceAddr p_insap_dest_address,  // TODO Rename in p_insap_dest_address
            in template (value) FNTPpacketCounter p_counter, 
            in template (value) FNTPhopCount p_hops, 
            in template (value) RXcip p_rxCIP, // TODO Perhaps this parameter is not required, p_accessParams would be enough
            in template (value) TXcip p_txCIP, // TODO Perhaps this parameter is not required, p_accessParams would be enough
            in template (value) AccessParameters p_accessParams 
        ) runs on ItsNt { 
            f_acTriggerEvent( 
                m_generateFntpNPDU_CIP( 
                    p_insap_source_address, 
                    p_insap_dest_address, 
                    bit2oct( 
                        encvalue( 
                            md_forwardingNPDU_CIP( 
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops, 
                                p_fromPort, 
                                p_toPort, 
                                p_counter, 
                                p_rxCIP, // TODO Perhaps this parameter is not required, p_accessParams would be enough
                                p_txCIP // TODO Perhaps this parameter is not required, p_accessParams would be enough
                            ) // End of field 'md_forwardingNPDU_CIP'
                        ) // End of function 'encvalue'
                    ), // End of function 'bit2oct'
                    p_accessParams 
                ) 
            ); 
        } // End of function f_acGenerateFntpForwardingNPDU_CIP
        
        /**
         * @desc    Triggers test adapter to generate Service advertisement message (SAM) PDU via IN_SAP interface
         * @param   p_sourcePort IN-SAP source port
         * @param   p_destinationPort IN-SAP destination port
         * @param   p_stationID ITS station identifier
         * @verdict Unchanged
         */
        function f_acGenerateSAM( 
            in template (value) LLserviceAddr p_insap_source_address, 
            in template (value) LLserviceAddr p_insap_dest_address, 
            in template (value) StationID p_stationID 
        ) runs on ItsNt { 
            f_acTriggerEvent( 
                m_generateSamMessagePDU( 
                    p_insap_source_address, 
                    p_insap_dest_address, 
                    bit2oct( 
                        encvalue( 
                            m_sam(
                                p_stationID
                            ) 
                        ) 
                    ) 
                ) 
            ); 
        } // End of function f_acGenerateSAM
        
        /**
         * @desc    Triggers test adapter to generate Service context message (CTX) PDU via IN_SAP interface
         * @param   p_sourcePort IN-SAP source port
         * @param   p_destinationPort IN-SAP destination port
         * @param   p_stationID ITS station identifier (See ISO/CD 24102-5 Clause 7.2.3 Service context message)
         * @verdict Unchanged
         */
        function f_acGenerateCTX( 
            in template (value) LLserviceAddr p_insap_source_address, 
            in template (value) LLserviceAddr p_insap_dest_address, 
            in template (value) StationID p_stationID 
        ) runs on ItsNt { 
            f_acTriggerEvent( 
                m_generateCtxMessagePDU( 
                    p_insap_source_address, 
                    p_insap_dest_address, 
                    bit2oct( 
                        encvalue( 
                            m_ctx( 
                                p_stationID 
                            ) 
                        ) 
                    ) 
                ) 
            ); 
        }
        
    } // End of group adapterControl
    
    group internalFunctions { // TODO Use parametrized function (ETSI ES 202 784) insetad of the three oct2xxx functions
        
        /**
         * @desc  This function convert the specified octetstring into a template (FNTPNPDU or FntpExtInd or FntpFwdInd)
         * This SHALL be done due to the ASN.1 description of IN-SAP service primitives DL_Unitdata_request/DL_Unitdata_indication
         * @param p_data        An octetstring to decode
         * @param p_syncPoint   Current synchronisation point, required to set verdict according to the LibCommon rules
         * @param p_decoded     The decoded message
         * @verdict Unchanged on success, set to fail otherwise
         * @see ISO/CD 21218 - Clause 8.2.2
         */
        function oct2npdu(in octetstring p_data, in charstring p_syncPoint, out FNTPNPDU p_decoded) runs on ItsAdapterComponent {
            var integer v_result;
            
            v_result := decvalue(oct2bit(p_data), p_decoded);
            if (v_result == 1) {
                f_selfOrClientSyncAndVerdictTestBody(p_syncPoint, e_error); 
                log("*** oct2npdu: FAIL: 'decvalue' operation failed ***");
            } else if (v_result == 2) {
                f_selfOrClientSyncAndVerdictTestBody(p_syncPoint, e_error); 
                log("*** oct2npdu: FAIL: 'decvalue' operation failed, not enougth bits ***");
            }
            log("*** oct2npdu: INFO: Decoded message done ***");
        } // End of function oct2npdu
        
        /**
         * @desc  This function convert the specified octetstring into a CTX template
         * @param p_data        An octetstring to decode
         * @param p_syncPoint   Current synchronisation point, required to set verdict according to the LibCommon rules
         * @param p_decoded     The decoded message
         * @verdict Unchanged on success, set to fail otherwise
         * @see ISO/CD 29281 - Clause 7.9.2 & 7.9.4
         */
        function oct2ctx(in octetstring p_data, in charstring p_syncPoint, out CTX p_decoded) runs on ItsAdapterComponent {
            var integer v_result;
            
            v_result := decvalue(oct2bit(p_data), p_decoded);
            if (v_result == 1) {
                f_selfOrClientSyncAndVerdictTestBody(p_syncPoint, e_error); 
                log("*** oct2ctx: FAIL: 'decvalue' operation failed ***");
            } else if (v_result == 2) {
                f_selfOrClientSyncAndVerdictTestBody(p_syncPoint, e_error); 
                log("*** oct2ctx: FAIL: 'decvalue' operation failed, not enougth bits ***");
            }
            log("*** oct2ctx: INFO: Decoded message done ***");
        } // End of function oct2ctx
        
        /**
         * @desc  This function convert the specified octetstring into a CTX template
         * @param p_data        An octetstring to decode
         * @param p_syncPoint   Current synchronisation point, required to set verdict according to the LibCommon rules
         * @param p_decoded     The decoded message
         * @verdict Unchanged on success, set to fail otherwise
         * @see ISO/CD 29281 - Clause 7.9.3
         */
        function oct2sam(in octetstring p_data, in charstring p_syncPoint, out SAM p_decoded) runs on ItsAdapterComponent {
            var integer v_result;
            
            v_result := decvalue(oct2bit(p_data), p_decoded);
            if (v_result == 1) {
                f_selfOrClientSyncAndVerdictTestBody(p_syncPoint, e_error); 
                log("*** oct2sam: FAIL: 'decvalue' operation failed ***");
            } else if (v_result == 2) {
                f_selfOrClientSyncAndVerdictTestBody(p_syncPoint, e_error); 
                log("*** oct2sam: FAIL: 'decvalue' operation failed, not enougth bits ***");
            }
            log("*** oct2sam: INFO: Decoded message done ***");
        } // End of function oct2npdu
        
    } // End of group internalFunctions
    
    group iutFunctions {
        
        /**
         * @desc    Get the local identifier of the VCI
         * @return  The local identifier of the VCI
         * @see     PX_SRC_LOCAL_CIID
         * @verdict Unchanged
         * @see ISO 21218 - Clause 6.2 Link Identifier
         */
        function f_getIutSrcLocalCIID() return EUI64 {
            return PX_SRC_LOCAL_CIID;
        }
        
        /**
         * @desc    Get the local identifier of the VCI
         * @return  The local identifier of the VCI
         * @see     PX_DEST_LOCAL_CIID
         * @verdict Unchanged
         * @see ISO 21218 - Clause 6.2 Link Identifier
         */
        function f_getIutDestLocalCIID() return EUI64 {
            return PX_DEST_LOCAL_CIID;
        }
        
        /**
         * @desc    Get the local identifier of the VCI for broadcast on ITS-S host
         * @return  The local identifier of the VCI for broadcast on ITS-S host
         * @see     PX_SRC_REMOTE_CIID_BC
         * @verdict Unchanged
         */
        function f_getIutSrcRemoteCIID_BC() return EUI64 {
            return PX_SRC_REMOTE_CIID_BC;
        }
        
        /**
         * @desc    Get the identifier of a different VCI on ITS-S host/router only 
         * @return  The identifier of a different VCI on ITS-S host/router only 
         * @see     PX_SRC_DIFFERENT_LOCAL_CIID
         * @verdict Unchanged
         */
        function f_getIutSrcDifferentLocalCIID() return EUI64 {
            return PX_SRC_DIFFERENT_LOCAL_CIID;
        }
        
        /**
         * @desc    Get the identifier of a second VCI for unicast (peer to peer) on ITS-S host 
         * @return  The identifier of a a second VCI for unicast (peer to peer) on ITS-S host 
         * @see     PX_SRC_SECOND_REMOTE_CIID_UC
         * @verdict Unchanged
         */
        function f_getIutSrcSecondRemoteCIID() return EUI64 {
            return PX_SRC_SECOND_REMOTE_CIID_UC;
        }
        
        /**
         * @desc    Get the remote CIID for unicast (peer to peer)
         * @return  The remote CIID for unicast 
         * @see     PX_SRC_REMOTE_CIID_UC
         * @verdict Unchanged
         */
        function f_getIutSrcRemoteCIID_UC() return EUI64 {
            return PX_SRC_REMOTE_CIID_UC;
        }
        
        /**
         * @desc    Get the remote identifier of a second VCI for unicast (peer to peer) on ITS-S host 
         * @return  The remote identifier of a a second VCI for unicast (peer to peer) on ITS-S host 
         * @see     PX_DEST_REMOTE_CIID_UC
         * @verdict Unchanged
         */
        function f_getIutDestRemoteCIID() return EUI64 {
            return PX_DEST_REMOTE_CIID_UC;
        }
        
        /**
         * @desc    Get the source forwarding port
         * @return  The source forwarding port
         * @see     PX_FORWARDING_SRC_PORT
         * @verdict Unchanged
         */
        function f_getIutForwardingSrcPort() return PortNumber {
            return PX_FORWARDING_SRC_PORT;
        }
        
        /**
         * @desc    Get the destination forwarding port
         * @return  The destination forwarding port
         * @see     PX_FORWARDING_DST_PORT
         * @verdict Unchanged
         */
        function f_getIutForwardingDestPort() return PortNumber {
            return PX_FORWARDING_DST_PORT;
        }
        
        /**
         * @desc    Get the source port number, i.e. the local endpoint
         * @return  The source port number
         * @see     PX_LOCAL_PORT_NUMBER
         * @verdict Unchanged
         */
        function f_getIutLocalPortNumber() return PortNumber {
            return PX_LOCAL_PORT_NUMBER;
        }
        
        /**
         * @desc    Get the remote port number, i.e. the local endpoint
         * @return  The remote port number
         * @see     PX_REMOTE_PORT_NUMBER
         * @verdict Unchanged
         */
        function f_getIutRemotePortNumber() return PortNumber {
            return PX_REMOTE_PORT_NUMBER;
        }
        
        /**
         * @desc    Get the remote identifier of the VCI for broadcast on ITS-S host
         * @return  The remote identifier of the VCI for broadcast on ITS-S host
         * @see     PX_DEST_REMOTE_CIID_BC
         * @verdict Unchanged
         * @see ISO 21218 - Clause 6.2 Link Identifier
         */
        function f_getIutRemoteDestCIID_BC() return EUI64 {
            return PX_DEST_REMOTE_CIID_BC;
        }
        
        /**
         * @desc    Get the IUT Link-ID in broadcast transmission mode
         * @return  The IUT Link-ID in broadcast transmission mode
         * @see     PX_LINK_ID_BC
         * @verdict Unchanged
         * @see ISO 21218 - Clause 6.2 Link Identifier
         */
        function f_getIutLinkId_BC() return Link_ID {
            return PX_LINK_ID_BC;
        }
        
        /**
         * @desc   TODO
         * @return TODO
         * @verdict Unchanged
         */
        function f_getIutLinkId_BC_WithSecondScuId() return Link_ID {
            return PX_LINK_ID_BC_WITH_SECOND_SCU_ID;
        }
        
//        /**
//         * @desc   TODO
//         * @return TODO
//         * @verdict Unchanged
//         */
//        function f_getIutLinkId_BC_WithThirdScuId() return Link_ID {
//            return PX_LINK_ID_BC_WITH_THIRD_SCU_ID;
//        }
//        
//        /**
//         * @desc   TODO
//         * @return TODO
//         * @verdict Unchanged
//         */
//        function f_getIutLinkId_BC_WithFourthScuId() return Link_ID {
//            return PX_LINK_ID_BC_WITH_FOURTH_SCU_ID;
//        }
//        
        /**
         * @desc    Get the IUT Link-ID in multicast transmission mode
         * @return  The IUT Link-ID in broadcast transmission mode
         * @see     PX_LINK_ID_BC
         * @verdict Unchanged
         */
        function f_getIutLinkId_MC() return Link_ID {
            return PX_LINK_ID_MC;
        }
        
        /**
         * @desc   TODO
         * @return TODO
         * @verdict Unchanged
         */
        function f_getIutLinkId_UNKWNON() return Link_ID {
            return PX_LINK_ID_UNKWNON;
        }
        
        /**
         * @desc   TODO
         * @return TODO
         * @verdict Unchanged
         */
        function f_getIutLinkId_UC() return Link_ID {
            return PX_LINK_ID_UC;
        }
        
//        /**
//         * @desc    Get the IUT station identifier
//         * @return  The IUT station identifier
//         * @see     PX_STATION_ID
//         * @verdict Unchanged
//         */
//        function f_getIutStationId() return StationID {
//            return PX_STATION_ID;
//        }
//        
        /**
         * @desc    Get an unknown IUT station identifier
         * @return  An unknown IUT station identifier
         * @see     PX_STATION_ID_UNKNOWN
         * @verdict Unchanged
         */
        function f_getIutStationId_UNKWNON() return StationID { // FIXME Rename into f_getIutPeerStationId
            return PX_STATION_ID_UNKNOWN;
        }
        
        /**
         * @desc    Get the ITS-SP payload EPDU
         * @return  The ITS-SP payload EPDU
         * @see     PX_ITS_SP_PAYLOAD_EPDU
         * @verdict Unchanged
         */
        function f_getIutItsSpPayloadEPDU() return ITSfpdu { 
            return PX_ITS_SP_PAYLOAD_EPDU;