1 | /* |
---|
2 | * |
---|
3 | * Copyright (c) 2007-2016 The University of Waikato, Hamilton, New Zealand. |
---|
4 | * All rights reserved. |
---|
5 | * |
---|
6 | * This file is part of libtrace. |
---|
7 | * |
---|
8 | * This code has been developed by the University of Waikato WAND |
---|
9 | * research group. For further information please see http://www.wand.net.nz/ |
---|
10 | * |
---|
11 | * libtrace is free software; you can redistribute it and/or modify |
---|
12 | * it under the terms of the GNU Lesser General Public License as published by |
---|
13 | * the Free Software Foundation; either version 3 of the License, or |
---|
14 | * (at your option) any later version. |
---|
15 | * |
---|
16 | * libtrace is distributed in the hope that it will be useful, |
---|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
19 | * GNU Lesser General Public License for more details. |
---|
20 | * |
---|
21 | * You should have received a copy of the GNU Lesser General Public License |
---|
22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
23 | * |
---|
24 | * |
---|
25 | */ |
---|
26 | #define _GNU_SOURCE |
---|
27 | |
---|
28 | #include "config.h" |
---|
29 | #include "common.h" |
---|
30 | #include "libtrace.h" |
---|
31 | #include "libtrace_int.h" |
---|
32 | #include "format_helper.h" |
---|
33 | #include "wandio.h" |
---|
34 | |
---|
35 | #include <sys/stat.h> |
---|
36 | #include <errno.h> |
---|
37 | #include <fcntl.h> |
---|
38 | #include <stdio.h> |
---|
39 | #include <string.h> |
---|
40 | #include <stdlib.h> |
---|
41 | #include <regex.h> |
---|
42 | |
---|
43 | #ifdef WIN32 |
---|
44 | # include <io.h> |
---|
45 | # include <share.h> |
---|
46 | #endif |
---|
47 | |
---|
48 | /* The format module deals with legacy DAG formats from older revisions of the |
---|
49 | * DAG hardware and software. Aside from a few minor differences, the legacy |
---|
50 | * formats are very similar so we can deal with them using the same callback |
---|
51 | * functions for the most part. |
---|
52 | * |
---|
53 | * These formats are intended for reading old ERF traces such as the earlier |
---|
54 | * Auckland traces. |
---|
55 | * |
---|
56 | * We definitely do not support writing using these formats - one should |
---|
57 | * convert packets to regular ERF instead before writing. |
---|
58 | */ |
---|
59 | |
---|
60 | /* Several formats are covered in this source file: |
---|
61 | * |
---|
62 | * Legacy Ethernet: as seen in Auckland VI |
---|
63 | * Legacy ATM: as seen in Auckland II and IV |
---|
64 | * Legacy PoS: as seen in Leipzig I and II |
---|
65 | * Legacy NZIX: as seen in NZIX I |
---|
66 | */ |
---|
67 | |
---|
68 | /* Catch undefined O_LARGEFILE on *BSD etc */ |
---|
69 | #ifndef O_LARGEFILE |
---|
70 | # define O_LARGEFILE 0 |
---|
71 | #endif |
---|
72 | |
---|
73 | #ifndef UINT32_MAX |
---|
74 | # define UINT32_MAX 0xffffffff |
---|
75 | #endif |
---|
76 | |
---|
77 | #define DATA(x) ((struct legacy_format_data_t *)x->format_data) |
---|
78 | |
---|
79 | /* Legacy NZIX timestamps are all relative to the start of the trace, so we |
---|
80 | * have to remember all sorts of stuff so that we can convert them into a |
---|
81 | * useful timestamp */ |
---|
82 | |
---|
83 | struct legacy_format_data_t { |
---|
84 | time_t starttime; /* Time that the trace file was started */ |
---|
85 | uint64_t ts_high; /* The timestamp of the last packet */ |
---|
86 | uint32_t ts_old; /* The timestamp of the last packet as |
---|
87 | reported in the NZIX header */ |
---|
88 | }; |
---|
89 | |
---|
90 | static void legacy_init_format_data(libtrace_t *libtrace) { |
---|
91 | libtrace->format_data = malloc(sizeof(struct legacy_format_data_t)); |
---|
92 | |
---|
93 | DATA(libtrace)->ts_high = 0; |
---|
94 | DATA(libtrace)->ts_old = 0; |
---|
95 | DATA(libtrace)->starttime = 0; |
---|
96 | } |
---|
97 | |
---|
98 | static int legacyeth_get_framing_length(const libtrace_packet_t *packet UNUSED) |
---|
99 | { |
---|
100 | return sizeof(legacy_ether_t); |
---|
101 | } |
---|
102 | |
---|
103 | static int legacypos_get_framing_length(const libtrace_packet_t *packet UNUSED) |
---|
104 | { |
---|
105 | return sizeof(legacy_pos_t); |
---|
106 | } |
---|
107 | |
---|
108 | static int legacyatm_get_framing_length(const libtrace_packet_t *packet UNUSED) |
---|
109 | { |
---|
110 | return sizeof(legacy_cell_t); |
---|
111 | } |
---|
112 | |
---|
113 | static int legacynzix_get_framing_length(const libtrace_packet_t *packet UNUSED) |
---|
114 | { |
---|
115 | return sizeof(legacy_nzix_t); |
---|
116 | } |
---|
117 | |
---|
118 | static int erf_init_input(libtrace_t *libtrace) |
---|
119 | { |
---|
120 | legacy_init_format_data(libtrace); |
---|
121 | |
---|
122 | return 0; |
---|
123 | } |
---|
124 | |
---|
125 | /* Takes a trace file name and determines the time that the capture began. |
---|
126 | * |
---|
127 | * NZIX only features relative timestamps so the trace file name is the only |
---|
128 | * indication we have of where the relative timestamping begins from |
---|
129 | */ |
---|
130 | static time_t trtime(char *s) { |
---|
131 | /* XXX: this function may not be particularly portable to |
---|
132 | * other platforms, e.g. *BSDs, Windows */ |
---|
133 | struct tm tm; |
---|
134 | time_t ret; |
---|
135 | |
---|
136 | if(sscanf(s, "%4u%2u%2u-%2u%2u%2u", &tm.tm_year, &tm.tm_mon, |
---|
137 | &tm.tm_mday, &tm.tm_hour, &tm.tm_min, |
---|
138 | &tm.tm_sec) != 6) { |
---|
139 | return (time_t)0; |
---|
140 | } |
---|
141 | tm.tm_year = tm.tm_year - 1900; |
---|
142 | tm.tm_mon --; |
---|
143 | tm.tm_wday = 0; /* ignored */ |
---|
144 | tm.tm_yday = 0; /* ignored */ |
---|
145 | tm.tm_isdst = -1; /* forces check for summer time */ |
---|
146 | |
---|
147 | /* |
---|
148 | if (getenv("TZ") == NULL) { |
---|
149 | fprintf(stderr, "Failed to get the current TZ"); |
---|
150 | return (time_t)0; |
---|
151 | } |
---|
152 | */ |
---|
153 | if (putenv("TZ=Pacific/Auckland")) { |
---|
154 | perror("putenv"); |
---|
155 | return (time_t)0; |
---|
156 | } |
---|
157 | tzset(); |
---|
158 | ret = mktime(&tm); |
---|
159 | |
---|
160 | return ret; |
---|
161 | } |
---|
162 | |
---|
163 | |
---|
164 | static int legacynzix_init_input(libtrace_t *libtrace) { |
---|
165 | |
---|
166 | int retval; |
---|
167 | char *filename = libtrace->uridata; |
---|
168 | regex_t reg; |
---|
169 | regmatch_t match; |
---|
170 | |
---|
171 | |
---|
172 | legacy_init_format_data(libtrace); |
---|
173 | |
---|
174 | /* Check that the filename appears to contain a suitable timestamp. |
---|
175 | * Without it, we have no way of determining the actual timestamps |
---|
176 | * for each packet */ |
---|
177 | if((retval = regcomp(®, "[0-9]{8}-[0-9]{6}", REG_EXTENDED)) != 0) { |
---|
178 | trace_set_err(libtrace, errno, "Failed to compile regex"); |
---|
179 | return -1; |
---|
180 | } |
---|
181 | if ((retval = regexec(®, filename, 1, &match, 0)) !=0) { |
---|
182 | trace_set_err(libtrace, errno, "Failed to exec regex"); |
---|
183 | return -1; |
---|
184 | } |
---|
185 | DATA(libtrace)->starttime = trtime(&filename[match.rm_so]); |
---|
186 | return 0; |
---|
187 | } |
---|
188 | |
---|
189 | /* All of the formats can be started in exactly the same way */ |
---|
190 | static int erf_start_input(libtrace_t *libtrace) |
---|
191 | { |
---|
192 | if (libtrace->io) |
---|
193 | return 0; /* Already open */ |
---|
194 | |
---|
195 | libtrace->io = trace_open_file(libtrace); |
---|
196 | |
---|
197 | if (libtrace->io) |
---|
198 | return 0; |
---|
199 | |
---|
200 | return -1; |
---|
201 | } |
---|
202 | |
---|
203 | static int erf_fin_input(libtrace_t *libtrace) { |
---|
204 | wandio_destroy(libtrace->io); |
---|
205 | free(libtrace->format_data); |
---|
206 | return 0; |
---|
207 | } |
---|
208 | |
---|
209 | static int legacy_prepare_packet(libtrace_t *libtrace, |
---|
210 | libtrace_packet_t *packet, void *buffer, |
---|
211 | libtrace_rt_types_t rt_type, uint32_t flags) { |
---|
212 | |
---|
213 | if (packet->buffer != buffer && |
---|
214 | packet->buf_control == TRACE_CTRL_PACKET) { |
---|
215 | free(packet->buffer); |
---|
216 | } |
---|
217 | |
---|
218 | if ((flags & TRACE_PREP_OWN_BUFFER) == TRACE_PREP_OWN_BUFFER) { |
---|
219 | packet->buf_control = TRACE_CTRL_PACKET; |
---|
220 | } else |
---|
221 | packet->buf_control = TRACE_CTRL_EXTERNAL; |
---|
222 | |
---|
223 | |
---|
224 | packet->buffer = buffer; |
---|
225 | packet->header = buffer; |
---|
226 | packet->type = rt_type; |
---|
227 | packet->payload = (void*)((char*)packet->buffer + |
---|
228 | libtrace->format->get_framing_length(packet)); |
---|
229 | |
---|
230 | |
---|
231 | if (libtrace->format_data == NULL) { |
---|
232 | legacy_init_format_data(libtrace); |
---|
233 | } |
---|
234 | return 0; |
---|
235 | } |
---|
236 | |
---|
237 | static int legacy_read_packet(libtrace_t *libtrace, libtrace_packet_t *packet) { |
---|
238 | int numbytes; |
---|
239 | void *buffer; |
---|
240 | uint32_t flags = 0; |
---|
241 | |
---|
242 | if (!packet->buffer || packet->buf_control == TRACE_CTRL_EXTERNAL) { |
---|
243 | packet->buffer=malloc((size_t)LIBTRACE_PACKET_BUFSIZE); |
---|
244 | } |
---|
245 | flags |= TRACE_PREP_OWN_BUFFER; |
---|
246 | buffer = packet->buffer; |
---|
247 | |
---|
248 | switch(libtrace->format->type) { |
---|
249 | case TRACE_FORMAT_LEGACY_ATM: |
---|
250 | packet->type = TRACE_RT_DATA_LEGACY_ATM; |
---|
251 | break; |
---|
252 | case TRACE_FORMAT_LEGACY_POS: |
---|
253 | packet->type = TRACE_RT_DATA_LEGACY_POS; |
---|
254 | break; |
---|
255 | case TRACE_FORMAT_LEGACY_ETH: |
---|
256 | packet->type = TRACE_RT_DATA_LEGACY_ETH; |
---|
257 | break; |
---|
258 | default: |
---|
259 | trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT, "Invalid trace format type in legacy_read_packet()"); |
---|
260 | return -1; |
---|
261 | } |
---|
262 | |
---|
263 | /* This is going to block until we either get an entire record |
---|
264 | * or we reach the end of the file */ |
---|
265 | while (1) { |
---|
266 | |
---|
267 | if ((numbytes=wandio_read(libtrace->io, |
---|
268 | buffer, |
---|
269 | (size_t)64)) != 64) { |
---|
270 | if (numbytes < 0) { |
---|
271 | trace_set_err(libtrace,TRACE_ERR_WANDIO_FAILED,"read(%s)",libtrace->uridata); |
---|
272 | } else if (numbytes > 0) { |
---|
273 | |
---|
274 | continue; |
---|
275 | } |
---|
276 | return numbytes; |
---|
277 | } |
---|
278 | break; |
---|
279 | } |
---|
280 | |
---|
281 | if (legacy_prepare_packet(libtrace, packet, packet->buffer, |
---|
282 | packet->type, flags)) { |
---|
283 | return -1; |
---|
284 | } |
---|
285 | |
---|
286 | return 64; |
---|
287 | |
---|
288 | } |
---|
289 | |
---|
290 | static int legacynzix_read_packet(libtrace_t *libtrace, libtrace_packet_t *packet) { |
---|
291 | /* Firstly, I apologize for all the constants being thrown around in |
---|
292 | * this function, but it does befit the hackish origins of the |
---|
293 | * NZIX format that I use them. Anyone who wants to clean them up is |
---|
294 | * welcome to do so */ |
---|
295 | int numbytes; |
---|
296 | void *buffer; |
---|
297 | char *data_ptr; |
---|
298 | uint32_t flags = 0; |
---|
299 | |
---|
300 | if (!packet->buffer || packet->buf_control == TRACE_CTRL_EXTERNAL) { |
---|
301 | packet->buffer=malloc((size_t)LIBTRACE_PACKET_BUFSIZE); |
---|
302 | } |
---|
303 | flags |= TRACE_PREP_OWN_BUFFER; |
---|
304 | |
---|
305 | buffer = packet->buffer; |
---|
306 | packet->type = TRACE_RT_DATA_LEGACY_NZIX; |
---|
307 | |
---|
308 | while (1) { |
---|
309 | if ((numbytes = wandio_read(libtrace->io, buffer, |
---|
310 | (size_t)68)) != 68) { |
---|
311 | if (numbytes < 0) { |
---|
312 | trace_set_err(libtrace,TRACE_ERR_WANDIO_FAILED,"read(%s)",libtrace->uridata); |
---|
313 | } else if (numbytes > 0) |
---|
314 | continue; |
---|
315 | return numbytes; |
---|
316 | } |
---|
317 | /* Packets with a zero length are GPS timestamp packets |
---|
318 | * but they aren't inserted at the right time to be |
---|
319 | * useful - instead we'll ignore them unless we can think |
---|
320 | * of a compelling reason to do otherwise */ |
---|
321 | if (((legacy_nzix_t *)buffer)->len == 0) |
---|
322 | continue; |
---|
323 | |
---|
324 | break; |
---|
325 | } |
---|
326 | |
---|
327 | /* Lets move the padding so that it's in the framing header */ |
---|
328 | data_ptr = ((char *)buffer) + 12; |
---|
329 | memmove(data_ptr + 2, data_ptr, 26); |
---|
330 | |
---|
331 | if (legacy_prepare_packet(libtrace, packet, packet->buffer, |
---|
332 | packet->type, flags)) { |
---|
333 | return -1; |
---|
334 | } |
---|
335 | return 68; |
---|
336 | } |
---|
337 | |
---|
338 | |
---|
339 | static libtrace_linktype_t legacypos_get_link_type( |
---|
340 | const libtrace_packet_t *packet) { |
---|
341 | /* POS can be PPP over HDLC (DLT_PPP_SERIAL), or it can be |
---|
342 | * just straight PPP. Sigh. |
---|
343 | * |
---|
344 | * Ref: RFC 1549 |
---|
345 | * - Perry Lorier (2008-11-04) |
---|
346 | */ |
---|
347 | |
---|
348 | /* It can also be CHDLC, which is different again */ |
---|
349 | |
---|
350 | /* This check matchs PPP over HDLC, a la RFC 1662 */ |
---|
351 | if (((char *)packet->payload)[0] == '\xFF' |
---|
352 | && ((char*)packet->payload)[1] == '\x03') |
---|
353 | return TRACE_TYPE_POS; |
---|
354 | |
---|
355 | /* This check matches unicast CHDLC */ |
---|
356 | else if (((char *)packet->payload)[0] == '\x0F' && |
---|
357 | ((char*)packet->payload)[1] == '\x00') |
---|
358 | return TRACE_TYPE_HDLC_POS; |
---|
359 | |
---|
360 | /* This check matches broadcast CHDLC */ |
---|
361 | else if (((char *)packet->payload)[0] == '\x8F' && |
---|
362 | ((char*)packet->payload)[1] == '\x00') |
---|
363 | return TRACE_TYPE_HDLC_POS; |
---|
364 | |
---|
365 | /* Otherwise just assume raw PPP (?) */ |
---|
366 | else |
---|
367 | return TRACE_TYPE_PPP; |
---|
368 | } |
---|
369 | |
---|
370 | static libtrace_linktype_t legacyatm_get_link_type( |
---|
371 | const libtrace_packet_t *packet UNUSED) { |
---|
372 | return TRACE_TYPE_ATM; |
---|
373 | } |
---|
374 | |
---|
375 | static libtrace_linktype_t legacyeth_get_link_type(const libtrace_packet_t *packet UNUSED) { |
---|
376 | return TRACE_TYPE_ETH; |
---|
377 | } |
---|
378 | |
---|
379 | static libtrace_linktype_t legacynzix_get_link_type(const libtrace_packet_t *packet UNUSED) { |
---|
380 | return TRACE_TYPE_ETH; |
---|
381 | } |
---|
382 | |
---|
383 | static int legacy_get_capture_length(const libtrace_packet_t *packet UNUSED) { |
---|
384 | return 64; |
---|
385 | } |
---|
386 | |
---|
387 | static int legacynzix_get_capture_length(const libtrace_packet_t *packet UNUSED) |
---|
388 | { |
---|
389 | return 54; |
---|
390 | } |
---|
391 | |
---|
392 | static int legacypos_get_wire_length(const libtrace_packet_t *packet) { |
---|
393 | legacy_pos_t *lpos = (legacy_pos_t *)packet->header; |
---|
394 | |
---|
395 | if (ntohl(lpos->wlen) <= 0) { |
---|
396 | trace_set_err(packet->trace, TRACE_ERR_BAD_PACKET, "Packet wire length is invalid (%d) " |
---|
397 | "in legacypos_get_wire_length()", ntohl(lpos->wlen)); |
---|
398 | return -1; |
---|
399 | } |
---|
400 | return ntohl(lpos->wlen); |
---|
401 | } |
---|
402 | |
---|
403 | static int legacyatm_get_wire_length(const libtrace_packet_t *packet UNUSED) { |
---|
404 | return 53; |
---|
405 | } |
---|
406 | |
---|
407 | static int legacyeth_get_wire_length(const libtrace_packet_t *packet) { |
---|
408 | legacy_ether_t *leth = (legacy_ether_t *)packet->header; |
---|
409 | return leth->wlen+4; /* +4 for FCS, wirelen is in little endian sigh. */ |
---|
410 | } |
---|
411 | |
---|
412 | static int legacynzix_get_wire_length(const libtrace_packet_t *packet) { |
---|
413 | legacy_nzix_t *lnzix = (legacy_nzix_t *)packet->header; |
---|
414 | return lnzix->len; |
---|
415 | } |
---|
416 | |
---|
417 | static uint64_t legacy_get_erf_timestamp(const libtrace_packet_t *packet) |
---|
418 | { |
---|
419 | legacy_ether_t *legacy = (legacy_ether_t*)packet->header; |
---|
420 | return bswap_le_to_host64(legacy->ts); |
---|
421 | } |
---|
422 | |
---|
423 | static uint32_t ts_cmp(uint32_t ts_a, uint32_t ts_b) { |
---|
424 | |
---|
425 | /* each ts is actually a 30 bit value */ |
---|
426 | ts_a <<= 2; |
---|
427 | ts_b <<= 2; |
---|
428 | |
---|
429 | |
---|
430 | if (ts_a > ts_b) |
---|
431 | return (ts_a - ts_b); |
---|
432 | else |
---|
433 | return (ts_b - ts_a); |
---|
434 | |
---|
435 | } |
---|
436 | |
---|
437 | static struct timeval legacynzix_get_timeval(const libtrace_packet_t *packet) { |
---|
438 | uint64_t new_ts = DATA(packet->trace)->ts_high; |
---|
439 | uint32_t old_ts = DATA(packet->trace)->ts_old; |
---|
440 | struct timeval tv; |
---|
441 | uint32_t hdr_ts; |
---|
442 | |
---|
443 | legacy_nzix_t *legacy = (legacy_nzix_t *)packet->header; |
---|
444 | |
---|
445 | hdr_ts = legacy->ts; |
---|
446 | |
---|
447 | /* Seems we only need 30 bits to represent our timestamp */ |
---|
448 | hdr_ts >>=2; |
---|
449 | |
---|
450 | /* Try a sequence number wrap-around comparison */ |
---|
451 | if (ts_cmp(hdr_ts, old_ts) > (UINT32_MAX / 2) ) |
---|
452 | new_ts += (1LL << 30); /* Wraparound */ |
---|
453 | new_ts &= ~((1LL << 30) -1); /* Mask lower 30 bits */ |
---|
454 | new_ts += hdr_ts; /* Packet ts is the new 30 bits */ |
---|
455 | DATA(packet->trace)->ts_old = hdr_ts; |
---|
456 | |
---|
457 | tv.tv_sec = DATA(packet->trace)->starttime + (new_ts / (1000 * 1000)); |
---|
458 | tv.tv_usec = new_ts % (1000 * 1000); |
---|
459 | DATA(packet->trace)->ts_high = new_ts; |
---|
460 | |
---|
461 | |
---|
462 | /*dts = tv.tv_sec + (double)tv.tv_usec / 1000 / 1000; */ |
---|
463 | return tv; |
---|
464 | |
---|
465 | } |
---|
466 | |
---|
467 | static void legacypos_help(void) { |
---|
468 | printf("legacypos format module: $Revision: 1753 $\n"); |
---|
469 | printf("Supported input URIs:\n"); |
---|
470 | printf("\tlegacypos:/path/to/file\t(uncompressed)\n"); |
---|
471 | printf("\tlegacypos:/path/to/file.gz\t(gzip-compressed)\n"); |
---|
472 | printf("\tlegacypos:-\t(stdin, either compressed or not)\n"); |
---|
473 | printf("\n"); |
---|
474 | printf("\te.g.: legacypos:/tmp/trace.gz\n"); |
---|
475 | printf("\n"); |
---|
476 | } |
---|
477 | |
---|
478 | static void legacyatm_help(void) { |
---|
479 | printf("legacyatm format module: $Revision: 1753 $\n"); |
---|
480 | printf("Supported input URIs:\n"); |
---|
481 | printf("\tlegacyatm:/path/to/file\t(uncompressed)\n"); |
---|
482 | printf("\tlegacyatm:/path/to/file.gz\t(gzip-compressed)\n"); |
---|
483 | printf("\tlegacyatm:-\t(stdin, either compressed or not)\n"); |
---|
484 | printf("\n"); |
---|
485 | printf("\te.g.: legacyatm:/tmp/trace.gz\n"); |
---|
486 | printf("\n"); |
---|
487 | } |
---|
488 | |
---|
489 | static void legacyeth_help(void) { |
---|
490 | printf("legacyeth format module: $Revision: 1753 $\n"); |
---|
491 | printf("Supported input URIs:\n"); |
---|
492 | printf("\tlegacyeth:/path/to/file\t(uncompressed)\n"); |
---|
493 | printf("\tlegacyeth:/path/to/file.gz\t(gzip-compressed)\n"); |
---|
494 | printf("\tlegacyeth:-\t(stdin, either compressed or not)\n"); |
---|
495 | printf("\n"); |
---|
496 | printf("\te.g.: legacyeth:/tmp/trace.gz\n"); |
---|
497 | printf("\n"); |
---|
498 | } |
---|
499 | |
---|
500 | static void legacynzix_help(void) { |
---|
501 | printf("legacynzix format module: $Revision: 1753 $\n"); |
---|
502 | printf("Supported input URIs:\n"); |
---|
503 | printf("\tlegacynzix:/path/to/file\t(uncompressed)\n"); |
---|
504 | printf("\tlegacynzix:/path/to/file.gz\t(gzip-compressed)\n"); |
---|
505 | printf("\tlegacynzix:-\t(stdin, either compressed or not)\n"); |
---|
506 | printf("\n"); |
---|
507 | printf("\te.g.: legacynzix:/tmp/trace.gz\n"); |
---|
508 | printf("\n"); |
---|
509 | } |
---|
510 | |
---|
511 | static struct libtrace_format_t legacyatm = { |
---|
512 | "legacyatm", |
---|
513 | "$Id$", |
---|
514 | TRACE_FORMAT_LEGACY_ATM, |
---|
515 | NULL, /* probe filename */ |
---|
516 | NULL, /* probe magic */ |
---|
517 | erf_init_input, /* init_input */ |
---|
518 | NULL, /* config_input */ |
---|
519 | erf_start_input, /* start_input */ |
---|
520 | NULL, /* pause_input */ |
---|
521 | NULL, /* init_output */ |
---|
522 | NULL, /* config_output */ |
---|
523 | NULL, /* start_output */ |
---|
524 | erf_fin_input, /* fin_input */ |
---|
525 | NULL, /* fin_output */ |
---|
526 | legacy_read_packet, /* read_packet */ |
---|
527 | legacy_prepare_packet, /* prepare_packet */ |
---|
528 | NULL, /* fin_packet */ |
---|
529 | NULL, /* write_packet */ |
---|
530 | NULL, /* flush_output */ |
---|
531 | legacyatm_get_link_type, /* get_link_type */ |
---|
532 | NULL, /* get_direction */ |
---|
533 | NULL, /* set_direction */ |
---|
534 | legacy_get_erf_timestamp, /* get_erf_timestamp */ |
---|
535 | NULL, /* get_timeval */ |
---|
536 | NULL, /* get_timespec */ |
---|
537 | NULL, /* get_seconds */ |
---|
538 | NULL, /* get_meta_data */ |
---|
539 | NULL, /* seek_erf */ |
---|
540 | NULL, /* seek_timeval */ |
---|
541 | NULL, /* seek_seconds */ |
---|
542 | legacy_get_capture_length, /* get_capture_length */ |
---|
543 | legacyatm_get_wire_length, /* get_wire_length */ |
---|
544 | legacyatm_get_framing_length, /* get_framing_length */ |
---|
545 | NULL, /* set_capture_length */ |
---|
546 | NULL, /* get_received_packets */ |
---|
547 | NULL, /* get_filtered_packets */ |
---|
548 | NULL, /* get_dropped_packets */ |
---|
549 | NULL, /* get_statistics */ |
---|
550 | NULL, /* get_fd */ |
---|
551 | trace_event_trace, /* trace_event */ |
---|
552 | legacyatm_help, /* help */ |
---|
553 | NULL, /* next pointer */ |
---|
554 | NON_PARALLEL(false) |
---|
555 | }; |
---|
556 | |
---|
557 | static struct libtrace_format_t legacyeth = { |
---|
558 | "legacyeth", |
---|
559 | "$Id$", |
---|
560 | TRACE_FORMAT_LEGACY_ETH, |
---|
561 | NULL, /* probe filename */ |
---|
562 | NULL, /* probe magic */ |
---|
563 | erf_init_input, /* init_input */ |
---|
564 | NULL, /* config_input */ |
---|
565 | erf_start_input, /* start_input */ |
---|
566 | NULL, /* pause_input */ |
---|
567 | NULL, /* init_output */ |
---|
568 | NULL, /* config_output */ |
---|
569 | NULL, /* start_output */ |
---|
570 | erf_fin_input, /* fin_input */ |
---|
571 | NULL, /* fin_output */ |
---|
572 | legacy_read_packet, /* read_packet */ |
---|
573 | legacy_prepare_packet, /* prepare_packet */ |
---|
574 | NULL, /* fin_packet */ |
---|
575 | NULL, /* write_packet */ |
---|
576 | NULL, /* flush_output */ |
---|
577 | legacyeth_get_link_type, /* get_link_type */ |
---|
578 | NULL, /* get_direction */ |
---|
579 | NULL, /* set_direction */ |
---|
580 | legacy_get_erf_timestamp, /* get_erf_timestamp */ |
---|
581 | NULL, /* get_timeval */ |
---|
582 | NULL, /* get_timespec */ |
---|
583 | NULL, /* get_seconds */ |
---|
584 | NULL, /* get_meta_data */ |
---|
585 | NULL, /* seek_erf */ |
---|
586 | NULL, /* seek_timeval */ |
---|
587 | NULL, /* seek_seconds */ |
---|
588 | legacy_get_capture_length, /* get_capture_length */ |
---|
589 | legacyeth_get_wire_length, /* get_wire_length */ |
---|
590 | legacyeth_get_framing_length, /* get_framing_length */ |
---|
591 | NULL, /* set_capture_length */ |
---|
592 | NULL, /* get_received_packets */ |
---|
593 | NULL, /* get_filtered_packets */ |
---|
594 | NULL, /* get_dropped_packets */ |
---|
595 | NULL, /* get_statistics */ |
---|
596 | NULL, /* get_fd */ |
---|
597 | trace_event_trace, /* trace_event */ |
---|
598 | legacyeth_help, /* help */ |
---|
599 | NULL, /* next pointer */ |
---|
600 | NON_PARALLEL(false) |
---|
601 | }; |
---|
602 | |
---|
603 | static struct libtrace_format_t legacypos = { |
---|
604 | "legacypos", |
---|
605 | "$Id$", |
---|
606 | TRACE_FORMAT_LEGACY_POS, |
---|
607 | NULL, /* probe filename */ |
---|
608 | NULL, /* probe magic */ |
---|
609 | erf_init_input, /* init_input */ |
---|
610 | NULL, /* config_input */ |
---|
611 | erf_start_input, /* start_input */ |
---|
612 | NULL, /* pause_input */ |
---|
613 | NULL, /* init_output */ |
---|
614 | NULL, /* config_output */ |
---|
615 | NULL, /* start_output */ |
---|
616 | erf_fin_input, /* fin_input */ |
---|
617 | NULL, /* fin_output */ |
---|
618 | legacy_read_packet, /* read_packet */ |
---|
619 | legacy_prepare_packet, /* prepare_packet */ |
---|
620 | NULL, /* fin_packet */ |
---|
621 | NULL, /* write_packet */ |
---|
622 | NULL, /* flush_output */ |
---|
623 | legacypos_get_link_type, /* get_link_type */ |
---|
624 | NULL, /* get_direction */ |
---|
625 | NULL, /* set_direction */ |
---|
626 | legacy_get_erf_timestamp, /* get_erf_timestamp */ |
---|
627 | NULL, /* get_timeval */ |
---|
628 | NULL, /* get_timespec */ |
---|
629 | NULL, /* get_seconds */ |
---|
630 | NULL, /* get_meta_data */ |
---|
631 | NULL, /* seek_erf */ |
---|
632 | NULL, /* seek_timeval */ |
---|
633 | NULL, /* seek_seconds */ |
---|
634 | legacy_get_capture_length, /* get_capture_length */ |
---|
635 | legacypos_get_wire_length, /* get_wire_length */ |
---|
636 | legacypos_get_framing_length, /* get_framing_length */ |
---|
637 | NULL, /* set_capture_length */ |
---|
638 | NULL, /* get_received_packets */ |
---|
639 | NULL, /* get_filtered_packets */ |
---|
640 | NULL, /* get_dropped_packets */ |
---|
641 | NULL, /* get_statistics */ |
---|
642 | NULL, /* get_fd */ |
---|
643 | trace_event_trace, /* trace_event */ |
---|
644 | legacypos_help, /* help */ |
---|
645 | NULL, /* next pointer */ |
---|
646 | NON_PARALLEL(false) |
---|
647 | }; |
---|
648 | |
---|
649 | static struct libtrace_format_t legacynzix = { |
---|
650 | "legacynzix", |
---|
651 | "$Id$", |
---|
652 | TRACE_FORMAT_LEGACY_NZIX, |
---|
653 | NULL, /* probe filename */ |
---|
654 | NULL, /* probe magic */ |
---|
655 | legacynzix_init_input, /* init_input */ |
---|
656 | NULL, /* config_input */ |
---|
657 | erf_start_input, /* start_input */ |
---|
658 | NULL, /* pause_input */ |
---|
659 | NULL, /* init_output */ |
---|
660 | NULL, /* config_output */ |
---|
661 | NULL, /* start_output */ |
---|
662 | erf_fin_input, /* fin_input */ |
---|
663 | NULL, /* fin_output */ |
---|
664 | legacynzix_read_packet, /* read_packet */ |
---|
665 | legacy_prepare_packet, /* prepare_packet */ |
---|
666 | NULL, /* fin_packet */ |
---|
667 | NULL, /* write_packet */ |
---|
668 | NULL, /* flush_output */ |
---|
669 | legacynzix_get_link_type, /* get_link_type */ |
---|
670 | NULL, /* get_direction */ |
---|
671 | NULL, /* set_direction */ |
---|
672 | NULL, /* get_erf_timestamp */ |
---|
673 | legacynzix_get_timeval, /* get_timeval */ |
---|
674 | NULL, /* get_timespec */ |
---|
675 | NULL, /* get_seconds */ |
---|
676 | NULL, /* get_meta_data */ |
---|
677 | NULL, /* seek_erf */ |
---|
678 | NULL, /* seek_timeval */ |
---|
679 | NULL, /* seek_seconds */ |
---|
680 | legacynzix_get_capture_length, /* get_capture_length */ |
---|
681 | legacynzix_get_wire_length, /* get_wire_length */ |
---|
682 | legacynzix_get_framing_length, /* get_framing_length */ |
---|
683 | NULL, /* set_capture_length */ |
---|
684 | NULL, /* get_received_packets */ |
---|
685 | NULL, /* get_filtered_packets */ |
---|
686 | NULL, /* get_dropped_packets */ |
---|
687 | NULL, /* get_statistics */ |
---|
688 | NULL, /* get_fd */ |
---|
689 | trace_event_trace, /* trace_event */ |
---|
690 | legacynzix_help, /* help */ |
---|
691 | NULL, /* next pointer */ |
---|
692 | NON_PARALLEL(false) |
---|
693 | }; |
---|
694 | |
---|
695 | void legacy_constructor(void) { |
---|
696 | register_format(&legacypos); |
---|
697 | register_format(&legacyeth); |
---|
698 | register_format(&legacyatm); |
---|
699 | register_format(&legacynzix); |
---|
700 | } |
---|