Browse code

1. Fix [1524070] bug reported for Scalable SIP server project in SourceForge. Please check OpenSER tracker for details. 2. Change log output.

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

Di-Shi Sun authored on 20/07/2006 19:51:13
Showing 17 changed files
... ...
@@ -164,7 +164,7 @@ int ospCheckOrigDestination(void)
164 164
     }
165 165
 
166 166
     if (result == -1) {
167
-        LOG(L_DBG, "osp: there is no unused destination\n");
167
+        LOG(L_DBG, "osp: there is not unused destination\n");
168 168
     }
169 169
 
170 170
     return result;
... ...
@@ -216,7 +216,7 @@ osp_dest* ospGetNextOrigDestination(void)
216 216
     }
217 217
 
218 218
     if (result == NULL) {
219
-        LOG(L_DBG, "osp: there is no unused destination\n");
219
+        LOG(L_DBG, "osp: there is not unused destination\n");
220 220
     }
221 221
 
222 222
     return result;
... ...
@@ -289,55 +289,6 @@ static osp_dest* ospGetLastOrigDestination(void)
289 289
     return lastdest;
290 290
 }
291 291
 
292
-/*
293
- * Retrieved the forked destination from an AVP
294
- *    name - OSP_ORIGDEST_LABEL
295
- *    value - osp_dest wrapped in a string
296
- *    There can be 0, 1 or more destinations. 
297
- *    Find the used (used==1), has the same dest item as the parameter fork,
298
- *    and return it.
299
- *    Note, there maybe multiple result destinations. osp_fork can be exten to
300
- *    deal with it in the future. 
301
- * param fork Forked destination index
302
- * return NULL on failure
303
- */
304
-osp_dest* ospGetForkedDestination(
305
-    osp_fork* fork)
306
-{
307
-    struct usr_avp* destavp = NULL;
308
-    int_str destval;
309
-    osp_dest* dest = NULL;
310
-    osp_dest* forked = NULL;
311
-    char* host;
312
-
313
-    LOG(L_DBG, "osp: ospGetForkedDesintaion\n");
314
-
315
-    for (destavp = search_first_avp(AVP_NAME_STR | AVP_VAL_STR, (int_str)OSP_ORIGDEST_LABEL, NULL, 0);
316
-        destavp != NULL;
317
-        destavp = search_next_avp(destavp, NULL))
318
-    {
319
-        get_avp_val(destavp, &destval);
320
-
321
-        /* OSP destination is wrapped in a string */
322
-        dest = (osp_dest*)destval.s.s;
323
-
324
-        if (dest->used == 1) {
325
-            if (*dest->host == '[') {
326
-                host = dest->host + 1;
327
-            } else {
328
-                host = dest->host ;
329
-            }
330
-            if (memcmp(host, fork->host, strlen(fork->host)) == 0) {
331
-                LOG(L_DBG, "osp: found\n");
332
-                forked = dest;
333
-                break;
334
-            }
335
-        }
336
-    }
337
-
338
-    return forked;
339
-}
340
-
341 292
 /*
342 293
  * Record destination status
343 294
  * param code Destination status
... ...
@@ -474,7 +425,7 @@ void ospDumpAllDestination(void)
474 425
         ospDumpDestination(dest);
475 426
     }
476 427
     if (count == 0) {
477
-        LOG(L_DBG, "osp: there is no originate destination AVP\n");
428
+        LOG(L_DBG, "osp: there is not originate destination AVP\n");
478 429
     }
479 430
 
480 431
     destavp = search_first_avp(AVP_NAME_STR | AVP_VAL_STR, (int_str)OSP_TERMDEST_LABEL, NULL, 0);
... ...
@@ -489,7 +440,7 @@ void ospDumpAllDestination(void)
489 440
 
490 441
         ospDumpDestination(dest);
491 442
     } else {
492
-        LOG(L_DBG, "osp: there is no terminate destination AVP\n");
443
+        LOG(L_DBG, "osp: there is not terminate destination AVP\n");
493 444
     }
494 445
 }
495 446
 
... ...
@@ -61,19 +61,15 @@ typedef struct _osp_dest {
61 61
     int reported;
62 62
 } osp_dest;
63 63
 
64
-typedef struct _osp_fork {
65
-    char host[OSP_STRBUF_SIZE];
66
-} osp_fork;
67
-
68 64
 osp_dest* ospInitDestination(osp_dest* dest);
69 65
 int ospSaveOrigDestination(osp_dest* dest);
70 66
 int ospSaveTermDestination(osp_dest* dest);
71 67
 int ospCheckOrigDestination(void);
72 68
 osp_dest* ospGetNextOrigDestination(void);
73 69
 osp_dest* ospGetTermDestination(void);
74
-osp_dest* ospGetForkedDestination(osp_fork* fork);
75 70
 void ospRecordEvent(int clientcode, int servercode);
76 71
 void ospDumpDestination(osp_dest* dest);
77 72
 void ospDumpAllDestination(void);
78 73
 
79 74
 #endif /* _OSP_MOD_DESTINATION_H_ */
