2 * State machine for text import
3 * November 2010, Jaap Keuter <jaap.keuter@xs4all.nl>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * Based on text2pcap.c by Ashok Narayanan <ashokn@cisco.com>
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program 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.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
29 /*******************************************************************************
31 * This utility reads in an ASCII hexdump of this common format:
33 * 00000000 00 E0 1E A7 05 6F 00 10 5A A0 B9 12 08 00 46 00 .....o..Z.....F.
34 * 00000010 03 68 00 00 00 00 0A 2E EE 33 0F 19 08 7F 0F 19 .h.......3......
35 * 00000020 03 80 94 04 00 00 10 01 16 A2 0A 00 03 50 00 0C .............P..
36 * 00000030 01 01 0F 19 03 80 11 01 1E 61 00 0C 03 01 0F 19 .........a......
38 * Each bytestring line consists of an offset, one or more bytes, and
39 * text at the end. An offset is defined as a hex string of more than
40 * two characters. A byte is defined as a hex string of exactly two
41 * characters. The text at the end is ignored, as is any text before
42 * the offset. Bytes read from a bytestring line are added to the
43 * current packet only if all the following conditions are satisfied:
45 * - No text appears between the offset and the bytes (any bytes appearing after
46 * such text would be ignored)
48 * - The offset must be arithmetically correct, i.e. if the offset is 00000020, then
49 * exactly 32 bytes must have been read into this packet before this. If the offset
50 * is wrong, the packet is immediately terminated
52 * A packet start is signalled by a zero offset.
54 * Lines starting with #TEXT2PCAP are directives. These allow the user
55 * to embed instructions into the capture file which allows text2pcap
56 * to take some actions (e.g. specifying the encapsulation
57 * etc.). Currently no directives are implemented.
59 * Lines beginning with # which are not directives are ignored as
60 * comments. Currently all non-hexdump text is ignored by text2pcap;
61 * in the future, text processing may be added, but lines prefixed
62 * with '#' will still be ignored.
64 * The output is a libpcap packet containing Ethernet frames by
65 * default. This program takes options which allow the user to add
66 * dummy Ethernet, IP and UDP or TCP headers to the packets in order
67 * to allow dumps of L3 or higher protocols to be decoded.
69 * Considerable flexibility is built into this code to read hexdumps
70 * of slightly different formats. For example, any text prefixing the
71 * hexdump line is dropped (including mail forwarding '>'). The offset
72 * can be any hex number of four digits or greater.
74 * This converter cannot read a single packet greater than 64KiB-1. Packet
75 * snaplength is automatically set to 64KiB-1.
81 * Just make sure we include the prototype for strptime as well
82 * (needed for glibc 2.2) but make sure we do this only if not
90 # define _XOPEN_SOURCE 600
95 * Defining _XOPEN_SOURCE is needed on some platforms, e.g. platforms
96 * using glibc, to expand the set of things system header files define.
98 * Unfortunately, on other platforms, such as some versions of Solaris
99 * (including Solaris 10), it *reduces* that set as well, causing
100 * strptime() not to be declared, presumably because the version of the
101 * X/Open spec that _XOPEN_SOURCE implies doesn't include strptime() and
102 * blah blah blah namespace pollution blah blah blah.
104 * So we define __EXTENSIONS__ so that "strptime()" is declared.
106 #ifndef __EXTENSIONS__
107 # define __EXTENSIONS__
114 #include <wsutil/file_util.h>
126 #include <epan/tvbuff.h>
127 #include <wsutil/crc32.h>
128 #include <epan/in_cksum.h>
130 #ifdef NEED_STRPTIME_H
131 # include "wsutil/strptime.h"
134 #include "text_import.h"
135 #include "text_import_scanner.h"
137 /*--- Options --------------------------------------------------------------------*/
140 static int debug = 0;
142 /* Dummy Ethernet header */
143 static int hdr_ethernet = FALSE;
144 static guint32 hdr_ethernet_proto = 0;
146 /* Dummy IP header */
147 static int hdr_ip = FALSE;
148 static long hdr_ip_proto = 0;
150 /* Dummy UDP header */
151 static int hdr_udp = FALSE;
152 static guint32 hdr_dest_port = 0;
153 static guint32 hdr_src_port = 0;
155 /* Dummy TCP header */
156 static int hdr_tcp = FALSE;
158 /* Dummy SCTP header */
159 static int hdr_sctp = FALSE;
160 static guint32 hdr_sctp_src = 0;
161 static guint32 hdr_sctp_dest = 0;
162 static guint32 hdr_sctp_tag = 0;
164 /* Dummy DATA chunk header */
165 static int hdr_data_chunk = FALSE;
166 static guint8 hdr_data_chunk_type = 0;
167 static guint8 hdr_data_chunk_bits = 3;
168 static guint32 hdr_data_chunk_tsn = 0;
169 static guint16 hdr_data_chunk_sid = 0;
170 static guint16 hdr_data_chunk_ssn = 0;
171 static guint32 hdr_data_chunk_ppid = 0;
173 static gboolean has_direction = FALSE;
174 static guint32 direction = 0;
176 /*--- Local data -----------------------------------------------------------------*/
178 /* This is where we store the packet currently being built */
179 static guint8 *packet_buf;
180 static guint32 curr_offset = 0;
181 static guint32 max_offset = IMPORT_MAX_PACKET;
182 static guint32 packet_start = 0;
183 static void start_new_packet (void);
185 /* This buffer contains strings present before the packet offset 0 */
186 #define PACKET_PREAMBLE_MAX_LEN 2048
187 static guint8 packet_preamble[PACKET_PREAMBLE_MAX_LEN+1];
188 static int packet_preamble_len = 0;
190 /* Time code of packet, derived from packet_preamble */
191 static time_t ts_sec = 0;
192 static guint32 ts_usec = 0;
193 static char *ts_fmt = NULL;
194 static struct tm timecode_default;
196 static wtap_dumper* wdh;
198 /* HDR_ETH Offset base to parse */
199 static guint32 offset_base = 16;
201 /* ----- State machine -----------------------------------------------------------*/
203 /* Current state of parser */
205 INIT, /* Waiting for start of new packet */
206 START_OF_LINE, /* Starting from beginning of line */
207 READ_OFFSET, /* Just read the offset */
208 READ_BYTE, /* Just read a byte */
209 READ_TEXT /* Just read text - ignore until EOL */
211 static parser_state_t state = INIT;
213 static const char *state_str[] = {"Init",
220 static const char *token_str[] = {"",
228 /* ----- Skeleton Packet Headers --------------------------------------------------*/
236 static hdr_ethernet_t HDR_ETHERNET = {
237 {0x20, 0x52, 0x45, 0x43, 0x56, 0x00},
238 {0x20, 0x53, 0x45, 0x4E, 0x44, 0x00},
244 guint16 packet_length;
245 guint16 identification;
250 guint16 hdr_checksum;
255 static hdr_ip_t HDR_IP =
256 {0x45, 0, 0, 0x3412, 0, 0, 0xff, 0, 0, 0x01010101, 0x02020202};
258 static struct { /* pseudo header for checksum calculation */
273 static hdr_udp_t HDR_UDP = {0, 0, 0, 0};
287 static hdr_tcp_t HDR_TCP = {0, 0, 0, 0, 0x50, 0, 0, 0, 0};
296 static hdr_sctp_t HDR_SCTP = {0, 0, 0, 0};
308 static hdr_data_chunk_t HDR_DATA_CHUNK = {0, 0, 0, 0, 0, 0, 0};
310 /* Link-layer type; see net/bpf.h for details */
311 static guint pcap_link_type = 1; /* Default is DLT_EN10MB */
313 /*----------------------------------------------------------------------
314 * Parse a single hex number
315 * Will abort the program if it can't parse the number
316 * Pass in TRUE if this is an offset, FALSE if not
319 parse_num (const char *str, int offset)
324 num = strtoul(str, &c, offset ? offset_base : 16);
326 fprintf(stderr, "FATAL ERROR: Bad hex number? [%s]\n", str);
331 /*----------------------------------------------------------------------
332 * Write this byte into current packet
335 write_byte (const char *str)
339 num = parse_num(str, FALSE);
340 packet_buf[curr_offset] = (guint8) num;
342 if (curr_offset >= max_offset) /* packet full */
346 /*----------------------------------------------------------------------
347 * Remove bytes from the current packet
350 unwrite_bytes (guint32 nbytes)
352 curr_offset -= nbytes;
355 /*----------------------------------------------------------------------
356 * Determin SCTP chunk padding length
359 number_of_padding_bytes (guint32 length)
363 remainder = length % 4;
368 return 4 - remainder;
371 /*----------------------------------------------------------------------
372 * Write current packet out
375 write_current_packet (void)
377 int prefix_length = 0;
378 int proto_length = 0;
380 int eth_trailer_length = 0;
381 int prefix_index = 0;
382 int i, padding_length;
384 if (curr_offset > 0) {
385 /* Write the packet */
387 /* Compute packet length */
389 if (hdr_data_chunk) { prefix_length += (int)sizeof(HDR_DATA_CHUNK); }
390 if (hdr_sctp) { prefix_length += (int)sizeof(HDR_SCTP); }
391 if (hdr_udp) { prefix_length += (int)sizeof(HDR_UDP); proto_length = prefix_length + curr_offset; }
392 if (hdr_tcp) { prefix_length += (int)sizeof(HDR_TCP); proto_length = prefix_length + curr_offset; }
394 prefix_length += (int)sizeof(HDR_IP);
395 ip_length = prefix_length + curr_offset + ((hdr_data_chunk) ? number_of_padding_bytes(curr_offset) : 0);
397 if (hdr_ethernet) { prefix_length += (int)sizeof(HDR_ETHERNET); }
399 /* Make room for dummy header */
400 memmove(&packet_buf[prefix_length], packet_buf, curr_offset);
404 if (prefix_length + curr_offset < 60) {
405 eth_trailer_length = 60 - (prefix_length + curr_offset);
409 /* Write Ethernet header */
411 HDR_ETHERNET.l3pid = g_htons(hdr_ethernet_proto);
412 memcpy(&packet_buf[prefix_index], &HDR_ETHERNET, sizeof(HDR_ETHERNET));
413 prefix_index += (int)sizeof(HDR_ETHERNET);
416 /* Write IP header */
418 vec_t cksum_vector[1];
420 HDR_IP.packet_length = g_htons(ip_length);
421 HDR_IP.protocol = (guint8) hdr_ip_proto;
422 HDR_IP.hdr_checksum = 0;
423 cksum_vector[0].ptr = (guint8 *)&HDR_IP; cksum_vector[0].len = sizeof(HDR_IP);
424 HDR_IP.hdr_checksum = in_cksum(cksum_vector, 1);
426 memcpy(&packet_buf[prefix_index], &HDR_IP, sizeof(HDR_IP));
427 prefix_index += (int)sizeof(HDR_IP);
430 /* initialize pseudo header for checksum calculation */
431 pseudoh.src_addr = HDR_IP.src_addr;
432 pseudoh.dest_addr = HDR_IP.dest_addr;
434 pseudoh.protocol = (guint8) hdr_ip_proto;
435 pseudoh.length = g_htons(proto_length);
437 /* Write UDP header */
439 vec_t cksum_vector[3];
441 HDR_UDP.source_port = g_htons(hdr_src_port);
442 HDR_UDP.dest_port = g_htons(hdr_dest_port);
443 HDR_UDP.length = g_htons(proto_length);
445 HDR_UDP.checksum = 0;
446 cksum_vector[0].ptr = (guint8 *)&pseudoh; cksum_vector[0].len = sizeof(pseudoh);
447 cksum_vector[1].ptr = (guint8 *)&HDR_UDP; cksum_vector[1].len = sizeof(HDR_UDP);
448 cksum_vector[2].ptr = &packet_buf[prefix_length]; cksum_vector[2].len = curr_offset;
449 HDR_UDP.checksum = in_cksum(cksum_vector, 3);
451 memcpy(&packet_buf[prefix_index], &HDR_UDP, sizeof(HDR_UDP));
452 prefix_index += (int)sizeof(HDR_UDP);
455 /* Write TCP header */
457 vec_t cksum_vector[3];
459 HDR_TCP.source_port = g_htons(hdr_src_port);
460 HDR_TCP.dest_port = g_htons(hdr_dest_port);
461 /* HDR_TCP.seq_num already correct */
462 HDR_TCP.window = g_htons(0x2000);
464 HDR_TCP.checksum = 0;
465 cksum_vector[0].ptr = (guint8 *)&pseudoh; cksum_vector[0].len = sizeof(pseudoh);
466 cksum_vector[1].ptr = (guint8 *)&HDR_TCP; cksum_vector[1].len = sizeof(HDR_TCP);
467 cksum_vector[2].ptr = &packet_buf[prefix_length]; cksum_vector[2].len = curr_offset;
468 HDR_TCP.checksum = in_cksum(cksum_vector, 3);
470 memcpy(&packet_buf[prefix_index], &HDR_TCP, sizeof(HDR_TCP));
471 prefix_index += (int)sizeof(HDR_TCP);
474 /* Compute DATA chunk header and append padding */
475 if (hdr_data_chunk) {
476 HDR_DATA_CHUNK.type = hdr_data_chunk_type;
477 HDR_DATA_CHUNK.bits = hdr_data_chunk_bits;
478 HDR_DATA_CHUNK.length = g_htons(curr_offset + sizeof(HDR_DATA_CHUNK));
479 HDR_DATA_CHUNK.tsn = g_htonl(hdr_data_chunk_tsn);
480 HDR_DATA_CHUNK.sid = g_htons(hdr_data_chunk_sid);
481 HDR_DATA_CHUNK.ssn = g_htons(hdr_data_chunk_ssn);
482 HDR_DATA_CHUNK.ppid = g_htonl(hdr_data_chunk_ppid);
484 padding_length = number_of_padding_bytes(curr_offset);
485 for (i=0; i<padding_length; i++)
486 packet_buf[prefix_length+curr_offset+i] = 0;
487 curr_offset += padding_length;
490 /* Write SCTP header */
492 HDR_SCTP.src_port = g_htons(hdr_sctp_src);
493 HDR_SCTP.dest_port = g_htons(hdr_sctp_dest);
494 HDR_SCTP.tag = g_htonl(hdr_sctp_tag);
495 HDR_SCTP.checksum = g_htonl(0);
497 HDR_SCTP.checksum = crc32c_calculate(&HDR_SCTP, sizeof(HDR_SCTP), CRC32C_PRELOAD);
499 HDR_SCTP.checksum = crc32c_calculate(&HDR_DATA_CHUNK, sizeof(HDR_DATA_CHUNK), HDR_SCTP.checksum);
500 HDR_SCTP.checksum = g_htonl(~crc32c_calculate(&packet_buf[prefix_length], curr_offset, HDR_SCTP.checksum));
502 memcpy(&packet_buf[prefix_index], &HDR_SCTP, sizeof(HDR_SCTP));
503 prefix_index += (int)sizeof(HDR_SCTP);
506 /* Write DATA chunk header */
507 if (hdr_data_chunk) {
508 memcpy(&packet_buf[prefix_index], &HDR_DATA_CHUNK, sizeof(HDR_DATA_CHUNK));
509 /*prefix_index += (int)sizeof(HDR_DATA_CHUNK);*/
512 /* Write Ethernet trailer */
513 if (hdr_ethernet && eth_trailer_length > 0) {
514 memset(&packet_buf[prefix_length+curr_offset], 0, eth_trailer_length);
517 HDR_TCP.seq_num = g_ntohl(HDR_TCP.seq_num) + curr_offset;
518 HDR_TCP.seq_num = g_htonl(HDR_TCP.seq_num);
521 /* Write the packet */
522 struct wtap_pkthdr pkthdr;
525 pkthdr.ts.secs = (guint32)ts_sec;
526 pkthdr.ts.nsecs = ts_usec * 1000;
527 if (ts_fmt == NULL) { ts_usec++; } /* fake packet counter */
528 pkthdr.caplen = pkthdr.len = prefix_length + curr_offset + eth_trailer_length;
529 pkthdr.pkt_encap = pcap_link_type;
530 pkthdr.interface_id = 0;
531 pkthdr.presence_flags = 0;
532 pkthdr.opt_comment = NULL;
533 pkthdr.drop_count = 0;
534 pkthdr.pack_flags = 0;
535 pkthdr.pack_flags |= direction;
536 pkthdr.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS|WTAP_HAS_PACK_FLAGS;
538 wtap_dump(wdh, &pkthdr, packet_buf, &err);
542 packet_start += curr_offset;
547 /*----------------------------------------------------------------------
548 * Append a token to the packet preamble.
551 append_to_preamble(char *str)
555 if (packet_preamble_len != 0) {
556 if (packet_preamble_len == PACKET_PREAMBLE_MAX_LEN)
557 return; /* no room to add more preamble */
558 /* Add a blank separator between the previous token and this token. */
559 packet_preamble[packet_preamble_len++] = ' ';
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 */
783 /* ----- Processing packet, start of new line -----------------------------*/
787 append_to_preamble(str);
790 process_directive(str);
793 num = parse_num(str, TRUE);
795 /* New packet starts here */
799 } else if ((num - packet_start) != curr_offset) {
801 * The offset we read isn't the one we expected.
802 * This may only mean that we mistakenly interpreted
803 * some text as byte values (e.g., if the text dump
804 * of packet data included a number with spaces around
805 * it). If the offset is less than what we expected,
806 * assume that's the problem, and throw away the putative
809 if (num < curr_offset) {
810 unwrite_bytes(curr_offset - num);
813 /* Bad offset; switch to INIT state */
815 fprintf(stderr, "Inconsistent offset. Expecting %0X, got %0X. Ignoring rest of packet\n",
817 write_current_packet();
828 /* ----- Processing packet, read offset -----------------------------------*/
832 /* Record the byte */
842 state = START_OF_LINE;
849 /* ----- Processing packet, read byte -------------------------------------*/
853 /* Record the byte */
862 state = START_OF_LINE;
869 /* ----- Processing packet, read text -------------------------------------*/
873 state = START_OF_LINE;
881 fprintf(stderr, "FATAL ERROR: Bad state (%d)", state);
886 fprintf(stderr, ", %s)\n", state_str[state]);
890 /*----------------------------------------------------------------------
891 * take in the import config information
894 text_import_setup(text_import_info_t *info)
896 packet_buf = (guint8 *)g_malloc(sizeof(HDR_ETHERNET) + sizeof(HDR_IP) +
897 sizeof(HDR_SCTP) + sizeof(HDR_DATA_CHUNK) +
902 fprintf(stderr, "FATAL ERROR: no memory for packet buffer");
906 /* Lets start from the beginning */
910 packet_preamble_len = 0;
911 ts_sec = time(0); /* initialize to current time */
912 timecode_default = *localtime(&ts_sec);
913 timecode_default.tm_isdst = -1; /* Unknown for now, depends on time given to the strptime() function */
917 hdr_ethernet = FALSE;
922 hdr_data_chunk = FALSE;
924 offset_base = (info->offset_type == OFFSET_HEX) ? 16 :
925 (info->offset_type == OFFSET_OCT) ? 8 :
926 (info->offset_type == OFFSET_DEC) ? 10 :
929 has_direction = info->has_direction;
931 if (info->date_timestamp)
933 ts_fmt = info->date_timestamp_format;
936 pcap_link_type = info->encapsulation;
940 switch (info->dummy_header_type)
944 hdr_ethernet_proto = info->pid;
949 hdr_ip_proto = info->protocol;
951 hdr_ethernet_proto = 0x800;
957 hdr_src_port = info->src_port;
958 hdr_dest_port = info->dst_port;
962 hdr_ethernet_proto = 0x800;
968 hdr_src_port = info->src_port;
969 hdr_dest_port = info->dst_port;
973 hdr_ethernet_proto = 0x800;
978 hdr_sctp_src = info->src_port;
979 hdr_sctp_dest = info->dst_port;
980 hdr_sctp_tag = info->tag;
984 hdr_ethernet_proto = 0x800;
987 case HEADER_SCTP_DATA:
989 hdr_data_chunk = TRUE;
990 hdr_sctp_src = info->src_port;
991 hdr_sctp_dest = info->dst_port;
992 hdr_data_chunk_ppid = info->ppi;
996 hdr_ethernet_proto = 0x800;
1003 max_offset = info->max_frame_length;
1006 /*----------------------------------------------------------------------
1007 * Clean up after text import
1010 text_import_cleanup(void)
1021 * indent-tabs-mode: nil
1024 * ex: set shiftwidth=4 tabstop=8 expandtab:
1025 * :indentSize=4:tabSize=8:noTabs=true: