Example #1
0
 virtual void onCall(const sg::rpc::Uri& target)
 {
     common::ConversationID conv_id(getFrom());
     common::UserPointID usr_ptid(getRequestData().sender_ua_uri());
     common::UserPointID target_ptid(target);
     LOG(info, "recv msg from " << usr_ptid << " to " << target_ptid << " conversation id =: " << conv_id);
     LOG(info, "msgid=" << getRequestData().msg_id() << ", content: " << getRequestData().content());
 }
Example #2
0
/**
 *		CDR LOG FILE parsing and write to file..
 **/ 
int parse_write_proc(char *read_file,
					 FILE *write_fd,
					 int file_format,
					 int min_flag,
					 char *search_min,
					 int ip_flag,
					 char *ip,
					 int port1_flag,
					 int port1,
					 int port2_flag,
					 int port2)
{

	int					i;
	int					year_int, time_int;
	long long			temp_long;
	char 				temp_file[256];
	char				year_data[4], time_data[10];
	char				*date_str;
	char				acct_sess_id[16];
	char				buffer[2048];
	char				src_ip[16], dest_ip[16];
	char				create_time[64], end_time[64];
	time_t				temp_cvt_crt_time, temp_cvt_last_time;
	time_t				cvt_crt_time, cvt_last_time;
	FILE				*fd;
	struct	tm			*crt_time, *last_time;
	st_CDRSessLog		cdrlog_info;
	st_CDRDumpInfo		cdrlog_head;
	int 			reg_cnt;


	/** initialize variables **/
	reg_cnt = 0;
	memset(&cdrlog_head, 	0x00, sizeof(st_CDRDumpInfo));
	memset(temp_file, 	0x00, sizeof(temp_file));
	memset(year_data, 	0x00, sizeof(year_data));
	memset(time_data, 	0x00, sizeof(time_data));

	if (file_format == COMPRESS_FILE)
		memcpy(temp_file, read_file, (strlen(read_file)-3));
	else
		memcpy(temp_file, read_file, strlen(read_file));

	date_str = strstr(temp_file, "2");
	//date_str = strstr(date_str, "2");

	/** get year info **/
	for(i=0; i<4; i++)
	{
		year_data[i] = *(date_str+i);
	}

	/** get date string **/
	for(i=0; i<10; i++)
	{
		time_data[i] = *(date_str+23+i);
	}

	year_int 	= atoi(year_data);
	time_int 	= atoi(time_data);


	fd = fopen(temp_file, "r");
	if (!fd)
	{
		printf("FILE OPEN ERROR : %s [FILE : %s]\n", 
								strerror(errno), temp_file);
		return (-1);	

	}
	printf("FILE OPEN SUCCESS : %s\n", temp_file); 

	/** read file head info **/
	if ((fread(&cdrlog_head, sizeof(st_CDRDumpInfo), 1, fd)) <= 0)
	{
		fprintf(stderr, "FILE READ ERROR : %s [FILE : %s]\n",
						strerror(errno), temp_file);	
	}

	/** print head info **/
	print_flag = 0;

	/** read CDR Sess Log data **/
	while(1)
	{

		memset(&cdrlog_info, 	0x00, sizeof(st_CDRSessLog));

		if ((fread(&cdrlog_info, sizeof(st_CDRSessLog), 1, fd)) <= 0)
		{
			//fprintf(stderr, "END READ FILE : %s\n", strerror(errno));
			break;
		}

		print_flag++;

		memset(acct_sess_id, 		0x00, sizeof(acct_sess_id));

		CVT_INT64_CP(&temp_long, cdrlog_info.llAcctSessID); 
		//sprintf(acct_sess_id, "%lld", temp_long);
		conv_id(temp_long, acct_sess_id);

		/** print sample **/
		/*
		if (print_flag == 1)
		{
			printf("############ PRINT CDR LOG DATA ###############\n\n");

			printf("IMSI 				: %s\n", 	cdrlog_info.szIMSI);
			printf("Acct Session ID 		: %s\n", 	acct_sess_id);
			printf("Source-IP-Address		: %s\n", 	
							cvt_ipaddr(CVT_INT_CP(cdrlog_info.uiSrcIP)));
			printf("Service-Option			: %d\n", CVT_INT_CP(cdrlog_info.dSvcOpt));
			printf("Create-Time			: %d\n", CVT_INT_CP(cdrlog_info.tCreateTime));
			printf("Last-Time			: %d\n", CVT_INT_CP(cdrlog_info.tLastTime));
			printf("Source-Port			: %d\n", cdrlog_info.usSecPort);
			printf("Destination-IP-Address		: %s\n", 
							cvt_ipaddr(CVT_INT_CP(cdrlog_info.uiDestIP)));
			printf("Destination-Port		: %d\n", cdrlog_info.usDestPort);
			printf("Service-Type			: %d\n", CVT_INT_CP(cdrlog_info.dSvcType));
			printf("IP-Up-Frame			: %d\n", CVT_INT_CP(cdrlog_info.uiUPIPFrames));
			printf("IP-Down-Frame			: %d\n", CVT_INT_CP(cdrlog_info.uiDownIPFrames));
			printf("IP-Up-Byte			: %d\n", CVT_INT_CP(cdrlog_info.uiUPIPBytes));
			printf("IP-Down-Byte			: %d\n", CVT_INT_CP(cdrlog_info.uiDownIPBytes));
			printf("ReTx-Up-Frame			: %d\n", CVT_INT_CP(cdrlog_info.uiUPTCPREFrames));
			printf("ReTx-Down-Frame			: %d\n", CVT_INT_CP(cdrlog_info.uiDownTCPREFrames));
			printf("ReTx-Up-Byte			: %d\n", CVT_INT_CP(cdrlog_info.uiUPTCPREBytes));
			printf("ReTx-Down-Byte			: %d\n", CVT_INT_CP(cdrlog_info.uiDownTCPREBytes));

			printf("################################################\n\n");
		}
		*/

		memset(src_ip, 		0x00, sizeof(src_ip));
		memset(dest_ip,		0x00, sizeof(dest_ip));
		memset(create_time,	0x00, sizeof(create_time));
		memset(end_time,	0x00, sizeof(end_time));

		strcpy(src_ip, (char *)cvt_ipaddr(CVT_INT_CP(cdrlog_info.uiSrcIP)));
		strcpy(dest_ip, (char *)cvt_ipaddr(CVT_INT_CP(cdrlog_info.uiDestIP)));

		CVT_INT_CP_CDR(cdrlog_info.tCreateTime, (int *)&cvt_crt_time);
		CVT_INT_CP_CDR(cdrlog_info.tLastTime, (int *)&cvt_last_time);

/*
		printf("=======>  cvt_crt_time : %d, %p\n", cvt_crt_time, &cvt_crt_time);
		printf("=======>  cvt_last_time : %d, %p\n", cvt_last_time, &cvt_last_time);
*/

		crt_time 	= localtime(&cvt_crt_time);
		sprintf(create_time, "%d-%02d-%02d %02d:%02d:%02d",
								crt_time->tm_year+1900,
								crt_time->tm_mon+1,
								crt_time->tm_mday,
								crt_time->tm_hour,
								crt_time->tm_min,
								crt_time->tm_sec);

		last_time 	= localtime(&cvt_last_time);
		sprintf(end_time, "%d-%02d-%02d %02d:%02d:%02d",
								last_time->tm_year+1900,
								last_time->tm_mon+1,
								last_time->tm_mday,
								last_time->tm_hour,
								last_time->tm_min,
								last_time->tm_sec);

		memset(buffer, 0x00, sizeof(buffer));


		if (check_register(dest_ip, cdrlog_info.usDestPort) < 0)
		{
			reg_cnt++;
			continue;
		}

		if (min_flag == 1)
		{
			if (!strcmp(search_min, cdrlog_info.szIMSI))
			{
				sprintf(buffer, "%s,0x%s,%s,%d,%s,%s,%u,%s,%u,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",	// 070913,poopee, ushort for port
					cdrlog_info.szIMSI,
					acct_sess_id,
					src_ip,
					CVT_INT_CP(cdrlog_info.dSvcOpt),
					create_time,
					end_time,
					CVT_SHORT_CP(cdrlog_info.usSecPort) & 0x0000FFFF,	// 070913,poopee
					dest_ip,	
					CVT_SHORT_CP(cdrlog_info.usDestPort) & 0x0000FFFF,	// 070913,poopee
					CVT_INT_CP(cdrlog_info.dSvcType),
					CVT_INT_CP(cdrlog_info.uiUPIPFrames),
					CVT_INT_CP(cdrlog_info.uiDownIPFrames),
					CVT_INT_CP(cdrlog_info.uiUPIPBytes),
					CVT_INT_CP(cdrlog_info.uiDownIPBytes),
					CVT_INT_CP(cdrlog_info.uiUPTCPREFrames),
					CVT_INT_CP(cdrlog_info.uiDownTCPREFrames),
					CVT_INT_CP(cdrlog_info.uiUPTCPREBytes),
					CVT_INT_CP(cdrlog_info.uiDownTCPREBytes));

				fputs(buffer, write_fd);
				cdrlog_cnt++;
			}
		}
		else if (min_flag == 2)
		{
			sprintf(buffer, "%s,0x%s,%s,%d,%s,%s,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
					cdrlog_info.szIMSI,
					acct_sess_id,
					src_ip,
					CVT_INT_CP(cdrlog_info.dSvcOpt),
					create_time,
					end_time,
					CVT_SHORT_CP(cdrlog_info.usSecPort) & 0x0000FFFF,	// 070913,poopee
					dest_ip,	
					CVT_SHORT_CP(cdrlog_info.usDestPort) & 0x0000FFFF,	// 070913,poopee
					CVT_INT_CP(cdrlog_info.dSvcType),
					CVT_INT_CP(cdrlog_info.uiUPIPFrames),
					CVT_INT_CP(cdrlog_info.uiDownIPFrames),
					CVT_INT_CP(cdrlog_info.uiUPIPBytes),
					CVT_INT_CP(cdrlog_info.uiDownIPBytes),
					CVT_INT_CP(cdrlog_info.uiUPTCPREFrames),
					CVT_INT_CP(cdrlog_info.uiDownTCPREFrames),
					CVT_INT_CP(cdrlog_info.uiUPTCPREBytes),
					CVT_INT_CP(cdrlog_info.uiDownTCPREBytes));

			fputs(buffer, write_fd);
			cdrlog_cnt++;
		}
		else if (min_flag == 3)
		{
			int 	ret_code;
			
			ret_code = check_dup_value( cdrlog_info.dSvcOpt, 
										cdrlog_info.uiDestIP,
										cdrlog_info.usDestPort);
			if(ret_code < 0)
			{
				dup_cnt++;
				continue;
			}
			else if (ret_code == 2)
			{
				add_dest_port(cdrlog_info.usDestPort);
			}
			else if (ret_code == 3)
			{
				add_dest_port(cdrlog_info.usDestPort);
				add_dest_ip(cdrlog_info.uiDestIP);
			}
			else if (ret_code == 4)
			{
				add_dest_port(cdrlog_info.usDestPort);
				add_dest_ip(cdrlog_info.uiDestIP);
				add_service_opt(cdrlog_info.dSvcOpt);
			}

			sprintf(buffer, "%s,0x%s,%s,%d,%s,%s,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
					cdrlog_info.szIMSI,
					acct_sess_id,
					src_ip,
					CVT_INT_CP(cdrlog_info.dSvcOpt),
					create_time,
					end_time,
					CVT_SHORT_CP(cdrlog_info.usSecPort) & 0x0000FFFF,	// 070913,poopee
					dest_ip,	
					CVT_SHORT_CP(cdrlog_info.usDestPort) & 0x0000FFFF,	// 070913,poopee
					CVT_INT_CP(cdrlog_info.dSvcType),
					CVT_INT_CP(cdrlog_info.uiUPIPFrames),
					CVT_INT_CP(cdrlog_info.uiDownIPFrames),
					CVT_INT_CP(cdrlog_info.uiUPIPBytes),
					CVT_INT_CP(cdrlog_info.uiDownIPBytes),
					CVT_INT_CP(cdrlog_info.uiUPTCPREFrames),
					CVT_INT_CP(cdrlog_info.uiDownTCPREFrames),
					CVT_INT_CP(cdrlog_info.uiUPTCPREBytes),
					CVT_INT_CP(cdrlog_info.uiDownTCPREBytes));
			
			fputs(buffer, write_fd);
			cdrlog_cnt++;
		}
		else 
		{
			if (ip_flag == 1)
			{
				if (!strcmp(ip, src_ip) || !strcmp (ip, dest_ip))
				{
					sprintf(buffer, "%s,0x%s,%s,%d,%s,%s,%u,%s,%u,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",	// 070913,poopee, ushort for port
						cdrlog_info.szIMSI,
						acct_sess_id,
						src_ip,
						CVT_INT_CP(cdrlog_info.dSvcOpt),
						create_time,
						end_time,
						CVT_SHORT_CP(cdrlog_info.usSecPort) & 0x0000FFFF,	// 070913,poopee
						dest_ip,	
						CVT_SHORT_CP(cdrlog_info.usDestPort) & 0x0000FFFF,	// 070913,poopee
						CVT_INT_CP(cdrlog_info.dSvcType),
						CVT_INT_CP(cdrlog_info.uiUPIPFrames),
						CVT_INT_CP(cdrlog_info.uiDownIPFrames),
						CVT_INT_CP(cdrlog_info.uiUPIPBytes),
						CVT_INT_CP(cdrlog_info.uiDownIPBytes),
						CVT_INT_CP(cdrlog_info.uiUPTCPREFrames),
						CVT_INT_CP(cdrlog_info.uiDownTCPREFrames),
						CVT_INT_CP(cdrlog_info.uiUPTCPREBytes),
						CVT_INT_CP(cdrlog_info.uiDownTCPREBytes));

					fputs(buffer, write_fd);
					cdrlog_cnt++;
				}
			}
			if (port1_flag == 1)
			{
				if (port1 == CVT_SHORT_CP(cdrlog_info.usSecPort) & 0x0000FFFF || port1 == CVT_SHORT_CP(cdrlog_info.usDestPort) & 0x0000FFFF)
				{
					sprintf(buffer, "%s,0x%s,%s,%d,%s,%s,%u,%s,%u,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",	// 070913,poopee, ushort for port
						cdrlog_info.szIMSI,
						acct_sess_id,
						src_ip,
						CVT_INT_CP(cdrlog_info.dSvcOpt),
						create_time,
						end_time,
						CVT_SHORT_CP(cdrlog_info.usSecPort) & 0x0000FFFF,	// 070913,poopee
						dest_ip,	
						CVT_SHORT_CP(cdrlog_info.usDestPort) & 0x0000FFFF,	// 070913,poopee
						CVT_INT_CP(cdrlog_info.dSvcType),
						CVT_INT_CP(cdrlog_info.uiUPIPFrames),
						CVT_INT_CP(cdrlog_info.uiDownIPFrames),
						CVT_INT_CP(cdrlog_info.uiUPIPBytes),
						CVT_INT_CP(cdrlog_info.uiDownIPBytes),
						CVT_INT_CP(cdrlog_info.uiUPTCPREFrames),
						CVT_INT_CP(cdrlog_info.uiDownTCPREFrames),
						CVT_INT_CP(cdrlog_info.uiUPTCPREBytes),
						CVT_INT_CP(cdrlog_info.uiDownTCPREBytes));

					fputs(buffer, write_fd);
					cdrlog_cnt++;
				}
			}
			if (port2_flag == 1)
			{
				if (port2 == CVT_SHORT_CP(cdrlog_info.usSecPort) & 0x0000FFFF || port2 == CVT_SHORT_CP(cdrlog_info.usDestPort) & 0x0000FFFF)
				{
					sprintf(buffer, "%s,0x%s,%s,%d,%s,%s,%u,%s,%u,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",	// 070913,poopee, ushort for port
						cdrlog_info.szIMSI,
						acct_sess_id,
						src_ip,
						CVT_INT_CP(cdrlog_info.dSvcOpt),
						create_time,
						end_time,
						CVT_SHORT_CP(cdrlog_info.usSecPort) & 0x0000FFFF,	// 070913,poopee
						dest_ip,	
						CVT_SHORT_CP(cdrlog_info.usDestPort) & 0x0000FFFF,	// 070913,poopee
						CVT_INT_CP(cdrlog_info.dSvcType),
						CVT_INT_CP(cdrlog_info.uiUPIPFrames),
						CVT_INT_CP(cdrlog_info.uiDownIPFrames),
						CVT_INT_CP(cdrlog_info.uiUPIPBytes),
						CVT_INT_CP(cdrlog_info.uiDownIPBytes),
						CVT_INT_CP(cdrlog_info.uiUPTCPREFrames),
						CVT_INT_CP(cdrlog_info.uiDownTCPREFrames),
						CVT_INT_CP(cdrlog_info.uiUPTCPREBytes),
						CVT_INT_CP(cdrlog_info.uiDownTCPREBytes));

					fputs(buffer, write_fd);
					cdrlog_cnt++;
				}
			}
		}
	} 	/** end of while **/

	total_cdr_cnt += cdrlog_cnt;
	printf("=======> CDR LOG COUNT : %d\n", cdrlog_cnt);
	printf("=======> check register cnt : %d\n", reg_cnt);
	cdrlog_cnt = 0;
	fclose(fd);
									
	return (1);

}