Changeset 8df87c4
- Timestamp:
- 12/19/18 15:35:26 (2 years ago)
- Branches:
- develop
- Children:
- 630460b
- Parents:
- 6327ce6
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_linux_common.c
r6327ce6 r8df87c4 66 66 unsigned int arphrd; 67 67 libtrace_dlt_t dlt; 68 libtrace_filter_t *f; 68 69 int sock; 69 70 pcap_t *pcap; 71 72 /* Take a copy of the filter structure to prevent against 73 * deletion causing the filter to no longer work */ 74 f = (libtrace_filter_t *) malloc(sizeof(libtrace_filter_t)); 75 memcpy(f, filter, sizeof(libtrace_filter_t)); 76 f->filterstring = strdup(filter->filterstring); 70 77 71 78 /* If we are passed a filter with "flag" set to zero, then we must … … 78 85 * anything (we've just copied it above). 79 86 */ 80 if (f ilter->flag == 0) {87 if (f->flag == 0) { 81 88 sock = socket(PF_INET, SOCK_STREAM, 0); 82 89 memset(&ifr, 0, sizeof(struct ifreq)); … … 94 101 FORMAT_DATA->snaplen); 95 102 96 if (pcap_compile(pcap, &f ilter->filter, filter->filterstring, 0, 0) == -1) {103 if (pcap_compile(pcap, &f->filter, f->filterstring, 0, 0) == -1) { 97 104 /* Filter didn't compile, set flag to 0 so we can 98 105 * detect this when trace_start() is called and 99 106 * produce a useful error 100 107 */ 101 f ilter->flag = 0;108 f->flag = 0; 102 109 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, 103 110 "Failed to compile BPF filter (%s): %s", 104 f ilter->filterstring, pcap_geterr(pcap));111 f->filterstring, pcap_geterr(pcap)); 105 112 } else { 106 113 /* Set the "flag" to indicate that the filterstring 107 114 * has been compiled 108 115 */ 109 f ilter->flag = 1;116 f->flag = 1; 110 117 } 111 118 … … 113 120 114 121 } 122 123 if (FORMAT_DATA->filter != NULL) 124 trace_destroy_filter(FORMAT_DATA->filter); 115 125 116 126 FORMAT_DATA->filter = filter; … … 489 499 { 490 500 if (libtrace->format_data) { 501 if (FORMAT_DATA->filter != NULL) 502 trace_destroy_filter(FORMAT_DATA->filter); 491 503 492 504 if (FORMAT_DATA->per_stream) -
lib/format_linux_ring.c
r6327ce6 r8df87c4 307 307 } 308 308 } 309 310 if (FORMAT_DATA->filter != NULL) 311 trace_destroy_filter(FORMAT_DATA->filter); 309 312 310 313 if (FORMAT_DATA->per_stream)
Note: See TracChangeset
for help on using the changeset viewer.