Browse code

- support for priority of destination - makes more predictible what destination is going to be chosen as the order in destination list can be forced - backward compatibility with versions without flags and priority preserved - new module parameter to control the name of the priority column

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

Daniel-Constantin Mierla authored on 14/01/2009 11:52:18
Showing 5 changed files
... ...
@@ -42,20 +42,21 @@ Carsten Bock
42 42
               1.3.4. setid_col (string)
43 43
               1.3.5. destination_col (string)
44 44
               1.3.6. flags_col (string)
45
-              1.3.7. force_dst (int)
46
-              1.3.8. flags (int)
47
-              1.3.9. use_default (int)
48
-              1.3.10. dst_avp (str)
49
-              1.3.11. grp_avp (str)
50
-              1.3.12. cnt_avp (str)
51
-              1.3.13. hash_pvar (str)
52
-              1.3.14. setid_pvar (str)
53
-              1.3.15. ds_ping_method (string)
54
-              1.3.16. ds_ping_from (string)
55
-              1.3.17. ds_ping_interval (int)
56
-              1.3.18. ds_probing_threshhold (int)
57
-              1.3.19. ds_probing_mode (int)
58
-              1.3.20. ds_append_branch (int)
45
+              1.3.7. priority_col (string)
46
+              1.3.8. force_dst (int)
47
+              1.3.9. flags (int)
48
+              1.3.10. use_default (int)
49
+              1.3.11. dst_avp (str)
50
+              1.3.12. grp_avp (str)
51
+              1.3.13. cnt_avp (str)
52
+              1.3.14. hash_pvar (str)
53
+              1.3.15. setid_pvar (str)
54
+              1.3.16. ds_ping_method (string)
55
+              1.3.17. ds_ping_from (string)
56
+              1.3.18. ds_ping_interval (int)
57
+              1.3.19. ds_probing_threshhold (int)
58
+              1.3.20. ds_probing_mode (int)
59
+              1.3.21. ds_append_branch (int)
59 60
 
60 61
         1.4. Exported Functions
61 62
 
... ...
@@ -89,24 +90,25 @@ Carsten Bock
89 90
    1.4. Set "setid_col" parameter
90 91
    1.5. Set "destination_col" parameter
91 92
    1.6. Set "flags_col" parameter
92
-   1.7. Set the "force_dst" parameter
93
-   1.8. Set the "flags" parameter
94
-   1.9. Set the "use_default" parameter
95
-   1.10. Set the "dst_avp" parameter
96
-   1.11. Set the "grp_avp" parameter
97
-   1.12. Set the "cnt_avp" parameter
98
-   1.13. Use $avp(i:273) for hashing:
99
-   1.14. Use combination of PVs for hashing:
100
-   1.15. Set the "setid_pvar" parameter
101
-   1.16. Set the "ds_ping_method" parameter
102
-   1.17. Set the "ds_ping_from" parameter
103
-   1.18. Set the "ds_ping_interval" parameter
104
-   1.19. Set the "ds_probing_threshhold" parameter
105
-   1.20. Set the "ds_probing_mode" parameter
106
-   1.21. Set the "ds_append_branch" parameter
107
-   1.22. ds_select_dst usage
108
-   1.23. dispatcher list file
109
-   1.24. Kamailio config script - sample dispatcher usage
93
+   1.7. Set "priority_col" parameter
94
+   1.8. Set the "force_dst" parameter
95
+   1.9. Set the "flags" parameter
96
+   1.10. Set the "use_default" parameter
97
+   1.11. Set the "dst_avp" parameter
98
+   1.12. Set the "grp_avp" parameter
99
+   1.13. Set the "cnt_avp" parameter
100
+   1.14. Use $avp(i:273) for hashing:
101
+   1.15. Use combination of PVs for hashing:
102
+   1.16. Set the "setid_pvar" parameter
103
+   1.17. Set the "ds_ping_method" parameter
104
+   1.18. Set the "ds_ping_from" parameter
105
+   1.19. Set the "ds_ping_interval" parameter
106
+   1.20. Set the "ds_probing_threshhold" parameter
107
+   1.21. Set the "ds_probing_mode" parameter
108
+   1.22. Set the "ds_append_branch" parameter
109
+   1.23. ds_select_dst usage
110
+   1.24. dispatcher list file
111
+   1.25. Kamailio config script - sample dispatcher usage
110 112
 
