2 * State machine for text import
3 * November 2010, Jaap Keuter <jaap.keuter@xs4all.nl>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * Based on text2pcap.c by Ashok Narayanan <ashokn@cisco.com>
11 * SPDX-License-Identifier: GPL-2.0-or-later
14 /*******************************************************************************
16 * This utility reads in an ASCII hexdump of this common format:
18 * 00000000 00 E0 1E A7 05 6F 00 10 5A A0 B9 12 08 00 46 00 .....o..Z.....F.
19 * 00000010 03 68 00 00 00 00 0A 2E EE 33 0F 19 08 7F 0F 19 .h.......3......
20 * 00000020 03 80 94 04 00 00 10 01 16 A2 0A 00 03 50 00 0C .............P..
21 * 00000030 01 01 0F 19 03 80 11 01 1E 61 00 0C 03 01 0F 19 .........a......
23 * Each bytestring line consists of an offset, one or more bytes, and
24 * text at the end. An offset is defined as a hex string of more than
25 * two characters. A byte is defined as a hex string of exactly two
26 * characters. The text at the end is ignored, as is any text before
27 * the offset. Bytes read from a bytestring line are added to the
28 * current packet only if all the following conditions are satisfied:
30 * - No text appears between the offset and the bytes (any bytes appearing after
31 * such text would be ignored)
33 * - The offset must be arithmetically correct, i.e. if the offset is 00000020, then
34 * exactly 32 bytes must have been read into this packet before this. If the offset
35 * is wrong, the packet is immediately terminated
37 * A packet start is signalled by a zero offset.
39 * Lines starting with #TEXT2PCAP are directives. These allow the user
40 * to embed instructions into the capture file which allows text2pcap
41 * to take some actions (e.g. specifying the encapsulation
42 * etc.). Currently no directives are implemented.
44 * Lines beginning with # which are not directives are ignored as
45 * comments. Currently all non-hexdump text is ignored by text2pcap;
46 * in the future, text processing may be added, but lines prefixed
47 * with '#' will still be ignored.
49 * The output is a libpcap packet containing Ethernet frames by
50 * default. This program takes options which allow the user to add
51 * dummy Ethernet, IP and UDP or TCP headers to the packets in order
52 * to allow dumps of L3 or higher protocols to be decoded.
54 * Considerable flexibility is built into this code to read hexdumps
55 * of slightly different formats. For example, any text prefixing the
56 * hexdump line is dropped (including mail forwarding '>'). The offset
57 * can be any hex number of four digits or greater.
59 * This converter cannot read a single packet greater than 64KiB-1. Packet
60 * snaplength is automatically set to 64KiB-1.
66 * Just make sure we include the prototype for strptime as well
67 * (needed for glibc 2.2) but make sure we do this only if not
75 # define _XOPEN_SOURCE 600
80 * Defining _XOPEN_SOURCE is needed on some platforms, e.g. platforms
81 * using glibc, to expand the set of things system header files define.
83 * Unfortunately, on other platforms, such as some versions of Solaris
84 * (including Solaris 10), it *reduces* that set as well, causing
85 * strptime() not to be declared, presumably because the version of the
86 * X/Open spec that _XOPEN_SOURCE implies doesn't include strptime() and
87 * blah blah blah namespace pollution blah blah blah.
89 * So we define __EXTENSIONS__ so that "strptime()" is declared.
91 #ifndef __EXTENSIONS__
92 # define __EXTENSIONS__
98 #include <wsutil/file_util.h>
106 #include <epan/tvbuff.h>
107 #include <wsutil/crc32.h>
108 #include <epan/in_cksum.h>
110 #ifndef HAVE_STRPTIME
111 # include "wsutil/strptime.h"
114 #include "text_import.h"
115 #include "text_import_scanner.h"
116 #include "text_import_scanner_lex.h"
118 /*--- Options --------------------------------------------------------------------*/
121 static int debug = 0;
123 /* Dummy Ethernet header */
124 static int hdr_ethernet = FALSE;
125 static guint32 hdr_ethernet_proto = 0;
127 /* Dummy IP header */
128 static int hdr_ip = FALSE;
129 static guint hdr_ip_proto = 0;
131 /* Dummy UDP header */
132 static int hdr_udp = FALSE;
133 static guint32 hdr_dest_port = 0;
134 static guint32 hdr_src_port = 0;
136 /* Dummy TCP header */
137 static int hdr_tcp = FALSE;
139 /* Dummy SCTP header */
140 static int hdr_sctp = FALSE;
141 static guint32 hdr_sctp_src = 0;
142 static guint32 hdr_sctp_dest = 0;
143 static guint32 hdr_sctp_tag = 0;
145 /* Dummy DATA chunk header */
146 static int hdr_data_chunk = FALSE;
147 static guint8 hdr_data_chunk_type = 0;
148 static guint8 hdr_data_chunk_bits = 3;
149 static guint32 hdr_data_chunk_tsn = 0;
150 static guint16 hdr_data_chunk_sid = 0;
151 static guint16 hdr_data_chunk_ssn = 0;
152 static guint32 hdr_data_chunk_ppid = 0;
154 static gboolean has_direction = FALSE;
155 static guint32 direction = 0;
157 /*--- Local data -----------------------------------------------------------------*/
159 /* This is where we store the packet currently being built */
160 static guint8 *packet_buf;
161 static guint32 curr_offset = 0;
162 static guint32 max_offset = IMPORT_MAX_PACKET;
163 static guint32 packet_start = 0;
164 static void start_new_packet (void);
166 /* This buffer contains strings present before the packet offset 0 */
167 #define PACKET_PREAMBLE_MAX_LEN 2048
168 static guint8 packet_preamble[PACKET_PREAMBLE_MAX_LEN+1];
169 static int packet_preamble_len = 0;
171 /* Time code of packet, derived from packet_preamble */
172 static time_t ts_sec = 0;
173 static guint32 ts_usec = 0;
174 static char *ts_fmt = NULL;
175 static struct tm timecode_default;
177 static wtap_dumper* wdh;
179 /* HDR_ETH Offset base to parse */
180 static guint32 offset_base = 16;
182 /* ----- State machine -----------------------------------------------------------*/
184 /* Current state of parser */
186 INIT, /* Waiting for start of new packet */
187 START_OF_LINE, /* Starting from beginning of line */
188 READ_OFFSET, /* Just read the offset */
189 READ_BYTE, /* Just read a byte */
190 READ_TEXT /* Just read text - ignore until EOL */
192 static parser_state_t state = INIT;
194 static const char *state_str[] = {"Init",
201 static const char *token_str[] = {"",
209 /* ----- Skeleton Packet Headers --------------------------------------------------*/
217 static hdr_ethernet_t HDR_ETHERNET = {
218 {0x20, 0x52, 0x45, 0x43, 0x56, 0x00},
219 {0x20, 0x53, 0x45, 0x4E, 0x44, 0x00},
225 guint16 packet_length;
226 guint16 identification;
231 guint16 hdr_checksum;
236 static hdr_ip_t HDR_IP =
237 {0x45, 0, 0, 0x3412, 0, 0, 0xff, 0, 0, 0x01010101, 0x02020202};
239 static struct { /* pseudo header for checksum calculation */
254 static hdr_udp_t HDR_UDP = {0, 0, 0, 0};
268 static hdr_tcp_t HDR_TCP = {0, 0, 0, 0, 0x50, 0, 0, 0, 0};
277 static hdr_sctp_t HDR_SCTP = {0, 0, 0, 0};
289 static hdr_data_chunk_t HDR_DATA_CHUNK = {0, 0, 0, 0, 0, 0, 0};
291 /* Link-layer type; see net/bpf.h for details */
292 static guint pcap_link_type = 1; /* Default is DLT_EN10MB */
294 /*----------------------------------------------------------------------
295 * Parse a single hex number
296 * Will abort the program if it can't parse the number
297 * Pass in TRUE if this is an offset, FALSE if not
300 parse_num (const char *str, int offset)
306 fprintf(stderr, "FATAL ERROR: str is NULL\n");
310 num = strtoul(str, &c, offset ? offset_base : 16);
312 fprintf(stderr, "FATAL ERROR: Bad hex number? [%s]\n", str);
317 /*----------------------------------------------------------------------
318 * Write this byte into current packet
321 write_byte (const char *str)
325 num = parse_num(str, FALSE);
326 packet_buf[curr_offset] = (guint8) num;
328 if (curr_offset >= max_offset) /* packet full */
332 /*----------------------------------------------------------------------
333 * Remove bytes from the current packet
336 unwrite_bytes (guint32 nbytes)
338 curr_offset -= nbytes;
341 /*----------------------------------------------------------------------
342 * Determin SCTP chunk padding length
345 number_of_padding_bytes (guint32 length)
349 remainder = length % 4;
354 return 4 - remainder;
357 /*----------------------------------------------------------------------
358 * Write current packet out
361 write_current_packet (void)
363 int prefix_length = 0;
364 int proto_length = 0;
366 int eth_trailer_length = 0;
367 int prefix_index = 0;
368 int i, padding_length;
370 if (curr_offset > 0) {
371 /* Write the packet */
373 /* Compute packet length */
375 if (hdr_data_chunk) { prefix_length += (int)sizeof(HDR_DATA_CHUNK); }
376 if (hdr_sctp) { prefix_length += (int)sizeof(HDR_SCTP); }
377 if (hdr_udp) { prefix_length += (int)sizeof(HDR_UDP); proto_length = prefix_length + curr_offset; }
378 if (hdr_tcp) { prefix_length += (int)sizeof(HDR_TCP); proto_length = prefix_length + curr_offset; }
380 prefix_length += (int)sizeof(HDR_IP);
381 ip_length = prefix_length + curr_offset + ((hdr_data_chunk) ? number_of_padding_bytes(curr_offset) : 0);
383 if (hdr_ethernet) { prefix_length += (int)sizeof(HDR_ETHERNET); }
385 /* Make room for dummy header */
386 memmove(&packet_buf[prefix_length], packet_buf, curr_offset);
390 if (prefix_length + curr_offset < 60) {
391 eth_trailer_length = 60 - (prefix_length + curr_offset);
395 /* Write Ethernet header */
397 HDR_ETHERNET.l3pid = g_htons(hdr_ethernet_proto);
398 memcpy(&packet_buf[prefix_index], &HDR_ETHERNET, sizeof(HDR_ETHERNET));
399 prefix_index += (int)sizeof(HDR_ETHERNET);
402 /* Write IP header */
404 vec_t cksum_vector[1];
406 HDR_IP.packet_length = g_htons(ip_length);
407 HDR_IP.protocol = (guint8) hdr_ip_proto;
408 HDR_IP.hdr_checksum = 0;
409 cksum_vector[0].ptr = (guint8 *)&HDR_IP; cksum_vector[0].len = sizeof(HDR_IP);
410 HDR_IP.hdr_checksum = in_cksum(cksum_vector, 1);
412 memcpy(&packet_buf[prefix_index], &HDR_IP, sizeof(HDR_IP));
413 prefix_index += (int)sizeof(HDR_IP);
416 /* initialize pseudo header for checksum calculation */
417 pseudoh.src_addr = HDR_IP.src_addr;
418 pseudoh.dest_addr = HDR_IP.dest_addr;
420 pseudoh.protocol = (guint8) hdr_ip_proto;
421 pseudoh.length = g_htons(proto_length);
423 /* Write UDP header */
425 vec_t cksum_vector[3];
427 HDR_UDP.source_port = g_htons(hdr_src_port);
428 HDR_UDP.dest_port = g_htons(hdr_dest_port);
429 HDR_UDP.length = g_htons(proto_length);
431 HDR_UDP.checksum = 0;
432 cksum_vector[0].ptr = (guint8 *)&pseudoh; cksum_vector[0].len = sizeof(pseudoh);
433 cksum_vector[1].ptr = (guint8 *)&HDR_UDP; cksum_vector[1].len = sizeof(HDR_UDP);
434 cksum_vector[2].ptr = &packet_buf[prefix_length]; cksum_vector[2].len = curr_offset;
435 HDR_UDP.checksum = in_cksum(cksum_vector, 3);
437 memcpy(&packet_buf[prefix_index], &HDR_UDP, sizeof(HDR_UDP));
438 prefix_index += (int)sizeof(HDR_UDP);
441 /* Write TCP header */
443 vec_t cksum_vector[3];
445 HDR_TCP.source_port = g_htons(hdr_src_port);
446 HDR_TCP.dest_port = g_htons(hdr_dest_port);
447 /* HDR_TCP.seq_num already correct */
448 HDR_TCP.window = g_htons(0x2000);
450 HDR_TCP.checksum = 0;
451 cksum_vector[0].ptr = (guint8 *)&pseudoh; cksum_vector[0].len = sizeof(pseudoh);
452 cksum_vector[1].ptr = (guint8 *)&HDR_TCP; cksum_vector[1].len = sizeof(HDR_TCP);
453 cksum_vector[2].ptr = &packet_buf[prefix_length]; cksum_vector[2].len = curr_offset;
454 HDR_TCP.checksum = in_cksum(cksum_vector, 3);
456 memcpy(&packet_buf[prefix_index], &HDR_TCP, sizeof(HDR_TCP));
457 prefix_index += (int)sizeof(HDR_TCP);
460 /* Compute DATA chunk header and append padding */
461 if (hdr_data_chunk) {
462 HDR_DATA_CHUNK.type = hdr_data_chunk_type;
463 HDR_DATA_CHUNK.bits = hdr_data_chunk_bits;
464 HDR_DATA_CHUNK.length = g_htons(curr_offset + sizeof(HDR_DATA_CHUNK));
465 HDR_DATA_CHUNK.tsn = g_htonl(hdr_data_chunk_tsn);
466 HDR_DATA_CHUNK.sid = g_htons(hdr_data_chunk_sid);
467 HDR_DATA_CHUNK.ssn = g_htons(hdr_data_chunk_ssn);
468 HDR_DATA_CHUNK.ppid = g_htonl(hdr_data_chunk_ppid);
470 padding_length = number_of_padding_bytes(curr_offset);
471 for (i=0; i<padding_length; i++)
472 packet_buf[prefix_length+curr_offset+i] = 0;
473 curr_offset += padding_length;
476 /* Write SCTP header */
478 HDR_SCTP.src_port = g_htons(hdr_sctp_src);
479 HDR_SCTP.dest_port = g_htons(hdr_sctp_dest);
480 HDR_SCTP.tag = g_htonl(hdr_sctp_tag);
481 HDR_SCTP.checksum = g_htonl(0);
483 HDR_SCTP.checksum = crc32c_calculate(&HDR_SCTP, sizeof(HDR_SCTP), CRC32C_PRELOAD);
485 HDR_SCTP.checksum = crc32c_calculate(&HDR_DATA_CHUNK, sizeof(HDR_DATA_CHUNK), HDR_SCTP.checksum);
486 HDR_SCTP.checksum = g_htonl(~crc32c_calculate(&packet_buf[prefix_length], curr_offset, HDR_SCTP.checksum));
488 memcpy(&packet_buf[prefix_index], &HDR_SCTP, sizeof(HDR_SCTP));
489 prefix_index += (int)sizeof(HDR_SCTP);
492 /* Write DATA chunk header */
493 if (hdr_data_chunk) {
494 memcpy(&packet_buf[prefix_index], &HDR_DATA_CHUNK, sizeof(HDR_DATA_CHUNK));
495 /*prefix_index += (int)sizeof(HDR_DATA_CHUNK);*/
498 /* Write Ethernet trailer */
499 if (hdr_ethernet && eth_trailer_length > 0) {
500 memset(&packet_buf[prefix_length+curr_offset], 0, eth_trailer_length);
503 HDR_TCP.seq_num = g_ntohl(HDR_TCP.seq_num) + curr_offset;
504 HDR_TCP.seq_num = g_htonl(HDR_TCP.seq_num);
507 /* Write the packet */
512 memset(&rec, 0, sizeof rec);
514 rec.rec_type = REC_TYPE_PACKET;
515 rec.ts.secs = (guint32)ts_sec;
516 rec.ts.nsecs = ts_usec * 1000;
517 if (ts_fmt == NULL) { ts_usec++; } /* fake packet counter */
518 rec.rec_header.packet_header.caplen = rec.rec_header.packet_header.len = prefix_length + curr_offset + eth_trailer_length;
519 rec.rec_header.packet_header.pkt_encap = pcap_link_type;
520 rec.rec_header.packet_header.pack_flags |= direction;
521 rec.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS|WTAP_HAS_PACK_FLAGS;
523 /* XXX - report errors! */
524 if (!wtap_dump(wdh, &rec, packet_buf, &err, &err_info)) {
527 case WTAP_ERR_UNWRITABLE_REC_DATA:
538 packet_start += curr_offset;
543 /*----------------------------------------------------------------------
544 * Append a token to the packet preamble.
547 append_to_preamble(char *str)
551 if (packet_preamble_len != 0) {
552 if (packet_preamble_len == PACKET_PREAMBLE_MAX_LEN)
553 return; /* no room to add more preamble */
554 /* Add a blank separator between the previous token and this token. */
555 packet_preamble[packet_preamble_len++] = ' ';
558 fprintf(stderr, "FATAL ERROR: str is NULL\n");
561 toklen = strlen(str);
563 if (packet_preamble_len + toklen > PACKET_PREAMBLE_MAX_LEN)
564 return; /* no room to add the token to the preamble */
565 g_strlcpy(&packet_preamble[packet_preamble_len], str, PACKET_PREAMBLE_MAX_LEN);
566 packet_preamble_len += (int) toklen;
569 char xs[PACKET_PREAMBLE_MAX_LEN];
570 g_strlcpy(xs, packet_preamble, PACKET_PREAMBLE_MAX_LEN);
571 while ((c = strchr(xs, '\r')) != NULL) *c=' ';
572 fprintf (stderr, "[[append_to_preamble: \"%s\"]]", xs);
577 /*----------------------------------------------------------------------
578 * Parse the preamble to get the timecode.
582 parse_preamble (void)
591 * Null-terminate the preamble.
593 packet_preamble[packet_preamble_len] = '\0';
596 switch (packet_preamble[0]) {
599 direction = 0x00000001;
600 packet_preamble[0] = ' ';
604 direction = 0x00000002;
605 packet_preamble[0] = ' ';
608 direction = 0x00000000;
612 while (packet_preamble[i] == ' ' ||
613 packet_preamble[i] == '\r' ||
614 packet_preamble[i] == '\t') {
617 packet_preamble_len -= i;
618 /* Also move the trailing '\0'. */
619 memmove(packet_preamble, packet_preamble + i, packet_preamble_len + 1);
623 * If no "-t" flag was specified, don't attempt to parse a packet
624 * preamble to extract a time stamp.
630 * Initialize to today localtime, just in case not all fields
631 * of the date and time are specified.
634 timecode = timecode_default;
637 /* Ensure preamble has more than two chars before attempting to parse.
638 * This should cover line breaks etc that get counted.
640 if ( strlen(packet_preamble) > 2 ) {
641 /* Get Time leaving subseconds */
642 subsecs = strptime( packet_preamble, ts_fmt, &timecode );
643 if (subsecs != NULL) {
644 /* Get the long time from the tm structure */
645 /* (will return -1 if failure) */
646 ts_sec = mktime( &timecode );
648 ts_sec = -1; /* we failed to parse it */
650 /* This will ensure incorrectly parsed dates get set to zero */
653 /* Sanitize - remove all '\r' */
655 while ((c = strchr(packet_preamble, '\r')) != NULL) *c=' ';
656 fprintf (stderr, "Failure processing time \"%s\" using time format \"%s\"\n (defaulting to Jan 1,1970 00:00:00 GMT)\n",
657 packet_preamble, ts_fmt);
659 fprintf(stderr, "timecode: %02d/%02d/%d %02d:%02d:%02d %d\n",
660 timecode.tm_mday, timecode.tm_mon, timecode.tm_year,
661 timecode.tm_hour, timecode.tm_min, timecode.tm_sec, timecode.tm_isdst);
663 ts_sec = 0; /* Jan 1,1970: 00:00 GMT; tshark/wireshark will display date/time as adjusted by timezone */
668 /* Parse subseconds */
669 ts_usec = (guint32)strtol(subsecs, &p, 10);
675 * Convert that number to a number
676 * of microseconds; if it's N digits
677 * long, it's in units of 10^(-N) seconds,
678 * so, to convert it to units of
679 * 10^-6 seconds, we multiply by
682 subseclen = (int) (p - subsecs);
685 * *More* than 6 digits; 6-N is
686 * negative, so we divide by
689 for (i = subseclen - 6; i != 0; i--)
691 } else if (subseclen < 6) {
692 for (i = 6 - subseclen; i != 0; i--)
700 while ((c = strchr(packet_preamble, '\r')) != NULL) *c=' ';
701 fprintf(stderr, "[[parse_preamble: \"%s\"]]\n", packet_preamble);
702 fprintf(stderr, "Format(%s), time(%u), subsecs(%u)\n", ts_fmt, (guint32)ts_sec, ts_usec);
707 packet_preamble_len = 0;
710 /*----------------------------------------------------------------------
714 start_new_packet (void)
717 fprintf(stderr, "Start new packet\n");
719 /* Write out the current packet, if required */
720 write_current_packet();
722 /* Ensure we parse the packet preamble as it may contain the time */
726 /*----------------------------------------------------------------------
727 * Process a directive
730 process_directive (char *str)
732 fprintf(stderr, "\n--- Directive [%s] currently unsupported ---\n", str+10);
736 /*----------------------------------------------------------------------
737 * Parse a single token (called from the scanner)
740 parse_token (token_t token, char *str)
745 * This is implemented as a simple state machine of five states.
746 * State transitions are caused by tokens being received from the
747 * scanner. The code should be self_documenting.
751 /* Sanitize - remove all '\r' */
753 if (str!=NULL) { while ((c = strchr(str, '\r')) != NULL) *c=' '; }
755 fprintf(stderr, "(%s, %s \"%s\") -> (",
756 state_str[state], token_str[token], str ? str : "");
761 /* ----- Waiting for new packet -------------------------------------------*/
765 append_to_preamble(str);
768 process_directive(str);
771 num = parse_num(str, TRUE);
773 /* New packet starts here */
779 if (offset_base == 0) {
790 /* ----- Processing packet, start of new line -----------------------------*/
794 append_to_preamble(str);
797 process_directive(str);
800 num = parse_num(str, TRUE);
802 /* New packet starts here */
806 } else if ((num - packet_start) != curr_offset) {
808 * The offset we read isn't the one we expected.
809 * This may only mean that we mistakenly interpreted
810 * some text as byte values (e.g., if the text dump
811 * of packet data included a number with spaces around
812 * it). If the offset is less than what we expected,
813 * assume that's the problem, and throw away the putative
816 if (num < curr_offset) {
817 unwrite_bytes(curr_offset - num);
820 /* Bad offset; switch to INIT state */
822 fprintf(stderr, "Inconsistent offset. Expecting %0X, got %0X. Ignoring rest of packet\n",
824 write_current_packet();
831 if (offset_base == 0) {
841 /* ----- Processing packet, read offset -----------------------------------*/
845 /* Record the byte */
855 state = START_OF_LINE;
862 /* ----- Processing packet, read byte -------------------------------------*/
866 /* Record the byte */
875 state = START_OF_LINE;
882 /* ----- Processing packet, read text -------------------------------------*/
886 state = START_OF_LINE;
894 fprintf(stderr, "FATAL ERROR: Bad state (%d)", state);
899 fprintf(stderr, ", %s)\n", state_str[state]);
903 /*----------------------------------------------------------------------
904 * Import a text file.
907 text_import(text_import_info_t *info)
912 packet_buf = (guint8 *)g_malloc(sizeof(HDR_ETHERNET) + sizeof(HDR_IP) +
913 sizeof(HDR_SCTP) + sizeof(HDR_DATA_CHUNK) +
918 fprintf(stderr, "FATAL ERROR: no memory for packet buffer");
922 /* Lets start from the beginning */
926 packet_preamble_len = 0;
927 ts_sec = time(0); /* initialize to current time */
928 now_tm = localtime(&ts_sec);
929 if (now_tm == NULL) {
931 * This shouldn't happen - on UN*X, this should Just Work, and
932 * on Windows, it won't work if ts_sec is before the Epoch,
933 * but it's long after 1970, so....
935 fprintf(stderr, "localtime(right now) failed\n");
938 timecode_default = *now_tm;
939 timecode_default.tm_isdst = -1; /* Unknown for now, depends on time given to the strptime() function */
943 hdr_ethernet = FALSE;
948 hdr_data_chunk = FALSE;
950 offset_base = (info->offset_type == OFFSET_NONE) ? 0 :
951 (info->offset_type == OFFSET_HEX) ? 16 :
952 (info->offset_type == OFFSET_OCT) ? 8 :
953 (info->offset_type == OFFSET_DEC) ? 10 :
956 has_direction = info->has_direction;
958 if (info->date_timestamp)
960 ts_fmt = info->date_timestamp_format;
963 pcap_link_type = info->encapsulation;
967 switch (info->dummy_header_type)
971 hdr_ethernet_proto = info->pid;
976 hdr_ip_proto = info->protocol;
978 hdr_ethernet_proto = 0x800;
984 hdr_src_port = info->src_port;
985 hdr_dest_port = info->dst_port;
989 hdr_ethernet_proto = 0x800;
995 hdr_src_port = info->src_port;
996 hdr_dest_port = info->dst_port;
1000 hdr_ethernet_proto = 0x800;
1005 hdr_sctp_src = info->src_port;
1006 hdr_sctp_dest = info->dst_port;
1007 hdr_sctp_tag = info->tag;
1010 hdr_ethernet = TRUE;
1011 hdr_ethernet_proto = 0x800;
1014 case HEADER_SCTP_DATA:
1016 hdr_data_chunk = TRUE;
1017 hdr_sctp_src = info->src_port;
1018 hdr_sctp_dest = info->dst_port;
1019 hdr_data_chunk_ppid = info->ppi;
1022 hdr_ethernet = TRUE;
1023 hdr_ethernet_proto = 0x800;
1030 max_offset = info->max_frame_length;
1032 ret = text_import_scan(info->import_text_file);
1043 * indent-tabs-mode: nil
1046 * ex: set shiftwidth=4 tabstop=8 expandtab:
1047 * :indentSize=4:tabSize=8:noTabs=true: