Skip to content
LibSip_Steps.ttcn 207 KiB
Newer Older
         * @param p_syncPoint dummy parameter (copied from the common lib)
         */
        function f_check2Null(
            in charstring p_syncPoint
        ) runs on SipComponent  {
            // != pass does not work, because in case of "none" execution shall continue
            if (getverdict == inconc or getverdict == fail) {
                log("*** f_check2Null: INFO: Verdict evaluated to fail or inconc. Stopping test execution now ***");
                f_selfOrClientSyncAndVerdict(p_syncPoint, e_error);
            } // end if
        }

        /*
 *
 * @desc original copied from older LibCommon_VerdictControl
 */
        function f_getVerdict(
        ) return FncRetCode  {
            var FncRetCode v_ret := e_error;
            if (getverdict == pass or getverdict == none) {
                v_ret := e_success;
            }
            return v_ret;
        }



    } // end group GlobalSteps

    group Registration {

        /**
         * @desc registration and authentication with MD5
         * @param p_cSeq_s cseq parameter
         * @param p_register register template
         * @param p_auth flag indicating if authentication is needed
         * @param p_emergency Set to true in case of emergency call
         */
        function f_Registration(
            inout CSeq p_cSeq_s,
            out template(value) REGISTER_Request p_register,
            in boolean p_auth,
            in boolean p_emergency := false
        ) runs on SipComponent  {
            if (PX_SIP_REGISTRATION) {
                f_setHeaders_REGISTER(p_cSeq_s, p_emergency);
                p_register := m_REGISTER_Request_Base(vc_requestUri, vc_callId, p_cSeq_s, vc_from, vc_to, vc_via_REG, vc_contact, vc_authorization);
                f_SendREGISTER(p_register); // LibSip
                // awaiting of 401 and sending 2nd REGISTER and awaiting 200 OK REGISTER
                if (p_auth) {
                    // receiving 401 Unauthorized response.
                    // and Re-send REGISTER request with Authorization header
                    tc_resp.start;
                    alt {
                        [] SIPP.receive(mw_Response_Base(c_statusLine401, vc_callId, p_cSeq_s)) -> value vc_response {
                            tc_resp.stop;
                            f_setHeadersOnReceiptOfResponse(vc_response);
                            // set headers via, cseq and authorization
                            f_setHeaders_2ndREGISTER(p_cSeq_s);
                            p_register := m_REGISTER_Request_Base(vc_requestUri, vc_callId, p_cSeq_s, vc_from, vc_to, vc_via_REG, vc_contact, vc_authorization);
                            // Re-send protected REGISTER
                            f_SendREGISTER(p_register); // LibSip
                            // awaiting 200 OK REGISTER
                            f_awaitingOkResponse(p_cSeq_s);
                            f_getServiceRouteMapIntoRouteInRegistration(vc_response);
                        }
                        [] SIPP.receive(mw_Response_Base(c_statusLine200, vc_callId, p_cSeq_s)) -> value vc_response {
                            tc_resp.stop;
                            f_setHeadersOnReceiptOfResponse(vc_response);
                            f_getServiceRouteMapIntoRouteInRegistration(vc_response);
                            log("*** " &__SCOPE__& ": INFO: Authorization was not requested as expected ***");
                        }
                    }
                }
                else {
                    f_awaitingOkResponse(p_cSeq_s);
                    f_getServiceRouteMapIntoRouteInRegistration(vc_response);
                }
            }
        } // end function f_Registration

        /**
         * @desc registration and authentication with MD5
         * @param p_cSeq_s cseq parameter
         * @param p_register register template
         * @param p_auth flag indicating if authentication is needed
         */
        function f_Registration_withTemplate(
            inout CSeq p_cSeq_s,
            inout template(value) REGISTER_Request p_register,
            in boolean p_auth
        ) runs on SipComponent  {
            if (PX_SIP_REGISTRATION) {
                if(not isbound(p_register)){
                    f_setHeaders_REGISTER(p_cSeq_s);
                    p_register := m_REGISTER_Request_Base(vc_requestUri, vc_callId, p_cSeq_s, vc_from, vc_to, vc_via_REG, vc_contact, vc_authorization);
                }
                f_SendREGISTER(p_register); // LibSip
                // awaiting of 401 and sending 2nd REGISTER and awaiting 200 OK REGISTER
                if (p_auth) {
                    // receiving 401 Unauthorized response.
                    // and Re-send REGISTER request with Authorization header
                    tc_resp.start;
                    alt {
                        [] SIPP.receive(mw_Response_Base(c_statusLine401, vc_callId, p_cSeq_s)) -> value vc_response {
                            tc_resp.stop;
                            f_setHeadersOnReceiptOfResponse(vc_response);
                            // set headers via, cseq and authorization
                            f_setHeaders_2ndREGISTER(p_cSeq_s);
                            // p_register := m_REGISTER_Request_Base(vc_requestUri, vc_callId, p_cSeq_s, vc_from, vc_to, vc_via_REG, vc_contact,
                            // vc_authorization);
                            // Re-send protected REGISTER
                            p_register.requestLine.requestUri := vc_requestUri;
                            p_register.msgHeader.cSeq := vc_cSeq;
                            p_register.msgHeader.via := vc_via_REG;
                            p_register.msgHeader.authorization := vc_authorization;
                            f_SendREGISTER(p_register); // LibSip
                            // awaiting 200 OK REGISTER
                            f_awaitingOkResponse(p_cSeq_s);
                            f_getServiceRouteMapIntoRouteInRegistration(vc_response);
                        }
                        [] SIPP.receive(mw_Response_Base(c_statusLine200, vc_callId, p_cSeq_s)) -> value vc_response {
                            tc_resp.stop;
                            f_setHeadersOnReceiptOfResponse(vc_response);
                            f_getServiceRouteMapIntoRouteInRegistration(vc_response);
                            log("*** " &__SCOPE__& ": INFO: Authorization was not requested as expected ***");
                        }
                    }
                }
                else {
                    f_awaitingOkResponse(p_cSeq_s);
                    f_getServiceRouteMapIntoRouteInRegistration(vc_response);
                }
            }
        } // end function f_Registration_withTemplate


        /**
         * @desc remove registration
         * @param p_cSeq_s cseq parameter
         */
        function f_RemoveRegistration(
            inout CSeq p_cSeq
        ) runs on SipComponent  {
            var template(value) REGISTER_Request v_request;
            var boolean v_receivedNotify := false;

            //
            if (vc_DeregDone) {
                f_componentStop();
            }
            else {
                vc_DeregDone := true;
            }

            if (PX_SIP_REGISTRATION) {
                f_setHeaders_deREGISTER(p_cSeq);
                v_request := m_REGISTER_Request_expires(vc_requestUri, vc_callIdReg, p_cSeq, vc_from, vc_to, vc_via_REG, vc_contact, vc_authorization, "0");

                f_SendREGISTER(v_request);
                if (PX_SIP_REGISTER_AUTHENTICATION_ENABLED) {
                    // receiving 401 Unauthorized response.
                    // and Re-send REGISTER request with Authorization header
                    tc_resp.start;
                    alt {
                        [] SIPP.receive(mw_Response_Base(c_statusLine401, vc_callIdReg, p_cSeq)) -> value vc_response {
                            tc_resp.stop;
                            f_setHeadersOnReceiptOfResponse(vc_response);
                            // set headers via, cseq and authorization
                            f_setHeaders_2ndREGISTER(p_cSeq);
                            v_request := m_REGISTER_Request_expires(vc_requestUri, vc_callIdReg, p_cSeq, vc_from, vc_to, vc_via_REG, vc_contact, vc_authorization, "0");
                            // v_request.msgHeader.route := f_route();
                            // Re-send protected REGISTER
                            f_SendREGISTER(v_request); // LibSip
                            // awaiting 200 OK REGISTER
                            f_awaitingResponse(mw_Response_Base(c_statusLine200, vc_callIdReg, p_cSeq));
                        }
                        [] SIPP.receive(mw_Response_Base(c_statusLine200, vc_callIdReg, p_cSeq)) -> value vc_response {
                            tc_resp.stop;
                            f_setHeadersOnReceiptOfResponse(vc_response);
                        // log ("Authorization was not requested as expected");
                        }
                        [] a_awaitNotify(mw_NOTIFY_Request_Base(vc_callIdSub), v_receivedNotify) {
                        }
                    }
                }
                else {
                    tc_resp.start;
                    alt {
                        [] a_awaitingResponse(mw_Response_Base(c_statusLine200, vc_callIdReg, p_cSeq)) {
                        }
                        [] a_awaitNotify(mw_NOTIFY_Request_Base(vc_callIdSub), v_receivedNotify) {
                        }
                    }
                }

                // await NOTIFY and send reply 200 OK
                if (vc_subscribed and v_receivedNotify == false) {
                    f_awaitingNOTIFY_sendReply_postamble(mw_NOTIFY_Request_Base(vc_callIdReg));
                }
            }
        } // end f_RemoveRegistration

        /**
         * @desc remove registration without authorization
         * @param p_cSeq_s cseq parameter
         */
        function f_RemoveRegistration_wo_authorization(
            inout CSeq p_cSeq
        ) runs on SipComponent  {
            if (PX_SIP_REGISTRATION) {
                f_setHeaders_deREGISTER(p_cSeq);
                f_SendREGISTER(m_REGISTER_Request_expires(vc_requestUri, vc_callIdReg, p_cSeq, vc_from, vc_to, vc_via, vc_contact, vc_authorization, "0"));
                f_awaitingResponse(mw_Response_Base(c_statusLine200, vc_callIdReg, p_cSeq));
            }
        } // end f_RemoveRegistration_wo_authorization



    } // end group Registration

    group Subscription {

        /**
         * @desc UE send subscrbe, await on 200 OK, await notify and send 200 OK
         * @param p_cSeq_s cseq parameter
         * @param p_subscribe subscribe template
         */
        function f_Subscription(
            inout CSeq p_cSeq_s,
            template(value) SUBSCRIBE_Request p_subscribe
        ) runs on SipComponent  {
            // send SUBSCRIBE
            f_SendSUBSCRIBE(p_subscribe);
            // awaiting 200 OK SUBSCRIBE
            // await NOTIFY and send reply 200 OK
            f_awaitingOkResponseAndNOTIFY_sendReply(p_cSeq_s, mw_NOTIFY_Request_Base(vc_callId));
        } // end function f_Subscription

        /**
         * @desc UE send subscrbe, await on 200 OK, await notify and send 200 OK
         * @param p_cSeq_s cseq parameter
         * @param p_subscribe subscribe template
         * @param p_notify notify template
         */
        function f_SubscriptionWithNotification(
            inout CSeq p_cSeq_s,
            template(value) SUBSCRIBE_Request p_subscribe,
            template(present) NOTIFY_Request p_notify := ?
        ) runs on SipComponent  {
            f_setHeaders_SUBSCRIBE(p_cSeq_s);
            // send SUBSCRIBE
            f_SendSUBSCRIBE(p_subscribe);
            // awaiting 200 OK SUBSCRIBE
            // await NOTIFY and send reply 200 OK
            f_awaitingOkResponseAndNOTIFY_sendReply(p_cSeq_s, p_notify);
        } // end function f_SubscriptionWithNotification

        /**
         * @desc UE await subscrbe, send on 200 OK; possibility to handle also other SUBSCRIBE methods where event is different than reg
         * @param p_cSeq_s cseq parameter
         * @param p_subscribe subscribe template
         */
        function f_awaitingSubscription(
            template(present) SUBSCRIBE_Request p_subscribe := ?
        ) runs on SipComponent  {
            var SUBSCRIBE_Request v_request;

            tc_wait.start(2.0); // awaiting of all SUBSCRIBES
            alt {
                [] SIPP.receive(p_subscribe) -> value v_request /*TODO Dynami error: sender vc_sent_label*/ {
                    f_setHeadersOnReceiptOfSUBSCRIBE(v_request);
                    f_send200OK();
                    repeat;
                }
                [] SIPP.receive(mw_SUBSCRIBE_Request_Base) -> value v_request /*TODO Dynami error: sender vc_sent_label*/ {
                    f_setHeadersOnReceiptOfSUBSCRIBE(v_request);
                    f_send200OK();
                    repeat;
                }
                [] tc_wait.timeout {
                    setverdict(pass);
                }
            }
        } // end function f_awaitingSubscription



    } // end group Subscription

    group Preambles {

        /**
         * @desc Set variables and default initialization for user profile
         * @param p_userprofile user profile of call
         * @param p_cSeq_s cseq parameter
         */
        function f_SIP_preamble_woREG(
            inout CSeq p_cSeq_s
        ) runs on SipComponent  {
            // varables and altsteps
            f_init_component(p_cSeq_s);

            // Preamble
            //NOTE STF471: removed f_init_userprofile(p_userprofile); // assignment of PIXIT values to component variable
            vc_sdp_local := valueof(m_SDP_bandwidth(m_media_dynPT(PX_SIP_SDP_DYN, PX_SIP_SDP_ENCODING, PX_SIP_SDP_CLOCKRATE, omit), vc_userprofile));
        }

        /**
         * @desc Set variables and default initialization for user profile and handle registration and authentication with MD5
         * @param p_userprofile user profile of call
         * @param p_cSeq_s cseq parameter
         * @param p_register register template
         */
        function f_SIP_preamble_withREG(
            inout CSeq p_cSeq_s,
            template(value) REGISTER_Request p_register
        ) runs on SipComponent  {
            // preamble
            f_SIP_preamble_woREG(p_cSeq_s);

            // Registration, Awaiting
            f_Registration(p_cSeq_s, p_register, PX_SIP_REGISTER_AUTHENTICATION_ENABLED);
        }



    } // end group Preambles

    group Postambles {

        /**
         * @desc function send BYE and awaits reponse
         * @param p_CallId parameter for outgoing BYE
         * @param p_cSeq parameter for outgoing BYE
         * @param p_from parameter for outgoing BYE
         * @param p_to parameter for outgoing BYE
         * @param p_reqHostPort parameter for outgoing BYE
         * @param p_byeCause parameter for Release cause to be used 
         *        in BYE and in Failure messages, former PX_SIP_BYE_CAUSE
         */
        function f_terminateCall(
            SipUrl p_requestUri,
            CallId p_CallId,
            inout CSeq p_cSeq,
            From p_from,
            template(value) To p_to,
            integer p_byeCause
        ) runs on SipComponent  {
            // Sending of a BYE request to release the call and expect a final response
            f_SendBYE(m_BYE_Request_cause(p_requestUri, p_CallId, p_cSeq, p_from, p_to, vc_via, p_byeCause));

            tc_resp.start;
            alt {
                [] SIPP.receive(mw_Response_Base(mw_statusLine1xx, p_CallId, p_cSeq)) {
                    repeat;
                }
                [] SIPP.receive(mw_Response_Base(mw_statusLineFinal, p_CallId, p_cSeq)) {
                    tc_resp.stop;
                }
            }
        } // end function f_terminateCall

        function f_cancelCall(
            template(value) CANCEL_Request p_request
        ) runs on SipComponent  {
            // This function is called to bring back the IUT in idle condition
            // in case of errors or unexpected behaviour.
            // Sending of a CANCEL request with the same Cseq
            f_setHeadersCANCEL(vc_cSeq);
            f_SendCANCEL(p_request);
            tc_resp.start;
            alt {
                [] SIPP.receive(mw_Response_Base(c_statusLine200, vc_callId, vc_cSeq)) {
                    tc_resp.stop;
                }
            }
        }

        function f_cancelCall_await487(
            template(value) CANCEL_Request p_request
        ) runs on SipComponent  {
            // This function is called to bring back the IUT in idle condition
            // in case of errors or unexpected behaviour.
            // Sending of a CANCEL request with the same Cseq
            f_cancelCall(p_request);
            // set method on INVITE
            vc_cSeq.method := "INVITE";

            // await on 487 response and send ACK
            f_awaitingResponse(mw_Response_Base(c_statusLine487, vc_callId, vc_cSeq));
            f_SendACK(m_ACK_Request_Base(vc_requestUri, vc_callId, vc_cSeq, vc_from, vc_to, vc_via));
        }

        function f_awaitCancelCall_send487(
            template(present) CANCEL_Request p_request := ?
        ) runs on SipComponent  {
            f_awaitingCANCEL(p_request);
            f_sendResponse(m_Response_Base(c_statusLine200, vc_callId, vc_cSeq, vc_caller_From, vc_caller_To, vc_via));

            // set method on INVITE
            vc_cSeq.method := "INVITE";

            // send 487 response and await ACK
            f_sendResponse(m_Response_Base(c_statusLine487, vc_callId, vc_cSeq, vc_caller_From, vc_caller_To, vc_via));
            // await ACK
            f_awaitingACK(mw_ACK_Request_Base(vc_callId));
        }

        altstep a_receiveCANCELorNothing(
            in template(present) CANCEL_Request p_CANCEL := ?
        ) runs on SipComponent {
            var CANCEL_Request v_MSG;
            [] SIPP.receive(p_CANCEL) -> value v_MSG /*TODO Dynami error: sender vc_sent_label*/ {
                f_setHeadersOnReceiptOfRequest(v_MSG);
                // Answer to the CANCEL
                f_send200OK();
            }
        }

        altstep a_awaitNotify(
            in template(present) NOTIFY_Request p_MSG := ?,
            inout boolean p_receivedNotify
        ) runs on SipComponent {
            var NOTIFY_Request v_MSG;
            [vc_subscribed] SIPP.receive(p_MSG) -> value v_MSG /*TODO Dynami error: sender vc_sent_label*/ {
4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841
                p_receivedNotify := true;
                f_getRouteMapIntoRecordRoute(v_MSG);
                f_setHeadersOnReceiptOfRequest(v_MSG);
                // Answer to the NOTIFY
                f_send200OK();
                repeat;
            }
        }



    } // end group Postambles

    group SipChecks {


        /**
         * @desc check the presence of conversation at SIP side
         * @param p_checkConversation boolean to perform check if conversation check is implemented.
         *             former PX_SIP_CHECK_CONVERSATION
         */
        function f_check_Conversation(
            boolean p_checkConversation := false
        ) runs on SipComponent  {
            var charstring v_question := "confirm if conversation at SIP port";

            if (p_checkConversation) {
                opPort
                .call(
                     s_SIP_conversation:
                     {
                         v_question,
                         -
                     }
                 ) {
                    [] opPort
                       .getreply(
                            s_SIP_conversation:
                            {
                                -,
                                true
                            }
                        ) {
                    }
                    [] opPort
                       .getreply(
                            s_SIP_conversation:
                            {
                                -,
                                false
                            }
                        ) {
                        all timer.stop;
                        setverdict(fail);
                        syncPort.send(m_syncClientStop);
                        stop;
                    }
                };
            }

            f_selfOrClientSyncAndVerdict(c_uPlane, f_getVerdict()); // Note: implemented in test bodies
            return;
        } // end of f_check_Conversation

        /**
         * @desc check the presence of conversation at SIP side
         * @param p_checkRinging boolean to perform check if ringing check is implemented.
         *             former PX_SIP_CHECK_RINGING
         */
        function f_check_Ringing(
            boolean p_checkRinging := false
        ) runs on SipComponent  {
            var charstring v_question := "confirm if ringing at SIP port";

            if (p_checkRinging) {
                opPort
                .call(
                     s_SIP_ringing:
                     {
                         v_question,
                         -
                     }
                 ) {
                    [] opPort
                       .getreply(
                            s_SIP_ringing:
                            {
                                -,
                                true
                            }
                        ) {
                    }
                    [] opPort
                       .getreply(
                            s_SIP_ringing:
                            {
                                -,
                                false
                            }
                        ) {
                        all timer.stop;
                        setverdict(fail);
                        syncPort.send(m_syncClientStop);
                        stop;
                    }
                };
            }

            f_selfOrClientSyncAndVerdict(c_Ringing, f_getVerdict());
            return;
        } // end of f_check_Ringing

        /**
         * @desc check the announcement at SIP side (UE A)
         * @param p_checkConversation boolean to perform check if conversation check is implemented.
         *             former PX_SIP_CHECK_CONVERSATION
         */
        function f_check_AnnouncementUE_A(
            boolean p_checkConversation := false
        ) runs on SipComponent  {
            var charstring v_question := "confirm if announcement at UE A";

            if (p_checkConversation) {
                opPort
                .call(
                     s_SIP_announcementA:
                     {
                         v_question,
                         -
                     }
                 ) {
                    [] opPort
                       .getreply(
                            s_SIP_announcementA:
                            {
                                -,
                                true
                            }
                        ) {
                    }
                    [] opPort
                       .getreply(
                            s_SIP_announcementA:
                            {
                                -,
                                false
                            }
                        ) {
                        all timer.stop;
                        setverdict(fail);
                        syncPort.send(m_syncClientStop);
                        stop;
                    }
                };
            }

            f_selfOrClientSyncAndVerdict(c_annoucA, f_getVerdict());
            return;
        } // end of f_check_AnnouncementUE_A

        /**
         * @desc check the announcement at SIP side (UE B)
         * @param p_checkConversation boolean to perform check if conversation check is implemented.
         *             former PX_SIP_CHECK_CONVERSATION
         */
        function f_check_AnnouncementUE_B(
            boolean p_checkConversation := false
        ) runs on SipComponent  {
            var charstring v_question := "confirm if announcement at UE B";

            if (p_checkConversation) {
                opPort
                .call(
                     s_SIP_announcementB:
                     {
                         v_question,
                         -
                     }
                 ) {
                    [] opPort
                       .getreply(
                            s_SIP_announcementB:
                            {
                                -,
                                true
                            }
                        ) {
                    }
                    [] opPort
                       .getreply(
                            s_SIP_announcementB:
                            {
                                -,
                                false
                            }
                        ) {
                        all timer.stop;
                        setverdict(fail);
                        syncPort.send(m_syncClientStop);
                        stop;
                    }
                };
            }

            f_selfOrClientSyncAndVerdict(c_annoucB, f_getVerdict());
            return;
        } // end of f_check_AnnouncementUE_B

        /**
         * @desc check the announcement at SIP side
         * @param p_checkConversation boolean to perform check if conversation check is implemented.
         *             former PX_SIP_CHECK_CONVERSATION
         */
        function f_check_Announcement(
            boolean p_checkConversation := false
        ) runs on SipComponent  {
            var charstring v_question := "confirm if announcement at SIP side";

            if (p_checkConversation) {
                opPort
                .call(
                     s_SIP_announcement:
                     {
                         v_question,
                         -
                     }
                 ) {
                    [] opPort
                       .getreply(
                            s_SIP_announcement:
                            {
                                -,
                                true
                            }
                        ) {
                    }
                    [] opPort
                       .getreply(
                            s_SIP_announcement:
                            {
                                -,
                                false
                            }
                        ) {
                        all timer.stop;
                        setverdict(fail);
                        syncPort.send(m_syncClientStop);
                        stop;
                    }
                };
            }

            f_selfOrClientSyncAndVerdict(c_annouc, f_getVerdict());
            return;
        } // end of f_check_Announcement

        /**
         * @desc check the Voice message at SIP side
         * @param p_checkConversation boolean to perform check if conversation check is implemented.
         *             former PX_SIP_CHECK_CONVERSATION
         */
        function f_check_VoiceMessage(
            boolean p_checkConversation := false
        ) runs on SipComponent  {
            var charstring v_question := "confirm if voice message at SIP side";

            if (p_checkConversation) {
                opPort
                .call(
                     s_SIP_voiceMessage:
                     {
                         v_question,
                         -
                     }
                 ) {
                    [] opPort
                       .getreply(
                            s_SIP_voiceMessage:
                            {
                                -,
                                true
                            }
                        ) {
                    }
                    [] opPort
                       .getreply(
                            s_SIP_voiceMessage:
                            {
                                -,
                                false
                            }
                        ) {
                        all timer.stop;
                        setverdict(fail);
                        syncPort.send(m_syncClientStop);
                        stop;
                    }
                };
            }

            f_selfOrClientSyncAndVerdict(c_voicem, f_getVerdict());
            return;
        } // end of f_check_Announcement

        /**
         * @desc check the stop of media stream
         * @param p_checkConversation boolean to perform check if conversation check is implemented.
         *             former PX_SIP_CHECK_CONVERSATION
         */
        function f_check_MediaStopped(
            boolean p_checkConversation := false
        ) runs on SipComponent  {
            var charstring v_question := "confirm if media stream stopped";

            if (p_checkConversation) {
                opPort
                .call(
                     s_SIP_mediastopped:
                     {
                         v_question,
                         -
                     }
                 ) {
                    [] opPort
                       .getreply(
                            s_SIP_mediastopped:
                            {
                                -,
                                true
                            }
                        ) {
                    }
                    [] opPort
                       .getreply(
                            s_SIP_mediastopped:
                            {
                                -,
                                false
                            }
                        ) {
                        all timer.stop;
                        setverdict(fail);
                        syncPort.send(m_syncClientStop);
                        stop;
                    }
                };
            }

            f_selfOrClientSyncAndVerdict(c_uPlaneStop, f_getVerdict());
            return;
        } // end of f_check_MediaStopped

    }

    group DefaultsTestStep {


        /**
         * @desc This default handles receiving of the sync server STOP message and calls the RT HUT postamble. (copy from common lib)
         */
        altstep a_Sip_catchSyncStop(
        ) runs on SipComponent {
            [] syncPort.receive(m_syncServerStop) {
                tc_sync.stop;
                log("*** a_Sip_catchSyncStop: INFO: Test component received STOP signal from MTC - going to IDLE state *** ");
                syncPort.send(m_syncClientStop);
                // in case if deregistration was not done
                // f_RemoveRegistration(vc_cSeq);
                f_terminate_component();
                log("*** a_Sip_catchSyncStop: INFO: TEST COMPONENT NOW STOPPING ITSELF! *** ");
                setverdict(inconc);
                stop;
            }
        }


        /**
         * @desc main default altstep to handle unexpected messages and timeout
         * @verdict fail for all unexpected branches
         */
        altstep a_clearRegistration(
        ) runs on SipComponent {
            var Response v_response;
            var Request v_request;
            var INFO_Request v_info_request;
            var NOTIFY_Request v_notify_request;
            var SUBSCRIBE_Request v_subscribe_request;
            var BYE_Request v_bye_request;
            var CANCEL_Request v_cancel_request;
            var REGISTER_Request v_register_request;
            var CSeq v_cSeq;
            [] any timer.timeout {
                setverdict(fail);
                all timer.stop;
                // f_SendCANCEL(m_CANCEL_Request(vc_callId, vc_cSeq, vc_from, vc_cancel_To, vc_reqHostPort, vc_via )); // difference between registration
                // state or transaction state
                vc_callId := vc_callIdReg;
                f_RemoveRegistration(vc_cSeq);
            }
            // allow repeated INVITEs
            [vc_ignore_invite] SIPP.receive(mw_INVITE_Request_Base) {
                repeat;
            }
            // allow repeated BYEs after ack of the first BYE
            [vc_ignore_bye] SIPP.receive(mw_BYE_Request_Base(?)) {
                repeat;
            }
            [] SIPP.receive(mw_ACK_Request_Base(?)) {
                repeat;
            }
            // allow 100 replies
            [] SIPP.receive(mw_Response_Base(c_statusLine100, ?, ?)) {
                repeat;
            }
            // ignore 181 if flag is set (following TS 183004 4.5.2.1)
            [vc_ignore181] SIPP.receive(mw_Response_Base(c_statusLine181, vc_callId, vc_cSeq)) -> value v_response /*TODO Dynami error: sender vc_sent_label*/ {
                v_cSeq := valueof(v_response.msgHeader.cSeq);
                f_setHeadersOnReceiptOfResponse(v_response); // CSeq is mandatory
                repeat;
            }
            // according to SIP chap.8.1.3.2
            [] SIPP.receive(mw_Response_Base(c_statusLine183, vc_callId, vc_cSeq)) {
                repeat;
            }
            // ignore 484 if flag is set
            [vc_ignore484] SIPP.receive(mw_Response_Base(c_statusLine484, vc_callId, vc_cSeq)) {
                repeat;
            }
            [vc_ignore4xx] SIPP.receive(mw_Response_Base(mw_statusLine4xx, vc_callId, ?)) -> value v_response /*TODO Dynami error: sender vc_sent_label*/ {
                v_cSeq := valueof(v_response.msgHeader.cSeq);
                f_setHeadersOnReceiptOfResponse(v_response); // CSeq is mandatory
                f_SendACK(m_ACK_Request_route(vc_requestUri, vc_callId, v_response.msgHeader.cSeq, vc_from, vc_to, vc_via, vc_route));
                repeat;
            }
            [vc_ignore200OKinv] SIPP.receive(mw_Response_Base(c_statusLine200, vc_callId, ?)) {
                repeat;
            }
            [] SIPP.receive(mw_INFO_Request_Base(vc_callId)) -> value v_info_request /*TODO Dynami error: sender vc_sent_label*/ {
                f_setHeadersOnReceiptOfRequest(v_info_request);
                f_send200OK();
                repeat;
            }
            // awaiting of Notify
            [] SIPP.receive(mw_NOTIFY_Request_Base(vc_callId)) -> value v_notify_request /*TODO Dynami error: sender vc_sent_label*/ {
                f_setHeadersOnReceiptOfRequest(v_notify_request);
                f_send200OK();
                repeat;
            }
            // awaiting of subscribe from UE
            [vc_ignore_subscribe] SIPP.receive(mw_SUBSCRIBE_Request_Base) -> value v_subscribe_request /*TODO Dynami error: sender vc_sent_label*/ {
                f_setHeadersOnReceiptOfSUBSCRIBE(v_subscribe_request);
                f_send200OK();
                repeat;
            }
            // awaiting of subscribe on proxy
            [] SIPP.receive(mw_SUBSCRIBE_Request_Base) -> value v_subscribe_request /*TODO Dynami error: sender vc_sent_label*/ {
                f_setHeadersOnReceiptOfRequest(v_subscribe_request);
                f_sendResponse(m_Response_Contact(c_statusLine200, vc_callId, vc_cSeq, vc_callee_From, vc_callee_To, vc_via, vc_contact));
                // f_setHeadersGeneral(vc_cSeq, "NOTIFY"); // cseq, contact, branch, via
                // f_SendNOTIFY(m_NOTIFY_Request_contact(vc_requestUri, vc_callId, vc_cSeq, vc_from, vc_to, vc_via, vc_contact));
                f_SendNOTIFY(m_NOTIFY_Request_contact(v_subscribe_request.msgHeader.contact.contactBody.contactAddresses[0].addressField.nameAddr.addrSpec, vc_callId, vc_cSeq, vc_callee_From, vc_callee_To, vc_via, vc_contact));
                f_awaitingOkResponse(vc_cSeq);
                repeat;
            }
            // unexpected BYE is acknowledged to avoid retransmissions
            [] SIPP.receive(mw_BYE_Request_Base(?)) -> value v_bye_request /*TODO Dynami error: sender vc_sent_label*/ {
                setverdict(fail);
                f_setHeadersOnReceiptOfRequest(v_bye_request);
                f_send200OK();
                f_RemoveRegistration(vc_cSeq);
            }
            // unexpected CANCEL is acknowledged to avoid retransmissions
            [] SIPP.receive(mw_CANCEL_Request_Base(?)) -> value v_cancel_request /*TODO Dynami error: sender vc_sent_label*/ {
                setverdict(fail);
                f_setHeadersOnReceiptOfRequest(v_cancel_request);
                // Answer to the CANCEL
                f_send200OK();
                f_RemoveRegistration(vc_cSeq);
            }
            // catch 4xx response
            [] SIPP.receive(mw_Response_Base(mw_statusLine4xx, vc_callId, ?)) -> value v_response /*TODO Dynami error: sender vc_sent_label*/ {
                setverdict(fail);
                if (v_response.msgHeader.cSeq.method == "INVITE") {
                    v_cSeq := valueof(v_response.msgHeader.cSeq);
                    f_setHeadersOnReceiptOfResponse(v_response); // CSeq is mandatory
                    LibSip_Steps.f_setHeadersACK();
                    f_SendACK(m_ACK_Request_route(vc_requestUri, vc_callId, v_response.msgHeader.cSeq, vc_from, vc_to, vc_via, vc_route));
                }
                f_RemoveRegistration(vc_cSeq);
            }
            // catch 5xx response
            [] SIPP.receive(mw_Response_Base(mw_statusLine5xx, vc_callId, ?)) -> value v_response /*TODO Dynami error: sender vc_sent_label*/ {
                setverdict(fail);
                if (v_response.msgHeader.cSeq.method == "INVITE") {
                    v_cSeq := valueof(v_response.msgHeader.cSeq);
                    f_setHeadersOnReceiptOfResponse(v_response); // CSeq is mandatory
                    LibSip_Steps.f_setHeadersACK();
                    f_SendACK(m_ACK_Request_route(vc_requestUri, vc_callId, v_response.msgHeader.cSeq, vc_from, vc_to, vc_via, vc_route));
                }
                f_RemoveRegistration(vc_cSeq);
            }
            // catch invalid REGISTER
            [] SIPP.receive(mw_REGISTER_Request_Base) -> value v_register_request /*TODO Dynami error: sender vc_sent_label*/ {
                setverdict(fail);
                f_componentStop();
            }
            // any
            [] SIPP.receive {
                setverdict(fail);
                all timer.stop;
                // f_setHeadersCANCEL(vc_cSeq);
                // f_SendCANCEL(m_CANCEL_Request_Base(vc_requestUri, vc_callId, vc_cSeq, vc_from, vc_cancel_To, vc_via )); // difference between
                // registration state or transaction state
                f_RemoveRegistration(vc_cSeq);
            }
        }

        /**
         * @desc altstep handle authentication for INVITE message
         */
        altstep a_altstep_401or407(
        ) runs on SipComponent {
            var CommaParam_List v_challenge;
            var Credentials v_Credentials;
            var Response v_Response;
            var Request v_Request := vc_requestFor407;
            [] any port.check(receive) {

                tc_resp.start;
                alt {
                    [] SIPP.receive(mw_Response_Base((c_statusLine401, c_statusLine407), vc_callId, vc_cSeq)) -> value v_Response {
                        tc_resp.stop;
                        // get tag from To header if available
                        vc_to := v_Response.msgHeader.toField;
                        if (vc_cSeq.method == "INVITE") {
                            // send ACK
                            f_SendACK(m_ACK_Request_Base(vc_requestUri, vc_callId, vc_cSeq, vc_from, vc_to, vc_via));
                        }
                        // resent the INVITE message with Proxyauthorization header include
                        // Extract challenge and calculate credentials for a response.
                        if (
                            ischosen(
                                v_Response.msgHeader.proxyAuthenticate.challenge
                                .otherChallenge // instead of digestCln (changed by axr to comply to alcatel)
                            )
                        ) {
                            v_challenge := v_Response.msgHeader.proxyAuthenticate.challenge.otherChallenge.authParams;
                            v_Credentials := f_calculatecCredentials(vc_userprofile, vc_requestFor407.msgHeader.cSeq.method, v_challenge);
                        }
                        else {
                            log("*** " &__SCOPE__& ": INFO: No scheme in Proxy Authenticate header!!! ***");
                            setverdict(inconc);
                            stop;
                        }

                        vc_branch := c_branchCookie & f_getRndTag();
                        vc_via := {
                            fieldName := VIA_E,
                            viaBody := {valueof(m_ViaBody_currIpaddr(vc_branch, vc_userprofile))}
                        };

                        v_Request.msgHeader.via := vc_via;
                        // Increment CSeq sequence number of and add the credentials
                        // to the original saved INVITE message.
                        vc_cSeq.method := vc_requestFor407.msgHeader.cSeq.method;
                        vc_cSeq.seqNumber := vc_cSeq.seqNumber + 1;
                        v_Request.msgHeader.cSeq.seqNumber := vc_cSeq.seqNumber;
                        v_Request.msgHeader.proxyAuthorization.fieldName := PROXY_AUTHORIZATION_E;
                        v_Request.msgHeader.proxyAuthorization.credentials := {v_Credentials};

                        // Re-send the saved INVITE with Authorization header
                        // included.
                        SIPP.send(v_Request) to vc_sent_label;
                    }