111 113
 Chapter 1. Admin Guide
112 114
 
... ...
@@ -208,19 +210,31 @@ modparam("dispatcher", "destination_col", "uri")
208 210
 modparam("dispatcher", "flags_col", "dstflags")
209 211
 ...
210 212
 
211
-1.3.7. force_dst (int)
213
+1.3.7. priority_col (string)
214
+
215
+   The column's name in the database storing the priority for
216
+   destination uri.
217
+
218
+   Default value is "priority".
219
+
220
+   Example 1.7. Set "priority_col" parameter
221
+...
222
+modparam("dispatcher", "priority_col", "dstpriority")
223
+...
224
+
225
+1.3.8. force_dst (int)
212 226
 
213 227
    If set to 1, force overwriting of destination address when that
214 228
    is already set.
215 229
 
216 230
    Default value is "0".
217 231
 
218
-   Example 1.7. Set the "force_dst" parameter
232
+   Example 1.8. Set the "force_dst" parameter
219 233
 ...
220 234
 modparam("dispatcher", "force_dst", 1)
221 235
 ...
222 236
 
223
-1.3.8. flags (int)
237
+1.3.9. flags (int)
224 238
 
225 239
    Various flags that affect dispatcher's behaviour. The flags are
226 240
    defined as a bitmask on an integer value. If flag 1 is set only
... ...
@@ -236,12 +250,12 @@ modparam("dispatcher", "force_dst", 1)
236 250
 
237 251
    Default value is "0".
238 252
 
239
-   Example 1.8. Set the "flags" parameter
253
+   Example 1.9. Set the "flags" parameter
240 254
  ...
241 255
  modparam("dispatcher", "flags", 3)
242 256
  ...
243 257
 
244
-1.3.9. use_default (int)
258
+1.3.10. use_default (int)
245 259
 
246 260
    If the parameter is set to 1, the last address in destination
247 261
    set is used as last option to send the message. For example, it
... ...
@@ -250,12 +264,12 @@ modparam("dispatcher", "force_dst", 1)
250 264
 
251 265
    Default value is "0".
252 266
 
253
-   Example 1.9. Set the "use_default" parameter
267
+   Example 1.10. Set the "use_default" parameter
254 268
  ...
255 269
  modparam("dispatcher", "use_default", 1)
256 270
  ...
257 271
 
258
-1.3.10. dst_avp (str)
272
+1.3.11. dst_avp (str)
259 273
 
260 274
    The name of the avp which will hold the list with addresses, in
261 275
    the order they have been selected by the chosen algorithm. If
... ...
@@ -272,12 +286,12 @@ Note
272 286
 
273 287
    Default value is "null" - don't add AVPs.
274 288
 
275
-   Example 1.10. Set the "dst_avp" parameter
289
+   Example 1.11. Set the "dst_avp" parameter
276 290
  ...
277 291
  modparam("dispatcher", "dst_avp", "$avp(i:271)")
278 292
  ...
279 293
 
280
-1.3.11. grp_avp (str)
294
+1.3.12. grp_avp (str)
281 295
 
282 296
    The name of the avp storing the group id of the destination
283 297
    set. Good to have it for later usage or checks.
... ...
@@ -289,12 +303,12 @@ Note
289 303
 
290 304
    Default value is "null" - don't add AVP.
291 305
 
292
-   Example 1.11. Set the "grp_avp" parameter
306
+   Example 1.12. Set the "grp_avp" parameter
293 307
  ...
294 308
  modparam("dispatcher", "grp_avp", "$avp(i:272)")
295 309
  ...
296 310
 
297
-1.3.12. cnt_avp (str)
311
+1.3.13. cnt_avp (str)
298 312
 
299 313
    The name of the avp storing the number of destination addresses
300 314
    kept in dst_avp avps.
... ...
@@ -306,12 +320,12 @@ Note
306 320
 
