Module: kamailio
Branch: master
Commit: c0d80f9eb42b025802c4680f19d788d01497301a
URL: 
https://github.com/kamailio/kamailio/commit/c0d80f9eb42b025802c4680f19d788d01497301a

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2024-04-25T13:53:31+02:00

htable: added in operator for rm functions

---

Modified: src/modules/htable/ht_api.c
Modified: src/modules/htable/ht_api.h
Modified: src/modules/htable/ht_dmq.h
Modified: src/modules/htable/htable.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/c0d80f9eb42b025802c4680f19d788d01497301a.diff
Patch: 
https://github.com/kamailio/kamailio/commit/c0d80f9eb42b025802c4680f19d788d01497301a.patch

---

diff --git a/src/modules/htable/ht_api.c b/src/modules/htable/ht_api.c
index afda3dc6c54..ecc49b547d6 100644
--- a/src/modules/htable/ht_api.c
+++ b/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) {
diff --git a/src/modules/htable/ht_api.h b/src/modules/htable/ht_api.h
index 7c7642ef5df..f7bd8ed42c0 100644
--- a/src/modules/htable/ht_api.h
+++ b/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);
 
diff --git a/src/modules/htable/ht_dmq.h b/src/modules/htable/ht_dmq.h
index 7577e445a76..5388d8e00df 100644
--- a/src/modules/htable/ht_dmq.h
+++ b/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();
diff --git a/src/modules/htable/htable.c b/src/modules/htable/htable.c
index 6f775bb33ce..414bd5556b1 100644
--- a/src/modules/htable/htable.c
+++ b/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;

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to