75
+
... ...
@@ -53,3 +53,4 @@ char _osp_LOCAL_CERTIFICATE[OSP_KEYBUF_SIZE];
53 53
 char _osp_CA_CERTIFICATE[OSP_KEYBUF_SIZE];
54 54
 
55 55
 OSPTPROVHANDLE _osp_provider = -1;
56
+
... ...
@@ -184,7 +184,7 @@ static int ospLoadRoutes(
184 184
             "valid after '%s' "
185 185
             "valid until '%s' "
186 186
             "time limit '%i' seconds "
187
-            "call-id '%.*s' "
187
+            "call id '%.*s' "
188 188
             "calling number '%s' "
189 189
             "called number '%s' "
190 190
             "host '%s' "
... ...
@@ -252,10 +252,10 @@ int requestosprouting(
252 252
     destcount = _osp_max_dests;
253 253
 
254 254
     if ((errorcode = OSPPTransactionNew(_osp_provider, &transaction)) != 0) {
255
-        LOG(L_ERR, "osp: ERROR: failed to create a new OSP transaction (%d)\n", errorcode);
255
+        LOG(L_ERR, "osp: ERROR: failed to create new OSP transaction (%d)\n", errorcode);
256 256
     } else if (ospGetFromUserpart(msg, source, sizeof(source)) != 0) {
257 257
         LOG(L_ERR, "osp: ERROR: failed to extract calling number\n");
258
-    } else if (ospGetToUserpart(msg, destination, sizeof(destination)) != 0) {
258
+    } else if (ospGetUriUserpart(msg, destination, sizeof(destination)) != 0) {
259 259
         LOG(L_ERR, "osp: ERROR: failed to extract called number\n");
260 260
     } else if (ospGetCallId(msg, &(callids[0])) != 0) {
261 261
         LOG(L_ERR, "osp: ERROR: failed to extract call id\n");
... ...
@@ -263,14 +263,14 @@ int requestosprouting(
263 263
         LOG(L_ERR, "osp: ERROR: failed to extract source address\n");
264 264
     } else {
265 265
         LOG(L_INFO,
266
-            "osp: requesting OSP auth and routing for: "
267
-            "transaction-handle '%i' "
268
-            "osp_source '%s' "
269
-            "osp_source_port '%s' "
270
-            "osp_source_dev '%s' "
266
+            "osp: request auth and routing for: "
267
+            "transaction '%i' "
268
+            "source '%s' "
269
+            "source_port '%s' "
270
+            "source_dev '%s' "
271 271
             "e164_source '%s' "
272 272
             "e164_dest '%s' "
273
-            "call-id '%.*s' "
273
+            "call_id '%.*s' "
274 274
             "dest_count '%i'\n",
275 275
             transaction,
276 276
             _osp_device_ip,
... ...
@@ -306,7 +306,7 @@ int requestosprouting(
306 306
 
307 307
         if ((errorcode == 0) && (destcount > 0)) {
308 308
             LOG(L_INFO, 
309
-                "osp: there are '%d' OSP routes, call-id '%.*s' transaction-id '%lld'\n",
309
+                "osp: there are '%d' OSP routes, call_id '%.*s' transaction_id '%lld'\n",
310 310
                 destcount,
311 311
                 callids[0]->ospmCallIdLen, 
312 312
                 callids[0]->ospmCallIdVal,
... ...
@@ -315,7 +315,7 @@ int requestosprouting(
315 315
             result = ospLoadRoutes(msg, transaction, destcount, _osp_device_ip, sourcedev, authtime);
316 316
         } else if ((errorcode == 0) && (destcount == 0)) {
317 317
             LOG(L_INFO, 
318
-                "osp: there is 0 osp routes, call-id '%.*s' transaction-id '%lld'\n",
318
+                "osp: there is 0 osp routes, call_id '%.*s' transaction_id '%lld'\n",
319 319
                 callids[0]->ospmCallIdLen,
320 320
                 callids[0]->ospmCallIdVal,
321 321
                 ospGetTransactionId(transaction));
... ...
@@ -323,7 +323,7 @@ int requestosprouting(
323 323
             ospRecordEvent(0, 503);
324 324
         } else {
325 325
             LOG(L_ERR, 
326
-                "osp: ERROR: failed to request auth and routing (%i), call-id '%.*s' transaction-id '%lld'\n",
326
+                "osp: ERROR: failed to request auth and routing (%i), call_id '%.*s' transaction_id '%lld'\n",
327 327
                 errorcode,
328 328
                 callids[0]->ospmCallIdLen,
329 329
                 callids[0]->ospmCallIdVal,
... ...
@@ -386,7 +386,7 @@ static int ospPrepareDestination(
386 386
         ospRebuildDestionationUri(&newuri, dest->called, dest->host, dest->networkid);
387 387
 
388 388
         LOG(L_INFO, 
389
-            "osp: preparing route to uri '%.*s' for call-id '%.*s' transaction-id '%lld'\n",
389
+            "osp: prepare route to URI '%.*s' for call_id '%.*s' transaction_id '%lld'\n",
390 390
             newuri.len,
391 391
             newuri.s,
392 392
             dest->callidsize,
... ...
@@ -460,7 +460,7 @@ int prepareallosproutes(
460 460
 {
461 461
     int result = MODULE_RETURNCODE_TRUE;
462 462
 
463
-    LOG(L_DBG, "osp: preparingallosproute\n");
463
+    LOG(L_DBG, "osp: prepareallosproute\n");
464 464
 
465 465
     for(result = ospPrepareDestination(msg, OSP_FIRST_ROUTE, OSP_MAIN_ROUTE);
466 466
         result == MODULE_RETURNCODE_TRUE;
... ...
@@ -470,3 +470,4 @@ int prepareallosproutes(
470 470
 
471 471
     return MODULE_RETURNCODE_TRUE;
472 472
 }
473
+
... ...
@@ -39,3 +39,4 @@ int prepareosproute(struct sip_msg*, char*, char*);
39 39
 int prepareallosproutes(struct sip_msg*, char*, char*);
40 40
 
41 41
 #endif /* _OSP_MOD_ORIG_TRANSACTION_H_ */
42
+
... ...
@@ -236,7 +236,7 @@ static int ospVerifyParameters(void)
236 236
 /*
237 237
  * Dump OSP module configuration
238 238
  */
239
-void ospDumpParameters(void) 
239
+static void ospDumpParameters(void) 
240 240
 {
241 241
     LOG(L_INFO, 
242 242
         "osp: module configuration: "
... ...
@@ -54,3 +54,4 @@
54 54
 #define OSP_HEADERBUF_SIZE              3072
55 55
 
56 56
 #endif /* _OSP_MOD_H_ */
57
+
... ...
@@ -68,7 +68,7 @@ unsigned long long ospGetTransactionId(
68 68
         id = (unsigned long long)context->TransactionID;
69 69
     } else {
70 70
         LOG(L_ERR, 
71
-            "osp: ERROR: failed to extract transaction ID from transaction handle %d (%d)\n",
71
+            "osp: ERROR: failed to extract transaction_id from transaction handle %d (%d)\n",
72 72
             transaction,
73 73
             errorcode);
74 74
     }
... ...
@@ -107,7 +107,7 @@ void ospReportUsage(
107 107
     int errorcode;
108 108
 
109 109
     LOG(L_DBG, "osp: ospReportUsage\n");
110
-    LOG(L_DBG, "osp: Scheduling usage report for '%lld'\n", ospGetTransactionId(ospvTransaction));
110
+    LOG(L_DBG, "osp: schedule usage report for '%lld'\n", ospGetTransactionId(ospvTransaction));
111 111
 
112 112
     usage = (osp_usage*)malloc(sizeof(osp_usage));
113 113
 
... ...
@@ -167,7 +167,7 @@ static OSPTTHREADRETURN ospReportUsageWork(
167 167
 
168 168
         if (errorcode == 0) {
169 169
             LOG(L_DBG, 
170
-                "osp: reported usage for '%lld'\n", 
170
+                "osp: reporte usage for '%lld'\n", 
171 171
                 ospGetTransactionId(usage->ospvTransaction));
172 172
             break;
173 173
         } else {
... ...
@@ -57,3 +57,4 @@ void ospReportUsage(
57 57
 );
58 58
 
59 59
 #endif /* _OSP_MOD_OSPTOOLKIT_H_ */
60
+
... ...
@@ -93,7 +93,7 @@ int ospSetupProvider(void)
93 93
         if (result != 0) {
94 94
             LOG(L_ERR, "osp: ERROR: failed to create provider (%i)\n", result);
95 95
         } else {
96
-            LOG(L_DBG, "osp: created a new (per process) provider '%d'\n", _osp_provider);
96
+            LOG(L_DBG, "osp: created new (per process) provider '%d'\n", _osp_provider);
97 97
             result = 0;
98 98
         }
99 99
     }
... ...
@@ -35,3 +35,4 @@ int ospSetupProvider(void);
35 35
 int ospDeleteProvider(void);
36 36
 
37 37
 #endif /* _OSP_MOD_PROVIDER_H_ */
38
+
... ...
@@ -357,7 +357,7 @@ int ospGetSourceAddress(
357 357
             via = (struct via_body*)hf->parsed;    
358 358
             ospCopyStrToBuffer(&via->host, sourceaddress, buffersize);
359 359
 
360
-            LOG(L_DBG, "osp: source address is '%s'\n", sourceaddress);
360
+            LOG(L_DBG, "osp: source address '%s'\n", sourceaddress);
361 361
 
362 362
             result = 0;
363 363
             break;
... ...
@@ -591,3 +591,4 @@ void ospGetNextHop(
591 591
         found =1;
592 592
     }
593 593
 }
594
+
... ...
@@ -97,7 +97,7 @@ int validateospheader (
97 97
         LOG(L_ERR, "osp: ERROR: failed to create a new OSP transaction handle (%d)\n", errorcode);
98 98
     } else if (ospGetFromUserpart(msg, dest.calling, sizeof(dest.calling)) != 0) {
99 99
         LOG(L_ERR, "osp: ERROR: failed to extract calling number\n");
100
-    } else if (ospGetToUserpart(msg, dest.called, sizeof(dest.called)) != 0) {
100
+    } else if (ospGetUriUserpart(msg, dest.called, sizeof(dest.called)) != 0) {
101 101
         LOG(L_ERR, "osp: ERROR: failed to extract called number\n");
102 102
     } else if (ospGetCallId(msg, &callid) != 0) {
103 103
         LOG(L_ERR, "osp: ERROR: failed to extract call id\n");
... ...
@@ -107,12 +107,12 @@ int validateospheader (
107 107
         LOG(L_ERR, "osp: ERROR: failed to extract OSP authorization token\n");
108 108
     } else {
109 109
         LOG(L_INFO, 
110
-            "osp: validating token for: "
111
-            "transaction-handle '%i' "
110
+            "osp: validate token for: "
111
+            "transaction_handle '%i' "
112 112
             "e164_source '%s' "
113 113
             "e164_dest '%s' "
114 114
             "validate_call_id '%s' "
115
-            "call-id '%.*s'\n",
115
+            "call_id '%.*s'\n",
116 116
             transaction,
117 117
             dest.calling,
118 118
             dest.called,
... ...
@@ -156,7 +156,7 @@ int validateospheader (
156 156
 
157 157
         if ((errorcode == 0) && (authorized == 1)) {
158 158
             LOG(L_DBG, 
159
-                "osp: call is authorized for %d seconds, call-id '%.*s' transaction-id '%lld'",
159
+                "osp: call is authorized for %d seconds, call_id '%.*s' transaction_id '%lld'",
160 160
                 timelimit,
161 161
                 dest.callidsize,
162 162
                 dest.callid,
... ...
@@ -37,3 +37,4 @@ int checkospheader(struct sip_msg*, char*, char*);
37 37
 int validateospheader(struct sip_msg*, char*, char*);
38 38
 
39 39
 #endif /* _OSP_MOD_TERM_TRANSACTION_H_ */
40
+
... ...
@@ -39,3 +39,4 @@
39 39
 int ospInitTm(void);
40 40
 
41 41
 #endif /* _OSP_MOD_TM_H_ */
42
+
... ...
@@ -166,7 +166,7 @@ void ospRecordTermTransaction(
166 166
  * param isorig Originate / Terminate
167 167
  * return
168 168
  */
169
-int ospReportUsageFromCookie(
169
+static int ospReportUsageFromCookie(
170 170
     struct sip_msg* msg,
171 171
     char* cookie, 
172 172
     OSPTCALLID* callid, 
... ...
@@ -219,12 +219,12 @@ int ospReportUsageFromCookie(
219 219
 
220 220
     ospGetSourceAddress(msg, firstvia, sizeof(firstvia));
221 221
     ospGetFromUserpart(msg, from, sizeof(from));
222
-    ospGetToUserpart(msg, to, sizeof(to));
222
+    ospGetUriUserpart(msg, to, sizeof(to));
223 223
     ospGetNextHop(msg, nexthop, sizeof(nexthop));
224 224
 
225 225
     if (strcmp(firstvia, uac) == 0) {
226 226
         LOG(L_INFO,
227
-            "osp: originator '%s' released the call, call-id '%.*s' transaction-id '%lld'\n",
227
+            "osp: originator '%s' released the call, call_id '%.*s' transaction_id '%lld'\n",
228 228
             firstvia,
229 229
             callid->ospmCallIdLen,
230 230
             callid->ospmCallIdVal,
... ...
@@ -235,7 +235,7 @@ int ospReportUsageFromCookie(
235 235
         terminator = nexthop;
236 236
     } else {
237 237
         LOG(L_INFO,
238
-            "osp: terminator '%s' released the cal, call-id '%.*s' transaction-id '%lld'\n",
238
+            "osp: terminator '%s' released the call, call_id '%.*s' transaction_id '%lld'\n",
239 239
             firstvia,
240 240
             callid->ospmCallIdLen,
241 241
             callid->ospmCallIdVal,
... ...
@@ -268,7 +268,7 @@ int ospReportUsageFromCookie(
268 268
         NULL,
269 269
         NULL);
270 270
 
271
-    LOG(L_DBG, "osp: building usage handle '%d' (%d)\n", transaction, errorcode);
271
+    LOG(L_DBG, "osp: built usage handle '%d' (%d)\n", transaction, errorcode);
272 272
 
273 273
     ospReportUsage(
274 274
         transaction,
... ...
@@ -313,7 +313,7 @@ int reportospusage(
313 313
         {
314 314
             if (strncmp(token, OSP_ORIG_COOKY, strlen(OSP_ORIG_COOKY)) == 0) {
315 315
                 LOG(L_INFO,
316
-                    "osp: reporting originate duration usage for call-id '%.*s'\n",
316
+                    "osp: report originate duration usage for call_id '%.*s'\n",
317 317
                     callid->ospmCallIdLen,
318 318
                     callid->ospmCallIdVal);
319 319
                 isorig = 1;
... ...
@@ -321,7 +321,7 @@ int reportospusage(
321 321
                 result = MODULE_RETURNCODE_TRUE;
322 322
             } else if (strncmp(token, OSP_TERM_COOKY, strlen(OSP_TERM_COOKY)) == 0) {
323 323
                 LOG(L_INFO,
324
-                    "osp: reporting terminate duration usage for call-id '%.*s'\n",
324
+                    "osp: report terminate duration usage for call_id '%.*s'\n",
325 325
                     callid->ospmCallIdLen,
326 326
                     callid->ospmCallIdVal);
327 327
                 isorig = 0;
... ...
@@ -338,7 +338,7 @@ int reportospusage(
338 338
     }
339 339
 
340 340
     if (result == MODULE_RETURNCODE_FALSE) {
341
-        LOG(L_DBG, "osp: there is no OSP originating or terminating usage information\n");
341
+        LOG(L_DBG, "osp: there is not OSP originating or terminating usage information\n");
342 342
     }
343 343
 
344 344
     return result;
... ...
@@ -351,7 +351,7 @@ int reportospusage(
351 351
  * param lastcode Destination status
352 352
  * return 0 success, others failure
353 353
  */
354
-int ospBuildUsageFromDestination(
354
+static int ospBuildUsageFromDestination(
355 355
     OSPTTRANHANDLE transaction, 
356 356
     osp_dest* dest, 
357 357
     int lastcode)
... ...
@@ -389,7 +389,7 @@ int ospBuildUsageFromDestination(
389 389
  * param dest Destination
390 390
  * return 0 success
391 391
  */
392
-int ospReportUsageFromDestination(
392
+static int ospReportUsageFromDestination(
393 393
     OSPTTRANHANDLE transaction, 
394 394
     osp_dest* dest)
395 395
 {
... ...
@@ -440,7 +440,7 @@ void ospReportOrigSetupUsage(void)
440 440
                 break;
441 441
             }
442 442
 
443
-            LOG(L_DBG, "osp: iterating through a used destination\n");
443
+            LOG(L_DBG, "osp: iterating through used destination\n");
444 444
 
445 445
             ospDumpDestination(dest);
446 446
 
... ...
@@ -457,7 +457,7 @@ void ospReportOrigSetupUsage(void)
457 457
 
458 458
     if (lastused) {
459 459
         LOG(L_INFO,
460
-            "osp: reporting originate setup usage for call-id '%.*s' transaction-id '%lld'\n",
460
+            "osp: reporting originate setup usage for call_id '%.*s' transaction_id '%lld'\n",
461 461
             lastused->callidsize,
462 462
             lastused->callid,
463 463
             lastused->tid);
... ...
@@ -485,7 +485,7 @@ void ospReportTermSetupUsage(void)
485 485
     if ((dest = ospGetTermDestination())) {
486 486
         if (dest->reported == 0) {
487 487
             LOG(L_INFO,
488
-                "osp: reporting terminate setup usage for call-id '%.*s' transaction-id '%lld'\n",
488
+                "osp: reporting terminate setup usage for call_id '%.*s' transaction_id '%lld'\n",
489 489
                 dest->callidsize,
490 490
                 dest->callid,
491 491
                 dest->tid);
... ...
@@ -496,6 +496,6 @@ void ospReportTermSetupUsage(void)
496 496
             LOG(L_DBG, "osp: destination usage has already been reported\n");
497 497
         }
498 498
     } else {
499
-        LOG(L_ERR, "osp: ERROR: there is no terminate destination to report\n");
499
+        LOG(L_ERR, "osp: ERROR: there is not terminate destination to report\n");
500 500
     }
501 501
 }
... ...
@@ -56,3 +56,4 @@ void ospReportTermSetupUsage(void);
56 56
 int  reportospusage(struct sip_msg* msg, char* ignore1, char* ignore2);
57 57
 
58 58
 #endif /* _OSP_MOD_USAGE_H_ */
59
+