307 321
    Default value is "null" - don't add AVP.
308 322
 
309
-   Example 1.12. Set the "cnt_avp" parameter
323
+   Example 1.13. Set the "cnt_avp" parameter
310 324
  ...
311 325
  modparam("dispatcher", "cnt_avp", "$avp(i:273)")
312 326
  ...
313 327
 
314
-1.3.13. hash_pvar (str)
328
+1.3.14. hash_pvar (str)
315 329
 
316 330
    String with PVs used for the hashing algorithm 7.
317 331
 
... ...
@@ -322,29 +336,29 @@ Note
322 336
 
323 337
    Default value is "null" - disabled.
324 338
 
325
-   Example 1.13. Use $avp(i:273) for hashing:
339
+   Example 1.14. Use $avp(i:273) for hashing:
326 340
  ...
327 341
  modparam("dispatcher", "hash_pvar", "$avp(i:273)")
328 342
  ...
329 343
 
330
-   Example 1.14. Use combination of PVs for hashing:
344
+   Example 1.15. Use combination of PVs for hashing:
331 345
  ...
332 346
  modparam("dispatcher", "hash_pvar", "hash the $fU@$ci")
333 347
  ...
334 348
 
335
-1.3.14. setid_pvar (str)
349
+1.3.15. setid_pvar (str)
336 350
 
337 351
    The name of the PV where to store the set ID (group ID) when
338 352
    calling ds_is_from_list() with no parameter.
339 353
 
340 354
    Default value is "null" - don't set PV.
341 355
 
342
-   Example 1.15. Set the "setid_pvar" parameter
356
+   Example 1.16. Set the "setid_pvar" parameter
343 357
  ...
344 358
  modparam("dispatcher", "setid_pvar", "$var(setid)")
345 359
  ...
346 360
 
347
-1.3.15. ds_ping_method (string)
361
+1.3.16. ds_ping_method (string)
348 362
 
349 363
    With this Method you can define, with which method you want to
350 364
    probe the failed gateways. This method is only available, if
... ...
@@ -352,12 +366,12 @@ Note
352 366
 
353 367
    Default value is "OPTIONS".
354 368
 
355
-   Example 1.16. Set the "ds_ping_method" parameter
369
+   Example 1.17. Set the "ds_ping_method" parameter
356 370
  ...
357 371
  modparam("dispatcher", "ds_ping_method", "INFO")
358 372
  ...
359 373
 
360
-1.3.16. ds_ping_from (string)
374
+1.3.17. ds_ping_from (string)
361 375
 
362 376
    With this Method you can define the "From:"-Line for the
363 377
    request, sent to the failed gateways. This method is only
... ...
@@ -366,12 +380,12 @@ Note
366 380
 
367 381
    Default value is "sip:dispatcher@localhost".
368 382
 
369
-   Example 1.17. Set the "ds_ping_from" parameter
383
+   Example 1.18. Set the "ds_ping_from" parameter
370 384
  ...
371 385
  modparam("dispatcher", "ds_ping_from", "sip:proxy@sip.somehost.com")
372 386
  ...
373 387
 
374
-1.3.17. ds_ping_interval (int)
388
+1.3.18. ds_ping_interval (int)
375 389
 
376 390
    With this Method you can define the interval for sending a
377 391
    request to a failed gateway. This parameter is only used, when
... ...
@@ -380,12 +394,12 @@ Note
380 394
 
381 395
    Default value is "10".
382 396
 
383
-   Example 1.18. Set the "ds_ping_interval" parameter
397
+   Example 1.19. Set the "ds_ping_interval" parameter
384 398
  ...
385 399
  modparam("dispatcher", "ds_ping_interval", 30)
386 400
  ...
387 401
 
388
-1.3.18. ds_probing_threshhold (int)
402
+1.3.19. ds_probing_threshhold (int)
389 403
 
390 404
    If you want to set a gateway into probing mode, you will need a
391 405
    specific number of requests until it will change from "active"
... ...
@@ -394,12 +408,12 @@ Note
394 408
 
395 409
    Default value is "3".
396 410
 
