Browse code

Added redirection_uri_format option in openser.cfg to work with Cisco 2600 IP-IP gateway.

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

Di-Shi Sun authored on 26/07/2007 01:49:42
Showing 7 changed files
... ...
@@ -104,6 +104,17 @@ modparam("osp", "sp1_uri", "http://osptestserver.transnexus.com:1080/osp")
104 104
 #
105 105
 # modparam("osp", "use_rpid_for_calling_number", 1)
106 106
 
107
+#
108
+# URI Format for Redirection Messages
109
+# ===========================================
110
+# This parameter is used to tell OSP module which URI format should be used for redirection messages.
111
+# The default value is 0.
112
+#
113
+# 0 - "xxxxxxxxxx@xxx.xxx.xxx.xxx"
114
+# 1 - "<xxxxxxxxxx@xxx.xxx.xxx.xxx>". This is for Cisco 2600 IP-IP gateway.
115
+#
116
+# modparam("osp", "redirection_uri_format", 0)
117
+
107 118
 # -- mi_fifo params --
108 119
 modparam("mi_fifo", "fifo_name", "/tmp/openser_fifo")
109 120
 
... ...
@@ -55,6 +55,7 @@ int _osp_retry_limit = OSP_DEF_RETRY;
55 55
 int _osp_timeout = OSP_DEF_TIMEOUT;
56 56
 int _osp_max_dests = OSP_DEF_DESTS;
57 57
 int _osp_use_rpid = OSP_DEF_USERPID;
58
+int _osp_redir_uri = OSP_DEF_REDIRURI;
58 59
 char _osp_PRIVATE_KEY[OSP_KEYBUF_SIZE];
59 60
 char _osp_LOCAL_CERTIFICATE[OSP_KEYBUF_SIZE];
60 61
 char _osp_CA_CERTIFICATE[OSP_KEYBUF_SIZE];
... ...
@@ -45,6 +45,7 @@ extern char* _osp_device_port;
45 45
 extern int _osp_max_dests;
46 46
 extern OSPTPROVHANDLE _osp_provider;
47 47
 extern auth_api_t osp_auth;
48
+extern int _osp_redir_uri;
48 49
 
49 50
 const int OSP_FIRST_ROUTE = 1;
50 51
 const int OSP_NEXT_ROUTE = 0;
... ...
@@ -53,7 +54,7 @@ const int OSP_BRANCH_ROUTE = 0;
53 54
 const str OSP_CALLING_NAME = {"_osp_calling_translated_", 24};
54 55
 
55 56
 static int ospLoadRoutes(struct sip_msg* msg, OSPTTRANHANDLE transaction, int destcount, char* source, char* sourcedev, time_t authtime);
56
-static int ospPrepareDestination(struct sip_msg* msg, int isfirst, int type);
57
+static int ospPrepareDestination(struct sip_msg* msg, int isfirst, int type, int format);
57 58
 static int ospSetRpid(struct sip_msg* msg, osp_dest* dest);
58 59
 
59 60
 /*
... ...
@@ -479,12 +480,14 @@ int ospCheckTranslation(
479 480
  * param msg SIP message
480 481
  * param isfirst Is first destination
481 482
  * param type Main or branch route block
483
+ * param format URI format
482 484
  * return MODULE_RETURNCODE_TRUE success MODULE_RETURNCODE_FALSE failure
483 485
  */
