From 26bdb4f056e2a1e5715004cd0429f1eec9b83b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20T=C3=BCxen?= Date: Tue, 2 Apr 2013 12:15:42 +0000 Subject: Add support for the initial direction indication. Irene will hook it up to the GUI soon. svn path=/trunk/; revision=48696 --- ui/text_import.c | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'ui/text_import.c') diff --git a/ui/text_import.c b/ui/text_import.c index 0d38e5c4b7..307b1e1fdc 100644 --- a/ui/text_import.c +++ b/ui/text_import.c @@ -170,6 +170,8 @@ static guint16 hdr_data_chunk_sid = 0; static guint16 hdr_data_chunk_ssn = 0; static guint32 hdr_data_chunk_ppid = 0; +static gboolean has_direction = FALSE; +static guint32 direction = 0; /*--- Local data -----------------------------------------------------------------*/ @@ -530,7 +532,8 @@ write_current_packet (void) pkthdr.opt_comment = NULL; pkthdr.drop_count = 0; pkthdr.pack_flags = 0; - pkthdr.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS; + pkthdr.pack_flags |= direction; + pkthdr.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS|WTAP_HAS_PACK_FLAGS; wtap_dump(wdh, &pkthdr, packet_buf, &err); } @@ -584,6 +587,37 @@ parse_preamble (void) int subseclen; int i; + /* + * Null-terminate the preamble. + */ + packet_preamble[packet_preamble_len] = '\0'; + + if (has_direction) { + switch (packet_preamble[0]) { + case 'i': + case 'I': + direction = 0x00000001; + packet_preamble[0] = ' '; + break; + case 'o': + case 'O': + direction = 0x00000002; + packet_preamble[0] = ' '; + break; + default: + direction = 0x00000000; + break; + } + i = 0; + while (packet_preamble[i] == ' ' || + packet_preamble[i] == '\r' || + packet_preamble[i] == '\t') { + i++; + } + packet_preamble_len -= i; + memmove(packet_preamble, packet_preamble+i, packet_preamble_len); + } + /* * If no "-t" flag was specified, don't attempt to parse a packet * preamble to extract a time stamp. @@ -599,11 +633,6 @@ parse_preamble (void) timecode = timecode_default; ts_usec = 0; - /* - * Null-terminate the preamble. - */ - packet_preamble[packet_preamble_len] = '\0'; - /* Ensure preamble has more than two chars before atempting to parse. * This should cover line breaks etc that get counted. */ @@ -896,6 +925,8 @@ text_import_setup(text_import_info_t *info) (info->offset_type == OFFSET_DEC) ? 10 : 16; + has_direction = info->has_direction; + if (info->date_timestamp) { ts_fmt = info->date_timestamp_format; -- cgit v1.2.1