Make the V10 path a bit more like the other paths.

Provide {FULL,PART}SIZEDEFV10 macros, similar to what's provided for the
other versions, containing the code to set the packet length and
captured data length, and use the TRACE_V10_REC_LEN_OFF() macro directly
after that to set the various length and offset values in the
pseudo-header.

Change-Id: I3513371057601b44821d89ebaa7565ab370a67f5
Reviewed-on: https://code.wireshark.org/review/7393
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2015-02-25 13:04:59 -08:00
parent 1a3dd34923
commit 0692d75455
1 changed files with 17 additions and 13 deletions

View File

@ -485,17 +485,6 @@ typedef struct nspr_pktracepart_v26
__TNV1L(phdr,enumprefix,structprefix,structname,nicno,phd.ph_DevNo)\
__TNDO(phdr,enumprefix,structname,eth)
#define TRACE_FULL_V10_REC_LEN_OFF(phdr,enumprefix,structprefix,structname) \
(phdr)->len = pletoh16(&(fp)->nsprRecordSize);\
(phdr)->caplen = (phdr)->len;\
TRACE_V10_REC_LEN_OFF(phdr,enumprefix,structprefix,structname)
#define TRACE_PART_V10_REC_LEN_OFF(phdr,enumprefix,structprefix,structname) \
(phdr)->presence_flags |= WTAP_HAS_CAP_LEN;\
(phdr)->len = pletoh16(&pp->pp_PktSizeOrg) + nspr_pktracepart_v10_s;\
(phdr)->caplen = pletoh16(&pp->nsprRecordSize);\
TRACE_V10_REC_LEN_OFF(phdr,enumprefix,structprefix,structname)
#define TRACE_V20_REC_LEN_OFF(phdr,enumprefix,structprefix,structname) \
__TNO(phdr,enumprefix,structprefix,structname,dir,RecordType)\
__TNL(phdr,enumprefix,structprefix,structname,dir,RecordType)\
@ -900,6 +889,19 @@ static gboolean nstrace_set_start_time(wtap *wth)
/*
** Netscaler trace format read routines.
*/
#define PARTSIZEDEFV10(phdr,pp,ver) \
do {\
(phdr)->presence_flags |= WTAP_HAS_CAP_LEN;\
(phdr)->len = pletoh16(&pp->pp_PktSizeOrg) + nspr_pktracepart_v##ver##_s;\
(phdr)->caplen = pletoh16(&pp->nsprRecordSize);\
}while(0)
#define FULLSIZEDEFV10(phdr,fp,ver) \
do {\
(phdr)->len = pletoh16(&(fp)->nsprRecordSize);\
(phdr)->caplen = (phdr)->len;\
}while(0)
#define PACKET_DESCRIBE(phdr,FULLPART,fullpart,ver,type,HEADERVER) \
do {\
nspr_pktrace##fullpart##_v##ver##_t *type = (nspr_pktrace##fullpart##_v##ver##_t *) &nstrace_buf[nstrace_buf_offset];\
@ -913,7 +915,8 @@ static gboolean nstrace_set_start_time(wtap *wth)
nsg_creltime += ns_hrtime2nsec(pletoh32(&type->type##_RelTimeHr));\
(phdr)->ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);\
(phdr)->ts.nsecs = (guint32) (nsg_creltime % 1000000000);\
TRACE_##FULLPART##_V##ver##_REC_LEN_OFF(phdr,v##ver##_##fullpart,type,pktrace##fullpart##_v##ver);\
FULLPART##SIZEDEFV##ver((phdr),type,ver);\
TRACE_V##ver##_REC_LEN_OFF((phdr),v##ver##_##fullpart,type,pktrace##fullpart##_v##ver);\
ws_buffer_assure_space(wth->frame_buffer, (phdr)->caplen);\
memcpy(ws_buffer_start_ptr(wth->frame_buffer), type, (phdr)->caplen);\
*data_offset = nstrace->xxx_offset + nstrace_buf_offset;\
@ -1309,7 +1312,8 @@ static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *
* the previous packet.\
*/\
(phdr)->presence_flags = 0;\
TRACE_##FULLPART##_V##ver##_REC_LEN_OFF(phdr,v##ver##_##fullpart,type,pktrace##fullpart##_v##ver);\
FULLPART##SIZEDEFV##ver((phdr),type,ver);\
TRACE_V##ver##_REC_LEN_OFF(phdr,v##ver##_##fullpart,type,pktrace##fullpart##_v##ver);\
(phdr)->pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##HEADERVER;\
}while(0)