| 54 | static __thread uint32_t g_flen = 0; |
| 55 | |
| 56 | int ff_enable_pcap(const char* dump_path, uint16_t snap_len) |
| 57 | { |
| 58 | char pcap_f_path[FILE_PATH_LEN] = {0}; |
| 59 | |
| 60 | snprintf(pcap_f_path, FILE_PATH_LEN, "%s/cpu%d_%d.pcap", dump_path==NULL?".":dump_path, rte_lcore_id(), seq); |
| 61 | g_pcap_fp = fopen(pcap_f_path, "w+"); |
| 62 | if (g_pcap_fp == NULL) { |
| 63 | rte_exit(EXIT_FAILURE, "Cannot open pcap dump path: %s, errno %d.\n", pcap_f_path, errno); |
| 64 | return -1; |
| 65 | } |
| 66 | g_flen = 0; |
| 67 | |
| 68 | struct pcap_file_header pcap_file_hdr; |
| 69 | void* file_hdr = &pcap_file_hdr; |
| 70 | |
| 71 | pcap_file_hdr.magic = 0xA1B2C3D4; |
| 72 | pcap_file_hdr.version_major = 0x0002; |
| 73 | pcap_file_hdr.version_minor = 0x0004; |
| 74 | pcap_file_hdr.thiszone = 0x00000000; |
| 75 | pcap_file_hdr.sigfigs = 0x00000000; |
| 76 | pcap_file_hdr.snaplen = snap_len; //0x0000FFFF; //65535 |
| 77 | pcap_file_hdr.linktype = 0x00000001; //DLT_EN10MB, Ethernet (10Mb) |
| 78 | |
| 79 | fwrite(file_hdr, sizeof(struct pcap_file_header), 1, g_pcap_fp); |
| 80 | g_flen += sizeof(struct pcap_file_header); |
| 81 | |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | int |
| 86 | ff_dump_packets(const char* dump_path, struct rte_mbuf* pkt, uint16_t snap_len, uint32_t f_maxlen) |
no test coverage detected