484 486
 static int ospPrepareDestination(
485 487
     struct sip_msg* msg, 
486 488
     int isfirst,
487
-    int type)
489
+    int type,
490
+    int format)
488 491
 {
489 492
     int_str val;
490 493
     int res;
... ...
@@ -496,7 +499,7 @@ static int ospPrepareDestination(
496 499
     osp_dest* dest = ospGetNextOrigDestination();
497 500
 
498 501
     if (dest != NULL) {
499
-        ospRebuildDestionationUri(&newuri, dest->called, dest->host, "");
502
+        ospRebuildDestionationUri(&newuri, dest->called, dest->host, "", format);
500 503
 
501 504
         LOG(L_INFO, 
502 505
             "osp: prepare route to URI '%.*s' for call_id '%.*s' transaction_id '%lld'\n",
... ...
@@ -579,7 +582,7 @@ int ospPrepareRoute(
579 582
     LOG(L_DBG, "osp: ospPrepareRoute\n");
580 583
 
581 584
     /* The first parameter will be ignored */
582
-    result = ospPrepareDestination(msg, OSP_FIRST_ROUTE, OSP_BRANCH_ROUTE);
585
+    result = ospPrepareDestination(msg, OSP_FIRST_ROUTE, OSP_BRANCH_ROUTE, 0);
583 586
 
584 587
     return result;
585 588
 }
... ...
@@ -601,9 +604,9 @@ int ospPrepareAllRoutes(
601 604
 
602 605
     LOG(L_DBG, "osp: ospPrepareAllRoutes\n");
603 606
 
604
-    for(result = ospPrepareDestination(msg, OSP_FIRST_ROUTE, OSP_MAIN_ROUTE);
607
+    for(result = ospPrepareDestination(msg, OSP_FIRST_ROUTE, OSP_MAIN_ROUTE, _osp_redir_uri);
605 608
         result == MODULE_RETURNCODE_TRUE;
606
-        result = ospPrepareDestination(msg, OSP_NEXT_ROUTE, OSP_MAIN_ROUTE))
609
+        result = ospPrepareDestination(msg, OSP_NEXT_ROUTE, OSP_MAIN_ROUTE, _osp_redir_uri))
607 610
     {
608 611
     }
609 612
 
... ...
@@ -62,6 +62,7 @@ extern int _osp_retry_limit;
62 62
 extern int _osp_timeout;
63 63
 extern int _osp_max_dests;
64 64
 extern int _osp_use_rpid;
65
+extern int _osp_redir_uri;
65 66
 extern char _osp_PRIVATE_KEY[];
66 67
 extern char _osp_LOCAL_CERTIFICATE[];
67 68
 extern char _osp_CA_CERTIFICATE[];
... ...
@@ -137,6 +138,7 @@ static param_export_t params[]={
137 138
     {"timeout",                        INT_PARAM, &_osp_timeout},
138 139
     {"max_destinations",               INT_PARAM, &_osp_max_dests},
139 140
     {"use_rpid_for_calling_number",    INT_PARAM, &_osp_use_rpid},
141
+    {"redirection_uri_format",         INT_PARAM, &_osp_redir_uri},
140 142
     {0,0,0} 
141 143
 };
142 144
 
... ...
@@ -319,6 +321,7 @@ static void ospDumpParameters(void)
319 321
     LOG(L_INFO, "    timeout '%d' ", _osp_timeout);
320 322
     LOG(L_INFO, "    validate_call_id '%d' ", _osp_validate_callid);
321 323
     LOG(L_INFO, "    use_rpid_for_calling_number '%d' ", _osp_use_rpid);
324
+    LOG(L_INFO, "    redirection_uri_format '%d' ", _osp_redir_uri);
322 325
     LOG(L_INFO, "    max_destinations '%d'\n", _osp_max_dests);
323 326
 }
324 327
 
... ...
@@ -47,6 +47,7 @@
47 47
 #define OSP_DEF_TIMEOUT                 (60 * 1000)
48 48
 #define OSP_DEF_DESTS                   5
49 49
 #define OSP_DEF_USERPID                 1
50
+#define OSP_DEF_REDIRURI                0   /* 0 for "xxxxxxxxxx@xxx.xxx.xxx.xxx", 1 for "<xxxxxxxxxx@xxx.xxx.xxx.xxx>" format */
50 51
 
51 52
 #define OSP_KEYBUF_SIZE                 256
52 53
 #define OSP_STRBUF_SIZE                 256
... ...
@@ -505,13 +505,15 @@ int ospGetRouteParameters(
505 505
  * param called Called number
506 506
  * param dest Destination IP
507 507
  * param port Destination port
508
+ * param format URI format
508 509
  * return 0 success, -1 failure
509 510
  */
510 511
 int ospRebuildDestionationUri(
511 512
     str* newuri, 
512 513
     char* called,
513 514
     char* dest, 
514
-    char* port) 
515
+    char* port,
516
+    int format) 
515 517
 {
516 518
     static const str TRANS = {";transport=tcp", 14};
517 519
     char* buffer;
... ...
@@ -525,22 +527,27 @@ int ospRebuildDestionationUri(
525 527
     destsize = strlen(dest);
526 528
     portsize = strlen(port);
527 529
 
528
-    LOG(L_DBG, "osp: '%s'(%i) '%s'(%i) '%s'(%i)\n",
530
+    LOG(L_DBG, "osp: '%s'(%i) '%s'(%i) '%s'(%i) '%d'\n",
529 531
         called, 
530 532
         calledsize,
531 533
         dest, 
532 534
         destsize, 
533 535
         port, 
534
-        portsize); 
536
+        portsize,
537
+        format); 
535 538
 
536
-    /* "sip:" + called + "@" + dest + : + port + " SIP/2.0" */
537
-    newuri->s = (char*)pkg_malloc(4 + calledsize + 1 + destsize + 1 + portsize + 1 + 16 + TRANS.len);
539
+    /* "sip:" + called + "@" + dest + : + port + " SIP/2.0" for URI format 0 */
540
+    /* "<sip:" + called + "@" + dest + : + port> + " SIP/2.0" for URI format 1 */
541
+    newuri->s = (char*)pkg_malloc(1 + 4 + calledsize + 1 + destsize + 1 + portsize + 1 + 1 + 16 + TRANS.len);
538 542
     if (newuri == NULL) {
539 543
         LOG(L_ERR, "osp: ERROR: no memory\n");
540 544
         return -1;
541 545
     }    
542 546
     buffer = newuri->s;
543 547
 
548
+    if (format == 1) {
549
+      *buffer++ = '<';
550
+    }
544 551
     *buffer++ = 's';
545 552
     *buffer++ = 'i';
546 553
     *buffer++ = 'p';
... ...
@@ -565,6 +572,10 @@ int ospRebuildDestionationUri(
565 572
         buffer += portsize;
566 573
     }
567 574
 
575
+    if (format == 1) {
576
+      *buffer++ = '>';
577
+    }
578
+
568 579
 /*    
569 580
     *buffer++ = ' ';
570 581
     *buffer++ = 'S';
... ...
@@ -47,7 +47,7 @@ int ospGetOspHeader(struct sip_msg* msg, unsigned char* token, unsigned int* tok
47 47
 int ospGetSourceAddress(struct sip_msg* msg, char* sourceaddress, int buffersize);
48 48
 int ospGetCallId(struct sip_msg* msg, OSPTCALLID** callid);
49 49
 int ospGetRouteParameters(struct sip_msg* msg, char* routeparams, int buffersize);
50
-int ospRebuildDestionationUri(str* newuri, char* called, char* dest, char* port);
50
+int ospRebuildDestionationUri(str* newuri, char* called, char* dest, char* port, int format);
51 51
 void ospGetNextHop(struct sip_msg* msg, char* nexthop, int buffersize);
52 52
 
53 53
 #endif /* _OSP_MOD_SIPHEADER_H_ */