|
@@ -1204,6 +1204,52 @@ static int ki_ht_setxi(sip_msg_t *msg, str *htname, str *itname, int itval,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+#define KSR_HT_KEMI_NOINTVAL -255
|
|
|
+static ht_cell_t *_htc_ki_local=NULL;
|
|
|
+
|
|
|
+static int ki_ht_add_op(sip_msg_t *msg, str *htname, str *itname, int itval)
|
|
|
+{
|
|
|
+ ht_t *ht;
|
|
|
+ ht_cell_t *htc=NULL;
|
|
|
+
|
|
|
+ ht = ht_get_table(htname);
|
|
|
+ if(ht==NULL) {
|
|
|
+ return KSR_HT_KEMI_NOINTVAL;
|
|
|
+ }
|
|
|
+
|
|
|
+ htc = ht_cell_value_add(ht, itname, itval, _htc_ki_local);
|
|
|
+ if(_htc_ki_local!=htc) {
|
|
|
+ ht_cell_pkg_free(_htc_ki_local);
|
|
|
+ _htc_ki_local=htc;
|
|
|
+ }
|
|
|
+ if(htc==NULL) {
|
|
|
+ return KSR_HT_KEMI_NOINTVAL;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(htc->flags&AVP_VAL_STR) {
|
|
|
+ return KSR_HT_KEMI_NOINTVAL;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* integer */
|
|
|
+ if (ht->dmqreplicate>0) {
|
|
|
+ if (ht_dmq_replicate_action(HT_DMQ_SET_CELL, htname, itname, 0,
|
|
|
+ &htc->value, 1)!=0) {
|
|
|
+ LM_ERR("dmq relication failed\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return htc->value.n;
|
|
|
+}
|
|
|
+
|
|
|
+static int ki_ht_inc(sip_msg_t *msg, str *htname, str *itname)
|
|
|
+{
|
|
|
+ return ki_ht_add_op(msg, htname, itname, 1);
|
|
|
+}
|
|
|
+
|
|
|
+static int ki_ht_dec(sip_msg_t *msg, str *htname, str *itname)
|
|
|
+{
|
|
|
+ return ki_ht_add_op(msg, htname, itname, -1);
|
|
|
+}
|
|
|
+
|
|
|
#define RPC_DATE_BUF_LEN 21
|
|
|
|
|
|
static const char* htable_dump_doc[2] = {
|
|
@@ -1846,6 +1892,16 @@ static sr_kemi_t sr_kemi_htable_exports[] = {
|
|
|
{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
|
|
|
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
|
|
|
},
|
|
|
+ { str_init("htable"), str_init("sht_inc"),
|
|
|
+ SR_KEMIP_INT, ki_ht_inc,
|
|
|
+ { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
|
|
|
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
|
|
|
+ },
|
|
|
+ { str_init("htable"), str_init("sht_dec"),
|
|
|
+ SR_KEMIP_INT, ki_ht_dec,
|
|
|
+ { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
|
|
|
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
|
|
|
+ },
|
|
|
|
|
|
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
|
|
|
};
|