Browse code

- documented insert_body() function

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4900 689a6050-402a-0410-94f2-e92a70836424

Daniel-Constantin Mierla authored on 15/09/2008 10:00:17
Showing 2 changed files
... ...
@@ -19,8 +19,8 @@ Daniel-Constantin Mierla
19 19
 
20 20
    Copyright � 2003 FhG FOKUS
21 21
    Revision History
22
-   Revision $Revision$ $Date: 2008-08-06 12:08:33 +0200
23
-                              (Mi, 06 Aug 2008) $
22
+   Revision $Revision$ $Date: 2008-08-11 09:46:44 +0300
23
+                              (Mon, 11 Aug 2008) $
24 24
      __________________________________________________________
25 25
 
26 26
    Table of Contents
... ...
@@ -51,19 +51,20 @@ Daniel-Constantin Mierla
51 51
               1.3.11. subst_uri('/re/repl/flags')
52 52
               1.3.12. subst_user('/re/repl/flags')
53 53
               1.3.13. subst_body('/re/repl/flags')
54
-              1.3.14. filter_body(content_type)
55
-              1.3.15. append_to_reply(txt)
56
-              1.3.16. append_hf(txt)
57
-              1.3.17. append_hf(txt, hdr)
58
-              1.3.18. insert_hf(txt)
59
-              1.3.19. insert_hf(txt, hdr)
60
-              1.3.20. append_urihf(prefix, suffix)
61
-              1.3.21. is_present_hf(hf_name)
62
-              1.3.22. append_time()
63
-              1.3.23. is_method(name)
64
-              1.3.24. remove_hf(hname)
65
-              1.3.25. has_body(), has_body(mime)
66
-              1.3.26. is_privacy(privacy_type)
54
+              1.3.14. insert_body(txt,content_type)
55
+              1.3.15. filter_body(content_type)
56
+              1.3.16. append_to_reply(txt)
57
+              1.3.17. append_hf(txt)
58
+              1.3.18. append_hf(txt, hdr)
59
+              1.3.19. insert_hf(txt)
60
+              1.3.20. insert_hf(txt, hdr)
61
+              1.3.21. append_urihf(prefix, suffix)
62
+              1.3.22. is_present_hf(hf_name)
63
+              1.3.23. append_time()
64
+              1.3.24. is_method(name)
65
+              1.3.25. remove_hf(hname)
66
+              1.3.26. has_body(), has_body(mime)
67
+              1.3.27. is_privacy(privacy_type)
67 68
 
68 69
         1.4. Known Limitations
69 70
 
... ...
@@ -88,19 +89,20 @@ Daniel-Constantin Mierla
88 89
    1.11. subst_uri usage
89 90
    1.12. subst usage
90 91
    1.13. subst_body usage
91
-   1.14. filter_body usage
92
-   1.15. append_to_reply usage
93
-   1.16. append_hf usage
92
+   1.14. insert_body usage
93
+   1.15. filter_body usage
94
+   1.16. append_to_reply usage
94 95
    1.17. append_hf usage
95
-   1.18. insert_hf usage
96
+   1.18. append_hf usage
96 97
    1.19. insert_hf usage
97
-   1.20. append_urihf usage
98
-   1.21. is_present_hf usage
99
-   1.22. append_time usage
100
-   1.23. is_method usage
101
-   1.24. remove_hf usage
102
-   1.25. has_body usage
103
-   1.26. is_privacy usage
98
+   1.20. insert_hf usage
99
+   1.21. append_urihf usage
100
+   1.22. is_present_hf usage
101
+   1.23. append_time usage
102
+   1.24. is_method usage
103
+   1.25. remove_hf usage
104
+   1.26. has_body usage
105
+   1.27. is_privacy usage
104 106
 
105 107
 Chapter 1. Admin Guide
106 108
 
... ...
@@ -394,7 +396,24 @@ if ( subst_body('/^o=(.*) /o=$fU ') ) {};
394 396
 
395 397
 ...
396 398
 
397
-1.3.14.  filter_body(content_type)
399
+1.3.14.  insert_body(txt,content_type)
400
+
401
+   Insert body to a SIP message. If the body exists, the function
402
+   returns false as multi-part is not supported yet.
403
+
404
+   Meaning of the parameters is as follows:
405
+     * txt - text for the body.
406
+     * content_type - value of Content-Type header.
407
+
408
+   This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
409
+   FAILURE_ROUTE, BRANCH_ROUTE.
410
+
411
+   Example 1.14. insert_body usage
412
+...
413
+insert_body("test", "text/plain");
414
+...
415
+
416
+1.3.15.  filter_body(content_type)
398 417
 
399 418
    Filters multipart body by leaving out all other body parts
400 419
    except the first body part of given type.
... ...
@@ -405,7 +424,7 @@ if ( subst_body('/^o=(.*) /o=$fU ') ) {};
405 424
    This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
406 425
    FAILURE_ROUTE, BRANCH_ROUTE.
407 426
 