397
-   Example 1.19. Set the "ds_probing_threshhold" parameter
411
+   Example 1.20. Set the "ds_probing_threshhold" parameter
398 412
  ...
399 413
  modparam("dispatcher", "ds_probing_threshhold", 10)
400 414
  ...
401 415
 
402
-1.3.19. ds_probing_mode (int)
416
+1.3.20. ds_probing_mode (int)
403 417
 
404 418
    Controls what gateways are tested to see if they are reachable.
405 419
    If set to 0, only the gateways with state PROBING are tested,
... ...
@@ -409,12 +423,12 @@ Note
409 423
 
410 424
    Default value is "0".
411 425
 
412
-   Example 1.20. Set the "ds_probing_mode" parameter
426
+   Example 1.21. Set the "ds_probing_mode" parameter
413 427
  ...
414 428
  modparam("dispatcher", "ds_probing_mode", 1)
415 429
  ...
416 430
 
417
-1.3.20. ds_append_branch (int)
431
+1.3.21. ds_append_branch (int)
418 432
 
419 433
    If set to 1, functions will automaticall append a new branch if
420 434
    called in FAILURE_ROUTE. If set to 0, script writer has to call
... ...
@@ -422,7 +436,7 @@ Note
422 436
 
423 437
    Default value is "1".
424 438
 
425
-   Example 1.21. Set the "ds_append_branch" parameter
439
+   Example 1.22. Set the "ds_append_branch" parameter
426 440
  ...
427 441
  modparam("dispatcher", "ds_append_branch", 0)
428 442
  ...
... ...
@@ -459,7 +473,7 @@ Note
459 473
 
460 474
    This function can be used from REQUEST_ROUTE.
461 475
 
462
-   Example 1.22. ds_select_dst usage
476
+   Example 1.23. ds_select_dst usage
463 477
 ...
464 478
 ds_select_dst("1", "0");
465 479
 ...
... ...
@@ -598,7 +612,7 @@ ds_select_dst("1", "0");
598 612
    address must be a valid SIP URI. Empty lines or lines starting
599 613
    with "#" are ignored.
600 614
 
601
-   Example 1.23. dispatcher list file
615
+   Example 1.24. dispatcher list file
602 616
 ...
603 617
 # $Id$
604 618
 # dispatcher destination sets
... ...
@@ -622,7 +636,7 @@ ds_select_dst("1", "0");
622 636
 
623 637
    Next picture displays a sample usage of dispatcher.
624 638
 
625
-   Example 1.24. Kamailio config script - sample dispatcher usage
639
+   Example 1.25. Kamailio config script - sample dispatcher usage
626 640
 ...
627 641
 # $Id$
628 642
 # sample config file for dispatcher module
... ...
@@ -71,6 +71,7 @@
71 71
 
72 72
 #define DS_TABLE_VERSION	1
73 73
 #define DS_TABLE_VERSION2	2
74
+#define DS_TABLE_VERSION3	3
74 75
 
75 76
 static int _ds_table_version = DS_TABLE_VERSION;
76 77
 
