diff options
Diffstat (limited to 'benchmark/src/sapp_benchmark_utils.cpp')
| -rw-r--r-- | benchmark/src/sapp_benchmark_utils.cpp | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/benchmark/src/sapp_benchmark_utils.cpp b/benchmark/src/sapp_benchmark_utils.cpp index 40aec01..6c80c7e 100644 --- a/benchmark/src/sapp_benchmark_utils.cpp +++ b/benchmark/src/sapp_benchmark_utils.cpp @@ -1,8 +1,13 @@ +#ifdef __cplusplus +extern "C" { +#endif + #include "sapp_benchmark.h" #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <netinet/ip.h> +#include <netinet/ip6.h> #include <netinet/tcp.h> #include <netinet/udp.h> #include <assert.h> @@ -12,8 +17,6 @@ #include <sys/socket.h> #include <sys/un.h> #include <errno.h> -#include "stream.h" -#include <signal.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/time.h> @@ -26,9 +29,8 @@ #include "wrap_cJSON.h" #include "sapp_bchmk_inner.h" -#ifdef __cplusplus -extern "C" { -#endif +#include "MESA_prof_load.h" + @@ -102,9 +104,9 @@ static int ifconfig_device_up(const char *interface_name) printf("Create Socket Failed.\n"); return -2; } - //ָ������������up + //ָ������������up sprintf(ifr.ifr_name, "%s", interface_name); - /* ��ýӿڵı�־ */ + /* ��ýӿڵı�־ */ if ((err = ioctl(socket_fd, SIOCGIFFLAGS, (void *)&ifr)) < 0) { fprintf(stderr, "ifconfig_device_up(%s), ioctl SIOCGIFFLAGS: %s\n", interface_name, strerror(errno)); close(socket_fd); @@ -143,7 +145,7 @@ int ifconfig_device_mtu(const char *interface_name, int mtu_val) return -2; } sprintf(ifr.ifr_name, "%s", interface_name); - /* ��ýӿڵı�־ */ + /* ��ýӿڵı�־ */ if ((err = ioctl(socket_fd, SIOCGIFMTU, (void *)&ifr)) < 0) { fprintf(stderr, "ifconfig_device_mtu(%s), ioctl SIOCGIFMTU: %s\n", interface_name, strerror(errno)); close(socket_fd); @@ -191,14 +193,14 @@ static int tuntap_dev_create(char *dev, int flags) ifconfig_device_up(dev); - ifconfig_device_mtu(dev, 2000); /* ijЩpcap�����ܿ�����offload, ����vlan, vxlan��, ����MTU */ + ifconfig_device_mtu(dev, 2000); /* ijЩpcap�����ܿ�����offload, ����vlan, vxlan��, ����MTU */ return fd; } /* - �������, ���mirror, inlineģʽ�Ǵ���һ��TAP, transparent�Ǵ�������TAP, - ֱ�Ӷ�ȡ����sapp.toml�ļ�. + �������, ���mirror, inlineģʽ�Ǵ���һ��TAP, transparent�Ǵ�������TAP, + ֱ�Ӷ�ȡ����sapp.toml�ļ�. */ int sapp_bchmk_create_process_engine(benchmark_engine_t *bch_engine) { @@ -289,9 +291,9 @@ int sapp_bchmk_md5_checksum(const char *filename, const char *expect_md5sum) } /* - ע��: - �˺���ʵ�ʷ��ص���TRUE��FALSE, - 0��ʾ��һ��, 1��ʾһ��!! + ע��: + �˺���ʵ�ʷ��ص���TRUE��FALSE, + 0��ʾ��һ��, 1��ʾһ��!! */ cJSON_bool sapp_bchmk_json_file_compare(benchmark_engine_t *bchmk_engine, const char *json_file1, const char *json_file2, cJSON_Compare_Opt_t opt) { @@ -429,7 +431,7 @@ int sapp_bchmk_gen_pcap_file(benchmark_engine_t *bchmk_engine, const pcap_pkt_de /* - ���ڴ��е�һ��ԭʼ����, ������pcap�ļ�, �ٵ���tshark -T ����һ��json�ļ�. + ���ڴ��е�һ��ԭʼ����, ������pcap�ļ�, �ٵ���tshark -T ����һ��json�ļ�. */ int sapp_bchmk_gen_tshark_json(benchmark_engine_t *bchmk_engine, const pcap_pkt_detail_t *pkt_detail, int pkt_num, const char *tshark_json_filename) { @@ -478,7 +480,7 @@ int sapp_bchmk_need_drop_cur_pkt(benchmark_engine_t *bchmk_engine, int pkt_index array_size = cJSON_GetArraySize(sub_pkt_index_item); - /* ��C�����±�ת��Ϊwireshark�����ݰ����, ��ʵ���Ǽ�1 */ + /* ��C�����±�ת��Ϊwireshark�����ݰ����, ��ʵ���Ǽ�1 */ ADJUST_ARRAY_INDEX_to_WIRESHARK(pkt_index); for(i = 0; i < array_size; i++){ @@ -492,9 +494,9 @@ int sapp_bchmk_need_drop_cur_pkt(benchmark_engine_t *bchmk_engine, int pkt_index } /* - ����ֵ: Ҫ���˰����������json file name. + ����ֵ: Ҫ���˰����������json file name. - �����NULL, ��Ҫ�����ж�һ��errno, �Ƿ�����Ϊjson��ʽ����, û��дpacket_detail_json_file. + �����NULL, ��Ҫ�����ж�һ��errno, �Ƿ�����Ϊjson��ʽ����, û��дpacket_detail_json_file. */ const char *sapp_bchmk_need_check_forward_pkt(benchmark_engine_t *bchmk_engine, int pkt_index) { @@ -520,7 +522,7 @@ const char *sapp_bchmk_need_check_forward_pkt(benchmark_engine_t *bchmk_engine, array_size = cJSON_GetArraySize(sub_pkt_detail_item); - /* ע��: Ϊ�˷����wireshark�Ա�, pkt index��1��ʼ����, �����±��0��ʼ */ + /* ע��: Ϊ�˷����wireshark�Ա�, pkt index��1��ʼ����, �����±��0��ʼ */ ADJUST_ARRAY_INDEX_to_WIRESHARK(pkt_index); for(i = 0; i < array_size; i++){ @@ -546,7 +548,7 @@ const char *sapp_bchmk_need_check_forward_pkt(benchmark_engine_t *bchmk_engine, } /* - ����ֵ: ָ��inject���cjson�ṹ��ָ��. + ����ֵ: ָ��inject���cjson�ṹ��ָ��. */ const cJSON *sapp_bchmk_need_check_inject_pkt(benchmark_engine_t *bchmk_engine, int carray_pkt_index) { @@ -566,9 +568,9 @@ const cJSON *sapp_bchmk_need_check_inject_pkt(benchmark_engine_t *bchmk_engine, return NULL; } - /* ע��: Ϊ�˷����wireshark�Ա�, pkt index��1��ʼ����, �˴������0��ʼ */ + /* ע��: Ϊ�˷����wireshark�Ա�, pkt index��1��ʼ����, �˴������0��ʼ */ if(sub_array_pkt_index_item->valueint != (carray_pkt_index+1)){ - /* ��ǰ�����ᴥ��inject����, do nothing */ + /* ��ǰ�����ᴥ��inject����, do nothing */ sapp_bchmk_log(bchmk_engine,RLOG_LV_DEBUG, "pkt index:%d, don't need check inject json, ignore it", carray_pkt_index+1); errno = 0; return NULL; @@ -578,7 +580,7 @@ const cJSON *sapp_bchmk_need_check_inject_pkt(benchmark_engine_t *bchmk_engine, } /* - ����ֵ: ָ��control���cjson�ṹ��ָ��. + ����ֵ: ָ��control���cjson�ṹ��ָ��. */ const cJSON *sapp_bchmk_need_process_control(benchmark_engine_t *bchmk_engine, int carray_pkt_index) { @@ -604,13 +606,13 @@ const cJSON *sapp_bchmk_need_process_control(benchmark_engine_t *bchmk_engine, i /* - ÿ�β���ǰ, ����sapp��Ĭ�����ø������л���, - ��Ҫ�ĵ����ò���, ÿ��ҲҪ�ֳ���, - ������Ĭ�ϲ��������²��Բ�ͨ��. + ÿ�β���ǰ, ����sapp��Ĭ�����ø������л���, + ��Ҫ�ĵ����ò���, ÿ��ҲҪ�ֳ���, + ������Ĭ�ϲ��������²��Բ�ͨ��. - ��sapp�������ļ�ֱ�ӷ������.c����, ����cmake install, ��rpm -iʱ�Ͳ���װһ���ļ���, - ���������װʱʹ��--prefix����, ������Ҳ�����Щ�ļ���. - ֱ�Ӵӳ�����copy����. + ��sapp�������ļ�ֱ�ӷ������.c����, ����cmake install, ��rpm -iʱ�Ͳ���װһ���ļ���, + ���������װʱʹ��--prefix����, ������Ҳ�����Щ�ļ���. + ֱ�Ӵӳ�����copy����. */ static void sapp_bchmk_write_to_file(const char *config_name, const void *content, int content_len) @@ -657,7 +659,7 @@ void sapp_bchmk_set_default_config(void) sapp_bchmk_write_to_file("etc/send_raw_pkt.conf", templete_send_raw_pkt, templete_send_raw_pkt_len); sapp_bchmk_write_to_file("etc/send_log.conf", templete_sapp_log, templete_sapp_log_len); - /* ������plug.inf����, ֻ���������ͷ���ֶ� */ + /* ������plug.inf����, ֻ���������ͷ���ֶ� */ system("mkdir -p ./plug/business/gtest_sapp"); system("echo \"[PLUGINFO]\" > ./plug/business/gtest_sapp/gtest_sapp.inf"); system("echo \"PLUGNAME=xxxx\" >> ./plug/business/gtest_sapp/gtest_sapp.inf"); @@ -734,7 +736,7 @@ const char *sapp_bchmk_rawpkt_ntop_v6(const struct ip6_hdr *ip6hdr, char *res_bu dport = inner_uhdr->dest; snprintf(res_buf, buf_len, "%s.%u --> %s.%u, %s", ip_src_str, ntohs(sport), ip_dst_str, ntohs(dport), "UDP"); - }else if(IPPROTO_ICMPV6 == inner_ip_proto){ /* ע��: ipv6��icmpͷ���ֶ���ipv4��һ��!! */ + }else if(IPPROTO_ICMPV6 == inner_ip_proto){ /* ע��: ipv6��icmpͷ���ֶ���ipv4��һ��!! */ snprintf(res_buf, buf_len, "%s --> %s,ICMP", ip_src_str, ip_dst_str); }else{ snprintf(res_buf, buf_len, "%s --> %s, unknown protocol:%u", ip_src_str, ip_dst_str, inner_ip_proto); |
