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