Переглянути джерело

htable: added in operator for rm functions

Daniel-Constantin Mierla 1 рік тому
батько
коміт
c0d80f9eb4

+ 12 - 1
src/modules/htable/ht_api.c

@@ -1389,8 +1389,12 @@ int ht_rm_cell_op(str *sre, ht_t *ht, int mode, int op)
 									   == 0) {
 						match = 1;
 					}
+				} else if(op == HT_RM_OP_IN) {
+					if(sre->len <= it->name.len
+							&& str_search(&it->name, sre) != NULL) {
+						match = 1;
+					}
 				}
-
 			} else {
 				if(op == HT_RM_OP_SW) {
 					if(it->flags & AVP_VAL_STR) {
@@ -1410,6 +1414,13 @@ int ht_rm_cell_op(str *sre, ht_t *ht, int mode, int op)
 							match = 1;
 						}
 					}
+				} else if(op == HT_RM_OP_IN) {
+					if(it->flags & AVP_VAL_STR) {
+						if(sre->len <= it->value.s.len
+								&& str_search(&it->value.s, sre) != NULL) {
+							match = 1;
+						}
+					}
 				}
 			}
 			if(match == 1) {

+ 2 - 0
src/modules/htable/ht_api.h

@@ -126,6 +126,8 @@ int ht_reset_content(ht_t *ht);
 #define HT_RM_OP_SW 3
 #define HT_RM_OP_EW 3
 #define HT_RM_OP_RE 4
+#define HT_RM_OP_IN 5
+
 int ht_rm_cell_op(str *sre, ht_t *ht, int mode, int op);
 int ht_match_cell_op_str(str *sre, ht_t *ht, int mode, int op);
 

+ 2 - 1
src/modules/htable/ht_dmq.h

@@ -40,7 +40,8 @@ typedef enum
 	HT_DMQ_DEL_CELL,
 	HT_DMQ_RM_CELL_RE,
 	HT_DMQ_RM_CELL_SW,
-	HT_DMQ_RM_CELL_EW
+	HT_DMQ_RM_CELL_EW,
+	HT_DMQ_RM_CELL_IN
 } ht_dmq_action_t;
 
 int ht_dmq_initialize();

+ 12 - 0
src/modules/htable/htable.c

@@ -527,6 +527,18 @@ static int ht_rm_items(sip_msg_t *msg, str *hname, str *op, str *val, int mkey)
 					return -1;
 				}
 				return 1;
+			} else if(strncmp(op->s, "ew", 2) == 0) {
+				isval.s = *val;
+				if((ht->dmqreplicate > 0)
+						&& ht_dmq_replicate_action(HT_DMQ_RM_CELL_IN, &ht->name,
+								   NULL, AVP_VAL_STR, &isval, mkey)
+								   != 0) {
+					LM_ERR("dmq replication failed (op %d)\n", mkey);
+				}
+				if(ht_rm_cell_op(val, ht, mkey, HT_RM_OP_IN) < 0) {
+					return -1;
+				}
+				return 1;
 			}
 			LM_WARN("unsupported match operator: %.*s\n", op->len, op->s);
 			break;