Newer
Older
* @author STF 346, STF366, STF368, STF369
* @version $Id$
* @desc This module provides the types used by the test component
* for SIP-IMS tests.
*/
module LibSip_Steps language "TTCN-3:2005"//MRO
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
//LibCommon
import from LibCommon_Sync all ;
import from LibCommon_VerdictControl all ;
//LibSip
import from LibSip_SIPTypesAndValues all;
import from LibSip_SDPTypes all;
import from LibSip_Templates all;
import from LibSip_Interface all;
import from LibSip_PIXITS all;
import from LibSip_XMLTypes all;
group externalfunctions {
//Return random charstring
external function fx_rndStr() return charstring;
// Return the equivalent string in lower case
external function fx_putInLowercase(charstring par_string) return charstring;
external function fx_getIpAddr(charstring host_name) return charstring;
// External function to generate a digest response.
// References:
// * RFC 2617 HTTP Authentication: Basic and Digest Access
// Authentication, and
// * RFC 1321 The MD5 Message-Digest Algorithm
// See RFC 2617, chapter 5 Sample implementation, for example usage, as
// the signature of calculateDigestResponse is according to the example
// given in the RFC.
//
external function fx_calculateDigestResponse(
charstring nonce,
charstring cnonce,
charstring user,
charstring realm,
charstring passwd,
charstring alg,
charstring nonceCount,
charstring method,
charstring qop,
charstring URI,
charstring HEntity) return charstring;
}
group ParameterOperations {
/**
* @desc function to generate a 32 bits random number as a charstring for tag field
* (used as e.g.: tag in from-header field, or branch parameter in via header)
* @return random value with at least 32 bits of randomness
*
*/
function f_getRndTag() return charstring
{
var charstring tag_value;
//tag_value is initialized with a random value with at least 32 bits of randomness
// 4294967296 is a 32 bits integer
tag_value := fx_rndStr()&fx_rndStr();
return(tag_value);
}
/**
* @desc Function to prepare credentials for request that has an empty
* entity body such as a REGISTER message.
* @param p_userprofile to get important parameters
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
* @return Credentials field
*/
function f_calculatecCredentials_empty(in SipUserProfile p_userprofile) return Credentials
{
var Credentials v_result;
var charstring v_nonce := "";
// RFC 2617 3.2.2 username:
// The name of user in the specified realm.
var charstring v_username := p_userprofile.privUsername;
var charstring v_realm := p_userprofile.registrarDomain;
var charstring v_uri := c_sipScheme & ":" & p_userprofile.registrarDomain;
var charstring v_response := "";
// Construct credentials for an Authorization field of a request.
v_result :=
{
digestResponse :=
{
{ id := "Digest username", paramValue := v_username },
{ id := "realm", paramValue := v_realm },
{ id := "uri", paramValue := v_uri },
{ id := "nonce=""""", paramValue := omit }, // already enclosed to " characters
{ id := "response=""""", paramValue := omit } // already enclosed to " characters
}
};
return v_result;
}
/**
*
* @desc Function to calculate credentials for request that has an empty
* entity body such as a REGISTER message.
* @param p_userprofile to get important parameters
* @param p_method (can be "REGISTER", "INVITE",....)
* @param p_challenge parameter from 4xx response
* @return Credentials field
* @verdict
*/
function f_calculatecCredentials(in SipUserProfile p_userprofile, in charstring p_method,
in CommaParam_List p_challenge) return Credentials
{
var Credentials v_result;
var charstring v_nonce := "";
// Use a fixed client nonce.
var charstring v_cnonce := "1317265";
// RFC 2617 3.2.2 username:
// The name of user in the specified realm.
var charstring v_username := p_userprofile.privUsername;
var charstring v_realm;
// RFC 2617 3.2.2.2 passwd:
// A known shared secret, the password of user of the specified
// username.
var charstring v_passwd := p_userprofile.passwd;
var charstring v_algorithm;
// Use a fixed nonce count.
const charstring c_nonceCount := "00000002";
var charstring v_qop := p_userprofile.qop;
var charstring v_uri := c_sipScheme & ":" & p_userprofile.registrarDomain;
// MD5 hash of empty entity body.
const charstring c_hEntity := "d41d8cd98f00b204e9800998ecf8427e";
var charstring v_response;
var charstring v_opaque;
// extract nonce, realm, algorithm, and opaque from challenge
v_nonce := f_extractParamValueFromChallenge(p_challenge, "nonce");
v_realm := f_extractParamValueFromChallenge(p_challenge, "realm");
v_algorithm := f_extractParamValueFromChallenge(p_challenge, "algorithm");
v_opaque := f_extractParamValueFromChallenge(p_challenge, "opaque");
// calculate a digest response for the Authorize header
v_response := fx_calculateDigestResponse(
v_nonce,
v_cnonce,
v_username,
v_realm,
v_passwd,
v_algorithm,
c_nonceCount,
p_method,
v_qop,
v_uri,
c_hEntity);
// Construct credentials for an Authorization field of a request.
v_result :=
{
digestResponse :=
{
{ id := "Digest username", paramValue := v_username },
{ id := "realm", paramValue := v_realm },
{ id := "nonce", paramValue := v_nonce },
{ id := "uri", paramValue := v_uri },
{ id := "response", paramValue := v_response },
{ id := "algorithm=md5", paramValue := omit }, // algorithm is not enclosed to " characters
{ id := "cnonce", paramValue := v_cnonce },
{ id := "opaque=""""", paramValue := omit }, // already enclosed to " characters
{ id := "qop="&v_qop, paramValue := omit },//qop
{ id := "nc="&c_nonceCount, paramValue := omit }//nonceCount
}
};
return v_result;
}
/**
*
* @desc Function to calculate credentials for request that has an empty
* entity body such as a REGISTER message. NO RESPONSE value to cause an error!
* @param p_userprofile to get important parameters
* @param p_method (can be "REGISTER", "INVITE",....)
* @param p_challenge parameter from 4xx response
* @return Credentials field
* @verdict
*/
function f_calculatecCredentials_wo_response(in SipUserProfile p_userprofile, in charstring p_method,
in CommaParam_List p_challenge) return Credentials
{
var Credentials v_result;
var charstring v_nonce := "";
// Use a fixed client nonce.
var charstring v_cnonce := "1317265";
// RFC 2617 3.2.2 username:
// The name of user in the specified realm.
var charstring v_username := p_userprofile.privUsername;
var charstring v_realm;
// RFC 2617 3.2.2.2 passwd:
// A known shared secret, the password of user of the specified
// username.
var charstring v_passwd := p_userprofile.passwd;
var charstring v_algorithm;
// Use a fixed nonce count.
const charstring c_nonceCount := "00000002";
var charstring v_qop := p_userprofile.qop;
var charstring v_uri := c_sipScheme & ":" & p_userprofile.registrarDomain;
// MD5 hash of empty entity body.
const charstring c_hEntity := "d41d8cd98f00b204e9800998ecf8427e";
var charstring v_response;
var charstring v_opaque;
// extract nonce, realm, algorithm, and opaque from challenge
v_nonce := f_extractParamValueFromChallenge(p_challenge, "nonce");
v_realm := f_extractParamValueFromChallenge(p_challenge, "realm");
v_algorithm := f_extractParamValueFromChallenge(p_challenge, "algorithm");
v_opaque := f_extractParamValueFromChallenge(p_challenge, "opaque");
// calculate a digest response for the Authorize header
v_response := fx_calculateDigestResponse(
v_nonce,
v_cnonce,
v_username,
v_realm,
v_passwd,
v_algorithm,
c_nonceCount,
p_method,
v_qop,
v_uri,
c_hEntity);
// Construct credentials for an Authorization field of a request.
v_result :=
{
digestResponse :=
{
{ id := "Digest username", paramValue := v_username },
{ id := "realm", paramValue := v_realm },
{ id := "nonce", paramValue := v_nonce },
{ id := "uri", paramValue := v_uri },
// { id := "response", paramValue := v_response }, // not included to cause an error
{ id := "algorithm=md5", paramValue := omit }, // algorithm is not enclosed to " characters
{ id := "cnonce", paramValue := v_cnonce },
{ id := "opaque=""""", paramValue := omit }, // already enclosed to " characters
{ id := "qop="&v_qop, paramValue := omit },//qop
{ id := "nc="&c_nonceCount, paramValue := omit }//nonceCount
}
};
return v_result;
}
/**
*
* @desc Function to calculate credentials for response 401 - WWW-Authorization
* @param p_qop of the peer UE (alternatively )
* @param p_challenge parameter from 1st REGISTER request
* @return Credentials field
* @verdict
*/
function f_calculatecChallenge_forWWWAuthorization(in charstring p_qop, in CommaParam_List p_challenge) return Challenge
{
var Challenge v_result;
var charstring v_realm;
var charstring v_qop := p_qop;
v_realm := f_extractParamValueFromChallenge(p_challenge, "realm");
// Construct credentials for an Authorization field of a request.
v_result :=
{
digestCln :=
{
{ id := "Digest realm", paramValue := v_realm },
{ id := "nonce=", paramValue := c_nonce },
{ id := "algorithm=", paramValue := c_algorithm }, // algorithm is not enclosed to " characters
{ id := "ck=", paramValue := c_ck },
{ id := "ik=", paramValue := c_ik }, // already enclosed to " characters
{ id := "qop="&v_qop, paramValue := omit }//qop
}
};
return v_result;
}
/**
*
* @desc Function to calculate credentials for request that has an empty
* entity body such as a REGISTER message and at the end put different private name
* @param p_userprofile to get important parameters
* @param p_method (can be "REGISTER", "INVITE",....)
* @param p_challenge parameter from 4xx response
* @return Credentials field
* @verdict
*/
function f_calculatecCredentialsAndChangeUserName(in SipUserProfile p_userprofile, in charstring p_method,
in CommaParam_List p_challenge) return Credentials
{
var Credentials v_result;
var charstring v_nonce := "";
// Use a fixed client nonce.
var charstring v_cnonce := "1317265";
// RFC 2617 3.2.2 username:
// The name of user in the specified realm.
var charstring v_username := p_userprofile.privUsername;
var charstring v_realm;
// RFC 2617 3.2.2.2 passwd:
// A known shared secret, the password of user of the specified
// username.
var charstring v_passwd := p_userprofile.passwd;
var charstring v_algorithm;
// Use a fixed nonce count.
const charstring c_nonceCount := "00000002";
var charstring v_qop := p_userprofile.qop;
var charstring v_uri := c_sipScheme & ":" & p_userprofile.registrarDomain;
// MD5 hash of empty entity body.
const charstring c_hEntity := "d41d8cd98f00b204e9800998ecf8427e";
var charstring v_response;
var charstring v_opaque;
// extract nonce, realm, algorithm, and opaque from challenge
v_nonce := f_extractParamValueFromChallenge(p_challenge, "nonce");
v_realm := f_extractParamValueFromChallenge(p_challenge, "realm");
v_algorithm := f_extractParamValueFromChallenge(p_challenge, "algorithm");
v_opaque := f_extractParamValueFromChallenge(p_challenge, "opaque");
// calculate a digest response for the Authorize header
v_response := fx_calculateDigestResponse(
v_nonce,
v_cnonce,
v_username,
v_realm,
v_passwd,
v_algorithm,
c_nonceCount,
p_method,
v_qop,
v_uri,
c_hEntity);
// Construct credentials for an Authorization field of a request.
v_result :=
{
digestResponse :=
{
{ id := "Digest username", paramValue := "DifferentToPrivateUser"},
{ id := "realm", paramValue := v_realm },
{ id := "nonce", paramValue := v_nonce },
{ id := "uri", paramValue := v_uri },
{ id := "response", paramValue := v_response },
{ id := "algorithm=md5", paramValue := omit }, // algorithm is not enclosed to " characters
{ id := "cnonce", paramValue := v_cnonce },
{ id := "opaque=""""", paramValue := omit }, // already enclosed to " characters
{ id := "qop="&v_qop, paramValue := omit },//qop
{ id := "nc="&c_nonceCount, paramValue := omit }//nonceCount
}
};
return v_result;
}
/**
*
* @desc Function to check if param related to id from CommanParam_List exist
* containing challenge.
* @param p_challenge parameter from 4xx response
* @param p_id name of parameter("nonce", "realm", "ck", "ik"...)
* @return parameter p_id value
*/
function f_checkParamValueFromChallengeIfPresent(in CommaParam_List p_challenge, in charstring p_id) return boolean
{
var boolean v_result := false;
var integer v_len := sizeof(p_challenge);
var charstring v_id := fx_putInLowercase(p_id);
for (var integer i := 0; i < v_len; i := i + 1)
{
if (fx_putInLowercase(p_challenge[i].id) == v_id)
{
v_result := true;
}
}
return v_result;
}
/**
*
* @desc Function to check if tag is present in SemicolonParam_List
* @param p_param_l SemicolonParam_List
* @return boolean true if tag is present
*/
function f_checkTagPresent(SemicolonParam_List p_param_l) runs on SipComponent return boolean {
var integer v_numberOfParams;
var integer i := 0;
v_numberOfParams := sizeof (p_param_l);
while (i < v_numberOfParams) {
if (fx_putInLowercase(p_param_l[i].id) == c_tagId) {
return (true);
}
i := i + 1;
}
return (false);
}
/**
* @desc Function to extract paramValue related to id from CommanParam_List
* containing challenge.
* @param p_challenge parameter from 4xx response
* @param p_id name of parameter("nonce", "realm",...)
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
* @return parameter p_id value
*/
function f_extractParamValueFromChallenge(in CommaParam_List p_challenge, in charstring p_id) return charstring
{
var charstring v_result := "";
var integer v_len := sizeof(p_challenge);
var charstring v_id := fx_putInLowercase(p_id);
for (var integer i := 0; i < v_len; i := i + 1)
{
if (fx_putInLowercase(p_challenge[i].id) == v_id)
{
v_result := p_challenge[i].paramValue;
}
}
if (v_result == "")
{
if(match(p_id,"algorithm"))
{
v_result := "MD5"
}
else if(match(p_id,"opaque"))
{
v_result := ""
}
else
{
var charstring v_tmpchar := "Cannot acquire value from credentials.";
log ("Cannot acquire value from credentials.");
setverdict(inconc);
stop;
}
}
return v_result;
}
}//end group ParameterOperations
group FieldOperations {
/**
*
* @desc function adds "Tag"-parameter in "To"-headerfield
* @param p_to To header field that should get a Tag parameter
*
*/
function f_addTagInTo(inout To p_to) runs on SipComponent
{
f_addParameterTagIfNotPresent(c_tagId, f_getRndTag(), p_to);
}
/**
*
* @desc addition of a single parameter in the via header field
* @param p_parameter_name name of parameter to be added
* @param p_parameter_value value of parameter to be added
* @param p_viaBody the via parameter to be extended
* @verdict
*/
function f_addParameterIfNotPresent(
in charstring p_parameter_name,
in charstring p_parameter_value,
inout ViaBody p_viaBody)
{
if (ispresent (p_viaBody.viaParams)) {
return;
}
p_viaBody.viaParams := {
{
p_parameter_name,
p_parameter_value
}
};
}
/**
*
* @desc function to addd a parameter to the "To" header field (if there is not any parameter)
* @param p_parameter_name name of the parameter to be added
* @param p_parameter_value value of the paramter to be added
* @param p_to "To" header field to be extended
* @verdict
*/
function f_addParameterTagIfNotPresent(
in charstring p_parameter_name,
in charstring p_parameter_value,
inout To p_to)
{
if (ispresent (p_to.toParams)) {
return;
}
p_to.toParams := {
{
p_parameter_name,
p_parameter_value
}
};
}
/**
*
* @desc function compares the IP address of two hosts
* @param p_host1 hostname
* @param p_host2 hostname
* @return boolean value that is true if the IP addresses are identical
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
* @verdict
*/
function f_equivalentHostAddr(in charstring p_host1, in charstring p_host2) return boolean
{
//A DNS server may be used
return(fx_getIpAddr(p_host1) == fx_getIpAddr(p_host2));
}
/**
*
* @desc function checks if Require contains Precondition
* @param p_message (request or response) SIP message to be analysed
* @return true if p_id parameter exist
*/
function f_checkRequirePrecondition(in Request p_message)
{
if (ispresent(p_message.msgHeader.require))
{
var boolean v_precondition_found:=false;
for (var integer v_i:=0; v_i<sizeof(p_message.msgHeader.require.optionsTags); v_i:=v_i+1){
if (match(p_message.msgHeader.require.optionsTags[v_i],c_tagPrecond)) {
v_precondition_found:=true;
}
}
if (not(v_precondition_found)){
setverdict(fail);
log("FAIL: precondition not found in Require options list!");
}
}
else
{
setverdict(fail);
log("FAIL: Require options is not present!");
}
}
/**
*
* @desc function checks if P-Charging-Vector contains a particular parameter
* @param p_message (request or response) SIP message to be analysed
* @param p_id name of parameter
* @return true if p_id parameter exist
*/
function f_checkPChargingVectorHeaderParamId(in Request p_message, charstring p_id) return boolean
{
var integer v_chargeParamsLen;
if (ispresent(p_message.msgHeader.pChargingVector)) {
for (var integer i:=0; i<sizeof(p_message.msgHeader.pChargingVector.chargeParams); i:=i+1)
{if(p_message.msgHeader.pChargingVector.chargeParams[i].id == p_id)
{return (true)}
};
}
return (false)
}
/**
*
* @desc function checks if P-Charging-Vector contains a particular parameter
* @param p_message (request or response) SIP message to be analysed
* @param p_id name of parameter
* @return true if p_id parameter exist
*/
function f_checkPChargingVectorHeaderParamIdResponse(in Response p_message, charstring p_id) return boolean
{
var integer v_chargeParamsLen;
if (ispresent(p_message.msgHeader.pChargingVector)) {
for (var integer i:=0; i<sizeof(p_message.msgHeader.pChargingVector.chargeParams); i:=i+1)
{if(p_message.msgHeader.pChargingVector.chargeParams[i].id == p_id)
{return (true)}
};
}
return (false)
}
/**
*
* @desc function returns the Host/Port of a given Contact header field
* @param p_contact contact header field to be analysed
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
* @return Host/Port record from the contact header field
*/
function f_getContactAddr(in ContactAddress p_contact) runs on SipComponent return HostPort
{
var HostPort v_locAddr;
var SipUrl v_SipUrl;
if (ischosen(p_contact.addressField.nameAddr))
{
v_SipUrl := p_contact.addressField.nameAddr.addrSpec;
}
else
{
v_SipUrl := p_contact.addressField.addrSpecUnion;
}
v_locAddr.host := v_SipUrl.hostPort.host;
if (ispresent(v_SipUrl.hostPort.portField))
{
v_locAddr.portField := v_SipUrl.hostPort.portField;
}
else
{
v_locAddr.portField := c_defaultSipPort;
}
return(v_locAddr);
} // end f_getContactAddr
/**
*
* @desc function checks if History-Info-Header of the p_message contains a particular URI
* @param p_message (request or response) SIP message to be analysed
* @param p_URI name of parameter
* @return true if p_URI parameter exist
*/
function f_checkHeaderInfoURI(in Response p_message, SipUrl p_URI) return boolean
{
var integer v_chargeParamsLen;
if (ispresent(p_message.msgHeader.historyInfo)) {
for (var integer i:=0; i<sizeof(p_message.msgHeader.historyInfo.historyInfoList); i:=i+1)
{if(p_message.msgHeader.historyInfo.historyInfoList[i].nameAddr.addrSpec == p_URI)
{return (true)}
};
}
return (false)
}
/**
*
* @desc function returns the Userinfo from a given To header field
* @param p_to To header field to be analysed
* @return Userinfo from the To header field as a charstring
*/
function f_getUserfromTo(in To p_to) runs on SipComponent return charstring
{
var SipUrl v_SipUrl;
if (ischosen(p_to.addressField.nameAddr))
{
v_SipUrl := p_to.addressField.nameAddr.addrSpec;
}
else
{
v_SipUrl := p_to.addressField.addrSpecUnion;
}
return(v_SipUrl.userInfo.userOrTelephoneSubscriber);
} // end f_getUserfromTo
/**
*
* @desc function to generate a 32 bits random number as a charstring for tag field
* @param p_cSeq_s CSeq parameter used to modify the tag field value
* @return tag value
*/
function f_getRndCallId(inout CSeq p_cSeq_s) return charstring
{
var charstring v_tag_value;
v_tag_value := fx_rndStr()&fx_rndStr();
//v_tag_value is initialized with a random value with at least 32 bits of randomness
// 4294967296 is a 32 bits integer
//v_tag_value := int2str(float2int(4294967296.0*rnd()) + loc_CSeq_s.seqNumber );
return(v_tag_value);
}
/**
*
* @desc function give access to the top element of the Path header field.
* @param p_Request SIP message to be analysed
* @return NameAddr (e.g. <sip:p.home.com>) or omit
*/
function f_getPathHeaderTop(inout Request p_Request) return template NameAddr
{
if (ispresent(p_Request.msgHeader.path)) {
if (sizeof(p_Request.msgHeader.path.pathValues)>0) {
return(p_Request.msgHeader.path.pathValues[0].nameAddr)}
};
return(omit)
}
/**
*
* @desc function updates first element of a Via headerfield list
* @param p_viaBody_List address list of a Via header field
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
* @param p_source_address address to be inserted in the top element
*/
function f_getViaReplyAddr(inout ViaBody_List p_viaBody_List, inout address4SIP p_source_address)
runs on SipComponent
{
var ViaBody v_viaBody;
var HostPort v_locAddr;
// The address to send message shall be updated after getting information
// in the Via header fied and according to 18.2.2
v_viaBody := p_viaBody_List[0];
// received parameter has to be addded to the via hader field
// Be careful it could be an Host name and not an IP Address
if (not f_equivalentHostAddr(valueof (v_viaBody.sentBy.host),
valueof (p_source_address.host))) {
f_addParameterIfNotPresent(
c_receivedId,
valueof (p_source_address.host),
v_viaBody);
}
if (ispresent(v_viaBody.sentBy.portField))
{
p_source_address.portField := valueof(v_viaBody.sentBy.portField);
}
else
{
p_source_address.portField := c_defaultSipPort;
}
}
/**
*
* @desc functions give access to an element of the Route header field (record).
* @param p_message (request) SIP message to be analysed
* @param p_index index of Route record element to be retrieved
* @return HostPort value of the Route element or omit
*/
function f_getRouteHeaderElementAddressFromRequest(in Request p_message, in integer p_index) return HostPort
{
if (ispresent(p_message.msgHeader.route)) {
if (sizeof(p_message.msgHeader.route.routeBody)>p_index) {
return(p_message.msgHeader.route.routeBody[p_index].nameAddr.addrSpec.hostPort)}
};
setverdict(fail);
return(c_hostport_dummy)
}
/**
*
* @desc functions give access to an element of the Record-Route header field (record).
* @param p_message (request) SIP message to be analysed
* @param p_index index of recordRoute record element to be retrieved
* @return HostPort value of the Record-Route element or omit
*/
function f_getRecordRouteHeaderElementAddressFromRequest(in Request p_message, in integer p_index) return HostPort
{
if (ispresent(p_message.msgHeader.recordRoute)) {
if (sizeof(p_message.msgHeader.recordRoute.routeBody)>p_index) {
return(p_message.msgHeader.recordRoute.routeBody[p_index].nameAddr.addrSpec.hostPort)}
};
setverdict(fail);
return(c_hostport_dummy)
}
/**
*
* @desc functions give access to an element of the Record-Route header field (record).
* @param p_message (response) SIP message to be analysed
* @param p_index index of recordRoute record element to be retrieved
* @return HostPort value of the Record-Route element or omit
*/
function f_getRecordRouteHeaderElementAddressFromResponse(in Response p_message, in integer p_index) return HostPort
{
if (ispresent(p_message.msgHeader.recordRoute)) {
if (sizeof(p_message.msgHeader.recordRoute.routeBody)>p_index) {
return(p_message.msgHeader.recordRoute.routeBody[p_index].nameAddr.addrSpec.hostPort)}
};
setverdict(fail);
return(c_hostport_dummy)
}
/**
*
* @desc functions give access to an element of the Via header field (record).
* @param p_message (request) SIP message to be analysed
* @param p_index index of via record element to be retrieved
* @return HostPort value of the Via element or omit
*/
function f_getViaHeaderElementHostPort(in Request p_message, in integer p_index) return HostPort
{
if (sizeof(p_message.msgHeader.via.viaBody)>p_index) {
return(p_message.msgHeader.via.viaBody[p_index].sentBy)}
setverdict(fail);
return(c_hostport_dummy)
}
/**
*
* @desc functions give access to an element of the Via header field (record).
* @param p_message (response) SIP message to be analysed
* @param p_index index of via record element to be retrieved
* @return HostPort value of the Via element or omit
*/ function f_getViaHeaderElementHostPortResponse(in Response p_message, in integer p_index) return HostPort
{
if (sizeof(p_message.msgHeader.via.viaBody)>p_index) {
return(p_message.msgHeader.via.viaBody[p_index].sentBy)}
setverdict(fail);
return(c_hostport_dummy)
}
/**
*
* @desc function checks indicators if topology hiding (TH) has been applied:
* - second element in via-header record has tokenized-by parameter
* @param p_Request SIP message to be analysed
* @return boolean value (true indicate TH, false otherwise)
*/
function f_topologyHiding(inout Request p_request) runs on SipComponent return boolean
{
var GenericParam v_viaParameter := p_request.msgHeader.via.viaBody[1].viaParams[0]; // second element
if (not v_viaParameter.id == "tokenized-by")
{return(false)};
return(true)
}
/**
*
* @desc function checks indicators if topology hiding (TH) has been applied:
* - any element in via-header record has tokenized-by parameter
* @param Response SIP message to be analysed
* @return boolean value (true indicate TH, false otherwise)
*/
function f_topologyHidingResponse(inout Response p_response) runs on SipComponent return boolean
{
var GenericParam v_viaParameter;
for (var integer v_i := 0; v_i < sizeof(p_response.msgHeader.via.viaBody); v_i := v_i + 1) {
v_viaParameter := p_response.msgHeader.via.viaBody[v_i].viaParams[0]; // first parameter
if (not v_viaParameter.id == "tokenized-by")
{return(false)}
}
return(true);
}
group SetHeaders {
/**
* @desc function for setting of component variables related to message header fields
* (message type independent: CSeq, contact, via), function uses information from userprofile
*
* @param p_cSeq_s CSeq parameter
* @param p_method method name for cSeq header field
*/
function f_setHeadersGeneral(inout CSeq p_cSeq_s, in charstring p_method) runs on SipComponent
{
var SemicolonParam_List v_params;
p_cSeq_s.fieldName := CSEQ_E;
p_cSeq_s.seqNumber := p_cSeq_s.seqNumber + 1;
p_cSeq_s.method := p_method ;
vc_cSeq := p_cSeq_s;
vc_contact := valueof(m_Contact(m_SipUrl_contactIpaddr(vc_userprofile)));
vc_branch := c_branchCookie & f_getRndTag();
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
vc_via:={
fieldName := VIA_E,
viaBody := {valueof(m_ViaBody_currIpaddr(vc_branch, vc_userprofile))}
};
}// end function f_setHeadersGeneral
/**
*
* @desc setting of general and basic Bye header fields
* in additon to the addresses (To, From, ReqUri)
* @param p_cSeq_s
*/
function f_setHeadersBYE(inout CSeq p_cSeq_s) runs on SipComponent
{
f_setHeadersGeneral(p_cSeq_s, "BYE"); // cseq, contact, branch, via
vc_callId := { fieldName:=CALL_ID_E, callid:=f_getRndCallId(p_cSeq_s) & c_AT & vc_userprofile.currIpaddr };
f_addTagInTo(vc_to);
vc_cancel_To := vc_to;
vc_caller_To := vc_to;
vc_caller_From := vc_from;
vc_reqHostPort := vc_requestUri.hostPort;
}// end function f_setHeadersBYE
/**
*
* @desc function sets header field for the next outgoing REGISTER message
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
* @param p_cSeq_s CSeq parameter to be applied
*/
function f_setHeaders_REGISTER(inout CSeq p_cSeq_s) runs on SipComponent
{
var SemicolonParam_List v_params;
f_setHeadersGeneral(p_cSeq_s, "REGISTER"); // cseq, contact, branch, via
vc_requestUri:=
{
scheme := c_sipScheme,
userInfo := omit,
hostPort := {host:=vc_userprofile.registrarDomain, portField:=omit},
urlParameters := omit,
headers := omit
};
vc_reqHostPort := vc_requestUri.hostPort;
vc_callId := { fieldName:=CALL_ID_E, callid:=f_getRndCallId(p_cSeq_s) & c_AT & vc_userprofile.currIpaddr };
vc_callIdReg := vc_callId;
vc_to := valueof(m_To(m_SipUrl_currDomain(vc_userprofile)));
v_params := {{id:=c_tagId, paramValue:=f_getRndTag()}}
vc_from := {fieldName := FROM_E,
addressField :=vc_to.addressField,
fromParams := v_params
};
if(not vc_firstREGISTER_sent)
{
v_params := {{id:=c_expiresId, paramValue:=c_shortRegistration}};
vc_contact.contactBody.contactAddresses[0].contactParams := v_params;
}
vc_firstREGISTER_sent := true;//f_setHeaders_Register is called in deREGISTER function
vc_authorization :=
{
fieldName := AUTHORIZATION_E,
body := {f_calculatecCredentials_empty(vc_userprofile)}
}
}// end function setHeaders_REGISTER
/**
*
* @desc function sets via, cseq and authorization header for the next outgoing (protected) REGISTER
* @verdict
*/
function f_setHeaders_2ndREGISTER() runs on SipComponent
{
var CommaParam_List v_challenge;
vc_branch := c_branchCookie & f_getRndTag();
vc_via_REG :={
fieldName := VIA_E,
viaBody := {valueof(m_ViaBody_currIpaddr(vc_branch, vc_userprofile))}
};
// Extract challenge and calculate credentials for a response.
v_challenge := vc_response.msgHeader.wwwAuthenticate.challenge.otherChallenge.authParams;
// Increment CSeq sequence number
vc_cSeq.seqNumber := vc_cSeq.seqNumber + 1;
// Prepair right answer
vc_authorization :=
{
fieldName := AUTHORIZATION_E,
body := {f_calculatecCredentials(vc_userprofile, "REGISTER", v_challenge)}
}
}// end function f_setHeaders_2ndREGISTER
/**
*
* @desc function sets via, cseq and authorization header for the next outgoing (protected) REGISTER
* NO response in Authorization header to cause an error
* @verdict
*/
function f_setHeaders_2ndREGISTER_wo_response() runs on SipComponent
{
var CommaParam_List v_challenge;
vc_branch := c_branchCookie & f_getRndTag();
vc_via_REG :={
fieldName := VIA_E,
viaBody := {valueof(m_ViaBody_currIpaddr(vc_branch, vc_userprofile))}
};
// Extract challenge and calculate credentials for a response.
v_challenge := vc_response.msgHeader.wwwAuthenticate.challenge.otherChallenge.authParams;
// Increment CSeq sequence number
vc_cSeq.seqNumber := vc_cSeq.seqNumber + 1;
// Prepair right answer
vc_authorization :=
{
fieldName := AUTHORIZATION_E,
body := {f_calculatecCredentials_wo_response(vc_userprofile, "REGISTER", v_challenge)}
}
}// end function f_setHeaders_2ndREGISTER_wo_response
/**
*
* @desc function sets via, cseq and authorization header with different private name for the next outgoing (protected) REGISTER
* @verdict
*/
function f_setHeaders_2ndREGISTER_authorizationWithDifferentUserName() runs on SipComponent
{
var CommaParam_List v_challenge;
vc_branch := c_branchCookie & f_getRndTag();
vc_via_REG :={
fieldName := VIA_E,
viaBody := {valueof(m_ViaBody_currIpaddr(vc_branch, vc_userprofile))}
};
// Extract challenge and calculate credentials for a response.
v_challenge := vc_response.msgHeader.wwwAuthenticate.challenge.otherChallenge.authParams;
// Increment CSeq sequence number
vc_cSeq.seqNumber := vc_cSeq.seqNumber + 1;
// Prepair right answer
vc_authorization :=
{
fieldName := AUTHORIZATION_E,
body := {f_calculatecCredentialsAndChangeUserName(vc_userprofile, "REGISTER", v_challenge)}
}
}// end function f_setHeaders_2ndREGISTER_authorizationWithDifferentUserName
/**
*
* @desc function sets header fields for the next outgoing REGISTER (de-registration)
* @param p_cSeq_s cSeq to be used
* @verdict
*/
function f_setHeaders_deREGISTER(inout CSeq p_cSeq_s) runs on SipComponent
{
f_setHeaders_REGISTER(p_cSeq_s);
vc_contact :=
{
fieldName := CONTACT_E,
contactBody := {wildcard := "*" }
};
} // end function f_setHeaders_deREGISTER
/**
* @desc setting of general and basic Invite header fields
* in additon to the addresses (To, From, ReqUri)
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
* @param p_cSeq_s
*/
function f_setHeadersINVITE(inout CSeq p_cSeq_s) runs on SipComponent
{
f_setHeadersGeneral(p_cSeq_s, "INVITE"); // cseq, contact, branch, via
vc_callId := { fieldName:=CALL_ID_E, callid:=f_getRndCallId(p_cSeq_s) & c_AT & vc_userprofile.currIpaddr };
vc_cancel_To := vc_to;
vc_caller_To := vc_to;
vc_caller_From := vc_from;
vc_reqHostPort := vc_requestUri.hostPort;
}// end function f_setHeadersINVITE
/**
*
* @desc setting of general and basic Message header fields
* in additon to the addresses (To, From, ReqUri)
* @param p_cSeq_s
*/
function f_setHeadersMESSAGE(inout CSeq p_cSeq_s) runs on SipComponent
{
f_setHeadersGeneral(p_cSeq_s, "MESSAGE"); // cseq, contact, branch, via
vc_callId := { fieldName:=CALL_ID_E, callid:=f_getRndCallId(p_cSeq_s) & c_AT & vc_userprofile.currIpaddr };
vc_cancel_To := vc_to;
vc_caller_To := vc_to;
vc_caller_From := vc_from;
vc_reqHostPort := vc_requestUri.hostPort;
}// end function f_setHeadersMESSAGE
/**
*
* @desc function sets header field for the next outgoing SUBSCRIBE message
* @param p_cSeq_s CSeq parameter to be applied
*/
function f_setHeaders_SUBSCRIBE(inout CSeq p_cSeq_s) runs on SipComponent
{
f_setHeadersGeneral(p_cSeq_s, "SUBSCRIBE"); // cseq, contact, branch, via
vc_requestUri:=valueof(m_SipUrl_currDomain(vc_userprofile))
}// end function setHeaders_SUBSCRIBE
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
/**
*
* @desc setting of general and basic REFER header fields
* in additon to the addresses (To, From, ReqUri)
* @param p_cSeq_s
*/
function f_setHeadersREFER(inout CSeq p_cSeq_s) runs on SipComponent
{
f_setHeadersGeneral(p_cSeq_s, "REFER"); // cseq, contact, branch, via
vc_callId := { fieldName:=CALL_ID_E, callid:=f_getRndCallId(p_cSeq_s) & c_AT & vc_userprofile.currIpaddr };
vc_cancel_To := vc_to;
vc_caller_To := vc_to;
vc_caller_From := vc_from;
vc_reqHostPort := vc_requestUri.hostPort;
}// end function f_setHeadersREFER
*
* @desc This function reads all necessary headers from the received REGISTER message and generate the tag for the answer
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
* @param p_Request REGISTER that has been received
*/
function f_setHeadersOnReceiptOfREGISTER(Request p_Request)
runs on SipComponent {
f_setHeadersOnReceiptOfRequest(p_Request);
vc_callId := p_Request.msgHeader.callId;
vc_caller_From := vc_from;
f_addTagInTo(vc_to);
vc_caller_To := vc_to;
vc_requestUri := p_Request.requestLine.requestUri;
vc_cancel_To := p_Request.msgHeader.toField;
if (ispresent(p_Request.msgHeader.contact)) {
vc_reqHostPort := f_getContactAddr(p_Request.msgHeader.contact.contactBody.contactAddresses[0]);
}
// update callee information and pick up tag if the call need to be canceled
vc_callee_To := {fieldName := TO_E,
addressField := vc_caller_From.addressField,
toParams := vc_caller_From.fromParams};
vc_callee_From := {fieldName := FROM_E,
addressField := vc_caller_To.addressField,
fromParams := vc_caller_To.toParams};
} // end f_setHeadersOnReceiptOfREGISTER
/**
*
* @desc This function reads all necessary headers from the received SUBSCRIBE message and generate the tag for the answer
* @param p_Request SUBSCRIBE that has been received
*/
function f_setHeadersOnReceiptOfSUBSCRIBE(Request p_Request)
runs on SipComponent {
f_setHeadersOnReceiptOfRequest(p_Request);
vc_callId := p_Request.msgHeader.callId;
vc_caller_From := vc_from;
f_addTagInTo(vc_to);
vc_caller_To := vc_to;
vc_requestUri := p_Request.requestLine.requestUri;
vc_cancel_To := p_Request.msgHeader.toField;
if (ispresent(p_Request.msgHeader.contact)) {
vc_reqHostPort := f_getContactAddr(p_Request.msgHeader.contact.contactBody.contactAddresses[0]);
}
// update callee information and pick up tag if the call need to be canceled
vc_callee_To := {fieldName := TO_E,
addressField := vc_caller_From.addressField,
toParams := vc_caller_From.fromParams};
vc_callee_From := {fieldName := FROM_E,
addressField := vc_caller_To.addressField,
fromParams := vc_caller_To.toParams};
} // end f_setHeadersOnReceiptOfSUBSCRIBE
/**
* @desc function reads all necessary headers from
* the received INVITE message and generate the tag for the answer
* @param p_Request received INVITE message
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
* @verdict
*/
function f_setHeadersOnReceiptOfINVITE(Request p_Request) runs on SipComponent {
f_setHeadersOnReceiptOfRequest(p_Request);
vc_callId := p_Request.msgHeader.callId;
vc_requestUri := p_Request.requestLine.requestUri;
vc_cancel_To := p_Request.msgHeader.toField;
f_addTagInTo(vc_to);
vc_caller_From := vc_from;
vc_caller_To := vc_to;
if (ispresent(p_Request.msgHeader.contact)) {
vc_reqHostPort :=
f_getContactAddr(p_Request.msgHeader.contact.contactBody.contactAddresses[0]);
};
// update callee information and pick up tag if the call need to be canceled
vc_callee_To := {fieldName := TO_E,
addressField := vc_caller_From.addressField,
toParams := vc_caller_From.fromParams};
vc_callee_From := {fieldName := FROM_E,
addressField := vc_caller_To.addressField,
fromParams := vc_caller_To.toParams};
if (ispresent(p_Request.msgHeader.privacy)) {
vc_privacy := p_Request.msgHeader.privacy;
};
if (ispresent(p_Request.messageBody)) {
//cleaning of attributes before assignment
if (ispresent(vc_sdp_remote.media_list))
{
for (var integer i:=0; i<sizeof(vc_sdp_remote.media_list); i:=i+1)
{
if (ispresent(vc_sdp_remote.media_list[i].attributes))
{
for (var integer j:=0; j<sizeof(vc_sdp_remote.media_list[i].attributes); j:=j+1)
{
}
}
};
}
// save SDP if present
if ( ischosen(p_Request.messageBody.sdpMessageBody))
{
vc_sdp_remote := p_Request.messageBody.sdpMessageBody;
vc_sdp_remote_is_valid := true;
f_prepare_SDP_answer();
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
};
// save XML if present
if ( ischosen(p_Request.messageBody.xmlBody))
{
vc_xml_remote := p_Request.messageBody.xmlBody;
}
if ( ischosen(p_Request.messageBody.mimeMessageBody))
{
for (var integer j:=0; j<sizeof(p_Request.messageBody.mimeMessageBody.mimeEncapsulatedList); j:=j+1){
if (match(p_Request.messageBody.mimeMessageBody.mimeEncapsulatedList[j].content_type,c_sdpAplication))
{
vc_sdp_remote := p_Request.messageBody.mimeMessageBody.mimeEncapsulatedList[j].mime_encapsulated_part.sdpMessageBody;
vc_sdp_remote_is_valid := true;
f_prepare_SDP_answer();
};
if (match(p_Request.messageBody.mimeMessageBody.mimeEncapsulatedList[j].content_type,c_xmlAplication))
{
vc_xml_remote := p_Request.messageBody.mimeMessageBody.mimeEncapsulatedList[j].mime_encapsulated_part.xmlBody;
};
}
}
};
if (ispresent(p_Request.msgHeader.supported.optionsTags)) {
for (var integer i := sizeof(p_Request.msgHeader.supported.optionsTags); i>0; i:=i-1)
{
if (p_Request.msgHeader.supported.optionsTags[i-1]=="100rel")
{ vc_supported_100rel := true };
if (p_Request.msgHeader.supported.optionsTags[i-1]=="precondition")
{ vc_supported_precondition := true }
}
};
} // end f_setHeadersOnReceiptOfINVITE
/**
*
* @desc function reads header field of a received BYE message
* @param p_Request received BYE
*/
function f_setHeadersOnReceiptOfBYE(Request p_BYE_Request)
runs on SipComponent
{
f_setHeadersOnReceiptOfRequest(p_BYE_Request);
vc_callId := p_BYE_Request.msgHeader.callId;
} // end f_setHeadersOnReceiptOfBYE
/**
*
* @desc function reads header field from an incoming Request message
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
* @param p_Request received Request message
*/
function f_setHeadersOnReceiptOfRequest(Request p_Request) runs on SipComponent {
vc_request := p_Request;
vc_cSeq := p_Request.msgHeader.cSeq;
vc_iut_CSeq := p_Request.msgHeader.cSeq;
vc_from := p_Request.msgHeader.fromField;
vc_to := p_Request.msgHeader.toField;
vc_via := p_Request.msgHeader.via;
// update sent_label according to received via header field
f_getViaReplyAddr(vc_via.viaBody, vc_sent_label);
// Catch route
vc_boo_recordRoute:=false;
if (ispresent(p_Request.msgHeader.recordRoute))
{
vc_boo_recordRoute:=true;
vc_recordRoute := p_Request.msgHeader.recordRoute;
}
} // end f_setHeadersOnReceiptOfRequest
/**
*
* @desc functions reads header fields from an incoming Response message
* @param p_cSeq
* @param p_response received response message
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
* @verdict
*/
function f_setHeadersOnReceiptOfResponse(inout CSeq p_cSeq, Response p_response) runs on SipComponent
{
var integer v_i, v_j, v_nbroute;
var Contact v_contact; //only for local purpose
vc_response := p_response;
//vc_cSeq := p_cSeq; //must not save global c_seq because it can overwrite temporary cSeq
vc_to :=p_response.msgHeader.toField;
vc_from :=p_response.msgHeader.fromField;
vc_caller_To := vc_to;
vc_caller_From := vc_from;
if (ispresent(p_response.msgHeader.contact))
{
v_contact := p_response.msgHeader.contact;
if (ischosen(v_contact.contactBody.contactAddresses))
{
vc_reqHostPort := f_getContactAddr(v_contact.contactBody.contactAddresses[0]);
}
}
else
{
if (ischosen(vc_to.addressField.nameAddr))
{
vc_reqHostPort := vc_to.addressField.nameAddr.addrSpec.hostPort;
}
else
{
vc_reqHostPort := vc_to.addressField.addrSpecUnion.hostPort;
}
}
vc_callee_To:={fieldName := TO_E,
addressField := vc_caller_From.addressField,
toParams := vc_caller_From.fromParams};
vc_callee_From:= {fieldName := FROM_E,
addressField := vc_caller_To.addressField,
fromParams := vc_caller_To.toParams};
vc_via:= p_response.msgHeader.via;
// Route Management
if (ispresent(p_response.msgHeader.recordRoute))
{
vc_recordRoute := p_response.msgHeader.recordRoute;
v_nbroute := sizeof(vc_recordRoute.routeBody);
// copy and reverse the order of the routes in route header
for (v_i:=0; v_i<=(v_nbroute - 1); v_i:=v_i+1)
{
v_j:= v_nbroute - 1 - v_i;
vc_route.routeBody[v_j]:=vc_recordRoute.routeBody[v_i];
}
vc_route.fieldName := ROUTE_E;
vc_boo_recordRoute := true;
vc_boo_route := true;
}
else
{
vc_boo_recordRoute := false;
vc_boo_route := false;
};
// extentions due to new fields in PRACK and UPDATE messages
if (ispresent(p_response.msgHeader.rSeq)) {
vc_rAck :=
{ fieldName := RACK_E,
responseNum := valueof(p_response.msgHeader.rSeq.responseNum),
seqNumber := valueof(p_response.msgHeader.cSeq.seqNumber),
method := valueof(p_response.msgHeader.cSeq.method)
};
};
// extentions due to new HistoryInfo fields 180 or 200OK messages
if (ispresent(p_response.msgHeader.historyInfo)) {
vc_historyInfoList := valueof(p_response.msgHeader.historyInfo.historyInfoList);
vc_history_is_valid := true
}
else {vc_history_is_valid := false};
//sdpMessageBody answer
if (ispresent(p_response.messageBody)) {
if ( ischosen(p_response.messageBody.sdpMessageBody))
{
vc_sdp_remote := p_response.messageBody.sdpMessageBody;
vc_sdp_remote_is_valid := true;
}
if ( ischosen(p_response.messageBody.xmlBody))
{
vc_xml_remote := p_response.messageBody.xmlBody;
}
if ( ischosen(p_response.messageBody.mimeMessageBody))
{
for (var integer j:=0; j<sizeof(p_response.messageBody.mimeMessageBody.mimeEncapsulatedList); j:=j+1){
if (match(p_response.messageBody.mimeMessageBody.mimeEncapsulatedList[j].content_type,c_sdpAplication))
{
vc_sdp_remote := p_response.messageBody.mimeMessageBody.mimeEncapsulatedList[j].mime_encapsulated_part.sdpMessageBody;
};
if (match(p_response.messageBody.mimeMessageBody.mimeEncapsulatedList[j].content_type,c_xmlAplication))
{
vc_xml_remote := p_response.messageBody.mimeMessageBody.mimeEncapsulatedList[j].mime_encapsulated_part.xmlBody;
};
}
}
};
}// end function f_setHeadersOnReceiptOfResponse
/**
*
* @desc functions reads ServiceRoute header field from an incoming 200 Response message in registration
* @param p_cSeq
* @param p_response received response message
*/
function f_getServiceRouteMapIntoRouteInRegistration(inout CSeq p_cSeq, Response p_response) runs on SipComponent
{
var integer v_i, v_j, v_nbroute;
var ServiceRoute v_serviceRoute;
// Route Management
if (ispresent(p_response.msgHeader.serviceRoute))
{
v_serviceRoute := p_response.msgHeader.serviceRoute;
v_nbroute := sizeof(v_serviceRoute.routeBody);
// copy and reverse the order of the routes in route header
for (v_i:=0; v_i<=(v_nbroute - 1); v_i:=v_i+1)
{
v_j:= v_nbroute - 1 - v_i;
vc_route.routeBody[v_j]:=v_serviceRoute.routeBody[v_i];
}
vc_route.fieldName := ROUTE_E;
}
}// end function f_getServiceRouteMapIntoRouteInRegistration
} // end group SetHeaders
} // end group FieldOperations
group SDPOperations{
/**
* @desc check if message body include SDP attribute (2nd parameter)
* for any media
*
*/
function f_check_attribute(in SDP_Message p_sdp, in template SDP_attribute p_attribute) runs on SipComponent return boolean {
if (ispresent(p_sdp.media_list)) {
for (var integer j:=0; j<sizeof(p_sdp.media_list); j:=j+1){
if (ispresent(p_sdp.media_list[j].attributes)) {
for (var integer i:=0; i<sizeof(p_sdp.media_list[j].attributes); i:=i+1){
if (match(p_sdp.media_list[j].attributes[i],p_attribute))
{return(true);};
};
}
};
}
if (ispresent(p_sdp.attributes)) {
for (var integer j:=0; j<sizeof(p_sdp.attributes); j:=j+1){
if (match(p_sdp.attributes[j],p_attribute)) {return(true);};
};
}
return(false);
}
*
* @desc identify an SDP direction attribute (session or first media attribute) in a SDP message and return its answer value
* @param p_sdp the SDP message that has been received
* @param p_attribute incoming SDP attribute that need to be used for the SDP direction (answer)
* @return the new attribute (to be send out) derived from the incoming SDP value
function f_get_attribute_answer(in SDP_Message p_sdp, in template SDP_attribute p_attribute) runs on SipComponent return SDP_attribute {
var template SDP_attribute v_attribute := p_attribute;
// check if the selected attribute is included in the SDP offer (session attributes)
if (ispresent(p_sdp.attributes)) {
for (var integer j:=0; j<sizeof(p_sdp.attributes); j:=j+1){
if (match(p_sdp.attributes[j],p_attribute)) {v_attribute := p_sdp.attributes[j];};
};
}
// check if the selected attribute is included in the SDP offer (any of the media attributes)
if (ispresent(p_sdp.media_list)) {
for (var integer j:=0; j<sizeof(p_sdp.media_list); j:=j+1){
if (ispresent(p_sdp.media_list[j].attributes)) {
for (var integer i:=0; i<sizeof(p_sdp.media_list[j].attributes); i:=i+1){
if (match(p_sdp.media_list[j].attributes[i],p_attribute))
{v_attribute := p_sdp.media_list[j].attributes[i];};
};
}
};
}
{
case (mw_attribute_sendonly) {return(valueof(m_attribute_recvonly));}
case (mw_attribute_sendrecv) {return(valueof(m_attribute_sendrecv));}//MRO
case (mw_attribute_inactive) {return(valueof(m_attribute_inactive));}//MRO
case (mw_attribute_recvonly) {return(valueof(m_attribute_sendonly));}//MRO
}
return(valueof(m_attribute_sendrecv));//the default return value in case of missing attribute offer
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
}
/**
* @desc check if message body include SDP bandwidth (2nd parameter)
* either for the session or a media description
*/
function f_check_bandwidth(in SDP_Message loc_sdp, in template SDP_bandwidth loc_bandw) runs on SipComponent return boolean {
if (ispresent(loc_sdp.bandwidth)) {
for (var integer j:=0; j<sizeof(loc_sdp.bandwidth); j:=j+1){
if (match(loc_sdp.bandwidth[j],loc_bandw)) {return(true);};
};
};
if (ispresent(loc_sdp.media_list)) {
for (var integer j:=0; j<sizeof(loc_sdp.media_list); j:=j+1){
if (ispresent(loc_sdp.media_list[j].bandwidth)) {
if (match(loc_sdp.media_list[j].bandwidth,loc_bandw)) {return(true);};
};
};
};
return(false);
}
/**
* @desc check if message body include SDP media (2nd parameter)
*
*/
function f_check_media(in SDP_Message loc_sdp, in template SDP_media_desc loc_media) runs on SipComponent return boolean {
if (ispresent(loc_sdp.media_list)) {
for (var integer j:=0; j<sizeof(loc_sdp.media_list); j:=j+1){
if (match(loc_sdp.media_list[j].media_field.transport,loc_media.media_field.transport) and
match(loc_sdp.media_list[j].media_field.fmts,loc_media.media_field.fmts))
{return(true);};
};
}
return(false);
}
/**
* @desc
* check if message body include precondition mechanism (a=des and
* a=curr) retrun true, else false
* @param loc_sdp SDP message
*/
function f_check_precondition(in SDP_Message loc_sdp) runs on SipComponent return boolean {
if (f_check_attribute(loc_sdp, mw_attribute_des) or
f_check_attribute(loc_sdp, mw_attribute_curr))
{return(true);}
return(false);
}
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
/**
* @desc check if message body include SDP media direction return true, else false
*
*/
function f_check_media_direction(in SDP_Message loc_sdp) runs on SipComponent return boolean {
if (f_check_attribute(loc_sdp, mw_attribute_sendonly) or
f_check_attribute(loc_sdp, mw_attribute_recvonly) or
f_check_attribute(loc_sdp, mw_attribute_sendrecv) or
f_check_attribute(loc_sdp, mw_attribute_inactive))
{return(true);}
return(false);
}
/**
* @desc copy media/attribute lines from remote to local SDP variable
*
*/
function f_check_SDP(integer loc_sdp, integer loc_codec) runs on SipComponent
return boolean
{
var SDP_media_desc v_media := f_prepare_media(loc_sdp,loc_codec);
log("log0");
if (vc_sdp_remote.media_list[0].media_field.media != v_media.media_field.media)
{ log("log1"); return false };
if (vc_sdp_remote.media_list[0].media_field.transport != v_media.media_field.transport)
{ log("log2"); return false };
if (vc_sdp_remote.media_list[0].media_field.fmts != v_media.media_field.fmts)
{ log("remote:",vc_sdp_remote.media_list[0].media_field.fmts,"expect:",v_media.media_field.fmts); return false };
return true
}
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
/**
* @desc replace the first curr media attribute with the given value.
* @param p_sdp SDP message to modify
* @param p_curr new curr attribute
*/
function f_replace_curr_attribute(inout SDP_Message p_sdp, in SDP_attribute_curr p_curr) {
if(ispresent(p_sdp.media_list)) {
var integer mn := sizeof(p_sdp.media_list[0].attributes);
for(var integer i := 0; i<=mn; i := i+1) {
if(ischosen(p_sdp.media_list[0].attributes[i].curr)){
p_sdp.media_list[0].attributes[i].curr := p_curr;
i:=mn;
}
}
}
}
/**
* @desc append new media attribute to the first media description.
* @param p_sdp SDP message to modify
* @param p_att SDP attribute to appand
*/
function f_append_media_attribute(inout SDP_Message p_sdp, in SDP_attribute p_att) {
if(ispresent(p_sdp.media_list)) {
var integer mn := sizeof(p_sdp.media_list[0].attributes);
p_sdp.media_list[0].attributes[mn] := p_att;
}
}
/**
* @desc append new media to the existing media list in SDP
*
*/
function f_append_media(inout SDP_Message loc_SDP, in template SDP_media_desc loc_media)
{
var integer mn := sizeof(loc_SDP.media_list);
loc_SDP.media_list[mn] := valueof(loc_media);
}
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
/**
* @desc repare media/attribute lines
*
*/
function f_prepare_media(integer loc_sdp, integer loc_codec) runs on SipComponent
return SDP_media_desc
{
var charstring v_codecs[32] := {
"PCMU/8000", "GSM/8000", "G723/8000", "DVI4/8000",
"DVI4/16000", "LPC/8000", "PCMA/8000", "G722/8000",
"L16/44100/2", "L16/44100", "QCELP/8000", "CN/8000",
"MPA/90000", "G728/8000", "DVI4/11025", "DVI4/22050",
"G729/8000", "G726-40/8000", "G726-32/8000", "G726-24/8000",
"G726-16/8000", "G726D/8000", "G726E/8000", "GSM-EFR/8000",
"CelB/90000", "JPEG/90000", "Nv/90000", "H261/90000",
"MPV/90000", "MP2T/90000", "H263/90000", "H263-1998/90000"
}
var SDP_media_desc v_media :=
{
media_field := {
media := "audio",
ports := {
port_number := 10000,
num_of_ports:=omit },
transport := "RTP/AVP",
fmts := { "0" }
}, //m=audio 8500 RTP/AVP 0
information := omit,
connections := omit,
bandwidth := omit,
key := omit,
attributes := omit
};
if (32<loc_codec or loc_codec<1) {
log("Unexpected SDP variant");
setverdict(inconc);
return (v_media)}
if (loc_sdp == 1) {}
else if (loc_sdp == 2) {
v_media.media_field.fmts := {PX_SIP_SDP_dyn}; //{ "98", "0" };
v_media.attributes := {{
rtpmap := { attr_value := PX_SIP_SDP_dyn & " " & v_codecs[loc_codec-1] } // PX_SIP_SDP_dyn := 98
}}
} else if (loc_sdp == 3) {
v_media.media_field.fmts := { "8" }
} else if (loc_sdp == 4) {
v_media.media_field.fmts := { "99", "8" };
v_media.attributes := {{
rtpmap := { attr_value := "99 " & v_codecs[loc_codec-1] }
}}
} else if (loc_sdp == 5) {
v_media.media_field.media := "image";
v_media.media_field.transport := "udptl";
v_media.media_field.fmts := { "t38" }
} else if (loc_sdp == 6) {
v_media.media_field.media := "image";
v_media.media_field.transport := "tcptl";
v_media.media_field.fmts := { "t38" }
} else {
log("Unexpected SDP variant"); setverdict(inconc)
};
return (v_media);
}
/**
* @desc repare media/attribute lines
*
*/
function f_prepare_SDP(integer loc_sdp, integer loc_codec) runs on SipComponent
{
vc_sdp_local.media_list := {f_prepare_media(loc_sdp,loc_codec)};
}
/**
*
* @desc function that copy media/attribute lines from remote to local SDP variable
*/
function f_prepare_SDP_answer() runs on SipComponent
{
var integer mn, cn := 0, i, j, k :=0;
var charstring v_PT, v_rtpmap := "";
var SDP_attribute_list v_mediaAttributes := {};
//increase session version
vc_sdp_local.origin.session_version := int2str(str2int(vc_sdp_local.origin.session_version)+1);
// if more than one codec, select the firs one
mn:= sizeof(vc_sdp_local.media_list);
for (i :=0; i < mn; i := i+1)
{
//for every single media
if (ispresent(vc_sdp_local.media_list[i].attributes))
{
cn := sizeof(vc_sdp_local.media_list[i].attributes);
};
if (sizeof(vc_sdp_local.media_list[i].media_field.fmts)>1)
{
// select the first one
v_PT := vc_sdp_local.media_list[i].media_field.fmts[0];
vc_sdp_local.media_list[i].media_field.fmts := {v_PT};
for (j :=0; j<cn; j:=j+1)
{
if (ischosen(vc_sdp_local.media_list[i].attributes[j].rtpmap))
{
if (v_PT == regexp(vc_sdp_local.media_list[i].attributes[j].rtpmap.attr_value, "[ \t]#(0,)([/d]+)*", 0))
{
v_rtpmap := vc_sdp_local.media_list[i].attributes[j].
rtpmap.attr_value;
v_mediaAttributes[k] := {rtpmap := {attr_value := v_rtpmap}};
k := k+1;
} // else line is not copied
}
// simplified handling of status attributes (copy/keep status from peer):
// a) copy/keep SDP_attribute_curr (invert tags if applicable)
if (ischosen(vc_sdp_local.media_list[i].attributes[j].curr))
{
// invert local/remote status tags
if (vc_sdp_local.media_list[i].attributes[j].curr.statusType == "local")
{vc_sdp_local.media_list[i].attributes[j].curr.statusType := "remote"};
if (vc_sdp_local.media_list[i].attributes[j].curr.statusType == "remote")
{vc_sdp_local.media_list[i].attributes[j].curr.statusType := "local"};
// invert send/recv direction tags
if (vc_sdp_local.media_list[i].attributes[j].curr.direction == "send")
{vc_sdp_local.media_list[i].attributes[j].curr.direction := "recv"};
if (vc_sdp_local.media_list[i].attributes[j].curr.direction == "recv")
{vc_sdp_local.media_list[i].attributes[j].curr.direction := "send"};
}
// b) copy/keep SDP_attribute_des (keep strength, invert tags if applicable)
else if (ischosen(vc_sdp_local.media_list[i].attributes[j].des))
{
// invert local/remote status tags
if (vc_sdp_local.media_list[i].attributes[j].des.statusType == "local")
{vc_sdp_local.media_list[i].attributes[j].des.statusType := "remote"};
if (vc_sdp_local.media_list[i].attributes[j].des.statusType == "remote")
{vc_sdp_local.media_list[i].attributes[j].des.statusType := "local"};
// invert send/recv direction tags
if (vc_sdp_local.media_list[i].attributes[j].des.direction == "send")
{vc_sdp_local.media_list[i].attributes[j].des.direction := "recv"};
if (vc_sdp_local.media_list[i].attributes[j].des.direction == "recv")
{vc_sdp_local.media_list[i].attributes[j].des.direction := "send"};
}
// c) simplification: assume no SDP_attribute_conf
else if (ischosen(vc_sdp_local.media_list[i].attributes[j].conf))
{
// todo: handle SDP_attribute_conf
}
else
{
// simple copy of attribute
v_mediaAttributes[k] := vc_sdp_local.media_list[i].attributes[j];
k := k+1;
}
}
vc_sdp_local.media_list[i].attributes := v_mediaAttributes;
}
}
// add handling of prenegotiation, change ports if required etc.
//if prenegotiation...
}
/**
* @desc reject SDP offer by setting media ports to 0
*
*/
function f_reject_SDP_offer() runs on SipComponent
{
var integer mn, i;
f_copy_SDP(); // TO BE DONE with more details!
//increase session version
vc_sdp_local.origin.session_version := int2str(str2int(vc_sdp_local.origin.session_version)+1);
// if more than one codec, select the firs one
mn:= sizeof(vc_sdp_local.media_list);
for (i :=0; i < mn; i := i+1)
{
vc_sdp_local.media_list[i].media_field.ports := {0, omit};
vc_sdp_local.media_list[i].attributes := omit; //{};
};
}
* @desc copies SDP message elements from remote to local component variable:
* - bandwidth
* - session version (will be incremented)
* - media list
* modify the direction attribute of an SDP media list entry within an SDP message (vc_sdp_local)
* @param p_medianum list position number of the media (if value 0 identifies first media list element)
* @param p_direction the new direction attribute to be included in the media entry
function f_SIP_modMediaDirection(integer p_medianum, template SDP_attribute p_direction) runs on SipComponent
{
var boolean v_set_direction; // flag indicates if direction attribute has been modified
var integer v_mn := 0; // length of media list (number of entries)
var integer v_cn := 0; // number of attributes of a media entry
var integer i, j, k := 0;
var SDP_attribute_list v_mediaAttributes := {}; // collect the media attributes (to be assigned at end of function)
f_copy_SDP(); // copy SDP session bandwidth and media list from remote to local component variable
// increment session version
vc_sdp_local.origin.session_version := int2str(str2int(vc_sdp_local.origin.session_version)+1);
// if more than one codec, select the first one
v_mn:= sizeof(vc_sdp_local.media_list);
if (p_medianum == 0) //specific media requested
{
p_medianum := 1; // start checking from first media
};
if (p_medianum > 0) //specific media requested
{
if (not(p_medianum > v_mn))
{v_mn := p_medianum}
};
// handling of media list elements
for (i :=0; i < v_mn; i := i+1)
{
v_cn := 0; // initialize the number of attributes of the media list entry
if (ispresent(vc_sdp_local.media_list)) //media_list is optional
{
// log("vc_sdp_local.media_list[i] ",vc_sdp_local.media_list[i]);
if (ispresent(vc_sdp_local.media_list[i].attributes))
{
v_cn := sizeof(vc_sdp_local.media_list[i].attributes);
};
v_set_direction := false;
//if (sizeof(vc_sdp_local.media_list[i].media_field.fmts)>1)
// select the first one
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
for (j :=0; j<v_cn; j:=j+1)
{
if (ischosen(vc_sdp_local.media_list[i].attributes[j].recvonly)
or ischosen(vc_sdp_local.media_list[i].attributes[j].sendonly)
or ischosen(vc_sdp_local.media_list[i].attributes[j].inactive)
or ischosen(vc_sdp_local.media_list[i].attributes[j].sendrecv))
{
v_mediaAttributes[k] := valueof(p_direction);
v_set_direction := true;
}
else // non-direction attributes will be copied
{
v_mediaAttributes[k] := vc_sdp_local.media_list[i].attributes[j];
k := k+1;
}
}
if (not v_set_direction)
{ v_mediaAttributes[k] := valueof(p_direction)};
vc_sdp_local.media_list[i].attributes := v_mediaAttributes;
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
}
// add handling of prenegotiation, change ports if required etc.
//if prenegotiation...
}
/**
* @desc modify session and media attributes direction
*
*/
function f_SIP_modSessionDirection(template SDP_attribute p_direction) runs on SipComponent
{
var boolean v_set_direction;
var integer v_mn:= 0, i:=0;
var SDP_attribute_list v_mediaAttributes := {};
if (ispresent(vc_sdp_local.attributes))
{ v_mn:= sizeof(vc_sdp_local.attributes);
for (i :=0; i < v_mn; i := i+1)
{//for every single attribute (that is not omit)
if (ischosen(vc_sdp_local.attributes[i].recvonly)
or ischosen(vc_sdp_local.attributes[i].sendonly)
or ischosen(vc_sdp_local.attributes[i].inactive)
or ischosen(vc_sdp_local.attributes[i].sendrecv))
{
v_mediaAttributes[i] := valueof(p_direction);
v_set_direction := true;
}
else // simple copy of attribute
{v_mediaAttributes[i] := vc_sdp_local.attributes[i]}
}
if (not v_set_direction) // if not sent before
{ v_mediaAttributes[v_mn] := valueof(p_direction)};
vc_sdp_local.attributes := v_mediaAttributes;
};
}
/**
* @desc c
*
*/
/*
*
* @desc check (from remote) and set (local) the session/media attribute lines on directions
* @param p_direction_in incoming SDP attribute that need to be checked
* @param p_direction_out SDP attribute that should be included in the SDP answer (to be returned to peer)
* @return
* @verdict
*/
function f_SIP_checksetSDPreqDirection(template SDP_attribute p_direction_in, template SDP_attribute p_direction_out) runs on SipComponent
{ var template SDP_attribute v_direction_out := p_direction_out;
// check incoming SDP attribute
if (not (ispresent(vc_request.messageBody) and f_check_attribute(vc_request.messageBody.sdpMessageBody,p_direction_in)))
{setverdict(fail);};
if (match(omit,p_direction_out))//not isvalue(v_direction_out))//MRO
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
{v_direction_out := f_get_attribute_answer(vc_request.messageBody.sdpMessageBody, p_direction_in);}
f_SIP_modMediaDirection(1, v_direction_out); // handling of attribute in media description
f_SIP_modSessionDirection(v_direction_out); // handling of attribute in session
}
/*
*
* @desc check (from remote) and set (local)the session/media attribute lines on directions
* @param p_direction_in attribute to be check
* @param p_direction_out attrubyte to be
* @return
* @verdict
*/
function f_SIP_checkSDPrespDirection(template SDP_attribute p_direction_in) runs on SipComponent
{
// check incoming SDP attribute
if (not (ispresent(vc_response.messageBody) and f_check_attribute(vc_response.messageBody.sdpMessageBody,p_direction_in)))
{setverdict(fail);};
}
/**
* @desc check media/attribute lines from remote
*
*/
function f_SIP_checkMediaDirection(integer p_medianum, template SDP_attribute p_direction) runs on SipComponent
return boolean
{
var integer v_mn, v_cn := 0, i, j;
var boolean v_result := false;
//increase session version
vc_sdp_remote.origin.session_version := int2str(str2int(vc_sdp_remote.origin.session_version)+1);
// if more than one codec, select the firs one
v_mn:= sizeof(vc_sdp_remote.media_list);
if (p_medianum == 0) //specific media requested
{
p_medianum := 1; // start checking from first media
};
if (p_medianum > 0) //specific media requested
{
if (p_medianum > v_mn) {return false}
else {v_mn := p_medianum}
};
for (i :=p_medianum-1; i < v_mn; i := i+1)
{
//for every single media
if (ispresent(vc_sdp_remote.media_list[i].attributes))
{
v_cn := sizeof(vc_sdp_remote.media_list[i].attributes);
log (v_cn);
};
if (sizeof(vc_sdp_remote.media_list[i].attributes)>0)
{
// select the first one
log(vc_sdp_remote.media_list[i].attributes);
for (j :=0; j<sizeof(vc_sdp_remote.media_list[i].attributes); j:=j+1)
{
log(vc_sdp_remote.media_list[i].attributes[j]);
if (ischosen(vc_sdp_remote.media_list[i].attributes[j].recvonly)
or ischosen(vc_sdp_remote.media_list[i].attributes[j].sendonly)
or ischosen(vc_sdp_remote.media_list[i].attributes[j].inactive)
or ischosen(vc_sdp_remote.media_list[i].attributes[j].sendrecv))
{
if (match(vc_sdp_remote.media_list[i].attributes[j],p_direction))
{ v_result := true; }
else { return false; }
}
//v_result := true; // TODO This is a shortcut since direction attributes are not decoded
}
}
}
return v_result
}
/**
* @desc copy media/attribute lines from remote to local SDP variable
*
*/
function f_copy_SDP() runs on SipComponent
if (ispresent(vc_sdp_remote.bandwidth))
{vc_sdp_local.bandwidth := vc_sdp_remote.bandwidth}
else {vc_sdp_local.bandwidth := {}};
if (ispresent(vc_sdp_remote.media_list))
{
// // cleaning of media before assignment
// if (ispresent(vc_sdp_local.media_list))
// {
// for (var integer i:=0; i<sizeof(vc_sdp_local.media_list); i:=i+1)
// {
// vc_sdp_local.media_list[i] := omit ;
// }
// };
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
vc_sdp_local.media_list := vc_sdp_remote.media_list;
}
}
}//end group SDPOperations
group AwaitingMessage {
/**
*
* @desc Function waiting for any MSG -request/response
*/
function f_awaitingAnyPassOnTimeout() runs on SipComponent
{
tc_wait.start(PX_SIP_TWAIT);
alt
{
[] SIPP.receive //TAU error if expect (*)
{
tc_wait.stop;
vc_boo_response:=true;
vc_boo_request:=true;
//setverdict(pass)
}
[] tc_wait.timeout
{
vc_boo_response:=false;
vc_boo_request:=false;
//setverdict (pass)
}
}
} //end f_awaitingResponsePassOnTimeout
/**
*
* @desc Function waiting for no MSG -request/response
*/
function f_awaitingNonePassOnTimeout() runs on SipComponent
{
tc_wait.start(PX_SIP_TWAIT);
alt
{
[] SIPP.receive
{
tc_wait.stop;
setverdict(fail);
}
[] tc_wait.timeout
{
setverdict (pass);
}
}
} //end f_awaitingResponsePassOnTimeout
/**
*
* @desc function awaits REGISTER
* @param p_register expected REGISTER request
*/
function f_awaitingREGISTER(in template REGISTER_Request p_register) runs on SipComponent
{
var Request v_request;
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
tc_resp.start(PX_SIP_TRESP);
alt
{
[] SIPP.receive(p_register)-> value v_request sender vc_sent_label
{
tc_resp.stop;
f_setHeadersOnReceiptOfREGISTER(v_request);
}
}
}
/**
*
* @desc function awaits SUBSCRIBE
* @param p_register expected SUBSCRIBE request
*/
function f_awaitingSUBSCRIBE(in template SUBSCRIBE_Request p_register) runs on SipComponent
{
var Request v_request;
tc_resp.start(PX_SIP_TRESP);
alt
{
[] SIPP.receive(p_register)-> value v_request sender vc_sent_label
{
tc_resp.stop;
f_setHeadersOnReceiptOfSUBSCRIBE(v_request);
}
}
}
/**
*
* @desc function awaits REGISTER and sends a 200 OK response
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
* @param p_reply flag used to avoid the 200OK response sending
*/
function f_awaitingREGISTER_sendReply(in template REGISTER_Request p_register, in boolean p_reply) runs on SipComponent
{
var Request v_request;
tc_resp.start(PX_SIP_TRESP);
alt
{
[] SIPP.receive(p_register)-> value v_request sender vc_sent_label
{
tc_resp.stop;
vc_request := v_request;
f_setHeadersOnReceiptOfREGISTER(v_request);
//Answer to the Request
if (p_reply) {f_send200OK();};
}
}
}
/**
*
* @desc Function waiting for a 200 OK response
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
* @param p_cSeq_s current cSeq expectation
*/
function f_awaitingOkResponse(inout CSeq p_cSeq_s) runs on SipComponent
{
tc_ack.start(PX_SIP_TACK);
alt
{
[] SIPP.receive (mw_Response_Base(c_statusLine200, vc_callId, p_cSeq_s)) -> value vc_response
{
tc_ack.stop;
f_setHeadersOnReceiptOfResponse(vc_cSeq, vc_response);
setverdict(pass)
}
}
} //end awaitingOkResponse
/**
*
* @desc Function waiting for a response
* @param p_Response expected response message
*/
function f_awaitingResponse(in template Response p_Response) runs on SipComponent
{
tc_ack.start(PX_SIP_TACK);
alt
{
[] SIPP.receive (p_Response) -> value vc_response
{
tc_ack.stop;
f_setHeadersOnReceiptOfResponse(vc_cSeq, vc_response);
setverdict(pass)
}
}
} //end f_awaitingResponse
/**
*
* @desc Function waiting for a response
* @param p_Response expected response message
*/
function f_awaitingResponsePassOnTimeout(in template Response p_Response) runs on SipComponent
{
tc_ack.start(PX_SIP_TACK);
alt
{
[] SIPP.receive (p_Response) -> value vc_response
{
tc_ack.stop;
f_setHeadersOnReceiptOfResponse(vc_cSeq, vc_response);
vc_boo_response:=true;
//setverdict(pass)
}
[] tc_ack.timeout
{
vc_boo_response:=false;
//setverdict (pass)
}
}
} //end f_awaitingResponsePassOnTimeout
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
/**
* @desc await INFO request
* reply with 200 OK
*/
function f_awaitingINFO_sendReply(in template INFO_Request p_MSG) runs on SipComponent
{
var INFO_Request v_MSG;
tc_resp.start(PX_SIP_TRESP);
alt
{
[] SIPP.receive(p_MSG)-> value v_MSG sender vc_sent_label
{
tc_resp.stop;
f_setHeadersOnReceiptOfRequest(v_MSG);
//Answer to the INFO
f_send200OK();
}
}
} // end of f_awaitingINFO_sendReply
*
* @desc function awaiting for an incoming INVITE
* @param p_request expected message
*/
function f_awaitingINVITE(template INVITE_Request p_request) runs on SipComponent
{
var INVITE_Request v_INVITE_Request;
tc_wait.start(PX_SIP_TWAIT);
alt
{
[]SIPP.receive (p_request) -> value v_INVITE_Request sender vc_sent_label
{
tc_wait.stop;
vc_ignore_invite := true;
vc_first_recv:= true; // communication has started
f_setHeadersOnReceiptOfINVITE(v_INVITE_Request);
SIPP.send(m_Response_Base(c_statusLine100, vc_callId, vc_cSeq, vc_from, vc_to, vc_via)) to vc_sent_label;
}
}
} //end f_awaitingINVITE
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
/**
*
* @desc function awaiting for an incoming INVITE
* @param p_request expected message
*/
function f_awaitingINVITE_No100Response(template INVITE_Request p_request) runs on SipComponent
{
var INVITE_Request v_INVITE_Request;
tc_wait.start(PX_SIP_TWAIT);
alt
{
[]SIPP.receive (p_request) -> value v_INVITE_Request sender vc_sent_label
{
tc_wait.stop;
vc_ignore_invite := true;
vc_first_recv:= true; // communication has started
f_setHeadersOnReceiptOfINVITE(v_INVITE_Request);
//SIPP.send(m_Response_Base(c_statusLine100, vc_callId, vc_cSeq, vc_from, vc_to, vc_via)) to vc_sent_label;
}
}
} //end f_awaitingInviteRequest
/**
*
* @desc function awaiting for an incoming INVITE
* @param p_request expected message
*/
function f_awaitingINVITE_PassOnTimeout(template INVITE_Request p_request) runs on SipComponent
{
var INVITE_Request v_INVITE_Request;
tc_wait.start(PX_SIP_TWAIT);
alt
{
[]SIPP.receive (p_request) -> value v_INVITE_Request sender vc_sent_label
{
tc_wait.stop;
vc_ignore_invite := true;
vc_first_recv:= true; // communication has started
vc_boo_request := true;
f_setHeadersOnReceiptOfINVITE(v_INVITE_Request);
SIPP.send(m_Response_Base(c_statusLine100, vc_callId, vc_cSeq, vc_from, vc_to, vc_via)) to vc_sent_label;
}
[]tc_wait.timeout
{
vc_boo_request := false;
}
}
} //end f_awaitingInviteRequest
/**
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
* @desc function awaiting ACK request
*/
function f_awaitingACK(in template ACK_Request p_ACK) runs on SipComponent
{
var Request v_ACK_Request;
tc_ack.start(PX_SIP_TACK);
alt
{
[] SIPP.receive(p_ACK) -> value v_ACK_Request
{
tc_ack.stop;
}
// INVITE may be repeated and shall be ignored
[]SIPP.receive(mw_INVITE_Request_Base)
{
repeat;
}
// Ignore othe message
[] SIPP.receive
{
repeat;
}
}
} //end f_awaitingAckRequest
/**
*
* @desc function awaiting BYE and sending 200OK response
* @param p_BYE expected BYE
*/
function f_awaitingBYE(in template BYE_Request p_BYE) runs on SipComponent
{
var BYE_Request v_BYE_Request;
tc_resp.start(PX_SIP_TRESP);
alt
{
[]SIPP.receive (p_BYE) -> value v_BYE_Request sender vc_sent_label
{
tc_resp.stop;
vc_ignore_bye:= true;
f_setHeadersOnReceiptOfBYE(v_BYE_Request);
//f_send200OK();
}
}
} // end f_awaitingBYE
/**
*
* @desc function awaiting BYE and sending 200OK response
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
* @param p_BYE expected BYE
*/
function f_awaitingBYE_sendReply
(in template BYE_Request p_BYE) runs on SipComponent
{
var BYE_Request v_BYE_Request;
tc_resp.start(PX_SIP_TRESP);
alt
{
[]SIPP.receive (p_BYE) -> value v_BYE_Request sender vc_sent_label
{
tc_resp.stop;
vc_ignore_bye:= true;
f_setHeadersOnReceiptOfBYE(v_BYE_Request);
f_send200OK();
}
}
} // end f_awaitingBYE_sendReply
/**
*
* @desc function awaiting BYE and sending 200OK response
* @param p_BYE expected BYE
*/
function f_awaitingBYE_sendReply_PassOnTimeout(in template BYE_Request p_BYE) runs on SipComponent
{
var BYE_Request v_BYE_Request;
tc_resp.start(PX_SIP_TRESP);
alt
{
[]SIPP.receive (p_BYE) -> value v_BYE_Request sender vc_sent_label
{
tc_resp.stop;
vc_ignore_bye:= true;
vc_boo_request := true;
f_setHeadersOnReceiptOfBYE(v_BYE_Request);
f_send200OK();
}
[]tc_resp.timeout
{
vc_boo_request := false;
}
}
} // end f_awaitingBYE_sendReply_PassOnTimeout
/**
*
* @desc function awaiting CANCEL
* @param p_CANCEL expected CANCEL
*/
function f_awaitingCANCEL(in template CANCEL_Request p_CANCEL) runs on SipComponent
{
var CANCEL_Request v_MSG;
tc_resp.start(PX_SIP_TRESP);
alt
{
[]SIPP.receive (p_CANCEL) -> value v_MSG sender vc_sent_label
{
tc_resp.stop;
f_setHeadersOnReceiptOfRequest(v_MSG);
}
}
} // end f_awaitingCANCEL
/**
* @desc await MESSAGE request
*/
function f_awaitingMESSAGE(in template MESSAGE_Request p_MSG) runs on SipComponent
{
var MESSAGE_Request v_MSG;
tc_resp.start(PX_SIP_TRESP);
alt
{
[] SIPP.receive(p_MSG)-> value v_MSG sender vc_sent_label
{
tc_resp.stop;
f_setHeadersOnReceiptOfRequest(v_MSG);
//Answer to the MESSAGE
//f_send200OK();
}
}
} // end of f_awaitingMESSAGE
/**
* @desc await MESSAGE request
* reply with 200 OK
*/
function f_awaitingMESSAGE_sendReply() runs on SipComponent
{
var MESSAGE_Request v_MSG;
tc_resp.start(PX_SIP_TRESP);
alt
{
[] SIPP.receive(mw_MESSAGE_Request_Base(vc_callId))-> value v_MSG sender vc_sent_label
{
tc_resp.stop;
f_setHeadersOnReceiptOfRequest(v_MSG);
//Answer to the MESSAGE
f_send200OK();
}
}
} // end of f_awaitingMESSAGE_sendReply
/**
* @desc await MESSAGE request
*/
function f_awaitingMESSAGE_sendReply_PassOnTimeout(in template MESSAGE_Request p_MSG) runs on SipComponent
{
var MESSAGE_Request v_MSG;
tc_resp.start(PX_SIP_TRESP);
alt
{
[] SIPP.receive(p_MSG)-> value v_MSG sender vc_sent_label
{
tc_resp.stop;
f_setHeadersOnReceiptOfRequest(v_MSG);
//Answer to the MESSAGE
//f_send200OK();
vc_boo_request := true;
f_send200OK();
//setverdict (pass);
}
[] tc_resp.timeout
{
vc_boo_request := false;
//setverdict (pass);
}
}
} // end of f_awaitingMESSAGE_PassOnTimeout
/**
* @desc await NOTIFY request
* reply with 200 OK
*/
function f_awaitingNOTIFY_sendReply(in template NOTIFY_Request p_MSG) runs on SipComponent
{
var NOTIFY_Request v_MSG;
tc_resp.start(PX_SIP_TRESP);
alt
{
[] SIPP.receive(p_MSG)-> value v_MSG sender vc_sent_label
{
tc_resp.stop;
f_setHeadersOnReceiptOfRequest(v_MSG);
//Answer to the NOTIFY
f_send200OK();
}
}
} // end of f_awaitingNOTIFY_sendReply
/**
* @desc await PRACK request
* reply with 200 OK
*/
function f_awaitingPRACK_sendReply(in template PRACK_Request p_MSG) runs on SipComponent
{
var PRACK_Request v_MSG;
tc_resp.start(PX_SIP_TRESP);
alt
{
[] SIPP.receive(p_MSG)-> value v_MSG sender vc_sent_label
{
tc_resp.stop;
f_setHeadersOnReceiptOfRequest(v_MSG);
//Answer to the PRACK
f_send200OK();
}
}
} // end of f_awaitingPRACK_sendReply
/**
* @desc await PUBLISH request
* reply with 200 OK
*/
function f_awaitingPUBLISH_sendReply(in template PUBLISH_Request p_MSG) runs on SipComponent
{
var PUBLISH_Request v_MSG;
tc_resp.start(PX_SIP_TRESP);
alt
{
[] SIPP.receive(p_MSG)-> value v_MSG sender vc_sent_label
{
tc_resp.stop;
f_setHeadersOnReceiptOfRequest(v_MSG);
//Answer to the PUBLISH
f_send200OK();
}
}
} // end of f_awaitingPUBLISH_sendReply
/**
* @desc await UPDATE request
*/
function f_awaitingUPDATE(in template UPDATE_Request p_MSG) runs on SipComponent
{
var UPDATE_Request v_MSG;
tc_resp.start(PX_SIP_TRESP);
alt
{
[] SIPP.receive(p_MSG)-> value v_MSG sender vc_sent_label
{
tc_resp.stop;
f_setHeadersOnReceiptOfRequest(v_MSG);
}
}
} // end of f_awaitingUPDATE
/**
* @desc await UPDATE request
* reply with 200 OK
*/
function f_awaitingUPDATE_sendReply(in template UPDATE_Request p_MSG) runs on SipComponent
{
var UPDATE_Request v_MSG;
tc_resp.start(PX_SIP_TRESP);
alt
{
[] SIPP.receive(p_MSG)-> value v_MSG sender vc_sent_label
{
tc_resp.stop;
f_setHeadersOnReceiptOfRequest(v_MSG);
//Answer to the UPDATE
f_send200OK();
}
}
} // end of f_awaitingUPDATE_sendReply
/**
* @desc await REFER request
*/
function f_awaitingREFER(in template REFER_Request p_MSG) runs on SipComponent
{
var REFER_Request v_MSG;
tc_resp.start(PX_SIP_TRESP);
alt
{
[] SIPP.receive(p_MSG)-> value v_MSG sender vc_sent_label
{
tc_resp.stop;
f_setHeadersOnReceiptOfRequest(v_MSG);
}
}
} // end of f_awaitingUPDATE
} // end AwaitingMessage
group SendMessage {
/**
*
* @desc send ACK message, update the route and recordRoute header fields depending on boolean flags
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
* @param p_request template of the message to be sent
*/
function f_SendACK(template ACK_Request p_request) runs on SipComponent
{
p_request.msgHeader.route := f_route(); // update the route header field depending on vc_boo_route
// n/a p_request.msgHeader.recordRoute := f_recordroute(); // update the route header field depending on vc_boo_route
SIPP.send(p_request) to vc_sent_label;
}
/**
*
* @desc send BYE message, update the route and recordRoute header fields depending on boolean flags
* @param p_request template of the message to be sent
*/
function f_SendBYE(template BYE_Request p_request) runs on SipComponent
{
f_setHeadersGeneral(vc_cSeq, "BYE"); // cseq, contact, branch, via
p_request.msgHeader.route := f_route(); // update the route header field depending on vc_boo_route
p_request.msgHeader.recordRoute := f_recordroute(); // update the route header field depending on vc_boo_route
SIPP.send(p_request) to vc_sent_label;
}
/**
*
* @desc send CANCEL message
* @param p_request template of the message to be sent
*/
function f_SendCANCEL(template CANCEL_Request p_request) runs on SipComponent
{
f_setHeadersGeneral(vc_cSeq, "CANCEL"); // cseq, contact, branch, via
SIPP.send(p_request) to vc_sent_label;
}
/**
*
* @desc send INFO message
* @param p_request template of the message to be sent
*/
function f_SendINFO(template INFO_Request p_request) runs on SipComponent
{
f_setHeadersGeneral(vc_cSeq, "INFO"); // cseq, contact, branch, via
SIPP.send(p_request) to vc_sent_label;
}
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
/**
*
* @desc send INVITE message
* @param p_request template of the message to be sent
*/
function f_SendINVITE(template INVITE_Request p_request) runs on SipComponent
{
vc_requestFor407 := valueof(p_request);
SIPP.send(p_request) to vc_sent_label;
if(PX_SIP_INVITE_AUTHENTICATION_ENABLED) {a_altstep_401or407();};
}
/**
*
* @desc send PRACK message
* @param p_request template of the message to be sent
*/
function f_SendPRACK(template PRACK_Request p_request) runs on SipComponent
{
f_setHeadersGeneral(vc_cSeq, "PRACK"); // cseq, contact, branch, via
vc_rAck := valueof(m_RAck(vc_response.msgHeader.rSeq.responseNum, vc_cSeq.seqNumber, vc_cSeq.method));
SIPP.send(p_request) to vc_sent_label;
}
/**
*
* @desc send PUBLISH message
* @param p_request template of the message to be sent
*/
function f_SendPUBLISH(template PUBLISH_Request p_request) runs on SipComponent
{
SIPP.send(p_request) to vc_sent_label;
}
/**
*
* @desc send REGISTER message
* @param p_request template of the message to be sent
*/
function f_SendREGISTER(template REGISTER_Request p_request) runs on SipComponent
{
SIPP.send(p_request) to vc_sent_label;
}
/**
*
* @desc send SUBSCRIBE message
* @param p_request template of the message to be sent
*/
function f_SendSUBSCRIBE(template SUBSCRIBE_Request p_request) runs on SipComponent
{
SIPP.send(p_request) to vc_sent_label;
}
/**
*
* @desc send UPDATE message
* @param p_request template of the message to be sent
*/
function f_SendUPDATE(template UPDATE_Request p_request) runs on SipComponent
{
f_setHeadersGeneral(vc_cSeq, "UPDATE"); // cseq, contact, branch, via
SIPP.send(p_request) to vc_sent_label;
if(PX_SIP_INVITE_AUTHENTICATION_ENABLED) {a_altstep_401or407();};
*
* @desc function send MESSAGE message
* @param p_request template of the message to be sent
*/
function f_SendMESSAGE(template MESSAGE_Request p_request) runs on SipComponent
{
SIPP.send(p_request) to vc_sent_label;
}
/**
*
* @desc function send NOTIFY message
* @param p_request template of the notify to be sent
*/
function f_SendNOTIFY(template NOTIFY_Request p_request) runs on SipComponent
{
SIPP.send(p_request) to vc_sent_label;
}
/**
*
* @desc send REFER message
* @param p_request template of the message to be sent
*/
function f_SendREFER(template REFER_Request p_request) runs on SipComponent
{
SIPP.send(p_request) to vc_sent_label;
}
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
/**
*
* @desc send 200 OK
*/
function f_send200OK() runs on SipComponent
{
f_sendResponse(m_Response_Base(c_statusLine200, vc_callId, vc_cSeq, vc_caller_From, vc_caller_To, vc_via));
}
/**
*
* @desc send response
* @param p_request template of the message to be sent
*/
function f_sendResponse(template Response p_response) runs on SipComponent
{
p_response.msgHeader.route := f_route(); // update the route header field depending on vc_boo_route
p_response.msgHeader.recordRoute := f_recordroute(); // update the route header field depending on vc_boo_route
SIPP.send(p_response) to vc_sent_label;
}
} // end SendMessage
group GlobalSteps {
/**
* @desc component initialization
* @param p_cSeq_s cSeq value to be assigned to the component variable
*/
function f_init_component(inout CSeq p_cSeq_s) runs on SipComponent
{
//Variables
vc_cSeq := p_cSeq_s;
//Defaults
vc_def_catchSyncStop := activate(a_Sip_catchSyncStop());
vc_default := activate (a_clearRegistration());
}
/**
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
* @desc component termination
*/
function f_terminate_component() runs on SipComponent
{
deactivate;
stop;
}
/**
*
* @desc setting of user parameters with PIXIT values
* @param p_user identifies the selected user configuration and location
*/
function f_init_userprofile(in integer p_user) runs on SipComponent
{
vc_userprofile.id := p_user;
select(p_user){
case (c_userProfile_SIP1_home) { //variant c_userProfile_SIP1_home
vc_userprofile.currPort := PX_SIP_TS1_PORT;
vc_userprofile.currIpaddr := PX_SIP_TS1_IPADDR;
vc_userprofile.contactPort := PX_SIP_TS1_PORT;
vc_userprofile.contactIpaddr := PX_SIP_TS1_IPADDR;
vc_userprofile.bearerIpaddr := PX_SIP_TS1_BEARER_IPADDR;
vc_userprofile.homeDomain := PX_SIP_TS1_LOCAL_DOMAIN;
vc_userprofile.publUsername := PX_SIP_TS1_LOCAL_USER;
vc_userprofile.qop := PX_SIP_SUT_UE1_QOP;
vc_userprofile.privUsername := PX_SIP_SUT_UE1_USERNAME;
vc_userprofile.passwd := PX_SIP_SUT_UE1_PASSWD;
vc_userprofile.registrarDomain := PX_SIP_SUT_REGISTRAR_DOMAIN;
}
case (c_userProfile_SIP2_home) { //variant c_userProfile_SIP2_home
vc_userprofile.currPort := PX_SIP_TS2_PORT;
vc_userprofile.currIpaddr := PX_SIP_TS2_IPADDR;
vc_userprofile.contactPort := PX_SIP_TS2_PORT;
vc_userprofile.contactIpaddr := PX_SIP_TS2_IPADDR;
vc_userprofile.bearerIpaddr := PX_SIP_TS2_BEARER_IPADDR;
vc_userprofile.homeDomain := PX_SIP_TS2_LOCAL_DOMAIN;
vc_userprofile.publUsername := PX_SIP_TS2_LOCAL_USER;
vc_userprofile.qop := PX_SIP_SUT_UE2_QOP;
vc_userprofile.privUsername := PX_SIP_SUT_UE2_USERNAME;
vc_userprofile.passwd := PX_SIP_SUT_UE2_PASSWD;
vc_userprofile.registrarDomain := PX_SIP_SUT_REGISTRAR_DOMAIN;
}
}
}
/**
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
* @desc function waits for particular time that allows the SUT to return to idle state
*/
function f_awaitSUTidle() runs on SipComponent
{
vc_ignore4xx := true; // allow 4xx in default
tc_noAct.start;
alt {
[] tc_noAct.timeout{}
}
}
/**
*
* @desc function waits for particular time before next expected message
*/
function f_wait(float p_time) runs on SipComponent
{
tc_noAct.start(p_time);
alt {
[] tc_noAct.timeout{}
}
}
/**
*
* @desc function cause termination of a PTC
* @param p_syncPoint dummy parameter (copied from the common lib)
*/
function f_check2Null(in charstring p_syncPoint) runs on SipComponent
{
//!= pass does not work, because in case of "none" execution shall continue
if (getverdict == inconc or getverdict == fail){
log("**** f_check2Null: Verdict evaluated to fail or inconc. Stopping test execution now ");
f_selfOrClientSyncAndVerdict (p_syncPoint, e_error) ;
}//end if
}
rennoch
committed
/*
rennoch
committed
* @desc original copied from older LibCommon_VerdictControl
*/
function f_getVerdict()
return FncRetCode {
var FncRetCode v_ret := e_error;
if (getverdict == pass or getverdict == none) {
v_ret := e_success;
}
return v_ret;
}
}// end group GlobalSteps
group Registration {
/**
*
* @desc registration and authentication with MD5
* @param p_cSeq_s cseq parameter
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
* @param p_register register template
* @param p_auth flag indicating if authentication is needed
*/
function f_Registration(inout CSeq p_cSeq_s, template REGISTER_Request p_register, in boolean p_auth) runs on SipComponent
{
var REGISTER_Request v_request := valueof(p_register);
if (PX_SIP_REGISTRATION)
{
f_setHeaders_REGISTER(p_cSeq_s);
f_SendREGISTER(v_request); //LibSip
//awaiting of 401 and sending 2nd REGISTER and awaiting 200 OK REGISTER
if (p_auth)
{
// receiving 401 Unauthorized response.
// and Re-send REGISTER request with Authorization header
tc_ack.start(PX_SIP_TACK);
alt
{
[] SIPP.receive (mw_Response_Base(c_statusLine401, vc_callId, p_cSeq_s)) -> value vc_response
{
tc_ack.stop;
// set headers via, cseq and authorization
f_setHeaders_2ndREGISTER();
// Re-send protected REGISTER
f_SendREGISTER(v_request);//LibSip
// awaiting 200 OK REGISTER
f_awaitingOkResponse(p_cSeq_s);
f_getServiceRouteMapIntoRouteInRegistration(p_cSeq_s, vc_response);
}
[] SIPP.receive (mw_Response_Base(c_statusLine200, vc_callId, p_cSeq_s))
{
tc_ack.stop;
log ("Authorization was not requested as expected");
setverdict(inconc)
}
}
}
else
{
f_awaitingOkResponse(p_cSeq_s);
f_getServiceRouteMapIntoRouteInRegistration(p_cSeq_s, vc_response);
}
};
}//end function f_Registration
/**
*
* @desc remove registration
* @param p_cSeq_s cseq parameter
*/
function f_RemoveRegistration(inout CSeq p_cSeq) runs on SipComponent
{
var CommaParam_List v_challenge;
var Credentials v_credentials;
var REGISTER_Request v_request := valueof(m_REGISTER_Request_expires(vc_requestUri, vc_callId,
p_cSeq, vc_from, vc_to, vc_via, vc_contact, vc_authorization, "0"));
if (PX_SIP_REGISTRATION)
{
f_setHeaders_deREGISTER(p_cSeq);
f_SendREGISTER(v_request);
if (PX_SIP_REGISTER_AUTHENTICATION_ENABLED)
{
// receiving 401 Unauthorized response.
// and Re-send REGISTER request with Authorization header
tc_ack.start(PX_SIP_TACK);
alt
{
[] SIPP.receive (mw_Response_Base(c_statusLine401, vc_callId, p_cSeq)) -> value vc_response
{
tc_ack.stop;
// set headers via, cseq and authorization
f_setHeaders_2ndREGISTER();
// Re-send protected REGISTER
f_SendREGISTER(v_request);//LibSip
// awaiting 200 OK REGISTER
f_awaitingOkResponse(p_cSeq);
f_getServiceRouteMapIntoRouteInRegistration(p_cSeq, vc_response);
}
[] SIPP.receive (mw_Response_Base(c_statusLine200, vc_callId, p_cSeq))
{
tc_ack.stop;
log ("Authorization was not requested as expected");
setverdict(inconc)
}
}
}
else
{
f_awaitingOkResponse(p_cSeq);
}
}
} // end f_RemoveRegistration
/**
*
* @desc remove registration without authorization
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
* @param p_cSeq_s cseq parameter
*/
function f_RemoveRegistration_wo_authorization(inout CSeq p_cSeq) runs on SipComponent
{
var SemicolonParam_List tmp_params;
if (PX_SIP_REGISTRATION)
{
f_setHeaders_deREGISTER(p_cSeq);
f_SendREGISTER(m_REGISTER_Request_expires(vc_requestUri, vc_callIdReg, p_cSeq,
vc_from, vc_to, vc_via, vc_contact, vc_authorization, "0" ));
f_awaitingOkResponse(p_cSeq);
}
} // end f_RemoveRegistration_wo_authorization
}//end group Registration
group Subscription {
/**
*
* @desc UE send subscrbe, await on 200 OK, await notify and send 200 OK
* @param p_cSeq_s cseq parameter
* @param p_register subscribe template
*/
function f_Subscription(inout CSeq p_cSeq_s, template SUBSCRIBE_Request p_subscribe) runs on SipComponent
{
f_setHeaders_SUBSCRIBE(p_cSeq_s);
//send SUBSCRIBE
f_SendSUBSCRIBE(p_subscribe);
// awaiting 200 OK SUBSCRIBE
f_awaitingOkResponse(p_cSeq_s);
//await NOTIFY and send reply 200 OK
f_awaitingNOTIFY_sendReply(mw_NOTIFY_Request_Base(vc_callId));
}//end function f_Subscription
/**
*
* @desc UE send subscrbe, await on 200 OK, await notify and send 200 OK
* @param p_cSeq_s cseq parameter
* @param p_register subscribe template
*/
function f_SubscriptionWithNotification(inout CSeq p_cSeq_s, template SUBSCRIBE_Request p_subscribe, template NOTIFY_Request p_notify) runs on SipComponent
{
f_setHeaders_SUBSCRIBE(p_cSeq_s);
//send SUBSCRIBE
f_SendSUBSCRIBE(p_subscribe);
// awaiting 200 OK SUBSCRIBE
f_awaitingOkResponse(p_cSeq_s);
//await NOTIFY and send reply 200 OK
f_awaitingNOTIFY_sendReply(p_notify);
}//end function f_Subscription
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
}//end group Subscription
group Preambles {
/**
*
* @desc Set variables and default initialization for user profile
* @param p_userprofile user profile of call
* @param p_cSeq_s cseq parameter
*/
function f_SIP_preamble_woREG(in integer p_userprofile, inout CSeq p_cSeq_s) runs on SipComponent
{
//varables and altsteps
f_init_component(p_cSeq_s);
//Preamble
f_init_userprofile(p_userprofile); // assignment of PIXIT values to component variable
vc_sdp_local := valueof(m_SDP_bandwidth(valueof(m_media_dynPT(PX_SIP_SDP_dyn, PX_SIP_SDP_encoding)), vc_userprofile));
}
/**
*
* @desc Set variables and default initialization for user profile and handle registration and authentication with MD5
* @param p_userprofile user profile of call
* @param p_cSeq_s cseq parameter
* @param p_register register template
*/
function f_SIP_preamble_withREG(in integer p_userprofile, inout CSeq p_cSeq_s, template REGISTER_Request p_register) runs on SipComponent
{
//preamble
f_SIP_preamble_woREG(p_userprofile, p_cSeq_s);
//Registration, Awaiting
f_Registration(p_cSeq_s, p_register, PX_SIP_REGISTER_AUTHENTICATION_ENABLED);
}
}// end group Preambles
group Postambles {
/**
*
* @desc function send BYE and awaits reponse
* @param p_CallId parameter for outgoing BYE
* @param p_cSeq parameter for outgoing BYE
* @param p_from parameter for outgoing BYE
* @param p_to parameter for outgoing BYE
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
* @param p_reqHostPort parameter for outgoing BYE
*/
function f_terminateCall(SipUrl p_requestUri, CallId p_CallId, inout CSeq p_cSeq, From p_from,
template To p_to) runs on SipComponent
{
// Sending of a BYE request to release the call and expect a final response
f_SendBYE(m_BYE_Request_cause(p_requestUri, p_CallId, p_cSeq, p_from, valueof(p_to), vc_via, PX_SIP_BYE_CAUSE));
tc_resp.start(PX_SIP_TRESP);
alt
{
[] SIPP.receive (mw_Response_Base(mw_statusLine1xx, p_CallId, p_cSeq))
{
repeat;
}
[] SIPP.receive (mw_Response_Base(mw_statusLineFinal, p_CallId, p_cSeq))
{
tc_resp.stop;
}
[] tc_resp.timeout
{
stop
}
}
} // end function f_terminateCall
function f_cancelCall(template CANCEL_Request p_request)
runs on SipComponent
{
// This function is called to bring back the IUT in idle condition
// in case of errors or unexpected behaviour.
// Sending of a CANCEL request with the same Cseq
f_SendCANCEL(p_request);
tc_resp.start(PX_SIP_TRESP);
alt
{
[] SIPP.receive (mw_Response_Base(c_statusLine200, vc_callId, vc_cSeq))
{
tc_resp.stop;
}
}
}
} // end group Postambles
group SipChecks
{
/*
* @desc check the presence of conversation at SIP side
*
*/
function f_check_Conversation() runs on SipComponent
{
var boolean v_result;
var charstring v_question := "confirm if conversation at SIP port";
if (PX_SIP_CheckConversation) {
opPort.call(s_SIP_conversation:{v_question, -})
{[] opPort.getreply(s_SIP_conversation:{-, true}) {}
[] opPort.getreply(s_SIP_conversation:{-, false})
{all timer.stop;
setverdict(fail);
syncPort.send(m_syncClientStop);
stop;}
}
}
f_selfOrClientSyncAndVerdict(c_uPlane, f_getVerdict()); // Note: implemented in test bodies
return
} // end of f_check_Conversation
/*
* @desc check the presence of conversation at SIP side
*
*/
function f_check_Ringing() runs on SipComponent
{
var boolean v_result;
var charstring v_question := "confirm if ringing at SIP port";
if (PX_SIP_CheckRinging) {
opPort.call(s_SIP_ringing:{v_question, -})
{[] opPort.getreply(s_SIP_ringing:{-, true}) {}
[] opPort.getreply(s_SIP_ringing:{-, false})
{all timer.stop;
setverdict(fail);
syncPort.send(m_syncClientStop);
stop;}
}
}
f_selfOrClientSyncAndVerdict(c_Ringing, f_getVerdict());
return
} // end of f_check_Ringing
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
/*
* @desc check the announcement at SIP side (UE A)
*
*/
function f_check_AnnouncementUE_A() runs on SipComponent
{
var boolean v_result;
var charstring v_question := "confirm if announcement at UE A";
if (PX_SIP_CheckConversation) {
opPort.call(s_SIP_announcementA:{v_question, -})
{[] opPort.getreply(s_SIP_announcementA:{-, true}) {}
[] opPort.getreply(s_SIP_announcementA:{-, false})
{all timer.stop;
setverdict(fail);
syncPort.send(m_syncClientStop);
stop;}
}
}
f_selfOrClientSyncAndVerdict(c_annoucA, f_getVerdict());
return
} // end of f_check_AnnouncementUE_A
/*
* @desc check the announcement at SIP side (UE B)
*
*/
function f_check_AnnouncementUE_B() runs on SipComponent
{
var boolean v_result;
var charstring v_question := "confirm if announcement at UE B";
if (PX_SIP_CheckConversation) {
opPort.call(s_SIP_announcementB:{v_question, -})
{[] opPort.getreply(s_SIP_announcementB:{-, true}) {}
[] opPort.getreply(s_SIP_announcementB:{-, false})
{all timer.stop;
setverdict(fail);
syncPort.send(m_syncClientStop);
stop;}
}
}
f_selfOrClientSyncAndVerdict(c_annoucB, f_getVerdict());
return
} // end of f_check_AnnouncementUE_B
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
/*
* @desc check the announcement at SIP side
*
*/
function f_check_Announcement() runs on SipComponent
{
var boolean v_result;
var charstring v_question := "confirm if announcement at SIP side";
if (PX_SIP_CheckConversation) {
opPort.call(s_SIP_announcement:{v_question, -})
{[] opPort.getreply(s_SIP_announcement:{-, true}) {}
[] opPort.getreply(s_SIP_announcement:{-, false})
{all timer.stop;
setverdict(fail);
syncPort.send(m_syncClientStop);
stop;}
}
}
f_selfOrClientSyncAndVerdict(c_annouc, f_getVerdict());
return
} // end of f_check_Announcement
/*
* @desc check the Voice message at SIP side
*
*/
function f_check_VoiceMessage() runs on SipComponent
{
var boolean v_result;
var charstring v_question := "confirm if voice message at SIP side";
if (PX_SIP_CheckConversation) {
opPort.call(s_SIP_voiceMessage:{v_question, -})
{[] opPort.getreply(s_SIP_voiceMessage:{-, true}) {}
[] opPort.getreply(s_SIP_voiceMessage:{-, false})
{all timer.stop;
setverdict(fail);
syncPort.send(m_syncClientStop);
stop;}
}
}
f_selfOrClientSyncAndVerdict(c_voicem, f_getVerdict());
return
} // end of f_check_Announcement
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
/*
* @desc check the stop of media stream
*
*/
function f_check_MediaStopped() runs on SipComponent
{
var boolean v_result;
var charstring v_question := "confirm if media stream stopped";
if (PX_SIP_CheckConversation) {
opPort.call(s_SIP_mediastopped:{v_question, -})
{[] opPort.getreply(s_SIP_mediastopped:{-, true}) {}
[] opPort.getreply(s_SIP_mediastopped:{-, false})
{all timer.stop;
setverdict(fail);
syncPort.send(m_syncClientStop);
stop;}
}
}
f_selfOrClientSyncAndVerdict(c_uPlaneStop, f_getVerdict());
return
} // end of f_check_MediaStopped
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
}
group DefaultsTestStep
{
/**
* @desc This default handles receiving of the sync server
* STOP message and calls the RT HUT postamble. (copy from common lib)
*/
altstep a_Sip_catchSyncStop() runs on SipComponent
{
[] syncPort.receive(m_syncServerStop)
{
tc_sync.stop ;
log("**** a_Sip_catchSyncStop: Test component received STOP signal from MTC - going to IDLE state **** ");
//TODO complete postamble
f_terminate_component();
log("**** a_Sip_catchSyncStop: TEST COMPONENT NOW STOPPING ITSELF! **** ") ;
setverdict(inconc);
stop ;
}
}
/**
*
* @desc main default altstep to handle unexpected messages and timeout
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
* @verdict fail for all unexpected branches
*/
altstep a_clearRegistration() runs on SipComponent
{
var Response v_response;
var Request v_request;
[] any timer.timeout
{
setverdict(fail);
all timer.stop;
//TODO check how to solve release of call
//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
f_RemoveRegistration(vc_cSeq);
f_check2Null("");
}
// allow repeated INVITEs
[vc_ignore_invite] SIPP.receive(mw_INVITE_Request_Base)
{
repeat
}
// allow repeated BYEs after ack of the first BYE
[vc_ignore_bye] SIPP.receive (mw_BYE_Request_Base(?))
{
repeat
}
// allow 100 replies
[] SIPP.receive(mw_Response_Base(c_statusLine100,vc_callId, vc_cSeq))
{
repeat
}
// ignore 181 if flag is set (following TS 183004 §4.5.2.1)
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
[vc_ignore181] SIPP.receive(mw_Response_Base(c_statusLine181,vc_callId, vc_cSeq))-> value v_response sender vc_sent_label
{
f_setHeadersOnReceiptOfResponse(v_response.msgHeader.cSeq, v_response);
repeat;
}
// according to SIP chap.8.1.3.2
[] SIPP.receive(mw_Response_Base(c_statusLine183,vc_callId, vc_cSeq))
{
repeat;
}
// ignore 484 if flag is set
[vc_ignore484] SIPP.receive(mw_Response_Base(c_statusLine484,vc_callId, vc_cSeq))
{
repeat
}
[vc_ignore4xx] SIPP.receive(mw_Response_Base(mw_statusLine4xx,vc_callId, ?))-> value v_response sender vc_sent_label
{
f_setHeadersOnReceiptOfResponse(v_response.msgHeader.cSeq, v_response);
f_SendACK(m_ACK_Request_route(vc_requestUri, vc_callId, v_response.msgHeader.cSeq, vc_from, vc_to, vc_via, vc_route));
repeat
}
[vc_ignore200OKinv] SIPP.receive(mw_Response_Base(c_statusLine200, vc_callId, ?))
{
repeat
}
[] SIPP.receive(mw_INFO_Request_Base(vc_callId))->value v_request sender vc_sent_label
{
f_setHeadersOnReceiptOfRequest(v_request);
f_send200OK();
repeat
}
//awaiting of subscribe on proxy
[] SIPP.receive(mw_SUBSCRIBE_Request_Base)->value v_request sender vc_sent_label
{
f_setHeadersOnReceiptOfRequest(v_request);
f_send200OK();
f_setHeadersGeneral(vc_cSeq, "NOTIFY"); // cseq, contact, branch, via
f_SendNOTIFY(m_NOTIFY_Request_Base(vc_requestUri, vc_callId, vc_cSeq, vc_from, vc_to, vc_via));
f_awaitingOkResponse(vc_cSeq);
repeat
}
// unexpected BYE is acknowledged to avoid retransmissions
[] SIPP.receive(mw_BYE_Request_Base(?))-> value v_request sender vc_sent_label
{
setverdict(fail);
f_setHeadersOnReceiptOfRequest(v_request);
f_send200OK();
f_RemoveRegistration(vc_cSeq);
f_check2Null("");
}
// unexpected CANCEL is acknowledged to avoid retransmissions
[] SIPP.receive(mw_CANCEL_Request_Base(?))-> value v_request sender vc_sent_label
{
setverdict(fail);
f_setHeadersOnReceiptOfRequest(v_request);
//Answer to the CANCEL
f_send200OK();
f_RemoveRegistration(vc_cSeq);
f_check2Null("");
}
[] SIPP.receive
{
setverdict(fail);
all timer.stop;
f_SendCANCEL(m_CANCEL_Request_Base(vc_requestUri, vc_callId, vc_cSeq, vc_from, vc_cancel_To, vc_via )); // difference between registration state or transaction state
f_RemoveRegistration(vc_cSeq);
f_check2Null("");
}
}
/**
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
* @desc altstep handle authentication for INVITE message
*/
altstep a_altstep_401or407() runs on SipComponent {
[] any port.check (receive) {
var CommaParam_List v_challenge;
var Credentials v_Credentials;
var Response v_Response;
var Request v_Request := valueof (vc_requestFor407);
tc_ack.start (PX_SIP_TACK);
alt {
[] SIPP.receive (mw_Response_Base((c_statusLine401,c_statusLine407),
vc_callId,
vc_cSeq)) -> value v_Response {
tc_ack.stop;
// get tag from To header if available
vc_to := v_Response.msgHeader.toField;
if (vc_cSeq.method == "INVITE"){
// send ACK
f_SendACK(m_ACK_Request_Base(vc_requestUri, vc_callId, vc_cSeq, vc_from, vc_to, vc_via));
}
// resent the INVITE message with Proxyauthorization header include
// Extract challenge and calculate credentials for a response.
if (ischosen (v_Response
.msgHeader
.proxyAuthenticate
.challenge
.otherChallenge // instead of digestCln (changed by axr to comply to alcatel)
)) {
v_challenge :=
v_Response
.msgHeader
.proxyAuthenticate
.challenge
.otherChallenge.authParams;
v_Credentials :=
f_calculatecCredentials(vc_userprofile,
vc_requestFor407.msgHeader.cSeq.method,
v_challenge);
} else {
log ("No scheme in Proxy Authenticate header!!");
setverdict (inconc);
stop;
}
vc_branch := c_branchCookie & f_getRndTag();
vc_via := {
fieldName := VIA_E,
viaBody := {
valueof (m_ViaBody_currIpaddr(vc_branch, vc_userprofile))}
};
v_Request.msgHeader.via := vc_via;
// Increment CSeq sequence number of and add the credentials
// to the original saved INVITE message.
vc_cSeq.method := vc_requestFor407.msgHeader.cSeq.method;
vc_cSeq.seqNumber := vc_cSeq.seqNumber + 1;
v_Request.msgHeader.cSeq.seqNumber :=
vc_cSeq.seqNumber;
v_Request.msgHeader.proxyAuthorization.fieldName :=
PROXY_AUTHORIZATION_E;
v_Request.msgHeader.proxyAuthorization.credentials :=
{v_Credentials};
// Re-send the saved INVITE with Authorization header
// included.
SIPP.send (v_Request) to vc_sent_label;
}
}
}
}
} // end of group DefaultsTestStep
} // end module LibSip_Steps