Changeset 4007dbb for tools/tracestats
- Timestamp:
- 08/21/15 11:22:30 (6 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- eea427f
- Parents:
- 76291d1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/tracestats/tracestats_parallel.c
r76291d1 r4007dbb 145 145 146 146 147 static void* fn_starting(libtrace_t *trace UNUSED, libtrace_thread_t *t, 148 libtrace_generic_t data UNUSED, void *global UNUSED, void*tls UNUSED) { 147 static void* fn_starting(libtrace_t *trace UNUSED, libtrace_thread_t *t UNUSED, void *global UNUSED) { 149 148 /* Allocate space to hold a total count and one for each filter */ 150 statistics_t *results = calloc(1, sizeof(statistics_t) * (filter_count + 1)); 151 trace_set_tls(t, results); 152 return NULL; 153 } 154 155 156 static void* fn_stopping(libtrace_t *trace, libtrace_thread_t *t UNUSED, 157 libtrace_generic_t data UNUSED, void *global UNUSED, void*tls) { 149 return calloc(1, sizeof(statistics_t) * (filter_count + 1)); 150 } 151 152 153 static void fn_stopping(libtrace_t *trace, libtrace_thread_t *t UNUSED, 154 void *global UNUSED, void*tls) { 158 155 statistics_t *results = tls; 159 156 libtrace_generic_t gen; … … 162 159 gen.ptr = results; 163 160 trace_publish_result(trace, t, 0, gen, RESULT_USER); 164 return NULL; 165 } 166 167 static void* fn_packet(libtrace_t *trace, libtrace_thread_t *t UNUSED, 168 libtrace_generic_t data, void *global UNUSED, void*tls) { 161 } 162 163 static libtrace_packet_t* fn_packet(libtrace_t *trace, libtrace_thread_t *t UNUSED, 164 void *global UNUSED, void*tls, libtrace_packet_t *pkt) { 169 165 statistics_t *results = tls; 170 166 int i, wlen; 171 167 172 168 /* Apply filters to every packet note the result */ 173 wlen = trace_get_wire_length( data.pkt);169 wlen = trace_get_wire_length(pkt); 174 170 for(i=0;i<filter_count;++i) { 175 171 if (filters[i].filter == NULL) 176 172 continue; 177 if(trace_apply_filter(filters[i].filter, data.pkt) > 0) {173 if(trace_apply_filter(filters[i].filter,pkt) > 0) { 178 174 results[i+1].count++; 179 175 results[i+1].bytes+=wlen; … … 188 184 results[0].count++; 189 185 results[0].bytes +=wlen; 190 return data.pkt;186 return pkt; 191 187 } 192 188 … … 220 216 } 221 217 222 trace_ set_handler(trace, MESSAGE_PACKET, fn_packet);223 trace_ set_handler(trace, MESSAGE_STARTING, fn_starting);224 trace_ set_handler(trace, MESSAGE_STOPPING, fn_stopping);218 trace_cb_packet(trace, fn_packet); 219 trace_cb_starting(trace, fn_starting); 220 trace_cb_stopping(trace, fn_stopping); 225 221 226 222 /* Start the trace as a parallel trace */
Note: See TracChangeset
for help on using the changeset viewer.