Browse code

1. Increase OSP service point number from 2 to 16.

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

Di-Shi Sun authored on 11/12/2006 21:38:30
Showing 4 changed files
... ...
@@ -32,8 +32,14 @@
32 32
 #include <osp/osp.h>
33 33
 #include "osp_mod.h"
34 34
 
35
+unsigned int _osp_sp_number;
35 36
 char* _osp_sp_uris[OSP_DEF_SPS];
36
-unsigned long _osp_sp_weights[OSP_DEF_SPS] = {OSP_DEF_WEIGHT, OSP_DEF_WEIGHT};
37
+unsigned long _osp_sp_weights[OSP_DEF_SPS] = {
38
+    OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT,
39
+    OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT,
40
+    OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT,
41
+    OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT
42
+};
37 43
 char* _osp_device_ip = NULL;
38 44
 char* _osp_device_port = NULL;
39 45
 unsigned char* _osp_private_key = NULL;
... ...
@@ -44,6 +44,7 @@
44 44
 
45 45
 MODULE_VERSION
46 46
 
47
+extern unsigned int _osp_sp_number;
47 48
 extern char* _osp_sp_uris[];
48 49
 extern unsigned long _osp_sp_weights[];
49 50
 extern char* _osp_device_ip;
... ...
@@ -89,9 +90,37 @@ static cmd_export_t cmds[]={
89 90
 
90 91
 static param_export_t params[]={
91 92
     {"sp1_uri",                        STR_PARAM, &_osp_sp_uris[0]},
92
-    {"sp1_weight",                     INT_PARAM, &(_osp_sp_weights[0])},
93 93
     {"sp2_uri",                        STR_PARAM, &_osp_sp_uris[1]},
94
+    {"sp3_uri",                        STR_PARAM, &_osp_sp_uris[2]},
95
+    {"sp4_uri",                        STR_PARAM, &_osp_sp_uris[3]},
96
+    {"sp5_uri",                        STR_PARAM, &_osp_sp_uris[4]},
97
+    {"sp6_uri",                        STR_PARAM, &_osp_sp_uris[5]},
98
+    {"sp7_uri",                        STR_PARAM, &_osp_sp_uris[6]},
99
+    {"sp8_uri",                        STR_PARAM, &_osp_sp_uris[7]},
100
+    {"sp9_uri",                        STR_PARAM, &_osp_sp_uris[8]},
101
+    {"sp10_uri",                       STR_PARAM, &_osp_sp_uris[9]},
102
+    {"sp11_uri",                       STR_PARAM, &_osp_sp_uris[10]},
103
+    {"sp12_uri",                       STR_PARAM, &_osp_sp_uris[11]},
104
+    {"sp13_uri",                       STR_PARAM, &_osp_sp_uris[12]},
105
+    {"sp14_uri",                       STR_PARAM, &_osp_sp_uris[13]},
106
+    {"sp15_uri",                       STR_PARAM, &_osp_sp_uris[14]},
107
+    {"sp16_uri",                       STR_PARAM, &_osp_sp_uris[15]},
108
+    {"sp1_weight",                     INT_PARAM, &(_osp_sp_weights[0])},
94 109
     {"sp2_weight",                     INT_PARAM, &(_osp_sp_weights[1])},
110
+    {"sp3_weight",                     INT_PARAM, &(_osp_sp_weights[2])},
111
+    {"sp4_weight",                     INT_PARAM, &(_osp_sp_weights[3])},
112
+    {"sp5_weight",                     INT_PARAM, &(_osp_sp_weights[4])},
113
+    {"sp6_weight",                     INT_PARAM, &(_osp_sp_weights[5])},
114
+    {"sp7_weight",                     INT_PARAM, &(_osp_sp_weights[6])},
115
+    {"sp8_weight",                     INT_PARAM, &(_osp_sp_weights[7])},
116
+    {"sp9_weight",                     INT_PARAM, &(_osp_sp_weights[8])},
117
+    {"sp10_weight",                    INT_PARAM, &(_osp_sp_weights[9])},
118
+    {"sp11_weight",                    INT_PARAM, &(_osp_sp_weights[10])},
119
+    {"sp12_weight",                    INT_PARAM, &(_osp_sp_weights[11])},
120
+    {"sp13_weight",                    INT_PARAM, &(_osp_sp_weights[12])},
121
+    {"sp14_weight",                    INT_PARAM, &(_osp_sp_weights[13])},
122
+    {"sp15_weight",                    INT_PARAM, &(_osp_sp_weights[14])},
123
+    {"sp16_weight",                    INT_PARAM, &(_osp_sp_weights[15])},
95 124
     {"device_ip",                      STR_PARAM, &_osp_device_ip},
96 125
     {"device_port",                    STR_PARAM, &_osp_device_port},
97 126
     {"private_key",                    STR_PARAM, &_osp_private_key},
... ...
@@ -237,15 +266,17 @@ static int ospVerifyParameters(void)
237 266
             OSP_DEF_TOKEN);
238 267
     }
239 268
 
240
-    if (_osp_sp_uris[1] == NULL) {
241
-        _osp_sp_uris[1] = _osp_sp_uris[0];
242
-    }
243
-
244 269
     if (_osp_sp_uris[0] == NULL) {
245 270
         LOG(L_ERR, "osp: ERROR: sp1_uri must be configured\n");
246 271
         result = -1;
247 272
     }
