Fix indentation (tab stops are not guaranteed to be every 4 spaces).
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 3 May 2011 05:28:39 +0000 (05:28 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 3 May 2011 05:28:39 +0000 (05:28 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@36971 f5534014-38df-0310-8fa8-9805f1628bb7

wiretap/network_instruments.c

index f5ccd4f6e38e87edec7eb57836b527f3d17ea3f2..87654a96c5fc0ac5c118fdc6d596b793fb3bd177 100644 (file)
@@ -44,7 +44,7 @@ static const guint32 observer_packet_magic = 0x88888888;
 typedef struct {
     guint64 packet_count;
     guint8  network_type;
-       guint32 time_format;
+    guint32 time_format;
 } observer_dump_private_state;
 
 /*
@@ -79,7 +79,7 @@ static time_t gmt_to_localtime_offset = (time_t) -1;
  
 static void init_gmt_to_localtime_offset(void)
 {
-       if (gmt_to_localtime_offset == (time_t) -1) {
+    if (gmt_to_localtime_offset == (time_t) -1) {
         time_t ansi_epoch_plus_one_day = 86400;
         struct tm gmt_tm;
         struct tm local_tm;
@@ -110,7 +110,7 @@ static int read_packet_header(FILE_T fh, packet_entry_header *packet_header,
 static int read_packet_data(FILE_T fh, int offset_to_frame, int current_offset_from_packet_header,
     guint8 *pd, int length, int *err, char **err_info);
 static gboolean skip_to_next_packet(wtap *wth, int offset_to_next_packet, 
-       int current_offset_from_packet_header, int *err, char **err_info);
+    int current_offset_from_packet_header, int *err, char **err_info);
 static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
     const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
 static gint observer_to_wtap_encap(int observer_encap);
@@ -118,149 +118,149 @@ static gint wtap_to_observer_encap(int wtap_encap);
 
 int network_instruments_open(wtap *wth, int *err, gchar **err_info)
 {
-       int bytes_read;
-       int offset;
-       capture_file_header file_header;
-       guint i;
-       tlv_header tlvh;
-       int seek_increment;
-       int header_offset;
-       packet_entry_header packet_header;
-       observer_dump_private_state * private_state = NULL;
-
-       errno = WTAP_ERR_CANT_READ;
-       offset = 0;
-
-       /* read in the buffer file header */
-       bytes_read = file_read(&file_header, sizeof file_header, wth->fh);
-       if (bytes_read != sizeof file_header) {
-               *err = file_error(wth->fh, err_info);
-               if (*err != 0)
-                       return -1;
-               return 0;
-       }
-       offset += bytes_read;
-       CAPTURE_FILE_HEADER_FROM_LE_IN_PLACE(file_header);
-
-       /* check if version info is present */
-       if (memcmp(file_header.observer_version, network_instruments_magic, true_magic_length)!=0) {
-               return 0;
-       }
+    int bytes_read;
+    int offset;
+    capture_file_header file_header;
+    guint i;
+    tlv_header tlvh;
+    int seek_increment;
+    int header_offset;
+    packet_entry_header packet_header;
+    observer_dump_private_state * private_state = NULL;
+
+    errno = WTAP_ERR_CANT_READ;
+    offset = 0;
+
+    /* read in the buffer file header */
+    bytes_read = file_read(&file_header, sizeof file_header, wth->fh);
+    if (bytes_read != sizeof file_header) {
+        *err = file_error(wth->fh, err_info);
+        if (*err != 0)
+            return -1;
+        return 0;
+    }
+    offset += bytes_read;
+    CAPTURE_FILE_HEADER_FROM_LE_IN_PLACE(file_header);
+
+    /* check if version info is present */
+    if (memcmp(file_header.observer_version, network_instruments_magic, true_magic_length)!=0) {
+        return 0;
+    }
 
     /* initialize the private state */
     private_state = (observer_dump_private_state *) g_malloc(sizeof(observer_dump_private_state));
-       private_state->time_format = TIME_INFO_LOCAL;
-       wth->priv = (void *) private_state;
-
-       /* get the location of the first packet */
-       /* v15 and newer uses high byte offset, in previous versions it will be 0 */
-       header_offset = file_header.offset_to_first_packet + ((int)(file_header.offset_to_first_packet_high_byte)<<16);
-
-       /* process extra information */
-       for (i = 0; i < file_header.number_of_information_elements; i++) {
-               /* for safety break if we've reached the first packet */
-               if (offset >= header_offset)
-                       break;
-
-               /* read the TLV header */
-               bytes_read = file_read(&tlvh, sizeof tlvh, wth->fh);
-               if (bytes_read != sizeof tlvh) {
-                       *err = file_error(wth->fh, err_info);
-                       if (*err == 0)
-                               *err = WTAP_ERR_SHORT_READ;
-                       return -1;
-               }
-               offset += bytes_read;
-               TLV_HEADER_FROM_LE_IN_PLACE(tlvh);
-
-               if (tlvh.length < sizeof tlvh) {
-                       *err = WTAP_ERR_BAD_RECORD;
-                       *err_info = g_strdup_printf("Observer: bad record (TLV length %u < %lu)",
-                           tlvh.length, (unsigned long)sizeof tlvh);
-                       return -1;
-               }
-
-                /* process (or skip over) the current TLV */
-               switch (tlvh.type) {
-               case INFORMATION_TYPE_TIME_INFO:
-                       bytes_read = file_read(&private_state->time_format, sizeof private_state->time_format, wth->fh);
-                       if (bytes_read != sizeof private_state->time_format) {
-                               *err = file_error(wth->fh, err_info);
-                               if(*err == 0)
-                                       *err = WTAP_ERR_SHORT_READ;
-                               return -1;
-                       }
-                       private_state->time_format = GUINT32_FROM_LE(private_state->time_format);
-                       offset += bytes_read;
-                       break;
-               default:
-                       seek_increment = tlvh.length - (int)sizeof tlvh;
-                       if (seek_increment > 0) {
-                               if (file_seek(wth->fh, seek_increment, SEEK_CUR, err) == -1)
-                                       return -1;
-                       }
-                       offset += seek_increment;
-               }
-       }
-
-       /* get to the first packet */
-       if (header_offset < offset) {
-               *err = WTAP_ERR_BAD_RECORD;
-               *err_info = g_strdup_printf("Observer: bad record (offset to first packet %d < %d)",
-                   header_offset, offset);
-               return FALSE;
-       }
-       seek_increment = header_offset - offset;
-       if (seek_increment > 0) {
-               if (file_seek(wth->fh, seek_increment, SEEK_CUR, err) == -1)
-                       return -1;
-       }
-
-       /* pull off the packet header */
-       bytes_read = file_read(&packet_header, sizeof packet_header, wth->fh);
-       if (bytes_read != sizeof packet_header) {
-               *err = file_error(wth->fh, err_info);
-               if (*err != 0)
-                       return -1;
-               return 0;
-       }
-       PACKET_ENTRY_HEADER_FROM_LE_IN_PLACE(packet_header);
-
-       /* check the packet's magic number */
-       if (packet_header.packet_magic != observer_packet_magic) {
-               *err = WTAP_ERR_UNSUPPORTED_ENCAP;
-               *err_info = g_strdup_printf("Observer: unsupported packet version %ul", packet_header.packet_magic);
-               return -1;
-       }
-
-       /* check the data link type */
-       if (observer_to_wtap_encap(packet_header.network_type) == WTAP_ENCAP_UNKNOWN) {
-               *err = WTAP_ERR_UNSUPPORTED_ENCAP;
-               *err_info = g_strdup_printf("Observer: network type %u unknown or unsupported", packet_header.network_type);
-               return -1;
-       }
-       wth->file_encap = observer_to_wtap_encap(packet_header.network_type);
-
-       /* set up the rest of the capture parameters */
+    private_state->time_format = TIME_INFO_LOCAL;
+    wth->priv = (void *) private_state;
+
+    /* get the location of the first packet */
+    /* v15 and newer uses high byte offset, in previous versions it will be 0 */
+    header_offset = file_header.offset_to_first_packet + ((int)(file_header.offset_to_first_packet_high_byte)<<16);
+
+    /* process extra information */
+    for (i = 0; i < file_header.number_of_information_elements; i++) {
+        /* for safety break if we've reached the first packet */
+        if (offset >= header_offset)
+            break;
+
+        /* read the TLV header */
+        bytes_read = file_read(&tlvh, sizeof tlvh, wth->fh);
+        if (bytes_read != sizeof tlvh) {
+            *err = file_error(wth->fh, err_info);
+            if (*err == 0)
+                *err = WTAP_ERR_SHORT_READ;
+            return -1;
+        }
+        offset += bytes_read;
+        TLV_HEADER_FROM_LE_IN_PLACE(tlvh);
+
+        if (tlvh.length < sizeof tlvh) {
+            *err = WTAP_ERR_BAD_RECORD;
+            *err_info = g_strdup_printf("Observer: bad record (TLV length %u < %lu)",
+                tlvh.length, (unsigned long)sizeof tlvh);
+            return -1;
+        }
+
+        /* process (or skip over) the current TLV */
+        switch (tlvh.type) {
+        case INFORMATION_TYPE_TIME_INFO:
+            bytes_read = file_read(&private_state->time_format, sizeof private_state->time_format, wth->fh);
+            if (bytes_read != sizeof private_state->time_format) {
+                *err = file_error(wth->fh, err_info);
+                if(*err == 0)
+                    *err = WTAP_ERR_SHORT_READ;
+                return -1;
+            }
+            private_state->time_format = GUINT32_FROM_LE(private_state->time_format);
+            offset += bytes_read;
+            break;
+        default:
+            seek_increment = tlvh.length - (int)sizeof tlvh;
+            if (seek_increment > 0) {
+                if (file_seek(wth->fh, seek_increment, SEEK_CUR, err) == -1)
+                    return -1;
+            }
+            offset += seek_increment;
+        }
+    }
+
+    /* get to the first packet */
+    if (header_offset < offset) {
+        *err = WTAP_ERR_BAD_RECORD;
+        *err_info = g_strdup_printf("Observer: bad record (offset to first packet %d < %d)",
+            header_offset, offset);
+        return FALSE;
+    }
+    seek_increment = header_offset - offset;
+    if (seek_increment > 0) {
+        if (file_seek(wth->fh, seek_increment, SEEK_CUR, err) == -1)
+            return -1;
+    }
+
+    /* pull off the packet header */
+    bytes_read = file_read(&packet_header, sizeof packet_header, wth->fh);
+    if (bytes_read != sizeof packet_header) {
+        *err = file_error(wth->fh, err_info);
+        if (*err != 0)
+            return -1;
+        return 0;
+    }
+    PACKET_ENTRY_HEADER_FROM_LE_IN_PLACE(packet_header);
+
+    /* check the packet's magic number */
+    if (packet_header.packet_magic != observer_packet_magic) {
+        *err = WTAP_ERR_UNSUPPORTED_ENCAP;
+        *err_info = g_strdup_printf("Observer: unsupported packet version %ul", packet_header.packet_magic);
+        return -1;
+    }
+
+    /* check the data link type */
+    if (observer_to_wtap_encap(packet_header.network_type) == WTAP_ENCAP_UNKNOWN) {
+        *err = WTAP_ERR_UNSUPPORTED_ENCAP;
+        *err_info = g_strdup_printf("Observer: network type %u unknown or unsupported", packet_header.network_type);
+        return -1;
+    }
+    wth->file_encap = observer_to_wtap_encap(packet_header.network_type);
+
+    /* set up the rest of the capture parameters */
     private_state->packet_count = 0;
     private_state->network_type = wtap_to_observer_encap(wth->file_encap);
-       wth->subtype_read = observer_read;
-       wth->subtype_seek_read = observer_seek_read;
-       wth->subtype_close = NULL;
-       wth->subtype_sequential_close = NULL;
-       wth->snapshot_length = 0;       /* not available in header */
-       wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
-       wth->file_type = WTAP_FILE_NETWORK_INSTRUMENTS;
-
-       /* reset the pointer to the first packet */
-       if (file_seek(wth->fh, header_offset, SEEK_SET,
-           err) == -1)
-               return -1;
-       wth->data_offset = header_offset;
-
-       init_gmt_to_localtime_offset();
-
-       return 1;
+    wth->subtype_read = observer_read;
+    wth->subtype_seek_read = observer_seek_read;
+    wth->subtype_close = NULL;
+    wth->subtype_sequential_close = NULL;
+    wth->snapshot_length = 0;    /* not available in header */
+    wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
+    wth->file_type = WTAP_FILE_NETWORK_INSTRUMENTS;
+
+    /* reset the pointer to the first packet */
+    if (file_seek(wth->fh, header_offset, SEEK_SET,
+        err) == -1)
+        return -1;
+    wth->data_offset = header_offset;
+
+    init_gmt_to_localtime_offset();
+
+    return 1;
 }
 
 /* Reads the next packet. */
@@ -269,56 +269,56 @@ static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
 {
     int bytes_consumed;
     int offset_from_packet_header = 0;
-       packet_entry_header packet_header;
+    packet_entry_header packet_header;
 
-       /* skip records other than data records */
-       for (;;) {
-               *data_offset = wth->data_offset;
+    /* skip records other than data records */
+    for (;;) {
+        *data_offset = wth->data_offset;
 
-               /* process the packet header, including TLVs */
-               bytes_consumed = read_packet_header(wth->fh, &packet_header, err,
-                   err_info);
-               if (bytes_consumed <= 0)
-                       return FALSE;   /* EOF or error */
+        /* process the packet header, including TLVs */
+        bytes_consumed = read_packet_header(wth->fh, &packet_header, err,
+            err_info);
+        if (bytes_consumed <= 0)
+            return FALSE;    /* EOF or error */
 
-               wth->data_offset += bytes_consumed;
+        wth->data_offset += bytes_consumed;
 
-               if (packet_header.packet_type == PACKET_TYPE_DATA_PACKET)
-                       break;
+        if (packet_header.packet_type == PACKET_TYPE_DATA_PACKET)
+            break;
 
         /* skip to next packet */
         offset_from_packet_header = (int) (wth->data_offset - *data_offset);
         if (!skip_to_next_packet(wth, packet_header.offset_to_next_packet,
                 offset_from_packet_header, err, err_info)) {
-            return FALSE;      /* EOF or error */
+            return FALSE;    /* EOF or error */
         }
-       }
-
-       /* neglect frame markers for wiretap */
-       if (packet_header.network_size < 4) {
-               *err = WTAP_ERR_BAD_RECORD;
-               *err_info = g_strdup_printf("Observer: bad record: Packet length %u < 4",
-                   packet_header.network_size);
-               return FALSE;
-       }
-
-       /* set the wiretap packet header fields */
-       wth->phdr.pkt_encap = observer_to_wtap_encap(packet_header.network_type);
-       if(wth->file_encap == WTAP_ENCAP_FIBRE_CHANNEL_FC2_WITH_FRAME_DELIMS) {
-               wth->phdr.len = packet_header.network_size;
-               wth->phdr.caplen = packet_header.captured_size;
-       } else {
-               wth->phdr.len = packet_header.network_size - 4;
-               wth->phdr.caplen = MIN(packet_header.captured_size, wth->phdr.len);
-       }
-
-       /* set the wiretap timestamp, assuming for the moment that Observer encoded it in GMT */
+    }
+
+    /* neglect frame markers for wiretap */
+    if (packet_header.network_size < 4) {
+        *err = WTAP_ERR_BAD_RECORD;
+        *err_info = g_strdup_printf("Observer: bad record: Packet length %u < 4",
+            packet_header.network_size);
+        return FALSE;
+    }
+
+    /* set the wiretap packet header fields */
+    wth->phdr.pkt_encap = observer_to_wtap_encap(packet_header.network_type);
+    if(wth->file_encap == WTAP_ENCAP_FIBRE_CHANNEL_FC2_WITH_FRAME_DELIMS) {
+        wth->phdr.len = packet_header.network_size;
+        wth->phdr.caplen = packet_header.captured_size;
+    } else {
+        wth->phdr.len = packet_header.network_size - 4;
+        wth->phdr.caplen = MIN(packet_header.captured_size, wth->phdr.len);
+    }
+
+    /* set the wiretap timestamp, assuming for the moment that Observer encoded it in GMT */
     wth->phdr.ts.secs = (time_t) ((packet_header.nano_seconds_since_2000 / 1000000000) + ansi_to_observer_epoch_offset);
     wth->phdr.ts.nsecs = (int) (packet_header.nano_seconds_since_2000 % 1000000000);
 
     /* adjust to local time, if necessary, also accounting for DST if the frame
        was captured while it was in effect */
-       if (((observer_dump_private_state*)wth->priv)->time_format == TIME_INFO_LOCAL)
+    if (((observer_dump_private_state*)wth->priv)->time_format == TIME_INFO_LOCAL)
     {
         struct tm daylight_tm;
         struct tm standard_tm;
@@ -338,16 +338,16 @@ static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
         }
     }
 
-       /* update the pseudo header */
-       switch (wth->file_encap) {
-       case WTAP_ENCAP_ETHERNET:
-               /* There is no FCS in the frame */
-               wth->pseudo_header.eth.fcs_len = 0;
-               break;
-       }
+    /* update the pseudo header */
+    switch (wth->file_encap) {
+    case WTAP_ENCAP_ETHERNET:
+        /* There is no FCS in the frame */
+        wth->pseudo_header.eth.fcs_len = 0;
+        break;
+    }
 
-       /* set-up the packet buffer */
-       buffer_assure_space(wth->frame_buffer, packet_header.captured_size);
+    /* set-up the packet buffer */
+    buffer_assure_space(wth->frame_buffer, packet_header.captured_size);
 
     /* read the frame data */
     offset_from_packet_header = (int) (wth->data_offset - *data_offset);
@@ -374,183 +374,183 @@ static gboolean observer_seek_read(wtap *wth, gint64 seek_off,
     union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
     int *err, gchar **err_info)
 {
-       packet_entry_header packet_header;
-       int offset;
+    packet_entry_header packet_header;
+    int offset;
 
-       if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+    if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
+        return FALSE;
 
-       /* process the packet header, including TLVs */
-       offset = read_packet_header(wth->random_fh, &packet_header, err,
-           err_info);
-       if (offset <= 0)
-               return FALSE;   /* EOF or error */
+    /* process the packet header, including TLVs */
+    offset = read_packet_header(wth->random_fh, &packet_header, err,
+        err_info);
+    if (offset <= 0)
+        return FALSE;    /* EOF or error */
 
-       /* update the pseudo header */
-       switch (wth->file_encap) {
+    /* update the pseudo header */
+    switch (wth->file_encap) {
 
-       case WTAP_ENCAP_ETHERNET:
-               /* There is no FCS in the frame */
-               pseudo_header->eth.fcs_len = 0;
-               break;
-       }
+    case WTAP_ENCAP_ETHERNET:
+        /* There is no FCS in the frame */
+        pseudo_header->eth.fcs_len = 0;
+        break;
+    }
 
-       /* read the frame data */
-       if (!read_packet_data(wth->random_fh, packet_header.offset_to_frame,
-           offset, pd, length, err, err_info))
-               return FALSE;
+    /* read the frame data */
+    if (!read_packet_data(wth->random_fh, packet_header.offset_to_frame,
+        offset, pd, length, err, err_info))
+        return FALSE;
 
-       return TRUE;
+    return TRUE;
 }
 
 static int
 read_packet_header(FILE_T fh, packet_entry_header *packet_header, int *err,
     gchar **err_info)
 {
-       int offset;
-       int bytes_read;
-       guint i;
-       tlv_header tlvh;
-       int seek_increment;
-
-       offset = 0;
-
-       /* pull off the packet header */
-       bytes_read = file_read(packet_header, sizeof *packet_header, fh);
-       if (bytes_read != sizeof *packet_header) {
-               *err = file_error(fh, err_info);
-               if (*err != 0)
-                       return -1;
-               return 0;       /* EOF */
-       }
-       offset += bytes_read;
+    int offset;
+    int bytes_read;
+    guint i;
+    tlv_header tlvh;
+    int seek_increment;
+
+    offset = 0;
+
+    /* pull off the packet header */
+    bytes_read = file_read(packet_header, sizeof *packet_header, fh);
+    if (bytes_read != sizeof *packet_header) {
+        *err = file_error(fh, err_info);
+        if (*err != 0)
+            return -1;
+        return 0;    /* EOF */
+    }
+    offset += bytes_read;
     PACKET_ENTRY_HEADER_FROM_LE_IN_PLACE(*packet_header);
 
-       /* check the packet's magic number */
-       if (packet_header->packet_magic != observer_packet_magic) {
-
-               /*
-                * Some files are zero-padded at the end. There is no warning of this
-                * in the previous packet header information, such as setting
-                * offset_to_next_packet to zero. So detect this situation by treating
-                * an all-zero header as a sentinel. Return EOF when it is encountered,
-                * rather than treat it as a bad record.
-                */
-               for (i = 0; i < sizeof *packet_header; i++) {
-                       if (((guint8*) packet_header)[i] != 0)
-                               break;
-               }
-               if (i == sizeof *packet_header) {
-                       *err = 0;
-                       return 0;       /* EOF */
-               }
-
-               *err = WTAP_ERR_BAD_RECORD;
-               *err_info = g_strdup_printf("Observer: bad record: Invalid magic number 0x%08x",
-                   GUINT32_FROM_LE(packet_header->packet_magic));
-               return -1;
-       }
-
-       /* process extra information */
-       for (i = 0; i < packet_header->number_of_information_elements; i++) {
-               /* read the TLV header */
-               bytes_read = file_read(&tlvh, sizeof tlvh, fh);
-               if (bytes_read != sizeof tlvh) {
-                       *err = file_error(fh, err_info);
-                       if (*err == 0)
-                               *err = WTAP_ERR_SHORT_READ;
-                       return -1;
-               }
-               offset += bytes_read;
+    /* check the packet's magic number */
+    if (packet_header->packet_magic != observer_packet_magic) {
+
+        /*
+         * Some files are zero-padded at the end. There is no warning of this
+         * in the previous packet header information, such as setting
+         * offset_to_next_packet to zero. So detect this situation by treating
+         * an all-zero header as a sentinel. Return EOF when it is encountered,
+         * rather than treat it as a bad record.
+         */
+        for (i = 0; i < sizeof *packet_header; i++) {
+            if (((guint8*) packet_header)[i] != 0)
+                break;
+        }
+        if (i == sizeof *packet_header) {
+            *err = 0;
+            return 0;    /* EOF */
+        }
+
+        *err = WTAP_ERR_BAD_RECORD;
+        *err_info = g_strdup_printf("Observer: bad record: Invalid magic number 0x%08x",
+            GUINT32_FROM_LE(packet_header->packet_magic));
+        return -1;
+    }
+
+    /* process extra information */
+    for (i = 0; i < packet_header->number_of_information_elements; i++) {
+        /* read the TLV header */
+        bytes_read = file_read(&tlvh, sizeof tlvh, fh);
+        if (bytes_read != sizeof tlvh) {
+            *err = file_error(fh, err_info);
+            if (*err == 0)
+                *err = WTAP_ERR_SHORT_READ;
+            return -1;
+        }
+        offset += bytes_read;
         TLV_HEADER_FROM_LE_IN_PLACE(tlvh);
 
-               if (tlvh.length < sizeof tlvh) {
-                       *err = WTAP_ERR_BAD_RECORD;
-                       *err_info = g_strdup_printf("Observer: bad record (TLV length %u < %lu)",
-                           tlvh.length, (unsigned long)sizeof tlvh);
-                       return -1;
-               }
-
-               /* skip the TLV data */
-               seek_increment = tlvh.length - (int)sizeof tlvh;
-               if (seek_increment > 0) {
-                       if (file_seek(fh, seek_increment, SEEK_CUR, err) == -1)
-                               return -1;
-               }
-               offset += seek_increment;
-       }
-
-       return offset;
+        if (tlvh.length < sizeof tlvh) {
+            *err = WTAP_ERR_BAD_RECORD;
+            *err_info = g_strdup_printf("Observer: bad record (TLV length %u < %lu)",
+                tlvh.length, (unsigned long)sizeof tlvh);
+            return -1;
+        }
+
+        /* skip the TLV data */
+        seek_increment = tlvh.length - (int)sizeof tlvh;
+        if (seek_increment > 0) {
+            if (file_seek(fh, seek_increment, SEEK_CUR, err) == -1)
+                return -1;
+        }
+        offset += seek_increment;
+    }
+
+    return offset;
 }
 
 static int
 read_packet_data(FILE_T fh, int offset_to_frame, int current_offset_from_packet_header, guint8 *pd, 
     int length, int *err, char **err_info)
 {
-       int seek_increment;
-       int bytes_consumed = 0;
+    int seek_increment;
+    int bytes_consumed = 0;
  
-       /* validate offsets */
-       if (offset_to_frame < current_offset_from_packet_header) {
-               *err = WTAP_ERR_BAD_RECORD;
-               *err_info = g_strdup_printf("Observer: bad record (offset to packet data %d < %d)",
-                   offset_to_frame, current_offset_from_packet_header);
-               return -1;
-       }
+    /* validate offsets */
+    if (offset_to_frame < current_offset_from_packet_header) {
+        *err = WTAP_ERR_BAD_RECORD;
+        *err_info = g_strdup_printf("Observer: bad record (offset to packet data %d < %d)",
+            offset_to_frame, current_offset_from_packet_header);
+        return -1;
+    }
 
     /* skip to the packet data */
-       seek_increment = offset_to_frame - current_offset_from_packet_header;
-       if (seek_increment > 0) {
-               if (file_seek(fh, seek_increment, SEEK_CUR, err) == -1) {
-                       return -1;
+    seek_increment = offset_to_frame - current_offset_from_packet_header;
+    if (seek_increment > 0) {
+        if (file_seek(fh, seek_increment, SEEK_CUR, err) == -1) {
+            return -1;
         }
         bytes_consumed += seek_increment;
-       }
+    }
 
-       /* read in the packet data */
-       wtap_file_read_expected_bytes(pd, length, fh, err, err_info);
+    /* read in the packet data */
+    wtap_file_read_expected_bytes(pd, length, fh, err, err_info);
     bytes_consumed += length;
 
-       return bytes_consumed;
+    return bytes_consumed;
 }
 
 static gboolean
 skip_to_next_packet(wtap *wth, int offset_to_next_packet, int current_offset_from_packet_header, int *err,
     char **err_info)
 {
-       int seek_increment;
+    int seek_increment;
  
     /* validate offsets */
-       if (offset_to_next_packet < current_offset_from_packet_header) {
-               *err = WTAP_ERR_BAD_RECORD;
-               *err_info = g_strdup_printf("Observer: bad record (offset to next packet %d < %d)",
-                   offset_to_next_packet, current_offset_from_packet_header);
-               return FALSE;
-       }
+    if (offset_to_next_packet < current_offset_from_packet_header) {
+        *err = WTAP_ERR_BAD_RECORD;
+        *err_info = g_strdup_printf("Observer: bad record (offset to next packet %d < %d)",
+            offset_to_next_packet, current_offset_from_packet_header);
+        return FALSE;
+    }
 
     /* skip to the next packet header */
-       seek_increment = offset_to_next_packet - current_offset_from_packet_header;
-       if (seek_increment > 0) {
-               if (file_seek(wth->fh, seek_increment, SEEK_CUR, err) == -1)
-                       return FALSE;
-               wth->data_offset += seek_increment;
-       }
-
-       return TRUE;
+    seek_increment = offset_to_next_packet - current_offset_from_packet_header;
+    if (seek_increment > 0) {
+        if (file_seek(wth->fh, seek_increment, SEEK_CUR, err) == -1)
+            return FALSE;
+        wth->data_offset += seek_increment;
+    }
+
+    return TRUE;
 }
 
 /* Returns 0 if we could write the specified encapsulation type,
    an error indication otherwise. */
 int network_instruments_dump_can_write_encap(int encap)
 {
-       /* per-packet encapsulations aren't supported */
-       if (encap == WTAP_ENCAP_PER_PACKET)
-               return WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED;
-       
-       if (encap < 0 || (wtap_to_observer_encap(encap) == OBSERVER_UNDEFINED))
-               return WTAP_ERR_UNSUPPORTED_ENCAP;
-
-       return 0;
+    /* per-packet encapsulations aren't supported */
+    if (encap == WTAP_ENCAP_PER_PACKET)
+        return WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED;
+    
+    if (encap < 0 || (wtap_to_observer_encap(encap) == OBSERVER_UNDEFINED))
+        return WTAP_ERR_UNSUPPORTED_ENCAP;
+
+    return 0;
 }
 
 /* Returns TRUE on success, FALSE on failure; sets "*err" to an error code on
@@ -561,7 +561,7 @@ gboolean network_instruments_dump_open(wtap_dumper *wdh, int *err)
     capture_file_header file_header;
 
     tlv_header comment_header;
-       tlv_time_info time_header;
+    tlv_time_info time_header;
     char comment[64];
     size_t comment_length;
     struct tm * current_time;
@@ -571,7 +571,7 @@ gboolean network_instruments_dump_open(wtap_dumper *wdh, int *err)
     private_state = (observer_dump_private_state *) g_malloc(sizeof(observer_dump_private_state));
     private_state->packet_count = 0;
     private_state->network_type = wtap_to_observer_encap(wdh->encap);
-       private_state->time_format = TIME_INFO_GMT;
+    private_state->time_format = TIME_INFO_GMT;
  
     /* populate the fields of wdh */
     wdh->priv = (void *) private_state;
@@ -579,9 +579,9 @@ gboolean network_instruments_dump_open(wtap_dumper *wdh, int *err)
 
     /* initialize the file header */
     memset(&file_header, 0x00, sizeof(file_header));
-       g_strlcpy(file_header.observer_version, network_instruments_magic, 31);
+    g_strlcpy(file_header.observer_version, network_instruments_magic, 31);
     file_header.offset_to_first_packet = (guint16)sizeof(file_header);
-       file_header.offset_to_first_packet_high_byte = 0;
+    file_header.offset_to_first_packet_high_byte = 0;
 
     /* create the file comment TLV */
     {
@@ -601,9 +601,9 @@ gboolean network_instruments_dump_open(wtap_dumper *wdh, int *err)
 
     /* create the timestamp encoding TLV */
     {
-               time_header.type = INFORMATION_TYPE_TIME_INFO;
-               time_header.length = (guint16) (sizeof(time_header));
-               time_header.time_format = TIME_INFO_GMT;
+        time_header.type = INFORMATION_TYPE_TIME_INFO;
+        time_header.length = (guint16) (sizeof(time_header));
+        time_header.time_format = TIME_INFO_GMT;
 
         /* update the file header to account for the timestamp encoding TLV */
         file_header.number_of_information_elements++;
@@ -633,7 +633,7 @@ gboolean network_instruments_dump_open(wtap_dumper *wdh, int *err)
 
     /* write the time info TLV */
     {
-               TLV_TIME_INFO_TO_LE_IN_PLACE(time_header);
+        TLV_TIME_INFO_TO_LE_IN_PLACE(time_header);
         if (!wtap_dump_file_write(wdh, &time_header, sizeof(time_header), err)) {
             return FALSE;
         }
@@ -658,11 +658,11 @@ static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
     /* convert the number of seconds since epoch from ANSI-relative to
        Observer-relative */
     if (phdr->ts.secs < ansi_to_observer_epoch_offset) {
-               if(phdr->ts.secs > (time_t) 0) {
-                       seconds_since_2000 = phdr->ts.secs;
-               } else {
-                       seconds_since_2000 = (time_t) 0;
-               }
+        if(phdr->ts.secs > (time_t) 0) {
+            seconds_since_2000 = phdr->ts.secs;
+        } else {
+            seconds_since_2000 = (time_t) 0;
+        }
     } else {
         seconds_since_2000 = phdr->ts.secs - ansi_to_observer_epoch_offset;
     }
@@ -705,30 +705,30 @@ static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
 
 static gint observer_to_wtap_encap(int observer_encap)
 {
-       switch(observer_encap) {
-       case OBSERVER_ETHERNET:
-               return WTAP_ENCAP_ETHERNET;
-       case OBSERVER_TOKENRING:
-               return WTAP_ENCAP_TOKEN_RING;
-       case OBSERVER_FIBRE_CHANNEL:
-               return WTAP_ENCAP_FIBRE_CHANNEL_FC2_WITH_FRAME_DELIMS;
-       case OBSERVER_UNDEFINED:
-               return WTAP_ENCAP_UNKNOWN;
-       }
-       return WTAP_ENCAP_UNKNOWN;
+    switch(observer_encap) {
+    case OBSERVER_ETHERNET:
+        return WTAP_ENCAP_ETHERNET;
+    case OBSERVER_TOKENRING:
+        return WTAP_ENCAP_TOKEN_RING;
+    case OBSERVER_FIBRE_CHANNEL:
+        return WTAP_ENCAP_FIBRE_CHANNEL_FC2_WITH_FRAME_DELIMS;
+    case OBSERVER_UNDEFINED:
+        return WTAP_ENCAP_UNKNOWN;
+    }
+    return WTAP_ENCAP_UNKNOWN;
 }
 
 static gint wtap_to_observer_encap(int wtap_encap)
 {
-       switch(wtap_encap) {
-       case WTAP_ENCAP_ETHERNET:
-               return OBSERVER_ETHERNET;
-       case WTAP_ENCAP_TOKEN_RING:
-               return OBSERVER_TOKENRING;
-       case WTAP_ENCAP_FIBRE_CHANNEL_FC2_WITH_FRAME_DELIMS:
-               return OBSERVER_FIBRE_CHANNEL;
-       case WTAP_ENCAP_UNKNOWN:
-               return OBSERVER_UNDEFINED;
-       }
-       return OBSERVER_UNDEFINED;
-}
\ No newline at end of file
+    switch(wtap_encap) {
+    case WTAP_ENCAP_ETHERNET:
+        return OBSERVER_ETHERNET;
+    case WTAP_ENCAP_TOKEN_RING:
+        return OBSERVER_TOKENRING;
+    case WTAP_ENCAP_FIBRE_CHANNEL_FC2_WITH_FRAME_DELIMS:
+        return OBSERVER_FIBRE_CHANNEL;
+    case WTAP_ENCAP_UNKNOWN:
+        return OBSERVER_UNDEFINED;
+    }
+    return OBSERVER_UNDEFINED;
+}