Esempio n. 1
0
/**
 * receive_binary_packet (callback) - receives a cmd_type, specifying the
 * purpose of the data encoded in the received UDP packet
 */
void receive_binary_packet(int info_type)
{
	int rc;

	LM_DBG("Received a binary packet!\n");

	switch (info_type) {
	case REPLICATION_DLG_CREATED:
		rc = dlg_replicated_create(NULL, NULL, NULL, 1);
		if_update_stat(dlg_enable_stats, create_recv, 1);
		break;

	case REPLICATION_DLG_UPDATED:
		rc = dlg_replicated_update();
		if_update_stat(dlg_enable_stats, update_recv, 1);
		break;

	case REPLICATION_DLG_DELETED:
		rc = dlg_replicated_delete();
		if_update_stat(dlg_enable_stats, delete_recv, 1);
		break;

	default:
		rc = -1;
		LM_ERR("Invalid dialog binary packet command: %d\n", info_type);
	}

	if (rc != 0)
		LM_ERR("Failed to process a binary packet!\n");
}
Esempio n. 2
0
void receive_dlg_binary_packet(int packet_type, struct receive_info *ri, void *att)
{
	int rc;
	char *ip;
	unsigned short port;
	int server_id;

	rc = bin_pop_int(&server_id);
	if (rc < 0)
		return;

	LM_DBG("Received a binary packet!\n");

	if(get_bin_pkg_version() != BIN_VERSION){
		LM_ERR("incompatible bin protocol version\n");
		return;
	}

	if (!accept_replicated_dlg) {
		get_su_info(&ri->src_su.s, ip, port);
		LM_WARN("Unwanted dialog packet received from %s:%hu (type=%d)\n",
				ip, port, packet_type);
		return;
	}

	if(!clusterer_api.check(accept_replicated_dlg, &ri->src_su, server_id, ri->proto))
		return;

	switch (packet_type) {
	case REPLICATION_DLG_CREATED:
		LM_DBG("AAAA dlg_replicated_create\n");
		rc = dlg_replicated_create(NULL, NULL, NULL, 1);
		if_update_stat(dlg_enable_stats, create_recv, 1);
		break;

	case REPLICATION_DLG_UPDATED:
		LM_DBG("AAAA dlg_replicated_update\n");
		rc = dlg_replicated_update();
		if_update_stat(dlg_enable_stats, update_recv, 1);
		break;

	case REPLICATION_DLG_DELETED:
		LM_DBG("AAAA dlg_replicated_deleted\n");
		rc = dlg_replicated_delete();
		if_update_stat(dlg_enable_stats, delete_recv, 1);
		break;

	default:
		rc = -1;
		get_su_info(&ri->src_su.s, ip, port);
		LM_WARN("Invalid dialog binary packet command: %d (from %s:%hu)\n",
			packet_type, ip, port);
	}

	if (rc != 0)
		LM_ERR("Failed to process a binary packet!\n");
}
Esempio n. 3
0
/**
 * receive_binary_packet (callback) - receives a cmd_type, specifying the
 * purpose of the data encoded in the received UDP packet
 */
void receive_binary_packet(int packet_type, struct receive_info *ri)
{
	int rc;
	char *ip;
	unsigned short port;

	LM_DBG("Received a binary packet!\n");

	if(get_bin_pkg_version() != BIN_VERSION){
		LM_ERR("incompatible bin protocol version\n");
		return;
	}

	if (accept_repl_profiles && packet_type == REPLICATION_DLG_PROFILE) {
		/* TODO: handle this */
		dlg_replicated_profiles(ri);
		return;
	}
	if (!accept_replicated_dlg) {
		get_su_info(&ri->src_su.s, ip, port);
		LM_WARN("Unwanted dialog packet received from %s:%hu (type=%d)\n",
				ip, port, packet_type);
		return;
	}


	switch (packet_type) {
	case REPLICATION_DLG_CREATED:
		rc = dlg_replicated_create(NULL, NULL, NULL, 1);
		if_update_stat(dlg_enable_stats, create_recv, 1);
		break;

	case REPLICATION_DLG_UPDATED:
		rc = dlg_replicated_update();
		if_update_stat(dlg_enable_stats, update_recv, 1);
		break;

	case REPLICATION_DLG_DELETED:
		rc = dlg_replicated_delete();
		if_update_stat(dlg_enable_stats, delete_recv, 1);
		break;

	default:
		rc = -1;
		get_su_info(&ri->src_su.s, ip, port);
		LM_WARN("Invalid dialog binary packet command: %d (from %s:%hu)\n",
				packet_type, ip, port);
	}

	if (rc != 0)
		LM_ERR("Failed to process a binary packet!\n");
}
Esempio n. 4
0
void receive_dlg_repl(bin_packet_t *packet)
{
	int rc = 0;
	bin_packet_t *pkt;

	for (pkt = packet; pkt; pkt = pkt->next) {
		switch (pkt->type) {
		case REPLICATION_DLG_CREATED:
			rc = dlg_replicated_create(pkt, NULL, NULL, NULL, 1);
			if_update_stat(dlg_enable_stats, create_recv, 1);
			break;
		case REPLICATION_DLG_UPDATED:
			rc = dlg_replicated_update(pkt);
			if_update_stat(dlg_enable_stats, update_recv, 1);
			break;
		case REPLICATION_DLG_DELETED:
			rc = dlg_replicated_delete(pkt);
			if_update_stat(dlg_enable_stats, delete_recv, 1);
			break;
		case DLG_SHARING_TAG_ACTIVE:
			rc = receive_shtag_active_msg(pkt);
			break;
		case SYNC_PACKET_TYPE:
			while (clusterer_api.sync_chunk_iter(pkt))
				if (dlg_replicated_create(pkt, NULL, NULL, NULL, 1) < 0) {
					LM_ERR("Failed to process sync packet\n");
					return;
				}
			break;
		default:
			rc = -1;
			LM_WARN("Invalid dialog binary packet command: %d "
				"(from node: %d in cluster: %d)\n", pkt->type, pkt->src_id,
				dialog_repl_cluster);
		}

		if (rc != 0)
			LM_ERR("Failed to process a binary packet!\n");
	}
}