248 273
 
274
+    for (_osp_sp_number = 1; _osp_sp_number < OSP_DEF_SPS; _osp_sp_number++) {
275
+        if (_osp_sp_uris[_osp_sp_number] == NULL) {
276
+            break;
277
+        }
278
+    }
279
+
249 280
     ospDumpParameters();
250 281
 
251 282
     return result;
... ...
@@ -256,45 +287,25 @@ static int ospVerifyParameters(void)
256 287
  */
257 288
 static void ospDumpParameters(void) 
258 289
 {
259
-    LOG(L_INFO, 
260
-        "osp: module configuration: "
261
-        "sp1_uri '%s' "
262
-        "sp1_weight '%ld' "
263
-        "sp2_uri '%s' "
264
-        "sp2_weight '%ld' "
265
-        "device_ip '%s' "
266
-        "device_port '%s' "
267
-        "private_key '%s' "
268
-        "local_certificate '%s' "
269
-        "ca_certificates '%s' "
270
-        "enable_crypto_hardware_support '%d' "
271
-        "token_format '%d' "
272
-        "ssl_lifetime '%d' "
273
-        "persistence '%d' "
274
-        "retry_delay '%d' "
275
-        "retry_limit '%d' "
276
-        "timeout '%d' "
277
-        "validate_call_id '%d' "
278
-        "use_rpid_for_calling_number '%d' "
279
-        "max_destinations '%d'\n",
280
-        _osp_sp_uris[0],
281
-        _osp_sp_weights[0],
282
-        _osp_sp_uris[1],
283
-        _osp_sp_weights[1],
284
-        _osp_device_ip,
285
-        _osp_device_port,
286
-        _osp_private_key,
287
-        _osp_local_certificate,
288
-        _osp_ca_certificate,
289
-        _osp_crypto_hw,
290
-        _osp_token_format,
291
-        _osp_ssl_lifetime,
292
-        _osp_persistence,
293
-        _osp_retry_delay,
294
-        _osp_retry_limit,
295
-        _osp_timeout,
296
-        _osp_validate_callid,
297
-        _osp_use_rpid,
298
-        _osp_max_dests);
290
+    int i;
291
+
292
+    LOG(L_INFO, "osp: module configuration: ");
293
+    for (i = 0; i < _osp_sp_number; i++) {
294
+        LOG(L_INFO, "    sp%d_uri '%s' sp%d_weight '%ld' ", i + 1, _osp_sp_uris[i], i + 1, _osp_sp_weights[i]);
295
+    }
296
+    LOG(L_INFO, "    device_ip '%s' device_port '%s' ", _osp_device_ip, _osp_device_port);
297
+    LOG(L_INFO, "    private_key '%s' ", _osp_private_key);
298
+    LOG(L_INFO, "    local_certificate '%s' ", _osp_local_certificate);
299
+    LOG(L_INFO, "    ca_certificates '%s' ", _osp_ca_certificate);
300
+    LOG(L_INFO, "    enable_crypto_hardware_support '%d' ", _osp_crypto_hw);
301
+    LOG(L_INFO, "    token_format '%d' ", _osp_token_format);
302
+    LOG(L_INFO, "    ssl_lifetime '%d' ", _osp_ssl_lifetime);
303
+    LOG(L_INFO, "    persistence '%d' ", _osp_persistence);
304
+    LOG(L_INFO, "    retry_delay '%d' ", _osp_retry_delay);
305
+    LOG(L_INFO, "    retry_limit '%d' ", _osp_retry_limit);
306
+    LOG(L_INFO, "    timeout '%d' ", _osp_timeout);
307
+    LOG(L_INFO, "    validate_call_id '%d' ", _osp_validate_callid);
308
+    LOG(L_INFO, "    use_rpid_for_calling_number '%d' ", _osp_use_rpid);
309
+    LOG(L_INFO, "    max_destinations '%d'\n", _osp_max_dests);
299 310
 }
300 311
 
... ...
@@ -35,7 +35,7 @@
35 35
 #define MODULE_RETURNCODE_STOPROUTE     0
36 36
 #define MODULE_RETURNCODE_FALSE         -1
37 37
 
38
-#define OSP_DEF_SPS                     2
38
+#define OSP_DEF_SPS                     16
39 39
 #define OSP_DEF_WEIGHT                  1000
40 40
 #define OSP_DEF_HW                      0
41 41
 #define OSP_DEF_CALLID                  1    /* Validate call ids, set to 0 to disable */
... ...
@@ -33,6 +33,7 @@
33 33
 #include "../../dprint.h"
34 34
 #include "provider.h"
35 35
 
36
+extern unsigned int _osp_sp_number;
36 37
 extern char* _osp_sp_uris[];
37 38
 extern unsigned long _osp_sp_weights[];
38 39
 extern unsigned char* _osp_private_key;
... ...
@@ -72,7 +73,7 @@ int ospSetupProvider(void)
72 73
         LOG(L_ERR, "osp: ERROR: failed to load CA certificate from '%s'\n", _osp_ca_certificate);
73 74
     } else {
74 75
         result = OSPPProviderNew(
75
-            2,
76
+            _osp_sp_number,
76 77
             (const char**)_osp_sp_uris,
77 78
             _osp_sp_weights,
78 79
             "http://localhost:1234",