- check if any or a specific uri in a group is active
... | ... |
@@ -3455,6 +3455,32 @@ int ds_is_from_list(struct sip_msg *_m, int group) |
3455 | 3455 |
return ds_is_addr_from_list(_m, group, NULL, DS_MATCH_NOPROTO); |
3456 | 3456 |
} |
3457 | 3457 |
|
3458 |
+/** |
|
3459 |
+ * Check if the a group has any or a specific active uri |
|
3460 |
+ */ |
|
3461 |
+int ds_is_active_uri(sip_msg_t *msg, int group, str *uri) |
|
3462 |
+{ |
|
3463 |
+ ds_set_t *list; |
|
3464 |
+ int j; |
|
3465 |
+ |
|
3466 |
+ list = ds_avl_find(_ds_list, group); |
|
3467 |
+ if(list) { |
|
3468 |
+ for(j = 0; j < list->nr; j++) { |
|
3469 |
+ if(!ds_skip_dst(list->dlist[j].flags)) { |
|
3470 |
+ if(uri==NULL || uri->s==NULL || uri->len<=0) { |
|
3471 |
+ return 1; |
|
3472 |
+ } |
|
3473 |
+ if((list->dlist[j].uri.len==uri->len) |
|
3474 |
+ && (memcmp(list->dlist[j].uri.s, uri->s, uri->len)==0)) { |
|
3475 |
+ return 1; |
|
3476 |
+ } |
|
3477 |
+ } |
|
3478 |
+ } |
|
3479 |
+ } |
|
3480 |
+ |
|
3481 |
+ return -1; |
|
3482 |
+} |
|
3483 |
+ |
|
3458 | 3484 |
/*! \brief |
3459 | 3485 |
* Callback-Function for the OPTIONS-Request |
3460 | 3486 |
* This Function is called, as soon as the Transaction is finished |
... | ... |
@@ -151,6 +151,7 @@ int ds_mark_dst(struct sip_msg *msg, int mode); |
151 | 151 |
int ds_print_list(FILE *fout); |
152 | 152 |
int ds_log_sets(void); |
153 | 153 |
int ds_list_exist(int set); |
154 |
+int ds_is_active_uri(sip_msg_t *msg, int group, str *uri); |
|
154 | 155 |
|
155 | 156 |
|
156 | 157 |
int ds_load_unset(struct sip_msg *msg); |
... | ... |
@@ -178,6 +178,9 @@ static int w_ds_is_from_list3(struct sip_msg*, char*, char*, char*); |
178 | 178 |
static int w_ds_list_exist(struct sip_msg*, char*, char*); |
179 | 179 |
static int w_ds_reload(struct sip_msg* msg, char*, char*); |
180 | 180 |
|
181 |
+static int w_ds_is_active(sip_msg_t *msg, char *pset, char *p2); |
|
182 |
+static int w_ds_is_active_uri(sip_msg_t *msg, char *pset, char *puri); |
|
183 |
+ |
|
181 | 184 |
static int fixup_ds_is_from_list(void** param, int param_no); |
182 | 185 |
static int fixup_ds_list_exist(void** param,int param_no); |
183 | 186 |
|
... | ... |
@@ -240,6 +243,10 @@ static cmd_export_t cmds[]={ |
240 | 243 |
0, 0, ANY_ROUTE}, |
241 | 244 |
{"ds_load_update", (cmd_function)w_ds_load_update, 0, |
242 | 245 |
0, 0, ANY_ROUTE}, |
246 |
+ {"ds_is_active", (cmd_function)w_ds_is_active, 1, |
|
247 |
+ fixup_igp_null, fixup_free_igp_null, ANY_ROUTE}, |
|
248 |
+ {"ds_is_active", (cmd_function)w_ds_is_active_uri, 2, |
|
249 |
+ fixup_igp_spve, fixup_free_igp_spve, ANY_ROUTE}, |
|
243 | 250 |
{"bind_dispatcher", (cmd_function)bind_dispatcher, 0, |
244 | 251 |
0, 0, 0}, |
245 | 252 |
{"ds_reload", (cmd_function)w_ds_reload, 0, |
... | ... |
@@ -1065,6 +1072,45 @@ static int fixup_ds_list_exist(void **param, int param_no) |
1065 | 1072 |
return fixup_igp_null(param, param_no); |
1066 | 1073 |
} |
1067 | 1074 |
|
1075 |
+static int ki_ds_is_active(sip_msg_t *msg, int set) |
|
1076 |
+{ |
|
1077 |
+ return ds_is_active_uri(msg, set, NULL); |
|
1078 |
+} |
|
1079 |
+ |
|
1080 |
+static int w_ds_is_active(sip_msg_t *msg, char *pset, char *p2) |
|
1081 |
+{ |
|
1082 |
+ int vset; |
|
1083 |
+ |
|
1084 |
+ if(fixup_get_ivalue(msg, (gparam_t *)pset, &vset) != 0) { |
|
1085 |
+ LM_ERR("cannot get set id value\n"); |
|
1086 |
+ return -1; |
|
1087 |
+ } |
|
1088 |
+ |
|
1089 |
+ return ds_is_active_uri(msg, vset, NULL); |
|
1090 |
+} |
|
1091 |
+ |
|
1092 |
+static int ki_ds_is_active_uri(sip_msg_t *msg, int set, str *uri) |
|
1093 |
+{ |
|
1094 |
+ return ds_is_active_uri(msg, set, uri); |
|
1095 |
+} |
|
1096 |
+ |
|
1097 |
+static int w_ds_is_active_uri(sip_msg_t *msg, char *pset, char *puri) |
|
1098 |
+{ |
|
1099 |
+ int vset; |
|
1100 |
+ str suri; |
|
1101 |
+ |
|
1102 |
+ if(fixup_get_ivalue(msg, (gparam_t *)pset, &vset) != 0) { |
|
1103 |
+ LM_ERR("cannot get set id value\n"); |
|
1104 |
+ return -1; |
|
1105 |
+ } |
|
1106 |
+ if(fixup_get_svalue(msg, (gparam_t *)puri, &suri) != 0) { |
|
1107 |
+ LM_ERR("cannot get uri value\n"); |
|
1108 |
+ return -1; |
|
1109 |
+ } |
|
1110 |
+ |
|
1111 |
+ return ki_ds_is_active_uri(msg, vset, &suri); |
|
1112 |
+} |
|
1113 |
+ |
|
1068 | 1114 |
static int ds_parse_reply_codes() |
1069 | 1115 |
{ |
1070 | 1116 |
param_t *params_list = NULL; |
... | ... |
@@ -1453,7 +1499,16 @@ static sr_kemi_t sr_kemi_dispatcher_exports[] = { |
1453 | 1499 |
{ SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE, |
1454 | 1500 |
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } |
1455 | 1501 |
}, |
1456 |
- |
|
1502 |
+ { str_init("dispatcher"), str_init("ds_is_active"), |
|
1503 |
+ SR_KEMIP_INT, ki_ds_is_active, |
|
1504 |
+ { SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE, |
|
1505 |
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } |
|
1506 |
+ }, |
|
1507 |
+ { str_init("dispatcher"), str_init("ds_is_active_uri"), |
|
1508 |
+ SR_KEMIP_INT, ki_ds_is_active_uri, |
|
1509 |
+ { SR_KEMIP_INT, SR_KEMIP_STR, SR_KEMIP_NONE, |
|
1510 |
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } |
|
1511 |
+ }, |
|
1457 | 1512 |
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } } |
1458 | 1513 |
}; |
1459 | 1514 |
/* clang-format on */ |