From 8abbfe5a10fdcca9e6b33beb1d3fad0bfc53c24c Mon Sep 17 00:00:00 2001 From: lijie Date: Wed, 28 Nov 2018 16:26:43 +0800 Subject: 添加统计功能,统计分配和释放的内存数以及接收和发送的数据包数目 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Makefile | 4 +- src/mrl_main.c | 165 +++++++++++++++++++++++++++++++++++++++++++------------ src/mrl_packet.c | 37 ++++++++----- src/mrl_redis.c | 52 +++--------------- src/mrl_stat.c | 82 +++++++++++++++++++++++++++ 5 files changed, 245 insertions(+), 95 deletions(-) create mode 100644 src/mrl_stat.c diff --git a/src/Makefile b/src/Makefile index b9cb678..5637f24 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,11 +18,11 @@ LIBS = -L /opt/MESA/lib #LIBS = -L ../support/lib -LIBS += -lMESA_prof_load -lMESA_handle_logger -lpthread -lmaatframe -lMESA_htable -lmaxminddb +LIBS += -lMESA_prof_load -lMESA_handle_logger -lpthread -lmaatframe -lMESA_htable -lMESA_field_stat2 -lmaxminddb TARGET = mrl.so -OBJS = mrl_main.o mrl_utils.o mrl_packet.o mrl_redis.o +OBJS = mrl_main.o mrl_utils.o mrl_packet.o mrl_redis.o mrl_stat.o .PHONY: all clean install diff --git a/src/mrl_main.c b/src/mrl_main.c index 99f8001..9296ee0 100644 --- a/src/mrl_main.c +++ b/src/mrl_main.c @@ -7,10 +7,10 @@ #include "mrl_main.h" #include "mrl_redis.h" #include "mrl_packet.h" - +#include "mrl_stat.h" struct mrl_global_instance mrl_instance; - +extern struct global_stat_t global_stat; void mrl_cfg_init(const char *profile) { char *temp_mac_str; @@ -74,45 +74,71 @@ void mrl_cfg_init(const char *profile) MESA_load_profile_uint_def(profile, "VXLAN_INFO", "vxlan_gdev_num", &(mrl_instance.mrl_cfg.vxlan_gdev_num), 1); temp_mac_str = (char *)calloc(mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_MAC_LEN,sizeof(char)); + global_stat.malloc_memory += mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_MAC_LEN; + temp_ip_str = (char *)calloc(mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_IP_LEN,sizeof(char)); + global_stat.malloc_memory += mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_IP_LEN; + temp_port_str = (char *)calloc(mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_PORT_LEN, sizeof(char)); + global_stat.malloc_memory += mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_PORT_LEN; + temp_encap_type_str = (char *)calloc(mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_ENCAP_TYPE_LEN,sizeof(char)); + global_stat.malloc_memory += mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_ENCAP_TYPE_LEN; + temp_vpn_id_str = (char *)calloc(mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_VPN_ID_LEN,sizeof(char)); + global_stat.malloc_memory += mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_VPN_ID_LEN; + temp_link_id_str = (char *)calloc(mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_LINK_ID_LEN,sizeof(char)); + global_stat.malloc_memory += mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_LINK_ID_LEN; + temp_link_dir_str = (char *)calloc(mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_LINK_DIR_LEN, sizeof(char)); + global_stat.malloc_memory += mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_LINK_DIR_LEN; MESA_load_profile_string_def(profile, "VXLAN_INFO", "vxlan_gdev_mac",temp_mac_str, mrl_instance.mrl_cfg.vxlan_gdev_num*MRL_STR_MAC_LEN, "00:00:00:00:00:00"); mrl_instance.mrl_cfg.vxlan_outer_gdev_mac = (char **)malloc(sizeof(char *)*mrl_instance.mrl_cfg.vxlan_gdev_num); + global_stat.malloc_memory += mrl_instance.mrl_cfg.vxlan_gdev_num * sizeof(char *); + for(i=0;ipktstate){ case OP_STATE_PENDING: if(mrl_pkt_signature_identify(a_tcp)) { - mrl_send_to_mgw(raw_packet, thread_seq); - ret = APP_STATE_GIVEME;//ָfawdropȡĸ + global_stat.recv_ir_pkts ++; + mrl_send_to_mgw(raw_packet, thread_seq); + ret = APP_STATE_GIVEME;//ָfawdropȡĸ } else { @@ -304,12 +385,17 @@ extern "C" char mrl_tcpall_entry(struct streaminfo *a_tcp,void **pme, int thread break; case OP_STATE_DATA: + global_stat.recv_ir_pkts ++; mrl_send_to_mgw(raw_packet, thread_seq); ret = APP_STATE_GIVEME; break; case OP_STATE_CLOSE: - mrl_send_to_mgw(raw_packet, thread_seq); + if(raw_packet != NULL) + { + global_stat.recv_ir_pkts ++; + mrl_send_to_mgw(raw_packet, thread_seq); + } ret = APP_STATE_DROPME; break; @@ -323,27 +409,36 @@ extern "C" char mrl_tcpall_entry(struct streaminfo *a_tcp,void **pme, int thread extern "C" char mrl_udp_entry(struct streaminfo *a_udp, void **pme, int thread_seq, void *raw_packet) { - char ret = APP_STATE_GIVEME; + global_stat.recv_gdev_total_pkts ++; + global_stat.recv_gdev_udp_pkts ++; + + char ret = APP_STATE_GIVEME; switch(a_udp->pktstate){ case OP_STATE_PENDING: if(mrl_pkt_signature_identify(a_udp)) { + global_stat.recv_ir_pkts ++; mrl_send_to_mgw(raw_packet, thread_seq); ret = APP_STATE_GIVEME; } else { mrl_identify_nominee(a_udp); - ret =APP_STATE_DROPME; + ret =APP_STATE_DROPME|APP_STATE_FAWPKT; } break; case OP_STATE_DATA: + global_stat.recv_ir_pkts ++; mrl_send_to_mgw(raw_packet, thread_seq); ret = APP_STATE_GIVEME; break; case OP_STATE_CLOSE: - mrl_send_to_mgw(raw_packet, thread_seq); + if(raw_packet != NULL) + { + global_stat.recv_ir_pkts ++; + mrl_send_to_mgw(raw_packet, thread_seq); + } ret = APP_STATE_DROPME; break; diff --git a/src/mrl_packet.c b/src/mrl_packet.c index 575ebb5..e4b3b26 100644 --- a/src/mrl_packet.c +++ b/src/mrl_packet.c @@ -12,7 +12,9 @@ #include "mrl_main.h" #include "mrl_utils.h" #include "mrl_redis.h" +#include "mrl_stat.h" +extern struct global_stat_t global_stat; extern struct mrl_global_instance mrl_instance; extern void mrl_get_vxlan_info(struct mrl_vxlan_info *vxlan, unsigned int index); @@ -26,6 +28,8 @@ void mrl_socket_init() sapp_get_platform_opt(SPO_THREAD_COUNT,(void *) &thread_num, &len); printf("sapp thread num is %d\n",thread_num); mrl_instance.mrl_snd_fd = (int *) malloc (sizeof(int)*thread_num); + global_stat.malloc_memory += sizeof(int)*thread_num; + for(i = 0; i< thread_num;i++) { mrl_instance.mrl_snd_fd[i] = socket(AF_INET, SOCK_DGRAM, 0); @@ -56,8 +60,11 @@ void mrl_socket_close() printf("sapp thread num is %d\n",thread_num); for(i = 0; i< thread_num;i++) { - close(mrl_instance.mrl_snd_fd[i]); + close(mrl_instance.mrl_snd_fd[i]); } + + free(mrl_instance.mrl_snd_fd); + global_stat.free_memory += sizeof(int)*thread_num; close(mrl_instance.mrl_rcv_fd); } @@ -239,7 +246,6 @@ void mrl_send_to_gdev(int thread_seq, struct mrl_vxlan_info * vxlan_info, const //жǷIPð bool mrl_pkt_signature_identify(struct streaminfo *mystream) { - //printf("start to signature identify\n"); char temp_sip[MRL_STR_IP_LEN]; char temp_dip[MRL_STR_IP_LEN]; memset(temp_sip,0,MRL_STR_IP_LEN); @@ -254,16 +260,17 @@ bool mrl_pkt_signature_identify(struct streaminfo *mystream) dip = ntohl(mystream->addr.tuple4_v4->daddr); inet_ntop(AF_INET,&(mystream->addr.tuple4_v4->saddr),temp_sip,MRL_STR_IP_LEN); inet_ntop(AF_INET,&(mystream->addr.tuple4_v4->daddr),temp_dip,MRL_STR_IP_LEN); - /*if(memcmp(temp_sip,"61.135.169.121",strlen(temp_sip)) == 0) + /* + if(memcmp(temp_sip,"61.135.169.121",strlen(temp_sip)) == 0) { - printf("cur sip is baidu\n"); + printf("cur stream sip is baidu\n"); return true; } else { - if(memcmp(temp_dip,"61.135.169.121",strlen(temp_sip)) == 0) + if(memcmp(temp_dip,"61.135.169.121",strlen(temp_dip)) == 0) { - printf("cur dip is baidu\n"); + printf("cur stream dip is baidu\n"); return true; } else @@ -315,11 +322,12 @@ void mrl_send_to_mgw(void *raw_pkt, int thread_seq) const char *pkt = (const char *)raw_pkt; struct iphdr *ip_hdr = (struct iphdr *)pkt; ssize_t pkt_len = ntohs(ip_hdr->tot_len); - MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_send_to_mgw","send to mgw len is %d",pkt_len); ssize_t send_len = 0; send_len = mrl_sock_send(mrl_instance.mrl_snd_fd[thread_seq],pkt,pkt_len,&(mrl_instance.mgw_addr)); + global_stat.send_to_mgw_pkts += 1; + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_send_to_mgw","pkt len is %d and send to mgw len is %d",pkt_len,send_len); assert(send_len == pkt_len); - printf("send socket len is %ld\n",send_len); + } @@ -338,7 +346,8 @@ void *mrl_recv_mgw_action(void *arg) } memset(rcv_buff,0,MRL_BUFF_LEN); recv_len = mrl_sock_recv(mrl_instance.mrl_rcv_fd,rcv_buff, MRL_BUFF_LEN); - printf("recv from mgw len is %ld\n",recv_len); + global_stat.recv_from_mgw_pkts ++; + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_recv_mgw_action","recv from mgw len is %ld",recv_len); struct mrl_vxlan_info *vxlan_info = (struct mrl_vxlan_info *)rcv_buff; MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_recv_mgw_action","recv mgw vxlan info:" "link_id:%d,encap_type:%d,link_dir:%d,vpn_id:%d,local_port:%s,gdev_port:%s, local_ip:%s,gdev_ip:%s," @@ -348,11 +357,10 @@ void *mrl_recv_mgw_action(void *arg) vxlan_info->vxlan_outer_local_ip,vxlan_info->vxlan_outer_gdev_ip,vxlan_info->vxlan_outer_local_mac, vxlan_info->vxlan_outer_gdev_mac,vxlan_info->vxlan_inner_smac, vxlan_info->vxlan_inner_dmac); size_t vxlan_len = sizeof(struct mrl_vxlan_info); - temp_len = sizeof(thread_seq); sapp_get_platform_opt(SPO_INDEPENDENT_THREAD_ID, &thread_seq, &temp_len); - //printf("send to gdev thread seq is %d\n",thread_seq); mrl_send_to_gdev(thread_seq,vxlan_info,rcv_buff + vxlan_len, recv_len - vxlan_len); + global_stat.send_gdev_total_pkts ++; } return NULL; } @@ -396,7 +404,7 @@ size_t mrl_build_udp_payload(char *payload) } void mrl_detect_action(uint32_t src_ip) { - MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"mrl_detect_action","detect ip is %u",src_ip); + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_detect_action","detect ip is %u",src_ip); unsigned int i = 0; int thread_seq = 0; int temp_len = 0; @@ -417,12 +425,14 @@ void mrl_detect_action(uint32_t src_ip) memset(&vxlan_info,0,sizeof(vxlan_info)); mrl_get_vxlan_info(&vxlan_info,i); mrl_send_to_gdev(thread_seq,&vxlan_info,ip_pkt,ip_len); + global_stat.send_detect_pkts ++; + global_stat.send_gdev_total_pkts ++; } } void *mrl_detect_ip_action(void *arg) { - sleep(10); + sleep(20); int ret = 0; uint32_t detect_ip = 0; long int ip_len = sizeof(detect_ip); @@ -433,7 +443,6 @@ void *mrl_detect_ip_action(void *arg) break; } ret = MESA_lqueue_get_head(mrl_instance.mrl_queue,&detect_ip,&ip_len); - MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"mrl_detect_ip_action","get ip from lqueue is %u",detect_ip); if(ret != 0) { MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"mrl_detect_ip_action","MESA_lqueue_get_head func error! ret is %d",ret); diff --git a/src/mrl_redis.c b/src/mrl_redis.c index 86287db..113ba68 100644 --- a/src/mrl_redis.c +++ b/src/mrl_redis.c @@ -3,8 +3,10 @@ #include "mrl_packet.h" #include "mrl_redis.h" +#include "mrl_stat.h" extern struct mrl_global_instance mrl_instance; +extern struct global_stat_t global_stat; extern void mrl_detect_action(const char *ip_addr); void wrapped_Maat_set_feather_opt(Maat_feather_t feather, enum MAAT_INIT_OPT type, const void* value, int size) @@ -24,22 +26,12 @@ void ht_nominee_free_cb(void * data) { free(nominee_item); nominee_item = NULL; + global_stat.free_memory += sizeof(struct mrl_nominee_item); } } -/* -void ht_candidate_free_cb(void * data) -{ - struct mrl_candidate_item *candidate_item = (struct mrl_candidate_item *)data; - if(candidate_item != NULL) - { - free(candidate_item); - candidate_item = NULL; - } -} -*/ + MESA_htable_handle mrl_htable_init(void * fn_data_free_cb) { - printf("mrl htable init\n"); unsigned int opt_int; MESA_htable_handle htable = MESA_htable_born(); assert(htable != NULL); @@ -159,6 +151,7 @@ void nominee_update_cb(int table_id,const char* table_line,void* u_para) int ret = 0; uint32_t client_ip = 0; struct mrl_nominee_item *nominee_item = (struct mrl_nominee_item *)calloc(1, sizeof(struct mrl_nominee_item)); + global_stat.malloc_memory += sizeof(struct mrl_nominee_item); sscanf(table_line,"%d\t%d\t%d\t%s\t%d\t%s", &(nominee_item->config_id), &(nominee_item->group_id), &(nominee_item->addr_type), nominee_item->ip_addr, &(nominee_item->is_vaild), nominee_item->op_time); @@ -169,7 +162,7 @@ void nominee_update_cb(int table_id,const char* table_line,void* u_para) switch(nominee_item->is_vaild) { case 0: - if(MESA_htable_search_cb(mrl_instance.ht_nominee, (const unsigned char *)nominee_item->ip_addr, MRL_STR_IP_LEN,NULL,NULL,NULL) == NULL) + if(MESA_htable_search_cb(mrl_instance.ht_nominee, (const unsigned char *)nominee_item->ip_addr, MRL_STR_IP_LEN,NULL,NULL,NULL) != NULL) { ret = MESA_htable_del(mrl_instance.ht_nominee, (const unsigned char *)nominee_item->ip_addr, MRL_STR_IP_LEN, NULL); if(ret < 0) @@ -213,37 +206,7 @@ void nominee_update_cb(int table_id,const char* table_line,void* u_para) } -/* -void candidate_update_cb(int table_id,const char* table_line,void* u_para) -{ - int ret = 0; - printf("this is candidate update cb\n"); - struct mrl_candidate_item *candidate_item = (struct mrl_candidate_item *)calloc(1, sizeof(struct mrl_candidate_item)); - sscanf(table_line,"%d\t%d\t%d\t%s\t%d\t%s\t%d\t%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%d\t%s", - &(candidate_item->config_id), &(candidate_item->group_id),&(candidate_item->addr_type), - candidate_item->ip_addr,&(candidate_item->location),candidate_item->mrl_ip, - &(candidate_item->vxlan_info.vxlan_link_id), &(candidate_item->vxlan_info.vxlan_encap_type), - &(candidate_item->vxlan_info.vxlan_link_dir),candidate_item->vxlan_info.vxlan_outer_local_port, - candidate_item->vxlan_info.vxlan_outer_gdev_port,candidate_item->vxlan_info.vxlan_outer_local_ip, - candidate_item->vxlan_info.vxlan_outer_gdev_ip,candidate_item->vxlan_info.vxlan_outer_local_mac, - candidate_item->vxlan_info.vxlan_outer_gdev_mac,candidate_item->vxlan_info.vxlan_inner_smac, - candidate_item->vxlan_info.vxlan_inner_dmac,&(candidate_item->is_vaild), candidate_item->op_time); - if(MESA_htable_search_cb(mrl_instance.ht_candidate, (const unsigned char *)candidate_item->ip_addr, sizeof(candidate_item->ip_addr),NULL,NULL,NULL) == NULL) - { - ret = MESA_htable_add(mrl_instance.ht_candidate, (const unsigned char *)(candidate_item->ip_addr), sizeof(candidate_item->ip_addr), candidate_item); - if(ret < 0) - { - MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"candidate_update_cb","MESA_htable_add func error! ret is %d",ret); - assert(0); - } - } - else - { - MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"candidate_update_cb","the candidate item is duplicated in candidate htable."); - } - -} -*/ + long ht_search_cb(void *data, const uchar *key, uint size, void *user_arg) { struct mrl_nominee_item *nominee_item = (struct mrl_nominee_item *)data; @@ -348,6 +311,7 @@ void mrl_identify_nominee(struct streaminfo *mystream) MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_identify_nominee","cur identify nominee stream ip is %s\n",ip_addr); if(MESA_htable_search_cb(mrl_instance.ht_nominee, (const unsigned char *)ip_addr, MRL_STR_IP_LEN,ht_search_cb,(void *)&candidate_item,&ret) != NULL) { + global_stat.recv_detect_pkts ++; get_rawpkt_opt_from_streaminfo(mystream, RAW_PKT_GET_GDEV_IP, &(gdev_ip)); //printf("cur gdev ip is %d\n",gdev_ip); index = get_gdev_ip_index(gdev_ip); diff --git a/src/mrl_stat.c b/src/mrl_stat.c new file mode 100644 index 0000000..a2ead74 --- /dev/null +++ b/src/mrl_stat.c @@ -0,0 +1,82 @@ +#include"mrl_stat.h" +#include +#include +#include +#include + +struct global_stat_t global_stat; +struct fs_stat_t global_fs_stat; +void mrl_stat_init() +{ + int value = 0; + char stat_file[] = "log/mrl_stat.log"; + memset(&global_stat,0,sizeof(struct global_stat_t)); + + global_fs_stat.handle = FS_create_handle(); + + FS_set_para(global_fs_stat.handle, OUTPUT_DEVICE, stat_file, strlen(stat_file)+1); + + value = 1; + FS_set_para(global_fs_stat.handle, PRINT_MODE, &value, sizeof(value)); + + value = 0; + FS_set_para(global_fs_stat.handle, CREATE_THREAD, &value, sizeof(value)); + + /* field */ + global_fs_stat.fs_field_id[FIELD_RECV_MGW_PKTS] = FS_register(global_fs_stat.handle, FS_STYLE_FIELD, FS_CALC_SPEED,"RECV_MGW_PKTS"); + global_fs_stat.fs_field_id[FIELD_SEND_MGW_PKTS] = FS_register(global_fs_stat.handle, FS_STYLE_FIELD, FS_CALC_SPEED,"SEND_MGW_PKTS"); + + global_fs_stat.fs_field_id[FIELD_RECV_GDEV_PKTS] = FS_register(global_fs_stat.handle, FS_STYLE_FIELD, FS_CALC_SPEED,"RECV_GDEV_PKTS"); + global_fs_stat.fs_field_id[FIELD_SEND_GDEV_PKTS] = FS_register(global_fs_stat.handle, FS_STYLE_FIELD, FS_CALC_SPEED,"SEND_GDEV_PKTS"); + + global_fs_stat.fs_field_id[FIELD_RECV_IR_PKTS] = FS_register(global_fs_stat.handle, FS_STYLE_FIELD, FS_CALC_SPEED,"rec_ir_pkts"); + + global_fs_stat.fs_field_id[FIELD_RECV_GDEV_TCP_PKTS] = FS_register(global_fs_stat.handle, FS_STYLE_FIELD, FS_CALC_SPEED,"recv_gdev_tcp_pkts"); + global_fs_stat.fs_field_id[FIELD_RECV_GDEV_UDP_PKTS] = FS_register(global_fs_stat.handle, FS_STYLE_FIELD, FS_CALC_SPEED,"recv_gdev_udp_pkts"); + + global_fs_stat.fs_field_id[FIELD_SEND_DETECT_PKTS] = FS_register(global_fs_stat.handle, FS_STYLE_FIELD, FS_CALC_SPEED,"send_detect_pkts"); + global_fs_stat.fs_field_id[FIELD_RECV_DETECT_PKTS] = FS_register(global_fs_stat.handle, FS_STYLE_FIELD, FS_CALC_SPEED,"recv_detect_pkts"); + + /*status*/ + global_fs_stat.fs_status_id[STATUS_MALLOC_MEMORY] = FS_register(global_fs_stat.handle, FS_STYLE_STATUS, FS_CALC_CURRENT, "malloc_memory(Byte)"); + global_fs_stat.fs_status_id[STATUS_FREE_MEMORY] = FS_register(global_fs_stat.handle, FS_STYLE_STATUS, FS_CALC_CURRENT, "free_memory(Byte)"); + + FS_start(global_fs_stat.handle); +} + +void mrl_stat_output() +{ + /*field*/ + + FS_operate(global_fs_stat.handle, global_fs_stat.fs_field_id[FIELD_SEND_MGW_PKTS], 0, FS_OP_SET, global_stat.send_to_mgw_pkts); + FS_operate(global_fs_stat.handle, global_fs_stat.fs_field_id[FIELD_RECV_MGW_PKTS], 0, FS_OP_SET, global_stat.recv_from_mgw_pkts); + + FS_operate(global_fs_stat.handle, global_fs_stat.fs_field_id[FIELD_SEND_GDEV_PKTS], 0, FS_OP_SET, global_stat.send_gdev_total_pkts); + FS_operate(global_fs_stat.handle, global_fs_stat.fs_field_id[FIELD_RECV_GDEV_PKTS], 0, FS_OP_SET, global_stat.recv_gdev_total_pkts); + FS_operate(global_fs_stat.handle, global_fs_stat.fs_field_id[FIELD_RECV_GDEV_TCP_PKTS], 0, FS_OP_SET, global_stat.recv_gdev_tcp_pkts); + FS_operate(global_fs_stat.handle, global_fs_stat.fs_field_id[FIELD_RECV_GDEV_UDP_PKTS], 0, FS_OP_SET, global_stat.recv_gdev_udp_pkts); + + FS_operate(global_fs_stat.handle, global_fs_stat.fs_field_id[FIELD_RECV_IR_PKTS], 0, FS_OP_SET, global_stat.recv_ir_pkts); + + FS_operate(global_fs_stat.handle, global_fs_stat.fs_field_id[FIELD_SEND_DETECT_PKTS], 0, FS_OP_SET, global_stat.send_detect_pkts); + FS_operate(global_fs_stat.handle, global_fs_stat.fs_field_id[FIELD_RECV_DETECT_PKTS], 0, FS_OP_SET, global_stat.recv_detect_pkts); + + /*status*/ + FS_operate(global_fs_stat.handle, global_fs_stat.fs_status_id[STATUS_MALLOC_MEMORY], 0, FS_OP_SET, global_stat.malloc_memory); + FS_operate(global_fs_stat.handle, global_fs_stat.fs_status_id[STATUS_FREE_MEMORY], 0, FS_OP_SET, global_stat.free_memory); + FS_passive_output(global_fs_stat.handle); +} + + +void *mrl_stat_action(void *arg) +{ + printf("start stat thread\n"); + for(;;) + { + mrl_stat_output(); + sleep(1); + } + return NULL; +} + + -- cgit v1.2.3