Пример #1
0
static int ht_rm_value_re(struct sip_msg* msg, char* key, char* foo)
{
	ht_pv_t *hpv;
	str sre;
	pv_spec_t *sp;
	sp = (pv_spec_t*)key;
	int_str isval;

	hpv = (ht_pv_t*)sp->pvp.pvn.u.dname;

	if(hpv->ht==NULL)
	{
		hpv->ht = ht_get_table(&hpv->htname);
		if(hpv->ht==NULL)
			return 1;
	}
	if(pv_printf_s(msg, hpv->pve, &sre)!=0)
	{
		LM_ERR("cannot get $sht expression\n");
		return -1;
	}

	if (hpv->ht->dmqreplicate>0) {
		isval.s = sre;
		if (ht_dmq_replicate_action(HT_DMQ_RM_CELL_RE, &hpv->htname, NULL, AVP_VAL_STR, &isval, 1)!=0) {
			LM_ERR("dmq relication failed\n");
		}
	}
	if(ht_rm_cell_re(&sre, hpv->ht, 1)<0)
		return -1;
	return 1;
}
Пример #2
0
int ht_api_rm_cell_re(str *hname, str *sre, int mode)
{
	ht_t* ht;
	ht = ht_get_table(hname);
	if(ht==NULL)
		return -1;
	if(ht_rm_cell_re(sre, ht, mode /* 0 - name; 1 - value */)<0)
		return -1;
	return 0;
}
Пример #3
0
static int ht_rm_items(sip_msg_t* msg, str* hname, str* op, str *val,
		int mkey)
{
	ht_t *ht;
	int_str isval;

	ht = ht_get_table(hname);
	if(ht==NULL) {
		LM_ERR("cannot get hash table [%.*s]\n", hname->len, hname->s);
		return -1;
	}

	switch(op->len) {
		case 2:
			if(strncmp(op->s, "re", 2)==0) {
				isval.s = *val;
				if (ht_dmq_replicate_action(HT_DMQ_RM_CELL_RE, &ht->name, NULL,
							AVP_VAL_STR, &isval, mkey)!=0) {
					LM_ERR("dmq relication failed (op %d)\n", mkey);
				}
				if(ht_rm_cell_re(val, ht, mkey)<0) {
					return -1;
				}
				return 1;
			} else if(strncmp(op->s, "sw", 2)==0) {
				if(ht_rm_cell_op(val, ht, mkey, HT_RM_OP_SW)<0) {
					return -1;
				}
			}
			LM_WARN("unsupported match operator: %.*s\n", op->len, op->s);
			break;
		default:
			LM_WARN("unsupported match operator: %.*s\n", op->len, op->s);
	}
	return -1;
}
Пример #4
0
int ht_dmq_replay_action(ht_dmq_action_t action, str* htname, str* cname, int type, int_str* val, int mode) {

    ht_t* ht;
    ht = ht_get_table(htname);
    if(ht==NULL) {
        LM_ERR("unable to get table\n");
        return -1;
    }

    LM_DBG("replaying action %d on %.*s=>%.*s...\n", action, htname->len, htname->s, cname->len, cname->s);

    if (action==HT_DMQ_SET_CELL) {
        return ht_set_cell(ht, cname, type, val, mode);
    } else if (action==HT_DMQ_SET_CELL_EXPIRE) {
        return ht_set_cell_expire(ht, cname, 0, val);
    } else if (action==HT_DMQ_DEL_CELL) {
        return ht_del_cell(ht, cname);
    } else if (action==HT_DMQ_RM_CELL_RE) {
        return ht_rm_cell_re(&val->s, ht, mode);
    } else {
        LM_ERR("unrecognized action");
        return -1;
    }
}