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