Store the packet encapsulation type as gint8. Saves 3 bytes per packet

svn path=/trunk/; revision=29767
This commit is contained in:
Kovarththanan Rajaratnam 2009-09-07 13:54:46 +00:00
parent 4fbc99e411
commit a65d590002
5 changed files with 16 additions and 7 deletions

View File

@ -326,7 +326,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
tvb, pinfo, parent_tree)) {
col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN");
col_add_fstr(pinfo->cinfo, COL_INFO, "WTAP_ENCAP = %u",
col_add_fstr(pinfo->cinfo, COL_INFO, "WTAP_ENCAP = %d",
pinfo->fd->lnk_t);
call_dissector(data_handle,tvb, pinfo, parent_tree);
}

View File

@ -44,7 +44,8 @@ typedef struct _frame_data {
guint32 pkt_len; /* Packet length */
guint32 cap_len; /* Amount actually captured */
guint32 cum_bytes; /* Cumulative bytes into the capture */
int lnk_t; /* Per-packet encapsulation/data-link type */
gint64 file_off; /* File offset */
gint8 lnk_t; /* Per-packet encapsulation/data-link type */
struct {
unsigned int passed_dfilter : 1; /* 1 = display, 0 = no display */
unsigned int encoding : 2; /* Character encoding (ASCII, EBCDIC...) */
@ -52,13 +53,15 @@ typedef struct _frame_data {
unsigned int marked : 1; /* 1 = marked by user, 0 = normal */
unsigned int ref_time : 1; /* 1 = marked as a reference time frame, 0 = normal */
} flags;
void *color_filter; /* Per-packet matching color_filter_t object */
nstime_t abs_ts; /* Absolute timestamp */
nstime_t rel_ts; /* Relative timestamp (yes, it can be negative) */
nstime_t del_dis_ts; /* Delta timestamp to previous displayed frame (yes, it can be negative) */
nstime_t del_cap_ts; /* Delta timestamp to previous captured frame (yes, it can be negative) */
gint64 file_off; /* File offset */
gchar **col_text; /* The column text for some columns, see colum_utils */
gchar **col_text; /* The column text for some columns, see colum_utils */
guint *col_text_len; /* The length of the column text strings in 'col_text' */
} frame_data;

4
file.c
View File

@ -1259,7 +1259,9 @@ read_packet(capture_file *cf, dfilter_t *dfcode,
fdata->pkt_len = phdr->len;
fdata->cap_len = phdr->caplen;
fdata->file_off = offset;
fdata->lnk_t = phdr->pkt_encap;
/* To save some memory, we coarcese it into a gint8 */
g_assert(phdr->pkt_encap <= G_MAXINT8);
fdata->lnk_t = (gint8) phdr->pkt_encap;
fdata->flags.encoding = CHAR_ASCII;
fdata->flags.visited = 0;
fdata->flags.marked = 0;

View File

@ -1019,7 +1019,9 @@ fill_in_fdata(frame_data *fdata, capture_file *cf,
fdata->cum_bytes = cum_bytes;
fdata->cap_len = phdr->caplen;
fdata->file_off = offset;
fdata->lnk_t = phdr->pkt_encap;
/* To save some memory, we coarcese it into a gint8 */
g_assert(phdr->pkt_encap <= G_MAXINT8);
fdata->lnk_t = (gint8) phdr->pkt_encap;
fdata->abs_ts.secs = phdr->ts.secs;
fdata->abs_ts.nsecs = phdr->ts.nsecs;
fdata->flags.passed_dfilter = 0;

View File

@ -2394,7 +2394,9 @@ fill_in_fdata(frame_data *fdata, capture_file *cf,
fdata->cum_bytes = cum_bytes;
fdata->cap_len = phdr->caplen;
fdata->file_off = offset;
fdata->lnk_t = phdr->pkt_encap;
/* To save some memory, we coarcese it into a gint8 */
g_assert(phdr->pkt_encap <= G_MAXINT8);
fdata->lnk_t = (gint8) phdr->pkt_encap;
fdata->abs_ts.secs = phdr->ts.secs;
fdata->abs_ts.nsecs = phdr->ts.nsecs;
fdata->flags.passed_dfilter = 0;