Rev

Rev 197 | Details | Compare with Previous | Last modification | View Log | SVN | Bug Tracker

Rev Author Line No. Line
162 rennoch 1
/**
187 tepelmann 2
 * @author STF 346, STF366, STF368, STF369, STF450, STF471
3
 * @version $Id: LibIms_Steps.ttcn 199 2014-07-07 11:55:30Z tepelmann $
4
 * @desc This module provides the types used by the test component for SIP-IMS tests. This module is part of LibImsV3.
2 rennoch 5
 */
187 tepelmann 6
module LibIms_Steps {
7
    // LibSip
8
    import from LibSip_SIPTypesAndValues all;
9
    import from LibSip_Templates all;
10
    import from LibSip_Steps all;
11
    import from LibSip_PIXITS all;
12
    import from LibSip_Interface all;
148 rennoch 13
    import from LibSip_MessageBodyTypes all;
187 tepelmann 14
    // LibIms
15
    import from LibIms_Templates all;
16
    import from LibIms_Interface all;
17
    import from LibIms_SIPTypesAndValues all;
157 pintar 18
 
187 tepelmann 19
    group externalfunctions {
20
    } // end group externalfunctions
21
    group parameterOperations {
22
 
157 pintar 23
        /**
190 tepelmann 24
         * @desc Adds new Via parameter
157 pintar 25
         * @param p_message (request) SIP message to be used to prepair via header
26
         */
187 tepelmann 27
        function f_addNewViaParameter(
194 tepelmann 28
            in Request p_message
187 tepelmann 29
        ) runs on ImsComponent  {
30
            var integer v_intVia;
31
            var integer i := 0;
32
            if (isvalue(p_message.msgHeader.via)) {
157 pintar 33
 
187 tepelmann 34
                v_intVia := lengthof(p_message.msgHeader.via.viaBody);
35
                while (i < v_intVia) {
36
                    p_message.msgHeader.via.viaBody[v_intVia] := p_message.msgHeader.via.viaBody[v_intVia - 1];
37
                    v_intVia := v_intVia - 1;
38
                }
39
                vc_branch := c_branchCookie & f_getRndTag();
40
                p_message.msgHeader.via.viaBody[0] := valueof(m_ViaBody_currIpaddr(vc_branch, vc_userprofile));
41
                vc_via := p_message.msgHeader.via;
157 pintar 42
            }
43
        }
187 tepelmann 44
 
157 pintar 45
        /**
190 tepelmann 46
         * @desc Removes own Via parameter
181 garciay 47
         * @param p_message (request) SIP message to be used to prepair via header
48
         */
187 tepelmann 49
        function f_removeOwnViaParameter(
50
            in Response p_message
51
        ) runs on ImsComponent  {
181 garciay 52
            var integer v_intVia;
53
            var Via v_via := c_empty_Via;
194 tepelmann 54
            var integer i := 0;
181 garciay 55
 
187 tepelmann 56
            if (ispresent(p_message.msgHeader.via)) {
57
 
193 nikolajev 58
                v_intVia := lengthof(p_message.msgHeader.via.viaBody) - 1;
187 tepelmann 59
 
194 tepelmann 60
                for (i := 0; i < v_intVia; i := i + 1) {
187 tepelmann 61
                    v_via.viaBody[i] := p_message.msgHeader.via.viaBody[i + 1];
181 garciay 62
                }
63
                vc_via := v_via;
64
            }
65
        }
157 pintar 66
 
187 tepelmann 67
        /**
190 tepelmann 68
         * @desc Adds new RecordRoute parameter and removes Route parameter
187 tepelmann 69
         * @param p_message (request) SIP message to be used to prepair via header
70
         */
71
        function f_addNewRecordRouteAndRemoveRoutParameter(
72
            in Request p_message
73
        ) runs on ImsComponent  {
74
            var integer v_intRoute, v_intRecordRoute;
75
            var integer i := 1;
76
            var RouteBody v_route1;
77
            var Route v_newRoute;
78
            v_newRoute.fieldName := ROUTE_E;
79
            if (isvalue(p_message.msgHeader.route)) {
80
                v_intRoute := lengthof(p_message.msgHeader.route.routeBody);
81
                v_route1 := p_message.msgHeader.route.routeBody[0];
82
                while (i < v_intRoute) {
83
                    v_newRoute.routeBody[i - 1] := p_message.msgHeader.route.routeBody[i];
84
                    i := i + 1;
85
                }
86
                vc_route := v_newRoute;
87
            }
158 pintar 88
 
187 tepelmann 89
            if (isvalue(p_message.msgHeader.recordRoute)) {
158 pintar 90
 
187 tepelmann 91
                v_intRecordRoute := lengthof(p_message.msgHeader.recordRoute.routeBody);
194 tepelmann 92
                while (0 < v_intRecordRoute) {
187 tepelmann 93
                    p_message.msgHeader.recordRoute.routeBody[v_intRecordRoute] := p_message.msgHeader.recordRoute.routeBody[v_intRecordRoute - 1];
94
                    v_intRecordRoute := v_intRecordRoute - 1;
95
                }
96
                p_message.msgHeader.recordRoute.routeBody[0] := v_route1;
97
                vc_recordRoute := valueof(p_message.msgHeader.recordRoute);
98
            }
99
        }
158 pintar 100
 
187 tepelmann 101
        /**
190 tepelmann 102
         * @desc Adds new RecordRoute parameter (IMS)
103
         * @param p_rr The recordRoute parameter to add
187 tepelmann 104
         */
105
        function f_addNewRecordRouteIMS(
106
            in RecordRoute p_rr
107
        ) runs on ImsComponent
108
        return template RecordRoute  {
109
            var integer v_intRecordRoute;
194 tepelmann 110
            var template RecordRoute v_recordRoute := omit;
2 rennoch 111
 
187 tepelmann 112
            v_intRecordRoute := lengthof(p_rr.routeBody);
113
            if (v_intRecordRoute > 0) {
194 tepelmann 114
                while (0 < v_intRecordRoute) {
187 tepelmann 115
                    p_rr.routeBody[v_intRecordRoute] := p_rr.routeBody[v_intRecordRoute - 1];
116
                    v_intRecordRoute := v_intRecordRoute - 1;
117
                }
118
                p_rr.routeBody[0] := valueof(m_routeBody_currIpAddr(vc_userprofile));
119
                vc_recordRoute := p_rr;
120
                return vc_recordRoute;
121
            }
122
            else {
123
                return (v_recordRoute);
124
            }
125
        }
74 pintar 126
 
187 tepelmann 127
    } // end group parameterOperations
128
 
129
    group fieldOperations {
130
 
131
        /**
190 tepelmann 132
         * @desc Sets BYE header fields (IMS addresses) extension of general settings from LibSip basic function
133
         * @param p_cSeq_s The current cSeq
192 tepelmann 134
         * @param p_to_user The selected user's SIP URL
187 tepelmann 135
         */
136
        function f_setHeadersBYE(
137
            inout CSeq p_cSeq_s,
192 tepelmann 138
            in SipUrl p_to_user
187 tepelmann 139
        ) runs on ImsComponent  {
192 tepelmann 140
            vc_requestUri := p_to_user; // Request URI of Invite is identical with To header
187 tepelmann 141
            vc_route := f_route(); // update the route header field depending on vc_boo_route
142
            vc_recordRoute := f_recordroute(); // update the route header field depending on vc_boo_route
143
            LibSip_Steps.f_setHeadersBYE(p_cSeq_s);
144
        } // end f_setHeadersBYE
145
 
146
        /**
190 tepelmann 147
         * @desc Sets CANCEL header fields (IMS addresses) extension of general settings from LibSip basic function
148
         * @param p_cSeq_s The current cSeq
187 tepelmann 149
         */
150
        function f_setHeadersCANCEL(
192 tepelmann 151
            inout CSeq p_cSeq_s
187 tepelmann 152
        ) runs on ImsComponent  {
153
            vc_route := f_route(); // update the route header field depending on vc_boo_route
154
            vc_recordRoute := f_recordroute(); // update the route header field depending on vc_boo_route
155
            LibSip_Steps.f_setHeadersCANCEL(p_cSeq_s);
156
        } // end f_setHeadersCANCEL
157
 
158
        /**
190 tepelmann 159
         * @desc Sets headers for forward request from AS in case if AS acts as Proxy
160
         * @param p_cSeq_s The current cSeq
187 tepelmann 161
         * @param p_proxyMode true = proxyMode, false = B2BMode
162
         */
163
        function f_setHeadersForwardRequestFromAS(
164
            inout CSeq p_cSeq_s,
165
            boolean p_proxyMode
166
        ) runs on ImsComponent  {
167
            var Request v_request;
168
            v_request := vc_request;
169
 
170
            if (p_proxyMode) {
157 pintar 171
                vc_requestUri2 := v_request.requestLine.requestUri;
172
                vc_to := v_request.msgHeader.toField;
173
                vc_contact := v_request.msgHeader.contact;
194 tepelmann 174
                f_addNewViaParameter(v_request);
157 pintar 175
                f_addNewRecordRouteAndRemoveRoutParameter(v_request);
187 tepelmann 176
            }
177
            else {
178
                // B2Bmode
179
                vc_contact := m_Contact(m_SipUrl_contactIpaddr(vc_userprofile));
180
                vc_callId := {
181
                    fieldName := CALL_ID_E,
197 nikolajev 182
                    callid := f_getRndCallId() & c_AT & vc_userprofile.currIpaddr
187 tepelmann 183
                };
184
            }
185
        } // end function f_setHeadersForwardRequest
186
 
187
        /**
190 tepelmann 188
         * @desc Sets header fields for forward request from AS in case if AS acts as Proxy
187 tepelmann 189
         */
190
        function f_setHeadersForwardResponseFromAS(
191
        ) runs on ImsComponent  {
192
            var Response v_response;
193
            v_response := vc_response;
194
 
195
            vc_caller_To := v_response.msgHeader.toField;
181 garciay 196
            vc_to := v_response.msgHeader.toField;
197
            vc_contact := v_response.msgHeader.contact;
187 tepelmann 198
 
199
            if (ispresent(v_response.msgHeader.recordRoute)) {
200
                vc_recordRoute := v_response.msgHeader.recordRoute;
201
            }
181 garciay 202
            f_removeOwnViaParameter(v_response);
187 tepelmann 203
        } // end function f_setHeadersForwardResponse
2 rennoch 204
 
187 tepelmann 205
        /**
190 tepelmann 206
         * @desc Sets Invite header fields (IMS addresses) extension of general settings from LibSip basic function
207
         * @param p_cSeq_s The current cSeq
192 tepelmann 208
         * @param p_to_user The selected user's SIP URL
187 tepelmann 209
         */
210
        function f_setHeadersINVITE(
211
            inout CSeq p_cSeq_s,
192 tepelmann 212
            in SipUrl p_to_user
187 tepelmann 213
        ) runs on ImsComponent  {
214
            vc_to := f_initToHeader(p_to_user); // init of vc_to using userProfile identifier
192 tepelmann 215
            vc_from := f_initFromHeader(p_to_user, f_getRndTag()); // init of vc_from using userProfile identifier
216
            vc_requestUri := p_to_user; // Request URI of Invite is identical with To header
187 tepelmann 217
            if (vc_boo_route) {
218
                vc_route := m_route_interface(vc_interfaceprofile);
219
            }
220
            if (vc_boo_recordRoute) {
221
                vc_recordRoute := m_recordRoute_currIpAddr(vc_userprofile);
222
            }
72 poglitsch 223
 
187 tepelmann 224
            LibSip_Steps.f_setHeadersINVITE(p_cSeq_s);
225
        } // end f_setHeadersINVITE
72 poglitsch 226
 
187 tepelmann 227
        /**
190 tepelmann 228
         * @desc Sets Invite header fields (IMS addresses) extension of general settings from LibSip basic function
229
         * @param p_cSeq_s The current cSeq
192 tepelmann 230
         * @param p_to_user The selected user's SIP URL
187 tepelmann 231
         */
232
        function f_setHeadersUPDATE(
233
            inout CSeq p_cSeq_s,
192 tepelmann 234
            in SipUrl p_to_user
187 tepelmann 235
        ) runs on ImsComponent  {
236
            vc_to := f_initToHeader(p_to_user); // init of vc_to using userProfile identifier
192 tepelmann 237
            vc_from := f_initFromHeader(p_to_user, f_getRndTag()); // init of vc_from using userProfile identifier
238
            vc_requestUri := p_to_user; // Request URI of Invite is identical with To header
187 tepelmann 239
            if (vc_boo_route) {
240
                vc_route := m_route_interface(vc_interfaceprofile);
241
            }
242
            if (vc_boo_recordRoute) {
243
                vc_recordRoute := m_recordRoute_currIpAddr(vc_userprofile);
244
            }
2 rennoch 245
 
187 tepelmann 246
            LibSip_Steps.f_setHeadersUPDATE(p_cSeq_s);
247
        } // end f_setHeadersUPDATE
46 rennoch 248
 
187 tepelmann 249
        /**
190 tepelmann 250
         * @desc Sets Message header fields (IMS addresses) extension of general settings from LibSip basic function
251
         * @param p_cSeq_s The current cSeq
192 tepelmann 252
         * @param p_to_user The selected user's SIP URL
187 tepelmann 253
         */
254
        function f_setHeadersMESSAGE(
255
            inout CSeq p_cSeq_s,
192 tepelmann 256
            in SipUrl p_to_user
187 tepelmann 257
        ) runs on ImsComponent  {
258
            vc_to := f_initToHeader(p_to_user); // init of vc_to using userProfile identifier
192 tepelmann 259
            vc_from := f_initFromHeader(p_to_user, f_getRndTag()); // init of vc_from using userProfile identifier
260
            vc_requestUri := p_to_user; // Request URI of Invite is identical with To header
187 tepelmann 261
            LibSip_Steps.f_setHeadersMESSAGE(p_cSeq_s);
262
        } // end f_setHeadersMESSAGE
46 rennoch 263
 
187 tepelmann 264
        /**
190 tepelmann 265
         * @desc Sets Notify header fields (IMS addresses) extension of general settings from LibSip basic function
266
         * @param p_cSeq_s The current cSeq
192 tepelmann 267
         * @param p_to_user The selected user's SIP URL
187 tepelmann 268
         */
269
        function f_setHeadersNOTIFY(
270
            inout CSeq p_cSeq_s,
192 tepelmann 271
            in SipUrl p_to_user
187 tepelmann 272
        ) runs on ImsComponent  {
273
            LibSip_Steps.f_setHeadersNOTIFY(p_cSeq_s);
78 pintar 274
 
187 tepelmann 275
            vc_branch := c_branchCookie & f_getRndTag();
276
            vc_via := {
277
                fieldName := VIA_E,
278
                viaBody := {valueof(m_ViaBody_virtual_XCSCF(vc_branch, vc_userprofile))}
279
            };
78 pintar 280
 
187 tepelmann 281
            vc_to := f_initToHeader(p_to_user); // init of vc_to using userProfile identifier
192 tepelmann 282
            vc_from := f_initFromHeader(p_to_user, f_getRndTag()); // init of vc_from using userProfile identifier
283
            vc_requestUri := p_to_user; // Request URI of Invite is identical with To header
187 tepelmann 284
            // contact header initialization for sending of NOTIFY from CSCF component
285
            vc_contact := m_Contact(m_SipUrl_currIpaddr_CSCF(vc_userprofile));
286
        } // end f_setHeadersNOTIFY
78 pintar 287
 
187 tepelmann 288
        /**
190 tepelmann 289
         * @desc Sets Publish header fields (IMS addresses) extension of general settings from LibSip basic function
290
         * @param p_cSeq_s The current cSeq
192 tepelmann 291
         * @param p_to_user The selected user's SIP URL
187 tepelmann 292
         */
293
        function f_setHeadersPUBLISH(
294
            inout CSeq p_cSeq_s,
192 tepelmann 295
            in SipUrl p_to_user
187 tepelmann 296
        ) runs on ImsComponent  {
297
            LibSip_Steps.f_setHeadersPUBLISH(p_cSeq_s);
157 pintar 298
 
187 tepelmann 299
            vc_branch := c_branchCookie & f_getRndTag();
300
            vc_via := {
301
                fieldName := VIA_E,
302
                viaBody := {valueof(m_ViaBody_virtual_XCSCF(vc_branch, vc_userprofile))}
303
            };
304
 
305
            vc_to := f_initToHeader(p_to_user); // init of vc_to using userProfile identifier
192 tepelmann 306
            vc_from := f_initFromHeader(p_to_user, f_getRndTag()); // init of vc_from using userProfile identifier
307
            vc_requestUri := p_to_user; // Request URI of Invite is identical with To header
187 tepelmann 308
            if (vc_boo_route) {
309
                vc_route := m_route_interface(vc_interfaceprofile);
310
            }
311
            if (vc_boo_recordRoute) {
312
                vc_recordRoute := m_recordRoute_currIpAddr(vc_userprofile);
313
            }
314
 
315
            // contact header initialization for sending of PUBLISH from CSCF component
316
            vc_contact := m_Contact(m_SipUrl_currIpaddr_CSCF(vc_userprofile));
317
        } // end f_setHeadersPUBLISH
318
 
319
        /**
190 tepelmann 320
         * @desc Sets Subscribe header fields (IMS addresses) extension of general settings from LibSip basic function
321
         * @param p_cSeq_s The current cSeq
192 tepelmann 322
         * @param p_to_user The selected user's SIP URL
187 tepelmann 323
         */
324
        function f_setHeadersSUBSCRIBE(
325
            inout CSeq p_cSeq_s,
326
            in SipUrl p_to_user
327
        ) runs on ImsComponent  {
328
            vc_to := {
329
                fieldName := TO_E,
330
                addressField := {
331
                    nameAddr := {
332
                        displayName := omit,  // optional charstring
333
                        addrSpec := p_to_user // SipUrl
334
                    }
335
                },  // end addressField
336
                toParams := omit
337
            };
192 tepelmann 338
            vc_from := f_initFromHeader(p_to_user, f_getRndTag()); // init of vc_from using userProfile identifier
187 tepelmann 339
            vc_requestUri := p_to_user; // Request URI of Invite is identical with To header
340
            LibSip_Steps.f_setHeadersSUBSCRIBE(p_cSeq_s);
341
        } // end f_setHeadersSUBSCRIBE
342
 
343
        /**
190 tepelmann 344
         * @desc Sets headers for ReINVITE method
345
         * @param p_cSeq_s The current cSeq
187 tepelmann 346
         * @param p_orginatingSide true in case of Re-INVITE is send from the orgination endpoint otherwise false.
192 tepelmann 347
         * @param p_to_user The selected user's SIP URL
187 tepelmann 348
         */
349
        function f_setHeadersReINVITE(
350
            inout CSeq p_cSeq_s,
351
            in boolean p_orginatingSide,
192 tepelmann 352
            in SipUrl p_to_user
187 tepelmann 353
        ) runs on ImsComponent  {
194 tepelmann 354
            var integer v_tmp, i, j, v_nbroute;
187 tepelmann 355
            var Request v_request;
356
            v_request := vc_request;
357
 
358
            f_setHeadersGeneral(p_cSeq_s, "INVITE"); // cseq, contact, branch, via
359
            vc_reqHostPort := vc_requestUri.components.sip.hostPort;
360
 
192 tepelmann 361
            vc_requestUri := p_to_user;
187 tepelmann 362
 
363
            if (p_orginatingSide) {
364
                vc_to := vc_caller_To;
365
                vc_from := vc_caller_From;
366
            }
367
            else {
368
                vc_to := vc_callee_To;
369
                vc_from := vc_callee_From;
370
 
371
                // get route from previous ACK request
372
                // Route Management
373
                if (isvalue(v_request.msgHeader.recordRoute)) {
374
                    vc_recordRoute := valueof(v_request.msgHeader.recordRoute);
375
                    v_nbroute := lengthof(vc_recordRoute.routeBody);
376
                    // copy and reverse the order of the routes in route header
194 tepelmann 377
                    for (i := 0; i <= (v_nbroute - 1); i := i + 1) {
378
                        j := v_nbroute - 1 - i;
379
                        vc_route.routeBody[j] := vc_recordRoute.routeBody[i];
187 tepelmann 380
                    }
381
                    vc_route.fieldName := ROUTE_E;
382
                    vc_boo_recordRoute := true;
383
                    vc_boo_route := true;
158 pintar 384
                }
187 tepelmann 385
                else {
386
                    vc_boo_recordRoute := false;
387
                    vc_boo_route := false;
388
                }
389
            }
2 rennoch 390
 
187 tepelmann 391
            v_tmp := str2int(vc_sdp_local.origin.session_id);
392
            vc_sdp_local.origin.session_id := int2str(v_tmp + 1);
393
            v_tmp := str2int(vc_sdp_local.origin.session_version);
394
            vc_sdp_local.origin.session_version := int2str(v_tmp + 1);
395
        } // end function f_setHeadersReINVITE
2 rennoch 396
 
187 tepelmann 397
        /**
190 tepelmann 398
         * @desc Sets component variables related to message header fields when sending requests from the home I-CSCF (TS) to the visited P-CSCF (SUT) (message type independent: CSeq, contact, via), function uses information from userprofile and interfaceprofile
399
         * @param p_cSeq_s The CSeq parameter
400
         * @param p_method The method name for cSeq header field
187 tepelmann 401
         */
402
        function f_setHeadersGeneral_ICSCF(
403
            inout CSeq p_cSeq_s,
404
            in charstring p_method
405
        ) runs on SipComponent  {
406
            p_cSeq_s.fieldName := CSEQ_E;
407
            p_cSeq_s.seqNumber := p_cSeq_s.seqNumber + 1;
408
            p_cSeq_s.method := p_method;
409
            vc_cSeq := p_cSeq_s;
2 rennoch 410
 
187 tepelmann 411
            vc_contact := m_Contact(m_SipUrl_contactIpaddr(vc_userprofile));
2 rennoch 412
 
187 tepelmann 413
            vc_branch := c_branchCookie & f_getRndTag();
414
            vc_branch_ICSCF := c_branchCookie & f_getRndTag();
2 rennoch 415
 
187 tepelmann 416
            vc_via := {
417
                fieldName := VIA_E,
418
                viaBody := {
194 tepelmann 419
                    valueof(m_ViaBody_currIpaddr(vc_branch, vc_userprofile)),
420
                    valueof(m_ViaBody_virtualUEinPCSCF(vc_branch_ICSCF, vc_userprofile))
187 tepelmann 421
                }
422
            };
423
        } // end function f_setHeadersGeneral_ICSCF
18 poglitsch 424
 
187 tepelmann 425
        /**
190 tepelmann 426
         * @desc Sets header field for the next outgoing REGISTER message from the visited P-CSCF to the home I-CSCF
427
         * @param p_cSeq_s The CSeq parameter to be applied
187 tepelmann 428
         */
429
        function f_setHeaders_REGISTER_PCSCF(
430
            inout CSeq p_cSeq_s
431
        ) runs on SipComponent  {
432
            var SemicolonParam_List v_params;
34 poglitsch 433
 
187 tepelmann 434
            f_setHeadersGeneral(p_cSeq_s, "REGISTER"); // cseq, contact, branch, via
435
            vc_requestUri := {
436
                scheme := c_sipScheme,
437
                components := {
438
                    sip := {
439
                        userInfo := omit,
440
                        hostPort := {
441
                            host := vc_userprofile.registrarDomain,
442
                            portField := omit
443
                        }
444
                    }
445
                },
446
                urlParameters := omit,
447
                headers := omit
448
            };
92 schmitting 449
 
187 tepelmann 450
            vc_reqHostPort := vc_requestUri.components.sip.hostPort;
55 deshpande 451
 
187 tepelmann 452
            vc_callId := {
453
                fieldName := CALL_ID_E,
197 nikolajev 454
                callid := f_getRndCallId() & c_AT & vc_userprofile.currIpaddr
187 tepelmann 455
            };
456
            vc_callIdReg := vc_callId;
55 deshpande 457
 
187 tepelmann 458
            vc_to := valueof(m_To(m_SipUrl_currDomain(vc_userprofile)));
459
            v_params := {
460
                {
461
                    id := c_tagId,
462
                    paramValue := f_getRndTag()
463
                }
464
            };
465
            vc_from := {
466
                fieldName := FROM_E,
467
                addressField := vc_to.addressField,
468
                fromParams := v_params
469
            };
2 rennoch 470
 
187 tepelmann 471
            if (not vc_firstREGISTER_sent) {
472
                v_params := {
473
                    {
474
                        id := c_expiresId,
475
                        paramValue := c_shortRegistration
476
                    }
477
                };
478
                vc_contact.contactBody.contactAddresses[0].contactParams := v_params;
479
            }
2 rennoch 480
 
187 tepelmann 481
            vc_firstREGISTER_sent := true; // f_setHeaders_Register is called in deREGISTER function
482
            vc_authorization := {
483
                fieldName := AUTHORIZATION_E,
484
                body := {f_calculatecCredentials_empty(vc_userprofile)}
485
            };
486
        } // end function setHeaders_REGISTER_PCSCF
2 rennoch 487
 
187 tepelmann 488
        /**
190 tepelmann 489
         * @desc Sets REFER header fields (IMS addresses) extension of general settings from LibSip basic function
490
         * @param p_cSeq_s The current cSeq
192 tepelmann 491
         * @param p_to_user The selected user's SIP URL
187 tepelmann 492
         */
493
        function f_setHeadersREFER(
494
            inout CSeq p_cSeq_s,
192 tepelmann 495
            in SipUrl p_to_user
187 tepelmann 496
        ) runs on ImsComponent  {
192 tepelmann 497
            vc_requestUri := p_to_user; // Request URI of Invite is identical with To header
187 tepelmann 498
            if (vc_boo_route) {
499
                vc_route := m_route_interface(vc_interfaceprofile);
500
            }
501
            if (vc_boo_recordRoute) {
502
                vc_recordRoute := m_recordRoute_currIpAddr(vc_userprofile);
503
            }
2 rennoch 504
 
187 tepelmann 505
            LibSip_Steps.f_setHeadersREFER(p_cSeq_s);
506
        } // end f_setHeadersREFER
117 poglitsch 507
 
187 tepelmann 508
        /**
190 tepelmann 509
         * @desc Sets REFER header fields (IMS addresses) extension of general settings from LibSip basic function
510
         * @param p_cSeq_s The current cSeq
511
         * @param p_uri The SipUrl for request URI and To header
187 tepelmann 512
         */
513
        function f_setHeadersREFER_conf(
514
            inout CSeq p_cSeq_s,
515
            in SipUrl p_uri
516
        ) runs on ImsComponent  {
517
            vc_to := {
518
                fieldName := TO_E,
519
                addressField := {
520
                    nameAddr := {
521
                        displayName := omit,  // optional charstring
522
                        addrSpec := p_uri // SipUrl
523
                    }
524
                },  // end addressField
525
                toParams := omit
526
            };
527
 
192 tepelmann 528
            vc_from := f_initFromHeader(p_uri, f_getRndTag()); // init of vc_from using userProfile identifier
187 tepelmann 529
            vc_requestUri := p_uri; // Request URI of Invite is identical with To header
530
            if (vc_boo_route) {
531
                vc_route := m_route_interface(vc_interfaceprofile);
117 poglitsch 532
            }
187 tepelmann 533
            if (vc_boo_recordRoute) {
534
                vc_recordRoute := m_recordRoute_currIpAddr(vc_userprofile);
157 pintar 535
            }
2 rennoch 536
 
187 tepelmann 537
            LibSip_Steps.f_setHeadersREFER(p_cSeq_s);
538
        } // end f_setHeadersREFER_conf
2 rennoch 539
 
187 tepelmann 540
    } // end group fieldOperations
2 rennoch 541
 
187 tepelmann 542
    group awaitingMessage {
543
    }
190 tepelmann 544
 
187 tepelmann 545
    group sendMessage {
546
 
547
        /**
190 tepelmann 548
         * @desc Sends PRACK message
549
         * @param p_mb The message body of the PRACK message
550
         * @param p_rack_cseq The cSeq of the PRACK message
187 tepelmann 551
         */
194 tepelmann 552
        function f_sendPRACK_sdp(
187 tepelmann 553
            template(value) MessageBody p_mb,
554
            CSeq p_rack_cseq
555
        ) runs on SipComponent  {
194 tepelmann 556
            var integer v_responseNum := 1;
557
            var template(value) PRACK_Request v_prackReq;
187 tepelmann 558
 
559
            f_setHeadersGeneral(vc_cSeq, "PRACK"); // cseq, contact, branch, via
560
            if (isvalue(vc_response.msgHeader.rSeq.responseNum)) {
194 tepelmann 561
                v_responseNum := vc_response.msgHeader.rSeq.responseNum;
187 tepelmann 562
            }
194 tepelmann 563
            vc_rAck := m_RAck(v_responseNum, p_rack_cseq.seqNumber, p_rack_cseq.method);
187 tepelmann 564
 
194 tepelmann 565
            v_prackReq := m_PRACK_Request_sdp(vc_requestUri, vc_callId, vc_cSeq, vc_from, vc_to, vc_via, vc_rAck, p_mb);
187 tepelmann 566
 
567
            // added route header if required
568
            if (isvalue(vc_response.msgHeader.recordRoute)) {
194 tepelmann 569
                v_prackReq.msgHeader.route := f_route();
187 tepelmann 570
            }
571
 
194 tepelmann 572
            SIPP.send(v_prackReq) to vc_sent_label;
187 tepelmann 573
        }
574
 
575
    }
576
    group globalSteps {
577
 
192 tepelmann 578
        //NOTE STF471: removed function f_init_userprofile, have to move up to specific ATS
187 tepelmann 579
 
197 nikolajev 580
        /**
581
         * @desc Initializes the To header
582
         * @param p_user Identifies the selected user's SIP URL
583
         * @return The To header
190 tepelmann 584
         */
187 tepelmann 585
        function f_initToHeader(
192 tepelmann 586
            in SipUrl p_user
187 tepelmann 587
        ) runs on ImsComponent
588
        return To  {
194 tepelmann 589
            var To v_to := c_empty_To;
590
            v_to := {
187 tepelmann 591
                fieldName := TO_E,
592
                addressField := {
593
                    nameAddr := {
594
                        displayName := omit,  // optional charstring
192 tepelmann 595
                        addrSpec := p_user // SipUrl
187 tepelmann 596
                    }
597
                },  // end addressField
598
                toParams := omit
599
            };
194 tepelmann 600
            return (v_to);
187 tepelmann 601
        }
602
 
197 nikolajev 603
        /**
604
         * @desc Initializes the From header
605
         * @param p_user Identifies the selected user' SIP URL
606
         * @param p_tag_str The string value of the tag id
607
         * @return The From header
190 tepelmann 608
         */
187 tepelmann 609
        function f_initFromHeader(
192 tepelmann 610
            in SipUrl p_user,
187 tepelmann 611
            charstring p_tag_str
612
        ) runs on ImsComponent
613
        return From  {
614
            var From v_from := c_empty_From;
615
            v_from := {
616
                fieldName := FROM_E,
617
                addressField := {
618
                    nameAddr := {
619
                        displayName := omit,  // optional charstring
192 tepelmann 620
                        addrSpec := p_user // SipUrl
187 tepelmann 621
                    }
622
                },  // end addressField
623
                fromParams := {
624
                    {
625
                        id := c_tagId,
626
                        paramValue := p_tag_str
627
                    }
628
                }
629
            };
630
            return v_from;
631
        }
632
 
192 tepelmann 633
        //NOTE STF471: removed function f_initSipUrl, have to move up to specific ATS
187 tepelmann 634
 
192 tepelmann 635
        //NOTE STF471: removed function f_init_interfaceprofile, have to move up to specific ATS
187 tepelmann 636
 
186 tepelmann 637
        /**
190 tepelmann 638
         * @desc Retrieves user DomainPort value of the user profile
639
         * @param p_userProfile Identifies the selected user profile
640
         * @return The Domain HostPort
157 pintar 641
         */
187 tepelmann 642
        function f_get_userDomainPort(
643
            in SipUserProfile p_userProfile
644
        ) runs on ImsComponent
645
        return HostPort  {
646
            return
647
                {
648
                    p_userProfile.homeDomain,
649
                    p_userProfile.currPort
650
                };
157 pintar 651
        }
2 rennoch 652
 
187 tepelmann 653
        /**
190 tepelmann 654
         * @desc Retrieves HostPort value of the interface profile
655
         * @param p_interface Identifies the selected interface
656
         * @return The HostPort
187 tepelmann 657
         */
658
        function f_get_interfaceHostPort(
659
            in ImsInterfaceProfile p_interface
660
        ) runs on ImsComponent
661
        return HostPort  {
662
            return
663
                {
664
                    p_interface.SUTIpaddr,
665
                    p_interface.SUTPort
666
                };
667
        }
2 rennoch 668
 
187 tepelmann 669
        /**
190 tepelmann 670
         * @desc Retrieves DomainPort value of the interface profile
671
         * @param p_interface Identifies the selected interface
672
         * @return The Domain HostPort
187 tepelmann 673
         */
674
        function f_get_interfaceDomainPort(
675
            in ImsInterfaceProfile p_interface
676
        ) runs on ImsComponent
677
        return  HostPort  {
678
            return
679
                {
680
                    p_interface.SUTHomeDomain,
681
                    p_interface.SUTPort
682
                };
683
        }
2 rennoch 684
 
187 tepelmann 685
        /**
190 tepelmann 686
         * @desc Gets the receive template for the NameAddr of the interface
687
         * @param p_interface Identifies the selected interface
688
         * @return The NameAddr template
187 tepelmann 689
         */
690
        function f_get_interfaceNameAddr(
691
            in ImsInterfaceProfile p_interface
692
        ) runs on ImsComponent
693
        return template NameAddr  {
694
            return mw_SipUrl_SUTinterface(p_interface.SUTIpaddr, p_interface.SUTPort);
695
        }
2 rennoch 696
 
187 tepelmann 697
    }
190 tepelmann 698
 
187 tepelmann 699
    group registration {
2 rennoch 700
 
187 tepelmann 701
        /**
190 tepelmann 702
         * @desc Registration and authentication
703
         * @param p_cSeq_s The current cseq
187 tepelmann 704
         * @param p_auth flag indicating if authentication is needed
192 tepelmann 705
         * @param p_host TODO formerly PX_IMS_TS_PCSCF_HOME_DOMAIN
706
         * @param p_port TODO formerly PX_IMS_TS_PCSCF_PORT
187 tepelmann 707
         */
708
        function f_Registration_IMS(
709
            inout CSeq p_cSeq_s,
192 tepelmann 710
            in boolean p_auth,
711
            template(value) charstring p_host,
712
            template(value) integer p_port
187 tepelmann 713
        ) runs on SipComponent  {
714
            f_setHeaders_REGISTER(p_cSeq_s);
192 tepelmann 715
            f_SendREGISTER(m_REGISTER_Request_IMS(vc_requestUri, vc_callId, vc_cSeq, vc_from, vc_to, vc_via_REG, vc_contact, m_add_Authorization_digest(vc_authorization, {c_Integrity_protected_no}), p_host, p_port)); // LibSip
187 tepelmann 716
            // awaiting of 401 and sending 2nd REGISTER and awaiting 200 OK REGISTER
717
            if (p_auth) {
718
                // receiving 401 Unauthorized response.
719
                // and Re-send REGISTER request with Authorization header
199 tepelmann 720
                tc_ack.start;
187 tepelmann 721
                alt {
722
                    [] SIPP.receive(mw_Response_Base(c_statusLine401, vc_callId, p_cSeq_s)) -> value vc_response {
723
                        tc_ack.stop;
724
                        // set headers via, cseq and authorization
725
                        f_setHeaders_2ndREGISTER(p_cSeq_s);
192 tepelmann 726
                        f_SendREGISTER(m_REGISTER_Request_IMS(vc_requestUri, vc_callId, vc_cSeq, vc_from, vc_to, vc_via_REG, vc_contact, m_add_Authorization_digest(vc_authorization, {c_Integrity_protected_yes}), p_host, p_port)); // LibSip
187 tepelmann 727
                        // awaiting 200 OK REGISTER
728
                        f_awaitingOkResponse(p_cSeq_s);
197 nikolajev 729
                        f_getServiceRouteMapIntoRouteInRegistration(vc_response);
187 tepelmann 730
                    }
731
                    [] SIPP.receive(mw_Response_Base(c_statusLine200, vc_callId, p_cSeq_s)) {
732
                        tc_ack.stop;
194 tepelmann 733
                        log("*** " & __SCOPE__ & ": INCONC: Authorization was not requested as expected ***");
187 tepelmann 734
                        setverdict(inconc);
735
                    }
736
                }
737
            }
738
            else {
739
                f_awaitingOkResponse(p_cSeq_s);
197 nikolajev 740
                f_getServiceRouteMapIntoRouteInRegistration(vc_response);
187 tepelmann 741
            }
742
        } // end function f_Registration_IMS
2 rennoch 743
 
187 tepelmann 744
        /**
745
         * @desc awaiting UE1 registration (with authentication)
190 tepelmann 746
         * @param p_cSeq_s The current cseq
192 tepelmann 747
         * @param p_to_user The selected user's SIP URL
748
         * @param p_qop of the peer UE (alternatively)
190 tepelmann 749
         * @param p_register The expected REGISTER_Request - default: mw_REGISTER_authorizedRequest_IMS
187 tepelmann 750
         */
751
        function f_awaitingRegistration_IMS(
190 tepelmann 752
            inout CSeq p_cSeq_s,
192 tepelmann 753
            in SipUrl p_to_user,
754
            in charstring p_qop,
190 tepelmann 755
            in template(present) REGISTER_Request p_register :=
756
                mw_REGISTER_authorizedRequest_IMS(
757
                    mw_Authorization_digest(
758
                        mw_digestResponse(
759
                            (c_Integrity_protected_yes, c_Integrity_protected_ip_assoc_pending)
760
                        )
761
                    )
762
                )
187 tepelmann 763
        ) runs on ImsComponent  {
99 poglitsch 764
            var SipUrl v_passociated_url;
194 tepelmann 765
 
187 tepelmann 766
            // Awaiting 1st REGISTER
767
            f_awaitingREGISTER(mw_REGISTER_unauthorizedRequest_IMS);
768
 
769
            // 401 response
770
            f_sendResponse(
771
                m_Response_WWWauthenticate_IMS(
772
                    c_statusLine401,
773
                    vc_callId,
194 tepelmann 774
                    p_cSeq_s,
187 tepelmann 775
                    vc_caller_From,
776
                    vc_caller_To,
777
                    vc_via,
778
                    m_wwwAuthenticate(
779
                        f_calculatecChallenge_forWWWAuthorization(
192 tepelmann 780
                            p_qop,
187 tepelmann 781
                            valueof(vc_authorization.body[0].digestResponse)
782
                        )
783
                    )
784
                )
785
            );
786
 
787
            // Awaiting 2nd REGISTER with authorization header
190 tepelmann 788
            f_awaitingREGISTER(p_register);
187 tepelmann 789
 
790
            // 200OK to complete the request
791
            if (isvalue(vc_request.msgHeader.contact)) {
792
                vc_contact := valueof(vc_request.msgHeader.contact);
793
                vc_contact.contactBody.contactAddresses[0].contactParams := {
794
                    {
795
                        "expires",
796
                        int2str(3600)
797
                    }
798
                };
799
            }
800
            v_passociated_url := vc_caller_From.addressField.nameAddr.addrSpec;
194 tepelmann 801
            f_sendResponse(m_Response_2xxonREGISTER_IMS(c_statusLine200, vc_callId, p_cSeq_s, vc_callee_From, vc_callee_To, vc_via, vc_contact, p_to_user, v_passociated_url));
187 tepelmann 802
        } // end function f_awaitingRegistration_IMS
803
 
804
        /**
190 tepelmann 805
         * @desc Awaiting UE1 registration (with authentication, without security headers)
806
         * @param p_cSeq_s The current cseq
192 tepelmann 807
         * @param p_to_user The selected user's SIP URL
808
         * @param p_qop of the peer UE (alternatively)
187 tepelmann 809
         */
810
        function f_awaitingRegistration_IMS_gm(
192 tepelmann 811
            inout CSeq p_cSeq_s,
812
            in SipUrl p_to_user,
813
            in charstring p_qop
187 tepelmann 814
        ) runs on ImsComponent  {
815
            vc_ignore_subscribe := true; // handle SUBSCRIBE during the call
190 tepelmann 816
 
192 tepelmann 817
            f_awaitingRegistration_IMS(p_cSeq_s, p_to_user, p_qop, mw_REGISTER_authorizedRequest_wo_securityheaders_IMS);
190 tepelmann 818
 
187 tepelmann 819
            vc_DeregDone := false;
820
        } // end function f_awaitingRegistration_IMS_gm
82 pintar 821
 
187 tepelmann 822
        /**
190 tepelmann 823
         * @desc Remove registration
824
         * @param p_cSeq_s The current cseq
192 tepelmann 825
         * @param p_host TODO formerly PX_IMS_TS_PCSCF_HOME_DOMAIN
826
         * @param p_port TODO formerly PX_IMS_TS_PCSCF_PORT
187 tepelmann 827
         */
194 tepelmann 828
        function f_removeRegistration_IMS(
829
            inout CSeq p_cSeq_s,
192 tepelmann 830
            template(value) charstring p_host,
831
            template(value) integer p_port
187 tepelmann 832
        ) runs on SipComponent  {
833
            var template(value) REGISTER_Request v_request;
73 pintar 834
 
187 tepelmann 835
            if (PX_SIP_REGISTRATION) {
194 tepelmann 836
                f_setHeaders_deREGISTER(p_cSeq_s);
837
                v_request := m_REGISTER_Request_expires_IMS(vc_requestUri, vc_callIdReg, p_cSeq_s, vc_from, vc_to, vc_via, vc_contact, vc_authorization, p_host, p_port, "0");
187 tepelmann 838
                v_request.msgHeader.route := f_route();
2 rennoch 839
 
187 tepelmann 840
                f_SendREGISTER(v_request);
841
                if (PX_SIP_REGISTER_AUTHENTICATION_ENABLED) {
842
                    // receiving 401 Unauthorized response.
843
                    // and Re-send REGISTER request with Authorization header
199 tepelmann 844
                    tc_ack.start;
187 tepelmann 845
                    alt {
194 tepelmann 846
                        [] SIPP.receive(mw_Response_Base(c_statusLine401, vc_callIdReg, p_cSeq_s)) -> value vc_response {
187 tepelmann 847
                            tc_ack.stop;
848
                            // set headers via, cseq and authorization
194 tepelmann 849
                            f_setHeaders_2ndREGISTER(p_cSeq_s);
850
                            v_request := m_REGISTER_Request_expires_IMS(vc_requestUri, vc_callIdReg, p_cSeq_s, vc_from, vc_to, vc_via, vc_contact, vc_authorization, p_host, p_port, "0");
187 tepelmann 851
                            v_request.msgHeader.route := f_route();
852
                            // Re-send protected REGISTER
853
                            f_SendREGISTER(v_request); // LibSip
854
                            // awaiting 200 OK REGISTER
194 tepelmann 855
                            f_awaitingResponse(mw_Response_Base(c_statusLine200, vc_callIdReg, p_cSeq_s));
187 tepelmann 856
                        }
194 tepelmann 857
                        [] SIPP.receive(mw_Response_Base(c_statusLine200, vc_callIdReg, p_cSeq_s)) -> value vc_response {
187 tepelmann 858
                            tc_ack.stop;
197 nikolajev 859
                            f_setHeadersOnReceiptOfResponse(vc_response);
194 tepelmann 860
                            log("*** " & __SCOPE__ & ": INFO: Authorization was not requested as expected ***");
187 tepelmann 861
                        }
862
                    }
863
                }
864
                else {
194 tepelmann 865
                    f_awaitingResponse(mw_Response_Base(c_statusLine200, vc_callIdReg, p_cSeq_s));
187 tepelmann 866
                }
867
            }
868
        } // end f_RemoveRegistration_IMS
2 rennoch 869
 
187 tepelmann 870
    } // end group registration
181 garciay 871
 
187 tepelmann 872
    group preambles {
873
 
874
        /**
875
         * @desc Sets variables and default initialization for user profile where proxy role is present
190 tepelmann 876
         * @param p_userprofile User profile of call
877
         * @param p_cSeq_s The current cseq
187 tepelmann 878
         */
879
        function f_IMS_preamble_MGCF(
880
            inout CSeq p_cSeq_s
881
        ) runs on ImsComponent  {
882
            vc_boo_recordRoute := true;
883
            vc_boo_route := true;
192 tepelmann 884
            //NOTE STF471: removed f_init_interfaceprofile(c_interfaceProfile_IMS_SUT_MGCF);
187 tepelmann 885
 
192 tepelmann 886
            f_IMS_preamble_woRegistration(p_cSeq_s);
187 tepelmann 887
        }
888
 
889
        /**
890
         * @desc Sets variables and default initialization for user profile
190 tepelmann 891
         * @param p_cSeq_s The current cseq
187 tepelmann 892
         */
893
        function f_IMS_preamble_woRegistration(
894
            inout CSeq p_cSeq_s
895
        ) runs on ImsComponent  {
896
            // avoid deregistration in default behavior
897
            vc_DeregDone := true;
898
            vc_boo_route := true;
899
            vc_boo_recordRoute := true;
900
 
901
            // Variables & defaults initialization
902
            LibSip_Steps.f_init_component(p_cSeq_s);
903
 
904
            // Preamble
192 tepelmann 905
            //NOTE STF471: removed f_init_userprofile(p_userprofile); // assignment of PIXIT values to component variable
197 nikolajev 906
            vc_sdp_local := valueof(m_SDP_bandwidth(m_media_dynPT(PX_SIP_SDP_DYN, PX_SIP_SDP_ENCODING), vc_userprofile));
187 tepelmann 907
            vc_contact := m_Contact(m_SipUrl_contactIpaddr(vc_userprofile));
908
        }
909
 
188 tepelmann 910
        //NOTE STF471 added
187 tepelmann 911
        /**
912
         * @desc Sets variables and default initialization for user profile
190 tepelmann 913
         * @param p_cSeq_s The current cseq
187 tepelmann 914
         */
915
        function f_IMS_preamble_woRegistration_as(
916
            inout CSeq p_cSeq_s
917
        ) runs on ImsComponent  {
918
            // avoid deregistration in default behavior
919
            vc_DeregDone := true;
920
            vc_boo_route := true;
921
            vc_boo_recordRoute := true;
922
 
923
            // Variables & defaults initialization
924
            LibSip_Steps.f_init_component(p_cSeq_s);
925
 
926
            // Preamble
192 tepelmann 927
            //NOTE STF471: removed f_init_userprofile(p_userprofile); // assignment of PIXIT values to component variable
197 nikolajev 928
            vc_sdp_local := valueof(m_SDP_bandwidth(m_media_dynPT(PX_SIP_SDP_DYN, PX_SIP_SDP_ENCODING), vc_userprofile));
187 tepelmann 929
        }
930
 
931
        /**
932
         * @desc Sets variables and default initialization for user profile and handle registration and authentication with MD5
190 tepelmann 933
         * @param p_cSeq_s The current cseq
934
         * @param p_register Register template
187 tepelmann 935
         */
936
        function f_IMS_preamble_withEmergencyRegistration(
937
            inout CSeq p_cSeq_s,
938
            template REGISTER_Request p_register
939
        ) runs on ImsComponent  {
940
 
192 tepelmann 941
            //NOTE STF471: removed f_init_interfaceprofile(p_interface);
187 tepelmann 942
            // Variables & defaults initialization
192 tepelmann 943
            f_IMS_preamble_woRegistration(p_cSeq_s);
187 tepelmann 944
            // Preamble
181 garciay 945
            f_Registration(p_cSeq_s, p_register, PX_SIP_REGISTER_AUTHENTICATION_ENABLED, true);
946
 
187 tepelmann 947
            // deregistration in case of successful registration
181 garciay 948
            vc_DeregDone := false;
949
        }
950
 
186 tepelmann 951
        /**
187 tepelmann 952
         * @desc Sets variables and default initialization for user profile and handle registration and authentication with MD5
190 tepelmann 953
         * @param p_cSeq_s The current cseq
954
         * @param p_register Register template
187 tepelmann 955
         */
956
        function f_IMS_preamble_withRegistration(
957
            inout CSeq p_cSeq_s,
958
            out template REGISTER_Request p_register
959
        ) runs on ImsComponent  {
182 garciay 960
 
192 tepelmann 961
            //NOTE STF471: removed f_init_interfaceprofile(p_interface);
187 tepelmann 962
            // Variables & defaults initialization
192 tepelmann 963
            f_IMS_preamble_woRegistration(p_cSeq_s);
187 tepelmann 964
 
965
            // Preamble
186 tepelmann 966
            f_Registration(p_cSeq_s, p_register, PX_SIP_REGISTER_AUTHENTICATION_ENABLED);
182 garciay 967
 
187 tepelmann 968
            // deregistration in case of successful registration
182 garciay 969
            vc_DeregDone := false;
187 tepelmann 970
 
186 tepelmann 971
            f_setHeaders_SUBSCRIBE(p_cSeq_s);
972
            f_Subscription(p_cSeq_s, m_SUBSCRIBE_Request_UE(vc_requestUri, vc_callId, p_cSeq_s, vc_from, vc_to, vc_via, vc_contact, vc_route_REG));
187 tepelmann 973
        }
186 tepelmann 974
 
188 tepelmann 975
        //NOTE STF471 added
187 tepelmann 976
        /**
977
         * @desc Sets variables and default initialization for user profile and handle registration and authentication with MD5
190 tepelmann 978
         * @param p_cSeq_s The current cseq
979
         * @param p_register Register template
187 tepelmann 980
         */
981
        function f_IMS_preamble_withRegistrationWoSubscription(
982
            inout CSeq p_cSeq_s,
983
            out template REGISTER_Request p_register
984
        ) runs on ImsComponent  {
192 tepelmann 985
            //NOTE STF471: removed f_init_interfaceprofile(p_interface);
187 tepelmann 986
 
987
            // Variables & defaults initialization
192 tepelmann 988
            f_IMS_preamble_woRegistration(p_cSeq_s);
187 tepelmann 989
 
990
            // Preamble
991
            f_Registration(p_cSeq_s, p_register, PX_SIP_REGISTER_AUTHENTICATION_ENABLED);
992
 
993
            // deregistration in case of successful registration
994
            vc_DeregDone := false;
182 garciay 995
        }
996
 
187 tepelmann 997
        /**
998
         * @desc Sets variables and default initialization for user profile and handle registration and authentication with MD5 (basic registration template)
190 tepelmann 999
         * @param p_cSeq_s The current cseq
192 tepelmann 1000
         * @param p_host TODO formerly PX_IMS_TS_PCSCF_HOME_DOMAIN
1001
         * @param p_port TODO formerly PX_IMS_TS_PCSCF_PORT
187 tepelmann 1002
         */
1003
        function f_IMS_preamble_withRegistrationBasic(
192 tepelmann 1004
            inout CSeq p_cSeq_s,
1005
            template(value) charstring p_host,
1006
            template(value) integer p_port
187 tepelmann 1007
        ) runs on ImsComponent  {
192 tepelmann 1008
            //NOTE STF471: removed f_init_interfaceprofile(p_interface);
187 tepelmann 1009
            // Variables & defaults initialization
192 tepelmann 1010
            f_IMS_preamble_woRegistration(p_cSeq_s);
162 rennoch 1011
 
187 tepelmann 1012
            // Preamble
192 tepelmann 1013
            f_Registration_IMS(p_cSeq_s, PX_SIP_REGISTER_AUTHENTICATION_ENABLED, p_host, p_port);
187 tepelmann 1014
            f_setHeaders_SUBSCRIBE(p_cSeq_s);
1015
            f_Subscription(p_cSeq_s, m_SUBSCRIBE_Request_UE(vc_requestUri, vc_callId, p_cSeq_s, vc_from, vc_to, vc_via, vc_contact, vc_route_REG));
1016
        }
157 pintar 1017
 
186 tepelmann 1018
        /**
187 tepelmann 1019
         * @desc Sets variables and default initialization for user profile and handle registration and authentication with MD5 (basic registration template)
190 tepelmann 1020
         * @param p_cSeq_s The current cseq
157 pintar 1021
         */
187 tepelmann 1022
        function f_IMS_preamble_AS(
1023
            inout CSeq p_cSeq_s
1024
        ) runs on ImsComponent  {
157 pintar 1025
            // avoid deregistration in default behavior
187 tepelmann 1026
            vc_DeregDone := true;
157 pintar 1027
            vc_boo_route := true;
1028
            vc_boo_recordRoute := true;
1029
            vc_cSeq := p_cSeq_s;
187 tepelmann 1030
 
1031
            // Defaults
157 pintar 1032
            vc_def_catchSyncStop := activate(a_Sip_catchSyncStop());
187 tepelmann 1033
            vc_default := activate(a_altstep_AS());
157 pintar 1034
 
187 tepelmann 1035
            // Preamble
192 tepelmann 1036
            //NOTE STF471: removed f_init_interfaceprofile(p_interface);
1037
            //NOTE STF471: removed f_init_userprofile(p_userprofile); // assignment of PIXIT values to component variable
197 nikolajev 1038
            vc_sdp_local := valueof(m_SDP_bandwidth(m_media_dynPT(PX_SIP_SDP_DYN, PX_SIP_SDP_ENCODING), vc_userprofile));
168 tepelmann 1039
            vc_contact := m_Contact(m_SipUrl_contactIpaddr(vc_userprofile));
187 tepelmann 1040
        }
1041
 
1042
    } // end group preambles
1043
 
1044
    group postambles {
1045
 
186 tepelmann 1046
        /**
190 tepelmann 1047
         * @desc Terminates component and handles deregistration
1048
         * @param p_cSeq_s The current cseq
187 tepelmann 1049
         */
1050
        function f_IMS_postamble_withDeRegistration(
194 tepelmann 1051
            CSeq p_cSeq_s
187 tepelmann 1052
        ) runs on ImsComponent  {
194 tepelmann 1053
            f_RemoveRegistration(p_cSeq_s); // TODO check if applicable for IMS
157 pintar 1054
            f_terminate_component();
1055
        }
2 rennoch 1056
 
187 tepelmann 1057
        /**
190 tepelmann 1058
         * @desc Terminates component and optionally handles deregistration on AS as TS
1059
         * @param p_deRegistration Handle deregistration?
187 tepelmann 1060
         */
1061
        function f_IMS_postamble_AS_withDeRegistration(
1062
            boolean p_deRegistration
1063
        ) runs on ImsComponent  {
2 rennoch 1064
 
187 tepelmann 1065
            if (p_deRegistration == true) {
1066
                f_awaitingREGISTER_sendReply(mw_REGISTER_Request_Base, true);
1067
            }
1068
            f_terminate_component();
1069
        }
2 rennoch 1070
 
190 tepelmann 1071
        /**
1072
         * @desc Terminates component without registration
1073
         */
187 tepelmann 1074
        function f_SIP_postamble_IMS1_withoutRegistration(
1075
        ) runs on ImsComponent  {
1076
            f_terminate_component();
1077
        }
2 rennoch 1078
 
190 tepelmann 1079
        /**
1080
         * @desc Terminates component without de-registration
1081
         */
187 tepelmann 1082
        function f_IMS_postamble_withoutDeRegistration(
1083
        ) runs on ImsComponent  {
1084
            f_terminate_component();
1085
        }
2 rennoch 1086
 
190 tepelmann 1087
        /**
1088
         * @desc Terminates component with de-registration
192 tepelmann 1089
         * @param p_to_user The selected user's SIP URL
1090
         * @param p_qop of the peer UE (alternatively)
190 tepelmann 1091
         */
187 tepelmann 1092
        function f_SIP_postamble_IMS1_awaitDeRegistration(
192 tepelmann 1093
            in SipUrl p_to_user,
1094
            in charstring p_qop
187 tepelmann 1095
        ) runs on ImsComponent  {
1096
            var SipUrl v_passociated_url;
1097
            // Awaiting 1st REGISTER
1098
            f_awaitingREGISTER(mw_REGISTER_unauthorizedRequest_IMS);
29 petersenj 1099
 
187 tepelmann 1100
            // 401 response
192 tepelmann 1101
            f_sendResponse(m_Response_WWWauthenticate_IMS(c_statusLine401, vc_callId, vc_cSeq, vc_caller_From, vc_caller_To, vc_via, m_wwwAuthenticate(f_calculatecChallenge_forWWWAuthorization(p_qop, valueof(vc_authorization.body[0].digestResponse)))));
29 petersenj 1102
 
187 tepelmann 1103
            // Awaiting 2nd REGISTER with authorization header
190 tepelmann 1104
            f_awaitingREGISTER(mw_REGISTER_unauthorizedRequest_IMS);
1105
 
187 tepelmann 1106
            // 200OK to complete the request
1107
            v_passociated_url := vc_caller_From.addressField.nameAddr.addrSpec;
192 tepelmann 1108
            f_sendResponse(m_Response_2xxonREGISTER_IMS(c_statusLine200, vc_callId, vc_cSeq, vc_callee_From, vc_callee_To, vc_via, vc_contact, p_to_user, v_passociated_url));
29 petersenj 1109
 
187 tepelmann 1110
            f_terminate_component();
1111
        }
29 petersenj 1112
 
190 tepelmann 1113
        /**
1114
         * @desc Terminates component with de-registration
192 tepelmann 1115
         * @param p_to_user The selected user's SIP URL
1116
         * @param p_qop of the peer UE (alternatively)
190 tepelmann 1117
         */
187 tepelmann 1118
        function f_IMS_postamble_awaitDeRegistration(
192 tepelmann 1119
            in SipUrl p_to_user,
1120
            in charstring p_qop
187 tepelmann 1121
        ) runs on ImsComponent  {
121 rennoch 1122
            var SipUrl v_passociated_url;
187 tepelmann 1123
            // Awaiting 1st REGISTER
121 rennoch 1124
            f_awaitingREGISTER(mw_REGISTER_unauthorizedRequest_IMS);
1125
 
1126
            // 401 response
192 tepelmann 1127
            f_sendResponse(m_Response_WWWauthenticate_IMS(c_statusLine401, vc_callId, vc_cSeq, vc_caller_From, vc_caller_To, vc_via, m_wwwAuthenticate(f_calculatecChallenge_forWWWAuthorization(p_qop, valueof(vc_authorization.body[0].digestResponse)))));
121 rennoch 1128
 
187 tepelmann 1129
            // Awaiting 2nd REGISTER with authorization header
190 tepelmann 1130
            f_awaitingREGISTER(mw_REGISTER_unauthorizedRequest_IMS);
1131
 
187 tepelmann 1132
            // 200OK to complete the request
1133
            v_passociated_url := vc_caller_From.addressField.nameAddr.addrSpec;
192 tepelmann 1134
            f_sendResponse(m_Response_2xxonREGISTER_IMS(c_statusLine200, vc_callId, vc_cSeq, vc_callee_From, vc_callee_To, vc_via, vc_contact, p_to_user, v_passociated_url));
121 rennoch 1135
 
187 tepelmann 1136
            f_terminate_component();
1137
        }
1138
 
1139
 
190 tepelmann 1140
        /**
1141
         * @desc Awaits de-registration
192 tepelmann 1142
         * @param p_to_user The selected user's SIP URL
1143
         * @param p_qop of the peer UE (alternatively)
190 tepelmann 1144
         */
187 tepelmann 1145
        function f_IMS_awaitDeRegistration(
192 tepelmann 1146
            in SipUrl p_to_user,
1147
            in charstring p_qop
187 tepelmann 1148
        ) runs on ImsComponent  {
1149
            var SipUrl v_passociated_url;
1150
            // Awaiting 1st REGISTER
1151
            f_awaitingREGISTER(mw_REGISTER_unauthorizedRequest_IMS);
1152
 
1153
            // 401 response
192 tepelmann 1154
            f_sendResponse(m_Response_WWWauthenticate_IMS(c_statusLine401, vc_callId, vc_cSeq, vc_caller_From, vc_caller_To, vc_via, m_wwwAuthenticate(f_calculatecChallenge_forWWWAuthorization(p_qop, valueof(vc_authorization.body[0].digestResponse)))));
187 tepelmann 1155
 
1156
            // Awaiting 2nd REGISTER with authorization header
190 tepelmann 1157
            f_awaitingREGISTER(mw_REGISTER_unauthorizedRequest_IMS);
1158
 
121 rennoch 1159
            // 200OK to complete the request
1160
            v_passociated_url := vc_caller_From.addressField.nameAddr.addrSpec;
192 tepelmann 1161
            f_sendResponse(m_Response_2xxonREGISTER_IMS(c_statusLine200, vc_callId, vc_cSeq, vc_callee_From, vc_callee_To, vc_via, vc_contact, p_to_user, v_passociated_url));
187 tepelmann 1162
        }
121 rennoch 1163
 
194 tepelmann 1164
        //NOTE STF471: renamed f_SIP_postamble_UE(1|2)_withoutRegistration to f_SIP_postamble_UE_withoutRegistration
190 tepelmann 1165
        /**
1166
         * @desc Terminates component without registration
1167
         */
194 tepelmann 1168
        function f_SIP_postamble_UE_withoutRegistration(
187 tepelmann 1169
        ) runs on ImsComponent  {
1170
            f_terminate_component();
1171
        }
1172
 
190 tepelmann 1173
        /**
1174
         * @desc Sends BYE and awaits response (IMS)
1175
         * @param p_requestUri The Request URI
194 tepelmann 1176
         * @param p_callId CallId parameter for outgoing BYE
1177
         * @param p_cSeq_s CSeq parameter for outgoing BYE
190 tepelmann 1178
         * @param p_from From parameter for outgoing BYE
1179
         * @param p_to To parameter for outgoing BYE
123 rennoch 1180
         */
187 tepelmann 1181
        function f_terminateCall_IMS(
1182
            SipUrl p_requestUri,
194 tepelmann 1183
            CallId p_callId,
1184
            inout CSeq p_cSeq_s,
187 tepelmann 1185
            From p_from,
1186
            template(value) To p_to
1187
        ) runs on ImsComponent  {
194 tepelmann 1188
            LibSip_Steps.f_setHeadersBYE(p_cSeq_s);
187 tepelmann 1189
            // Sending of a BYE request to release the call and expect a final response
194 tepelmann 1190
            f_SendBYE(m_BYE_Request_IMS(p_requestUri, p_callId, p_cSeq_s, p_from, p_to, vc_via, vc_route));
187 tepelmann 1191
 
199 tepelmann 1192
            tc_resp.start;
187 tepelmann 1193
            alt {
194 tepelmann 1194
                [] SIPP.receive(mw_Response_Base(mw_statusLine1xx, p_callId, p_cSeq_s)) {
187 tepelmann 1195
                    repeat;
1196
                }
194 tepelmann 1197
                [] SIPP.receive(mw_Response_Base(mw_statusLineFinal, p_callId, p_cSeq_s)) {
187 tepelmann 1198
                    tc_resp.stop;
1199
                }
123 rennoch 1200
            // timeout should be handled in default_alt_step
187 tepelmann 1201
            }
190 tepelmann 1202
        } // end function f_terminateCall_IMS
187 tepelmann 1203
 
1204
        /**
190 tepelmann 1205
         * @desc Sends BYE and awaits response (UE)
1206
         * @param p_requestUri The Request URI
194 tepelmann 1207
         * @param p_callId CallId parameter for outgoing BYE
1208
         * @param p_cSeq_s CSeq parameter for outgoing BYE
190 tepelmann 1209
         * @param p_from From parameter for outgoing BYE
1210
         * @param p_to To parameter for outgoing BYE
1211
         * @param p_recordRoute RecordRoute parameter for outgoing BYE - default: omit
187 tepelmann 1212
         */
1213
        function f_terminateCall_UE(
1214
            SipUrl p_requestUri,
194 tepelmann 1215
            CallId p_callId,
1216
            inout CSeq p_cSeq_s,
187 tepelmann 1217
            From p_from,
1218
            template(value) To p_to,
1219
            template RecordRoute p_recordRoute := omit
1220
        ) runs on ImsComponent  {
194 tepelmann 1221
            var Route v_route;
1222
            LibSip_Steps.f_setHeadersBYE(p_cSeq_s);
187 tepelmann 1223
            // Sending of a BYE request to release the call and expect a final response
1224
            if (ispresent(p_recordRoute)) {
194 tepelmann 1225
                v_route := {ROUTE_E, valueof(p_recordRoute.routeBody)};
1226
                f_SendBYE(m_BYE_Request_UE(p_requestUri, p_callId, p_cSeq_s, p_from, valueof(p_to), vc_via, v_route));
187 tepelmann 1227
            }
1228
            else {
194 tepelmann 1229
                f_SendBYE(m_BYE_Request_UE(p_requestUri, p_callId, p_cSeq_s, p_from, valueof(p_to), vc_via, vc_route));
187 tepelmann 1230
            }
1231
 
199 tepelmann 1232
            tc_resp.start;
187 tepelmann 1233
            alt {
194 tepelmann 1234
                [] SIPP.receive(mw_Response_Base(mw_statusLine1xx, p_callId, p_cSeq_s)) {
187 tepelmann 1235
                    repeat;
1236
                }
194 tepelmann 1237
                [] SIPP.receive(mw_Response_Base(mw_statusLineFinal, p_callId, p_cSeq_s)) {
187 tepelmann 1238
                    tc_resp.stop;
1239
                }
1240
            // timeout should be handled in default_alt_step
1241
            }
1242
        } // end function f_terminateCall_UE
1243
 
1244
        /**
190 tepelmann 1245
         * @desc Sends BYE and awaits response and De-registration
1246
         * @param p_requestUri The Request URI
194 tepelmann 1247
         * @param p_callId CallId parameter for outgoing BYE
1248
         * @param p_cSeq_s CSeq parameter for outgoing BYE
190 tepelmann 1249
         * @param p_from From parameter for outgoing BYE
1250
         * @param p_to To parameter for outgoing BYE
192 tepelmann 1251
         * @param p_qop of the peer UE (alternatively)
187 tepelmann 1252
         */
1253
        function f_terminateCall_UE_withDeReg(
1254
            SipUrl p_requestUri,
194 tepelmann 1255
            CallId p_callId,
1256
            inout CSeq p_cSeq_s,
187 tepelmann 1257
            From p_from,
192 tepelmann 1258
            template(value) To p_to,
1259
            in charstring p_qop
187 tepelmann 1260
        ) runs on ImsComponent  {
194 tepelmann 1261
            LibSip_Steps.f_setHeadersBYE(p_cSeq_s);
187 tepelmann 1262
            // Sending of a BYE request to release the call and expect a final response
194 tepelmann 1263
            f_SendBYE(m_BYE_Request_UE(p_requestUri, p_callId, p_cSeq_s, p_from, p_to, vc_via, vc_route));
187 tepelmann 1264
 
199 tepelmann 1265
            tc_resp.start;
187 tepelmann 1266
            alt {
194 tepelmann 1267
                [] SIPP.receive(mw_Response_Base(mw_statusLine1xx, p_callId, p_cSeq_s)) {
187 tepelmann 1268
                    repeat;
1269
                }
194 tepelmann 1270
                [] SIPP.receive(mw_Response_Base(mw_statusLineFinal, p_callId, p_cSeq_s)) {
187 tepelmann 1271
                    tc_resp.stop;
1272
                }
1273
            // timeout should be handled in default_alt_step
1274
            }
1275
            action("Please de-register");
192 tepelmann 1276
            f_IMS_awaitDeRegistration(p_requestUri, p_qop);
123 rennoch 1277
        } // end function f_terminateCall_UE_withDeReg
187 tepelmann 1278
 
1279
    }
1280
    group defaults {
1281
 
197 nikolajev 1282
        /**
192 tepelmann 1283
         * @desc Altstep for clearing registration (IMS user)
1284
         * @param p_to_user The selected user's SIP URL
197 nikolajev 1285
         * @param p_qop of the peer UE (alternatively)
190 tepelmann 1286
         * @verdict fail for all unexpected branches
1287
         */
187 tepelmann 1288
        altstep a_clearRegistration_IMSuser(
192 tepelmann 1289
            in SipUrl p_to_user,
1290
            in charstring p_qop
187 tepelmann 1291
        ) runs on ImsComponent {
122 rennoch 1292
            var Response v_response;
1293
            var Request v_request;
171 tepelmann 1294
            var CSeq v_cSeq;
187 tepelmann 1295
            [] any timer.timeout {
194 tepelmann 1296
                log("*** " & testcasename() & ": FAIL: Timeout while waiting for message. ***");
187 tepelmann 1297
                setverdict(fail);
1298
                all timer.stop;
1299
                // TODO check how to solve release of call
1300
                // 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
122 rennoch 1301
                vc_callId := vc_callIdReg;
187 tepelmann 1302
                action("Please de-register");
192 tepelmann 1303
                f_IMS_awaitDeRegistration(p_to_user, p_qop);
187 tepelmann 1304
                f_componentStop();
122 rennoch 1305
            }
1306
            // allow repeated INVITEs
187 tepelmann 1307
            [vc_ignore_invite] SIPP.receive(mw_INVITE_Request_Base) {
1308
                repeat;
122 rennoch 1309
            }
1310
            // allow repeated BYEs after ack of the first BYE
187 tepelmann 1311
            [vc_ignore_bye] SIPP.receive(mw_BYE_Request_Base(?)) {
1312
                repeat;
122 rennoch 1313
            }
187 tepelmann 1314
            [] SIPP.receive(mw_ACK_Request_Base(?)) {
1315
                repeat;
122 rennoch 1316
            }
1317
            // allow 100 replies
187 tepelmann 1318
            [] SIPP.receive(mw_Response_Base(c_statusLine100, ?, ?)) {
1319
                repeat;
1320
            }
1321
            // ignore 181 if flag is set (following TS 183004 §4.5.2.1)
1322
            [vc_ignore181] SIPP.receive(mw_Response_Base(c_statusLine181, vc_callId, vc_cSeq)) -> value v_response sender vc_sent_label {
171 tepelmann 1323
                v_cSeq := valueof(v_response.msgHeader.cSeq);
197 nikolajev 1324
                f_setHeadersOnReceiptOfResponse(v_response);
122 rennoch 1325
                repeat;
187 tepelmann 1326
            }
122 rennoch 1327
            // according to SIP chap.8.1.3.2
187 tepelmann 1328
            [] SIPP.receive(mw_Response_Base(c_statusLine183, vc_callId, vc_cSeq)) {
122 rennoch 1329
                repeat;
187 tepelmann 1330
            }
122 rennoch 1331
            // ignore 484 if flag is set
187 tepelmann 1332
            [vc_ignore484] SIPP.receive(mw_Response_Base(c_statusLine484, vc_callId, vc_cSeq)) {
1333
                repeat;
1334
            }
1335
            [vc_ignore4xx] SIPP.receive(mw_Response_Base(mw_statusLine4xx, vc_callId, ?)) -> value v_response sender vc_sent_label {
171 tepelmann 1336
                v_cSeq := valueof(v_response.msgHeader.cSeq);
197 nikolajev 1337
                f_setHeadersOnReceiptOfResponse(v_response);
122 rennoch 1338
                f_SendACK(m_ACK_Request_route(vc_requestUri, vc_callId, v_response.msgHeader.cSeq, vc_from, vc_to, vc_via, vc_route));
187 tepelmann 1339
                repeat;
1340
            }
1341
            [vc_ignore200OKinv] SIPP.receive(mw_Response_Base(c_statusLine200, vc_callId, ?)) {
1342
                repeat;
1343
            }
1344
            [] SIPP.receive(mw_INFO_Request_Base(vc_callId)) -> value v_request sender vc_sent_label {
1345
                f_setHeadersOnReceiptOfRequest(v_request);
122 rennoch 1346
                f_send200OK();
187 tepelmann 1347
                repeat;
1348
            }
122 rennoch 1349
            // awaiting of Notify
187 tepelmann 1350
            [] SIPP.receive(mw_NOTIFY_Request_Base(vc_callId)) -> value v_request sender vc_sent_label {
1351
                f_setHeadersOnReceiptOfRequest(v_request);
122 rennoch 1352
                f_send200OK();
187 tepelmann 1353
                repeat;
1354
            }
122 rennoch 1355
            // awaiting of subscribe from UE
187 tepelmann 1356
            [vc_ignore_subscribe] SIPP.receive(mw_SUBSCRIBE_Request_Base) -> value v_request sender vc_sent_label {
122 rennoch 1357
                f_setHeadersOnReceiptOfSUBSCRIBE(v_request);
1358
                f_send200OK();
1359
                repeat;
187 tepelmann 1360
            }
1361
            // awaiting of subscribe on proxy
1362
            [] SIPP.receive(mw_SUBSCRIBE_Request_Base) -> value v_request sender vc_sent_label {
1363
                f_setHeadersOnReceiptOfRequest(v_request);
1364
                f_sendResponse(m_Response_Contact(c_statusLine200, vc_callId, vc_cSeq, vc_callee_From, vc_callee_To, vc_via, vc_contact));
1365
                f_SendNOTIFY(m_NOTIFY_Request_contact(v_request.msgHeader.contact.contactBody.contactAddresses[0].addressField.nameAddr.addrSpec, vc_callId, vc_cSeq, vc_callee_From, vc_callee_To, vc_via, vc_contact));
122 rennoch 1366
                f_awaitingOkResponse(vc_cSeq);
187 tepelmann 1367
                repeat;
1368
            }
122 rennoch 1369
            // unexpected BYE is acknowledged to avoid retransmissions
187 tepelmann 1370
            [] SIPP.receive(mw_BYE_Request_Base(?)) -> value v_request sender vc_sent_label {
194 tepelmann 1371
                log("*** " & testcasename() & ": FAIL: Unexpected BYE message received. ***");
122 rennoch 1372
                setverdict(fail);
187 tepelmann 1373
                f_setHeadersOnReceiptOfRequest(v_request);
122 rennoch 1374
                f_send200OK();
187 tepelmann 1375
                action("Please de-register");
192 tepelmann 1376
                f_IMS_awaitDeRegistration(p_to_user, p_qop);
187 tepelmann 1377
                f_componentStop();
1378
            }
122 rennoch 1379
            // unexpected CANCEL is acknowledged to avoid retransmissions
187 tepelmann 1380
            [] SIPP.receive(mw_CANCEL_Request_Base(?)) -> value v_request sender vc_sent_label {
194 tepelmann 1381
                log("*** " & testcasename() & ": FAIL: Unexpected CANCEL message received. ***");
122 rennoch 1382
                setverdict(fail);
1383
                f_setHeadersOnReceiptOfRequest(v_request);
187 tepelmann 1384
                // Answer to the CANCEL
122 rennoch 1385
                f_send200OK();
187 tepelmann 1386
                action("Please de-register");
192 tepelmann 1387
                f_IMS_awaitDeRegistration(p_to_user, p_qop);
187 tepelmann 1388
                f_componentStop();
1389
            }
122 rennoch 1390
            // catch 4xx response
187 tepelmann 1391
            [] SIPP.receive(mw_Response_Base(mw_statusLine4xx, vc_callId, ?)) -> value v_response sender vc_sent_label {
194 tepelmann 1392
                log("*** " & testcasename() & ": FAIL: Unexpected 4xx response received. ***");
122 rennoch 1393
                setverdict(fail);
171 tepelmann 1394
                v_cSeq := valueof(v_response.msgHeader.cSeq);
197 nikolajev 1395
                f_setHeadersOnReceiptOfResponse(v_response);
122 rennoch 1396
                LibSip_Steps.f_setHeadersACK();
1397
                f_SendACK(m_ACK_Request_route(vc_requestUri, vc_callId, v_response.msgHeader.cSeq, vc_from, vc_to, vc_via, vc_route));
187 tepelmann 1398
                action("Please de-register");
192 tepelmann 1399
                f_IMS_awaitDeRegistration(p_to_user, p_qop);
187 tepelmann 1400
                f_componentStop();
122 rennoch 1401
            }
1402
            // catch 5xx response
187 tepelmann 1403
            [] SIPP.receive(mw_Response_Base(mw_statusLine5xx, vc_callId, ?)) -> value v_response sender vc_sent_label {
194 tepelmann 1404
                log("*** " & testcasename() & ": FAIL: Unexpected 5xx response received. ***");
122 rennoch 1405
                setverdict(fail);
171 tepelmann 1406
                v_cSeq := valueof(v_response.msgHeader.cSeq);
197 nikolajev 1407
                f_setHeadersOnReceiptOfResponse(v_response);
122 rennoch 1408
                LibSip_Steps.f_setHeadersACK();
1409
                f_SendACK(m_ACK_Request_route(vc_requestUri, vc_callId, v_response.msgHeader.cSeq, vc_from, vc_to, vc_via, vc_route));
187 tepelmann 1410
                action("Please de-register");
192 tepelmann 1411
                f_IMS_awaitDeRegistration(p_to_user, p_qop);
187 tepelmann 1412
                f_componentStop();
122 rennoch 1413
            }
187 tepelmann 1414
            // catch invalid REGISTER
1415
            [] SIPP.receive(mw_REGISTER_Request_Base) -> value v_request sender vc_sent_label {
194 tepelmann 1416
                log("*** " & testcasename() & ": FAIL: Unexpected REGISTER received. ***");
187 tepelmann 1417
                setverdict(fail);
1418
                f_componentStop();
1419
            }
1420
            // any
1421
            [] SIPP.receive {
194 tepelmann 1422
                log("*** " & testcasename() & ": FAIL: Unexpected message received. ***");
187 tepelmann 1423
                setverdict(fail);
1424
                all timer.stop;
1425
                action("Please de-register");
192 tepelmann 1426
                f_IMS_awaitDeRegistration(p_to_user, p_qop);
187 tepelmann 1427
                f_componentStop();
122 rennoch 1428
            }
1429
        }
157 pintar 1430
 
1431
        /**
190 tepelmann 1432
         * @desc Main default altstep to handle unexpected messages and timeout
157 pintar 1433
         * @verdict fail for all unexpected branches
187 tepelmann 1434
         */
1435
        altstep a_altstep_AS(
1436
        ) runs on SipComponent {
157 pintar 1437
            var Request v_request;
187 tepelmann 1438
            [] any timer.timeout {
194 tepelmann 1439
                log("*** " & testcasename() & ": FAIL: Timeout while waiting for message. ***");
187 tepelmann 1440
                setverdict(fail);
1441
                all timer.stop;
157 pintar 1442
            }
1443
            // allow repeated INVITEs
187 tepelmann 1444
            [vc_ignore_invite] SIPP.receive(mw_INVITE_Request_Base) {
1445
                repeat;
157 pintar 1446
            }
187 tepelmann 1447
            // handle REGISTER requests
1448
            [] SIPP.receive(mw_REGISTER_Request_Base) -> value v_request sender vc_sent_label {
157 pintar 1449
                f_setHeadersOnReceiptOfREGISTER(v_request);
187 tepelmann 1450
                // vc_contact := vc_request.msgHeader.contact;
1451
                f_sendResponse(m_Response_Contact(c_statusLine200, vc_callId, vc_cSeq, vc_caller_From, vc_caller_To, vc_via, vc_contact));
157 pintar 1452
                repeat;
187 tepelmann 1453
            }
1454
            // according to SIP chap.8.1.3.2
1455
            [] SIPP.receive(mw_Response_Base(c_statusLine183, vc_callId, vc_cSeq)) {
157 pintar 1456
                repeat;
187 tepelmann 1457
            }
181 garciay 1458
            // unexpected CANCEL is acknowledged to avoid retransmissions
187 tepelmann 1459
            [] SIPP.receive(mw_CANCEL_Request_Base(?)) -> value v_request sender vc_sent_label {
194 tepelmann 1460
                log("*** " & testcasename() & ": FAIL: Unexpected CANCEL message received. ***");
181 garciay 1461
                setverdict(fail);
1462
                f_setHeadersOnReceiptOfRequest(v_request);
187 tepelmann 1463
                f_send200OK();
1464
            }
181 garciay 1465
            // unexpected BYE is acknowledged to avoid retransmissions
187 tepelmann 1466
            [] SIPP.receive(mw_BYE_Request_Base(?)) -> value v_request sender vc_sent_label {
194 tepelmann 1467
                log("*** " & testcasename() & ": FAIL: Unexpected BYE message received. ***");
181 garciay 1468
                setverdict(fail);
187 tepelmann 1469
                f_setHeadersOnReceiptOfRequest(v_request);
181 garciay 1470
                f_send200OK();
187 tepelmann 1471
            }
1472
            [] SIPP.receive(mw_Response_Base(?, vc_callId, vc_cSeq)) -> value vc_response {
194 tepelmann 1473
                log("*** " & testcasename() & ": FAIL: Unexpected response message in " & __SCOPE__ & " received. ***");
181 garciay 1474
                setverdict(fail);
1475
                repeat;
157 pintar 1476
            }
187 tepelmann 1477
            // any
1478
            [] SIPP.receive {
194 tepelmann 1479
                log("*** " & testcasename() & ": FAIL: Unexpected message received. ***");
187 tepelmann 1480
                setverdict(fail);
1481
                all timer.stop;
1482
            }
157 pintar 1483
        }
187 tepelmann 1484
    }
143 rennoch 1485
} // module LibIms_Steps