Newer
Older
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
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
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
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
{
modifier:="AS",
bandwidth:=64
}
template SDP_bandwidth mw_bandwidth_rs:=
{
modifier:="RS",
bandwidth:=?
}
template SDP_bandwidth mw_bandwidth_rr:=
{
modifier:="RR",
bandwidth:=?
}
template SDP_media_field m_media_field(charstring p_media, integer p_portNum, charstring p_transport, charstring p_fmts) :=
{
media := p_media,
ports := { port_number := p_portNum, num_of_ports:=omit },
transport := p_transport,
fmts := { p_fmts }
}
template SDP_media_field mw_media_PCMU :=
{
media := c_audio,
ports := { port_number := ?, num_of_ports:=* },
transport := c_rtpAvp,
fmts := { "0" }
}
template SDP_media_field mw_media_PCMA :=
{
media := c_audio,
ports := { port_number := ?, num_of_ports:=* },
transport := c_rtpAvp,
fmts := { "8" }
}
template SDP_media_field mw_media_PCMA_U_DPT :=
{
media := c_audio,
ports := { port_number := ?, num_of_ports:=* },
transport := c_rtpAvp,
fmts := { * }
}
template SDP_media_field mw_media_T38 :=
{
media := c_image,
ports := { port_number := ?, num_of_ports:=* },
transport := pattern "*ptl", //udptl,tcptl
fmts := { "t38" }
}
template SDP_media_field mw_media_G722 :=
{
media := c_audio,
ports := { port_number := ?, num_of_ports:=* },
transport := "RTP/AVP",
fmts := { "9" }
}
template SDP_media_field mw_media_AMR_DPT :=
{
media := c_audio,
ports := { port_number := ?, num_of_ports:=* },
transport := c_rtpAvp,
fmts := { * }
}
template SDP_attribute m_attribute_sendonly := {sendonly:={}};
template SDP_attribute mw_attribute_sendonly := {sendonly:=*};
template SDP_attribute m_attribute_recvonly := {recvonly:={}};
template SDP_attribute mw_attribute_recvonly := {recvonly:=*};
template SDP_attribute m_attribute_sendrecv := {sendrecv:={}};
template SDP_attribute mw_attribute_sendrecv := {sendrecv:=*};
template SDP_attribute m_attribute_inactive := {inactive:={}};
template SDP_attribute mw_attribute_inactive := {inactive:=*};
template SDP_attribute mw_attribute_sendonly_inactive := (mw_attribute_sendonly,mw_attribute_inactive);
template SDP_attribute mw_attribute_sendrecv_recvonly_omit := (mw_attribute_sendrecv,mw_attribute_recvonly,omit);
template SDP_attribute m_attribute_AMR_DPT := { rtpmap := { attr_value := /*pattern "**/PX_SIP_SDP_dyn & " AMR" }};
template SDP_attribute m_attribute_CLEARMODE_DPT := {rtpmap := { attr_value := /*pattern "**/PX_SIP_SDP_dyn & " CLEARMODE/8000" }};
template SDP_attribute m_attribute_G722 := { rtpmap := { attr_value := "9 G722/8000" }};
template SDP_attribute m_attribute_PCMU := { rtpmap := { attr_value := "0 PCMU/8000" }};
template SDP_attribute m_attribute_PCMU_DPT := { rtpmap := { attr_value := /*pattern "**/PX_SIP_SDP_dyn & " PCMU/8000" }};
template SDP_attribute m_attribute_PCMA := { rtpmap := { attr_value := "8 PCMA/8000" }};
template SDP_attribute m_attribute_PCMA_DPT := { rtpmap := { attr_value := /*pattern "**/PX_SIP_SDP_dyn & " PCMA/8000" }};
template SDP_attribute m_attribute_T38 := { unknown := { name:=?, attr_value := pattern "*t38*" }};
template SDP_attribute m_attribute_curr (charstring p_preconditionType, charstring p_statusType, charstring p_direction):=
{
curr:={preconditionType := p_preconditionType,
statusType := p_statusType,
direction := p_direction}
};
template SDP_attribute mw_attribute_curr :=
{
curr := ?
};
template SDP_attribute m_attribute_des (charstring p_preconditionType, charstring p_strength, charstring p_statusType, charstring p_direction):=
{
des:={preconditionType := p_preconditionType,
strength := p_strength,
statusType := p_statusType,
direction := p_direction}
};
template SDP_attribute mw_attribute_des :=
{
des := ?
};
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
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
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
2221
2222
2223
2224
2225
2226
2227
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
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
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
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
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
2444
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
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
template SDP_attribute m_attribute_conf (charstring p_preconditionType, charstring p_statusType, charstring p_direction):=
{
conf:={preconditionType := p_preconditionType,
statusType := p_statusType,
direction := p_direction}
};
} // end group SDP_Fields
} // end group SDP_Templates
group MessageBodies {
template MessageBody m_MBody_SDP(template SDP_Message p_SDP):=
{
sdpMessageBody := p_SDP
};
template MessageBody m_MBody_XML(template XmlBody p_xmlBody):=
{
xmlBody := p_xmlBody
};
template MessageBody m_MBody_longPlainText:=
{
textplain := c_longMessageContent_1300Bytes
};
template MessageBody m_mBody_plainText(charstring p_plaitext):=
{
textplain := p_plaitext
};
template MessageBody m_MBody_MIMESdpXml(template SDP_Message p_sdp, template XmlBody p_xmlBody):=
{
mimeMessageBody := {boundary:="PX_SIP_MIME_Boundary",
mimeEncapsulatedList:= {
{content_type:="PX_SIP_SDP_ContentType",
content_disposition:=omit,
mime_encapsulated_part:={sdpMessageBody := p_sdp}},
{content_type:="PX_SIP_ISUP_ContentType",
content_disposition:=omit,
mime_encapsulated_part:={xmlBody := p_xmlBody}}
}
}
}
template MessageBody mw_MBody_SDP(template SDP_Message p_SDP):=
{
sdpMessageBody := p_SDP
};
template MessageBody mw_MBody_XML(template XmlBody p_xmlBody):=
{
xmlBody := p_xmlBody
};
template MessageBody mw_MBody_MIMESdpXml(template SDP_Message p_sdp, template XmlBody p_xmlBody):=
{
mimeMessageBody := {boundary:=?,
mimeEncapsulatedList:= {
{content_type:=?,
content_disposition:=*,
mime_encapsulated_part:={sdpMessageBody := p_sdp}},
{content_type:=?,
content_disposition:=*,
mime_encapsulated_part:={xmlBody := p_xmlBody}}
}
}
}
}
/*
*
* @desc group TemplatePreparationFunctions contain functions which are used for templates
*/
group TemplatePreparationFunctions {
group SDPlen_calculation {
/**
*
* @desc Calculation of SDP length
* @param p_mb contain sdp message
* @return sdp_lenght
*/
function f_SDPlength(SDP_Message p_mb) return integer
{
var integer v_result:=2; // due to empty line beginning of message body
var charstring v_auxstring;
v_result := 2+c_CRlen + lengthof(int2str(p_mb.protocol_version)); // "v="
v_result := v_result + 2+c_CRlen + lengthof(p_mb.origin.user_name & " " &
p_mb.origin.session_id & " " &
p_mb.origin.session_version & " " &
p_mb.origin.net_type & " " &
p_mb.origin.addr_type & " " &
p_mb.origin.addr
); // "o="
v_result := v_result + 2+c_CRlen + lengthof(p_mb.session_name); // "s="
if (ispresent(p_mb.information))
{v_auxstring:=p_mb.information; v_result := v_result + 2+c_CRlen + lengthof(v_auxstring);}; // "i= "
if (ispresent(p_mb.uri))
{v_auxstring:=p_mb.uri; v_result := v_result + 2+c_CRlen + lengthof(v_auxstring);}; // "u="
if (ispresent(p_mb.emails)) {
for (var integer i:=0; i<sizeof(p_mb.emails); i:=i+1)
{v_result := v_result + 2+c_CRlen + lengthof(p_mb.emails[i].addr_or_phone); // "e="
if (ispresent(p_mb.emails[i].disp_name))
{v_auxstring:=p_mb.emails[i].disp_name; v_result := v_result + 1 + lengthof(v_auxstring);};
};
};
if (ispresent(p_mb.phone_numbers)) {
for (var integer i:=0; i<sizeof(p_mb.phone_numbers); i:=i+1)
{v_result := v_result + 2+c_CRlen + lengthof(p_mb.phone_numbers[i].addr_or_phone); // "p= "
if (ispresent(p_mb.phone_numbers[i].disp_name))
{v_auxstring:=p_mb.phone_numbers[i].disp_name; v_result := v_result + 1 + lengthof(v_auxstring);};
};
};
if (ispresent(p_mb.connection))
{
var integer v_len_con0 := f_SDPlength_connection(p_mb.connection);
v_result := v_result + v_len_con0;
}; // "c="
if (ispresent(p_mb.bandwidth))
{
for (var integer i:=0; i<sizeof(p_mb.bandwidth); i:=i+1) { // "b= "
v_result := v_result + 2+c_CRlen + lengthof(p_mb.bandwidth[i].modifier & " ") +
lengthof(int2str(p_mb.bandwidth[i].bandwidth));
}
};
for (var integer i:=0; i<sizeof(p_mb.times); i:=i+1)
{
v_result := v_result + 2+c_CRlen + lengthof(p_mb.times[i].time_field.start_time & " " // "t="
& p_mb.times[i].time_field.stop_time);
if (ispresent(p_mb.times[i].time_repeat))
{
for (var integer j:=0; j<sizeof(p_mb.times[i].time_repeat[j]); j:=j+1)
{
v_result := v_result + 2+c_CRlen + lengthof(int2str(p_mb.times[i].time_repeat[j].repeat_interval.time)); // "r="
if (ispresent(p_mb.times[i].time_repeat[j].repeat_interval.unit))
{
v_auxstring:=p_mb.times[i].time_repeat[j].repeat_interval.unit;
v_result := v_result + 1 + lengthof(v_auxstring);
};
v_result := v_result + 1 + lengthof(int2str(p_mb.times[i].time_repeat[j].active.time));
if (ispresent(p_mb.times[i].time_repeat[j].active.unit))
{
v_auxstring:=p_mb.times[i].time_repeat[j].active.unit;
v_result := v_result + 1 + lengthof(v_auxstring);
};
for (var integer k:=0; j<sizeof(p_mb.times[i].time_repeat[j].offsets[k]); k:=k+1)
{
v_result := v_result + 1 + lengthof(int2str(p_mb.times[i].time_repeat[j].offsets[k].time));
if (ispresent(p_mb.times[i].time_repeat[j].offsets[k].unit))
{
v_auxstring:=p_mb.times[i].time_repeat[j].offsets[k].unit;
v_result := v_result + 1 + lengthof(v_auxstring);
};
}
}
};
};
if (ispresent(p_mb.timezone_adjustments))
{log("timezone adjustments have not been considered in SDP length calculation yet");
}; // "z="
if (ispresent(p_mb.key)) {
v_result := v_result + 2+c_CRlen + lengthof(p_mb.key.method); // "k= "
if (ispresent(p_mb.key.key))
{v_auxstring:=p_mb.key.key; v_result := v_result + 1 + lengthof(v_auxstring);};
};
if (ispresent(p_mb.attributes)) {
for (var integer i:=0; i<sizeof(p_mb.attributes); i:=i+1){ // "a= "
var integer v_len_con1 := f_SDPlength_attribute(p_mb.attributes[i]);
v_result := v_result + v_len_con1;
};
}; // "a="
if (ispresent(p_mb.media_list))
{
for (var integer i:=0; i<sizeof(p_mb.media_list); i:=i+1){ // "m= "
// for each media_field
//log("p_mb.media_list[i] ",p_mb.media_list[i]);
v_result := v_result + 2+c_CRlen + lengthof(p_mb.media_list[i].media_field.media)
+ 1 + lengthof(int2str(p_mb.media_list[i].media_field.ports.port_number));
if (ispresent(p_mb.media_list[i].media_field.ports.num_of_ports))
{v_result := v_result + 1 + lengthof(int2str(p_mb.media_list[i].media_field.ports.num_of_ports));};
v_result := v_result + 1 + lengthof(p_mb.media_list[i].media_field.transport);
for (var integer j:=0; j<sizeof(p_mb.media_list[i].media_field.fmts); j:=j+1){
v_result := v_result + 1 + lengthof(valueof(p_mb.media_list[i].media_field.fmts[j]));
}
if (ispresent(p_mb.media_list[i].information)) {
v_auxstring:=p_mb.media_list[i].information;
v_result := v_result + 2+c_CRlen + lengthof(v_auxstring); // "i= "
};
if (ispresent(p_mb.media_list[i].connections)) {
for (var integer j:=0; j<sizeof(p_mb.media_list[i].media_field.fmts); j:=j+1){
var integer v_len_con2 := f_SDPlength_connection(p_mb.media_list[i].connections[j]);
v_result := v_result + v_len_con2;
}; // end for
};
if (ispresent(p_mb.media_list[i].bandwidth)) { // "b= "
v_result := v_result + 2+c_CRlen + lengthof(p_mb.media_list[i].bandwidth.modifier)
+ 1 + lengthof(int2str(p_mb.media_list[i].bandwidth.bandwidth));
};
if (ispresent(p_mb.media_list[i].key)) { // "k= "
v_result := v_result + 1 + lengthof(p_mb.media_list[i].key.method);
if (ispresent(p_mb.media_list[i].key.key)) {
v_auxstring := p_mb.media_list[i].key.key;
v_result := v_result + 1 + lengthof(v_auxstring);
};
};
if (ispresent(p_mb.media_list[i].attributes)) {
for (var integer j:=0; j<sizeof(p_mb.media_list[i].attributes); j:=j+1){ // "a= "
var integer v_len_attr := f_SDPlength_attribute(p_mb.media_list[i].attributes[j]);
v_result := v_result + v_len_attr;
} // end for j
};
}; // end for i
}; // end if media_list
return v_result;
};//end function f_SDPlength
/**
*
* @desc Calculation of messagebody-textplain type length
* @param p_mb contain textplain message
* @return lenght
*/
function f_TextPlainLength(MessageBody p_mb) return integer
{
var integer v_result:=2;
v_result:=v_result+lengthof(p_mb.textplain);
return v_result;
};//end function f_SDPlength
/**
*
* @desc Calculation of Message Body length
* @param p_mb_par contain message body part
* @return message body length
*/
function f_MessageBodyLength(MessageBody p_mb_par) return integer {
var integer v_result:=0;
// assume SDP_Message ONLY in the message body
if (ischosen(p_mb_par.sdpMessageBody))
{
v_result := f_SDPlength(p_mb_par.sdpMessageBody);
};
/* TODO f_XMLlength and f_MIMElength
// assume XML_Message ONLY in the message body
if (ischosen(p_mb_par.xmlBody))
{
v_result := f_XMLlength(p_mb_par.xmlBody);
};
// assume MIME_Message in the message body
if (ischosen(p_mb_par.mimeMessageBody))
{
v_result := f_MIMElength(p_mb_par.mimeMessageBody);
};
*/
return v_result
};
function f_SDPlength_connection(SDP_connection p_element) return integer // "c="
{
var integer v_result:=0;
var charstring v_auxstring;
v_result := v_result + 2+c_CRlen + lengthof(p_element.net_type & " " &
p_element.addr_type & " " &
p_element.conn_addr.addr);
if (ispresent(p_element.conn_addr.ttl))
{v_result := v_result + 1 + lengthof(int2str(p_element.conn_addr.ttl));};
if (ispresent(p_element.conn_addr.num_of_addr))
{v_result := v_result + 1 + lengthof(int2str(p_element.conn_addr.num_of_addr));};
return v_result
} // f_SDPlength_connection
function f_SDPlength_attribute(SDP_attribute p_element) return integer // "a="
{
var integer v_result:=0;
var charstring v_auxstring;
if (ischosen(p_element.cat)) {v_result := v_result + 2+c_CRlen + lengthof("cat:" & p_element.cat.attr_value)};
if (ischosen(p_element.keywds)) {v_result := v_result + 2+c_CRlen + lengthof("keywds:" & p_element.keywds.attr_value)};
if (ischosen(p_element.tool)) {v_result := v_result + 2+c_CRlen + lengthof("tool:" & p_element.tool.attr_value)};
if (ischosen(p_element.ptime)) {v_result := v_result + 2+c_CRlen + lengthof("ptime:" & p_element.ptime.attr_value)};
if (ischosen(p_element.recvonly)) {v_result := v_result + 2+c_CRlen + lengthof("recvonly")};
if (ischosen(p_element.sendrecv)) {v_result := v_result + 2+c_CRlen + lengthof("sendrecv")};
if (ischosen(p_element.sendonly)) {v_result := v_result + 2+c_CRlen + lengthof("sendonly")};
if (ischosen(p_element.inactive)) {v_result := v_result + 2+c_CRlen + lengthof("inactive")};
if (ischosen(p_element.orient)) {v_result := v_result + 2+c_CRlen + lengthof("orient:" & p_element.orient.attr_value)};
if (ischosen(p_element.sdp_type)) {v_result := v_result + 2+c_CRlen + lengthof("type:" & p_element.sdp_type.attr_value)};
if (ischosen(p_element.charset)) {v_result := v_result + 2+c_CRlen + lengthof("charset" & p_element.charset.attr_value)};
if (ischosen(p_element.sdplang)) {v_result := v_result + 2+c_CRlen + lengthof("sdplang:" & p_element.sdplang.attr_value)};
if (ischosen(p_element.lang)) {v_result := v_result + 2+c_CRlen + lengthof("lang:" & p_element.lang.attr_value)};
if (ischosen(p_element.framerate)) {v_result := v_result + 2+c_CRlen + lengthof("framerate:" & p_element.framerate.attr_value)};
if (ischosen(p_element.quality)) {v_result := v_result + 2+c_CRlen + lengthof("quality:" & p_element.quality.attr_value)};
if (ischosen(p_element.fmtp)) {v_result := v_result + 2+c_CRlen + lengthof("fmtp:" & p_element.fmtp.attr_value)};
if (ischosen(p_element.curr)) {v_result := v_result + 2+c_CRlen + lengthof("curr:" & p_element.curr.preconditionType & " "
& p_element.curr.statusType & " " & p_element.curr.direction)};
if (ischosen(p_element.des)) {v_result := v_result + 2+c_CRlen + lengthof("des:" & p_element.des.preconditionType & " "
& p_element.des.strength & " " & p_element.des.statusType & " " & p_element.des.direction)};
if (ischosen(p_element.conf)) {v_result := v_result + 2+c_CRlen + lengthof("conf:" & p_element.conf.preconditionType & " "
& p_element.des.statusType & " " & p_element.des.direction)};
if (ischosen(p_element.rtpmap)) {v_result := v_result + 2+c_CRlen + lengthof("rtpmap:" & p_element.rtpmap.attr_value)};
if (ischosen(p_element.rtcp)) {v_result := v_result + 2+c_CRlen + lengthof("rtcp:" & p_element.rtcp.attr_value)};
if (ischosen(p_element.unknown))
{v_result := v_result + 2+c_CRlen + lengthof(p_element.unknown.name);
if (ispresent(p_element.unknown.attr_value))
{var charstring aux := p_element.unknown.attr_value;
v_result := v_result + lengthof(":" & p_element.unknown.attr_value);
};
};
// log("axr: length attribute=", v_result);
return v_result
} // f_SDPlength_attribute
} // group SDPlen_calculation
group GiveHeaders {
/**
*
* @desc Return component variable of recordRoute header if vc_boo_recordRoute is true
* @return component variable of recordRoute header
*/
function f_recordroute() runs on SipComponent return template RecordRoute
{
if (vc_boo_recordRoute)
{return vc_recordRoute}
else {return(omit)}
}
/**
*
* @desc Return component variable of Route header if vc_boo_route is true
* @return component variable of recordRoute header
*/
function f_route() runs on SipComponent return template RecordRoute
{
if (vc_boo_route)
{return vc_route} // TODO: Route header need to be in reverse order than RecordRoute, question of return value - RecordRoute
else {return(omit)}
}
} // end group GiveHeaders
group others {
/*
*
* @desc function combines two comma parameter lists
* @param p_list1 first list
* @param p_list2 second list
* @return comma parameter list that contains parameters from both input lists
* @verdict
*/
function f_merge_CommaParam_List(CommaParam_List p_list1, CommaParam_List p_list2) return template CommaParam_List
{ var CommaParam_List p_result;
var integer limit1 := sizeof(p_list1);
for (var integer i:=0; i<limit1; i:=i+1) {
p_result[i] := p_list1[i]
};
for (var integer i:=limit1; i<limit1+sizeof(p_list2); i:=i+1) {
p_result[i] := p_list2[i]
};
return p_result
}
} // end group others
} //group TemplatePreparationFunctions
} // end module LibSip_Templates