aboutsummaryrefslogtreecommitdiffstats
path: root/packet.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-08-14 04:23:22 +0000
committerGuy Harris <guy@alum.mit.edu>1999-08-14 04:23:22 +0000
commit6572382f9a72c7b232f18a1c4bc2368fa2eb27d2 (patch)
treead35c97188e889c736148e8441989c11b422f01f /packet.c
parentc7a00d29f8d4b8c54f3190e86a0f81ecbb4979f0 (diff)
downloadwireshark-6572382f9a72c7b232f18a1c4bc2368fa2eb27d2.tar.gz
wireshark-6572382f9a72c7b232f18a1c4bc2368fa2eb27d2.tar.bz2
wireshark-6572382f9a72c7b232f18a1c4bc2368fa2eb27d2.zip
Have the "delta" format for time stamps show the time delta between a
packet and the previous *displayed* packet, rather than the previous packet in a capture. svn path=/trunk/; revision=486
Diffstat (limited to 'packet.c')
-rw-r--r--packet.c108
1 files changed, 42 insertions, 66 deletions
diff --git a/packet.c b/packet.c
index a34564df70..732983d2c9 100644
--- a/packet.c
+++ b/packet.c
@@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
- * $Id: packet.c,v 1.35 1999/08/04 04:37:45 guy Exp $
+ * $Id: packet.c,v 1.36 1999/08/14 04:23:21 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -57,7 +57,6 @@
#include "packet.h"
#include "file.h"
-#include "timestamp.h"
extern capture_file cf;
@@ -70,6 +69,10 @@ gchar *
ether_to_str(const guint8 *ad) {
static gchar str[3][18];
static gchar *cur;
+ gchar *p;
+ int i;
+ guint32 octet;
+ static const gchar hex_digits[16] = "0123456789abcdef";
if (cur == &str[0][0]) {
cur = &str[1][0];
@@ -78,15 +81,30 @@ ether_to_str(const guint8 *ad) {
} else {
cur = &str[0][0];
}
- sprintf(cur, "%02x:%02x:%02x:%02x:%02x:%02x", ad[0], ad[1], ad[2],
- ad[3], ad[4], ad[5]);
- return cur;
+ p = &cur[18];
+ *--p = '\0';
+ i = 5;
+ for (;;) {
+ octet = ad[i];
+ *--p = hex_digits[octet&0xF];
+ octet >>= 4;
+ *--p = hex_digits[octet&0xF];
+ if (i == 0)
+ break;
+ *--p = ':';
+ i--;
+ }
+ return p;
}
gchar *
ip_to_str(const guint8 *ad) {
static gchar str[3][16];
static gchar *cur;
+ gchar *p;
+ int i;
+ guint32 octet;
+ guint32 digit;
if (cur == &str[0][0]) {
cur = &str[1][0];
@@ -95,8 +113,25 @@ ip_to_str(const guint8 *ad) {
} else {
cur = &str[0][0];
}
- sprintf(cur, "%d.%d.%d.%d", ad[0], ad[1], ad[2], ad[3]);
- return cur;
+ p = &cur[16];
+ *--p = '\0';
+ i = 3;
+ for (;;) {
+ octet = ad[i];
+ *--p = (octet%10) + '0';
+ octet /= 10;
+ digit = octet%10;
+ octet /= 10;
+ if (digit != 0 || octet != 0)
+ *--p = digit + '0';
+ if (octet != 0)
+ *--p = octet + '0';
+ if (i == 0)
+ break;
+ *--p = '.';
+ i--;
+ }
+ return p;
}
#define PLURALIZE(n) (((n) > 1) ? "s" : "")
@@ -557,54 +592,6 @@ check_col(frame_data *fd, gint el) {
return FALSE;
}
-/* To do: Add check_col checks to the col_add* routines */
-
-static void
-col_add_abs_time(frame_data *fd, gint el)
-{
- struct tm *tmp;
- time_t then;
-
- then = fd->abs_secs;
- tmp = localtime(&then);
- col_add_fstr(fd, el, "%02d:%02d:%02d.%04ld",
- tmp->tm_hour,
- tmp->tm_min,
- tmp->tm_sec,
- (long)fd->abs_usecs/100);
-}
-
-static void
-col_add_rel_time(frame_data *fd, gint el)
-{
- col_add_fstr(fd, el, "%d.%06d", fd->rel_secs, fd->rel_usecs);
-}
-
-static void
-col_add_delta_time(frame_data *fd, gint el)
-{
- col_add_fstr(fd, el, "%d.%06d", fd->del_secs, fd->del_usecs);
-}
-
-/* Add "command-line-specified" time. */
-void
-col_add_cls_time(frame_data *fd)
-{
- switch (timestamp_type) {
- case ABSOLUTE:
- col_add_abs_time(fd, COL_CLS_TIME);
- break;
-
- case RELATIVE:
- col_add_rel_time(fd, COL_CLS_TIME);
- break;
-
- case DELTA:
- col_add_delta_time(fd, COL_CLS_TIME);
- break;
- }
-}
-
/* Adds a vararg list to a packet info string. */
void
col_add_fstr(frame_data *fd, gint el, gchar *format, ...) {
@@ -639,17 +626,6 @@ dissect_packet(const u_char *pd, frame_data *fd, proto_tree *tree)
struct timeval tv;
/* Put in frame header information. */
- if (check_col(fd, COL_CLS_TIME))
- col_add_cls_time(fd);
- if (check_col(fd, COL_ABS_TIME))
- col_add_abs_time(fd, COL_ABS_TIME);
- if (check_col(fd, COL_REL_TIME))
- col_add_rel_time(fd, COL_REL_TIME);
- if (check_col(fd, COL_DELTA_TIME))
- col_add_delta_time(fd, COL_DELTA_TIME);
- if (check_col(fd, COL_PACKET_LENGTH))
- col_add_fstr(fd, COL_PACKET_LENGTH, "%d", fd->pkt_len);
-
if (tree) {
ti = proto_tree_add_item_format(tree, proto_frame, 0, fd->cap_len,
NULL, "Frame (%d on wire, %d captured)", fd->pkt_len, fd->cap_len);