Пример #1
0
int cmd_broadcast_req(struct sip_msg *msg, int *cluster_id, str *gen_msg,
									pv_spec_t *param_tag)
{
	pv_value_t tag_val;
	int rc;

	/* generate tag */
	generate_msg_tag(&tag_val, *cluster_id);

	if (param_tag && pv_set_value(msg, param_tag, 0, &tag_val) < 0) {
		LM_ERR("Unable to set tag pvar\n");
		return -1;
	}

	rc = bcast_gen_msg(*cluster_id, gen_msg, &tag_val.rs);
	switch (rc) {
		case 0:
			return 1;
		case 1:
			return -1;
		case -1:
			return -2;
		case -2:
			return -3;
		default:
			return -4;
	}
}
Пример #2
0
int cmd_broadcast_req(struct sip_msg *msg, char *param_cluster, char *param_msg,
									char *param_tag)
{
	int cluster_id;
	str gen_msg;
	pv_value_t tag_val;
	int rc;

	if (fixup_get_ivalue(msg, (gparam_p)param_cluster, &cluster_id) < 0) {
		LM_ERR("Failed to fetch cluster id parameter\n");
		return -1;
	}

	if (fixup_get_svalue(msg, (gparam_p)param_msg, &gen_msg) < 0) {
		LM_ERR("Failed to fetch message parameter\n");
		return -1;
	}

	/* generate tag */
	generate_msg_tag(&tag_val, cluster_id);

	if (param_tag && pv_set_value(msg, (pv_spec_p)param_tag, 0, &tag_val) < 0) {
		LM_ERR("Unable to set tag pvar\n");
		return -1;
	}

	rc = bcast_gen_msg(cluster_id, &gen_msg, &tag_val.rs);
	switch (rc) {
		case 0:
			return 1;
		case 1:
			return -1;
		case -1:
			return -2;
		case -2:
			return -3;
		default:
			return -4;
	}
}