LibItsFntp_Functions.ttcn3 45.9 KB
Newer Older
/**
 *  @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_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_utCommandRequestConfirm, f_utCommandRequestWithoutConfirm
    };
    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(PX_WAIT_FOR_IUT_READY); // 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_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 PortNumber p_port) runs on ItsNt {
            // Request allocation of a port number associated with the ITS-SP
            // TODO Consider case of c_portDyn, and use f_utCommandRequestConfirm
            f_utCommandRequestWithoutConfirm(
                m_generateNfFntpPortCreationRequest(
                    f_getIutServiceRef(), 
            // Store the allocated port number
            vc_portNumber := p_port;
            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 Call this method to remove entry created by f_initializeFntpForwardingTable() in FNTP Forwarding Table
         * @verdict Unchanged
         */
        function f_unInitializeFntpForwardingTable() runs on ItsNt {
            // check c_portDyn
            // Send for FTN-SOCKET.request & Wait for FTN-SOCKET.confirm
            f_utCommandRequestConfirm(
                m_generateNfFntpPortDeletionRequest(f_getIutServiceRef(), vc_portNumber),
                mw_fntpPortConfirm(f_getIutServiceRef(), ?),
                false,
                vc_utCommandConf);
        } // End of function f_unInitializeFntpForwardingTable
        
        /**
         * @desc Trigger a basic FNTPNPDU to create an entry in forwarding table for a known peer station 
         */
        function f_setupKnownPeerStation() runs on ItsNt { 
            f_acGenerateFntpNPDU( 
                f_getIutRemotePortNumberValue(), 
                vc_portNumber, 
                m_llServiceAddr(m_linkID(f_getIutSrcRemoteCIID_BC(), f_getIutSrcLocalCIID())), 
                m_llServiceAddr(m_linkID(f_getIutRemoteDestCIID_BC(), f_getIutDestLocalCIID())), 
                f_getIutSHopValue() 
            );
            // TODO Do we ignore management and NF-COMM.indication messages?
        } // End of function f_setupKnownPeerStation
        
    } // End of group preambles
    
    group postambles {
        
        /**
         * @desc The default postamble.
         */
        function f_poDefault() runs on ItsNt {
        }
        
    } // 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, 
            in template (value) LLserviceAddr p_insap_dest_address, 
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
            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 application port number, used instead of c_portDyn
         * @return The application port number, used instead of c_portDyn
         * @see PX_APP_PORT_NUMBER
         * @verdict Unchanged
         */
        function f_getIutAppPortValue() return PortNumber {
            return PX_APP_PORT_NUMBER;
        }
        
        /**
         * @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_getIutLocalPortNumberValue() return PortNumber {
            return PX_LOCAL_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_Router() 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_BC() return Link_ID {
            return PX_LINK_ID_UNKWNON_BC;
        }
        
        /**
         * @desc   TODO
         * @return TODO
         * @verdict Unchanged
         */
        function f_getIutLinkId_UNKWNON_UC() return Link_ID {
            return PX_LINK_ID_UNKWNON_UC;
        }
        
        /**
         * @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_FPDU
        function f_getIutItsFPDU() return ITSfpdu { 
            return PX_ITS_FPDU;
        }
        
        /**
         * @desc    Get the service reference defining a number uniquely identifying the endpoint at this host in an implementation specific way
         * @return  The service reference
         * @see     PX_SERVICE_REF
         * @verdict Unchanged
         */
        function f_getIutServiceRef() return integer {
            return PX_SERVICE_REF;
        }
        
        /**
         * @desc    Get the Single-hop value
         * @return  The Single-hop value
         * @verdict Unchanged
         */
        function f_getIutSHopValue() return FNTPhopCount {
            return PX_SHOP;
        }
        
        /**
         * @desc    Get the N-hops value
         * @return  The N-hops value
         * @verdict Unchanged
         */
        function f_getIutNHopsValue() return FNTPhopCount {
            return PX_NHOPS;
        }