| 1 | /* |
|---|
| 2 | * This file is part of libtrace |
|---|
| 3 | * |
|---|
| 4 | * Copyright (c) 2004 The University of Waikato, Hamilton, New Zealand. |
|---|
| 5 | * Authors: Daniel Lawson |
|---|
| 6 | * Perry Lorier |
|---|
| 7 | * |
|---|
| 8 | * All rights reserved. |
|---|
| 9 | * |
|---|
| 10 | * This code has been developed by the University of Waikato WAND |
|---|
| 11 | * research group. For further information please see http://www.wand.net.nz/ |
|---|
| 12 | * |
|---|
| 13 | * libtrace is free software; you can redistribute it and/or modify |
|---|
| 14 | * it under the terms of the GNU General Public License as published by |
|---|
| 15 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 16 | * (at your option) any later version. |
|---|
| 17 | * |
|---|
| 18 | * libtrace is distributed in the hope that it will be useful, |
|---|
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 21 | * GNU General Public License for more details. |
|---|
| 22 | * |
|---|
| 23 | * You should have received a copy of the GNU General Public License |
|---|
| 24 | * along with libtrace; if not, write to the Free Software |
|---|
| 25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 26 | * |
|---|
| 27 | * $Id$ |
|---|
| 28 | * |
|---|
| 29 | */ |
|---|
| 30 | |
|---|
| 31 | #define _GNU_SOURCE |
|---|
| 32 | #include "config.h" |
|---|
| 33 | #include "common.h" |
|---|
| 34 | #include "libtrace.h" |
|---|
| 35 | #include "libtrace_int.h" |
|---|
| 36 | #include "format_helper.h" |
|---|
| 37 | #include "wag.h" |
|---|
| 38 | |
|---|
| 39 | #include <sys/stat.h> |
|---|
| 40 | #include <fcntl.h> |
|---|
| 41 | #include <assert.h> |
|---|
| 42 | #include <errno.h> |
|---|
| 43 | #include <stdio.h> |
|---|
| 44 | #include <string.h> |
|---|
| 45 | #include <stdlib.h> |
|---|
| 46 | |
|---|
| 47 | #ifdef HAVE_LIMITS_H |
|---|
| 48 | # include <limits.h> |
|---|
| 49 | #endif |
|---|
| 50 | |
|---|
| 51 | #ifdef HAVE_SYS_LIMITS_H |
|---|
| 52 | # include <sys/limits.h> |
|---|
| 53 | #endif |
|---|
| 54 | |
|---|
| 55 | #ifdef WIN32 |
|---|
| 56 | # include <io.h> |
|---|
| 57 | # include <share.h> |
|---|
| 58 | #endif |
|---|
| 59 | |
|---|
| 60 | static struct libtrace_format_t wag; |
|---|
| 61 | static struct libtrace_format_t wag_trace; |
|---|
| 62 | |
|---|
| 63 | #define DATA(x) ((struct wag_format_data_t *)x->format_data) |
|---|
| 64 | #define DATAOUT(x) ((struct wag_format_data_out_t *)x->format_data) |
|---|
| 65 | |
|---|
| 66 | #define INPUT DATA(libtrace)->input |
|---|
| 67 | #define OUTPUT DATAOUT(libtrace)->output |
|---|
| 68 | #define OPTIONS DATAOUT(libtrace)->options |
|---|
| 69 | |
|---|
| 70 | struct wag_format_data_t { |
|---|
| 71 | /** Information about the current state of the input device */ |
|---|
| 72 | union { |
|---|
| 73 | int fd; |
|---|
| 74 | libtrace_io_t *file; |
|---|
| 75 | } input; |
|---|
| 76 | }; |
|---|
| 77 | |
|---|
| 78 | struct wag_format_data_out_t { |
|---|
| 79 | union { |
|---|
| 80 | struct { |
|---|
| 81 | int level; |
|---|
| 82 | int filemode; |
|---|
| 83 | } zlib; |
|---|
| 84 | } options; |
|---|
| 85 | union { |
|---|
| 86 | int fd; |
|---|
| 87 | libtrace_io_t *file; |
|---|
| 88 | } output; |
|---|
| 89 | }; |
|---|
| 90 | |
|---|
| 91 | static int wag_init_input(libtrace_t *libtrace) { |
|---|
| 92 | libtrace->format_data = calloc(1, sizeof(struct wag_format_data_t)); |
|---|
| 93 | |
|---|
| 94 | return 0; |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | static int wag_start_input(libtrace_t *libtrace) |
|---|
| 98 | { |
|---|
| 99 | struct stat buf; |
|---|
| 100 | if (stat(libtrace->uridata,&buf) == -1 ) { |
|---|
| 101 | trace_set_err(libtrace,errno,"stat(%s)",libtrace->uridata); |
|---|
| 102 | return -1; |
|---|
| 103 | } |
|---|
| 104 | #ifndef WIN32 |
|---|
| 105 | if (S_ISCHR(buf.st_mode)) { |
|---|
| 106 | INPUT.fd = open(libtrace->uridata, O_RDONLY); |
|---|
| 107 | return 0; |
|---|
| 108 | } |
|---|
| 109 | #endif |
|---|
| 110 | trace_set_err(libtrace,TRACE_ERR_INIT_FAILED, |
|---|
| 111 | "%s is not a valid char device", |
|---|
| 112 | libtrace->uridata); |
|---|
| 113 | return -1; |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | static int wtf_init_input(struct libtrace_t *libtrace) |
|---|
| 117 | { |
|---|
| 118 | libtrace->format_data = malloc(sizeof(struct wag_format_data_t)); |
|---|
| 119 | return 0; |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | static int wtf_start_input(libtrace_t *libtrace) |
|---|
| 123 | { |
|---|
| 124 | if (DATA(libtrace)->input.file) |
|---|
| 125 | return 0; /* success */ |
|---|
| 126 | DATA(libtrace)->input.file = trace_open_file(libtrace); |
|---|
| 127 | |
|---|
| 128 | if (!DATA(libtrace)->input.file) |
|---|
| 129 | return -1; |
|---|
| 130 | |
|---|
| 131 | return 0; /* success */ |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | static int wtf_init_output(struct libtrace_out_t *libtrace) { |
|---|
| 135 | libtrace->format_data = calloc(1,sizeof(struct wag_format_data_out_t)); |
|---|
| 136 | |
|---|
| 137 | OUTPUT.file = 0; |
|---|
| 138 | OPTIONS.zlib.level = 0; |
|---|
| 139 | OPTIONS.zlib.filemode = O_CREAT | O_WRONLY; |
|---|
| 140 | |
|---|
| 141 | return 0; |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | static int wtf_start_output(libtrace_out_t *libtrace) { |
|---|
| 145 | OUTPUT.file = trace_open_file_out(libtrace, |
|---|
| 146 | OPTIONS.zlib.level, |
|---|
| 147 | OPTIONS.zlib.filemode); |
|---|
| 148 | if (!OUTPUT.file) { |
|---|
| 149 | return -1; |
|---|
| 150 | } |
|---|
| 151 | return 0; |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | static int wtf_config_output(struct libtrace_out_t *libtrace, |
|---|
| 155 | trace_option_output_t option, |
|---|
| 156 | void *value) { |
|---|
| 157 | switch(option) { |
|---|
| 158 | #if HAVE_ZLIB |
|---|
| 159 | case TRACE_OPTION_OUTPUT_COMPRESS: |
|---|
| 160 | OPTIONS.zlib.level = *(int*)value; |
|---|
| 161 | assert(OPTIONS.zlib.level>=0 |
|---|
| 162 | && OPTIONS.zlib.level<=9); |
|---|
| 163 | return 0; |
|---|
| 164 | #else |
|---|
| 165 | case TRACE_OPTION_OUTPUT_COMPRESS: |
|---|
| 166 | /* E feature unavailable */ |
|---|
| 167 | trace_set_err_out(libtrace,TRACE_ERR_OPTION_UNAVAIL, |
|---|
| 168 | "zlib not supported"); |
|---|
| 169 | return -1; |
|---|
| 170 | #endif |
|---|
| 171 | default: |
|---|
| 172 | /* E unknown feature */ |
|---|
| 173 | trace_set_err_out(libtrace,TRACE_ERR_UNKNOWN_OPTION, |
|---|
| 174 | "Unknown option"); |
|---|
| 175 | return -1; |
|---|
| 176 | } |
|---|
| 177 | } |
|---|
| 178 | |
|---|
| 179 | static int wag_pause_input(libtrace_t *libtrace) |
|---|
| 180 | { |
|---|
| 181 | close(INPUT.fd); |
|---|
| 182 | |
|---|
| 183 | return 0; |
|---|
| 184 | } |
|---|
| 185 | |
|---|
| 186 | static int wag_fin_input(struct libtrace_t *libtrace) { |
|---|
| 187 | free(libtrace->format_data); |
|---|
| 188 | return 0; |
|---|
| 189 | } |
|---|
| 190 | |
|---|
| 191 | static int wtf_fin_input(struct libtrace_t *libtrace) { |
|---|
| 192 | libtrace_io_close(INPUT.file); |
|---|
| 193 | free(libtrace->format_data); |
|---|
| 194 | return 0; |
|---|
| 195 | } |
|---|
| 196 | |
|---|
| 197 | static int wtf_fin_output(struct libtrace_out_t *libtrace) { |
|---|
| 198 | libtrace_io_close(OUTPUT.file); |
|---|
| 199 | free(libtrace->format_data); |
|---|
| 200 | return 0; |
|---|
| 201 | } |
|---|
| 202 | |
|---|
| 203 | static int wag_read(struct libtrace_t *libtrace, void *buffer, size_t len) { |
|---|
| 204 | size_t framesize; |
|---|
| 205 | char *buf_ptr = (char *)buffer; |
|---|
| 206 | int to_read = 0; |
|---|
| 207 | uint16_t magic = 0; |
|---|
| 208 | |
|---|
| 209 | assert(libtrace); |
|---|
| 210 | |
|---|
| 211 | to_read = sizeof(struct frame_t); |
|---|
| 212 | |
|---|
| 213 | while (to_read>0) { |
|---|
| 214 | int ret=read(INPUT.fd,buf_ptr,to_read); |
|---|
| 215 | |
|---|
| 216 | if (ret == -1) { |
|---|
| 217 | if (errno == EINTR || errno==EAGAIN) |
|---|
| 218 | continue; |
|---|
| 219 | |
|---|
| 220 | trace_set_err(libtrace,errno,"read(%s)",libtrace->uridata); |
|---|
| 221 | return -1; |
|---|
| 222 | } |
|---|
| 223 | |
|---|
| 224 | assert(ret>0); |
|---|
| 225 | |
|---|
| 226 | to_read = to_read - ret; |
|---|
| 227 | buf_ptr = buf_ptr + ret; |
|---|
| 228 | } |
|---|
| 229 | |
|---|
| 230 | |
|---|
| 231 | framesize = ntohs(((struct frame_t *)buffer)->size); |
|---|
| 232 | magic = ntohs(((struct frame_t *)buffer)->magic); |
|---|
| 233 | |
|---|
| 234 | if (magic != 0xdaa1) { |
|---|
| 235 | trace_set_err(libtrace, |
|---|
| 236 | TRACE_ERR_BAD_PACKET,"magic number bad or missing"); |
|---|
| 237 | return -1; |
|---|
| 238 | } |
|---|
| 239 | |
|---|
| 240 | /* We should deal. this is called "snapping", but we don't yet */ |
|---|
| 241 | assert(framesize>len); |
|---|
| 242 | |
|---|
| 243 | buf_ptr = (void*)((char*)buffer + sizeof (struct frame_t)); |
|---|
| 244 | to_read = framesize - sizeof(struct frame_t); |
|---|
| 245 | |
|---|
| 246 | while (to_read>0) { |
|---|
| 247 | int ret=read(INPUT.fd,buf_ptr,to_read); |
|---|
| 248 | |
|---|
| 249 | if (ret == -1) { |
|---|
| 250 | if (errno == EINTR || errno==EAGAIN) |
|---|
| 251 | continue; |
|---|
| 252 | trace_set_err(libtrace,errno,"read(%s)",libtrace->uridata); |
|---|
| 253 | return -1; |
|---|
| 254 | } |
|---|
| 255 | |
|---|
| 256 | to_read = to_read - ret; |
|---|
| 257 | buf_ptr = buf_ptr + ret; |
|---|
| 258 | } |
|---|
| 259 | return framesize; |
|---|
| 260 | } |
|---|
| 261 | |
|---|
| 262 | |
|---|
| 263 | static int wag_read_packet(struct libtrace_t *libtrace, struct libtrace_packet_t *packet) { |
|---|
| 264 | int numbytes; |
|---|
| 265 | |
|---|
| 266 | if (packet->buf_control == TRACE_CTRL_EXTERNAL || !packet->buffer) { |
|---|
| 267 | packet->buf_control = TRACE_CTRL_PACKET; |
|---|
| 268 | packet->buffer = malloc(LIBTRACE_PACKET_BUFSIZE); |
|---|
| 269 | } |
|---|
| 270 | |
|---|
| 271 | |
|---|
| 272 | packet->trace = libtrace; |
|---|
| 273 | packet->type = RT_DATA_WAG; |
|---|
| 274 | |
|---|
| 275 | if ((numbytes = wag_read(libtrace, (void *)packet->buffer, RP_BUFSIZE)) <= 0) { |
|---|
| 276 | |
|---|
| 277 | return numbytes; |
|---|
| 278 | } |
|---|
| 279 | |
|---|
| 280 | |
|---|
| 281 | packet->header = packet->buffer; |
|---|
| 282 | packet->payload=(char*)packet->buffer+trace_get_framing_length(packet); |
|---|
| 283 | return numbytes; |
|---|
| 284 | } |
|---|
| 285 | |
|---|
| 286 | static int wtf_read_packet(struct libtrace_t *libtrace, struct libtrace_packet_t *packet) { |
|---|
| 287 | int numbytes; |
|---|
| 288 | void *buffer; |
|---|
| 289 | void *buffer2; |
|---|
| 290 | int framesize; |
|---|
| 291 | int size; |
|---|
| 292 | |
|---|
| 293 | if (packet->buf_control == TRACE_CTRL_EXTERNAL || !packet->buffer) { |
|---|
| 294 | packet->buf_control = TRACE_CTRL_PACKET; |
|---|
| 295 | packet->buffer = malloc(LIBTRACE_PACKET_BUFSIZE); |
|---|
| 296 | } |
|---|
| 297 | packet->type = RT_DATA_WAG; |
|---|
| 298 | buffer2 = buffer = packet->buffer; |
|---|
| 299 | |
|---|
| 300 | numbytes = libtrace_io_read(INPUT.file, buffer, sizeof(struct frame_t)); |
|---|
| 301 | |
|---|
| 302 | if (numbytes == 0) { |
|---|
| 303 | return 0; |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | if (numbytes != sizeof(struct frame_t)) { |
|---|
| 307 | int err=errno; |
|---|
| 308 | trace_set_err(libtrace,err, |
|---|
| 309 | "read(%s,frame_t)",packet->trace->uridata); |
|---|
| 310 | printf("failed to read header=%i\n",err); |
|---|
| 311 | return -1; |
|---|
| 312 | } |
|---|
| 313 | |
|---|
| 314 | if (htons(((struct frame_t *)buffer)->magic) != 0xdaa1) { |
|---|
| 315 | trace_set_err(libtrace, |
|---|
| 316 | TRACE_ERR_BAD_PACKET,"Insufficient magic (%04x)",htons(((struct frame_t *)buffer)->magic)); |
|---|
| 317 | return -1; |
|---|
| 318 | } |
|---|
| 319 | |
|---|
| 320 | framesize = ntohs(((struct frame_t *)buffer)->size); |
|---|
| 321 | buffer2 = (char*)buffer + sizeof(struct frame_t); |
|---|
| 322 | size = framesize - sizeof(struct frame_t); |
|---|
| 323 | assert(size < LIBTRACE_PACKET_BUFSIZE); |
|---|
| 324 | |
|---|
| 325 | |
|---|
| 326 | if ((numbytes=libtrace_io_read(INPUT.file, buffer2, size)) != size) { |
|---|
| 327 | trace_set_err(libtrace, |
|---|
| 328 | errno,"read(%s,buffer)",packet->trace->uridata); |
|---|
| 329 | return -1; |
|---|
| 330 | } |
|---|
| 331 | |
|---|
| 332 | packet->header = packet->buffer; |
|---|
| 333 | packet->payload=(char*)packet->buffer+trace_get_framing_length(packet); |
|---|
| 334 | return framesize; |
|---|
| 335 | |
|---|
| 336 | } |
|---|
| 337 | |
|---|
| 338 | static int wtf_write_packet(struct libtrace_out_t *libtrace, const struct libtrace_packet_t *packet) { |
|---|
| 339 | int numbytes =0 ; |
|---|
| 340 | if (packet->trace->format != &wag_trace) { |
|---|
| 341 | trace_set_err_out(libtrace,TRACE_ERR_NO_CONVERSION, |
|---|
| 342 | "Cannot convert to wag trace format from %s format yet", |
|---|
| 343 | packet->trace->format->name); |
|---|
| 344 | return -1; |
|---|
| 345 | } |
|---|
| 346 | |
|---|
| 347 | /* We could just read from packet->buffer, but I feel it is more |
|---|
| 348 | * technically correct to read from the header and payload pointers |
|---|
| 349 | */ |
|---|
| 350 | if ((numbytes = libtrace_io_write(OUTPUT.file, packet->header, |
|---|
| 351 | trace_get_framing_length(packet))) == -1) { |
|---|
| 352 | trace_set_err_out(libtrace,errno, |
|---|
| 353 | "write(%s)",packet->trace->uridata); |
|---|
| 354 | return -1; |
|---|
| 355 | } |
|---|
| 356 | if ((numbytes = libtrace_io_write(OUTPUT.file, packet->payload, |
|---|
| 357 | trace_get_capture_length(packet)) == -1)) { |
|---|
| 358 | trace_set_err_out(libtrace, |
|---|
| 359 | errno,"write(%s)",packet->trace->uridata); |
|---|
| 360 | return -1; |
|---|
| 361 | } |
|---|
| 362 | return numbytes; |
|---|
| 363 | } |
|---|
| 364 | |
|---|
| 365 | static libtrace_linktype_t wag_get_link_type(const struct libtrace_packet_t *packet UNUSED) { |
|---|
| 366 | return TRACE_TYPE_80211; |
|---|
| 367 | } |
|---|
| 368 | |
|---|
| 369 | static int8_t wag_get_direction(const struct libtrace_packet_t *packet) { |
|---|
| 370 | struct frame_data_rx_t *wagptr = (struct frame_data_rx_t *)packet->buffer; |
|---|
| 371 | if (wagptr->hdr.type == 0) { |
|---|
| 372 | return wagptr->hdr.subtype; |
|---|
| 373 | } |
|---|
| 374 | return -1; |
|---|
| 375 | } |
|---|
| 376 | |
|---|
| 377 | static uint64_t wag_get_erf_timestamp(const struct libtrace_packet_t *packet) { |
|---|
| 378 | struct frame_data_rx_t *wagptr = (struct frame_data_rx_t *)packet->buffer; |
|---|
| 379 | uint64_t timestamp = 0; |
|---|
| 380 | timestamp = ((uint64_t)(ntohl(wagptr->ts.secs)) << 32) | (uint64_t)(ntohl(wagptr->ts.subsecs)); |
|---|
| 381 | return timestamp; |
|---|
| 382 | } |
|---|
| 383 | |
|---|
| 384 | static int wag_get_capture_length(const struct libtrace_packet_t *packet) { |
|---|
| 385 | struct frame_data_rx_t *wagptr = (struct frame_data_rx_t *)packet->buffer; |
|---|
| 386 | return ntohs(wagptr->hdr.size); |
|---|
| 387 | } |
|---|
| 388 | |
|---|
| 389 | static int wag_get_wire_length(const struct libtrace_packet_t *packet) { |
|---|
| 390 | struct frame_data_rx_t *wagptr = (struct frame_data_rx_t *)packet->buffer; |
|---|
| 391 | return ntohs(wagptr->hdr.size); |
|---|
| 392 | } |
|---|
| 393 | |
|---|
| 394 | static int wag_get_framing_length(UNUSED const libtrace_packet_t *packet) { |
|---|
| 395 | return sizeof(struct frame_data_rx_t); |
|---|
| 396 | } |
|---|
| 397 | |
|---|
| 398 | static int wag_get_fd(const libtrace_t *trace) { |
|---|
| 399 | return DATA(trace)->input.fd; |
|---|
| 400 | } |
|---|
| 401 | |
|---|
| 402 | static void wag_help() { |
|---|
| 403 | printf("wag format module: $Revision$\n"); |
|---|
| 404 | printf("Supported input URIs:\n"); |
|---|
| 405 | printf("\twag:/dev/wagn\n"); |
|---|
| 406 | printf("\n"); |
|---|
| 407 | printf("\te.g.: wag:/dev/wag0\n"); |
|---|
| 408 | printf("\n"); |
|---|
| 409 | printf("Supported output URIs:\n"); |
|---|
| 410 | printf("\tNone\n"); |
|---|
| 411 | printf("\n"); |
|---|
| 412 | } |
|---|
| 413 | |
|---|
| 414 | static void wtf_help() { |
|---|
| 415 | printf("wag trace format module: $Revision$\n"); |
|---|
| 416 | printf("Supported input URIs:\n"); |
|---|
| 417 | printf("\twtf:/path/to/trace.wag\n"); |
|---|
| 418 | printf("\twtf:/path/to/trace.wag.gz\n"); |
|---|
| 419 | printf("\n"); |
|---|
| 420 | printf("\te.g.: wtf:/tmp/trace.wag.gz\n"); |
|---|
| 421 | printf("\n"); |
|---|
| 422 | printf("Supported output URIs:\n"); |
|---|
| 423 | printf("\twtf:/path/to/trace.wag\n"); |
|---|
| 424 | printf("\twtf:/path/to/trace.wag.gz\n"); |
|---|
| 425 | printf("\n"); |
|---|
| 426 | printf("\te.g.: wtf:/tmp/trace.wag.gz\n"); |
|---|
| 427 | printf("\n"); |
|---|
| 428 | } |
|---|
| 429 | |
|---|
| 430 | static struct libtrace_format_t wag = { |
|---|
| 431 | "wag", |
|---|
| 432 | "$Id$", |
|---|
| 433 | TRACE_FORMAT_WAG, |
|---|
| 434 | wag_init_input, /* init_input */ |
|---|
| 435 | NULL, /* config_input */ |
|---|
| 436 | wag_start_input, /* start_input */ |
|---|
| 437 | wag_pause_input, /* pause_input */ |
|---|
| 438 | NULL, /* init_output */ |
|---|
| 439 | NULL, /* config_output */ |
|---|
| 440 | NULL, /* start_output */ |
|---|
| 441 | wag_fin_input, /* fin_input */ |
|---|
| 442 | NULL, /* fin_output */ |
|---|
| 443 | wag_read_packet, /* read_packet */ |
|---|
| 444 | NULL, /* fin_packet */ |
|---|
| 445 | NULL, /* write_packet */ |
|---|
| 446 | wag_get_link_type, /* get_link_type */ |
|---|
| 447 | wag_get_direction, /* get_direction */ |
|---|
| 448 | NULL, /* set_direction */ |
|---|
| 449 | wag_get_erf_timestamp, /* get_erf_timestamp */ |
|---|
| 450 | NULL, /* get_timeval */ |
|---|
| 451 | NULL, /* get_seconds */ |
|---|
| 452 | NULL, /* seek_erf */ |
|---|
| 453 | NULL, /* seek_timeval */ |
|---|
| 454 | NULL, /* seek_seconds */ |
|---|
| 455 | wag_get_capture_length, /* get_capture_length */ |
|---|
| 456 | wag_get_wire_length, /* get_wire_length */ |
|---|
| 457 | wag_get_framing_length, /* get_framing_length */ |
|---|
| 458 | NULL, /* set_capture_length */ |
|---|
| 459 | wag_get_fd, /* get_fd */ |
|---|
| 460 | trace_event_device, /* trace_event */ |
|---|
| 461 | wag_help, /* help */ |
|---|
| 462 | NULL /* next pointer */ |
|---|
| 463 | }; |
|---|
| 464 | |
|---|
| 465 | /* wtf stands for Wag Trace Format */ |
|---|
| 466 | |
|---|
| 467 | static struct libtrace_format_t wag_trace = { |
|---|
| 468 | "wtf", |
|---|
| 469 | "$Id$", |
|---|
| 470 | TRACE_FORMAT_WAG, |
|---|
| 471 | wtf_init_input, /* init_input */ |
|---|
| 472 | NULL, /* config input */ |
|---|
| 473 | wtf_start_input, /* start input */ |
|---|
| 474 | NULL, /* pause_input */ |
|---|
| 475 | wtf_init_output, /* init_output */ |
|---|
| 476 | wtf_config_output, /* config_output */ |
|---|
| 477 | wtf_start_output, /* start output */ |
|---|
| 478 | wtf_fin_input, /* fin_input */ |
|---|
| 479 | wtf_fin_output, /* fin_output */ |
|---|
| 480 | wtf_read_packet, /* read_packet */ |
|---|
| 481 | NULL, /* fin_packet */ |
|---|
| 482 | wtf_write_packet, /* write_packet */ |
|---|
| 483 | wag_get_link_type, /* get_link_type */ |
|---|
| 484 | wag_get_direction, /* get_direction */ |
|---|
| 485 | NULL, /* set_direction */ |
|---|
| 486 | wag_get_erf_timestamp, /* get_erf_timestamp */ |
|---|
| 487 | NULL, /* get_timeval */ |
|---|
| 488 | NULL, /* get_seconds */ |
|---|
| 489 | NULL, /* seek_erf */ |
|---|
| 490 | NULL, /* seek_timeval */ |
|---|
| 491 | NULL, /* seek_seconds */ |
|---|
| 492 | wag_get_capture_length, /* get_capture_length */ |
|---|
| 493 | wag_get_wire_length, /* get_wire_length */ |
|---|
| 494 | wag_get_framing_length, /* get_framing_length */ |
|---|
| 495 | NULL, /* set_capture_length */ |
|---|
| 496 | NULL, /* get_fd */ |
|---|
| 497 | trace_event_trace, /* trace_event */ |
|---|
| 498 | wtf_help, /* help */ |
|---|
| 499 | NULL /* next pointer */ |
|---|
| 500 | }; |
|---|
| 501 | |
|---|
| 502 | |
|---|
| 503 | void CONSTRUCTOR wag_constructor() { |
|---|
| 504 | register_format(&wag); |
|---|
| 505 | register_format(&wag_trace); |
|---|
| 506 | } |
|---|