LibSip_Templates.ttcn 196 KB
Newer Older
garciay's avatar
garciay committed
                                v_result := v_result + 1 + lengthof(v_auxstring);
                            }
                        }
                    }

                    if (isvalue(p_mb.connection)) {
                        v_len_con0 := f_SDPlength_connection(valueof(p_mb.connection));
garciay's avatar
garciay committed
                        v_result := v_result + v_len_con0;
                    } //*     "c="
                    if (isvalue(p_mb.bandwidth)) {
                        for (i := 0; i < lengthof(p_mb.bandwidth); i := i + 1) {
garciay's avatar
garciay committed
                            //*     "b= "
                            v_auxstring := p_mb.bandwidth[i].modifier & " ";
                            v_result := v_result + 2 + c_CRlen + lengthof(v_auxstring) + lengthof(int2str(p_mb.bandwidth[i].bandwidth));
                        }
                    }

                    for (i := 0; i < lengthof(p_mb.times); i := i + 1) {
garciay's avatar
garciay committed
                        v_auxstring := p_mb.times[i].time_field.start_time & " " & p_mb.times[i].time_field.stop_time;
                        v_result := v_result + 2 + c_CRlen + lengthof(v_auxstring); //*     "t="
                        if (isvalue(p_mb.times[i].time_repeat)) {
                            for (j := 0; j < lengthof(p_mb.times[i].time_repeat); j := j + 1) {
garciay's avatar
garciay committed
                                v_result := v_result + 2 + c_CRlen + lengthof(int2str(p_mb.times[i].time_repeat[j].repeat_interval.time)); //*     "r="
                                if (isvalue(p_mb.times[i].time_repeat[j].repeat_interval.unit)) {
                                    v_auxstring := valueof(p_mb.times[i].time_repeat[j].repeat_interval.unit);
garciay's avatar
garciay committed
                                    v_result := v_result + 1 + lengthof(v_auxstring);
                                }

                                v_result := v_result + 1 + lengthof(int2str(p_mb.times[i].time_repeat[j].active.time));
                                if (isvalue(p_mb.times[i].time_repeat[j].active.unit)) {
                                    v_auxstring := valueof(p_mb.times[i].time_repeat[j].active.unit);
garciay's avatar
garciay committed
                                    v_result := v_result + 1 + lengthof(v_auxstring);
                                }

                                for (k := 0; k < lengthof(p_mb.times[i].time_repeat[j].offsets); k := k + 1) {
garciay's avatar
garciay committed
                                    v_result := v_result + 1 + lengthof(int2str(p_mb.times[i].time_repeat[j].offsets[k].time));
                                    if (isvalue(p_mb.times[i].time_repeat[j].offsets[k].unit)) {
                                        v_auxstring := valueof(p_mb.times[i].time_repeat[j].offsets[k].unit);
garciay's avatar
garciay committed
                                        v_result := v_result + 1 + lengthof(v_auxstring);
                                    }
                                }
                            }
                        }
                    }

                    if (isvalue(p_mb.timezone_adjustments)) {
                        log("*** " & __SCOPE__ & ": INFO: timezone adjustments have not been considered in SDP length calculation yet ***");
garciay's avatar
garciay committed
                    } //*     "z="
                    if (isvalue(p_mb.key)) {
garciay's avatar
garciay committed
                        v_result := v_result + 2 + c_CRlen + lengthof(p_mb.key.method); //*     "k=
                                                                                        //*     "
                        if (isvalue(p_mb.key.key)) {
                            v_auxstring := valueof(p_mb.key.key);
garciay's avatar
garciay committed
                            v_result := v_result + 1 + lengthof(v_auxstring);
                        }
                    }
                    if (isvalue(p_mb.attributes)) {
                        for (i := 0; i < lengthof(p_mb.attributes); i := i + 1) {
tepelmann's avatar
tepelmann committed

garciay's avatar
garciay committed
                            //*     "a= "
                            v_len_con1 := f_SDPlength_attribute(p_mb.attributes[i]);
garciay's avatar
garciay committed
                            v_result := v_result + v_len_con1;
                        }
                    } //*     "a="
                    if (isvalue(p_mb.media_list)) {
                        for (i := 0; i < lengthof(p_mb.media_list); i := i + 1) {
garciay's avatar
garciay committed
                            //*     "m= "
                            //*     for each media_field
                            //*     log("p_mb.media_list[i ] ",p_mb.media_list[i
                            //*     ] );
tepelmann's avatar
tepelmann committed
                            v_result := v_result + 2 + c_CRlen + lengthof(p_mb.media_list[i].media_field.media) + 1 + lengthof(int2str(p_mb.media_list[i].media_field.ports.port_number));
                            if (isvalue(p_mb.media_list[i].media_field.ports.num_of_ports)) {
                                v_result := v_result + 1 + lengthof(int2str(valueof(p_mb.media_list[i].media_field.ports.num_of_ports)));
garciay's avatar
garciay committed
                            }
                            v_result := v_result + 1 + lengthof(p_mb.media_list[i].media_field.transport);
                            for (j := 0; j < lengthof(p_mb.media_list[i].media_field.fmts); j := j + 1) {
garciay's avatar
garciay committed
                                v_result := v_result + 1 + lengthof(p_mb.media_list[i].media_field.fmts[j]);
                            }

                            if (isvalue(p_mb.media_list[i].information)) {
                                v_auxstring := valueof(p_mb.media_list[i].information);
garciay's avatar
garciay committed
                                v_result := v_result + 2 + c_CRlen + lengthof(v_auxstring); //*     "i= "
                            }
                            if (isvalue(p_mb.media_list[i].connections)) {
                                for (j := 0; j < lengthof(p_mb.media_list[i].connections); j := j + 1) {
                                    v_len_con2 := f_SDPlength_connection(p_mb.media_list[i].connections[j]);
garciay's avatar
garciay committed
                                    v_result := v_result + v_len_con2;
tepelmann's avatar
tepelmann committed
                                } //*     end for
                            if (isvalue(p_mb.media_list[i].bandwidth)) {
garciay's avatar
garciay committed
                                //*     "b= "
                                for (j := 0; j < lengthof(p_mb.media_list[i].bandwidth); j := j + 1) {
tepelmann's avatar
tepelmann committed
                                    v_result := v_result + 2 + c_CRlen + lengthof(p_mb.media_list[i].bandwidth[j].modifier) + 1 + lengthof(int2str(p_mb.media_list[i].bandwidth[j].bandwidth));
                                } //*     end for
                            if (isvalue(p_mb.media_list[i].key)) {
garciay's avatar
garciay committed
                                //*     "k= "
                                v_result := v_result + 1 + lengthof(p_mb.media_list[i].key.method);
                                if (isvalue(p_mb.media_list[i].key.key)) {
                                    v_auxstring := valueof(p_mb.media_list[i].key.key);
garciay's avatar
garciay committed
                                    v_result := v_result + 1 + lengthof(v_auxstring);
                                }
                            }
                            if (isvalue(p_mb.media_list[i].attributes)) {
                                for (j := 0; j < lengthof(p_mb.media_list[i].attributes); j := j + 1) {
tepelmann's avatar
tepelmann committed

garciay's avatar
garciay committed
                                    //*     "a= "
                                    v_len_attr := f_SDPlength_attribute(p_mb.media_list[i].attributes[j]);
garciay's avatar
garciay committed
                                    v_result := v_result + v_len_attr;
tepelmann's avatar
tepelmann committed
                                } //*     end for j
tepelmann's avatar
tepelmann committed
                        } //*     end for i
                    } //*     end if media_list
garciay's avatar
garciay committed
                    return v_result;
                }
tepelmann's avatar
tepelmann committed
                //*     end function f_SDPlength
                function f_SDPlength_connection(
                    SDP_connection p_element
                ) return integer  {
                //*     "c="
garciay's avatar
garciay committed
                    var integer v_result := 0;
                    v_result := v_result + 2 + c_CRlen + lengthof(p_element.net_type & " " & p_element.addr_type & " " & p_element.conn_addr.addr);
                    if (isvalue(p_element.conn_addr.ttl) and p_element.conn_addr.ttl > 0) {
                        v_result := v_result + 1 + lengthof(int2str(valueof(p_element.conn_addr.ttl)));
                    if (isvalue(p_element.conn_addr.num_of_addr) and p_element.conn_addr.num_of_addr > 0) {
                        v_result := v_result + 1 + lengthof(int2str(valueof(p_element.conn_addr.num_of_addr)));
garciay's avatar
garciay committed
                    }
                    return v_result;
                } //*     f_SDPlength_connection

                function f_SDPlength_attribute(
                    SDP_attribute p_element
                ) return integer  {
                //*     "a="
garciay's avatar
garciay committed
                    var integer v_result := 0;
                    if (ischosen(p_element.cat)) {
                        v_result := v_result + 2 + c_CRlen + lengthof("cat:" & p_element.cat.attr_value);
                    }
                    if (ischosen(p_element.keywds)) {
                        v_result := v_result + 2 + c_CRlen + lengthof("keywds:" & p_element.keywds.attr_value);
                    }
                    if (ischosen(p_element.tool)) {
                        v_result := v_result + 2 + c_CRlen + lengthof("tool:" & p_element.tool.attr_value);
                    }
                    if (ischosen(p_element.ptime)) {
                        v_result := v_result + 2 + c_CRlen + lengthof("ptime:" & p_element.ptime.attr_value);
                    }
                    if (ischosen(p_element.recvonly)) {
                        v_result := v_result + c_CRlen + lengthof("recvonly");
                    }
                    if (ischosen(p_element.sendrecv)) {
                        v_result := v_result + c_CRlen + lengthof("sendrecv");
                    }
                    if (ischosen(p_element.sendonly)) {
                        v_result := v_result + c_CRlen + lengthof("sendonly");
                    }
                    if (ischosen(p_element.inactive)) {
                        v_result := v_result + c_CRlen + lengthof("inactive");
                    }
                    if (ischosen(p_element.orient)) {
                        v_result := v_result + 2 + c_CRlen + lengthof("orient:" & p_element.orient.attr_value);
                    }
                    if (ischosen(p_element.sdp_type)) {
                        v_result := v_result + 2 + c_CRlen + lengthof("type:" & p_element.sdp_type.attr_value);
                    }
                    if (ischosen(p_element.charset)) {
                        v_result := v_result + 2 + c_CRlen + lengthof("charset" & p_element.charset.attr_value);
                    }
                    if (ischosen(p_element.sdplang)) {
                        v_result := v_result + 2 + c_CRlen + lengthof("sdplang:" & p_element.sdplang.attr_value);
                    }
                    if (ischosen(p_element.lang)) {
                        v_result := v_result + 2 + c_CRlen + lengthof("lang:" & p_element.lang.attr_value);
                    }
                    if (ischosen(p_element.framerate)) {
                        v_result := v_result + 2 + c_CRlen + lengthof("framerate:" & p_element.framerate.attr_value);
                    }
                    if (ischosen(p_element.quality)) {
                        v_result := v_result + 2 + c_CRlen + lengthof("quality:" & p_element.quality.attr_value);
                    }
                    if (ischosen(p_element.fmtp)) {
                        v_result := v_result + 2 + c_CRlen + lengthof("fmtp:" & p_element.fmtp.format & " " & f_fmtpparams_to_charstring(p_element.fmtp.params));
garciay's avatar
garciay committed
                    }
                    if (ischosen(p_element.curr)) {
tepelmann's avatar
tepelmann committed
                        v_result := v_result + 2 + c_CRlen + lengthof("curr:" & p_element.curr.preconditionType & " " & p_element.curr.statusType & " " & p_element.curr.direction);
garciay's avatar
garciay committed
                    }
                    if (ischosen(p_element.des)) {
tepelmann's avatar
tepelmann committed
                        v_result := v_result + 2 + c_CRlen + lengthof("des:" & p_element.des.preconditionType & " " & p_element.des.strength & " " & p_element.des.statusType & " " & p_element.des.direction);
garciay's avatar
garciay committed
                    }
                    if (ischosen(p_element.conf)) {
tepelmann's avatar
tepelmann committed
                        v_result := v_result + 2 + c_CRlen + lengthof("conf:" & p_element.conf.preconditionType & " " & p_element.conf.statusType & " " & p_element.conf.direction);
garciay's avatar
garciay committed
                    }
                    if (ischosen(p_element.rtpmap)) {
                        v_result := v_result + 2 + c_CRlen + lengthof("rtpmap:" & f_rtpmap_to_charstring(p_element.rtpmap));
garciay's avatar
garciay committed
                    }
                    if (ischosen(p_element.rtcp)) {
                        v_result := v_result + 2 + c_CRlen + lengthof("rtcp:" & f_rtcp_to_charstring(p_element.rtcp));
garciay's avatar
garciay committed
                    }
                    if (ischosen(p_element.unknown)) {
                        v_result := v_result + 2 + c_CRlen + lengthof(p_element.unknown.name);
                        if (isvalue(p_element.unknown.attr_value)) {
garciay's avatar
garciay committed
                            v_result := v_result + lengthof(":" & p_element.unknown.attr_value);
                        }
                    }
                    //*     log("axr: length attribute=", v_result);
                    return v_result;
                } //*     f_SDPlength_attribute

                function f_fmtpparams_to_charstring(
                    SDP_attribute_fmtp_format_specific_params p_params
                ) return charstring  {
                    var charstring v_result := "";
                    if(ischosen(p_params.unstructured)){
                        v_result := p_params.unstructured;
                    }
                    else
                    {
                        for(var integer v_idx := 0; v_idx < lengthof(p_params.paramList); v_idx := v_idx + 1) {
                            if(v_idx != 0)
                            {
                                v_result := v_result & "; "
                            }
                            v_result := v_result & p_params.paramList[v_idx].id;
                            if(ispresent(p_params.paramList[v_idx].paramValue)){
                                if(ischosen(p_params.paramList[v_idx].paramValue.tokenOrHost))
                                {
                                    v_result := v_result & "=" & p_params.paramList[v_idx].paramValue.tokenOrHost;
                                }
                                else
                                {
                                    v_result := v_result & "=""" & p_params.paramList[v_idx].paramValue.quotedString & """";
                                }
                            }
                        }
                    }
                    return v_result;
                }

                function f_rtpmap_to_charstring(
                    SDP_attribute_rtpmap p_rtpmap
                ) return charstring  {
                    var charstring v_result := "";
                    v_result := p_rtpmap.payload_type & " " & p_rtpmap.codec.encoding & "/" & p_rtpmap.codec.clockrate;
                    if(ispresent(p_rtpmap.codec.parameters))
                    {
                        v_result := v_result & "/" & p_rtpmap.codec.parameters;
                    }
                    return v_result;
                }

                function f_rtcp_to_charstring(
                    SDP_attribute_rtcp p_rtcp
                ) return charstring  {
                    var charstring v_result := int2str(p_rtcp.portnumber);
                    if(ispresent(p_rtcp.connection))
                    {
                        v_result := v_result & " " & p_rtcp.connection.net_type & " " & p_rtcp.connection.addr_type & " " & p_rtcp.connection.conn_addr.addr;
                        if(ispresent(p_rtcp.connection.conn_addr.ttl))
                        {
                            v_result := v_result & "/" & int2str(p_rtcp.connection.conn_addr.ttl);
                            if(ispresent(p_rtcp.connection.conn_addr.num_of_addr))
                            {
                                v_result := v_result & "/" & int2str(p_rtcp.connection.conn_addr.num_of_addr);
                            }
                        }
                    }
                    return v_result;
                }
garciay's avatar
garciay committed

            } //*     group SDPlen_calculation

            group XML_Len_calculation {

                /**
tepelmann's avatar
tepelmann committed
                 * @desc Declaration of external functions to calculate length of message bodies switching of internal or external functions are made by boolean module parameter/PIXIT USE_FX_FOR_XML_LENGTH declared at top of this module
garciay's avatar
garciay committed
                 */
                external function fx_calculateXMLBodyLen(
                    XmlBody p_mb
                ) return integer;
garciay's avatar
garciay committed

                /**
                 * @desc Calculation of XML body length
                 * @param p_mb contain XML body
                 * @return xml_length
                 */
tepelmann's avatar
tepelmann committed
                function f_XMLBody_Length(
                    XmlBody p_mb,
                    boolean p_ext_func
                ) return integer  {
garciay's avatar
garciay committed
                    var integer v_result := 0;

                    if (p_ext_func) {
                        v_result := fx_calculateXMLBodyLen(p_mb);
tepelmann's avatar
tepelmann committed
                    }
                    else {
                        // assume ConferenceInfo ONLY in the XML message
                        // body
garciay's avatar
garciay committed
                        if (ischosen(p_mb.conference)) {
                            v_result := f_XMLBody_ConferenceInfo_Length(p_mb.conference);
                        }

tepelmann's avatar
tepelmann committed
                        // assume CUG ONLY in the XML message body
garciay's avatar
garciay committed
                        if (ischosen(p_mb.cug)) {
                            v_result := f_XMLBody_Cug_Length(p_mb.cug);
                        }

tepelmann's avatar
tepelmann committed
                        // assume MCID ONLY in the XML message body
garciay's avatar
garciay committed
                        if (ischosen(p_mb.mcid)) {
                            v_result := f_XMLBody_Mcid_Length(p_mb.mcid);
                        }

tepelmann's avatar
tepelmann committed
                        // assume CW ONLY in the XML message body
garciay's avatar
garciay committed
                        if (ischosen(p_mb.cw)) {
                            v_result := f_XMLBody_Cw_Length(p_mb.cw);
                        }

tepelmann's avatar
tepelmann committed
                        // assume CDIV ONLY in the XML message body
garciay's avatar
garciay committed
                        if (ischosen(p_mb.cdivn)) {
                            v_result := f_XMLBody_Cdivn_Length(p_mb.cdivn);
                        }

tepelmann's avatar
tepelmann committed
                        // assume PSTNTransit ONLY in the XML message body
garciay's avatar
garciay committed
                        if (ischosen(p_mb.pstnTransit)) {
                            v_result := f_XMLBody_PSTNTransit_Length(p_mb.pstnTransit);
                        }

tepelmann's avatar
tepelmann committed
                        // assume Simservs ONLY in the XML message body
garciay's avatar
garciay committed
                        if (ischosen(p_mb.simservs)) {
                            v_result := f_XMLBody_Simservs_Length(p_mb.simservs);
                        }

tepelmann's avatar
tepelmann committed
                        // assume ResourceLists ONLY in the XML message body
garciay's avatar
garciay committed
                        if (ischosen(p_mb.resourceLists)) {
                            v_result := f_XMLBody_ResourceList_Length(p_mb.resourceLists);
                        }

tepelmann's avatar
tepelmann committed
                        // assume Ims3GPP ONLY in the XML message body
garciay's avatar
garciay committed
                        if (ischosen(p_mb.ims3gpp)) {
                            v_result := f_XMLBody_Ims3GPP_Length(p_mb.ims3gpp);
                        }
                        /**
                         *     Add aditional checks regarding to new variants, also implement appropriate function for calculation
                         */
                    }
                    return v_result;
                } //*     f_XMLBodyLength

                group XMLBodies_calculation {

                    /**
                     * @desc Calculation of XML ConferenceInfo element length
                     * @param p_mb contain XML ConfInfo body
                     * @return xml_length
                     */
                    function f_XMLBody_ConferenceInfo_Length(
                        template(value) Conference_type p_mb
                    ) return integer  {
garciay's avatar
garciay committed
                        var integer v_result := lengthof(encvalue(p_mb)) / 8;
                        return v_result;
                    } //*     f_XMLBody_ConferenceInfo_Length

                    /**
                     * @desc Calculation of XML CUG element length
                     * @param p_mb contain XML CUG body
                     * @return xml_length
                     */
                    function f_XMLBody_Cug_Length(
                        template(value) Cug p_mb
                    ) return integer  {
garciay's avatar
garciay committed
                        var integer v_result := lengthof(encvalue(p_mb)) / 8;
                        return v_result;
                    } //*     f_XMLBody_Cug_Length

                    /**
                     * @desc Calculation of XML MCID element length
                     * @param p_mb contain XML MCID body
                     * @return xml_length
                     */
                    function f_XMLBody_Mcid_Length(
                        template(value) Mcid p_mb
                    ) return integer  {
garciay's avatar
garciay committed
                        var integer v_result := lengthof(encvalue(p_mb)) / 8;

                        return v_result;
                    } //*     f_XMLBody_Mcid_Length

                    /**
                     * @desc Calculation of XML CW element length
                     * @param p_mb contain XML CW body
                     * @return xml_length
                     */
                    function f_XMLBody_Cw_Length(
                        template(value) Ims_cw p_mb
                    ) return integer  {
garciay's avatar
garciay committed
                        var integer v_result := lengthof(encvalue(p_mb)) / 8;

                        return v_result;
                    } //*     f_XMLBody_Cw_Length

                    /**
                     * @desc Calculation of XML CDIVN element length
                     * @param p_mb contain XML CDIVN body
                     * @return xml_length
                     */
                    function f_XMLBody_Cdivn_Length(
                        template(value) Comm_div_info_type p_mb
                    ) return integer  {
garciay's avatar
garciay committed
                        var integer v_result := lengthof(encvalue(p_mb)) / 8;

                        return v_result;
                    } //*     f_XMLBody_Cdivn_Length

                    /**
                     * @desc Calculation of XML PSTNTransit element length
                     * @param p_mb contain XML PSTNTransit body
                     * @return xml_length
                     */
                    function f_XMLBody_PSTNTransit_Length(
                        template(value) PSTN_transit p_mb
                    ) return integer  {
garciay's avatar
garciay committed
                        var integer v_result := lengthof(encvalue(p_mb)) / 8;
                        return v_result;
                    } //*     f_XMLBody_PSTNTransit_Length

                    /**
                     * @desc Calculation of XML Simservs element length
                     * @param p_mb contain XML Simservs body
                     * @return xml_length
                     */
                    function f_XMLBody_Simservs_Length(
                        template(value) Simservs p_mb
                    ) return integer  {
garciay's avatar
garciay committed
                        var integer v_result := lengthof(encvalue(p_mb)) / 8;
                        return v_result;
                    } //*     f_XMLBody_Simservs_Length

                    /**
                     * @desc Calculation of XML ResourceList length
                     * @param p_mb contain XML ResourceList body
                     * @return xml_length
                     */
                    function f_XMLBody_ResourceList_Length(
                        template(value) Resource_lists p_mb
                    ) return integer  {
garciay's avatar
garciay committed
                        var integer v_result := lengthof(encvalue(p_mb)) / 8;
                        return v_result;
                    } //*     f_XMLBody_ResourceList_Length

                    /**
                     * @desc Calculation of XML Ims3GPP length
                     * @param p_mb contain XML Ims3GPP body
                     * @return xml_length
                     */
                    function f_XMLBody_Ims3GPP_Length(
                        template(value) TIMS3GPP p_mb
                    ) return integer  {
garciay's avatar
garciay committed
                        var integer v_result := lengthof(encvalue(p_mb)) / 8;
                        return v_result;
                    } //*     f_XMLBody_Ims3GPP_Length


                } //*     XMLBodies_calculation


            } //*     group XMLlen_calculation

            group simpleMsgSummaryBody_Length {

                function f_simpleMsgSummaryBody_Length(
                    SimpleMsgSummary p_mb
                ) return integer  {
                    var integer i;
garciay's avatar
garciay committed
                    var integer v_result := 2;

tepelmann's avatar
tepelmann committed

garciay's avatar
garciay committed
                    //*     due to empty line beginning of message body
                    var charstring v_auxstring;

                    v_result := 2 + lengthof(p_mb.msg_status_line.msg_type) + 2 + lengthof(p_mb.msg_status_line.msg_status) + c_CRlen; //*     "Message-Waiting:
                                                                                                                                       //*     yes"
                    if (isvalue(p_mb.msg_account))
garciay's avatar
garciay committed
                    //*     "Message-Account"
                    {
                        v_result := v_result + 2 + lengthof(p_mb.msg_account.msg_type_account) + 2 + lengthof(p_mb.msg_account.account_URI) + c_CRlen;
                    }
                    if (isvalue(p_mb.msg_summary_line_list)) {
                        for (i := 0; i < lengthof(p_mb.msg_summary_line_list); i := i + 1) {
tepelmann's avatar
tepelmann committed
                            v_result := v_result + 2 + c_CRlen + lengthof(p_mb.msg_summary_line_list[i].msg_context_class) + 2 + lengthof(p_mb.msg_summary_line_list[i].msgs);
                            if (isvalue(p_mb.msg_summary_line_list[i].urgent_msgs)) {
                                v_auxstring := valueof(p_mb.msg_summary_line_list[i].urgent_msgs);
garciay's avatar
garciay committed
                                v_result := v_result + 1 + lengthof(v_auxstring);
                            }
                        }
                    }
                    if (isvalue(p_mb.opt_msg_headers)) {
                        for (i := 0; i < lengthof(p_mb.opt_msg_headers); i := i + 1) {
garciay's avatar
garciay committed
                            v_result := v_result + 2 + c_CRlen + lengthof(p_mb.opt_msg_headers[i]);
                        }
                    }
                    return v_result;
                }
            }

            group MIME_Len_calculation {
                /**
                 * @desc Calculation of MIME length
                 * @param p_mb contain MIME message
                 * @return xml_length
                 */
                function f_MIMElength(
                    MIME_Message p_mb
                ) return integer  {
                    var integer i;
garciay's avatar
garciay committed
                    var integer v_result := 2;
tepelmann's avatar
tepelmann committed
                    // 0d0a
garciay's avatar
garciay committed
                    v_result := v_result + lengthof(p_mb.boundary) + 2 /*0d0a*/;

                    for (i := 0; i < lengthof(p_mb.mimeEncapsulatedList); i := i + 1) {
garciay's avatar
garciay committed

                        v_result := v_result + lengthof("Content-Type: ") + lengthof(p_mb.mimeEncapsulatedList[i].content_type) + 2 /*0d0a*/;

                        if (isvalue(p_mb.mimeEncapsulatedList[i].content_disposition)) {
garciay's avatar
garciay committed
                            v_result := v_result + lengthof("Content-Disposition: ") + lengthof(p_mb.mimeEncapsulatedList[i].content_disposition) + 2 /*0d0a*/;
                        }

tepelmann's avatar
tepelmann committed
                        // v_result := v_result +2/*0d0a*/; ??? to check
                        // assume SDP_Message ONLY in the message body
garciay's avatar
garciay committed
                        if (ischosen(p_mb.mimeEncapsulatedList[i].mime_encapsulated_part.sdpMessageBody)) {
                            v_result := v_result + f_SDPlength(p_mb.mimeEncapsulatedList[i].mime_encapsulated_part.sdpMessageBody);
                        }

tepelmann's avatar
tepelmann committed
                        // assume XML_Body ONLY in the message body
garciay's avatar
garciay committed
                        if (ischosen(p_mb.mimeEncapsulatedList[i].mime_encapsulated_part.xmlBody)) {
                            v_result := v_result + f_XMLBody_Length(p_mb.mimeEncapsulatedList[i].mime_encapsulated_part.xmlBody, PX_USE_FX_FOR_XML_LENGTH);
tepelmann's avatar
tepelmann committed
                    // //assume XML_Message ONLY in the message body
                    // if (ischosen(p_mb.mimeEncapsulatedList[i ]
                    // .mime_encapsulated_part.xmlMessage))
                    // {
                    // v_result := v_result +
                    // f_XMLlength(p_mb.mimeEncapsulatedList[i ]
                    // .mime_encapsulated_part.xmlMessage,
                    // USE_FX_FOR_XML_LENGTH );
                    // };
                    // v_result := v_result +2/*0d0a*/; ??? to check
                    }

                    // v_result := v_result +2/*0d0a*/; ??? to check
garciay's avatar
garciay committed
                    return v_result;
                } //*     f_MIMElength


            } //*     group MIMElen_calculation

            group TextPlain_Len_calculation {
                /**
                 * @desc Calculation of messagebody-textplain type length
                 * @param p_mb contain textplain message
                 * @return lenght
                 */
                function f_TextPlainLength(
                    template(value) MessageBody p_mb
                ) return integer  {
garciay's avatar
garciay committed
                    var integer v_result := 0;

                    v_result := v_result + lengthof(p_mb.textplain);

                    return v_result;
tepelmann's avatar
tepelmann committed
                } //*     end function f_TextPlainLength
tepelmann's avatar
tepelmann committed
            } //*     end group TextPlainLen_calculation

garciay's avatar
garciay committed
        } //*     group MessageBody_Calculation


        group GiveHeaders {
            /**
             * @desc Return component variable of recordRoute header if vc_boo_recordRoute is true
             * @return component variable of recordRoute header
             */
            function f_recordroute(
            ) runs on SipComponent 
            return template(omit) RecordRoute {
tepelmann's avatar
tepelmann committed
                var template(omit) RecordRoute v_recordRoute := omit;
garciay's avatar
garciay committed
                if (vc_boo_recordRoute) {
                    return vc_recordRoute;
tepelmann's avatar
tepelmann committed
                }
                else {
garciay's avatar
garciay committed
                    return (v_recordRoute);
nikolajev's avatar
nikolajev committed
                }
garciay's avatar
garciay committed
            }

            /**
             * @desc Return component variable of Route header if vc_boo_route is true
             * @return component variable of recordRoute header
             */
            function f_route(
            ) runs on SipComponent 
            return template(omit) Route  {
                var template(omit) Route v_route := omit;
garciay's avatar
garciay committed
                if (vc_boo_route) {
nikolajev's avatar
nikolajev committed
                    return vc_route;
                }
garciay's avatar
garciay committed
                else {
                    return (v_route);
nikolajev's avatar
nikolajev committed
                }
tepelmann's avatar
tepelmann committed
        } //*     end group GiveHeaders
garciay's avatar
garciay committed

        group others {

            /*
             *
             * @desc function combines two comma parameter lists
             * @param p_list1 first list
             * @param p_list2 second list
             * @return comma parameter list that contains parameters from both input lists
             * @verdict
             */
tepelmann's avatar
tepelmann committed
            function f_merge_CommaParam_List(
                template(value) CommaParam_List p_list1,
                template(value) CommaParam_List p_list2
            ) return template(value) CommaParam_List  {
garciay's avatar
garciay committed
                var template(value) CommaParam_List p_result;
                var integer i, v_limit1 := lengthof(p_list1);
                for (i := 0; i < v_limit1; i := i + 1) {
garciay's avatar
garciay committed
                    p_result[i] := p_list1[i];
                }
                for (i := 0; i < lengthof(p_list2); i := i + 1) {
                    p_result[i + v_limit1] := p_list2[i];
garciay's avatar
garciay committed
                }
                return p_result;
            }

tepelmann's avatar
tepelmann committed
        } //*     end group others

garciay's avatar
garciay committed
    } //*     group TemplatePreparationFunctions
tepelmann's avatar
tepelmann committed
} //*     end module LibSip_Templates