-
Notifications
You must be signed in to change notification settings - Fork 564
/
sipmsgops_admin.xml
1618 lines (1543 loc) · 47.1 KB
/
sipmsgops_admin.xml
1
2
3
4
5
6
7
8
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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
462
463
464
465
466
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
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
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
654
655
656
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
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
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
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
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
968
969
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
<!-- Module User's Guide -->
<chapter>
<title>&adminguide;</title>
<section id="overview" xreflabel="Overview">
<title>Overview</title>
<para>
The module implements SIP based operations over the messages
processed by OpenSIPS. SIP is a text based protocol and the module
provides a large set of very useful functions to manipulate the
message at SIP level, e.g., inserting new headers or deleting them,
check for method type, etc.
</para>
</section>
<section id="dependencies" xreflabel="Dependencies">
<title>Dependencies</title>
<section>
<title>&osips; Modules</title>
<para>
The following modules must be loaded before this module:
<itemizedlist>
<listitem>
<para>
<emphasis>No dependencies on other &osips; modules</emphasis>.
</para>
</listitem>
</itemizedlist>
</para>
</section>
<section>
<title>External Libraries or Applications</title>
<para>
The following libraries or applications must be installed before
running &osips; with this module loaded:
<itemizedlist>
<listitem>
<para>
<emphasis>None</emphasis>.
</para>
</listitem>
</itemizedlist>
</para>
</section>
</section>
<section id="exported_functions" xreflabel="exported_functions">
<title>Exported Functions</title>
<section id="func_append_to_reply" xreflabel="append_to_reply()">
<title>
<function moreinfo="none">append_to_reply(txt)</function>
</title>
<para>
Append 'txt' as header to all replies that will be generated by
OpenSIPS for this request.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>txt (string)</emphasis> - SIP header field,
value and CRLF marker.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
BRANCH_ROUTE, ERROR_ROUTE.
</para>
<example>
<title><function>append_to_reply</function> usage</title>
<programlisting format="linespecific">
...
append_to_reply("Foo: bar\r\n");
append_to_reply("Foo: $rm at $Ts\r\n");
...
</programlisting>
</example>
</section>
<section id="func_append_hf" xreflabel="append_hf()">
<title>
<function moreinfo="none">append_hf(txt[, hdr_anchor])</function>
</title>
<para>
Appends 'txt' as header after the last header field. If
'hdr_anchor' is given, 'txt' will be appended after the first
occurrence of 'hdr_anchor' instead.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>txt (string)</emphasis> - Header field to be appended.
</para>
</listitem>
<listitem>
<para><emphasis>hdr_anchor (string, optional)</emphasis> - Header name
after which the 'txt' is appended.
</para>
</listitem>
</itemizedlist>
<para>
Note: Headers which are added in main route cannot be removed in further routes
(e.g. failure routes). So, the idea is not to add there any headers that you
might want to remove later. To add headers temporarily, use the branch route
because the changes you do there are per-branch.
</para>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE.
</para>
<example>
<title><function>append_hf</function> usage</title>
<programlisting format="linespecific">
...
append_hf("P-hint: VOICEMAIL\r\n");
append_hf("From-username: $fU\r\n");
append_hf("From-username: $fU\r\n", "Call-ID");
...
</programlisting>
</example>
</section>
<section id="func_insert_hf" xreflabel="insert_hf()">
<title>
<function moreinfo="none">insert_hf(txt)</function>
</title>
<para>
Inserts 'txt' as header before the first header field.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>txt (string)</emphasis> - Header field to be inserted.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE.
</para>
<example>
<title><function>insert_hf</function> usage</title>
<programlisting format="linespecific">
...
insert_hf("P-hint: VOICEMAIL\r\n");
insert_hf("To-username: $tU\r\n");
...
</programlisting>
</example>
</section>
<section id="func_insert_hf_2" xreflabel="insert_hf()">
<title>
<function moreinfo="none">insert_hf(txt, hdr)</function>
</title>
<para>
Inserts 'txt' as header before first 'hdr' header field.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>txt (string)</emphasis> - Header field to be inserted.
</para>
</listitem>
<listitem>
<para><emphasis>hdr (string, optional)</emphasis> - Header name
before which the 'txt' is inserted.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE.
</para>
<example>
<title><function>insert_hf</function> usage</title>
<programlisting format="linespecific">
...
insert_hf("P-hint: VOICEMAIL\r\n", "Call-ID");
insert_hf("To-username: $tU\r\n", "Call-ID");
...
</programlisting>
</example>
</section>
<section id="func_append_urihf" xreflabel="append_urihf()">
<title>
<function moreinfo="none">append_urihf(prefix, suffix)</function>
</title>
<para>
Append header field name with original <acronym>Request-URI</acronym>
in middle.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>prefix</emphasis> - string (usually at least
header field name).
</para>
</listitem>
<listitem>
<para><emphasis>suffix</emphasis> - string (usually at least
line terminator).
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
BRANCH_ROUTE.
</para>
<example>
<title><function>append_urihf</function> usage</title>
<programlisting format="linespecific">
...
append_urihf("CC-Diversion: ", "\r\n");
...
</programlisting>
</example>
</section>
<section id="func_is_present_hf" xreflabel="is_present_hf()">
<title>
<function moreinfo="none">is_present_hf(hf_name)</function>
</title>
<para>
Return true if a header field is present in message.
</para>
<note>
<para>
The function is also able to distinguish the compact names. For
exmaple <quote>From</quote> will match with <quote>f</quote>
</para>
</note>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>hf_name (string)</emphasis> - Header field name (long or
compact form).
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE.
</para>
<example>
<title><function>is_present_hf</function> usage</title>
<programlisting format="linespecific">
...
if (is_present_hf("From")) log(1, "From HF Present");
...
</programlisting>
</example>
</section>
<section id="func_append_time" xreflabel="append_time()">
<title>
<function moreinfo="none">append_time()</function>
</title>
<para>
Adds a time header to the reply of the request. You must use it
before functions that are likely to send a reply, e.g., save()
from 'registrar' module. Header format is:
<quote>Date: %a, %d %b %Y %H:%M:%S GMT</quote>, with the legend:
<itemizedlist>
<listitem>
<para><emphasis>%a</emphasis> abbreviated week of day name (locale)
</para>
</listitem>
<listitem>
<para><emphasis>%d</emphasis> day of month as decimal number
</para>
</listitem>
<listitem>
<para><emphasis>%b</emphasis> abbreviated month name (locale)
</para>
</listitem>
<listitem>
<para><emphasis>%Y</emphasis> year with century
</para>
</listitem>
<listitem>
<para><emphasis>%H</emphasis> hour
</para>
</listitem>
<listitem>
<para><emphasis>%M</emphasis> minutes
</para>
</listitem>
<listitem>
<para><emphasis>%S</emphasis> seconds
</para>
</listitem>
</itemizedlist>
</para>
<para>
Return true if a header was successfully appended.
</para>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
BRANCH_ROUTE.
</para>
<example>
<title><function>append_time</function> usage</title>
<programlisting format="linespecific">
...
append_time();
...
</programlisting>
</example>
</section>
<section id="func_is_method" xreflabel="is_method()">
<title>
<function moreinfo="none">is_method(name)</function>
</title>
<para>
Check if the method of the message matches the name. If name is a
known method (invite, cancel, ack, bye, options, info, update, register,
message, subscribe, notify, refer, prack), the function performs method
ID testing (integer comparison) instead of ignore case string
comparison.
</para>
<para>
The 'name' can be a list of methods in the form of
'method1|method2|...'. In this case, the function returns true if the
SIP message's method is one from the list. IMPORTANT NOTE: in the list
must be only methods defined in &osips; with ID (invite, cancel, ack,
bye, options, info, update, register, message, subscribe, notify,
refer, prack, publish; for more see:
<ulink url="https://www.iana.org/assignments/sip-parameters">
https://www.iana.org/assignments/sip-parameters</ulink>).
</para>
<para>
If used for replies, the function tests the value of method field from
CSeq header.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>name (string)</emphasis> - SIP method name
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, and BRANCH_ROUTE.
</para>
<example>
<title><function>is_method</function> usage</title>
<programlisting format="linespecific">
...
if(is_method("INVITE"))
{
# process INVITEs here
}
if(is_method("OPTION|UPDATE"))
{
# process OPTIONs and UPDATEs here
}
...
</programlisting>
</example>
</section>
<section id="func_remove_hf" xreflabel="remove_hf()">
<title>
<function moreinfo="none">remove_hf(hname)</function>
</title>
<para>
Remove from message all headers with name <quote>hname</quote>
</para>
<para>
Returns true if at least one header is found and removed.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>hname (string)</emphasis> - header name to be removed.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE and BRANCH_ROUTE.
</para>
<example>
<title><function>remove_hf</function> usage</title>
<programlisting format="linespecific">
...
if(remove_hf("User-Agent"))
{
# User Agent header removed
}
...
</programlisting>
</example>
</section>
<section id="func_remove_hf_re" xreflabel="remove_hf_re()">
<title>
<function moreinfo="none">remove_hf_re(hname_expr)</function>
</title>
<para>
Remove from message all headers matching the
<quote>hname_expr</quote> POSIX regular expression.
</para>
<para>
Returns true if at least one header is found and removed.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>hname_expr (string)</emphasis> - regular expression.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE and BRANCH_ROUTE.
</para>
<example>
<title><function>remove_hf_re</function> usage</title>
<programlisting format="linespecific">
...
remove_hf_re("^X-g.+[0-9]");
...
</programlisting>
</example>
</section>
<section id="func_remove_hf_glob" xreflabel="remove_hf_glob()">
<title>
<function moreinfo="none">remove_hf_glob(hname_pattern)</function>
</title>
<para>
Remove from message all headers matching the
<quote>hname_pattern</quote> glob pattern.
</para>
<para>
Returns true if at least one header is found and removed.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>hname_pattern (string)</emphasis> - glob pattern
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE and BRANCH_ROUTE.
</para>
<example>
<title><function>remove_hf_glob</function> usage</title>
<programlisting format="linespecific">
...
# removes X-Billing-Account, X-Billing-Price, X-Billing-rateplan, etc
remove_hf_glob("X-Billing*");
...
</programlisting>
</example>
</section>
<section id="func_has_totag" xreflabel="has_totag()">
<title>
<function moreinfo="none">has_totag()</function>
</title>
<para>
Check if To header field uri contains tag parameter.
</para>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE and LOCAL_ROUTE.
</para>
<example>
<title><function>has_totag</function> usage</title>
<programlisting format="linespecific">
...
if (has_totag()) {
...
};
...
</programlisting>
</example>
</section>
<section id="func_ruri_has_param" xreflabel="ruri_has_param()">
<title>
<function moreinfo="none">ruri_has_param(param[,value])</function>
</title>
<para>
Find if Request URI has a given parameter. If no value is given,
the function will look for the paramter with no value, oherwise it
will search for the parameter with the matching value.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>param (string)</emphasis> - parameter name to look for.
</para>
</listitem>
<listitem>
<para><emphasis>value (string, optional)</emphasis> - parameter value to match.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE and LOCAL_ROUTE.
</para>
<example>
<title><function>ruri_has_param</function> usage</title>
<programlisting format="linespecific">
...
if (ruri_has_param("user","phone")) {
...
};
...
</programlisting>
</example>
</section>
<section id="func_ruri_add_param" xreflabel="ruri_add_param()">
<title>
<function moreinfo="none">ruri_add_param(param)</function>
</title>
<para>
Add to RURI an URI parameter formated as "name=value".
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>param (string)</emphasis> - parameter to be appended in
<quote>name=value</quote> format.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE and LOCAL_ROUTE.
</para>
<example>
<title><function>ruri_add_param</function> usage</title>
<programlisting format="linespecific">
...
ruri_add_param("nat=yes");
...
</programlisting>
</example>
</section>
<section id="func_ruri_del_param" xreflabel="ruri_del_param()">
<title>
<function moreinfo="none">ruri_del_param(param)</function>
</title>
<para>
Delete a parameter from the RURI being given the key(key=value);
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>param (string)</emphasis> - key of the parameter to be removed/
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE and LOCAL_ROUTE.
</para>
<example>
<title><function>ruri_del_param</function> usage</title>
<programlisting format="linespecific">
...
ruri_del_param("user");
...
</programlisting>
</example>
</section>
<section id="func_ruri_tel2sip" xreflabel="ruri_tel2sip()">
<title>
<function moreinfo="none">ruri_tel2sip()</function>
</title>
<para>
Converts RURI, if it is tel URI, to SIP URI. Returns true, only if
conversion succeeded or if no conversion was needed (like RURI
was not tel URI.
</para>
<para>
This function can be used from REQUEST_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE and LOCAL_ROUTE.
</para>
<example>
<title><function>ruri_tel2sip</function> usage</title>
<programlisting format="linespecific">
...
ruri_tel2sip();
...
</programlisting>
</example>
</section>
<section id="func_is_uri_user_e164" xreflabel="is_uri_user_e164()">
<title>
<function moreinfo="none">is_uri_user_e164(uri)</function>
</title>
<para>
Checks if the username part of the given URI is an E164 number.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>uri (string)</emphasis> - a SIP URI
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
</para>
<example>
<title><function>is_uri_user_e164</function> usage</title>
<programlisting format="linespecific">
...
if (is_uri_user_e164($fu)) { # Check From header URI user part
...
}
if (is_uri_user_e164($avp(uri)) {
# Check user part of URI stored in avp uri
...
};
...
</programlisting>
</example>
</section>
<section id="func_has_body_part" xreflabel="has_body_part()">
<title>
<function moreinfo="none">has_body_part([mime])</function>
</title>
<para>
The function returns <emphasis>true</emphasis> if the SIP message
has any body part with the given MIME. If there is no MIME given,
it will return true if at least one body part is found (with any MIME).
</para>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE and BRANCH_ROUTE.
</para>
<example>
<title><function>has_body_part</function> usage</title>
<programlisting format="linespecific">
...
if(has_body_part("application/sdp"))
{
# do interesting stuff here
}
...
</programlisting>
</example>
</section>
<section id="func_is_audio_on_hold" xreflabel="is_audio_on_hold()">
<title>
<function moreinfo="none">is_audio_on_hold()</function>
</title>
<para>
The function returns <emphasis>true</emphasis> if the SIP message
has an SDP body attached and at least one audio stream in on hold.
The return code of the function indicates the detected hold type:
<itemizedlist>
<listitem>
<para><emphasis>1</emphasis> - RFC2543 hold type:
null connection IP detected
</para>
</listitem>
<listitem>
<para><emphasis>2</emphasis> - RFC3264 hold type:
inactive or sendonly attributes detected
</para>
</listitem>
</itemizedlist>
</para>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE and BRANCH_ROUTE.
</para>
<example>
<title><function>is_audio_on_hold</function> usage</title>
<programlisting format="linespecific">
...
if(is_audio_on_hold())
{
switch ($rc) {
case 1:
# RFC2543 hold type
# do interesting stuff here
break;
case 2:
# RFC3264 hold type
# do interesting stuff here
break;
}
...
</programlisting>
</example>
</section>
<section id="func_is_privacy" xreflabel="is_privacy()">
<title>
<function moreinfo="none">is_privacy(privacy_type)</function>
</title>
<para>
The function returns <emphasis>true</emphasis> if
the SIP message has a Privacy header field that includes
the given privacy_type among its privacy values. See
<ulink url="https://www.iana.org/assignments/sip-parameters/sip-parameters.xhtml#sip-parameters-8">
https://www.iana.org/assignments/sip-parameters/sip-parameters.xhtml#sip-parameters-8</ulink>
for possible privacy type values.
</para>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE and BRANCH_ROUTE.
</para>
<example>
<title><function>is_privacy</function> usage</title>
<programlisting format="linespecific">
...
if(is_privacy("id"))
{
# do interesting stuff here
}
...
</programlisting>
</example>
</section>
<section id="func_remove_body_part" xreflabel="remove_body_part()">
<title>
<function moreinfo="none">remove_body_part([mime[, revert]])</function>
</title>
<para>
Removes from the message body all the body parts with the given mime.
The necessary corrections over the Content-Type and Content-Length
headers are automatically done.
</para>
<para>
If a MIME type is given, it will delete only the body parts with
that mime. If no MIME given, all the parts (entire body) will be
removed.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>mime (string, optional)</emphasis> - MIME type to
be checked against the body parts; If not given, all parts
are to remvoed;
</para>
</listitem>
<listitem>
<para><emphasis>revert (string, optional)</emphasis> - useful only
if a MIME was specified. If "revert" string is given here, the
function will delete all body parts but the ones with the given MIME.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE and LOCAL_ROUTE.
</para>
<example>
<title><function>remove_body_part()</function> usage</title>
<programlisting format="linespecific">
...
# delete entire body message (all parts)
remove_body_part();
# delete all body parts with mime "application/isup"
remove_body_part("application/isup");
# delete all body parts but keep the the ones with "application/sdp"
remove_body_part("application/sdp","revert")
...
</programlisting>
</example>
</section>
<section id="func_add_body_part" xreflabel="add_body_part()">
<title>
<function moreinfo="none">add_body_part(body, mime[, headers])</function>
</title>
<para>
This function can be used to add a new body part to the message body.
If another part already exist, body of the message will be converted
to a multi-part body automatically.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>body (string)</emphasis> - the content of the body part
to be added
</para>
</listitem>
<listitem>
<para><emphasis>mime (string)</emphasis> - the mime string for the body
part to be added
</para>
</listitem>
<listitem>
<para><emphasis>headers (string, optional)</emphasis> - optional list of SIP headers
(fully defined, including the header separator) to be pushed into
this part next to the <emphasis>Content-Type</emphasis> header.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE and LOCAL_ROUTE.
</para>
<example>
<title><function>add_body_part</function> usage</title>
<programlisting format="linespecific">
...
add_body_part("Hello World!", "text/plain");
...
</programlisting>
</example>
</section>
<section id="func_get_updated_body_part" xreflabel="get_updated_body_part()">
<title>
<function moreinfo="none">get_updated_body_part( [mime], variable)</function>
</title>
<para>
This function returns into a variable the regenerated body part,
meaning the body part updated with all the changes done so far by
OpenSIPS. This is helpful if you want to do a sequance of operations
over the body parts and some operations require to have all the
previous changes applied (like first doing some codec related changes
and later to rtpengine insertion).
</para>
<para>
NOTE: the actual SIP message will not be affected by this operation!
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>mime (string)</emphasis> - the mime string for
the body to be regenerated and returned. If missing, the whole
body (with all its parts) will be regenerated.
</para>
</listitem>
<listitem>
<para><emphasis>variable</emphasis> - a variable to be used to
return the regenerated body part (as text).
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE and LOCAL_ROUTE.
</para>
<example>
<title><function>get_updated_body_part</function> usage</title>
<programlisting format="linespecific">
...
codec_delete_re("PCMA|PCMU");
get_updated_body_part( "application/sdp", $var(new_sdp));
xlog("------updated SDP is ----\n$var(new_sdp)\n-----------\n");
exit;
...
</programlisting>
</example>
</section>
<section id="func_sipmsg_validate" xreflabel="sipmsg_validate()">
<title>
<function moreinfo="none">sipmsg_validate([flags[, result_pvar]])</function>
</title>
<para>
The function returns <emphasis>true</emphasis> if the SIP message
is properly built according to SIP RFC3261. It verifies if the
mandatory headers for each request/reply and can also check the format
of the headers body.
</para>
<para>The flags parameter received is optional and can be composed
with the following values:
<itemizedlist>
<listitem><para><emphasis>'s'</emphasis> - checks the
integrity of the SDP body, if it exists
</para></listitem>
<listitem><para><emphasis>'h'</emphasis> - checks the format
and integrity of each header body.
</para></listitem>
<listitem><para><emphasis>'m'</emphasis> - don't check the
Max-Forwards header.
</para></listitem>
<listitem><para><emphasis>'r'</emphasis> - checks the R-URI
and whether the domain contains valid characters.
</para></listitem>
<listitem><para><emphasis>'f'</emphasis> - checks the URI of the 'From' field
and whether the domain contains valid characters.
</para></listitem>
<listitem><para><emphasis>'t'</emphasis> - checks the URI of the 'To' field
and whether the domain contains valid characters.
</para></listitem>
<listitem><para><emphasis>'c'</emphasis> - checks the URI of the 'Contact' field.
</para></listitem>
</itemizedlist>
</para>
<para>The result_pvar parameter sets resulting pvar with text error reason in case of
negative result ( easy for logging or propagating the rejection reason back to the
bogus UA )
</para>
<para>This function can return the following codes:
<itemizedlist>
<listitem><para><emphasis>1</emphasis> - the message is
RFC3261 compliant and has been successfully validated.
</para></listitem>
<listitem><para><emphasis>-1</emphasis> - No SIP message
</para></listitem>
<listitem><para><emphasis>-2</emphasis> - Header Parsing error
</para></listitem>
<listitem><para><emphasis>-3</emphasis> - No Call-ID header
</para></listitem>
<listitem><para><emphasis>-4</emphasis> - No Content-Length header for transports that require it ( eg. TCP )
</para></listitem>
<listitem><para><emphasis>-5</emphasis> - Invalid Content-Length, other from the size of the actual body
</para></listitem>
<listitem><para><emphasis>-6</emphasis> - SDP body parsing error.
</para></listitem>
<listitem><para><emphasis>-7</emphasis> - No Cseq header.
</para></listitem>
<listitem><para><emphasis>-8</emphasis> - No From header.
</para></listitem>
<listitem><para><emphasis>-9</emphasis> - No To header.
</para></listitem>
<listitem><para><emphasis>-10</emphasis> - No Via header.
</para></listitem>
<listitem><para><emphasis>-11</emphasis> - Request URI parse error.
</para></listitem>
<listitem><para><emphasis>-12</emphasis> - Bad hostname in R-URI.
</para></listitem>
<listitem><para><emphasis>-13</emphasis> - No Max-Forwards header.
</para></listitem>
<listitem><para><emphasis>-14</emphasis> - No Contact header.
</para></listitem>
<listitem><para><emphasis>-15</emphasis> - Path user for non-Register request.
</para></listitem>
<listitem><para><emphasis>-16</emphasis> - No allow header in 405 reply.
</para></listitem>
<listitem><para><emphasis>-17</emphasis> - No Min-Expire header in 423 reply.
</para></listitem>
<listitem><para><emphasis>-18</emphasis> - No Proxy-Authorize header in 407 reply.
</para></listitem>
<listitem><para><emphasis>-19</emphasis> - No Unsupported header in 420 reply.
</para></listitem>
<listitem><para><emphasis>-20</emphasis> - No WWW-Authorize header in 401 reply.
</para></listitem>
<listitem><para><emphasis>-21</emphasis> - No Content-Type header
</para></listitem>
<listitem><para><emphasis>-22</emphasis> - To header parse error
</para></listitem>
<listitem><para><emphasis>-23</emphasis> - Bad hostname in To header
</para></listitem>
<listitem><para><emphasis>-24</emphasis> - From header parse error
</para></listitem>
<listitem><para><emphasis>-25</emphasis> - Bad hostname in From header
</para></listitem>
<listitem><para><emphasis>-26</emphasis> - Contact header parse error
</para></listitem>
<listitem><para><emphasis>-27</emphasis> - Bad URI username
</para></listitem>
<listitem><para><emphasis>-28</emphasis> - Bad From URI username
</para></listitem>
<listitem><para><emphasis>-29</emphasis> - Bad To URI username
</para></listitem>
<listitem><para><emphasis>-255</emphasis> - undefined errors.
</para></listitem>
</itemizedlist>
</para>