408
-   Example 1.14. filter_body usage
427
+   Example 1.15. filter_body usage
409 428
 ...
410 429
 if (has_body("multipart/mixed")) {
411 430
     if (filter_body("application/sdp") {
... ...
@@ -417,7 +436,7 @@ if (has_body("multipart/mixed")) {
417 436
 }
418 437
 ...
419 438
 
420
-1.3.15.  append_to_reply(txt)
439
+1.3.16.  append_to_reply(txt)
421 440
 
422 441
    Append txt as header to the reply.
423 442
 
... ...
@@ -427,13 +446,13 @@ if (has_body("multipart/mixed")) {
427 446
    This function can be used from REQUEST_ROUTE, BRANCH_ROUTE,
428 447
    ERROR_ROUTE.
429 448
 
430
-   Example 1.15. append_to_reply usage
449
+   Example 1.16. append_to_reply usage
431 450
 ...
432 451
 append_to_reply("Foo: bar\r\n");
433 452
 append_to_reply("Foo: $rm at $Ts\r\n");
434 453
 ...
435 454
 
436
-1.3.16.  append_hf(txt)
455
+1.3.17.  append_hf(txt)
437 456
 
438 457
    Appends 'txt' as header after the last header field.
439 458
 
... ...
@@ -450,13 +469,13 @@ append_to_reply("Foo: $rm at $Ts\r\n");
450 469
    This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
451 470
    FAILURE_ROUTE, BRANCH_ROUTE.
452 471
 
453
-   Example 1.16. append_hf usage
472
+   Example 1.17. append_hf usage
454 473
 ...
455 474
 append_hf("P-hint: VOICEMAIL\r\n");
456 475
 append_hf("From-username: $fU\r\n");
457 476
 ...
458 477
 
459
-1.3.17.  append_hf(txt, hdr)
478
+1.3.18.  append_hf(txt, hdr)
460 479
 
461 480
    Appends 'txt' as header after first 'hdr' header field.
462 481
 
... ...
@@ -468,13 +487,13 @@ append_hf("From-username: $fU\r\n");
468 487
    This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
469 488
    FAILURE_ROUTE, BRANCH_ROUTE.
470 489
 
471
-   Example 1.17. append_hf usage
490
+   Example 1.18. append_hf usage
472 491
 ...
473 492
 append_hf("P-hint: VOICEMAIL\r\n", "Call-ID");
474 493
 append_hf("From-username: $fU\r\n", "Call-ID");
475 494
 ...
476 495
 
477
-1.3.18.  insert_hf(txt)
496
+1.3.19.  insert_hf(txt)
478 497
 
479 498
    Inserts 'txt' as header before the first header field.
480 499
 
... ...
@@ -485,13 +504,13 @@ append_hf("From-username: $fU\r\n", "Call-ID");
485 504
    This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
486 505
    FAILURE_ROUTE, BRANCH_ROUTE.
487 506
 
488
-   Example 1.18. insert_hf usage
507
+   Example 1.19. insert_hf usage
489 508
 ...
490 509
 insert_hf("P-hint: VOICEMAIL\r\n");
491 510
 insert_hf("To-username: $tU\r\n");
492 511
 ...
493 512
 
494
-1.3.19.  insert_hf(txt, hdr)
513
+1.3.20.  insert_hf(txt, hdr)
495 514
 
496 515
    Inserts 'txt' as header before first 'hdr' header field.
497 516
 
... ...
@@ -503,13 +522,13 @@ insert_hf("To-username: $tU\r\n");
503 522
    This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
504 523
    FAILURE_ROUTE, BRANCH_ROUTE.
505 524
 
506
-   Example 1.19. insert_hf usage
525
+   Example 1.20. insert_hf usage
507 526
 ...
508 527
 insert_hf("P-hint: VOICEMAIL\r\n", "Call-ID");
509 528
 insert_hf("To-username: $tU\r\n", "Call-ID");
510 529
 ...
511 530
 
512
-1.3.20.  append_urihf(prefix, suffix)
531
+1.3.21.  append_urihf(prefix, suffix)
513 532
 
514 533
    Append header field name with original Request-URI in middle.
515 534
 
... ...
@@ -520,12 +539,12 @@ insert_hf("To-username: $tU\r\n", "Call-ID");
520 539
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
521 540
    BRANCH_ROUTE.
522 541
 
523
-   Example 1.20. append_urihf usage
542
+   Example 1.21. append_urihf usage
524 543
 ...
525 544
 append_urihf("CC-Diversion: ", "\r\n");
526 545
 ...
527 546
 
528
-1.3.21.  is_present_hf(hf_name)
547
+1.3.22.  is_present_hf(hf_name)
529 548
 
530 549
    Return true if a header field is present in message.
531 550
 
... ...
@@ -540,12 +559,12 @@ Note
540 559
    This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
541 560
    FAILURE_ROUTE, BRANCH_ROUTE.
542 561
 
543
-   Example 1.21. is_present_hf usage
562
+   Example 1.22. is_present_hf usage
544 563
 ...
545 564
 if (is_present_hf("From")) log(1, "From HF Present");
546 565
 ...
547 566
 
548
-1.3.22.  append_time()
567
+1.3.23.  append_time()
549 568
 
550 569
    Adds a time header to the reply of the request. You must use it
551 570
    before functions that are likely to send a reply, e.g., save()
... ...
@@ -564,12 +583,12 @@ if (is_present_hf("From")) log(1, "From HF Present");
564 583
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
565 584
    BRANCH_ROUTE.
566 585
 
567
-   Example 1.22. append_time usage
586
+   Example 1.23. append_time usage
568 587
 ...
569 588
 append_time();
570 589
 ...
571 590
 
572
-1.3.23.  is_method(name)
591
+1.3.24.  is_method(name)
573 592
 
574 593
    Check if the method of the message matches the name. If name is
575 594
    a known method (invite, cancel, ack, bye, options, info,
... ...
@@ -594,7 +613,7 @@ append_time();
594 613
    This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
595 614
    FAILURE_ROUTE, and BRANCH_ROUTE.
596 615
 
597
-   Example 1.23. is_method usage
616
+   Example 1.24. is_method usage
598 617
 ...
599 618
 if(is_method("INVITE"))
600 619
 {
... ...
@@ -606,7 +625,7 @@ if(is_method("OPTION|UPDATE"))
606 625
 }
607 626
 ...
608 627
 
609
-1.3.24.  remove_hf(hname)
628
+1.3.25.  remove_hf(hname)
610 629
 
611 630
    Remove from message all headers with name "hname"
612 631
 
... ...
@@ -618,7 +637,7 @@ if(is_method("OPTION|UPDATE"))
618 637
    This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
619 638
    FAILURE_ROUTE and BRANCH_ROUTE.
620 639
 
621
-   Example 1.24. remove_hf usage
640
+   Example 1.25. remove_hf usage
622 641
 ...
623 642
 if(remove_hf("User-Agent"))
624 643
 {
... ...
@@ -626,7 +645,7 @@ if(remove_hf("User-Agent"))
626 645
 }
627 646
 ...
628 647
 
629
-1.3.25.  has_body(), has_body(mime)
648
+1.3.26.  has_body(), has_body(mime)
630 649
 
631 650
    The function returns true if the SIP message has a body
632 651
    attached. The checked includes also the "Content-Lenght" header
... ...
@@ -642,7 +661,7 @@ if(remove_hf("User-Agent"))
642 661
    This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
643 662
    FAILURE_ROUTE and BRANCH_ROUTE.
644 663
 
645
-   Example 1.25. has_body usage
664
+   Example 1.26. has_body usage
646 665
 ...
647 666
 if(has_body("application/sdp"))
648 667
 {
... ...
@@ -650,7 +669,7 @@ if(has_body("application/sdp"))
650 669
 }
651 670
 ...
652 671
 
653
-1.3.26.  is_privacy(privacy_type)
672
+1.3.27.  is_privacy(privacy_type)
654 673
 
655 674
    The function returns true if the SIP message has a Privacy
656 675
    header field that includes the given privacy_type among its
... ...
@@ -661,7 +680,7 @@ if(has_body("application/sdp"))
661 680
    This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
662 681
    FAILURE_ROUTE and BRANCH_ROUTE.
663 682
 
664
-   Example 1.26. is_privacy usage
683
+   Example 1.27. is_privacy usage
665 684
 ...
666 685
 if(is_privacy("id"))
667 686
 {
... ...
@@ -525,6 +525,40 @@ if ( subst_body('/^o=(.*) /o=$fU ') ) {};
525 525
 		</example>
526 526
 	</section>
527 527
 
528
+	<section>
529
+		<title>
530
+		<function moreinfo="none">insert_body(txt,content_type)</function>
531
+		</title>
532
+		<para>
533
+		Insert body to a SIP message. If the body exists, the function returns
534
+		false as multi-part is not supported yet.
535
+		</para>
536
+		<para>Meaning of the parameters is as follows:</para>
537
+		<itemizedlist>
538
+		<listitem>
539
+			<para><emphasis>txt</emphasis> - text for the body.
540
+			</para>
541
+		</listitem>
542
+		<listitem>
543
+			<para><emphasis>content_type</emphasis> - value of Content-Type header.
544
+			</para>
545
+		</listitem>
546
+		</itemizedlist>
547
+		<para>
548
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
549
+		FAILURE_ROUTE, BRANCH_ROUTE.
550
+		</para>
551
+		<example>
552
+		<title><function>insert_body</function> usage</title>
553
+		<programlisting format="linespecific">
554
+...
555
+insert_body("test", "text/plain");
556
+...
557
+</programlisting>
558
+		</example>
559
+	</section>
560
+
561
+
528 562
 	<section>
529 563
 		<title>
530 564
 		<function moreinfo="none">filter_body(content_type)</function>