... ...
@@ -78,6 +79,7 @@ typedef struct _ds_dest
78 79
 {
79 80
 	str uri;
80 81
 	int flags;
82
+	int priority;
81 83
 	struct ip_addr ip_address; 	/*!< IP-Address of the entry */
82 84
 	unsigned short int port; 	/*!< Port of the request URI */
83 85
 	int failure_count;
... ...
@@ -107,6 +109,30 @@ int *next_idx   = NULL;
107 109
 
108 110
 void destroy_list(int);
109 111
 
112
+static int ds_print_sets(void)
113
+{
114
+	ds_set_p si = NULL;
115
+	int i;
116
+
117
+	if(_ds_list==NULL)
118
+		return -1;
119
+	
120
+	/* get the index of the set */
121
+	si = _ds_list;
122
+	while(si)
123
+	{
124
+		for(i=0; i<si->nr; i++)
125
+		{
126
+			LM_DBG("dst>> %d %.*s %d %d\n", si->id,
127
+					si->dlist[i].uri.len, si->dlist[i].uri.s,
128
+					si->dlist[i].flags, si->dlist[i].priority);
129
+		}
130
+		si = si->next;
131
+	}
132
+
133
+	return 0;
134
+}
135
+
110 136
 int init_data(void)
111 137
 {
112 138
 	int * p;
... ...
@@ -135,10 +161,13 @@ int init_data(void)
135 161
 	return 0;
136 162
 }
137 163
 
138
-int add_dest2list(int id, str uri, int flags, int list_idx, int * setn)
164
+int add_dest2list(int id, str uri, int flags, int priority, int list_idx,
165
+		int * setn)
139 166
 {
140 167
 	ds_dest_p dp = NULL;
141 168
 	ds_set_p  sp = NULL;
169
+	ds_dest_p dp0 = NULL;
170
+	ds_dest_p dp1 = NULL;
142 171
 	
143 172
 	/* For DNS-Lookups */
144 173
 	static char hn[256];
... ...
@@ -197,6 +226,7 @@ int add_dest2list(int id, str uri, int flags, int list_idx, int * setn)
197 226
 	dp->uri.s[uri.len]='\0';
198 227
 	dp->uri.len = uri.len;
199 228
 	dp->flags = flags;
229
+	dp->priority = priority;
200 230
 
201 231
 	/* The Hostname needs to be \0 terminated for resolvehost, so we
202 232
 	 * make a copy here. */
... ...
@@ -217,8 +247,28 @@ int add_dest2list(int id, str uri, int flags, int list_idx, int * setn)
217 247
 	/* Copy the Port out of the URI: */
218 248
 	dp->port = puri.port_no;		
219 249
 
220
-	dp->next = sp->dlist;
221
-	sp->dlist = dp;
250
+	if(sp->dlist==NULL)
251
+	{
252
+		sp->dlist = dp;
253
+	} else {
254
+		dp1 = NULL;
255
+		dp0 = sp->dlist;
256
+		/* highest priority last -> reindex will copy backwards */
257
+		while(dp0) {
258
+			if(dp0->priority > dp->priority)
259
+				break;
260
+			dp1 = dp0;
261
+			dp0=dp0->next;
262
+		}
263
+		if(dp1==NULL)
264
+		{
265
+			dp->next = sp->dlist;
266
+			sp->dlist = dp;
267
+		} else {
268
+			dp->next  = dp1->next;
269
+			dp1->next = dp;
270
+		}
271
+	}
222 272
 
223 273
 	LM_DBG("dest [%d/%d] <%.*s>\n", sp->id, sp->nr, dp->uri.len, dp->uri.s);
224 274
 	
... ...
@@ -280,7 +330,7 @@ int ds_load_list(char *lfile)
280 330
 {
281 331
 	char line[256], *p;
282 332
 	FILE *f = NULL;
283
-	int id, setn, flags;
333
+	int id, setn, flags, priority;
284 334
 	str uri;
285 335
 	
286 336
 	if( (*crt_idx) != (*next_idx)) {
... ...
@@ -302,7 +352,7 @@ int ds_load_list(char *lfile)
302 352
 		
303 353
 	}
304 354
 
305
-	id = setn = flags = 0;
355
+	id = setn = flags = priority = 0;
306 356
 
307 357
 	*next_idx = (*crt_idx + 1)%2;
308 358
 	destroy_list(*next_idx);
... ...
@@ -345,20 +395,33 @@ int ds_load_list(char *lfile)
345 395
 		
346 396
 		/* get flags */
347 397
 		flags = 0;
398
+		priority = 0;
348 399
 		if(*p=='\0' || *p=='#')
400
+			goto add_destination; /* no flags given */
401
+
402
+		while(*p>='0' && *p<='9')
349 403
 		{
350
-			/* no flags given */
351
-			goto add_destination;
404
+			flags = flags*10+ (*p-'0');
405
+			p++;
352 406
 		}
407
+		
408
+		/* eat all white spaces */
409
+		while(*p && (*p==' ' || *p=='\t' || *p=='\r' || *p=='\n'))
410
+			p++;
411
+		
412
+		/* get priority */
413
+		priority = 0;
414
+		if(*p=='\0' || *p=='#')
415
+			goto add_destination; /* no priority given */
353 416
 
354 417
 		while(*p>='0' && *p<='9')
355 418
 		{
356
-			flags = flags*10+ (*p-'0');
419
+			priority = priority*10+ (*p-'0');
357 420
 			p++;
358 421
 		}
359 422
 		
360 423
 add_destination:
361
-		if(add_dest2list(id, uri, flags, *next_idx, &setn) != 0)
424
+		if(add_dest2list(id, uri, flags, priority, *next_idx, &setn) != 0)
362 425
 			goto error;
363 426
 					
364 427
 		
... ...
@@ -376,6 +439,7 @@ next_line:
376 439
 	/* Update list */
377 440
 	_ds_list_nr = setn;
378 441
 	*crt_idx = *next_idx;
442
+	ds_print_sets();
379 443
 	return 0;
380 444
 
381 445
 error:
... ...
@@ -443,10 +507,12 @@ int init_ds_db(void)
443 507
 		LM_ERR("failed to query table version\n");
444 508
 		return -1;
445 509
 	} else if (_ds_table_version != DS_TABLE_VERSION
446
-			&& _ds_table_version != DS_TABLE_VERSION2) {
447
-		LM_ERR("invalid table version (found %d , required %d or %d)\n"
510
+			&& _ds_table_version != DS_TABLE_VERSION2
511
+			&& _ds_table_version != DS_TABLE_VERSION3) {
512
+		LM_ERR("invalid table version (found %d , required %d, %d or %d)\n"
448 513
 			"(use kamdbctl reinit)\n",
449
-			_ds_table_version, DS_TABLE_VERSION, DS_TABLE_VERSION2 );
514
+			_ds_table_version, DS_TABLE_VERSION, DS_TABLE_VERSION2,
515
+			DS_TABLE_VERSION3);
450 516
 		return -1;
451 517
 	}
452 518
 
... ...
@@ -462,18 +528,21 @@ int ds_load_db(void)
462 528
 {
463 529
 	int i, id, nr_rows, setn;
464 530
 	int flags;
531
+	int priority;
465 532
 	int nrcols;
466 533
 	str uri;
467 534
 	db_res_t * res;
468 535
 	db_val_t * values;
469 536
 	db_row_t * rows;
470 537
 	
471
-	db_key_t query_cols[3] = {&ds_set_id_col, &ds_dest_uri_col,
472
-								&ds_dest_flags_col};
538
+	db_key_t query_cols[4] = {&ds_set_id_col, &ds_dest_uri_col,
539
+								&ds_dest_flags_col, &ds_dest_priority_col};
473 540
 	
474 541
 	nrcols = 2;
475 542
 	if(_ds_table_version == DS_TABLE_VERSION2)
476 543
 		nrcols = 3;
544
+	else if(_ds_table_version == DS_TABLE_VERSION3)
545
+		nrcols = 4;
477 546
 
478 547
 	if( (*crt_idx) != (*next_idx))
479 548
 	{
... ...
@@ -520,13 +589,17 @@ int ds_load_db(void)
520 589
 		uri.s = VAL_STR(values+1).s;
521 590
 		uri.len = strlen(uri.s);
522 591
 		flags = 0;
523
-		if(nrcols==3)
592
+		if(nrcols>=3)
524 593
 			flags = VAL_INT(values+2);
594
+		priority=0;
595
+		if(nrcols>=4)
596
+			priority = VAL_INT(values+3);
525 597
 
526
-		if(add_dest2list(id, uri, flags, *next_idx, &setn) != 0)
598
+		if(add_dest2list(id, uri, flags, priority, *next_idx, &setn) != 0)
527 599
 			goto err2;
528 600
 
529 601
 	}
602
+	ds_dbf.free_result(ds_db_handle, res);
530 603
 
531 604
 	if(reindex_dests(*next_idx, setn)!=0)
532 605
 	{
... ...
@@ -537,7 +610,8 @@ int ds_load_db(void)
537 610
 	/*update data*/
538 611
 	_ds_list_nr = setn;
539 612
 	*crt_idx = *next_idx;
540
-	ds_dbf.free_result(ds_db_handle, res);
613
+
614
+	ds_print_sets();
541 615
 
542 616
 	return 0;
543 617
 
... ...
@@ -58,6 +58,7 @@ extern str ds_table_name;
58 58
 extern str ds_set_id_col;
59 59
 extern str ds_dest_uri_col;
60 60
 extern str ds_dest_flags_col;
61
+extern str ds_dest_priority_col;
61 62
 
62 63
 extern int ds_flags; 
63 64
 extern int ds_use_default;
... ...
@@ -67,10 +67,11 @@
67 67
 
68 68
 MODULE_VERSION
69 69
 
70
-#define DS_SET_ID_COL		"setid"
71
-#define DS_DEST_URI_COL		"destination"
72
-#define DS_DEST_FLAGS_COL	"flags"
73
-#define DS_TABLE_NAME 		"dispatcher"
70
+#define DS_SET_ID_COL			"setid"
71
+#define DS_DEST_URI_COL			"destination"
72
+#define DS_DEST_FLAGS_COL		"flags"
73
+#define DS_DEST_PRIORITY_COL	"priority"
74
+#define DS_TABLE_NAME			"dispatcher"
74 75
 
75 76
 /** parameters */
76 77
 char *dslistfile = CFG_DIR"dispatcher.list";
... ...
@@ -100,11 +101,12 @@ int ds_probing_mode  = 0;
100 101
 int ds_append_branch = 1;
101 102
 
102 103
 /*db */
103
-str ds_db_url         = {NULL, 0};
104
-str ds_set_id_col     = str_init(DS_SET_ID_COL);
105
-str ds_dest_uri_col   = str_init(DS_DEST_URI_COL);
106
-str ds_dest_flags_col = str_init(DS_DEST_FLAGS_COL);
107
-str ds_table_name     = str_init(DS_TABLE_NAME);
104
+str ds_db_url            = {NULL, 0};
105
+str ds_set_id_col        = str_init(DS_SET_ID_COL);
106
+str ds_dest_uri_col      = str_init(DS_DEST_URI_COL);
107
+str ds_dest_flags_col    = str_init(DS_DEST_FLAGS_COL);
108
+str ds_dest_priority_col = str_init(DS_DEST_PRIORITY_COL);
109
+str ds_table_name        = str_init(DS_TABLE_NAME);
108 110
 
109 111
 str ds_setid_pvname   = {NULL, 0};
110 112
 pv_spec_t ds_setid_pv;
... ...
@@ -152,6 +154,7 @@ static param_export_t params[]={
152 154
 	{"setid_col",       STR_PARAM, &ds_set_id_col.s},
153 155
 	{"destination_col", STR_PARAM, &ds_dest_uri_col.s},
154 156
 	{"flags_col",       STR_PARAM, &ds_dest_flags_col.s},
157
+	{"priority_col",    STR_PARAM, &ds_dest_priority_col.s},
155 158
 	{"force_dst",       INT_PARAM, &ds_force_dst},
156 159
 	{"flags",           INT_PARAM, &ds_flags},
157 160
 	{"use_default",     INT_PARAM, &ds_use_default},
... ...
@@ -175,6 +175,27 @@ modparam("dispatcher", "flags_col", "dstflags")
175 175
 		</example>
176 176
 	</section>
177 177
 
178
+	<section>
179
+		<title><varname>priority_col</varname> (string)</title>
180
+		<para>
181
+			The column's name in the database storing the priority for
182
+			destination uri.
183
+		</para>
184
+		<para>
185
+		<emphasis>
186
+			Default value is <quote>priority</quote>.
187
+		</emphasis>
188
+		</para>
189
+		<example>
190
+		<title>Set <quote>priority_col</quote> parameter</title>
191
+		<programlisting format="linespecific">
192
+...
193
+modparam("dispatcher", "priority_col", "dstpriority")
194
+...
195
+</programlisting>
196
+		</example>
197
+	</section>
198
+
178 199
 	<section>
179 200
 		<title><varname>force_dst</varname> (int)</title>
180 201
 		<para>